akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <complex>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
#include <assert.h>
#include <array>
#include <cstdio>
#include <cstring>
#include <random>
#include <functional>
#include <numeric>
#include <bitset>
#include <fstream>

using namespace std;

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

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

constexpr int MOD = 1e9+7;

namespace math { namespace integer {

template<class value_type> value_type mod_mul(value_type x, value_type k, ll m) { if(k == 0) { return 0; } if(k % 2 == 0) { return mod_mul((x+x) % m, k/2, m); } else { return (x + mod_mul(x, k-1, m)) % m; } }
template<class value_type> value_type mod_pow(value_type x, value_type n, ll mod) { if(n == 0) { return 1; } if(n % 2 == 0) { return mod_pow(mod_mul(x, x, mod) % mod, n / 2, mod); } else { return mod_mul(x, mod_pow(x, n - 1, mod), mod); } }
template<class value_type> value_type extgcd(value_type a, value_type b, value_type& x, value_type& y) { value_type d = a; if(b != 0) { d = extgcd(b, a%b, y, x); y -= (a / b) * x;} else { x = 1, y = 0; } return d; }
template<class value_type> value_type mod_inverse(value_type x, ll mod) { return mod_pow(x, value_type(mod-2), mod); /* use fermat */ }
template<class value_type> value_type mod_inverse_composite_num_mod(value_type a, ll mod) { value_type x, y; extgcd(a, mod, x, y); return (mod + x % mod) % mod; }

}}
using namespace math::integer;

namespace math {

constexpr int MaxFact = 1000100;

struct FactRevFactList {

  array<long long, MaxFact+1> fact_;
  array<long long, MaxFact+1> rev_fact_;

  FactRevFactList() {
    fact_[0] = 1;
    for(int i=1; i<MaxFact; i++) {
      fact_[i] = fact_[i-1] * i;
      fact_[i] %= MOD;
    }

    rev_fact_[MaxFact-1] = mod_pow(fact_[MaxFact-1], (long long)MOD-2, MOD);

    for(int i=MaxFact-2; i>=0; i--) {
      rev_fact_[i] = rev_fact_[i+1] * (i+1);
      rev_fact_[i] %= MOD;
    }
  }

  long long fact(int x) const { return fact_[x]; }
  long long fact_inv(int x) const { return rev_fact_[x]; }

};

struct CombinationBig {
  math::FactRevFactList fr_;
  long long comb(int n, int r) { return (fr_.fact(n) * fr_.fact_inv(r) % MOD) * fr_.fact_inv(n-r) % MOD; }
};

}

math::CombinationBig cbig;

int main() {

  ll H, W, A, B;cin >> H >> W >> A  >>B;

//  ll All = (cbig.comb(H + W, W) - (cbig.comb(H + B, B) - cbig.comb(H - A + B, B)) * cbig.comb(W - B + A, A) + MOD) % MOD;

  ll ans = 0;
  for(int i=0; i<=H-A-1; i++) {
    ans += mod_mul(cbig.comb(i + B - 1, B - 1), cbig.comb(H - 1 - i + W - B - 1, W - B - 1), MOD);
    ans %= MOD;
  }

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

Measured memory_bytes: 15872
#include <stdio.h>

int main(void)
{
  int key, i, j, A[3];

  scanf("%d %d %d",&A[0], &A[1], &A[2]);

  for (i = 1; i < 3; i++){
    key = A[i];
    j = i - 1;
    while ((j >=  0) && (A[j] > key)){
      A[j+1] = A[j];
      j = j-1;
    }
    A[j+1] = key;
  }

  for (i = 0; i < 2; i++)
    printf("%d ", A[i]);
  printf("%d\n", A[2]);

  return 0;
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    

    int n;
    cin>>n;
    ll ans=0;
    ffor(i,1,n+1)
    {
        if(i%3==0||i%5==0) {}
            else ans+=i;
    }
    cout<<ans;
    
    return 0;
}



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

struct P {
  int m,a,sta;
  bool operator < (const P t ) const {
    if( a == t.a) return sta < t.sta;
    return a < t.a;
  }

};

int main() {

  while(1) {
  int n;
  cin >> n;
  if(n == 0) break;

  P ls[202];
  for(int i=0;i<2*n;i++) ls[i].sta = (i+1)%2;

  int b,c,d;
  for(int i=0;i<n;i++) {
    cin >> b >> c >> d;
    ls[i*2].m = b;
    ls[i*2+1].m = b;
    ls[i*2].a = c;
    ls[i*2+1].a = d;
  }


  sort(ls,ls+2*n);

  int sum = 0;
  int flg = 0;
  for(int i=0;i<2*n;i++) {
    if(ls[i].sta == 0) sum -= ls[i].m;
    if(ls[i].sta == 1)  sum += ls[i].m;
    if(sum > 150) {
      flg = 1;
      break;
    }
  }

  if(flg == 0) cout <<"OK"<<endl;
  else cout <<"NG"<<endl;

  }

  return 0;

}

Measured memory_bytes: 1180
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
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(a > b){a = b; return 1;} return 0;}

