akhauriyash/Code-Regression huggingface dataset:
#pragma region include
#include <stdio.h>
#include <string>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#pragma endregion
using namespace std;

#pragma region 定数
#define INF_VAL (2147483647 - 1)
#define INF_VAL_MINUS -INFVAL
#pragma endregion

#pragma region マクロ
// 配列の長さを取得する(ただし関数内ではポインタサイズに注意)
#define SIZE_OF_ARRAY(array) sizeof(array) / sizeof(*array)

// ソート
#define Sort(array, length) sort(array, array + length)
#define SortDESC(array, length) sort(array, array + length, greater<>())

// 配列の最大値、最小値取得
#define MAX_OF_ARRAY(array, length) *max_element(array, array + length)
#define MIN_OF_ARRAY(array, length) *min_element(array, array + length)
#pragma endregion

#pragma region Utility
#pragma region 配列要素の合計値を取得
template <typename T>
T getSum(T array[], int length)
{
    T sum = 0;
    for (int i = 0; i < length; i++)
    {
        sum += array[i];
    }
    return sum;
}
#pragma endregion

#pragma region ToString(int)
string ToString(int i)
{
    char buffer[1000];
    sprintf(buffer, "%d", i);
    return string(buffer);
}
#pragma endregion

#pragma region 10進数からN進数(<= 10) へ変換
string convertToN(long n, int base)
{
    string ans = "";
    while (n != 0)
    {
        int temp = n % base; // 1桁取得
        ans = ToString(temp) + ans;
        n /= base;
    }
    return ans;
}
#pragma endregion
#pragma endregion

int main()
{
    // ***  問題のpathを記載 ***
    // https://onlinejudge.u-aizu.ac.jp/courses/lesson/2/ITP1/1/ITP1_1_D

    // 標準入力から値を取得
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B && A != C)
    {
        puts("Yes");
    }
    else if (A == C && A != B)
    {
        puts("Yes");
    }
    else if (B == C && A != B)
    {
        puts("Yes");
    }
    else
    {
        puts("No");
    }
    

    // 成功時は必ず0を返す
    return 0;
}


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

#define rep(i,n) for(int i = 0;i < n;i++)
using ll = long long;
/*
 * Modint struct
 * library author : @snuke
 * */
const int mod = 998244353;
struct mint {
  long long x; // typedef long long ll;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) { if((x+=a.x)>=mod)x-=mod;return *this;}
  mint& operator-=(const mint a) { if((x+=mod-a.x)>=mod)x-=mod; return *this;}
  mint& operator*=(const mint a) { (x *=a.x)%=mod; return *this;}
  mint operator+(const mint a) const { mint res(*this);return res+=a;}
  mint operator-(const mint a) const { mint res(*this);return res-=a;}
  mint operator*(const mint a) const { mint res(*this);return res*=a;}
  mint pow(ll t) const {
    if (!t) return 1;mint a = pow(t>>1);a*=a;
    if (t&1) a *= *this;return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return (*this) *= a.inv();}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint dp[3030][3030];

int main(void){

  ll a,b,c,d;cin >> a >> b >> c >> d;
  
  dp[a][b] = 1;
  
  for(ll i = a + 1;i <= c + 1;i++){
    dp[i][b] = dp[i-1][b] * (mint)b;
  }

  for(ll i = b + 1;i <= d + 1;i++){
    dp[a][i] = dp[a][i-1] * (mint)a;
  }

  for(ll i = a + 1;i <= c + 1;i++){
    for(ll j = b + 1;j <= d + 1;j++){
      dp[i][j] = dp[i][j-1] * (mint)i + dp[i-1][j] * (mint)j - (mint)((i-1)*(j-1))*dp[i-1][j-1];
    }
  }
 
  cout << dp[c][d] << '\n';

}


Measured memory_bytes: 75276
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_nl = lambda: list(map(int, readline().split()))
in_na = lambda: map(int, read().split())
in_s = lambda: readline().rstrip().decode('utf-8')


def main():
    N = in_n()
    h = in_nl()
    now = [0] * N

    ans = 0
    while h != now:
        ok = [-1] + [i for i, x in enumerate(now) if x == h[i]] + [N]
        lr = []
        for i in range(len(ok) - 1):
            if ok[i + 1] - ok[i] > 1:
                l = ok[i] + 1
                r = ok[i + 1]
                lr.append((l, r))

        for l, r in lr:
            diff = 10**9 + 7
            for i in range(r - l):
                diff = min(diff, h[l + i] - now[l + i])

            ans += diff
            for i in range(r - l):
                now[l + i] += diff

    print(ans)


if __name__ == '__main__':
    main()


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

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            List<String> S = new ArrayList<>();
            int[] T = new int[N];
            for (int i = 0; i < N; i++) {
                S.add(sc.next());
                T[i] = sc.nextInt();
            }
            String X = sc.next();

            int pos = S.indexOf(X);

            int ans = 0;
            for (int i = pos + 1; i < N; i++) {
                ans += T[i];
            }

            System.out.println(ans);
        }
    }

}


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

#define F first
#define S second
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

using namespace std;

typedef long long ll;

void solve(){
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	while(b<=a && k){
		b*=2;
		k--;
	}	
	while(c<=b && k){
		c*=2;
		k--;
	}	
	if(a<b && b<c)cout<<"Yes";
	else cout<<"No";
}

