akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

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

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

int main() {
  int n;
  vector< pair<int, int> > p_red;
  vector< pair<int, int> > p_blue;

  cin >> n;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    p_red.pb(mp(a, b));
  }
  rep(i, n) {
    int c, d;
    cin >> c >> d;
    p_blue.pb(mp(c, d));
  }

  sort(all(p_red), greater< pair<int, int> >());
  sort(all(p_blue), comp);

  vector<bool> is_used;
  is_used.assign(n, false);
  int ans = 0;
  rep(i, n) {
    pair<int, int> red = p_red[i];
    rep(j, n) {
      pair<int, int> blue = p_blue[j];
      if( !is_used[j] && red.first < blue.first && red.second < blue.second ) {
        is_used[j] = true;
        ans++;
        break;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
object Main extends App {
    val in = io.Source.stdin.getLines.map(_.split(" ").map(_.toInt)).toSeq.tail
    val x = in.map(r => r :+ r.sum)
    val y = x.transpose.map(_.sum)
    x.foreach(r => println(r.mkString(" ")))
    println(y.mkString(" "))
}

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

using namespace std;
long long a,b;
map<char,int> mp1,mp2;
int n,res;
string s;
int check(int x){
int cnt=0;
    mp1.clear();
    mp2.clear();
    for (int i=0;i<=x;i++) mp1[s[i]]=1;
    for (int i=x+1;i<n;i++) mp2[s[i]]=1;
    for (int i='a';i<='z';i++) if (mp1[i]==1&&mp2[i]==1) cnt++;
    return cnt;
}

int main()
{
    cin>>n;
    cin>>s;
    for (int i=0;i<n;i++){
        if (check(i)>res) res=check(i);
    }
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>
#include <iterator>

#define Flash ios_base::sync_with_stdio(0), cout.tie(0), cin.tie(0);
#define F first
#define S second
#define pb push_back
#define nl '\n'
#define mp make_pair
#define NL cout << '\n';
#define EX exit(0)
#define all(s) s.begin(), s.end()
#define ll long long
#define FOR(i, start, finish, k) for(int i = start; i <= finish; i += k)

const long long MXN = 1e5 + 1;
const long long MNN = 1 * 1e4 + 1;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
const long long OO = 1e9 + 500;

typedef long long llong;
typedef unsigned long long ullong;

using namespace std;

int l[203], n, sum;

int main(){
    cin >> n;
    for(int i = 1; i <= 2 * n; i ++){
        cin >> l[i];
    }
    sort(l + 1, l + n * 2 + 1);
    for(int i = 1; i <= 2 * n; i += 2){
        sum += min(l[i], l[i + 1]);
    }
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
	char a[105],x=0,i;
	scanf("%s",a);
	int n=strlen(a);
	for(i=0;i<strlen(a)/2;i++)
    {
    	if(a[i]!=a[n-1-i])
    	{
    		x++;
		}
	}
	printf("%d",x);
} 

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long

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

int dp[1000000][3];

int a[10000000][3];

int n;

signed main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
        }
    }

    for(int i = 0; i < n; i++){
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(j == k) continue;
                 chmax(dp[i + 1][k],dp[i][j] + a[i][k]);
            }
        }
    }

    int res = 0;
    for(int i = 0; i < 3; i++) chmax(res,dp[n][i]);
    cout << res << endl;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 200002;
multiset<string> a,b;
vector<string> v;
 
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,y;
    cin>>n>>y;
    y/=1000;
    FOR(i,0,n+1){
    	FOR(j,0,n+1){
    		int x=y-5*i-10*j;
    		if(x>=0 && (x+i+j)==n){
    			cout<<j<<" "<<i<<" "<<x<<endl;
    			return 0;
    		}
    	}
    }
    cout<<-1<<" "<<-1<<" "<<-1<<endl;
    return 0;
}


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

int main(){
	
	string s, t;
	cin >> s >> t;
	
	sort(s.begin(), s.end());
	
	sort(t.begin(), t.end());
	
    reverse(t.begin(), t.end());
	
	if(s<t) cout << "Yes" << endl;
	
	else cout << "No" << endl;
 
	
    return 0;

}


Measured memory_bytes: 256
n = gets.to_i
a = gets.split(' ').map(&:to_i)
def sort(a)
  for i in 1..a.size-1
    ans = ""
    count = 1
    a.each do |i|
      ans += "#{i}"
      ans += " " unless count == a.size
      count += 1
    end
    puts ans
    v = a[i]
    j = i - 1
    while j >= 0 && a[j] > v
      a[j+1] = a[j]
      j -= 1
    end
    a[j+1] = v
  end
end

sort(a)
ans = ""
count = 1
a.each do |i|
  ans += "#{i}"
  ans += " " unless count == a.size
  count += 1
end
puts ans

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