int num[31];

int main(int argc, char const* argv[])
{
  int n, m;
  cin >> n >> m;
  rep(i, n){
    int k;
    cin >> k;
    rep(j, k){
      int x;
      cin >> x, x--;
      num[x]++;
    }
  }
  int res = 0;
  rep(i, m){
    if(num[i] == n)res++;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll=long long;
template<typename T=ll>inline T in(istream&is=cin){T ret;is>>ret;return ret;}
template<typename T>inline auto vec2(typename vector<T>::size_type h,typename vector<T>::size_type w,T v=T()){return vector<vector<T>>(h,vector<T>(w,v));}

ll count_kaijo_0(ll n)
{
    ll foo=5,ans=0;
    while(n/foo!=0){
        ans+=n/foo;
        foo*=5;
    }
    return ans;
}
int main()
{
    ll n=in();
    if(n%2==1){
        cout<<0<<endl;
        return 0;
    }else{
        cout<<n/10+count_kaijo_0(n/10)<<endl;
    }
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a=sc.nextLong();
    long b=sc.nextLong();
    long c=sc.nextLong();
    long d=sc.nextLong();
    long cab=b/c-(a-1)/c;
    long dab=b/d-(a-1)/d;
    long e=c*d/gcm(c,d);
    long i=1;
    long eab=b/e-(a-1)/e;
    System.out.println( b-(a-1) - cab - dab + eab );
  }
  static long gcm(long cc,long dd){
    long c=cc;
    long d=dd;
    while(true){
      long f=c%d;
      if(f==0){
        return d;
      }
      c=d;
      d=f;
    }
  }
}


Measured memory_bytes: 22228
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
#include <math.h>

using namespace std;
typedef long long ll;
///定義場所///
int i, j, k, l, m, n;
int N, M, K;
ll MOD = 1000000007;
int ans = 0;
int keta = 1;

//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<ll, ll> firstElof, pair<ll, ll> secondElof)
{
	return firstElof.second > secondElof.second;
}
//////////////

int main()
{
	string S;
	cin >> S;
	int sum = 0;
	for (i = 0; i < S.size(); i++) {
		if (S[i] == 'o') {
			sum++;
		}
	}
	if (8 - sum <= 15 - S.size()) {
		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define dbg(n) cout<<#n<<' '<<n<<endl;
int main(){ 
	char c;
	cin>>c;
	if(c-'a'>=0)
		cout<<"a\n";
	else
		cout<<"A\n";
}



Measured memory_bytes: 3524
import itertools
N = int(input())
S = input()
li = [i for i in S]
d_alpa = {'A':0,'B':1,'C':2,'D':3,'E':4,'F':5,'G':6,'H':7,'I':8,'J':9,'K':10,'L':11,'M':12,'N':13,'O':14,'P':15,'Q':16,'R':17,'S':18,'T':19,'U':20,'V':21,'W':22,'X':23,'Y':24,'Z':25}

keys = []
for i in li:
  va = d_alpa[i]+N
  if va <= 25:
    f_va = va
  elif va > 25:
    f_va = va - 26
  key = [k for k, v in d_alpa.items() if v == f_va]
  keys.append(key)

  
flatten_k = list(itertools.chain.from_iterable(keys))
k = ''.join(flatten_k)
print(k)

Measured memory_bytes: 4468
// atcoder/abc078/B/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  lli x, y, z;
  while (cin >> x >> y >> z) {
    auto fn = [&] (lli n) {
      return n * y + (n + 1) * z <= x;
    };
    lli small = 0;
    lli large = 1LL << 45;
    while (small + 1 < large) {
      lli mid = (small + large) / 2;
      if (fn(mid)) small = mid;
      else large = mid;
    }
    cout << (fn(large) ? large : small) << endl;
  }

  return 0;
}


Measured memory_bytes: 256
function Main(input) {
	var str = input;
	var ans = 0;
	var str = str.split("\n")[0];
	var num = str.split(" ");
	var h1 = Number(num[0]);	
	var m1 = Number(num[1]);	
	var h2 = Number(num[2]);
	var m2 = Number(num[3]);
	var k = Number(num[4]);
	
	var time1 = m1+60*h1;
	var time2 = m2+60*h2;
	ans = time2-time1-k;
	console.log(ans);
	}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29632
/*
 * @Autor: valk
 * @Date: 2020-04-04 14:56:12
 * @LastEditTime: 2020-09-17 17:06:44
 * @Description: 如果邪恶  是华丽残酷的乐章 它的终场 我会亲手写上 晨曦的光 风干最后一行忧伤 黑色的墨 染上安详
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#define emplace_back push_back
#define pb push_back
// #define fuck(a, b) cout << a << ' ' << b << ' ' << endl
// #define fuck(a, b, c) cout << a << ' ' << b << ' ' << c << ' ' << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll seed = 12289;
const double eps = 1e-6;
const ll inf = 0x3f3f3f3f;
const int N = 2e3 + 10;

ll dp[N][N], sum[N];

int main()
{
    int n;
    scanf("%d", &n);
    for (int i = 3; i <= n; i++) {
        dp[i][i] = sum[i] = 1;
    }
    for (int i = 6; i <= n; i++) {
        for (int j = 3; j <= i - 3; j++) {
            dp[i][j] += sum[i - j];
            sum[i] += dp[i][j];
            dp[i][j] %= mod;
            sum[i] %= mod;
        }
    }
    // for (int i = 1; i <= n; i++) {
    //     for (int j = 1; j <= n; j++) {
    //         printf("%lld ", dp[i][j]);
    //     }
    //     cout << endl;
    // }
    printf("%lld\n", sum[n]);
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,a[200010],dp[200010][3];

int main()
{
	cin>>n;
	rep(i,n) scanf("%lld",&a[i]);
	rep(i,200005) rep(j,3) dp[i][j]=-1e18;
	if(n%2==0)
	{
		dp[0][0]=a[0];
		dp[1][1]=a[1];
		rep(i,n-1)
		{
			rep(j,2)
			{
				if(dp[i][j]==-1e18) continue;
				if(i+2<n) dp[i+2][j]=max(dp[i+2][j],dp[i][j]+a[i+2]);
				if(i+3<n&&j==0) dp[i+3][j+1]=max(dp[i+3][j+1],dp[i][j]+a[i+3]);
			}
		}
		cout<<max(dp[n-1][1],dp[n-2][0])<<endl;
	}
	else
	{
		dp[0][0]=a[0];
		dp[1][1]=a[1];
		dp[2][2]=a[2];
		rep(i,n)
		{
			rep(j,3)
			{
				if(dp[i][j]==-1e18) continue;
				if(i+2<n) dp[i+2][j]=max(dp[i+2][j],dp[i][j]+a[i+2]);
				if(i+3<n&&j<2) dp[i+3][j+1]=max(dp[i+3][j+1],dp[i][j]+a[i+3]);
				if(i+4<n&&j==0) dp[i+4][j+2]=max(dp[i+4][j+2],dp[i][j]+a[i+4]);
			}
		}
		cout<<max(max(dp[n-1][2],dp[n-2][1]),dp[n-3][0])<<endl;
	}
	return 0;
}

Measured memory_bytes: 10008
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const ll INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  ll n,k; cin>>n>>k;
  ll ans=1;
  ll now=1;
  while(now*k<=n){
    now*=k;
    ans++;
  }
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

int main()
{
    int N, W;
    cin>>N>>W;
    vector<int> w(N), v(N);
    for (int i=0; i<N; i++)
        cin>>w[i]>>v[i];
    vector<vector<long long>> T(N, vector<long long>(W+1));
    T[0][w[0]] = v[0];
    for (int i=1; i<N; i++)
        for (int j=0; j<=W; j++)
        {
            T[i][j] = max(T[i][j], T[i-1][j]);
            if (j+w[i] <= W)
                T[i][j+w[i]] = max(T[i][j+w[i]], T[i-1][j]+v[i]);
        }
    cout<<*max_element(T[N-1].begin(), T[N-1].end())<<endl;
    return 0;
}


Measured memory_bytes: 79488
H,W = map(int,input().split())
mas = [list(input()) for i in range(H)]
new_mas = []
new_mas2 = []
for row in mas:
    if "#" in row:
        new_mas.append(row)
    elif "#" not in row:
        continue

for column in list(zip(*new_mas)):
    if "#" in column:
        new_mas2.append(column)
    elif "#" not in column:
        continue

for i in list(zip(*new_mas2)):
    for j in i:
        print(j,end="")
    print()

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n-1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < n; ++i)
#define FORR(i, s, n) for (int i = n-1; i >= s; --i)
#define ALL(c) (c).begin(), (c).end()
#define CLEAR(v) memset(v, 0, sizeof(v))
#define F first
#define S second

int n, t, a, h[1000];

int main() {
    cin >> n >> t >> a;
    REP(i, n) cin >> h[i];
    double mi = INF;
    int res = 0;
    REP(i, n) {
        double v = t - h[i] * 0.006;
        if (abs(v - a) < mi) {
            mi = abs(v - a);
            res = i;
        }
    }
    cout << (res + 1) << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <cstdio>

int s[20010], a[20010], b[20010];

int main(){
  int N; scanf("%d", &N);
  for(int i = 1; i <= N; i++){
    int x; scanf("%d", &x);
    s[x] = i;
  }

  a[1] = 1;
  for(int i = 2; i <= N; i++){
    int v = a[i - 1];
    if(s[i] - s[i - 1] > 0) v += s[i] - s[i - 1];
    a[i] = v + 1;
  }

  for(int i = 1; i <= N; i++){
    b[i] = s[i] - s[N] - a[i] + a[N] + 1;
  }

  for(int i = 1; i <= N; i++) printf("%d ", a[i]);
  printf("\n");
  for(int i = 1; i <= N; i++) printf("%d ", b[i]);
  printf("\n");
  return 0;
}

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

using namespace std;

int main(){
	int mi=100000,ma = 0,k;
	for(int i = 0;i < 5;i++){
		int a;
		cin >> a;
		mi = min(mi,a);
		ma = max(ma,a);
	}
	cin >> k;
	
	if(ma - mi > k){
		cout << ":(" << endl;
	}else{
		cout << "Yay!"<< endl;;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a;
 cin >> a;
 if(a%2==0){
     cout << fixed << setprecision(10) << 0.5 << endl;
 }else{
     cout << fixed << setprecision(10) <<(double)((a/2)+1)/a << endl;
 }
return 0;
}

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

int  Q[100000];
int f=0,e=0,f2=0,e2=0;
int Q2[100000];


void input_time(int a){
  Q[e]=a;
  e=(e+1)%100000;
}

int output_time(){
  int a=Q[f];
  f=(f+1)%100000;
  return a;
}

void input_name(int a){
  Q2[e2]=a;
 e2=(e2+1)%100000;
}

int output_name(){
  int a=Q2[f2];
  f2=(f2+1)%100000;
  return a;
}

char name[100000][15];

int main(){
  int n,q;
  int time,count;
  
  cin>>n>>q;
  for(int i=0;i<n;i++){
    cin>>name[i]>>time;
    input_time(time);
    input_name(i);
  }
  count=0;
  while(1){
    if((time=output_time())>q){
      input_time(time-q);
      input_name(output_name());
      count+=q;
    }else{
      count+=time;
      
      cout<<name[output_name()]<<' '<<count<<endl;
      
    }
    if(e==f){
      break;
    }
  }
  return 0;
}
  
  
  

Measured memory_bytes: 2684
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <climits>
#include <cstring>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

using namespace std;

const int N_MAX = 1000000;
string a[200];
string b[200];
int dp[10000][10000];

int solve(string a, string b){
  int N = a.length();
  int M = b.length();
  int n = max(N, M);
  rep(i, 0, n+1){
    rep(j, 0, n+1){
      dp[i][j] = 0;
    }
  }

  /*
    ...X
    .....X
    dp[i][j] = dp[i-1][j-1] + 1

    ...X
    .....Y
    dp[i][j] = max(dp[i-1][j], dp[i][j-1])
   */
  
  rep(row, 1, N+1){
    rep(col, 1, M+1){
      if(a[row-1] == b[col-1]){
	dp[row][col] = dp[row-1][col-1] + 1;
      }
      else{
	dp[row][col] = max(dp[row-1][col], dp[row][col-1]);
      }
    }
  }
  /*
  rep(row, 0, n+1){
    rep(col, 0, n+1){
      cout << dp[row][col] << " ";
    }
    cout << endl;
    }*/
  return dp[a.length()][b.length()];
}

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

  rep(i, 0, n){
    cin >> a[i];
    cin >> b[i];
  }
  
  rep(i, 0, n){
    cout << solve(a[i], b[i]) << endl;
  }
  
  return 0;
}



