akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n;
  cin >> n;
  // ll n, m;
  // cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  map<string, ll> m;
  while(n--){
    string s;
    cin >> s;
    sort(all(s));
    m[s] += 1;
  }
  for(auto x: m) {
    if(x.second == 1) continue;
    ans += x.second * (x.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define md 1000000007
#define ll long long 
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define fastmap mp.reserve(1024);mp.max_load_factor(0.25);
#define fastset st.reserve(1024);st.max_load_factor(0.25);
ll int mpw(ll int a,ll int b,ll int m)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans=(ans*a)%m;
		}
		a=(a*a)%m;
		b>>=1;
	}
	return ans;
}
 
ll int pw(ll int a,ll int b)
{
	ll int ans=1;
	if(a==0)return 0;
	if(a==1 || b==0)return 1;
	while(b)
	{
		if(b&1)
		{
			ans*=a;
		}
		a*=a;
		b>>=1;
	}
	return ans;
}
 
ll int mn(ll int a,ll int b)
{
	if(a<=b)
	{
		return a;
	}
	return b;
}
 
ll int mx(ll int a,ll int b)
{
	if(a>=b)
	{
		return a;
	}
	return b;
}

int main()
{
	fio
	int n;
	cin>>n;
	string s;
	cin>>s;
	vector<vector<ll int>>D(n,vector<ll int>(n+1,0));

	for(int i=1;i<=n;++i)
	{
		D[0][i]=1;
	}
	for(int i=1;i<n;++i)
	{
		for(int j=1;j<=i+1;++j)
		{
			if(s[i-1]=='<')
			{
				D[i][j]=(((D[i-1][j-1]-D[i-1][0])%md)+md)%md;
			}
			else{
				D[i][j]=(((D[i-1][n]-D[i-1][j-1])%md)+md)%md;
			}
		}
		for(int j=1;j<=n;++j)
		{
			D[i][j]=(D[i][j]+D[i][j-1])%md;
		}
	}
	
	cout<<(D[n-1][n])<<"\n";
	return 0;
}

Measured memory_bytes: 73652
#include<bits/stdc++.h>
#define int long long
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

signed main()
{
        string A,B,C; cin>>A>>B>>C;
        int posA=0,posB=0,posC=0;
        int cur=0;
        while(true){
                if(cur==0){
                        if(posA==A.size()){
                                cout<<'A'<<endl;
                                return 0;
                        }
                        cur=A[posA++]-'a';
                }
                if(cur==1){
                        if(posB==B.size()){
                                cout<<'B'<<endl;
                                return 0;
                        }
                        cur=B[posB++]-'a';
                }
                if(cur==2){
                        if(posC==C.size()){
                                cout<<'C'<<endl;
                                return 0;
                        }
                        cur=C[posC++]-'a';
                }
        }
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  if(a==1){
    a=14;
  }
  if(b==1){
    b=14;
  }
  string ret;
  if(a==b){
    ret="Draw";
  }else if(a<b){
    ret="Bob";
  }else{
    ret="Alice";
  }
  cout<<ret;
  return 0;
}
    

Measured memory_bytes: 256
"use strict";
function Main(input) {
  input = input.split("\n");
  let arr = input[1].split(" ");

  let result = 0;
  while (true) {
    for (const i in arr) {
      if (parseInt(arr[i]) % 2 == 0) {
        arr[i] = parseInt(arr[i]) / 2;
      } else {
        console.log(result);
        return;
      }
    }
    result++;
  }
}

Main(require("fs").readFileSync("/dev/stdin", "utf-8"));


Measured memory_bytes: 21064
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
B.append(0)

ans = 0
for i in range(N+1):
  taosukazu1 = min(A[i],B[i])
  B[i] -= taosukazu1
  A[i] -= taosukazu1
  ans += taosukazu1
  if B[i] > 0:
    taosukazu2 = min(A[i+1],B[i])
    B[i] -= taosukazu2
    A[i+1] -= taosukazu2
    ans += taosukazu2
print(ans)