int main(){
  int a, b;  
  cin >> a >> b;
  
  double c = (a + b)/2.0;
  
  if(c - (a + b)/2 > 0 ){
    cout << (a + b)/2  + 1<< endl;
  }
  if(c - (a + b)/2 == 0){
   cout << c << endl;
  }

}





Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int a,b;
    char op;
    while(1){
        scanf("%d %c %d", &a, &op, &b);
        if(op == '?') break;
        if(op == '+'){
            printf("%d\n", a + b);
        }else if(op == '-'){
            printf("%d\n", a - b);
        }else if(op == '*'){
            printf("%d\n", a * b);
        }else if(op == '/'){
            printf("%d\n", a / b);
        }else{
            break;
        }
    }
    
    return 0;
}



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

using namespace std;


int32_t main(){

	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);

	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b))<<endl;

	return 0;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<double> x(n);
	vector<string> u(n);
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> u[i];
	}
	double sum = 0.0;
	for (int i = 0; i < n; i++) {
		if (u[i].compare("JPY") == 0) {
			sum += x[i];
		}
		if (u[i].compare("BTC") == 0) {
			sum += (380000.0 * x[i]);
		}
	}
	cout << sum << '\n';
	
	return 0;
}


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

int main() {
	double a[1000],b;
	int c=0,i=0;
	while(cin>>a[i]){
		
		b=1000-a[i];
	    
	while(1){
		
		if(b<0){
			b=b+500.0;
			c--;
			break;
			
		}
		c++;
		b=b-500.0;
	}	
	while(1){
		
		if(b<0){
			b=b+100.0;
			c--;
			break;
		}
		c++;
		b=b-100.0;
	}	
	while(1){
		
		if(b<0){
			b=b+50;
			c--;
			break;
		}
		c++;
		b=b-50;
	}	
	while(1){
		
		if(b<0){
			b=b+10.0;
			c--;
			break;
		}
		c++;
		b=b-10;
    	}
    	while(1){
     		
    		if(b<0){
	    		b=b+5.0;
    			c--;
    			break;
    		}
		c++;
		b=b-5.0;
     	}
	    while(1){
		
		    if(b<0){
		    	b=b+1.0;
			    c--;
		    	break;
		    }
		    c++;
		    b=b-1.0;
	    }
	   if(a[i]==0){
	   	
	   }
       else{
       	cout<<c<<endl;
        }
        i++;
        c=0;
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3112
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define MAX_N 100
#define MAX_S 17
#define MAX_T 10

typedef struct time_tbl
{
	int no;
	int time;
	bool used;
} time_t;

time_t t[MAX_T];

int
main(int argc, char **argv)
{
	int s[MAX_S];
	int w[MAX_N];

	for (int i = 0; i < MAX_S; ++i)
		s[i] = -1;

	int time = 0;
	int ix = 0;
	for (int sn = 0;;)
	{
		int stime = 5 * sn;
		int k = (sn % 5 == 1) ? 5 : 2;
		int c = 0;
		int p = -1;
		for (int i = 0; i < MAX_S; ++i)
		{
			if (s[i] == -1)
			{
				if (p == -1)
					p = i;

				c++;
				if (c >= k)
					break;
			}
			else
			{
				c = 0;
				p = -1;
			}
		}

		int min;
		if (c >= k)
		{
			w[sn] = time - stime;
			for (int i = 0; i < c; ++i)
				s[p + i] = sn;

			int u;
			for (u = 0; u < ix; ++u)
			{
				if (!t[u].used)
					break;
			}

			if (u >= ix)
				u = ix++;

			int etime = 17 * (sn % 2) + 3 * (sn % 3) + 19;
			t[u].time = time + etime;
			t[u].no = sn;
			t[u].used = true;

			sn++;
			if (sn >= MAX_N)
				break;

			stime = 5 * sn;
			min = stime;
		}
		else
			min = 1000000000;

		for (int i = 0; i < ix; ++i)
		{
			if (t[i].used && t[i].time < min)
				min = t[i].time;
		}

		while(true)
		{
			int u;
			for (u = 0; u < ix; ++u)
			{
				if (t[u].used && t[u].time == min)
					break;
			}

			if (u >= ix)
				break;

			t[u].used = false;
			for (int i = 0; i < MAX_S; ++i)
			{
				if (s[i] == t[u].no)
					s[i] = -1;
			}
		}

		if (time < min)
			time = min;

		if (time < stime)
			time = stime;
	}

	int n;
	while (scanf("%d", &n) != EOF)
		printf("%d\n", w[n]);

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N, A[200010];
    cin >> N;
    rep(i,0,N){
        cin >> A[i];
    }
    sort(A, A+N, greater<ll>());
    ll ans = 0;
    map<ll,ll> mp;
    rep(i,0,N){
        mp[A[i]]++;
    }
    rep(i,0,N){
        if(mp[A[i]] == 0) continue;
        ll nn = 1;
        while(nn <= A[i]){
            nn *= 2;
        }
        ll val = nn - A[i];
        mp[A[i]]--;
        if(mp[val] != 0){
            mp[val]--;
            ans++;
        }
    }
    print(ans);
}


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

int main() {

  int A, B, C, D, R, L;

  cin >> A >> B >> C >> D;

  L = A + B;
  R = C + D;

  if ( L == R) cout << "Balanced" << endl;
   else if ( L > R) cout << "Left" << endl;
   else if ( L < R) cout << "Right" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//Fast io
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
//Class shorthands
#define ll long long
#define db long double
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
//Function Shorthands
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define mp make_pair
#define po pop_back
#define eb emplace_back
//Code Shorthands
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
//Constants
#define hell 1000000007
#define PI acos(-1.0)
using namespace std;

void solve(){
	int n,x,t;
	cin>>n>>x>>t;
	int ans = ((n/x))*t;
	if(n%x) ans+=t;
	cout<<ans<<endl;
}

int main(){
	io;
	int t = 1;
	//cin>>t;
	while(t--){
		solve();
	}
}

Measured memory_bytes: 3608
#include <stdio.h>
#include <math.h>

int main(){
    int N,D;
    int X[22][22];
    scanf("%d%d",&N,&D);
    double length[22];
    double dist = 0;
    int i,j;
    
    for(j= 0;j<N;j++){
        for(i=0;i<D;i++){
            scanf("%d",&X[i][j]);
        }
    }
    int count = 0;
    int k;
    double z = 0;
    for(i=0;i<j;i++){
        for(j=i+1;j<N;j++){
             z = 0;
            for(k=0;k<D;k++){
                
                z += (X[k][i]-X[k][j])*(X[k][i]-X[k][j]);
                
            }
           
            z = sqrt(z);
           
            if(z==(int)z)count++;

        }
    }
    printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	buf.Split(bufio.ScanWords)
	n := scanInt()
	r := scanInt()

	var result int
	if n < 10 {
		result = r + 100*(10-n)
	} else {
		result = r
	}
	fmt.Printf("%d", result)
}

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func scanString() string {
	buf.Scan()
	return buf.Text()
}

func scanStrings(n int) []string {
	a := make([]string, n)
	for k, _ := range a {
		a[k] = scanString()
	}
	return a
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int n, m, vis[N];
vector<int> G[N];
deque<int> path;

void dfs(int u, int pre) {
    vis[u] = 1;
    for(int v : G[u]) {
        if(v == pre || vis[v]) continue;
        path.push_back(v);
        dfs(v, u);
        return;
    }
}

void dfs2(int u, int pre) {
    vis[u] = 1;
    for(int v : G[u]) {
        if(v == pre || vis[v]) continue;
        path.push_front(v);
        dfs2(v, u);
        return;
    }
}

int main() {
    scanf("%d%d", &n, &m);
    while(m--) {
        int u, v;
        scanf("%d%d", &u, &v);
        G[u].push_back(v);
        G[v].push_back(u);
    }

    for(int i = 1; i <= n; i++) {
        if(G[i].empty()) continue;
        path.push_back(i);
        dfs(i, 0);
        dfs2(i, 0);
        break;
    }
    printf("%d\n", path.size());
    for(int i = 0; i < path.size(); i++) {
        printf("%d%c", path[i], " \n"[i+1==path.size()]);
    }
    return 0;
}


Measured memory_bytes: 9984
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;
using ll = long long;

class Graph {
public:
    explicit Graph(int N = 0) : V_NUM(N) { path.resize(V_NUM); }
    void span(int u, int v) { path[u].push_back(v); }
    vector<int> operator[](int v) const { return path[v]; }

    int V_NUM;
    vector<vector<int>> path;
};

void fail() {
    cout << "NO" << endl;
    exit(0);
}

vector<ll> A;
Graph tree;

ll dfs(int v, int r) {
    vector<ll> ch;
    for (int sv : tree[v]) {
        if (sv == r) continue;
        ch.push_back(dfs(sv, v));
    }
    if (ch.empty()) return A[v];

    ll sum = accumulate(ch.begin(), ch.end(), 0LL);
    ll ma = *max_element(ch.begin(), ch.end());

    ll P = min(sum / 2, sum - ma);  // 作れる最大ペア数
    if (A[v] < sum - P || sum < A[v]) fail();

    // 実際に葉同士でペアにするのは、sum-A[v]組
    // よって親に引き継がれる葉の数は、sum-2(sum-A[v])個
    ll ret = A[v] * 2 - sum;
    cerr << v << "," << ret << endl;
    return ret;
}

int main() {
    int N;
    cin >> N;
    A.resize(N);
    for (auto& a : A) cin >> a;

    tree = Graph(N);
    for (int i = 0; i < N - 1; ++i) {
        int u, v;
        cin >> u >> v;
        --u, --v;
        tree.span(u, v);
        tree.span(v, u);
    }

    // 例外
    if (N == 2) {
        cout << (A[0] == A[1] ? "YES" : "NO") << endl;
        return 0;
    }

    // 葉でない頂点からDFS
    for (int r = 0; r < N; ++r) {
        if (tree[r].size() == 1) continue;
        cout << (dfs(r, -1) == 0 ? "YES" : "NO") << endl;
        return 0;
    }
    terminate();
    return 0;
}


Measured memory_bytes: 18560
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 998244353
#define test ll tx; cin>>tx; while(tx--)
typedef long long int ll;
ll fac[200001]; 
ll power1[200001];
void solve(ll m){
    fac[0] = 1; 
    power1[0]=1;
    for (ll i=1 ; i<=200001; i++){
        fac[i]=(fac[i-1]*i)%mod; 
        power1[i]=(power1[i-1]*(m))%mod;
    }
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x) % p; 
  
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
ll nCrModPFermat(ll n, ll r, ll p) 
{ 
   // Base case 
   if (r==0) 
      return 1; 
    return (fac[n]* modInverse(fac[r], p) % p * 
            modInverse(fac[n-r], p) % p) % p; 
} 
int main() {
    FIO;
    //test
    {
       ll n,m,k,ans=0,u;
       cin>>n>>m>>k;
       solve(m-1);
       for(ll i=0;i<=k;i++){
           u=(m*power1[n-i-1])%mod;
           u*=nCrModPFermat(n-1,i,mod);
           ans+=u;
           ans%=mod;
       }
       cout<<ans<<endl; 
    }
	return 0;
}


Measured memory_bytes: 6784
n = int(input())
a = [0] + [int(item) for item in input().split()] + [0]

cost, place = 0, 0
for item in a:
  cost += abs(place - item)
  place = item
  
for i in range(1,n+1):
  print(cost + abs(a[i+1] - a[i-1]) - abs(a[i]-a[i-1]) - abs(a[i+1] -a[i]))

Measured memory_bytes: 14048
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long lint;


string S;
lint N, L, a, b, i, j, Ans = 0, c, d;
lint judge1, judge2, judge3;
int main() {
	cin >> a >> b >> c >> d;
	L = c * d;

	judge2 = b / c - a / c;
	if (a%c == 0)
		judge2 += 1;
	judge3 = b / d - a / d;
	if (a%d == 0)
		judge3 += 1;
	lint tmp;

	if (c < d) {
		tmp = c;
		c = d;
		d = tmp;
	}
	lint r;
	r = c % d;
	while (r != 0) {
		c = d;
		d = r;
		r = c % d;
	}
	L = L / d;

	judge1 = b / L - a / L;
	if (a%L == 0)
		judge1 += 1;

	//	cout << judge1 << endl << judge2 << endl << judge3;
	Ans = b - a - (judge2 + judge3 - judge1) + 1;

	cout << Ans << endl;
	return 0;
}


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

   scanf("%d",&num) ;

   while(num--)
   {
         int a[3] , i ,j , temp;

    for(i=0 ; i<3 ; i++)
    {
        scanf("%d",&a[i]) ;
    }

    for(i=0 ; i<3 ; i++)
    {
        for(j=i+1 ; j<3 ; j++)
        {

            if(a[i]<a[j])
            {
                temp = a[i] ;
                a[i] = a[j] ;
                a[j] = temp ;
            }
        }
    }

   int otivuj = a[0] , lombo= a[1] , vumi = a[2] ;


   if(otivuj * otivuj == (lombo * lombo + vumi * vumi))
    printf("YES\n") ;
   else
    printf("NO\n") ;
   }

return 0 ;
}

Measured memory_bytes: 580
#include<stdio.h>
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define S(type,x) fscanf(stdin,"%"#type,&x)
#define MAX(a,b) a>b?a:b
#define MIN(a,b) a<b?a:b
int dp[850][850];
int main() {
	int t[50],
		i,j,k,n;
	for (i = 0; i < 850; i++)for (j = 0; j < 850; j++)dp[i][j] = 1 << 20;
	dp[0][0] = 0;
	S(d, n);
	for (i = 0; i < n; i++)S(d, t[i]);
	for (i = 0; i<n; i++)
		for (j = 849; j >= 0; j--)
			for (k = 849; k >= 0; k--) {
				dp[j][k] += t[i];
				if (j >= t[i]) dp[j][k] = MIN(dp[j][k], dp[j - t[i]][k]);
				if (k >= t[i]) dp[j][k] = MIN(dp[j][k], dp[j][k - t[i]]);
			}
	int a = 1 << 20;
	for (i = 0; i < 850; i++)
		for (j = 0; j < 850; j++) {
			int x = MAX(i, j);
			x = MAX(x, dp[i][j]);
			a = MIN(a,x);
		}
	P(d, a);
	return 0;
}

Measured memory_bytes: 3420
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;

signed main(){
  int h,w;
  cin>>h>>w;
  vector<string> hw(h);
  for(int i=0;i<h;i++)cin>>hw[i];

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j==0||(i%2==1&&j!=w-1)||hw[i][j]=='#')cout<<"#";
      else cout<<".";
    }
    cout<<endl;
  }
  cout<<endl;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(j==w-1||(i%2==0&&j!=0)||hw[i][j]=='#')cout<<"#";
      else cout<<".";
    }
    cout<<endl;
  }
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll  long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define br cout <<"\n";
#define all(x)  (x).begin(),(x).end()
#define rall(x)  (x).rbegin(),(x).rend()
#define tr(c,i) for(auto i : c)
#define pii pair< int,int >
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define pq priority_queue< pair<ll,pii> ,vector<pair<ll,pii>>,greater <pair<ll,pii>> >p;//container adapter makes ascending q
using namespace std;
const int dx[] = { -1 ,0 };// U , L 
const int dy [] = { 0 ,-1 };
const int MOD = 1000 * 1000 * 1000 + 7 ;
const int N = 1000*1000+ 5   ;
const int MAXN = 1000000 ;
const int INF = INT_MAX ;
int main ( ){
fast_io();
bool ok = false ;
int a[3][3];
for(int i = 0 ; i < 3  ; ++ i )
{
for(int j = 0 ; j < 3 ; j++ )
cin >>a[i][j];

}
int n ;
cin >> n ;
for(int k = 0 ; k < n ; ++k )
{	int x ;
	cin >>x ;
	for(int i = 0 ; i < 3 ; ++i )
	{
		for(int j = 0 ; j < 3 ; ++j )
		{
			if (x ==a[i][j])
			{
				a[i][j] =  0  ;
				break ;  
			}
		}
	}
}

for(int i = 0 ; i < 3 ; ++i)
{	bool yes = true ; 
	for(int  j = 0 ; j < 3 ; ++ j)
	{
		yes &= (a[i][j] == 0  ); 
	}
	if (yes)
	{
		ok =true ;
		break ; 
	} 
	
}

for(int i = 0 ; i < 3 ; ++i)
{	bool yes = true ; 
	for(int  j = 0 ; j < 3 ; ++ j)
	{
		yes &= (a[j][i] == 0  ); 
	}
	if (yes)
	{ok =true ;
		break ;
	} 
	
}
bool yes = true ; 
for(int i = 0 ; i < 3 ; ++ i )
	yes &=(a[i][i] == 0 ); 
if(yes)
	ok = true ;
yes = true ;
for(int i = 0 ; i < 3 ; ++ i )
 yes &= ( a[i][2-i] == 0 ) ;
if(yes )
	ok = true ;
	
 cout << ( ok ? "Yes": "No") ;
 br
  

return 0 ;
 
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  vector<bool> have(N, false);
  
  int count = 0;
  
  for (int i = 0; i < K; i++) {
    int d;
    cin >> d;
    
    for (int j = 0; j < d; j++) {
      int A;
      cin >> A;
      
      if (have.at(A - 1) == false) {
        count++;
        have.at(A - 1) = true;
      }
      
    }
  }
  
  cout << N - count << endl;
}