Measured memory_bytes: 11064
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int N,K;
	cin >> N >> K;
	vector<int> A(N);
	for(int i=0;i<N;++i){
		cin >> A[i];
	}
	sort( A.begin(),A.end(),greater<int>() );
	int ans = 0;
	for(int i=0;i<K;++i){
		ans += A[i];
	}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

vector<vector<int>> v(111111);
vector<ll> c;
int mp[111111];
ll ans;
ll cou;

void dfs(int now, int pre){
	REP(i, v[now].size()){
		if(v[now][i] != pre)dfs(v[now][i], now);
	}
	mp[now] = c[cou];
	ans += c[cou];
	cou++;
}

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

	int n;cin >> n;
	REP(i, n-1){
		int a, b;cin >> a >> b;
		a--;b--;
		v[a].PB(b);
		v[b].PB(a);
	}

	REP(i, n){
		ll a;cin >> a;
		c.PB(a);
	}
	sort(ALL(c));

	dfs(0, -1);
	cout << ans - c[n-1] << endl;
	REP(i, n)cout << mp[i] << " ";cout << endl;


	return 0;
}


Measured memory_bytes: 3968
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    def p(s):
        for i in range(len(s)):
            if s[i] != s[-i-1]:
                return False
        return True
    N = len(S)
    if p(S) and p(S[:(N-1)//2]) and p(S[(N+3)//2-1:]):
        return 'Yes'
    return 'No'


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 7356
s = input()
cnt = 0
for i in s:
    if i == 'R':
        cnt += 1
if cnt == 3:
    re = 3
elif cnt == 2:
    if s[1] == 'R':
        re = 2
    else:
        re = 1
elif cnt == 1:
    re = 1
else:
    re = 0
print(re)

Measured memory_bytes: 9104
fun main(args: Array<String>) {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val hx = (1..n).map { readLine()!!.toLong() }.sorted()

    var ans = Long.MAX_VALUE
    for ((i, hi) in hx.withIndex()) {
        if (hx.size < i + k) {
            break
        }

        val hmax = hx[i + k - 1]
        val hmin = hx[i]
        ans = Math.min(ans, hmax - hmin)
    }

    println(ans)
}

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

#define     ll      long long int

const int N = 200005;
int cnt[N];

int main( )
{
    int n, i, j, k;
    cin >> n;
    for (i = 2; i <= n; i++) {
        cin >> j;
        cnt[j]++;
    }
    for (i = 1; i <= n; i++) {
        cout << cnt[i] << '\n';
    }
    return 0;
}


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

using namespace std;

typedef long long ll;

#define MOD 998244353
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);


ll arr[100001];
bool vis[100001];
ll lvl[100001];



ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b>0)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }

