akhauriyash/Code-Regression huggingface dataset:
n, m = map(int, input().split())
ab_list = list()
for _ in range(m):
    a, b = map(int, input().split())
    ab_list.append([a, b])
ab_list = sorted(ab_list, key=lambda x: x[1])
x = -1
ans = 0
for a, b in ab_list:
    if a <= x:
        continue
    else:
        x = b-1
        ans += 1
print(ans)

Measured memory_bytes: 22108
#include<stdio.h>
int main()
{
	int a, b, c;
	int k;
	int n;

	scanf("%d%d%d", &a, &b, &c);
	n = 0;
	for (k = a; k <= b; k++) {
		if (c % k == 0) n++;
	}
	printf("%d\n", n);
	return 0;

}


Measured memory_bytes: 2760
package main

import "fmt"

func main() {
	var S string
	fmt.Scan(&S)
	ans, n := 0, len(S)
	for i := 0; i < n; i++ {
		j := i
		for j < n && ok(S[j]) {
			j++
		}
		ans = Max(ans, j-i)
		i = j
	}
	fmt.Println(ans)
}

func ok(c byte) bool { return c == 'A' || c == 'C' || c == 'G' || c == 'T' }

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


Measured memory_bytes: 1768
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 250005;

int n, x[MAXN], y[MAXN];

struct pque{
	bool neg;
	lint offset = 0;
	priority_queue<lint> pq;
	void push(lint x){
		if(neg) x = -x;
		pq.push(x - offset);
	}
	lint top(){
		lint x = pq.top() + offset;
		if(neg) x = -x;
		return x;
	}
	void pop(){
		pq.pop();
	}
	void add_offset(lint x){
		if(neg) x = -x;
		offset += x;
	}
}pql, pqr;