Measured memory_bytes: 3564
/* 
 Author:N_o_o_B 
 Created:September 28 2019 17:08:09
*/
#include <bits/stdc++.h>
using namespace std;

#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define endl '\n'
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
     ll a[2];
    fori(i,2) cin >> a[i];
    set<ll> s[2];
    fori(i,2){
        for(ll j=2;j*j<=a[i];j++){
            if(a[i]%j) continue;
            ll cnt=0;
            while(a[i]%j==0){
                a[i]/=j;
                cnt++;
            }
            s[i].insert(j);
        }
        if(a[i]>1) {
          s[i].insert(a[i]);
        }
    }
    set<ll> ans;
    for(ll x:s[0]){
        if(s[1].count(x)) ans.insert(x);
    }
    ll n=ans.size();
    cout << n+1 << endl;
    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string S;
    string T;
    cin >> S >> T;
    
    int A,B;
    cin >> A >> B;
    
    string U;
    cin >> U;
    
    if (U==S){
        cout << A-1 << ' ' << B << endl;
    } else if(U==T){
        cout << A  << ' '<< B-1 << endl;
    }
}

Measured memory_bytes: 256
//
// Maximum Flow (Ford-Fulkerson)
// 
// Description:
//   Given a directed network G = (V, E) with edge capacity c: E->R.
//   The algorithm finds a maximum flow. 
//
// Algorithm:
//   Ford-Fulkerson's augmenting path algorithm
//
// Complexity:
//   O(n m^2), but very fast in practice.
// 
// Verified:
//
// Reference:
//   B. H. Korte and Jens Vygen (2008):
//   Combinatorial Optimization: Theory and Algorithms.
//   Springer Berlin Heidelberg. 
//