Measured memory_bytes: 25448
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {
	ll n;
	cin >> n;
	VL v(n);
	cin >> v;

	ll ans = 0;
	ll cnt = -1;
	ll now = 1e10;
	REPC(x, v) {
		if (x > now) { now = x; cnt = 0; continue; }
		++cnt;
		MAX(ans, cnt);
		now = x;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
// 解き直し.
// https://img.atcoder.jp/abc154/editorial.pdf
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define repex(i, a, b, c) for(LL i = a; i < b; i += c)
#define repx(i, a, b) repex(i, a, b, 1)
#define rep(i, n) repx(i, 0, n)
const LL MOD = 1e9 + 7;
const int LIMIT = 2020202;
LL FAC[LIMIT];
LL INV[LIMIT];

// Fermat's little theorem から, 大きな冪乗の計算を行う.
// @param a: べき乗したい正整数.
// @param b: 指数.
// @return:  べき乗した計算結果(mod版).
LL inverse(LL a, LL b){
    LL t = 1;
    while(b){
        if(b & 1) t = (t * a) % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return t % MOD;
}

// 組み合わせ(nCk)計算用(mod版).
// ※配列FAC, INV は, 事前に計算済のものを使う.
// @param n: 対象となる要素の個数.
// @param k: 選択する要素の個数.
// @return: 組み合わせ(nCk)の計算結果(mod版).
LL combination(LL n, LL k){
    if(n < 0 || k < 0 || k > n) return 0;
    LL ret = FAC[n] * INV[k] % MOD * INV[n - k] % MOD;
    return ret;
}

// (0, 0) ～ (r, c) の範囲で, 組み合わせ(nCk) の 総和 を 計算.
// @param r: (目的地の)行番号.
// @param c: (目的地の)列番号.
// @return : 計算結果(mod版).
LL S(LL r, LL c){
    // TLE版.
    // ex.
    // 12345 123 54321 543
    // -> 614939681 の 出力で, 481[ms] かかった.
    // LL ret = 0;
    // rep(i, r + 1) rep(j, c + 1) ret += combination(i + j, i), ret %= MOD;
    
    // 高速版(解説通り).
    LL ret = combination(r + 1 + c + 1, c + 1);
    ret += MOD;
    ret--;
    ret %= MOD;
    return ret;
}

int main(){
    
    // 1. 入力情報.
    LL r1, c1, r2, c2;
    scanf("%lld %lld %lld %lld", &r1, &c1, &r2, &c2);
    FAC[0] = 1;
    repx(i, 1, LIMIT) FAC[i] = i * FAC[i - 1] % MOD;
    rep(i, LIMIT)     INV[i] = inverse(FAC[i], MOD - 2) % MOD;
    
    // 2. チェック.
    assert(S(0, 0) == combination(1 + 1, 1) - 1);
    assert(S(0, 1) == combination(1 + 2, 2) - 1);
    assert(S(1, 0) == combination(2 + 1, 1) - 1);
    assert(S(1, 1) == combination(2 + 2, 2) - 1);
    assert(S(5, 8) == combination(6 + 9, 9) - 1);
    assert(S(12, 15) == combination(13 + 16, 16) - 1);
    
    // 3. 経路数の総和を計算(解説通り).
    // S(r, c) = ΣΣf(i, j) (0 <= i <= r, 0 <= j <= c) と置くと,
    // S(r2, c2) - S(r2, c1 - 1) - S(r1 - 1, c2) + S(r1 - 1, c1 - 1) で 計算可能とのこと.
    // また, S(r, c) = f(r + 1, c + 1) - 1 となることを使うらしい.
    LL ans = 0;
    ans += S(r2, c2);
    ans += MOD;
    ans -= S(r2, c1 - 1);
    ans %= MOD;
    ans += MOD;
    ans -= S(r1 - 1, c2);
    ans %= MOD;
    ans += S(r1 - 1, c1 - 1);
    ans %= MOD;
    
    // 4. 出力 ～ 後処理.
    printf("%lld\n", ans);
    return 0;
    
}

Measured memory_bytes: 31872
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    int a = N % 10;
    if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9) cout << "hon" << endl;
    else if(a == 0 || a == 1 || a == 6 || a == 8) cout << "pon" << endl;
    else cout << "bon" << endl;
}

Measured memory_bytes: 3636
using System;
using System.Linq;


class Program
{
    static void Main(string[] args)
    {
        Console.ReadLine();
        string[] input = Console.ReadLine().Split(' ');

        long[] intAry = Array.ConvertAll(input, long.Parse);
        Console.WriteLine("{0} {1} {2}", intAry.Min(), intAry.Max(), intAry.Sum());
    }
}



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

bool checkRange(int n)
{
    if ((n >= 1) && (n <= 9)) {
        return true;
    }
    else {
        return false;
    }
}

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

    int C;
    if (checkRange(A) & checkRange(B)) {
        C = A * B;
    }
    else {
        C = -1;
    }
    cout << C << endl;
    return 0;
}

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

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

int W, H;
vector<string> mp;
int dir[4][2]={{0,1},{1,0},{0,-1},{-1,0}};

void solve(int x, int y){
  if(x<0 || H<=x || y<0 || W<=y || mp[x][y]!='.')return;
  mp[x][y]='A';
  rep(i,4)solve(x+dir[i][0], y+dir[i][1]);
}