return ans;
}

ll pow(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }

return ans;
}


/*const int N=200000;

ll fac[N+1];
ll inv[N+1];
ll p=998244353;

ll c(ll a, ll b,ll m)
{
  if(a<b)return 0;
  return (fac[a]*inv[b]%m)*(inv[a-b])%m;
}

void fill()
{
inv[0]=1;
fac[0]=1;

for(int i=1;i<=N;i++)
{
  fac[i]=fac[i-1]*i%p;
  inv[i]=powM(fac[i],p-2,p);
}

}
*/
//ld dp[2001][2001];


int main()
{  fast



ld a,b;
cin>>a>>b;

ll ans=a*b;

cout<<ans<<"\n";

 return 0;

}


Measured memory_bytes: 3744
S = input()
Q = int(input())
 
A = ""
B = ""
count = 0

Que = []
ope = []

def rev(s):
    re = ""
    for i in range(len(s)):
        re = re + s[len(s) - 1 - i]
    return re
 
for i in range(Q):
    k = input()
    if k == "1":
        count += 1
        Que.append("1")
        ope.append("0")
    else:
        Que.append("2")
        ope.append([k[2],k[4]])
 
cou = 0
 
if count % 2 == 0:
    for i in range(Q):
        if Que[i] == "1":
            cou += 1
        else:
            if (int(ope[i][0]) + cou) % 2 == 1:
                A = ope[i][1] + A
            else:
                B = B + ope[i][1]