#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <functional>

using namespace std;

#define fst first
#define snd second
#define all(c) ((c).begin()), ((c).end())

const int INF = 1 << 30;
struct graph {
  int n;
  struct edge {
    int src, dst;
    int capacity, residue;
    size_t rev;
  };
  vector<vector<edge>> adj;
  graph(int n) : n(n), adj(n) { }
  void add_edge(int src, int dst, int capacity) {
    adj[src].push_back({src, dst, capacity, 0, adj[dst].size()});
    adj[dst].push_back({dst, src, 0, 0, adj[src].size()-1});
  }
  int max_flow(int s, int t) {
    vector<bool> visited(n);
    function<int (int,int)> augment = [&](int u, int f = INF) {
      if (u == t) return f;
      visited[u] = true;
      for (auto &e: adj[u]) {
        if (!visited[e.dst] && e.residue > 0) {
          int d = augment(e.dst, min(e.residue, f));
          if (d > 0) {
            e.residue -= d;
            adj[e.dst][e.rev].residue += d;
            return d;
          }
        }
      }
      return 0;
    };
    for (int u = 0; u < n; ++u)
      for (auto &e: adj[u]) e.residue = e.capacity;

    int total = 0;
    for (int f = 1; f; ) {
      fill(all(visited), false);
      total += (f = augment(s, INF));
    }
    return total;
  }
};