int main(){
  while(true){
    cin>>W>>H;
    if(W==0&&H==0)break;
    mp.clear();
    rep(i,H){
      string s;
      cin>>s;
      mp.push_back(s);
    }
    int sx, sy;
    rep(i,H)rep(j,W)if(mp[i][j]=='@'){sx=i; sy=j; break;}
    mp[sx][sy]='.';
    solve(sx, sy);

    int cnt=0;
    rep(i,H)rep(j,W)if(mp[i][j]=='A')cnt++;
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>

int d;
int c[27];
int s[370][27];


int main(){
  //printf("%d\n",d); //0
  scanf("%d",&d);

  //printf("%d\n",d); //365
  for(int i=0;i<26;i++){
    scanf("%d",&c[i]);}

  //printf("%d\n",d); //1927
  for(int i=0;i<d;i++){
    for(int j=0;j<26;j++){
      scanf("%d",&s[i][j]);}}

  int last[27]={};
  //printf("%d\n",d);
  for(int i=1;i<=d;i++){
    int max=0;
    int maxid=0;
    for(int j=0;j<26;j++){
      int tmp = c[j]*(i-last[j])+s[i-1][j];
      if(tmp>max){
	max = tmp;
	maxid = j;}
    }
    last[maxid]=i;
    printf("%d\n",maxid+1);
  }

  //printf("haha\n");
  return 0;
}


Measured memory_bytes: 1760
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int[][] bingo = new int[3][3];
		for(int i = 0; i < 3; i++){
		    for(int j = 0; j < 3; j++){
		        bingo[i][j] = sc.nextInt();
		    }
		}
		int n = sc.nextInt();
		int[] b = new int[n];
		for(int i = 0; i < n; i++){
		    b[i] = sc.nextInt();
		}
		
		// 計算
		String result = "No";
		for(int i = 0; i < 3; i++){
		    for(int j = 0; j < 3; j++){
		        for(int k = 0; k < n; k++){
		            if(bingo[i][j] == b[k]) bingo[i][j] = 0;
		        }
		    }
		}
		for(int i = 0; i < 3; i++){
		    boolean flg = true;
		    for(int j = 0; j < 3; j++){
		        if(bingo[i][j] != 0) flg =false;
		    }
		    if(flg) result = "Yes";
		}
		for(int i = 0; i < 3; i++){
		    boolean flg = true;
		    for(int j = 0; j < 3; j++){
		        if(bingo[j][i] != 0) flg = false;
		    }
		    if(flg) result = "Yes";
		}
		if(bingo[0][0] == 0 && bingo[1][1] == 0 && bingo[2][2] == 0) result = "Yes";
		if(bingo[0][2] == 0 && bingo[1][1] == 0 && bingo[2][0] == 0) result = "Yes";
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 21716
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#define lp(n) for (int i = 0; i < n; i++)
#define lop(n,i) for (int i = 0; i < n; i++)
#define INT_MAX 2147483647
#define LLINT_MAX 9223372036854775807
#define mod 1000000007
#define ll long long int
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>l(n*2);
	lp(n*2)
		cin >> l[i];
	sort(l.begin(), l.end());
	int ans = 0;
	lp(n)
		ans += l[i * 2];
	cout << ans << endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) {
        if(a[i] % 2 == 0) {
            if(a[i] % 3 == 0 or a[i] % 5 == 0) {

            } else {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}


Measured memory_bytes: 3600
#pragma once
#include <string.h>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
#define INF 1000000007
typedef long long ll;
typedef pair<int, int> pii;
int t[101];
int pri[26];
int res = 0;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[y] = px;
	}
	else {
		pr[x] = py;
	}
	return true;
}

// dinic
struct max_flow {
	struct edge { int to, cap, rev;
	edge(int _to, int _cap, int _rev) : to(_to), cap(_cap), rev(_rev) {}
	};
	int V;
	vector<vector<edge>> G;
	vector<int> itr, level;

	max_flow(int V) : V(V) { G.assign(V, vector<edge>()); }

	void add_edge(int from, int to, int cap) {
		G[from].push_back(edge (to, cap, (int)G[to].size() ));
		G[to].push_back(edge (from, 0, (int)G[from].size() - 1 ));
	}

	void bfs(int s) {
		level.assign(V, -1);
		queue<int> q;
		level[s] = 0; q.push(s);
		while (!q.empty()) {
			int v = q.front(); q.pop();
			for (auto &e : G[v]) {
				if (e.cap > 0 and level[e.to] < 0) {
					level[e.to] = level[v] + 1;
					q.push(e.to);
				}
			}
		}
	}

	int dfs(int v, int t, int f) {
		if (v == t) return f;
		for (int& i = itr[v]; i < (int)G[v].size(); ++i) {
			edge& e = G[v][i];
			if (e.cap > 0 && level[v] < level[e.to]) {
				int d = dfs(e.to, t, min(f, e.cap));
				if (d > 0) {
					e.cap -= d;
					G[e.to][e.rev].cap += d;
					return d;
				}
			}
		}
		return 0;
	}

	int run(int s, int t) {
		int ret = 0, f;
		while (bfs(s), level[t] >= 0) {
			itr.assign(V, 0);
			while ((f = dfs(s, t, INF)) > 0) ret += f;
		}
		return ret;
	}
};
vector<vector<int> > calcNext(const string &S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}

const int MOD = 1000000007;
// mod 1000000007 の世界で a += b する関数
void add(long long &a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll c[26];
ll memo[26];
ll rec(int i) {

	if (i == 26) {
		return 1;
	}
	ll &res = memo[i];
	if (~res) return res;
	res = 0;
	for (size_t j = i + 1; j <= 26; j++)
	{
		ll v = c[i] * rec(j);
		v %= INF;
		res += v;
		res %= INF;
	}
	return res;
}
void solv() {
	int n;
	cin >> n;
	ll c[200010];
	c[0] = 0;
	for (size_t i = 1; i <= n; i++)
	{
		cin >> c[i];
	}

	int bef[200010];
	memset(bef, -1, sizeof(bef));

	ll dp[200010];
	dp[0] = 1;
	for (size_t i = 1; i <= n; i++)
	{
		ll b = bef[c[i]];

		dp[i] = (dp[i - 1] + ((b == -1 || b == i - 1) ? 0 : dp[b])) % INF;
		bef[c[i]] = i;
	}
	cout << dp[n] << endl;
}


int main() {
	solv();

	return 0;
}


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

prev_t = 0
prev_x = 0
prev_y = 0

for i in range(N):
    t,x,y = map(int,input().split())
    dist = abs(x-prev_x)+ abs(y-prev_y)
    if dist > (t-prev_t) or (dist+(t - prev_t))%2:
        print("No")
        exit()
    prev_t = t
    prev_x = x
    prev_y = y

print("Yes")


Measured memory_bytes: 9200
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons;

T[][] comb(T)(in T[] arr, in int k) pure nothrow {
    if (k == 0) return [[]];
    typeof(return) result;
    foreach (immutable i, immutable x; arr)
        foreach (suffix; arr[i + 1 .. $].comb(k - 1))
            result ~= x ~ suffix;
    return result;
}

int N;
string[10^^5] SS;

void main()
{
    N = readln.chomp.to!int;
    foreach (i; 0..N) SS[i] = readln.chomp;

    long[5] march;
    foreach (s; SS[0..N]) {
        switch (s[0]) {
            case 'M': ++march[0]; break;
            case 'A': ++march[1]; break;
            case 'R': ++march[2]; break;
            case 'C': ++march[3]; break;
            case 'H': ++march[4]; break;
            default:
        }
    }

    auto cb = [0, 1, 2, 3, 4].comb(3);
    long ret;
    foreach (c; cb) ret += march[c[0]] * march[c[1]] * march[c[2]];
    writeln(ret);
}

Measured memory_bytes: 3452
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
int main() {
    string s;
    cin>>s;
    //char ans[50000];
    string ans;
    int count=0;
    for(int i=0;i<s.size();i++){
        if(i%2==0){
            ans += s[i];
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 760
#include "bits/stdc++.h"
 
using namespace std;
 
#define fast_cin() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define rep(i, x, n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define eb emplace_back
#define trav(a, x) for(auto& a: x)
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define MOD 1000000007
 
typedef vector<int> vec;
typedef long long ll;
typedef unsigned long long ull;
 
int main(){
    fast_cin();
    int n;cin>>n;
    ll ans = 0;
    ans+=1000*(n/500);
    n%=500;
    ans+=5*(n/5);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n];
		for (int i = 0; i < n; i++) {
		    arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		long ans = 0;
		PriorityQueue<Pair> queue = new PriorityQueue<>();
		queue.add(new Pair(arr[n - 1], arr[n - 2]));
		queue.add(new Pair(arr[n - 1], arr[n - 2]));
		ans += arr[n - 1];
		for (int i = n - 3; i >= 0; i--) {
		    Pair p = queue.poll();
		    ans += p.value();
		    queue.add(new Pair(arr[i], p.left));
		    queue.add(new Pair(arr[i], p.right));
		}
		System.out.println(ans);
	}
	
	static class Pair implements Comparable<Pair> {
	    int left;
	    int right;
	    
	    public Pair(int left, int right) {
	        this.left = left;
	        this.right = right;
	    }
	    
	    public int value() {
	        return Math.min(left, right);
	    }
	    
	    public int compareTo(Pair another) {
	        return another.value() - value();
	    }
	}
}


Measured memory_bytes: 62428
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int N; cin >> N;
    vector< vector<int> > G(N);
    map< pair<int, int>, int > edge_id;
    for(int i=0; i<N-1; i++) {
        int u, v; cin >> u >> v;
        u--; v--;
        G[u].emplace_back(v);
        G[v].emplace_back(u);
        edge_id[minmax(u, v)] = i;
    }

    vector<int> p(N), rec(N-1);
    auto dfs = [&](auto&& f, int cur, int par, int tar, int id, int root) -> void {
        for(auto to : G[cur]) {
            if(to == par) continue;
            p[to] = cur;
            if(to == tar) {
                int v = tar;
                while(v != root) {
                    int u = p[v];
                    fprintf(stderr, "u = %d, v = %d\n", u, v);
                    rec[edge_id[minmax(u, v)]] |= (1 << id);
                    v = p[v];
                }
                return;
            }
            f(f, to, cur, tar, id, root);
        }
    };

    int M; cin >> M;
    vector<int> X(M), Y(M);
    for(int i=0; i<M; i++) {
        cin >> X[i] >> Y[i]; X[i]--; Y[i]--;
        fill(p.begin(), p.end(), -1);
        dfs(dfs, X[i], -1, Y[i], i, X[i]);
    }

    ll ans = 0;
    // 選ばないものの集合
    for(int bit=0; bit<(1<<M); bit++) {
        int cnt = 0;
        for(int i=0; i<N-1; i++) if((bit & rec[i]) == 0) cnt++;
        if(__builtin_parity(bit)) ans -= (1LL << cnt);
        else ans += (1LL << cnt);
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC optimize("fast-math")
#define y1 y3278
#define y2 y4368
#define y y4368232
#define x x43682322
#define ff first
#define ss second
#define pb push_back
#define all(a) a.begin(),a.end()
#define tm tm3278
#define left left3278
#define right right3278
typedef long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
template <class T> using Pair_indexed_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
const long long INF = 2000000000000000000;
const long long Maxll = 9223372036854775807;
const long long MOD = 1000000000000037;
const long long MOD2 = 1000000000 + 7;
const long long q0 = 239;
const int differ = 'a' - 'A';
template <class T>
istream& operator >> (istream &in, vector <T> &a)
{
    for (T &i: a) in >> i;
    return in;
}
template <class T>
ostream& operator << (ostream &out, vector <T> &a)
{
    for (T &i: a) out << i;
    out << '\n';
    return out;
}
template <class T>
ostream& operator << (ostream &out, set <T> &a)
{
    //out << a.size() << '\n';
    for (T i: a) out << i << ' ';
    return out;
}
/// Actual code starts here
ll t, m, n, a, b, mark, k, d,h, c;

void Kloynada() {
    cin >> n >> m;
    if (n  <= m) {
        cout << "unsafe";
    }
    else
        cout << "safe";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    t = 1;
    //cin >> t;
    while (t--)
        Kloynada();
}

Measured memory_bytes: 3644
//khodaya khodet komak kon
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int n, a[N], b[N], cnt[N], par[N], ans, sz[N];
vi num, G[N], GG[N];
bool mark[N];

int getpar(int v){
	return (par[v] == v?v:par[v] = getpar(par[v]));
}

void merge(int v, int u){
	v = getpar(v), u = getpar(u);
	if (v == u) return;
	if (sz[v] < sz[u]) swap(v, u);
	ans --;
	par[u] = v;
	sz[v] += sz[u];
}

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int X = 0;
	cin >> n;
	for (int i = 1; i < N; i++) par[i] = i, sz[i] = 1;
	for (int i = 1; i <= n; i++){
		cin >>a[i];
		X ^= a[i];
		num.pb(a[i]);
	}
	a[n + 1] = X;
	num.pb(X);
	for (int i = 1; i <= n; i++){
		cin >> b[i];
		num.pb(b[i]);
	}
	sort(all(num));
	num.resize(unique(all(num)) - num.begin());
	for (int i = 1; i <= n + 1; i++){
		a[i] = lower_bound(all(num), a[i]) - num.begin() + 1;
		cnt[a[i]]++;
	}
	for (int i = 1; i <= n; i++){
		b[i] = lower_bound(all(num), b[i]) - num.begin() + 1;
		if (cnt[b[i]] == 0) return cout << -1, 0;
		cnt[b[i]]--;
	}	
	for (int i = 0; i <N; i++){
		if (cnt[i] == 1){
			X = i;
			break;
		}
	}
//	cout << X << '\n';
	memset(cnt, 0, sizeof cnt);
	for (int i = 1; i <= n; i++){
		if (a[i] == b[i]) continue;
		ans ++;
		cnt[a[i]]++;
		G[b[i]].pb(i);
	}
	G[b[n + 1]].pb(n + 1);
	if (ans == 0) return cout << 0, 0;
	ans ++;
	ans *= 2;
	ans -= 2;
//	cout << ans << '\n';
	for (int i = 1; i <= n; i++){
		if (a[i] == b[i]) continue;
		GG[a[i]].pb(i);
	}
	GG[a[n + 1]].pb(n + 1);
	for (int i = 1; i <= n; i++){
		if (a[i] == b[i]) continue;
		if (!mark[a[i]]){
			mark[a[i]] = 1;
			for (auto u:G[a[i]]){
				merge(i, u);
			}
			for (auto u:GG[a[i]]) merge(i, u);
		}
	}
	if (!mark[a[n + 1]]){
		for (auto u:G[a[n + 1]]){
			merge(n + 1, u);
		}
	}
	cout << ans;
	return 0;
}


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

int main()
{

        int N;
        cin >> N;
        set<int> key;
        map<int, int> m;
        for (int i= 0; i < N; ++i) {
                int tmp;
                cin >> tmp;
                key.insert(tmp);
                m[tmp] += 1;
        }
        long long ans = 0;
        for (auto k : key) {
                if (m[k] == k) {

                }
                else if (m[k] > k) {
                        ans += (m[k]-k);
                }
                else {
                        ans += m[k];
                }
        }
        cout << ans << endl;



}


Measured memory_bytes: 9216
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int x;
    cin >> x;
    long long int l = 0, v = 100;
    while(1)
    {
        l++;
        v += v / 100;
        if(v>=x)
        {
            cout << l;
            break;
        }
    }
    return 0;
}

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

int main(){
    string s;
    int len;
    int firstA, lastZ;
    cin >> s;
    len = (int)(s.length());
    for(int i = 0; i < len; i++){
        if(s[i] == 'A'){
            firstA = i;
            break;
        }
    }
    for(int i = len - 1; i >= 0; i--){
        if(s[i] == 'Z'){
            lastZ = i;
            break;
        }
    }
    cout << lastZ - firstA + 1 << endl;
}

Measured memory_bytes: 640
def inpl():
    return list(map(int, input().split()))


N, A = inpl()
X = inpl()
maxX = max(X)

dp = [[[0 for _ in range(N * maxX + 1)] for j in range(i + 1)]
      for i in range(51)]

dp[0][0][0] = 1
for i in range(N):
    x = X[i - 1]
    for j in range(i + 1):
        for k in range(N * maxX + 1):
            # print(i, j, k)
            if dp[i][j][k] == 0:
                continue
            dp[i + 1][j][k] += dp[i][j][k]
            dp[i + 1][j + 1][k + x] += dp[i][j][k]

ans = 0
for j in range(1, N + 1):
    if j * A > N * maxX:
        continue
    ans += dp[N][j][j * A]
print(ans)


Measured memory_bytes: 39152
A,V=map(int,input().split())
B,W=map(int,input().split())
T=int(input())
if A<B:
    if A+T*V>=B+W*T:
        print("YES")
    else:
        print("NO")
if A>B:
    if A-T*V<=B-W*T:
        print("YES")
    else:
        print("NO")


Measured memory_bytes: 9180
#include <algorithm>
#include <cassert>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

using namespace std;

using Pii = pair<int, int>;

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

    vector<int> dists(K + 1, -1);
    priority_queue<Pii, vector<Pii>, std::greater<Pii>> pq;
    pq.push(make_pair(0, K));

    while (!pq.empty()) {
        int dist = pq.top().first;
        int n = pq.top().second;
        pq.pop();

        if (dists[n] != -1)
            continue;

        dists[n] = dist;

        for (int d = 0; d < 10; ++d) {
            int l = (n + K * d) % 10;
            int h = (n + K * d) / 10;
            pq.push(make_pair(dist + l, h));
        }
    }

    cout << dists[0] << '\n';

    return 0;
}


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

using ll = long long;
#define int long long

#define LOG(variable) cout << #variable":\t" << (variable) << endl
#define LOGCON(i, container) for(int (i) = 0; (i) < (container).size(); ++(i)) cout << (i) << ":\t" << (container)[(i)] << endl
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, n, r) for(int i = (n); i >= (r); --i) // from n to r
#define REPOBJ(itr, obj) for(auto itr = (obj).begin(); itr != (obj).end() ; ++itr)
#define REPROBJ(itr, obj) for(auto itr = (obj).rbegin(), e = (obj).rend(); itr != e; ++itr)
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
constexpr int MAX = 2005;
int H, W;
bool g[MAX][MAX];
int in() {int x; cin>>x; return x;}
string stin() {string s; cin>>s; return s;}
int vert_count[MAX][MAX];
int hori_count[MAX][MAX];
/***** MAIN *****/
signed main() {
  cin >> H >> W;
  REP(h, H) {
    REP(w, W) {
      char c;
      cin >> c;
      g[h][w] = (c == '.');
    }
  }
  REP(h, H) {
    int start_w = 0;
    REP(w, W) {
      if(!g[h][w]) {
        if(w-start_w) {
          REPS(i, start_w, w) {
            hori_count[h][i] = w - start_w;
          }
        }
        start_w = w + 1;
      }
    }
    if(start_w < W) {
      REPS(i, start_w, W) {
        hori_count[h][i] = W - start_w;
      }
    }
  }
  REP(w, W) {
    int start_h = 0;
    REP(h, H) {
      if(!g[h][w]) {
        if(h-start_h) {
          REPS(i, start_h, h) {
            vert_count[i][w] = h - start_h;
          }
        }
        start_h = h+1;
      }
    }
    if(start_h < H) {
      REPS(i, start_h, H) {
        vert_count[i][w] = H - start_h;
      }
    }
  }
  int ans = 0;
  REP(h, H) {
    REP(w, W) {
      ans = max(ans, hori_count[h][w]+vert_count[h][w]-1);
    }
  }
  cout << ans;
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 66944
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

vector<int> as;

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

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

    ll ans = 0;
    int cur_h = as[0];
    for (int i = 1; i < N; i++) {
        if (cur_h > as[i]) {
            // printf("i: %d, += %d\n", i, cur_h - as[i]);
            ans += cur_h - as[i];
        } else {
            cur_h = as[i];
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3908
// Created by sz
#include <bits/stdc++.h>
using namespace std;


int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int cur = 0;
    char s[15], c;
    while(cin>>c){
        if(c=='B'){if(cur) cur--;}
        else s[cur++] = c;
    }
    for(int i = 0;i<cur; i++)cout<<s[i];
    cout<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
const int MAXN = 5e3 + 5;

int b[MAXN][205], n, m;
long long a[MAXN], sum[MAXN][MAXN];
int l[MAXN];
int stack[MAXN], top;


int main() {
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= n - 1; i++) scanf("%lld", &a[i]);
	for(int i = 1; i <= n; i++) for(int j = 1; j <= m; j++) scanf("%d", &b[i][j]);

	for(int j = 1; j <= m; j++) {
		top = 0;
		stack[top++] = 0;
		for(int i = 1; i <= n; i++) {
			while(top > 1 && b[stack[top - 1]][j] < b[i][j]) top--;
			l[i] = stack[top - 1];
			stack[top++] = i;
		}
		top = 0;
		stack[top++] = n + 1;
		for(int i = n; i >= 1; i--) {
			while(top > 1 && b[stack[top - 1]][j] < b[i][j]) top--;
			int r = stack[top - 1];
			sum[l[i] + 1][i] += b[i][j];
			sum[l[i] + 1][r] -= b[i][j];
			sum[i + 1][i] -= b[i][j];
			sum[i + 1][r] += b[i][j];
			stack[top++] = i;
		}
	}
	for(int i = 2; i <= n - 1; i++) a[i] += a[i - 1];
	long long ans = 0;
	for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) {
		sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
		if(i <= j) {
			long long cur = a[j - 1] - a[i - 1];
			cur = sum[i][j] - cur;
			if(ans < cur) ans = cur;
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 199936
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		if (a < b) {
			if (b < c) {
				System.out.println(a + " " + b + " " + c);
			} else if (a > c) {
				System.out.println(c + " " + a + " " + b);
			} else {
				System.out.println(a + " " + c + " " + b);
			}
		} else if (a < c) {
			System.out.println(b + " " + a + " " + c);
		} else if (b > c) {
			System.out.println(c + " " + b + " " + a);
		}else {
			System.out.println(b + " " + c + " " + a);
		}

	}
}


Measured memory_bytes: 26216
#include <stdio.h>
#include <stdlib.h>
 
#define MAX 100000
 
typedef struct{
  char suit;
  int num,id;
} Card;
 
void quickSort(Card [], int, int);
int partition(Card [], int, int);
 
int main()
{
  Card A[MAX],B[MAX];
  int i,j,s,flag=0,n;
 
  scanf("%d",&n);
 
  for(i=0 ; i<n ; i++)
    {
      scanf("%s %d",&A[i].suit, &A[i].num);
      A[i].id = i;
      B[i] = A[i];
    }
 
  quickSort(A,0,n-1);
 
  for(i=0 ; i<n-1 ; i++)
    {
      if(A[i].num == A[i+1].num)
    {
      if(A[i].id > A[i+1].id) flag = 1;
    }
    }
 
  if( flag == 0) printf("Stable\n");
  else printf("Not stable\n");
 
  for(i=0 ; i<n ; i++)
    {
      printf("%c %d\n",A[i].suit, A[i].num);
    }
 
  return 0;
}
 
void quickSort(Card A[],int p, int r)
{
  int q;
 
  if(p < r)
    {
      q = partition(A, p, r);
      quickSort(A, p, q-1);
      quickSort(A, q+1, r);
    }
}
 
 

int partition(Card *A, int p, int r)
{
  Card tmp;
  int x,i,j;
 
  x = A[r].num;
  i = p-1;
 
  for( j=p ; j<=r-1 ; j++ )
    {
      if( A[j].num <= x )
    {
      i = i + 1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    }  
    }
 
  tmp = A[i+1];
  A[i+1] = A[r];
  A[r] = tmp;
 
  return i+1;
}

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

int main() {
  string S;
  cin>>S;
  int cnt=0;
  for(int i=0;i<3;i++){
    if(S.at(1)=='R'){
      if(S.at(0)=='R' && S.at(2)=='R'){
      	cnt=3;
      }else if(S.at(0)=='R' || S.at(2)=='R'){
        cnt=2;
      }else{
        cnt=1;
      }
    }else if(S.at(0)=='R' || S.at(2)=='R'){
      cnt=1;
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
    using namespace std;
 
    int main(){
      int n,a;
      cin >> n >> a;
      cout << n*n-a << endl;
      return 0;}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	public static void main(String[] args) throws IOException {
		InputReader in = new InputReader(System.in);
		int n = in.readInt();
		int four = 0; 
		int one = 0; 
		int two = 0;
		for(int i = 0; i<n; i++) {
			int x = in.readInt();
			if(x%4 == 0)four++;
			else if(x%2 == 0) two++; 
			else one++;
			 
		}
		if(two == 0) {
			if(one <= four+1)
			  System.out.println("Yes"); 
			else System.out.println("No");
		}
		else {
			if(one <= four) System.out.println("Yes"); 
			else System.out.println("No"); 
		}
	}
}
class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


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

typedef long long ll;
ll n, s1, s2, ans, a[200005];
int main()
{
	ll i, j;
	cin >> n;
	for (i = 0; i < n; i++) {
		scanf ("%lld", &a[i]);
	}
	j = 0;
	s1 = s2 = 0;
	for (i =0; i < n; i++) {
		for (; j < n; j++) {
			if (s1 + a[j] != (s2 ^ a[j])) break;
			s1 += a[j];
			s2 ^= a[j];
		}
		ans += j - i;
		s1 -= a[i];
		s2 ^= a[i];
	}
	cout << ans;
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<string.h>


using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
const int INF=1001001001;
char A[4002],B[4002];
int DP[4002];


int main(){
	while(scanf("%s",A) != EOF){
		scanf("%s",B);
		int ans=0;
		rep(i,strlen(A)){
			for(int j=strlen(B);j>-1;j--){
				if(A[i]==B[j]){
					if(i!=0&&j!=0){
						DP[j]=DP[j-1];
					}else DP[j]=0;
					DP[j]++;
				}else{DP[j]=0;}
				ans=max(ans,DP[j]);
			}
		}
	printf("%d\n",ans);
	}
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String[] tmpArray = br.readLine().split(" ");
			
			int n = Integer.parseInt(tmpArray[0]);
			int winner = Integer.parseInt(tmpArray[1]);
			int rate = Integer.parseInt(tmpArray[2]);
			
			if(n == 0 && winner == 0 && rate == 0){
				break;
			}
			
			int[] tickets = new int[n];
			int sumOfTicket = 0;
			for(int i = 0; i < n; i++){
				tickets[i] = Integer.parseInt(br.readLine());
				sumOfTicket += tickets[i];
			}
			
			int gold = sumOfTicket * (100 - rate);
			
			if(tickets[winner - 1] == 0){
				System.out.println(0);
			}
			else {
				System.out.println(gold/tickets[winner-1]);
			}
		}
	}

}

Measured memory_bytes: 25808
#pragma GCC optimize("O3", "unroll-loops")

// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <limits>
#include <ext/rope>

using namespace std;
using namespace __gnu_cxx;

const int inf = (1 << 30) + 9e8;
const int MAXN = 1e5;
const int MAXN2 = 1e4;
const int P = 131;
const long long MOD = 1000000007;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;
typedef vector<bool> vb;

#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define all(a) a.begin(), a.end()
#define pb push_back
#define files(in, out) freopen(in, "r", stdin); freopen(out, "w", stdout)
#define ppb pop_back
#define ppf pop_front
#define fs first
#define sd second
#define eb emplace_back

template<class T> inline void sort(T &a) { sort(all(a)); }
template<class T> inline istream& operator>>(istream& str, vector<T> &a) { for (auto &i : a) str >> i; return str; }
std::mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

void solve() {
    string s, t;
    cin >> s >> t;
    if (s.size() > t.size())
        swap(t, s);
    int n = s.size(), m = t.size();
    vvi dp(n + 1, vi(m + 1, 0));
    for (int i = 1; i <= n; ++i) {
        for (int j = 1; j <= m; ++j) {
            dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
            if (s[i - 1] == t[j - 1]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + 1);
            }
        }
    }
    int i = n, j = m;
    string ans;
    while (i > 0 && j > 0 && ans.size() < dp[n][m]) {
        if (s[i - 1] == t[j - 1]) {
            ans.pb(t[j - 1]);
            i--;
            j--;
        } else if (dp[i - 1][j] > dp[i][j - 1]) {
            i--;
        } else {
            j--;
        }
    }
    reverse(all(ans));
    cout << ans;
}

signed main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    FAST;
    int q = 1;
    // cin >> q;
    // int st = clock();
    while (q--) {
        solve();
    }
    // int en = clock();
    // cout << en - st << "ms.";
    return 0;
}


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

int main()
{
	string n;
	cin >> n;
	
	if (n[0] == '7' or n[1] == '7' or n[2] == '7')
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
using namespace std;

int k, arr[] = {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};

int main(){
    //IO("input.txt", "output.txt");
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> k;
    cout << arr[k - 1] << "\n";
    return 0;
}

Measured memory_bytes: 256