else:
    for i in range(Q):
        if Que[i] == "1":
            cou += 1
        else:
            if (int(ope[i][0]) + cou) % 2 == 1:
                A = A + ope[i][1]
            else:
                B = ope[i][1] + B
 
if count % 2 == 0:
    S = A + S + B
else:
    S = rev(S)
    S = B + S + A
 
print(S)

Measured memory_bytes: 26448
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str = br.readLine();
			//int N = Integer.parseInt(str);
			//StringBuilder sb = new StringBuilder();
			int count = 0;
			for(int i = 0;i < str.length();i++) {
				if(str.charAt(i) == '1') {
					count++;
				}
			}
			System.out.println(count);
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}

}


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

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

  if(N%2!=0) {
    cout << "No" << endl;
    return 0;
  }
  string ans = "Yes";
  for(int i = 0; i < N/2; i++){
    if(S[i] != S[N/2+i]) ans ="No";    
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  
  int i;
  int x[5] = {1,2,3,4,5};
  scanf("%d %d %d %d %d",&x[0],&x[1],&x[2],&x[3],&x[4]);
  
  for(i=0;i<5;i++)
   if(x[i]==0){ 
     printf("%d\n",i+1);
     break;
   }
  
 return 0; 
}

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

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

	vector<int> hv(n);
	for (auto& h : hv) {
		cin >> h;
	}

	long long count = 0;
	vector<int> v(n,0);
	while (1) {

		long long prev = count;
		bool start = false;
		for (int i = 0; i < n; ++i) {
			if (v[i] < hv[i]) {
				++v[i];
				start = true;
			}
			else if(start){
				++count;
				start = false;
			}
		}

		if (start) {
			++count;
			start = false;
		}

		if (prev == count) {
			break;
		}
	}

	cout << count << endl;

	return 0;
}

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

#define MAX 10000

int main() {
  int n;
  int ele[MAX];
  int ans = 0;
  int i, j;

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> ele[i];
  }

  for (i = 0; i < n; i++) {
    int len = sqrt(ele[i]);
    for (j = 2; j <= len; j++) {
      if (ele[i] % j == 0) {
        break;
      }
    }
    if (j == len + 1) {
      ans++;
    }
  }

  cout << ans << endl;
}

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