int main(){
	Red;
	int T=1;
	//cin>>T;
	while(T--)solve();
}

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

int main(void)
{
  int m, f, r, i;
  while (1) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1) break;
    if (m == -1 || f == -1) cout << "F" << endl;
    else if (m + f >= 80) cout << "A" << endl;
    else if (m + f >= 65) cout << "B" << endl;
    else if (m + f >= 50) cout << "C" << endl;
    else if (m + f >= 30){
      if (r >= 50) cout << "C" << endl;
      else cout << "D" << endl;
    }
    else cout << "F" << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using longlong=long long;

int main(){
    std::cin.tie(nullptr);std::cin.sync_with_stdio(false);
    int n,k;std::cin>>n>>k;
    int N=1<<n;
    int ans=std::numeric_limits<int>::max();
    for(int bs=0;bs<N;bs++){
        int x=1;
        for(int i=0;i<n;i++){
            if(bs>>i&1)x*=2;
            else x+=k;
        }
        if(x<ans)ans=x;
    }
    std::cout<<ans<<std::endl;
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int num = c;
    num += 10*b;
    num += 100*a;
    if(num % 4 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


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

void tolowercase( string& s ) {
	for( auto& ch: s ) {
		if( ch >= 'A' && ch <= 'Z' ) {
			ch += 'a' - 'A';
		}
	}
}

int main() {
	string W, T;
	cin >> W;

	int result = 0;

	while( cin >> T ) {
		if( T == "END_OF_TEXT" ) {
			break;
		}

		tolowercase( T );

		if( T == W ) {
			result += 1;
		}
	}

	cout << result << endl;
}



Measured memory_bytes: 3168
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <utility>
#include <map>
#include <set>
#include <algorithm>

#define REP(i, a, b) for (int i=a; i <b; i++)
#define F first
#define S second
#define INF 1000+1;

using namespace std;

typedef long long ll;
typedef vector< int > vi;

int main() {
    int h, w;
    scanf("%d %d", &h, &w);
    int g[10][10];
    vector <vector < int > > input(h);
    REP(i, 0, h) {
        input[i].resize(w);
    }

    REP(i, 0, 10) {
        REP(j, 0, 10) {
            scanf("%d", &g[i][j]);
        }
    }

    REP(i, 0, h) {
        REP(j, 0, w) {
            scanf("%d", &input[i][j]);
        }
    }

    int dist[10], parent[10];
    REP(i, 0, 10) {
        dist[i] = INF;
        parent[i] = i;
    }
    dist[1] = 0;

    REP(i, 0, 10) {
        REP(j, 0, 10) {
            REP(k, 0, 10) {
                if (dist[j] + g[k][j] < dist[k]) {
                    dist[k] = dist[j] + g[k][j];
                    parent[k] = j;    
                }
            }
        }
    }

    /* printf("distances are\n");
    REP(i, 0, 10) {
        printf("%d's distance: %d\n ",i, dist[i]);
    }
    printf("parents are\n");
    REP(i, 0, 10) {
        printf("%d's parent: %d \n",i, parent[i]);
    }
    */

    int num[10] = {0};
    REP(i, 0, h) {
        REP(j, 0, w) {
            if (input[i][j] >= 0) {
                num[input[i][j]]++;
            }
        }
    }
    int ans = 0;
    REP(i, 0, 10) {
            ans += dist[i] * num[i];
    }
    printf("%d\n", ans);
    return 0;
}

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

int A[2][105];

int main(){
  
  int n;
  cin>>n;
  
  int ans=0;
  int sum=0;

  for(int i=0;i<2;i++)
    for(int j=0;j<n;j++) cin>>A[i][j];
  
  for(int i=0;i<n;i++){
    
    sum+=A[0][i];
    
    int sum2=sum;
    
    for(int j=i;j<n;j++) sum2+=A[1][j];

    ans=max(ans, sum2);
    
  }

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


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

int main() {
  int n, m, l, r, mx = -1, mn = 999999;

  cin >> n >> m;

  for (int i = 0; i < m; i++) {
    cin >> l >> r;
    mx = max(mx, l);
    mn = min(mn, r);
  }

  if (mx == mn) {
    cout << "1";
  } else if (mx > mn) {
    cout << "0";
  } else {
    cout << abs(mx - mn) + 1;
  }

  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	s := nextLine()
	args := strings.Split(s, " ")
	hp, _ := strconv.Atoi(args[0])
	ak, _ := strconv.Atoi(args[1])
	if hp < ak {
		fmt.Print(1)
	} else if hp%ak == 0 {
		fmt.Print(hp / ak)
	} else {
		fmt.Print(hp/ak + 1)
	}
}


Measured memory_bytes: 640
#include <iostream>
using namespace std;
bool coffelike(string line)
{
	if(line.size()<6)return false;
	if(line[2]==line[3]&&line[4]==line[5])return true;
	return false;
}
int main()
{
	string line;
	cin>>line;
	if(coffelike(line))cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T> inline bool chmax(T& a,T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> inline bool chmin(T& a,T b) { if (a > b) { a = b; return true; } return false; }
constexpr long long INF = 1e18;

int main() {
    int n;
    long long x;
    cin >> n >> x;
    vector<long long> a(n);
    for (auto& e : a) cin >> e;
    
    vector<vector<long long>> cost(n, vector<long long>(n));
    for (int i = 0; i < n; i++) cost[i][0] = a[i];
    for (int j = 1; j < n; j++) {
        for (int i = 0; i < n; i++) {
            cost[(i+1)%n][j] = cost[i][j-1];
        }
    }
    
    auto f = [&] (int k) {
        long long res = k * x;
        for (int i = 0; i < n; i++) {
            long long c = INF;
            for (int j = 0; j <= k; j++) chmin(c, cost[i][j]);
            res += c;
        }
        return res;
    };
    
    int l = 0, r = n-1;
    while (abs(l - r) > 2) {
        int m1 = (l * 2 + r) / 3;
        int m2 = (l + r * 2) / 3;
        if (f(m1) > f(m2)) l = m1;
        else r = m2;
    }
    
    long long ans = INF;
    for (int i = l; i <= r; i++) chmin(ans, f(i));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 31616
#include<stdio.h>
#define F 44

int main()
{
  int i,n,N[F];

  scanf("%d",&n);
  N[0]=1;
  N[1]=1;

  for(i=2;i<=n;i++){
    N[i] = N[i-1] + N[i-2];
  }
  printf("%d\n",N[n]);
  return 0;
}

Measured memory_bytes: 596
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

string A;

string ans = "A";

void solve(){
	if(A[0]<='z' && A[0]>='a') ans = "a";
}

int main(){
    cin >> A;

    solve();

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

Measured memory_bytes: 3032
#include <stdio.h>

int main(){

    long N,n;
    long sum,min,max;

    scanf("%ld",&N);
    scanf("%ld",&n);
    min=n;
    max=n;
    sum=n;
    for(int i=0;i<N-1;i++){
        scanf("%ld",&n);
        if(n>max)
            max=n;
        if(n<min)
            min=n;
        sum += n;
    }

    printf("%ld %ld %ld\n",min,max,sum);
    
}


Measured memory_bytes: 2104
#include<iostream>
#include<vector>
#include<sstream>
#include<string>
#include<numeric>
#include <algorithm>
#include<math.h>
#include<cstdio>
#include<string.h>




using namespace std;
typedef long long ll;
struct point{
  int x;
  int y;

};
int gcd(int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
int lcm( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
int input(){
  int x;
  cin>>x;
  return x;
}

int moji(char in)
{
    int ans = (int)in-(int)'a';
    if((ans < 0) || (ans > 25)){
        ans = 26;
    }
    return ans;
}
const int VV=10;//場合に応じてVVの値のみ変更する必要あり
//dijkstra(s)sがスタート地点でそこからの最短距離を配列dで表す。正の重みのみ使用可能
int cost[VV][VV];
int d[VV];
bool used[VV];
void dijkstra(int s){
  fill(d,d+VV,100000);
  fill(used,used+VV,false);
  d[s]=0;
  while(true){
    int v=-1;
    for(int u=0;u<VV;u++){
      if(!used[u]&&(v==-1||d[u]<d[v]))v=u;
    }
    if(v==-1)break;
    used[v]=true;
    for(int u=0;u<VV;u++){
      d[u]=min(d[u],d[v]+cost[v][u]);
    }
  }

}

int compare_int(const void *a, const void *b)//qsort(quick sort利用時に使用)
{
    return *(int*)a - *(int*)b;
}

int binary_searchh(long long x,long long k[],int n){
  int l=0;
  int r=n;
  while(r-l>=1){
    int i=(l+r)/2;
    if(k[i]==x)return i;
    else if(k[i]<x)l=i+1;
    else r=i;
  }
  return -1;
}




int main(){
  int N;
  cin>>N;
  int p[N];
  for(int i=0;i<N;i++){
    cin>>p[i];
  }
  sort(p,p+N);
  int sum=0;
  for(int i=0;i<N;i++){
    if(i!=N-1){
      sum+=p[i];
    }else{
      sum+=p[i]/2;
    }
  }
  cout<<sum<<endl;





  

  



}


  
  


  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define cout_precision cout.setf(ios::fixed); cout.precision(32);
#define clr(a) memset(a,0,sizeof(a))
#define umap unordered_map
#define uset unordered_set
#define fr first
#define sc second
#define pb push_back
#define M int(1e9+7)


using ll = int64_t; using vll = vector<ll>; using vvll = vector<vll>;
using pll = pair<ll, ll>; using vpll = vector<pll>; using vvpll = vector<vpll>;

bool isInt(double x){
	if(ceil(x) == floor(x))	return 1;
	return 0;
}

int main(){
	fast_io; cout_precision;
	int a,b;	cin >> a >> b;
	if(isInt(double(a+b)/2))	cout<<int(a+b)/2<<endl;
	else	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(A[N-1])

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

using namespace std;

int main(void){
    int N;
    cin>>N;
    vector<long long> A(N+1);
    vector<long long> B(N);
    for(int i=0;i<N+1;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cin>>B[i];
    }
    long long ans=0;
    for(int i=0;i<N;i++){
        ans+=min(A[i],B[i]);
        B[i]=B[i]-min(A[i],B[i]);
        ans+=min(A[i+1],B[i]);
        A[i+1]=A[i+1]-min(A[i+1],B[i]);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[],int N) {
	int i;
	for(i=0;i<N;i++) {
		/* 隣接する要素の間に1つの空白を出力 */
		if(i>0) printf(" "); //先頭以外空白
		printf("%d",A[i]);
	}
	printf("\n");
}

/* 挿入ソート(0オリジン配列) */
void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v; // A[j + 1]とA[i]は同じ場所
		trace(A,N);
	}
}

int main(void)
{
	int N, i, j;  // j いらん
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);  //N回A[N-1]まで入力
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}


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

int main() 
{ 
    int64_t n,m,x;
    cin>>n>>m>>x;

    vector<int64_t> c(n);
    vector<vector<int64_t>> a(n, vector<int64_t>(m));
    for(int i=0;i<n;i++){
        cin>>c.at(i);
        for(int j=0;j<m;j++){
            cin>>a.at(i).at(j);
        }
    }



    int64_t price_min=1000000000;
    for(int tmp=0;tmp<(1<<n);tmp++){
        bitset<12> s(tmp);
        vector<int64_t> und(m,0);
        int64_t price=0;
        for(int i=0;i<n;i++){
            if(s.test(i)){
                price+=c.at(i);
                for(int j=0;j<m;j++){
                    und.at(j)+=a.at(i).at(j);
                }
            }
        }

        bool flg=false;
        for(int i=0;i<m;i++){
            if(und.at(i)<x){
                break;
            }else{
                if(i==m-1)
                    flg=true;
            }
        }
        if(flg)
            price_min=min(price_min,price);
    }


    if(price_min==1000000000)
        cout<<-1<<endl;
    else
        cout<<price_min<<endl;

return 0; 
} 


Measured memory_bytes: 3636
#include<bits/stdc++.h>
 
#define REP(i,s,N) for (int i=s;i<(N); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

ll A[100000];
ll Score[100000];
string ans;

int main(){
	ll N,K,Q;
  cin >> N >> K >> Q;
  REP(i,0,Q){
    cin >> A[i];
  }
  
  REP(i,0,Q){
  		Score[A[i]-1]++;
  }
   REP(k,0,N){
   	ans = (K-Q+Score[k]>0) ? "Yes":"No";
     cout << ans << endl;
   }
	
	return 0;
}

Measured memory_bytes: 2176
// C - Train Ticket
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

int main(){
	string S; cin>>S;
	int a=S[0]-'0', b=S[1]-'0', c=S[2]-'0', d=S[3]-'0';
	rp(bit, 0, 8){
		int i = (bit&4)==4, j = (bit&2)==2, k = (bit&1)==1;
		if(7 == a + (i? -b: b) + (j? -c: c) + (k? -d: d)){
			printf("%d%c%d%c%d%c%d=7\n",
			a, (i? '-': '+'), b, (j? '-': '+'), c, (k? '-': '+'), d);
			return 0;
		}
	}
}

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

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    register int n;
    register int a;
    register long long ans=0;
    register bool t=0;

    cin>>n;
    while(n--){
        cin>>a;
        if(a==0){
            t=0;
            continue;
        }
        ans+=(a+t)/2;
        t=(a+t)%2;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AizuLCS solver = new AizuLCS();
        solver.solve(1, in, out);
        out.close();
    }

    static class AizuLCS {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            while (n-- != 0) {
                String x = in.next();
                String y = in.next();

                out.printf("%d\n", lcs(x, y));
            }
        }

        private int lcs(final String x, final String y) {
            int xlen = x.length();
            int ylen = y.length();
            int[][] dp = new int[xlen + 1][ylen + 1];

            for (int i = 1; i <= xlen; i++) {
                for (int j = 1; j <= ylen; j++) {
                    int insertion = dp[i][j - 1];
                    int deletion = dp[i - 1][j];

                    if (x.charAt(i - 1) == y.charAt(j - 1)) {
                        dp[i][j] = Math.max(dp[i - 1][j - 1] + 1, Math.min(insertion, deletion));
                    } else {
                        dp[i][j] = Math.max(insertion, deletion);
                    }
                }
            }

            return dp[xlen][ylen];
        }

    }
}




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

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

	vector<int> A;

	for (int i = 0; i < N; i++) {
		A.push_back(0);
		cin >> A[i];
	}

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

	cout << A[N - 1] - A[0] << endl;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
while(true){
   var nm=arr.shift().split(" ");
   if(nm.join(" ")=="0 0")break;
   var n=nm[0];
   var m=nm[1];
   var M=[];
   for(var i=0;i<m;i++)M.push(arr.shift()-0);
   var N=[];
   for(var i=0;i<n;i++)N.push(arr.shift()-0);
   var dp=[];
   for(var i=0;i<=n;i++){
      dp[i]=[];
      for(var j=0;j<=255;j++){
         dp[i][j]=Infinity;
      }
   }
   dp[0][128]=0;
   for(var i=1;i<=n;i++){
      for(var j=0;j<=255;j++){
         if(dp[i-1][j]!=Infinity){
            for(var k=0;k<m;k++){
               var jm=j+M[k];
               if(jm<0)jm=0;
               if(jm>255)jm=255;
               dp[i][jm]=Math.min(dp[i][jm],dp[i-1][j]+Math.pow(N[i-1]-jm,2));
            }
         }
      }
   }
   var min=Infinity;
   dp[n].forEach(function(v){
      min=Math.min(min,v);
   });
   console.log(min);
}

Measured memory_bytes: 239560
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main(){
	string a,b;
	cin>>a>>b;
	int count=0;
	for(int i=0;i<a.size();i++){
	   if(a[i]!=b[i]){
	      count++;
	   }
	}
	cout<<count<<endl;
}

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

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int N, K, D[9];

bool check(int a){
  bool flag = true;
  string b = to_string(a);
  rep(i,b.size()){
    rep(j,K){
      if(a % 10 == D[j]) flag = false;
    }
    a = a/10;
  }
  return flag;
}

int main(){
  memset(D, -1, sizeof(D));
  cin >> N >> K;
  rep(i, K){
    int d;
    cin >> d;
    D[i] = d;
  }
  int ans = N;
  while(true){
    if(check(ans)){
      break;
    }
    ans++;
  }
  cout << ans <<endl;
}
  
  

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int dx[4] = {-1, 0, 0, 1}, dy[4] = {0, -1, 1, 0};
constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

void solve() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i=0; i<3; ++i) if (s[i] == t[i]) ++ans;
    cout << ans << endl;
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3648
#include <cstdio>

using namespace std;

const int mod = 998244353;
int c[100000];

int main() {
    int n, i, j;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int x;
        
        scanf("%d", &x);
        
        if (i == 0 && x != 0) {
            puts("0");
            
            return 0;
        }
        
        c[x]++;
    }
    
    if (c[0] > 1) {
        puts("0");
    } else {
        long long ans = 1;
        
        for (i = 1; i < n; i++) {
            for (j = 0; j < c[i]; j++) ans = ans * c[i - 1] % mod;
        }
        
        printf("%lld\n", ans);
    }
    
    return 0;
}


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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) {is >> x;} return is;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'['; for(T i: a) {out<<i<<',';} out<<']'; return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n, s;
    cin >> n >> s;
    vector<ll> x(n), p(n);
    REP(i, n) cin >> x[i] >> p[i];

    vector<ll> path;
    ll l=0, r=n-1;
    while(1) {
        // 自明なケースで終了
        if(x[r] < s) {
            path.push_back(x[l]);
            break;
        }
        if(x[l] > s) {
            path.push_back(x[r]);
            break;
        }
        // 先に左端に行く
        if(p[l] >= p[r]) {
            path.push_back(x[r]);
            p[l] += p[r];
            r--;
        }
        // 先に右端に行く
        else {
            path.push_back(x[l]);
            p[r] += p[l];
            l++;
        }
    }

    ll ans = 0;
    for(ll i=(ll)path.size()-1; i>=0; --i) {
        ans += abs(s-path[i]);
        s = path[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long int ll;
const int N = 1e4 + 100;
vector<ll> a(N) , b(N) , c(N);
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	vector<ll> ab , abc;

	ll x, y , z , k;
	cin >> x >> y >> z >> k;
	for (int i = 0; i < x; ++i) {
		cin >> a[i];
	}

	for (int i = 0; i < y; ++i) {
		cin >> b[i];
	}

	for (int i = 0; i < z; ++i) {
		cin >> c[i];
	}


	sort(a.begin(), a.begin() + x, greater<ll>());
	sort(b.begin(), b.begin() + y, greater<ll>());
	for (int i = 0; i < min(x, k); ++i) {
		for (int j = 0; j < min(y , k); ++j) {
			ab.pb(a[i] + b[j]);
		}
	}
	sort(ab.begin(), ab.end(), greater<ll>());

	ll sz = ab.size();
	for (int i = 0; i < min( sz, k); ++i ) {
		for (int j = 0; j < min(z , k); ++j) {
			abc.pb(ab[i] + c[j]);
		}
	}
	sort( abc.begin(), abc.end(), greater<ll>() );
	for (int i = 0; i < k; ++i) cout << abc[i] << "\n";

}



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

#define ll long long
#define ld long double
#define ull unsigned long long
#define endl "\n"
#define MohamedMotaz ios::sync_with_stdio(0); cin.tie(0); ios_base::sync_with_stdio(0);
#define f(a, b, c) for(int a = b; a < c; a++)
using namespace std;
const ll mod = 1e9 + 7;



//ll fact[1000001]; ll inv[1000001];
//ll primes[100007];
//ll arr[1000007];
//ll modPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//
//	ll halfpow = modPower(b, p / 2);
//	ll toReturn = (halfpow * halfpow) % mod;
//	if (p % 2)
//		toReturn = (toReturn * b) % mod;
//
//	return toReturn;
//}
//
//ll fastPower(ll b, ll p) {
//	if (p == 0)
//		return 1;
//	ll ans = fastPower(b, p / 2);
//	ans = (ans * ans);
//	if (p % 2 != 0)
//		ans = (ans * b);
//	return ans;
//}
//ll GcdRecursive(ll a, ll b) {
//	if (b == 0) return a;
//	return GcdRecursive(b, a % b);
//}
//ll modLCM(ll a, ll b) {
//	ll val = GcdRecursive(a, b);
//	ll tmp = ((a % mod) * (b % mod)) % mod;
//	ll finalVal = ((tmp % mod) * (arr[val] % mod)) % mod;
//	return finalVal;
//
//}
//ll LCM(ll a, ll b) {
//	return (a * b) / GcdRecursive(a, b);
//}
//void move1step(ll& a, ll& b, ll q) { // a and b by reference
//	ll c = a - q * b;
//	a = b;
//	b = c;
//}
//ll GcdIterative(ll a, ll b) {
//	while (b) move1step(a, b, a / b);
//	return a;
//}
//
//void pre(ll n) {
//
//	fact[0] = 1;
//	inv[0] = 1;
//
//	for (ll i = 1; i <= n; i++) {
//		fact[i] = (i * fact[i - 1]) % mod;
//		inv[i] = modPower(fact[i], mod - 2);
//		arr[i] = modPower(i, mod - 2);
//	}
//}
//
//ll npr(ll n, ll r) {
//	return ((fact[n] * inv[n - r]) % mod);
//}
//
//ll ncr(ll n, ll r) {
//	return ((((fact[n] * inv[n - r]) % mod) * inv[r]) % mod);
//}
//
//void sieve(ll val) {
//	memset(primes, 1, sizeof primes);
//	primes[0] = primes[1] = false;
//	for (int i = 2; i <= val; i++) {
//		if (primes[i]) {
//			for (int j = i * i; j <= val; j += i) {
//				primes[j] = 0;
//			}
//		}
//	}
//
//}




bool checkPalindrome(string s) {

    f(i, 0, s.size() / 2) {
        if (s[i] != s[s.size() - i - 1]) return false;
    }
    return true;

}

int main()
{
    MohamedMotaz;
    
    string s; cin >> s;
    if (s.size() == 1) return cout << "Yes", 0;
    if (checkPalindrome(s) && checkPalindrome(s.substr(0, (s.size() - 1) / 2))) cout << "Yes";
    else cout << "No";
}








Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;

//const i64 inf = mod;

const long double eps = 1e-8;

int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    string s;
    cin >> s;
    if (s.back() == 's') {
        s += "es";
    }
    else {
        s += "s";
    }
    cout << s << endl;


    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'

int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    long long x;
    cin>>x;
    long long ans=(x/500)*1000+((x%500)/5)*5;
    cout<<ans<<endl;
}

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

vector<vector<int> > dp(110,vector<int>(2,0));

int main(){
    int N;
    cin>>N;
    priority_queue<int> q;
    for(int i=0;i<N;i++){
        int S;
        cin>>S;
        q.push(S);
    }
    for(int i=1;i<=N;i++){
        dp[i][0]+=q.top();
        if((dp[i][0]+dp[i-1][0])%10!=0){
            dp[i][0]+=dp[i-1][0];
            dp[i][1]=dp[i][0];
        }else if((dp[i][0]+dp[i-1][1])%10!=0){
            dp[i][1]=dp[i][0]+dp[i-1][1];
            dp[i][0]+=dp[i-1][0];
        }else {
            dp[i][1]=dp[i-1][1];
             dp[i][0]+=dp[i-1][0];       
        }
        q.pop();
    }
    /*
for(int i=0;i<=1;i++){
        for(int j=1;j<=N;j++){
            cout<<dp[j][i]<<" ";
        }
        cout<<endl;
    }
*/
    for(int i=N;i>=1;i--){
        if(dp[i][1]) {
            cout<<dp[i][1]<<endl;
            return 0;
        }
    }
    
    cout<<0<<endl;
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    int mx = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> h[i];
        mx = max(mx,h[i]);
    }

    for(int i = 1; i <= mx; i++){
        int cnt = 0;
        bool flag = false;
        for(int j = 0; j < n; j++){
            if(h[j] >= i && !flag){
                cnt++;
                flag = true;
            }
            else if(h[j] >= i && flag) continue;
            else flag = false;
        }
        ans += cnt;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//cout<<setprecision(1)<<fixed<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int MAX_N=100000;
const int INF = 0x3f3f3f3f;
#define eps 1e-7
//#define Kongxiangzhouye
int n;
int a[123][123];
int st[123];
int ed[123];
int now;
void dfs(int local){
	st[local]=now++;
	for(int i=1;i<=n;i++){
		if(a[local][i]){
			if(st[i]==0){
				dfs(i);
			}
		}
	}
	ed[local]=now++;
}
int main(){
	ios::sync_with_stdio(false);
	while(cin>>n){
		memset(a,0,sizeof(a));
		memset(st,0,sizeof(st));
		memset(ed,0,sizeof(ed));
		for(int i=0;i<n;i++){
			int t,m;
			cin>>t>>m;
			for(int i=0;i<m;i++){
				int te;
				cin>>te;
				a[t][te]=1;
			}
			now=1;
		}
		for(int i=1;i<=n;i++){
			if(!st[i])
				dfs(i);
		}
		for(int i=1;i<=n;i++){
			cout<<i<<" "<<st[i]<<" "<<ed[i]<<endl;
		}
	}
	return 0;
}






Measured memory_bytes: 3216
#include<bits/stdc++.h>
#include<string>
#include<vector>
using namespace std;
main()
{
	int a,b;
	cin>>a>>b;
	int f=0;
	for(int i=1;i<=3;i++)
	{
		int p = a*b*i;
		if(p%2 != 0)
		{
			f = 1;
			break;
		}
	}
	if(f == 1)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
}

Measured memory_bytes: 256
A,B=map(int,input().split())

mat=[]
for i in range(100):
  array=["."]*20+["#"]*20
  mat.append(array)

for i in range(B-1):
  j=2*(i//10)
  k=2*(i%10)
  mat[j][k]="#"
for i in range(A-1):
  j=2*(i//10)
  k=2*(i%10)+21
  mat[j][k]="."
  
print(100,40)
for i in range(100):
  print("".join(mat[i]))

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

#define PI 3.141592653589793

int main(void) {
	int x[5], i,a;

	for (i = 0; i < 5; i++)
	{
		scanf("%d", &x[i]);
		if (x[i] == 0) {
			a = i + 1;
		}
	}
	printf("%d\n",a);
	return 0;
}

Measured memory_bytes: 1732
import java.io.PrintWriter;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int N = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<>();
		
		for(int i=0; i<N; i++) {
			int A = sc.nextInt();
			if(map.get(A)==null) {
				map.put(A, 1);
			} else {
				map.put(A, map.get(A)+1);
			}
		}
		
		long ans = 0;
		for(int key : map.keySet()) {
			ans += (long)key*map.get(key);
		}
		
		int Q = sc.nextInt();
		for(int i=0; i<Q; i++) {
			int B = sc.nextInt();
			int C = sc.nextInt();
			if(map.get(B) != null) {
				int v = map.get(B);
				ans += (long)(C-B)*v;
				if(map.get(C)==null) {
					map.put(C, v);
				} else {
					map.put(C, v+map.get(C));
				}
				map.remove(B);
			}
			pw.println(ans);
		}
		
		sc.close();
		pw.close();
	}
}


Measured memory_bytes: 56768
#include <iostream>

int solve_t()
{
    int N, M;
    std::cin >> N >> M;

    int sum = 0;
    for(int i = 1; i <= M; ++i) {
        int x;
        std::cin >> x;
        sum += x;
        if (sum > N)    return -1;
    }

    return N - sum;
}

int main()
{
    std::cout << solve_t();
    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<iostream>
#include<string>
using namespace std;

int main(){
char w[8][7]={{"abcde"},{"fghij"},{"klmno"},{"pqrst"},{"uvwxy"},{"z.?! "}};
string st;
while(cin>>st){
	bool f=true;char W[200]={};

if(st.size()%2==1)cout<<"NA"<<endl;
else{
for(int i=0;i<(st.size());i+=2){
int x=st[i]-'0'-1;int y=st[i+1]-'0'-1;
W[i/2]=w[x][y];
if(x>5||x<0||y>4||y<0)f=false;
}

if(f==false)cout<<"NA"<<endl;
else cout<<W<<endl;
}
}
return 0;
}

Measured memory_bytes: 1176
#include <bits/stdc++.h>
using namespace std;
template < typename T > std::string to_string( const T& n ){
	std::ostringstream stm ;
	stm << n ;
	return stm.str() ;
}


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


Measured memory_bytes: 3088
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

using ll = long long;
using ld = long double;

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

template <class K, class T>
ostream& operator<<(ostream& os, map<K, T> v) {
    os << "[";
    for (auto vv : v) os << vv << ",";
    return os << "]";
}

const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 25;
const ll INF = 1LL << 50;
// const ld PI = acos(-1);
// const ld EPS = 1e-10;
// mt19937 mt(ll(time(0)));

template <typename T>
inline T sq(T a) { return a * a; }

template <typename T>
inline T iceil(T n, T d) { return (n + d - 1) / d; }

template <typename T>
T gcd(T a, T b) {
    if (a < b) return gcd(b, a);
    return b == 0 ? a : gcd(b, a % b);
}

template <typename T, typename U>
T ipow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b;
    return n % 2 == 0 ? mypow(b * b, n / 2) : mypow(b, n - 1) * b;
}

template <typename T, typename U>
T mpow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b % MOD;
    return n % 2 == 0 ? mypow(b * b % MOD, n / 2) : mypow(b, n - 1) * b % MOD;
}

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;

    set<ll> s = {-INF, INF}, t = {-INF, INF};
    for (int i = 0; i < A; ++i) {
        ll a;
        cin >> a;
        s.insert(a);
    }
    for (int i = 0; i < B; ++i) {
        ll a;
        cin >> a;
        t.insert(a);
    }

    for (int q = 0; q < Q; ++q) {
        ll x;
        cin >> x;
        auto sitr = s.upper_bound(x);
        ll sr = *sitr, sl = *(--sitr);
        auto titr = t.upper_bound(x);
        ll tr = *titr, tl = *(--titr);

        cout << min({
                    min(sr - x, x - tl) + (sr - tl),
                    min(tr - x, x - sl) + (tr - sl),
                    max(sr, tr) - x,
                    x - min(sl, tl),
                })
             << endl;
    }
    return 0;
}


Measured memory_bytes: 10752
/****************************
/////  Shubham Singhal
/////  LNMIIT
*****************************/
#include <bits/stdc++.h>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define pf push_front
#define ppf pop_front
#define eb emplace_back
#define lwr lower_bound
#define upr upper_bound
#define pq priority_queue
#define umap unordered_map
#define rep(i,n) for(i=0; i<n;i++)
#define repp(i,a,n) for(i=a; i<n;i++)
#define precise(x) cout<<fixed<<setprecision(x)
#define all(x) x.begin(),x.end()
#define lcm(a,b) (a*b)/__gcd(a,b)
#define prn(x) cout<<x<<"\n"
#define prn2(x, y) cout<<x<<" "<<y<<"\n"
#define prn3(x, y, z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define prn4(x, y, z, a) cout<<x<<" "<<y<<" "<<z<<" "<<a<<"\n"
#define prnv(x) for(auto i:x) cout<<i<<" "; cout<<"\n"
#define MOD 1000000007
#define MAX 300005
using namespace std;
 
typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd; 
typedef vector<int> vi;
typedef vector<long> vl;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef vector<pll> vpll;
const long long INF64 = 1'000'000'000'000'000'000ll;
clock_t time_p=clock();
void time()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
void doc()
{
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
}
const int INF=1e9+5;
int main()
{
	fast();
	int n,k;
	scanf("%d%d",&n,&k);
	vector<int> h(n);
	for(int &x : h)
		scanf("%d",&x);
	vector<int> dp(n,INF);
	dp[0]=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<=i+k;j++)
			if(j<n)
			{
				dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
			}
	}
	printf("%d",dp[n-1]);
}