int main(){
	scanf("%d",&n);
	lint ans = 0;
	pqr.neg = 1;
	for(int i=0; i<n; i++){
		scanf("%d %d",&x[i],&y[i]);
		y[i] -= x[i];
		if(i > 0){
			pql.add_offset(-y[i]);
			pqr.add_offset(y[i - 1]);
			if(pqr.top() < x[i]){
				ans += x[i] - pqr.top();
				pqr.push(x[i]);
				pqr.push(x[i]);
				pql.push(pqr.top());
				pqr.pop();
			}
			else if(pql.top() > x[i]){
				ans += pql.top() - x[i];
				pql.push(x[i]);
				pql.push(x[i]);
				pqr.push(pql.top());
				pql.pop();
			}
			else{
				pql.push(x[i]);
				pqr.push(x[i]);
			}
		}
		else{
			pql.push(x[i]);
			pqr.push(x[i]);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2796
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sS = System.Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            if (sS.Length == 3) { sS = string.Join("", sS.Reverse()); }

            // 出力
            System.Console.WriteLine("{0}", sS.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

}


Measured memory_bytes: 11348
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i,m,n) for(ll i=m ; i<n ; i++)
#define forr(i,m,n) for(ll i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N =2e5+5;
using namespace std;
int main()
{
    IO;
    int n;
    cin>>n;
    ll freq[10][10]= {};
    forr(i,1,n)
    {
        string s=to_string(i);
        int u=s[0]-'0',v=s.back()-'0';
        freq[u][v]++;
    }
    ll ans=0;
    rep(i,0,10)
    {
        rep(j,0,10)
        {
            ans+=freq[i][j]*freq[j][i];
        }
    }


    cout<<ans;








}


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

#define endl '\n'
#define ff first
#define ss second
#define mp make_pair
#define pb push_back

typedef long long llong;
typedef pair<int, int> pii;

void solve(){

	string str;
	cin >> str;

	stack<char> s;
	for(char c : str){
		
		if(c == 'T'){

			if(!s.empty() && s.top() == 'S') s.pop();
			else s.push(c);

		}else{
			s.push(c);
		}

	}

	cout << s.size();

}

int main(){

	ios_base::sync_with_stdio(0);
	cin.tie(0);

	#ifdef LOCAL
		ifstream in("in");
		cin.rdbuf(in.rdbuf());
	#endif

	solve();

	return 0;
	
}

Measured memory_bytes: 720
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007
//S.size()
//配列名.Length()
using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<bool> VB;
typedef unsigned long long ll;

int main(void){
	string S; cin>>S;
	int cnt = 0;
	int cnt2 = 0;
	int num;
	bool jud1 = false,jud2 = false, jud3 = false;
	if(S[0] == 'A')jud1 = true;
  for(int i = 2; i <= S.size() - 2; i++){
		if(S[i] == 'C'){
			cnt++;
			num = i;
		}
	}
	if(cnt == 1)jud2 = true;

  for(int j = 0; j < S.size(); j++){
		if(j != 0 && j != num && isupper(S[j])){
			cnt2++;
		}
	}

	if(cnt2 == 0)jud3 = true;

	cout<<(jud1 && jud2 && jud3?"AC":"WA");
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<vector>
#include<climits>
#define ll long long int
using namespace std;
int main(void) {
  int x;
  int ans=1;
  cin>>x;
  for(int i=2; i<=sqrt(x); i++) {
    for(int j=2; ; j++) {
      int y=pow(i, j);
      if(y>x) break;
      else ans = max(y, ans);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string S;
    int N;
    cin>>S;
    int cnt=0;
    N=S.length();
    //cout<<N<<endl;
    string now=S.substr(0,1);
    for(int i=0;i<N-1;){
        int k=1;
        while(now==S.substr(i+1,k)){
            if(i+1+k==N){
                cnt--;
                break;
            }
            k++;
        }
        //cout<<now<<"==" <<S.substr(i+1,k)<<endl;
        now=S.substr(i+1,k);
        i+=k;
        cnt++;
    }
    cout<<cnt+1<<endl;
}


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

char S[112345];
long long int ans;

int main(void) {
	scanf("%s", &S);
	for (int i = 0; i < strlen(S) - 1; ++i) {
		if (S[i] != S[i + 1]) { ans++; }
	}
	printf("%lld\n", ans);
	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 rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    cout << (n+1)/2 << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
template<class T, class Compare = less<T> >
using MaxHeap = priority_queue<T, vector<T>, Compare>;
template<class T, class Compare = greater<T> >
using MinHeap = priority_queue<T, vector<T>, Compare>;
using llong = long long;

llong n;
llong a[25];
llong b[25];
llong c[25];
llong sum = 0;

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

    for (int i = 1; i <= n; i++) {
        sum += b[a[i]];

        if (i >= 2) {
            if (a[i] - a[i - 1] == 1) {
                sum += c[a[i - 1]];
            }
        }
    }

    cout << sum << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  long n,rn,i,ans;
  scanf("%ld",&n);
  rn=0;
  while (rn*rn<=n) rn++;
  i=1;
  while (i<rn){
    if (!(n%i)) ans=i;
    i++;
  }
  printf("%ld\n",ans+n/ans-2);
  return 0;
}
    

Measured memory_bytes: 128
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[][] d = new int[N][2];
        for(int n=0; n<N; n++){
            d[n][0] = sc.nextInt();
            d[n][1] = sc.nextInt();
        }

        for(int n=0; n<N-2; n++){
            if(d[n][0]==d[n][1] && d[n+1][0]==d[n+1][1] && d[n+2][0]==d[n+2][1]){
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");        
    }
}

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

int main() {
    string s;
    cin >> s;
    int len = s.size();
    int cnt = 0;
    for (int i = 0; i < len / 2; i++) {
        if (s.at(i) != s.at(len - i - 1)) cnt++;
    }
    cout << cnt << endl;
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;

    int s1, s2;
    s1 = a * b;
    s2 = c * d;

    if (s1 >= s2) {
        cout << s1 << endl;
    }
    else {
        cout << s2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#nyuuryoku
food=[]
for i in range (5):
  food.append(int(input()))
time = 0

#1keta toru 10 watte amari dasu
#amari wo dasu
machi = []
for i in range (5):
  if food[i]%10 == 0:
    time += food[i]
  else:
    time += food[i]+(10-(food[i]%10))
    machi.append(10-(food[i]%10)) 

if len(machi) == 0:
  print(time)
else:
  print(time-max(machi))  
    

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

const int MAX_N = 1e5 + 1;
int N;
int par[MAX_N];
int UFTrank[MAX_N];

void init(int n) {
   for (int i = 0; i < n; i++) {
      par[i] = i;
      UFTrank[i] = 0;
   }
}

int find(int x) {
   if (par[x] == x) {
      return x;
   } else {
      return par[x] = find(par[x]);
   }
}

void unite(int x, int y) {
   x = find(x);
   y = find(y);
   if (x == y) return;

   if (UFTrank[x] < UFTrank[y]) {
      par[x] = y;
   } else {
      par[y] = x;
      if (UFTrank[x] == UFTrank[y]) UFTrank[x]++;
   }
}

bool same(int x, int y) {
   return find(x) == find(y);
}       

struct edge { int u, v, cost; };

bool comp(const edge& e1, const edge& e2) {
   return e1.cost < e2.cost;
}

edge es[MAX_N * 2];

int main() {
   cin >> N;
   vector<ipair> x, y;
   int tmp1, tmp2;
   for (int i = 0; i < N; i++) {
      cin >> tmp1 >> tmp2;
      x.push_back(ipair(i, tmp1));
      y.push_back(ipair(i, tmp2));
   }
   sort(x.begin(), x.end() , lessPair); 
   sort(y.begin(), y.end() , lessPair); 
   int E = 0;
   int cnt = 0;
   for (auto it = x.begin(); it != x.end(); it++) {
      if (cnt == 0) {
         tmp1 = it->first;
         tmp2 = it->second;
         cnt++;
         continue;
      }
      es[E].u = tmp1;
      es[E].v = it->first;
      es[E].cost = abs(it->second - tmp2);
      tmp1 = it->first;
      tmp2 = it->second;
      cnt++;
      E++;
   }
   cnt = 0;
   for (auto it = y.begin(); it != y.end(); it++) {
      if (cnt == 0) {
         tmp1 = it->first;
         tmp2 = it->second;
         cnt++;
         continue;
      }
      es[E].u = tmp1;
      es[E].v = it->first;
      es[E].cost = abs(it->second - tmp2);
      tmp1 = it->first;
      tmp2 = it->second;
      cnt++;
      E++;
   }
   int V = N;
   sort(es, es + E, comp);
   init(V);
   int ans = 0;

   for (int i = 0; i < E; i++) {
      edge e = es[i];
      if (!same(e.u, e.v)) {
         unite(e.u, e.v);
         ans += e.cost;
      }
   }

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


Measured memory_bytes: 5100
#include <iostream>
#include <cmath>
#include <vector>
#include <iomanip>
#include <algorithm>
using namespace std;

void print_vector(vector<int> num)
{
	for(int i = 0; i < num.size(); i++){
		if(i){
			cout << " ";
		}
		cout << num[i];
	}
	cout << endl;
}
int SelectionSort(vector<int> &A)
{	
	int count = 0;
	for(int i = 0; i <= A.size() - 1; i++){
		int mini= i;
		for(int j = i; j <= A.size() - 1; j++){
			if(A[j] < A[mini]){
				mini = j;
			}
		}
		if(i != mini){
			count++;
			int a = A[i];
			A[i] = A[mini];
			A[mini] = a;
		}
	}
	return count;
}
int main(void)
{
	int n;
	cin >> n;
	vector<int> A(n);
	for(int i = 0; i < n; i++){
		cin >> A[i];
	}
	
	int count = SelectionSort(A);
	
	print_vector(A);
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC127
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] ab= Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ans = 0;
            if (ab[0] > 12) { ans = ab[1]; }
            else if (ab[0] > 5) { ans = ab[1] / 2; }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define INF (1LL<<59)
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define whoami(x) cerr<<#x<<" "<<x<<"\n";
#define mp make_pair
#define ins insert
#define sz size

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];
bool fx[MV];

void solve(int T)
{
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=k;i++)
	{
		int s;
		cin>>s;
		for(int j=0;j<s;j++)
		{
			int tx;
			cin>>tx;
			fx[tx] = 1;
		}	
	}
	int yt = 0;
	for(int i=1;i<=n;i++)
	yt += !fx[i];
	cout<<yt<<"\n";
	return;	
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3656
n=int(input())
p=list(map(int,input().split()))
count=0
ans="YES"
for i in range(1,n+1):
    p_i=p.index(i)
    if p_i!=i-1:
        if p[i-1]==p_i+1 and count<=2:
            count+=1
        else:
            ans="NO"
            break
print(ans)

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;

vec<vll> dp;
/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(30);

    int n, weight;
    cin >> n >> weight;
    vi w(n), v(n);
    rep(i,n) cin >> w[i] >> v[i];
    dp.resize(n+1, vll(100001, infll));
    dp[0][0] = 0;  // 初期条件忘れ

    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= 100000; ++j) {
            if(j-v[i] >= 0) chmin(dp[i+1][j], dp[i][j-v[i]] + w[i]);
            chmin(dp[i+1][j], dp[i][j]);
        }
    }
   int ans;
    for(int j = 100000; j >= 0; --j) {
        if(dp[n][j] <= weight) {
            ans = j;
            break;
        }
    }
    cout << ans << '\n';

   // 復元
    // int i = n-1;
    // int j = ans;
    // while(i>=0&&j>=0) {
    //     if(j-v[i] >= 0 && dp[i+1][j] == dp[i][j-v[i]]+w[i]) {
    //         cout << i+1 << '\n';
    //         j = j-v[i];
    //         --i;
    //     }
    //     else --i;
    // }
}

Measured memory_bytes: 80256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int dp[5050][5050];

int main() {
    int n; cin >> n;
    string s; cin >> s;
    for (int i=n-1; i>=0; --i) {
        for (int j=n-1; j>=0; --j) {
            if (s[i]==s[j]) dp[i][j] = dp[i+1][j+1]+1;
        }
    }
    //rep(i,n)rep(j,n) cout << "i: " << i << " j: " << j  << " dp: " << dp[i][j] << endl;
    int ans = 0;
    rep(i,n)rep(j,n) {
        ans = max(ans, min(dp[i][j],j-i));
    }
    cout << ans << endl;
    return 0;
}
















Measured memory_bytes: 98944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int d[100][100], len[100][100];
int prev[100];
int n, m;

void warshall_floyed(){
  for(int k = 0; k < n; k++)
    for(int i = 0; i < n; i++)
      for(int j = 0; j < n; j++)
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
}
          

int main(){
  cin >> n >> m;
  rep(i, 100) fill(d[i], d[i] + 100, INF);
  rep(i, 100) fill(len[i], len[i] + 100, INF);
  rep(i, 100) d[i][i] = 0;
  rep(i, m){
    int a, b, c;
    cin >> a >> b >> c;
    a--;b--;
    len[a][b] = c;
    len[b][a] = c;
    d[a][b] = c;
    d[b][a] = c;
  }
  warshall_floyed();
  set<P> s;
  for(int i = 0; i < n; i++)
    for(int j = 0; j < n; j++)
      for(int k = 0; k < n; k++)
        //i to j で k to j　の辺を通ったか否か
        if(d[i][j] == d[i][k] + len[k][j]){
          if(k < j) s.insert(P(k, j));
          else s.insert(P(j, k));
        }
  cout << m - int(s.size()) <<endl;
}
  

Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using Graph = vector<vector<int>>;
using P = pair<int,int>;
using ll =long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

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

int main(){
    int h,w;
    cin >> h >> w;

    vector<string> a(h);
    rep(i,h) cin >> a[i];


    queue<P> q;
    vector<vector<int>> d(h,vector<int>(w,-1));
    
    rep(i,h) rep(j,w){
        if(a[i][j]=='#'){
            q.push(make_pair(i,j));
            d[i][j]=0;
        }
    }
    int ans = 0;
    while(!q.empty()){
        P p = q.front();
        q.pop();
        //a[p.first][p.second] = '#';
        //cout << "e1" << endl;
        rep(i,4){
            int nx=p.first + dx[i];
            int ny=p.second + dy[i];

            if(nx>=0 && nx<h && ny>=0 && ny<w && a[nx][ny]!='#' /*&& d[nx][ny]==-1*/){
                d[nx][ny] = d[p.first][p.second] + 1;
                ans = d[nx][ny];
                a[nx][ny] = '#';
                q.push(make_pair(nx,ny));
            }
        }
        //cout << "e2" << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13456
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	string s, t; cin >> s >> t;
	int x = stoi(s+t);
	for(int i = 1; i <= 1000; ++i){
		if(i*i == x){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}


Measured memory_bytes: 256
n = int( input( ) )
dic = {}
output = []
for i in range( n ):
	cmd, word = input( ).split( " " )
	if "insert" == cmd:
		dic[ word ] = True
	elif "find" == cmd:
		try:
			dic[ word ]
			output.append( "yes" )
		except KeyError:
			output.append( "no" )

print( "\n".join( output ) )

Measured memory_bytes: 59556
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

ll cmemo[1002][1002];
ll dp[1002][1002];

ll modpow(ll x, ll n){
    ll res = 1;
    ll mul = x;
    while(n){
        if(n % 2) res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

ll com(int n, int k){
    if(cmemo[n][k]) return cmemo[n][k];
    if(k == 0 || k == n) return 1;
    return cmemo[n][k] = (com(n - 1, k) + com(n - 1, k - 1)) % MOD;
}

int main()
{
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    ll r[1002];
    for(int i = 1; i <= n; i++) r[i] = modpow(i, MOD - 2);
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++){
        for(int k = 0; k <= n; k++) dp[i][k] = dp[i - 1][k];
        if(i < a || i > b) continue;
        for(int k = 0; k <= n; k++){
            ll s = 1;
            for(int j = 1; j * i <= k; j++){
                s = s * com((n - k) + i * j, i) % MOD * r[j] % MOD;
                if(j >= c && j <= d) dp[i][k] = (dp[i][k] + dp[i - 1][k - j * i] * s % MOD) % MOD;
            }
        }
    }
    cout << dp[n][n] << endl;
}

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

using namespace std;

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

    for(int i=1;i<=9;i++)
    {
        double b;
        b = (double)n /(double)i; 
        //cout<<"i and n/i "<< i<<" "<<b<<endl; 
        
        if(b>=1 && b<=9 && n%i==0)
        {
            
            cout<<"Yes"<<endl;
            return 0; 
        }
    }
    cout<<"No"<<endl; 

    return 0; 
}



Measured memory_bytes: 256
#include <stdio.h>
using namespace std;

int main(){
  int N, a, b, c, t;
  scanf("%d", &N);
  for(int i=0;i<N;i++){
    scanf("%d %d %d", &a, &b, &c);
    if(a<b){
      t=a; a=b; b=t;
    }
    if(a<c){
      t=a; a=c; c=t;
    }
    if(a*a == b*b + c*c) printf("YES");
    else printf("NO");
    printf("\n");
  }
  return 0;
}



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

int main()
{
  int n, m;
  int k, x;
  cin >> n >> m;
  int a[m];
  rep(i, m){
    a[i] = 0;
  }
  rep(i, n){
    cin >> k;
    rep(j, k){
      cin >> x;
      a[x - 1]++;
    }
  }
  int ans = 0;
  rep(i, m){
    if(a[i] == n) ans++;
  }
  cout << ans << endl;
      
  return 0;
}

Measured memory_bytes: 3588
package main

import (
	"fmt"
)

func main() {
	var n, q int
	var a []int

	// 特定の値が何個あるか
	nums := make(map[int]int, 100005)
	var sum int

	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var temp int
		fmt.Scan(&temp)
		a = append(a, temp)
		nums[temp]++
		sum += temp
	}
	fmt.Scan(&q)
	for j := 0; j < q; j++ {
		//log.Println("----------")
		//log.Println("変換前", nums)
		var b, c int
		fmt.Scan(&b, &c)

		//
		nums[c] += nums[b]
		sum += (c - b) * nums[b]
		nums[b] = 0
		//log.Println(b, "=>", c)
		//log.Println("変換後", nums)
		fmt.Println(sum)
	}
}


Measured memory_bytes: 10432
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;

int fdp(const auto A, auto &dp, int N, int T){
  for(int i=1;i<=N;i++){
    int a=A[i].first;
    int b=A[i].second;
    for(int j=0;j<T;j++){
      if(j<a) dp[i][j]=dp[i-1][j];
      else dp[i][j]=max(dp[i-1][j],dp[i-1][j-a]+b);
    }
  }
  return 0;
}

int main(){
  int N,T;
  cin >> N >> T;

  vector<pair<int,int>> A(N+2,make_pair(0,0));
  for(int i=1;i<N+1;i++) cin >> A[i].first >> A[i].second;
  
  vector<vector<int>> dp1(N+1,vector<int>(T,0));
  vector<vector<int>> dp2(N+1,vector<int>(T,0));

  fdp(A, dp1, N, T);
  reverse(A.begin(),A.end());
  fdp(A, dp2, N, T);
  reverse(A.begin(),A.end());
  
  int ans=0;
  for(int i=1;i<=N;i++){
    int b=A[i].second;
    for(int j=0;j<T;j++){
      ans=max(ans,dp1[i-1][j]+dp2[N-i][T-1-j]+b);
    }
  }

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


Measured memory_bytes: 70912
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
    vector<int> time(3);
    for(int i = 0;i < 3;i++){
        cin >> time[i];
    }
    sort(time.begin(), time.end());
    cout << time[0]+time[1] << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N, M; scanf("%d %d", &N, &M);
  vector<ll> X(N), Y(M);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", &X[i]);
  }
  for (int i = 0; i < M; ++i) {
    scanf("%lld", &Y[i]);
  }
  sort(X.begin(), X.end());
  sort(Y.begin(), Y.end());
  ll sx = 0, sy = 0;
  for (int i = 0; i < N; ++i) {
    sx += X[i] * (2 * i - N + 1);
  }
  for (int i = 0; i < M; ++i) {
    sy += Y[i] * (2 * i - M + 1);
  }
  sx %= MOD;
  sy %= MOD;
  ll ans = (sx * sy) % MOD;
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    char c[4]; cin >> c;

    if ((c[0] == c[1] && c[0] == c[2]) || (c[1] == c[2] && c[2] == c[3])) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
template<class T> void debug(T a) { for (auto iiiiiiiiii : a)cout << iiiiiiiiii << endl; }
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

int main()
{
	int n[2];
	while (cin >> n[0]&&n[0])
	{
		int t[2];
		int h, m;
		cin >> h >> m;
		t[0] = h * 60 + m;
		cin >> n[1];
		cin >> h >> m;
		t[1] = h * 60 + m;
		int x[][8] = { {0,0,0,0,0,0,0,0},{0,0,300,500,600,700,1350,1650},{0,0,0,350,450,600,1150,1500},{0,0,0,0,250,400,1000,1350},{0,0,0,0,0,250,850,1300},{0,0,0,0,0,0,600,1150},{0,0,0,0,0,0,0,500} };
		int ans = x[min(n[0], n[1])][max(n[0], n[1])];
		int p = 0;
		if (17 * 60 + 30 <= t[0] && t[0] <= 19 * 60 + 30)p++;
		if (17 * 60 + 30 <= t[1] && t[1] <= 19 * 60 + 30)p++;
		int d[] = { 6,7,5,5,20,15 };
		int D = 0;
		if (n[0] > n[1])swap(n[0], n[1]);
		while (n[0] < n[1])
		{
			D += d[n[0]-1];
			n[0]++;
		}
		if (p && D <= 40)
		{
			ans /= 2;
			while (ans % 50)ans++;
		}
		cout << ans << endl;


	}

}

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

if N % 2: 
    T = [int(i+1) //2 * 2 for i in range(N)]
    if sorted(A) == T:
        print (2**(N//2) % (10 ** 9 + 7))
    else: 
        print(0)
        
else: 
    T = [int(i // 2 * 2 + 1)  for i in range(N)]
    if sorted(A) == T:
        print (2**(N//2) % (10 ** 9 + 7))
    else: 
        print(0)
        

Measured memory_bytes: 14008
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;

  ll ans;
  rep(i, n){
    ll a;
    cin >> a;
    if(i == 0) ans = a;
    else {
      ans = gcd(ans, a);
    }
  }

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


Measured memory_bytes: 3580
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define put(i) cout<<fixed<<i<<endl
using namespace std;
using ll = long long;


int main(){
    int n; cin >> n;
    ll ans = 1, mod = 1e9 + 7;

    for(ll i = 1; i <= n; i++){
        ans = (ans * i) % mod;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<sstream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int tot = 0,n;
	cin >> n;
	string s;
	cin >> s;
	int i = 0;
	char c = '0';
	while (i < n) {
			c = s[i];
			tot++;
			while (s[i] == c)
				i++;
	}
	cout << tot;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ld a, b, h, m;std::cin >> a >> b >> h >> m;
  ld x = h*60+m;
  ld mizikai = (ld)(2*M_PI*x/(ld)720.0);
  ld nagai = (ld)(2*M_PI*m/(ld)60.0);

  ld mx = a*sin(mizikai), my = a*cos(mizikai);
  ld nx = b*sin(nagai), ny = b*cos(nagai);

  ld ans = sqrt((mx-nx)*(mx-nx)+(my-ny)*(my-ny));
  std::cout << fixed << setprecision(20) << ans << '\n';
  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#define pb push_back
#define mp make_pair
#define pie 3.141592653589793238
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
/////////////////////////////////////////////////////////////////////
const ll mod = 1e9 + 7;
const int N = 1e6 + 9;
ll a[N][6];
ll dp[6][N];
vector <ll> v[N];
ll modexp(ll a, ll n)
{
    ll r = 1;
    while(n){
        if(n & 1)
            r = (r * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return r;
}
bool cmp(const pair<double, ll> &a, const pair<double, int> &b)
{
    if(a.first == b.first){
        return a.second < b.second;
    }
    else return a.first > b.first;
}
int main()
{
    fast;
    string a, b;
    cin >> a >> b;
    if(a.size() > b.size()){
        cout << "GREATER" << endl;
    }
    else if(a.size() < b.size()){
        cout << "LESS" << endl;
    }
    else {
        if(a == b){
            cout << "EQUAL" << endl;
        }
        else{
            for(int i = 0; i < a.size() ; i ++)
            {
                if(a[i] > b[i]){
                    cout << "GREATER" << endl;
                    return 0;
                }
                else if(b[i] > a[i]){
                        cout << "LESS" << endl;
                return 0;
                }
            }
            cout << "EQUAL" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 24832
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;

template <int M, bool IsPrime = false> class Modulo {
  int n;
  static typename std::enable_if<IsPrime, ll>::type inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
  }

public:
  Modulo() : n(0) { ; }
  Modulo(int m) : n(m) {
    if (n >= M)
      n %= M;
    else if (n < 0)
      n = (n % M + M) % M;
  }
  Modulo(ll m) {
    if (m >= M)
      m %= M;
    else if (m < 0)
      m = (m % M + M) % M;
    n = m;
  }
  explicit operator int() const { return n; }
  explicit operator ll() const { return n; }
  bool operator==(const Modulo &a) const { return n == a.n; }
  Modulo &operator+=(const Modulo &a) {
    n += a.n;
    if (n >= M) n -= M;
    return *this;
  }
  Modulo &operator-=(const Modulo &a) {
    n -= a.n;
    if (n < 0) n += M;
    return *this;
  }
  Modulo &operator*=(const Modulo &a) {
    n = (ll(n) * a.n) % M;
    return *this;
  }
  Modulo operator+(const Modulo &a) const {
    Modulo res = *this;
    return res += a;
  }
  Modulo operator-(const Modulo &a) const {
    Modulo res = *this;
    return res -= a;
  }
  Modulo operator-() const { return Modulo(0) - *this; }
  Modulo operator*(const Modulo &a) const {
    Modulo res = *this;
    return res *= a;
  }

  Modulo operator^(ll m) const {
    if (m == 0) return Modulo(1);
    const Modulo a = *this;
    Modulo res = (a * a) ^ (m / 2);
    return m % 2 ? res * a : res;
  }
  typename std::enable_if<IsPrime, Modulo>::type
  operator/(const Modulo &a) const {
    return *this * inv(ll(a), M);
  }
  typename std::enable_if<IsPrime, Modulo>::type operator/=(const Modulo &a) {
    return *this *= inv(ll(a), M);
  }

  friend bool is_zero(const Modulo &x) { return int(x) == 0; }
  friend int abs(const Modulo &x) { return int(x); }

  static Modulo fact(int n, bool sw = true) {
    static std::vector<Modulo> v1 = { 1 }, v2 = { 1 };
    if (n >= (int)v1.size()) {
      const int from = v1.size(), to = n + 1024;
      v1.reserve(to);
      v2.reserve(to);
      for (int i = from; i < to; ++i) {
        v1.push_back(v1.back() * Modulo<M, true>(i));
        v2.push_back(v2.back() / Modulo<M, true>(i));
      }
    }
    return sw ? v1[n] : v2[n];
  }
  static Modulo comb(int a, int b) {
    if (b < 0 || b > a) return 0;
    return Modulo::fact(a, true) * Modulo::fact(b, false) *
           Modulo::fact(a - b, false);
  }
};
using Mod = Modulo<998244353, true>;

int main(void)
{
  ll n,a,b,k;
  cin >> n >> a >> b >> k;
  Mod answer=0;
  REP(i,n+1) {
    ll lf = k - a*i;
    if(lf%b == 0 && lf/b <= n) answer += Mod::comb(n, i) * Mod::comb(n, lf/b);
  }
  cout << (ll)answer << endl;
  return 0;
}



Measured memory_bytes: 3740
#include <stdio.h>
#include <math.h>
#include <string.h>
int main(void) {
	char s1[10];
	char s2[10];
	char s3[10];

	scanf("%s%s%s", &s1, &s2, &s3);
	s1[0] -= 32;
	s2[0] -= 32;
	s3[0] -= 32;

	printf("%c%c%c", s1[0], s2[0], s3[0]);


	return 0;

}

Measured memory_bytes: 128
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 100000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    string s, t;
    cin>>s>>t;

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

    vector<vector<ll> > dp(n+1, vector<ll> (m+1, 0));

    for(int i=1; i<=n; i++){
        for(int j=1; j<=m; j++){
            if(s[i-1] == t[j-1]){
                dp[i][j] = 1 + dp[i-1][j-1];
            }
            else{
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }

    int i = n, j = m;
    string ans = "";

    while(i > 0 && j > 0){
        if(dp[i][j] == dp[i-1][j]){
            i--;
        }
        else if(dp[i][j] == dp[i][j-1]){
            j--;
        }
        else if(dp[i][j] == dp[i-1][j-1] + 1){
            ans += s[i-1];
            i--;
            j--;
        }
        else{
            break;
        }
    }

    reverse(ans.begin(), ans.end());

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 73672
N,W = map(int,input().split())

w = []
v = []

for i in range(N):
	a,b = map(int,input().split())
	w.append(a)
	v.append(b)

dp = [[0]*(W+1) for _ in range(N+1)]
for i in range(N):
	for sum_w in range(W+1):
		if sum_w - w[i] >=0:
			dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w - w[i]] + v[i])

		dp[i+1][sum_w] = max(dp[i+1][sum_w], dp[i][sum_w])

print(dp[N][W])

Measured memory_bytes: 120684
#include<stdio.h>
int main(void)
{
	int a,b,c,i,j,k,cnt,cnt1;
	char x[101][101];
	scanf("%d%d%d",&a,&b,&c);
	for(i=0;i<a;i++){
		for(j=0;j<b;j++) scanf(" %c",&x[i][j]);
	}
	cnt=0;
	for(i=0;i<a;i++){
		for(j=0;j<b;j++){
			if(x[i][j]=='.'){
				cnt1=1;
				for(k=1;k<c;k++){
					if(x[i][j+k]=='.') cnt1++;
					else break;
				}
				if(cnt1==c) cnt++;
				cnt1=1;
				for(k=1;k<c;k++){
					if(x[i+k][j]=='.') cnt1++;
					else break;
				}
				if(cnt1==c) cnt++;
			}
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 2740
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    rep(i,h) cin >> a[i];
    map<char,int> m;
    rep(i,h) rep(j,w) m[a[i][j]]++;
    if(h%2 == 0 && w%2 == 0) {
        for(auto p : m) {
            if(p.second < 4 || p.second%4 != 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    } else if(h%2 == 0) {
        int cnt4 = 0;
        for(auto p : m) {
            if(p.second < 2) {
                cout << "No" << endl;
                return 0;
            } else if(p.second%2 != 0) {
                cout << "No" << endl;
                return 0;
            } else {
                cnt4 += p.second/4;
            }
        }
        if(cnt4 < h*(w-1)/4) {
            cout << "No" << endl;
            return 0;
        }
    } else if(w%2 == 0) {
        int cnt4 = 0;
        for(auto p : m) {
            if(p.second < 2) {
                cout << "No" << endl;
                return 0;
            } else if(p.second%2 != 0) {
                cout << "No" << endl;
                return 0;
            } else {
                cnt4 += p.second/4;
            }
        }
        if(cnt4 < w*(h-1)/4) {
            cout << "No" << endl;
            return 0;
        }
    } else {
        int cnt4 = 0,cnt1 = 0;
        for(auto p : m) {
            if(p.second < 2) {
                cnt1++;
            } else if(p.second%2 != 0) {
                cnt1++;
                cnt4 += p.second/4;
            } else {
                cnt4 += p.second/4;
            }
        }
        if(cnt4 < (h-1)*(w-1)/4) {
            cout << "No" << endl;
            return 0;
        }
        if(cnt1 != 1) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.*;
 
 
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
    
    public  static void main(String[] args)   throws Exception, IOException{
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}
        int n=sc.nextInt();
        int d[] = new int[n];
        int ws=0,w=0;
        char c[]=sc.nextString().toCharArray();

        for(int i=0; i<n; i++) {
            if(c[i]=='W')ws++;
        }

        int ans=n ,es=0;

        for(int i=0; i<n; i++) {
            if(i>0 && c[i-1]=='W')w++;
            if(c[i]=='E')es++;
            ans = min(ans, n-ws-es+w);
        }


        out.println(ans);
        out.flush();
    }
    
    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
     
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }
    
    static boolean bit(long x,int k){
        // weather k-th bit (from right) be one or zero
        return  ( 0 < ( (x>>k) & 1 )  )  ? true:false;
    }    
}

class P implements Comparable<P>{
        int id, d;
        P(int  id, int d) {
            this.id=id;
            this.d=d;
        } 
          
        public int compareTo(P p){
            return d-p.d; //descend
        }
    }

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

int dp[55][3030];

int main() {

  int const MOD = 100000;

  for(int N, M, S; cin >> N >> M >> S && (N|M|S);) {
    rep(i, 55) rep(j, 3030)
      dp[i][j] = 0;

    dp[0][0] = 1;

    REP(i, 1, N * N + 1) {
      REP(j, i, S + 1) {
        dp[i][j] = (dp[i - 1][j - i] + dp[i][j - i]) % MOD;
        if(j >= M+1) {
          dp[i][j] -= dp[i - 1][j - M - 1];
          (dp[i][j] += MOD) %= MOD;
        }
      }
    }

    cout << dp[N*N][S] << endl;

  }
  
  return 0;
}

Measured memory_bytes: 3676