namespace ConsoleApp1 {
    public class Class1 {
        static void Main(string[] args) {
            int nums = int.Parse(Console.ReadLine());
            List<string> item = new List<string>();

            for(var i = 0; i < nums; i++) {
                item.Add(Console.ReadLine());
            }

            Console.Write(item.Distinct().Count());
        }
    }
}

Measured memory_bytes: 47912
using System;
using System.Collections.Generic;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] A = Console.ReadLine().Split(' ');
            int[] aa = new int[N];
            int[] d = new int[N];
            for(int i = 0; i < N; i++)
            {
                aa[i] = int.Parse(A[i]);
            }
            int j = 0;int k = 1;
            int m = 0;
            while (true)
            {
                if (j < N)
                {
                    if (aa[j] == k)
                    {
                        d[j] = m;
                        j++; k++;
                    }
                    else
                    {
                        m++;
                        d[j] = m;
                        j++;
                    }
                }
                else
                {
                    break;
                }
            }
            if (d[N - 1] == N)
            {
                Console.WriteLine("-1");
            }
            else
            {
                Console.Write(d[N - 1]);
            }
        }
    }
}


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


int main(){
    
    int rahul;
    cin>>rahul;
    int arr[rahul];
    for (int i = 0; i < rahul; i++) {
        /* code */
        cin>>arr[i];
    }
    
    int count=0;
    int min=1e9;
    for (int i = 0; i < rahul; i++) {
        /* code */
        if(min>arr[i]){
            count++;
            min=arr[i];
        }
    }
    cout<<count<<endl;
    
}

Measured memory_bytes: 1152
#include <cstdio>
#include <cstring>

using namespace std;

int main(void){
	int n, id, value, num, buf[4000], bufnum, i, j;
	long long int yen[4000];
	bool f;
	while(1){
		scanf("%d",&n);
		if(n == 0){
			break;
		}
		memset(yen,0ll,sizeof(yen));
		bufnum = 0;
		for(i = 0;i < n;i++){
			scanf("%d%d%d",&id,&value,&num);
			for(j = 0;j < bufnum;j++){
				if(buf[j] == id){
					break;
				}
			}
			if(j == bufnum){
				buf[bufnum++] = id;
			}
			yen[id - 1] += (long long int)value * num;
		}
		f = true;
		for(i = 0;i < bufnum;i++){
			if(yen[buf[i] - 1] >= 1000000ll){
				printf("%d\n",buf[i]);
				f = false;
			}
		}
		if(f){
			printf("NA\n");
		}
	}
	return 0;
}

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

int a, b;
int ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> a >> b;
}

void solve(){
    ans = 1 + 2 + 3 - a - b;
}

void out(){
    cout << ans;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			int m;
			int h;
			while (!str.equals("-")) {
				m = Integer.parseInt(input.readLine());

				for (int i = 0; i < m; i++) {
					h = Integer.parseInt(input.readLine());
					str = (str.substring(h, str.length()) + str.substring(0, h));
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

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

int main(){
	int N,nyu[10],B[11],C[11],c,b,i;
	
	scanf("%d",&N);
	for(;N>0;N--){
		c=0;
		b=0;
		
		for(i=0;i<10;i++){
			scanf("%d",&nyu[i]);
			B[i]=0;
			C[i]=0;
		}
		B[10]=0;
		C[10]=0;
		
		for(i=0;i<10;i++){
			if(C[c]<nyu[i] && B[b]<nyu[i]){
				if(C[c]>=B[b]){
					C[c+1]=nyu[i];
					++c;
				}else{
					B[b+1]=nyu[i];
					++b;
				}
			}else if(C[c]<nyu[i]){
				C[c+1]=nyu[i];
				++c;
			}else if(B[b]<nyu[i]){
				B[b+1]=nyu[i];
				++b;
			}else{
				printf("NO\n");
				c=-1;
				break;
			}
		}
		
		if(c==-1){
			continue;
		}
		printf("YES\n");
	}
	return 0;
}

Measured memory_bytes: 0
s = list(input())
ans = 0
b_count = 0
w_count = 0
#B, W の転倒数を数える
for i in range(len(s)):
    if s[i] == 'B':
        b_count += 1
    else:
        w_count += 1
        ans += b_count
print(ans)


Measured memory_bytes: 4840
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - pushpush
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)
	var a int
	//b := make([]int, 0)
	var b [1000000]int
	var left int = 499999
	var right int = 500000
	var flag int = 0
	for i := 0; i < N; i++ {
		a = nextInt()
		if i%2 == 0 {
			//b = append(b, a)
			b[right] = a
			right++
			if i != 0 {
				flag = 1
			}
		} else {
			//list := []int{a}
			//b = append(list, b...)
			b[left] = a
			left--
			flag = 0
		}
	}

	if flag == 1 {
		for i := right - 1; left < i; i-- {

			fmt.Printf("%d", b[i])
			if i > left+1 {
				fmt.Printf(" ")
			} else {
				fmt.Printf("\n")
			}
		}
	} else {
		for i := left + 1; i < right; i++ {
			fmt.Printf("%d", b[i])
			if i < right-1 {
				fmt.Printf(" ")
			} else {
				fmt.Printf("\n")
			}
		}
	}
}


Measured memory_bytes: 14996
import java.util.Scanner;

class Solver {
    public void Solve() {
        String s = sc.next();
        String t = sc.next();
        int a = sc.nextInt();
        int b = sc.nextInt();
        String u = sc.next();
        if (s.equals(u)) {
            a--;
        } else {
            b--;
        }
        System.out.println(a + " " + b);
    }

    Scanner sc;

    Solver(Scanner in) {
        this.sc = in;
    }
}

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Solver s = new Solver(sc);
        s.Solve();
        sc.close();
    }
}


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