Measured memory_bytes: 1024
import Control.Monad

main = do
    (h:w:_) <- map read . words <$> getLine :: IO [Int]
    xs <- replicateM h getLine
    let a1 = delAllDotLine h xs
        a2 = delAllDotLine w $ spin (length (head a1)) a1
    mapM_ putStrLn $ spin (length (head a2)) a2

delAllDotLine :: Int -> [String] -> [String]
delAllDotLine _ [] = []
delAllDotLine 0 _ = []
delAllDotLine n (x:xs)
  | all (=='.') x = delAllDotLine (n-1) xs
  | otherwise = x : delAllDotLine (n-1) xs

spin :: Int -> [String] -> [String]
spin 0 _ = []
spin n xs = map head xs : spin (n-1) (map tail xs)

Measured memory_bytes: 1916
# Code for C - Tax Increase
# Use input() to fetch data from STDIN
import math
def solve():
    [a, b] = map(int, input().split())
    
    for i in range(1, 1009):
        if math.floor(i * 0.08) == a and math.floor(i * 0.10) == b:
            print(i)
            return

    print("-1")

solve()


Measured memory_bytes: 2940
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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



int main(){
    int n,m,x;
    cin >> n >> m>> x;
    int a[200] = {} ;

    rep(i,0,m)cin >> a[i];

    int p = lb(a,m,x);
    
    P(min(p , m-p ));
	return  0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;




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

cout<<s[0]<<s.size()-2<<s[s.size()-1]<<endl;
 return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N,M,V,P; cin >> N >> M >> V >> P;
    vector <ll> A(N);
    vector <ll> pfxsum(N);
    loop(i,0,N) cin >> A[i];
    sort(A.begin(), A.end());
    pfxsum[0]=A[0];
    loop(i,1,N) pfxsum[i]=pfxsum[i-1]+A[i];
    vector <int> lastOccurence(N);
    for (int i=0; i<N; ++i)
    {
        int j=i;
        for (; j<N; ++j)
        {
            if (A[j]!=A[i]) {
                break;
            }
        }
        for (int k=i; k<j; ++k) lastOccurence[k]=j-1;
        i=j-1;
    }
    ll ans=P;
    ll cindex=N-P-1;
    while (cindex>=0)
    {
        int index=lastOccurence[cindex];
        if (index>N-P-1) ans++;
        else if (A[index]+M<A[N-P]) break;
        else if ((P+index)>=V) ans++;
        else  {
            int balance=V-(P+index);
            ll tsum = pfxsum[N-P]-pfxsum[index];
            ll ub=A[index]+M;
            // cout << index << " " << balance << " " << tsum << " " << ub << "\n";
            if ((N-P-index)*ub - tsum >= balance*M ) ans++; 
            // if (index+balance < N-P-balance+1)
            // {
            //     int ub = A[index]+M-A[N-P];
            //     int lb = A[index+balance]-A[index];
            //     if (!(lb>ub)) ans++;
            // }
        }
        cindex--;
    }
    cout << ans << "\n";
    return 0;
}

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

#define rep(i,x,y) for(int (i)=(x);(i)<(y);(i)++)

int main()
{
  int N,W,H;
  cin>>N>>W>>H;

  vector<int> X(W+1,0);
  vector<int> Y(H+1,0);

  int x,y,w;
  int minx,maxx,miny,maxy;
  rep(i,0,N){
    cin>>x>>y>>w;

    minx=max(0,x-w);
    maxx=x+w;
    miny=max(0,y-w);
    maxy=y+w;

    X[minx]++;
    if(maxx<=W){
      X[maxx]--;
    }
    Y[miny]++;
    if(maxy<=H){
      Y[maxy]--;
    }
  }

  rep(i,0,W){
    X[i+1]+=X[i];
  }
  rep(i,0,H){
    Y[i+1]+=Y[i];
  }

  bool flagx=true;
  bool flagy=true;
  rep(i,0,W){
    if(X[i]<=0){
      flagx=false;
      break;
    }
  }

  rep(i,0,H){
    if(Y[i]<=0){
      flagy=false;
      break;
    }
  }

  if(flagx==true||flagy==true){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

  return 0;
}

Measured memory_bytes: 3640