int main() {
  for (int n, m; scanf("%d %d", &n, &m) == 2; ) {
    graph g(n);
    for (int i = 0; i < m; ++i) {
      int u, v, w;
      scanf("%d %d %d", &u, &v, &w);
      g.add_edge(u, v, w);
    }
    printf("%d\n", g.max_flow(0, n-1));
  }
}

Measured memory_bytes: 1284
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,a,sum=0;
    cin>>n>>m;
    while(m--)
    {
     cin>>a;
     sum=sum+a;
    }
    if(n-sum>=0)
      cout<<n-sum;
    else
      cout<<-1;
}

Measured memory_bytes: 3632
function Main(input) {
  var A = parseInt(input.split(" ")[0]);
  var B = parseInt(input.split(" ")[1]);
  var K = parseInt(input.split(" ")[2]);
  var turn = true;//true:高橋君、false:青木君
  
  for(var i = 0; i < K; i++){
    if(turn){
       if(A % 2 == 1){
          A--;
       }
       A = A / 2;
       B += A;
       turn = false;
    }else{
      if(B % 2 == 1){
         B--;
      }
      B = B / 2;
      A += B;
      turn = true;
    }
  }
  console.log(A + " " + B);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main(){
  int n, m;
  cin >> n >> m;
 vector<int> a(n);
  for(int i = 0; i<n; i++){
     cin >> a[i];
  }
 sort(a.begin(), a.end());
 reverse(a.begin(), a.end());
 int sum = 0;
 for(int i = 0; i< n; i++){
    sum += a[i];
 }

    for(int i =0;i<m; i++){
     if(a[i] *4* m < sum)  {
       cout << "No" << endl;
       return 0;
      }
   }
     cout << "Yes" << endl;
    return 0;
 }


Measured memory_bytes: 3584
from collections import defaultdict
n,p = map(int,list(input().split()))
i,dic = 2,defaultdict(int)
while i*i<=p:
    while p%i==0:
        p/=i
        dic[i]+=1
    i+=1
if p>1:
    dic[p]=1
ans = 1
for k in dic.keys():
    while dic[k]>=n:
        dic[k]-=n
        ans *= k
print(int(ans))

Measured memory_bytes: 3316
n,k = map(int,input().split())
sunukes = [0]*n

for _ in range(k) :
    a = int(input())
    b = list(map(int,input().split()))
    for i in b :
        sunukes[i-1] += 1
        
count = 0
for j in sunukes :
    if j == 0 :
        count += 1
print(count)        

Measured memory_bytes: 9184
#include<bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

template<class Ty>
using passive_queue = priority_queue<Ty, vector<Ty>, greater<Ty>>;

struct Problem {

	UL gcd(UL a, UL b) { return b ? gcd(b, a % b) : a; }

	void Solve() {


		UL K; cin >> K;
		UL T[201] = {};

		for (UL i = 1; i <= K; i++) {
			for (UL j = 1; j <= K; j++) {
				T[gcd(i, j)]++;
			}
		}


		ULL ans = 0;
		for (UL i = 1; i <= K; i++) {
			for (UL j = 1; j <= K; j++) {
				ans += T[i] * gcd(i, j);
			}
		}

		cout << ans << endl;

	}

	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    ll a, b, k; cin >> a >> b >> k;
    if(a < k){
        cout << 0 << " " << max(b-(k-a),0LL) << endl;
    }else {
        cout << a - k << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    int n; cin >> n;
    set<string> st;
    string last; cin >> last; st.insert(last);
    bool ok = 1;
    REP(i,n-1){
        string now; cin >> now;
        if(last[last.size()-1]!=now[0] || (st.count(now))) ok = 0;
        st.insert(now);
        last = now;
    }
    Yn(ok);

    return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
low=1
high=n 
for _ in range(m):
    l,r=map(int,input().split())
    low=max(l,low)
    high=min(r,high)
if high-low+1>=0:
    print(high-low+1)
else:
  print(0)

Measured memory_bytes: 9124
n, *p = $stdin.read.split.map(&:to_f)
n = n.to_i
dp = Array.new(n+1).map { Array.new(n+2, 0.0) }
p.unshift(nil)
dp[1][0], dp[1][1] = 1-p[1], p[1]
(2..n).each do |i|
  (0..i).each do |f|
    dp[i][f] = dp[i-1][f-1] * p[i] + dp[i-1][f] * (1-p[i])
  end
end
puts (n/2+1..n).inject(0.0){ |sum, i| sum + dp[n][i] }


Measured memory_bytes: 186236
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

typedef long long ll;

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

// const int C ;
// const int M = 1000000007;

typedef pair<int, int> pass;

const int infty = 1000000000;

int N;
int M;
int x[510];
queue<int> Q;
queue<int> R;
int ans[300000];

int main () {
  cin >> N;
  set<int> S;
  for (auto i = 0; i < N; i++) {
    cin >> x[i];
    x[i]--;
    if (S.find(x[i]) != S.end()) {
      cout << "No" << endl;
      return 0;
    }
    S.insert(x[i]);
  }
  M = N*N;
  fill(ans, ans+M, infty);
  for (auto i = 0; i < N; i++) {
    ans[x[i]] = i;
  }
  vector<pass> V;
  for (auto i = 0; i < N; i++) {
    V.push_back(make_pair(x[i], i));
  }
  sort(V.begin(), V.end());
  // cerr << "Q" << endl;
  for (auto i = 0; i < N; i++) {
    for (auto j = 0; j < V[i].second; j++) {
      // cerr << V[i].second << endl;
      Q.push(V[i].second);
    }
  }
  for (auto i = 0; i < M; i++) {
    if (ans[i] == infty) {
      if (!Q.empty()) {
        int now = Q.front();
        if (i > x[now]) {
          cout << "No" << endl;
          return 0;
        }
        ans[i] = now;
        Q.pop();
      } else if (!R.empty()) {
        int now = R.front();
        ans[i] = now;
        R.pop();        
      } else {
        cout << "No" << endl;
        return 0;        
      }
    } else {
      // cerr << "R" << endl;
      for (auto j = 0; j < N-ans[i]-1; j++) {
        // cerr << ans[i] << endl;
        R.push(ans[i]);
      }
    }
  }
  cout << "Yes" << endl;
  for (auto i = 0; i < M; i++) {
    cout << ans[i]+1;
    if (i < M-1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
}


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

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

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

const int MAXN = 2 * 100 * 1000 + 17;

int n, a, b, c, d;
string s;

int go(int v) {
	if (s[v + 1] != '#')
		return go(v + 1);
	else if (s[v + 2] != '#')
		return go(v + 2);
	else
		return v;
}

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> a >> b >> c >> d >> s;
	s = '#' + s;
	s += "##";
	if (go(a) < c || go(b) < d)
		return cout << "No\n", 0;
	if (c < d)
		return cout << "Yes\n", 0;
	for (int i = b; i <= d; i++)
		if (s[i] != '#' && s[i - 1] != '#' && s[i + 1] != '#')
			return cout << "Yes\n", 0;
	cout << "No\n";
	return 0;
}


Measured memory_bytes: 720
#include <stdio.h>
#include <string.h>
 
#define MAX 2000
 
void longest_common_subsequence(char x[], char y[]){
    int i,j,m,n;
    
    m = strlen(x);
    n = strlen(y);
    int a[m+1][n+1];
    
    for(i=0; i<=m; i++){
    for(j=0; j<=n; j++){
        a[i][j] = 0;
    }
    }
    
    for(i=1; i <= m; i++){
        for(j=1; j<=n; j++){
            if(x[i-1] == y[j-1])
            a[i][j] = a[i-1][j-1] + 1;
            else if(a[i-1][j] >= a[i][j-1])
            a[i][j] = a[i-1][j];
            else a[i][j] = a[i][j-1];
        }
    }
printf("%d\n",a[m][n]);    
    
}
 
int main(){
    int i,n;
    char x[MAX],y[MAX];
    
    scanf("%d",&n);
    for(i=0; i<n; i++){
        scanf("%s",x);
        scanf("%s",y);
        
        longest_common_subsequence(x,y);
    }
return 0;    
}

Measured memory_bytes: 4528
import bisect
n, k = map(int, input().split())
V = list(map(int, input().split()))
max_dequeue = min(n, k)

max_value = 0
for dequeue_num in range(max_dequeue + 1):
  for left in range(dequeue_num + 1):
    right = dequeue_num - left
    #print("left", left, "right", right, "dn", dequeue_num)
    jewel_taken = sorted(V[:left] + V[n - right:])
    #print("jt", jewel_taken)
    pos_zero = bisect.bisect(jewel_taken, 0)
    ret_num = min(k - dequeue_num, pos_zero)
    #print(pos_zero, k - dequeue_num)
    #print(jewel_taken[ret_num:])
    #print()
    max_value = max(max_value, sum(jewel_taken[ret_num:]))
print(max_value)    


Measured memory_bytes: 42088
from collections import deque

H, W=map(int, input().split())
ch, cw=map(int, input().split())
dh, dw=map(int, input().split())
ch-=1
cw-=1
dh-=1
dw-=1

grid=["0"]*H
for i in range(H):
    s=input()
    grid[i]=s

Inf=10**12
cost=[[Inf] * W for i in range(H)]

walk=[(0, 1), (0, -1), (-1, 0), (1, 0)]
warp=[]
for i in range(-2, 3):
    for j in range(-2, 3):
        if i==0 and j==0:
            continue
        if (i, j) not in walk:
            warp.append((i, j))

q=deque()
cost[ch][cw]=0
q.append((ch, cw, 0))

while q:
    x, y, c=q.popleft()
    for dx, dy in walk:
        nx = x+dx
        ny = y+dy
        if 0<= nx < H and 0<= ny < W and grid[nx][ny]=="." and cost[nx][ny]>c:
            cost[nx][ny]=c
            q.appendleft((nx, ny, c))
    
    for dx, dy in warp:
        nx = x+dx
        ny = y+dy
        if 0<= nx < H and 0<= ny < W and grid[nx][ny]=="." and cost[nx][ny]>c+1:
            cost[nx][ny]=c+1
            q.append((nx, ny, c+1))


if cost[dh][dw]==Inf:
    print(-1)
else:
    ans=cost[dh][dw]
    print(ans)

Measured memory_bytes: 94324
n = int(input())
ss = {}
for i in range(n):
    s = input().strip()
    if s in ss:
        ss[s] += 1
    else:
        ss[s] = 1

m = int(input())
ts = {}
for i in range(m):
    s = input().strip()
    if s in ts:
        ts[s] += 1
    else:
        ts[s] = 1

max_score = 0
for s, sc in ss.items():
    tc = ts[s] if s in ts else 0
    max_score = max(max_score, sc - tc)

print(max_score)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    char pre[4];
    char real[4];
    int score=0;

    scanf("%s",pre);
    scanf("%s",real);

    for(int i=0;i<=2;i++){
        if(pre[i]==real[i]){
            score=score+1;
        }
    }
    printf("%d",score);
    return 0;
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}

int K;
void dfs(int d, ll val, vector<ll> &vec) {
  vec.push_back(val);

  // 終了条件
  if(d == 10) return;

  // 再帰
  for(int i = -1; i <= 1; ++i) {
    int add = (val % 10) + i;
    if(add >= 0 && add <= 9) dfs(d + 1, val * 10 + add, vec);
  }
}

int main() {
  cin >> K;
  vector<ll> vec; // 空の配列
  for(int v = 1; v < 10; ++v) dfs(1, v, vec);
  sort(all(vec));
  cout << vec[K - 1] << endl;
}

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

public class Solution
{
    public static void Main()
    {
        const int mod = 2019;
        const int len = mod + 1;
        var S = Console.ReadLine();
        long all = 0;
        var cur = new long[len];

        foreach (var c in S)
        {
            var nexts = new long[len];
            var v = c - '0';
            for (int i = 0; i < len; i++)
            {
                var j = (i * 10 + v) % mod;
                nexts[j] += cur[i];
            }
            nexts[v]++;

            cur = nexts;
            all += cur[0];
        }

        Console.WriteLine(all);
    }
}

Measured memory_bytes: 39352
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll MOD = 1e9 + 7;
ll INF = 1e18;

using matrix = vector<V>;
matrix power(const matrix &a, int n)
{
    int sz = a.size();
    matrix res(sz, V(sz));
    rep(i, sz)
    rep(j, sz)
    {
        if (i == j)
            res[i][j] = 1;
        else
            res[i][j] = 0;
    }
    matrix r = a;
    while (n > 0)
    {
        if (n & 1)
        {
            matrix tmp(sz, V(sz, 0));
            rep(i, sz)
            rep(j, sz) rep(k, sz)
            {
                tmp[i][j] += res[i][k] * r[k][j];
            }
            res = tmp;
        }
        matrix tmp(sz, V(sz, 0));
        rep(i, sz)
        rep(j, sz)rep(k, sz)
        {
            tmp[i][j] += r[i][k] * r[k][j];
        }
        r = tmp;
        n >>= 1;
    }
    return res;
}

int fib(int n)
{
    matrix a(2, V(2));
    a[0] = {1, 1};
    a[1] = {1, 0};
    a = power(a, n - 1);
    V start = {1, 1};
    V res(2, 0);
    rep(i, 2)
    rep(j, 2)
    {
        res[i] += a[i][j] * start[j];
    }
    return res[0];
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << fib(n) << endl;
}



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

using namespace std;

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

	long long n,k;
	cin >> n >> k;

	long long ans = 0;
	long long m;
	if (k == 0) ans = n*n;
	else {
		for (long long i = k+1;i <= n;i++){
			ans += n/i*(i-k);
			m = (n-(i*(n/i))) - k+1;
			if (m >= 0) ans += m;
		}
	}
	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n,k[100]={0},max=0;
    while(cin>>n){
        k[n]++;
        if(max<k[n]){
           max=k[n];
        }
    }
    for(int i=0;i<100;i++){
        if(k[i]==max){
            cout<<i<<endl;
        }
    }
}

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

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

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

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

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

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,ans=0;
	cin>>a>>b>>c;
	range(i,1,10000){
		if(i*a<=c)ans+=b;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256