int chk(int x, int y){
  if(x-y < 0) return 0;
  return x-y;
}

int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int ans = a*x + b*y;
  int n = max(x,y) * 2;
  for(int i = 0; i <= n; i++){
    int d = i / 2;
    int temp = (chk(x,d) * a) + (chk(y,d) * b) + (c * i);
    ans = min(ans, temp);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e18;
const int MOD = 1e9 + 7;

template <typename T>
vector<T> eratos(T n){
    vector<T> primeVec;
    vector<bool> isPrime(n+1, true);
    isPrime[0] = false; isPrime[1] = false;
    for(int p = 2; p*p <= n; p++){
        if(isPrime[p]) for(int i = p*2; i <= n; i += p) isPrime[i] = false;
    }
    for(int p = 2; p <= n; p++) if(isPrime[p]) primeVec.push_back(p);
    return primeVec;
}

class Countings{
    private:
        int mod;
        vector<long long> factList, invList;
        long long Pow(long long x, long long n);
    public:
        Countings(int sz, int mod);
        long long Permutation(int n, int r);
        long long Combination(int n, int r);
        long long HomogeneousProduct(int n, int r);
};

Countings::Countings(int sz, int mod) : mod(mod), factList(sz + 1), invList(sz + 1) {
    factList[0] = 1;
    for(int i = 1; i < factList.size(); i++) {
        factList[i] = factList[i - 1] * i % mod;
    }
    invList[sz] = Pow(factList[sz], mod - 2);
    for(int i = sz - 1; i >= 0; i--) {
        invList[i] = invList[i + 1] * (i + 1) % mod;
    }
}

long long Countings::Pow(long long x, long long n){
    long long ret = 1;
    while(n > 0) {
        if(n & 1) ret = ret * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return ret;
}

long long Countings::Permutation(int n, int r){
    if(r < 0 || n < r) return 0;
    return factList[n] * invList[n - r] % mod;
}

long long Countings::Combination(int n, int r){
    if(r < 0 || n < r) return 0;
    return factList[n] * invList[r] % mod * invList[n - r] % mod;
}

long long Countings::HomogeneousProduct(int n, int r){
    if(n < 0 || r < 0) return 0;
    return (r == 0 ? 1 : Combination(n + r - 1, r));
}

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

    int n, m;
    cin >> n >> m;

    vector<int> sosuu = eratos((int)sqrt(1000000000) + 1);
    map<int, int> mp;
    int cnt = 0;
    for(auto itr = sosuu.begin(); itr != sosuu.end() && m > 1; ++itr){
        while(m % *itr == 0){
            mp[*itr]++;
            cnt++;
            m /= *itr;
        }
    }

    if(m != 1) mp[m]++, cnt++;

    Countings c(1000000, MOD);

    LL ans = 1;
    for(auto x : mp){
        ans = ans * c.Combination(x.second + n - 1, x.second) % MOD;
    }
    cout << ans << endl;
}


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


typedef vector<char> P;

int calc(string &a)
{
	auto isNum = [](char c) {return c == '0' || c == '1' || c == '2'; };
	auto isOpe = [](char c) {return c == '*' || c == '+'; };
	while (a.size() != 1)
	{
		FOR(i, a.size())
		{
			if (i + 1 >= a.size())continue;
			if (a[i] == '-'&&isNum(a[i + 1]))
			{
				char c = a[i + 1];
				switch (c)
				{
				case '0':c = '2'; break;
				case '2':c = '0'; break;
				}
				a[i + 1] = c;
				a.erase(a.begin() + i);
				break;
			}
			if (i + 4 >= a.size())continue;
			if (
				a[i] == '('
				&&isNum(a[i + 1]) 
				&& isOpe(a[i + 2]) 
				&& isNum(a[i + 3]) 
				&& a[i + 4] == ')'
				)
			{
				char x = a[i + 1];
				char y = a[i + 3];
				char c;
				if (a[i + 2] == '+')
				{
					string cc[3] = { "012","112","222" };
					c = cc[x - '0'][y - '0'];
				}
				else
				{
					string cc[3] = { "000","011","012" };
					c = cc[x - '0'][y - '0'];
				}
				a[i + 4] = c;
				FOR(k, 4)a.erase(a.begin() + i);
			}
		}
	}
	return a.front()-'0';
}

int main()
{
	while (true)
	{
		string a;
		cin >> a;
		if (a == ".")break;
		int ans = 0;
		FOR(p, 3)
		{
			FOR(q, 3)
			{
				FOR(r, 3)
				{
					string s;
					FOR(i, a.size())
					{
						switch (a[i])
						{
						case 'P':
							s.push_back(p + '0');
							break;
						case 'Q':
							s.push_back(q + '0');
							break;
						case 'R':
							s.push_back(r + '0');
							break;
						default:
							s.push_back(a[i]);
							break;
						}
					}
					if (calc(s) == 2)ans++;
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 2992
N = int(input())
L = [int(v) for v in input().split()]

L.sort()

ans = 0

if N < 3:
    print(0)
    exit()

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            li,lj,lk = L[i],L[j],L[k]
            if li + lj > lk:
                if li != lj and lj != lk and li != lk:
                    ans += 1

print(ans)


Measured memory_bytes: 9188
/*---> praveenojha33 <---> 01 September 2019 <--- > 17:50:56 <---*/
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC optimize("unroll-loops")
// #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define mod 1000000007
#define inf (int)1e18+5
#define sz(x) (int)x.size()
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define vi vector<int>
#define vpii vector<pair<int,int> > 
#define vvi vector<vector<int> >
#define PRINT_TIME cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." <<endl;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
typedef long double ld;
typedef pair<int,int> pii;
///////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////

int32_t main(){__
	int n;
	cin>>n;
	cout<<(n*(n-1))/2<<"\n";
return 0;
}

Measured memory_bytes: 256
w, h, n = map(int, input().split())

x0, y0 = (0, 0)
x1, y1 = (w, h)

for _ in range(n):
    x, y, a = map(int, input().split())
    if a == 1:
        if x0 < x:
            x0 = x
        if x1 < x:
            x1 = x
    if a == 2:
        if x0 > x:
            x0 = x
        if x1 > x:
            x1 = x
    if a == 3:
        if y0 < y:
            y0 = y
        if y1 < y:
            y1 = y
    if a == 4:
        if y0 > y:
            y0 = y
        if y1 > y:
            y1 = y

ans = (x1 - x0) * (y1 - y0)
print(ans)


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

int main() {
  int N, K;
  cin >> N >> K;
  vector<ll> p(N);
  rep(i, N) cin >> p[i];
  rep(i, N) p[i] = p[i] + 1;
  ll max = 0;
  ll now = 0;
  rep(i, K) now += p[i];
  rep(i, N-K+1) {
    if(now > max) {
      max = now;
    }
    now -= p[i];
    if(i != N-K) now += p[i+K];
  }
  if(max%2 == 0) cout << max/2 << endl;
  else cout << max/2 << ".5" << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void){
    int i,j,k,l;
    int a[4],b[4];
    int hit,bro;
    
    while(1){
        scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3]);
        if(feof(stdin))break;
        scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
        
        hit=0;
        bro=0;
        
        for(i=0;i<4;i++){
            for(j=0;j<4;j++){
                if(a[i]==b[j]){
                    if(i==j){
                        hit++;
                    }else{
                        bro++;
                    }
                }
            }
        }
        printf("%d %d\n",hit,bro);
    }
    return(0);
}

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

int main() {
    int N, H, W;
    scanf("%d", &N);
    scanf("%d", &H);
    scanf("%d", &W);
    printf("%d\n", (N - H + 1) * (N - W + 1));
    return 0;
}

Measured memory_bytes: 128
n , k = map(int, input().split())
x = list(map(int,input().split()))
b = [list(map(int,bin(x)[2:].zfill(n))) for x in range(2**n)]
h = [0]*n

def check(li,n,k):
    c=1
    hi=li[0]
    for i in range(1,n):
        if li[i]>hi:
            c+=1
            hi=li[i]
    if c>=k:
        return True
    else:
        return False

for i in range(1,n):
    h[i]=max(h[i-1],x[i-1])

mi = float('inf')
for bit in b:
    ans = 0
    s1=0
    x2=x.copy()
    if bit[0]==1:
        for i in range(n):
            if bit[i]==1:
                s2=x[i]
                if s2<=s1:
                    ans+=s1-s2+1
                    s2=s1+1
                if s2<=h[i]:
                    ans += h[i]-s2+1
                    s2=h[i]+1
                s1=s2
                x2[i]=s2
            else:
                x2[i]=x[i]
    if check(x2,n,k):
        mi=min(mi,ans)

print(mi)


Measured memory_bytes: 10980
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int a1 = 10 * A + B + C;
  int a2 = A + 10 * B + C;
  int a3 = A + B + 10 * C;
  cout << max({a1, a2, a3}) << endl;
  return 0;
}


Measured memory_bytes: 256