akhauriyash/Code-Regression huggingface dataset:
import Data.List
import Data.Ord
import Control.Applicative

f :: [(Int, Int)] -> Int -> [Int]
f xs ypos = filter fil_f [0 .. 7]
    where
      fil_f xpos = case (find (isExist xpos) xs) of
                     Just _ -> False
                     Nothing -> True
      isExist xpos a = snd a == xpos || abs (xpos - (snd a)) == abs (ypos - (fst a))

solve2 :: [(Int, Int)] -> [Int] -> [(Int, Int)]
solve2 res [] = res
solve2 res (y:ys)
    | next_xs == [] = []
    | otherwise = foldr (\next_x_elem xs -> if (next_res next_x_elem) /= [] then (next_res next_x_elem) else xs) [] next_xs
    where
      lowList = filter (\a -> fst a < y) res
      highList = filter (\a -> fst a > y) res
      next_xs = f res y
      next_res next_x_elem = solve2 (lowList ++ [(y, next_x_elem)] ++ highList) ys

solve :: [(Int, Int)] -> [(Int, Int)]
solve ins = solve2 ins ([0 .. 7] \\ yList)
    where
      yList = map (\a -> fst a) ins

input :: Int -> IO [(Int, Int)]
input n
    | n == 0 = return []
    | otherwise = do
  ins <- (map read . words) <$> getLine
  rems <- input $ n-1
  return $ (ins !! 0, ins !! 1) : rems
  
display :: [(Int, Int)] -> IO ()
display [] = return ()
display (x:xs) = do
  putStrLn $ getStr (snd x) 0
  display xs
    where 
      getStr a pos
          | pos == 8 = ""
          | a == pos = 'Q' : (getStr a (pos+1))
          | otherwise = '.' : (getStr a (pos+1))

main :: IO()
main = do
  n <- readLn
  _in <- input n
  display $ solve $ sortBy (comparing fst) _in

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

int main() {
  int N,M;
  
  cin >> N >> M;
 
  for(int i = 0;  i<M+2 ; i++){
  	cout << "#" ;
  } 
  cout << endl;
  
  vector<string>vec(N);
  for(int i = 0 ; i < N ; i++){
  	cin >> vec.at(i);
	}
  
  for(int i = 0 ; i < N ; i++){
  	cout << "#" <<vec.at(i) << "#" << endl;
	}
  
  for(int i = 0;  i<M+2 ; i++){
    cout << "#" ;
  }
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let N : usize = read();

    let mut ans = 1000000001;
    for i in 0..N {
        let mut a: i64 = read();
        let mut tmp = 0;
        while a%2 == 0 {
            tmp += 1;
            a = a/2;
        }

        ans = std::cmp::min(ans, tmp);
    }

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
int n;
string s;
ll ans = 0;

void solve(ll x,ll y){
    if(x==n+1){
        ans += y;
        return;
    }
    ll cur = 0;
    for(ll i=x;i<=n;i++){
        cur = (10*cur) + (s[i]-'0');
        solve(i+1,y+cur);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int cnt[27]={0};
    for(auto x: s)cnt[x-'a']++;
    for(int i=0;i<26;i++){
        if(cnt[i]>1)return 0*puts("no");
    }
    puts("yes");
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int k;
  vi a ={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cin>>k;
  cout<<a[k-1]<<endl;
  
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


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

    
    int n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    ll ans = 1e18;
    for(int i=-100;i<=100;i++){
        ll ret = 0;
        for(int j=0;j<n;j++){
            ret += (i-a[j])*(i-a[j]);
        }
        chmin(ans,ret);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
*A, = map(int,input().split())
q = int(input())
*ms, = map(int, input().split())

def solve(ind, cur):
    if cur == 0:
        return True
    if ind >= n:
        return False

    return solve(ind + 1, cur) or solve(ind + 1, cur - A[ind])

amax = sum(A)
amin = min(A)
for m in ms:
    if amax < m or amin > m: print('no')
    else:
        if solve(0, m): print('yes')
        else: print('no')


Measured memory_bytes: 5624
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


const int V = 100005;
const int INF = 1e9 + 10;

int main() {
  int n, W;
  cin >> n >> W;
  vi w(n), v(n);
  rep(i, n) cin >> w[i] >> v[i];

  int dp[n+1][V];
  rep(i, n+1) rep(j, V) dp[i][j] = INF;
  dp[0][0] = 0;

  rep(i, n){
    rep(j, V){
      dp[i+1][j] = dp[i][j];
      if (j >= v[i]){
        dp[i+1][j] = min(dp[i][j], dp[i][j-v[i]] + w[i]);
      }
    }
  }
  int ans = 0;
  rep(i, V){
    if (dp[n][i] <= W) ans = i;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 39680
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

S = I()
L = S//3
dp = [[0]*(S+1) for _ in range(L+1)]

for i in range(L+1):
    if i == 0:
        for j in range(3,S+1):
            dp[i][j] = 1
    else:
        val = dp[i-1][0]
        for j in range(3,S+1):
            dp[i][j] = val
            val += dp[i-1][j-2]
            val %= mod

ans = 0
for i in range(L+1):
    ans += dp[i][S]
    ans %= mod
print(ans)

Measured memory_bytes: 78888
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<numeric>
#include<map>

#define REP(i, a) for(int i=0;i<(int)a;++i)
#define ALL(a) (a).begin(),(a).end()
#define VI vector<int>
#define INF 1145141919

template<class T, size_t N>
size_t countof(const T (&array)[N]) { return N; }

typedef long long ll;
typedef long double ld;

using namespace std;

const string l[4]{"S", "H", "C", "D"};


void solver() {
    map<string, int> m;
    REP(i, countof(l))REP(j, 13)m[l[i] + " " + to_string(j + 1)] = 1;

    int N;
    cin >> N;
    REP(i, N) {
        string c;
        int num;
        cin >> c >> num;
        m[c + " " + to_string(num)] += 1;
    }

    vector<string>ans;
    REP(i, countof(l))REP(j, 13)
            if (m[l[i] + " " + to_string(j + 1)] == 1)
                ans.push_back(l[i] + " " + to_string(j + 1));

    REP(i,ans.size()){
        cout<<ans[i]<<endl;
    }
    //cout<<ans[ans.size()-1];



}

int main() {
    solver();
    return 0;
}


Measured memory_bytes: 3252
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

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

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))

#define fillInt(xs)        \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%ld", &xs[i]);
#define fillDouble(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    scanf("%lf", &xs[i]);
#define fillString(xs)       \
  for (int i = 0; i < (xs).size(); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;
const int MAX_V = 100005;

bool used[MAX_V];
vector<int> G[MAX_V];

vector<int> lv;
vector<int> rv;

void dfsl(int s) {
  used[s] = true;
  for(int v: G[s]) {
    if (used[v]) continue;
    lv.push_back(v);
    dfsl(v);
    break;
  }
}

void dfsr(int s) {
  used[s] = true;
  for(int v: G[s]) {
    if (used[v]) continue;
    rv.push_back(v);
    dfsr(v);
    break;
  }
}


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

  long n, m;
  cin >> n >> m;

  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  lv.push_back(0);
  dfsl(0);
  dfsr(0);

  cout << lv.size() + rv.size() << endl;
  rep(i, lv.size()) {
    cout << lv[lv.size() - i - 1] + 1 << endl;
  }
  rep(i, rv.size()) {
    cout << rv[i] + 1 << endl;
  }
}


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

#define ll long long
#define ld long double
#define ull unsigned long long
#define pw(x) (1LL << (x))

#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n"
#define db3(x, y, z) cerr << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", " << z << ")\n"

using namespace std;

const int MOD = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n;
    ll power = 1;

    for (int i = 1; i <= n; ++i)
    {
        power *= i;
        power %= MOD;
    }

    cout << power << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#define SIZE 1002
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

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

// グローバル変数
ll n;
ll ret;

int main(void) {

// 入力

	cin >> n;
	vector<vector<int>> a(n, vector<int>(n - 1));
	rep(i, n)
	{
		rep(j, n - 1)
		{
			cin >> a[i][j];
			a[i][j]--;
		}
		reverse(a[i].begin(), a[i].end());
	}
	
// 処理

	vector<P> q;
	auto check = [&](int i)
	{
		if (a[i].size() == 0) return;
		int j = a[i].back();
		if (a[j].size() == 0) return;
		if (a[j].back() == i)
		{
			if (i > j) swap(i, j);
			q.push_back(P(i, j));
		}
	};
	rep(i, n)
	{
		check(i);
	}
	int day = 0;
	while (q.size() > 0)
	{
		day++;
		// 重複削除
		sort(q.begin(), q.end());
		q.erase(unique(q.begin(), q.end()), q.end());
		vector<P> prevQ;
		swap<P>(q, prevQ);
		for (P p : prevQ)
		{
			int i = p.first, j = p.second;
			a[i].pop_back();
			a[j].pop_back();
		}
		for (P p : prevQ)
		{
			int i = p.first, j = p.second;
			check(i);
			check(j);
		}
	}


// 出力

	rep(i, n)
	{
		if (a[i].size() != 0)
		{
			cout << -1;
			return 0;
		}
	}
	cout << day;
	return 0;
}

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

using namespace std;

long long int n,w,i,j;
long long int waga[103];
long long int koszt[103];
long long int dp[103][100003];

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> w;
    for(i=1;i<=n;i++){
        cin >> waga[i] >> koszt[i];
    }
    for(i=0;i<103;i++)
    {
        for(j=1;j<100003;j++)
        {
            dp[i][j]=2000000000000000001;
        }
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=100003;j++)
        {
            if(koszt[i]>j){
                dp[i][j]=dp[i-1][j];
            }
            else{
                dp[i][j]=min(dp[i-1][j], dp[i-1][j-koszt[i]]+waga[i]);
            }
        }
    }
    for(i=100003;i>=0;i--)
    {
        for(j=0;j<=n;j++)
        {
            if(dp[j][i]>0 && dp[j][i]<=w)
            {
                cout << i;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 80768
#include <stdio.h>
int main(void)
{
  int n;
  int count=0;

  while(1)
    {
      scanf("%d",&n);
      if(n == 0) break;
      while(n != 1)
	{
	  if(n % 2 == 0)
	    {
	      n /= 2;
	      count++;
	    }
	  else if(n % 2 == 1)
	    {
	      n = n * 3 + 1;
	      count++;
	    }
	}
      printf("%d\n",count);
      count = 0;
    }
  return 0;
}

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

using namespace std;
int main(){


  long long a,b,k;

  cin>>a>>b>>k;



  for(int i=0;i<k;i++){

    if(i%2==0){
      if(a%2==1){
	a-=1;
	b+=(a/2);
	a/=2;
	
      }else{
	b+=(a/2);
	a/=2;
      }
    }else{
      if(b%2==1){
	b-=1;
	
	a+=(b/2);
	b/=2;
      }else{
	a+=(b/2);
	b/=2;
      }  
    }
  }

  cout<<a<<" "<<b<<endl;
  
  
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,k;
	cin>>n>>k;
	ll ans=0;
	for(ll i=k+1;i<=n;i++){
		ans+=n/i*(i-k);
		if(k==0){
			ans+=max(n%i-(k),ll(0));
		}
		else{
			ans+=max(n%i-(k-1),ll(0));
		}
	//	cout <<ans<<endl;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){

  string S; cin >> S;

  vector <int> cnt(3);
  for (int i = 0; i < S.length(); i++){
    int A = S[i]- 'a';
    cnt[A]++;
  }
  sort(cnt.begin(), cnt.end());
  
  int length = S.length();
  
  bool ans = false;
  if (length % 3 == 0){
    if (cnt[0] == length / 3){
      ans = true;
    }
  }else{
    if (cnt[0] == length / 3 && cnt[2] == length / 3 + 1){
      ans = true;
    }
  }
  
  if (ans == true){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  

  return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;

#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define FORR(i,a,b) for (int i = b - 1; i >= a; --i)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) FORR(i,0,n)

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

	vector<int> L(N);
	REP(i, N) cin >> L[i];

	int cnt = 0;
	for (int k = 2; k <= N; k++) {
		for (int j = 1; j < k; j++) {
			for (int i = 0; i < j; i++) {
				if (L[i] == L[j] | L[j] == L[k] | L[k] == L[i]) continue;

				vector<int> buf;
				buf.push_back(L[i]);
				buf.push_back(L[j]);
				buf.push_back(L[k]);

				sort(buf.begin(), buf.end());
				if (buf[0] + buf[1] > buf[2]) ++cnt;
			}
		}
	}

	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3624
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] c = new int[n];
		for (int i = 0; i < n; i++) {
			c[i] = in.nextInt();
		}
		bubbleSort(c);
		in.close();
	}

	private static void bubbleSort(int[] A) {
		int flg = 1;
		int wk;
		int count=0;
		while (flg == 1) {
			flg = 0;
			for (int i = A.length - 1; i > 0; i--) {
				wk = A[i - 1];

				if (A[i] < A[i - 1]) {
					A[i - 1] = A[i];
					A[i] = wk;
					count+=1;
					flg=1;
				}
			}

		}
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<A.length;i++) {
			if(i>0) {
				sb.append(" ");
			}
			sb.append(A[i]);

		}
		System.out.println(sb.toString());
		System.out.println(count);
	}

}



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

vector<int> counter;
vector<vector<int>> g;
vector<int> px;
vector<bool> seen;

void dfs(int v, int x) {
    seen[v] = true;
    counter[v] += x + px[v];
    for(auto next_v : g[v]) {
        if(seen[next_v]) continue;
        dfs(next_v, x + px[v]);
    }
}

int main() {
    int n, q;
    cin >> n >> q;
    g.resize(n);
    int a, b;
    for(int i = 0; i < n - 1; i++) {
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    int p, x;
    px.assign(n, 0);
    for(int i = 0; i < q; i++) {
        cin >> p >> x;
        p--;
        px[p] += x;
    }
    seen.assign(n, false);
    counter.assign(n, 0);
    dfs(0, 0);
    for(int i = 0; i < n - 1; i++) cout << counter[i] << " ";
    cout << counter[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 24320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  string s;
  cin >> n >> s;
  vector<int> r(n);
  vector<int> g(n);
  vector<int> b(n);
  int ra = 0;
  int ga = 0;
  int ba = 0;
  for(int i = 0;i < n;i++){
    r[i] = 0,g[i] = 0,b[i] = 0;
    if(s[i] == 'R'){
      r[i]++;
      ra++;
    }
    else if(s[i] == 'G'){
      g[i]++;
      ga++;
    }
    else{
      b[i]++;
      ba++;
    }
  }
  //cout << ra << " " << ga << " " << ba << endl;
  //for(int i = 0;i < n;i++)cout << r[i] << " " << g[i] << " " << b[i] << endl;
  ll res = 0;
  res = (ll)ra * ga * ba;
  ll count = 0;
  for(int i = 0;i < n - 1;i++){
    for(int j = i;j < n;j++){
      if(j + j - i < n){
        char nowi,nowj,nowk;
        nowi = s[i];
        nowj = s[j];
        nowk = s[j + j - i];
        if(nowi != nowj && nowj != nowk && nowi != nowk)count++/*,cout << i << " " << j << " " << j + j - i << endl*/;
      }
    }
  }
  //cout << res << endl;
  //cout << count << endl;
  cout << res - (count)<< endl;
  return 0;
}

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

typedef long long   ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a>=k) cout << k << "\n";
    else if(a+b>=k) cout << a << "\n";
    else cout << a-(k-a-b) << "\n";
    return 0;
}

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

typedef long long LL;
const int MAXN = 1e3+5;
LL a[MAXN],b[MAXN], c[MAXN];
bool cmp(LL A, LL B) {
    return A > B;
}
int main() {
    /*int A, B, C, K; cin>>A>>B>>C>>K;
    for(int i=0; i<A; i++) cin>>a[i];
    for(int i=0; i<B; i++) cin>>b[i];
    for(int i=0; i<C; i++) cin>>c[i];
    sort(a, a+A, cmp);
    sort(b, b+B, cmp);
    sort(c, c+C, cmp);
    for(int i=0; i<A; i++) {

    }*/
    LL n; cin>>n;
    for(int i=0; i<5; i++) cin>>a[i];
    LL ans = (n-1)/a[0]+1, Mn=a[0];
    for(int i=1; i<5; i++) {
        if(a[i] >= Mn) {
            ans++;
            continue;
        }
        ans=max(ans,(n-1)/a[i]+1+i);
        Mn=a[i];
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys

n, x, *a = map(int, sys.stdin.read().split())

def main():
  cnt = 0
  lim = x
  for c in a:
    if c > lim:
      cnt += c - lim
      lim = x - lim
    else:
      lim = x - c
  print(cnt)

if __name__ ==  '__main__':
  main()

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

int main(){
 int x,y,a,b,c,ans,flag;
  ans = 0;
  cin >> a >> b >> c >> x >> y;
  
  if(a+b > c*2){
	if(x < y){
      ans += c*x*2;
    }
    else{
      ans += c*y*2;
    }
    flag = 0;
  }
  else{
	if(x < y){
      ans += a*x;
    }
    else{
      ans += b*y;
    }
    flag = 1;
  }
  
  if(flag == 0){
    if(y < x){
      if((x-y)*a > (x-y)*2*c){
        ans += (x-y)*2*c;
      }
      else{
        ans += (x-y)*a;
      }
    }
    else{
      if((y-x)*b > (y-x)*2*c){
        ans += (y-x)*2*c;
      }
      else{
        ans += (y-x)*b;
      }
    }
  }
  else if(flag == 1){
    if(y < x){
      if(x*a > x*2*c){
        ans += x*2*c;
      }
      else{
        ans += x*a;
      }
    }
    else{
      if(y*b > y*2*c){
        ans += y*2*c;
      }
      else{
        ans += y*b;
      }
    }
  }
  	
  
  cout << ans << endl;
 return 0; 
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,k = map(int,input().split())
h = []
for _ in range(n):
    h.append(int(input()))

h.sort()

ans = 10**10

for i in range(n-k+1):
    ans = min(ans,h[i+k-1]-h[i])

print(ans)


Measured memory_bytes: 44636
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<bitset>
#include<math.h>
#include<stack>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long ll;
typedef long double db;
typedef pair<int,int> pii;
const int N=100000;
const db pi=acos(-1.0);
#define lowbit(x) (x)&(-x)
#define sqr(x) (x)*(x)
#define rep(i,a,b) for (register int i=a;i<=b;i++)
#define per(i,a,b) for (register int i=a;i>=b;i--)
#define go(u,i) for (register int i=head[u];i;i=sq[i].nxt)
#define fir first
#define sec second
#define mp make_pair
#define pb push_back
#define maxd 998244353
#define eps 1e-8
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while ((ch<'0') || (ch>'9')) {if (ch=='-') f=-1;ch=getchar();}
    while ((ch>='0') && (ch<='9')) {x=x*10+(ch-'0');ch=getchar();}
    return x*f;
}

namespace My_Math{
	#define N 100000

	int fac[N+100],invfac[N+100];

	int add(int x,int y) {return x+y>=maxd?x+y-maxd:x+y;}
	int dec(int x,int y) {return x<y?x-y+maxd:x-y;}
	int mul(int x,int y) {return 1ll*x*y%maxd;}
	ll qpow(ll x,int y)
	{
		ll ans=1;
		while (y)
		{
			if (y&1) ans=mul(ans,x);
			x=mul(x,x);y>>=1;
		}
		return ans;
	}
	int inv(int x) {return qpow(x,maxd-2);}

	int C(int n,int m)
	{
		if ((n<m) || (n<0) || (m<0)) return 0;
		return mul(mul(fac[n],invfac[m]),invfac[n-m]);
	}

	int math_init()
	{
		fac[0]=invfac[0]=1;
		rep(i,1,N) fac[i]=mul(fac[i-1],i);
		invfac[N]=inv(fac[N]);
		per(i,N-1,1) invfac[i]=mul(invfac[i+1],i+1);
	}
	#undef N
}
using namespace My_Math;

struct node{int to,nxt;}sq[400400];
int all=0,head[200200];
int n,ans[200200];
queue<int> q[2];

void addedge(int u,int v)
{
	all++;sq[all].to=v;sq[all].nxt=head[u];head[u]=all;
}

void dfs(int u,int fu,int c)
{
	q[c].push(u);
	go(u,i)
	{
		int v=sq[i].to;
		if (v==fu) continue;
		dfs(v,u,c^1);
	}
}

int solve(int c,int x)
{
	while ((x<=n) && (!q[c].empty()))
	{
		int u=q[c].front();q[c].pop();
		ans[u]=x;x+=3;
	}
	return x;
}

int main()
{
	n=read();
	rep(i,1,n-1)
	{
		int u=read(),v=read();
		addedge(u,v);addedge(v,u);
	}
	dfs(1,0,0);
	if (q[0].size()<q[1].size()) swap(q[0],q[1]);
	solve(0,1);
	if (q[0].size()<q[1].size()) swap(q[0],q[1]);
	solve(0,2);
	int now=solve(0,3);solve(1,now);
	rep(i,1,n) printf("%d ",ans[i]);
	return 0;
}
	



Measured memory_bytes: 19840
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
 

//result = Math.pow(num1, num3)
//StringBuffer str = new StringBuffer(hoge1);
//String hoge2 = str.reverse().toString();
//map.containsKey(A)
//Map<String, Integer> map = new HashMap<String, Integer>(n);
//ArrayList<String> cc = new ArrayList<>(n);
//Collections.sort(list);
//Array.sort(list);
//Arrays.asList(c).contains("a")

public class Main {
	private static Scanner sc = new Scanner(System.in);
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	//static String eikomoji[]={"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"};
	
	
	public static void main(String[] args) {
	int N=sc.nextInt();
	int p[]=new int[N];
	int min=0;
	int ctn=0;
	for(int i=0;i<N;i++) {
		p[i]=sc.nextInt();
		if(i==0) {
			min=p[i];
		}
		if(min>=p[i]) {
			min=p[i];
			ctn++;
		}
	}
	
	p(ctn);
	
 }
	static boolean te() {
		
		
		
		return true;
	}
}


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

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;

const int DEBUG = 0;

bool check(const VI& v) {
  vector<PI> cont;
  int cur = v[0];
  int cnt = 1;
  REP(i, 1, v.size() + 1) {
    if (i >= v.size() || cur != v[i]) {
      cont.push_back(PI(cur, cnt));
      cnt = 0;
    }
    if (i < v.size()) {
      cur = v[i];
      cnt++;
    }
  }
  vector<PI> cont2;
  cnt = 0;
  REP(i, 0, cont.size() + 1) {
    if (i >= cont.size() || cont[i].second != 1) {
      if (cnt >= 1) {
	cont2.push_back(PI(-1, cnt));
	cnt = 0;
      }
    }
    if (i < cont.size()) {
      PI t = cont[i];
      if (t.second == 1) {
	cnt++;
      } else {
	cont2.push_back(t);
      }
    }
  }
  if (DEBUG) {
    cerr << "cont:" << endl;
    REP(i, 0, cont.size()) {
      cerr << (cont[i].first ? "b" : "w") << cont[i].second << " ";
    }
    cerr << endl << "cont2:" << endl;
    REP(i, 0, cont2.size()) {
      cerr << (cont2[i].first == -1 ? "m" : cont2[i].first ? "b" : "w")
	   << cont2[i].second << " ";
    }
    cerr << endl;
  }
  if (cont2.size() == 1 && cont2[0].first == -1) { // (w)bwbwbwbw...
    return v[0];
  }
  int c2s = cont2.size();
  REP(i, 0, c2s) {
    if (cont2[i].first >= 0) {
      continue;
    }
    int stripe = cont2[i].second;
    if (i >= 1 && i < c2s - 1) {
      cont2[i - 1].second += stripe / 2;
      cont2[i].second -= stripe / 2;
      cont2[i + 1].second += stripe - stripe / 2;
      cont2[i].second -= stripe - stripe / 2;
    }
    if (i == 0) {
      cont2[1].second += stripe;
      cont2[0].second -= stripe;
    }
    if (i == c2s - 1) {
      cont2[c2s - 2].second += stripe;
      cont2[c2s - 1].second -= stripe;
    }
  }
  if (DEBUG) {
    cerr << "cont2-mod:" << endl;
    REP(i, 0, cont2.size()) {
      cerr << (cont2[i].first == -1 ? "m" : cont2[i].first ? "b" : "w")
	   << cont2[i].second << " ";
    }
    cerr << endl;
  }
  int rem = v.size() / 2;
  REP(i, 0, cont2.size()) {
    if (rem < cont2[i].second) {
      assert (cont2[i].first >= 0);
      return cont2[i].first;
    }
    rem -= cont2[i].second;
  }
  assert (0);
}

int main(void){
  int n;
  cin >> n;
  VI a(2 * n - 1);
  REP(i, 0, 2 * n - 1) {
    cin >> a[i];
  }
  int lo = 1, hi = 2 * n - 1;
  while (hi - lo > 1) {
    int mid = (hi + lo) / 2;
    VI monochrome(2 * n - 1);
    REP(i, 0, 2 * n - 1) {
      monochrome[i] = a[i] >= mid;
    }
    if (DEBUG) {
      cerr << "mid = " << mid << endl;
    }
    if (check(monochrome)) {
      lo = mid;
    } else {
      hi = mid;
    }
  }
  cout << lo << endl;
}


Measured memory_bytes: 5528
#include <stdio.h>
#include <string.h>
#define MAX 201
int main(void)
{
	char n[MAX], nn[MAX]; 
	int m, h, i, j;
	int len;
	while(scanf("%s", n), n[0] != '-'){
		len = strlen(n);
		scanf("%d", &m);
		for(i=0; i<m; i++){
			scanf("%d", &h);
			for(j=0; j<len-h; j++){
				nn[j] = n[h+j];
			}
			for(j=len-h; j<len; j++){
				nn[j] = n[j-(len-h)];
			}
			for(j=0; j<len; j++){
				n[j] = nn[j];
			}
			for(j=0; j<=MAX; j++){
				nn[j] = 0;
			}
		}
		printf("%s\n", n);
	}
	return 0;
}

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

int max(int a, int b)
{
    return a > b ? a : b;
}

int main(void)
{
    using namespace std;
    
    int n;
    cin >> n;

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a.at(i);
    }

    int res = 0;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            res = max(res, abs(a.at(j) - a.at(i)));
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
int main() {
	char s[11];
	scanf("%s", s);
	int digit[10], length = strlen(s), i;
	for (i = 0; i < length; i++)digit[i] = s[i] - '0';
	int j;
	long long tmp, sum = 0;
	for (i = 0; i < 1 << (length - 1); i++) {
		tmp = digit[0];
		for (j = 0; j < length - 1; j++) {
			if (i&(1 << j)) {
				sum += tmp;
				tmp = digit[j + 1];
			}
			else {
				tmp = tmp * 10 + digit[j + 1];
			}
		}
		sum += tmp;
	}
	printf("%lld", sum);
	return 0;
}

Measured memory_bytes: 128
//%std
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
inline int read()
{
	int out=0,fh=1;
	char jp=getchar();
	while ((jp>'9'||jp<'0')&&jp!='-')
		jp=getchar();
	if (jp=='-')
		fh=-1,jp=getchar();
	while (jp>='0'&&jp<='9')
		out=out*10+jp-'0',jp=getchar();
	return out*fh;
}
const int N=1e5;
int a[6]={100,101,102,103,104,105};
int vis[N+10];
queue<int> q;
void init()
{
	vis[0]=1;
	q.push(0);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=0;i<6;++i)
		{
			int y=(x+a[i]);
			if(y<=N && !vis[y])
			{
				vis[y]=1;
				q.push(y);
			}
		}
	}
}
int main()
{
	init();
	int x=read();
	cout<<vis[x]<<endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String s2 = sc.next();
		
		if(s.equals(s2.substring(0, s.length()))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		
	}
}

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

#define FOR(i, a, b) for(int i = a; i < b; i ++)
#define FORS(i, a, b, c) for(int i = a; i < b; i += c)
#define FORN(i, a, b) for(int i = a; i <= b; i ++)
#define FORD(i, a, b) for(int i = a-1; i >= b; i --)
#define FORE(i, b) for(auto &i:b)
#define REP(i, b) FOR(i, 0, b)
#define REPN(i, b) FORN(i, 0, b)
#define SQ(i) (i*i)
#define ALL(a) a.begin(), a.end()
#define ALLA(a,n) a, a+n
#define SORT(a) sort(ALL(a))
#define SORTA(a, n) sort(ALLA(a, n))
#define REV(a) reverse(ALL(a))
#define REVA(a, n) reverse(ALLA(a, n))
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define IN(a, b) (a.find(b) != a.end())
#define BACK(a) a.back(); a.RB()
#define QBACK(a) a.top(); a.pop()
#define PRINT(a) FORE(i, a) cout << i << " "; cout << endl

#define PB  push_back
#define RB  pop_back
#define RF  pop_front
#define INS insert
#define F   first
#define S   second
#define UM  unordered_map
#define US  unordered_set
#define PQ  priority_queue

#define IO ios_base::sync_with_stdio(false); cin.tie(NULL)

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pll;
typedef queue<int> qi;
typedef queue<double> qd;
typedef queue<ll> qll;
typedef US<int> si;
typedef US<double> sd;
typedef US<ll> sll;
typedef vector<vi> mi;
typedef vector<vd> md;
typedef vector<vll> mll;
typedef vector<pi> vpi;
typedef vector<pd> vpd;
typedef vector<pll> vpll;


int main(){
  IO; int A, B; cin >> A >> B; cout << A*B << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cassert>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repd(i, n) for (int i = n; i > 0; i--)
#define mod 1000000007
#define MOD 998244353
#define inf 1e20
typedef long long int ll;
typedef pair<ll, ll> p;

int main() {
	string n;
	cin >> n;
	int ans = 0;
	rep(i,n.size()) {
		if (n[i] == *"+") {
			ans++;
		}
		else {
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

//Ctrl+Aを使わない

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define endl '\n'
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define repab(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define  printarr(v) for(auto x:v){cout<<x<<" "; }
#define debug1(a) cout<<#a<<" "<<(a)<<endl;
#define debug2(a,b) cout<<#a<<" "<<(a)<<" "<<#b<<" "<<(b)<<endl;
#define debug3(a,b,c) cout<<#a<<" "<<(a)<<" "<<#b<<" "<<(b)<<" "#c<<" "<<(c)<<endl;
typedef long double ld;

void solve()
{
	ll n;
	cin >> n;
	ll ans = 0;
	vector<ll> div(n + 1, 0);

	// For every number from 1 to n
	for (ll i = 1; i <= n; i++) {

		// Increase divisors count for
		// every number divisible by i
		for (ll j = 1; j * i < n; j++)
			if (j * i >= 0)
			{
				div[i * j]++;
			}
	}


	for (ll i = 1; i <= n; i++)
		ans += div[i];
	cout << ans << endl;



}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
}


Measured memory_bytes: 11072
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
 
struct Node{
    int location;
    int p,left,right;
};
 
struct Point{
    Point(){
        id = x = y = 0;
    }
 
    Point(int arg_id,int arg_x,int arg_y){
        id = arg_id;
        x = arg_x;
        y = arg_y;
    }
    bool operator < (const Point & arg)const{
        return id < arg.id;
    }
    void print(){
        printf("%d\n",id);
    }
    int id,x,y;
};
 
static const int MAX = 1000000;
static const int NIL = -1;
 
int N;
Point P[MAX];
Node T[MAX];
int number;
 
bool lessX(const Point &p1, const Point &p2) {return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) {return p1.y < p2.y; }
 
int makeKDTree(int left,int right, int depth){
 
    if(!(left < right))return NIL;
 
    int mid = (left+right)/2;
 
    int node_id = number++;
 
    if(depth%2 == 0){
        sort(P+left,P+right,lessX);
    }else{
        sort(P+left,P+right,lessY);
    }
 
    T[node_id].location = mid;
    T[node_id].left = makeKDTree(left,mid,depth+1);
    T[node_id].right = makeKDTree(mid+1,right,depth+1);
 
    return node_id;
}
 
void find(int node_id,int sx,int tx,int sy,int ty, int depth, vector<Point> &ans){
 
    int x = P[T[node_id].location].x;
    int y = P[T[node_id].location].y;
 
    if(sx <= x && x <= tx && sy <= y && y <= ty){
        ans.push_back(P[T[node_id].location]);
    }
 
    if(depth%2 == 0){
        if(T[node_id].left != NIL){
            if(sx <= x)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[node_id].right != NIL){
            if( x <= tx)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
        }
    }else{
        if(T[node_id].left != NIL){
            if(sy <= y)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[node_id].right != NIL){
            if(y <= ty)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
        }
    }
}
 
 
int main(){
 
    int x,y;
    scanf("%d",&N);
    for(int i = 0; i < N; i++){
        scanf("%d %d",&x,&y);
        P[i] = Point(i,x,y);
        T[i].left = T[i].right = T[i].p = NIL;
    }
 
    number = 0;
 
    int root = makeKDTree(0,N,0);
 
    int q;
    scanf("%d",&q);
    int sx,tx,sy,ty;
    vector<Point> ans;
    for(int i = 0; i < q; i++){
        scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
        ans.clear();
        find(root,sx,tx,sy,ty,0,ans);
        sort(ans.begin(),ans.end());
        for(int j = 0; j < ans.size(); j++){
            ans[j].print();
        }
        printf("\n");
    }
    return 0;
}


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

int gcd(long long a,long long b){
    if(b == 0) return a;
    return gcd( b , a % b);
}

int find(string str, const string& word) {
  int count = 0;
  for (string::size_type pos = 0; (pos = str.find(word, pos)) != string::npos; pos += word.size()) {
    ++count;
  }
  return count;
}

int main(){
    int n, k;
    string s;
    cin >> n >> k >> s;
    s[k-1] += 32;
    cout << s << endl;;
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int a[5],i,mai[14]={0},max=0,cnt=0,flg=0;
  while(scanf("%d,%d,%d,%d,%d",&a[0],&a[1],&a[2],&a[3],&a[4])!=EOF){
    for(i=0,max=0,flg=0,cnt=0;i<=13;i++)mai[i]=0;
    for(i=0;i<5;i++)mai[a[i]]++;

    for(i=1;i<=13;i++){
      if(max<mai[i])max=mai[i];
      if(mai[i]>=4){
	printf("four card\n");
	flg=1;
      }
    }
    if(flg==1)continue;

    if(max==3){
      for(i=1;i<=13;i++){
	if(mai[i]==2){
	  printf("full house\n");
	  flg=1;
	}
      }
    }
    if(flg==1)continue;

    for(i=2,cnt=0;i<=13;i++){
      if(mai[i]==1){
	for(;i<=13;i++){
	  if(mai[i]==1){
	    cnt++;
	  }
	  else{
	    flg=1;
	    goto exit;
	  }
	}
      }
    }
  exit:
    if(cnt==4&&mai[1]==1&&(mai[2]==1||mai[13]==1)&&(!(mai[2]==1&&mai[13]==1))){
      cnt++;
    }
    if(cnt==5){
      printf("straight\n");
      continue;
    }

    if(max==3){
      printf("three card\n");
      continue;
    }
    flg=0;
    if(max==2){
      for(i=1;i<=13;i++){
	if(mai[i]==2)flg++;
	if(flg==2){
	  printf("two pair\n");
	  break;
	}
      }
    }
    if(flg==2)continue;

    if(max==2){
      printf("one pair\n");
      continue;
    }
    printf("null\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i,n)	 for(int i=0;i<n;i++)
using namespace std;
void print(vector< int > &v){
	for(int i=0;i<v.size();i++){
		cout<<v[i]<<" ";
	}
	cout<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //write your code here
		string s, t;
		cin>> s>> t;
		vector<vector<int> > dp(s.size()+1, vector<int > (t.size()+1,0));
		for(int i=1;i<=s.size();i++){
			for(int j=1;j<=t.size();j++){
				if(s[i-1]==t[j-1]){
					dp[i][j]= dp[i-1][j-1]+1;
				}
				else{
					dp[i][j]=  max(dp[i-1][j], dp[i][j-1]);
				}
			}
		}
		string ans = "";
		int i=s.size(), j=t.size();
		while(i!=0&& j!=0){
			if(s[i-1]==t[j-1]){
				ans.push_back(s[i-1]);
				i--;j--;
			}
			else{
				if(dp[i-1][j]>dp[i][j-1])
					i--;
				else
					j--;
			}
		}
		reverse(ans.begin(), ans.end());
		cout<<ans<<endl;
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    
    for(int i = 1; i <= n; i++){
        if(i < 10){
            ans++;
        } else if (i < 1000 && i >= 100){
            ans++;
        } else if (i >= 10000 && i < 100000){
            ans++;
        }
    }
    cout << ans << endl;
    
}

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

int main() {
	int h, w;
	cin >> h >> w;
	int n = 10;
	vector<vector<int>> a(n, vector<int>(n));
	rep(i, n)rep(j, n) cin >> a[i][j];
	vector<int> c(n);
	rep(i, h)rep(j, w) {
		int x; cin >> x;
		if (x == -1) continue;
		c[x]++;
	}
	rep(k, n)rep(i, n)rep(j, n) a[i][j] = min(a[i][j], a[i][k] + a[k][j]);
	int ans = 0;
	rep(i, n) ans += a[i][1] * c[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce

sys.setrecursionlimit(2147483647)
INF = 10 ** 20
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


class BIT:
    def __init__(self, n):
        self.num = n
        self.dat = [0] * (self.num + 1)

    def add(self, i, x):
        i += 1
        while i <= self.num:
            self.dat[i] += x
            i += i & -i

    def sum(self, i):
        i += 1
        s = 0
        while i > 0:
            s += self.dat[i]
            i -= i & -i
        return s

n, q = LI()
ans = [0] * q
C = LI()
Q = [[] for _ in range(n)]
for i in range(q):
    l, r = LI()
    Q[r - 1] += [(i, l - 1)]

last = [-1] * (n + 1)
bit = BIT(n + 1)
for i, c in enumerate(C):
    col = C[i]
    bit.add(i, 1)
    if last[col] != -1:
        bit.add(last[col], -1)
    last[col] = i
    for qi, li in Q[i]:
        ans[qi] = bit.sum(i) - bit.sum(li - 1)


print(*ans, sep="\n")


Measured memory_bytes: 208080
d=int(input())
C=list(map(int,input().split()))
S=[list(map(int,input().split())) for i in range(d)]
A=[0]*26
for i in range(d):
    cnt=[0]*26
    for j in range(26):
        A[j]+=C[j]
        cnt[j]=S[i][j]-A[j]
    now=cnt.index(max(cnt))
    print(now+1)
    A[now]=0

Measured memory_bytes: 9392
def solve():
    MOD = 1000000007
    N, *a_l = map(int, open(0).read().split())
    t_l = [3] + [0 for _ in range(N+1)]
    ans = 1

    for a in a_l:
        ans = t_l[a] * ans % MOD
        t_l[a] -= 1
        t_l[a+1] += 1
    
    print(ans)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 14044
#![allow(unused)]

//入力マクロここから
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
//入力マクロここまで

//input
//use std::io::Read;

//collections
//use std::collections::BTreeMap;
//use std::collections::BTreeSet;
//use std::collections::HashMap;
//use std::collections::HashSet;
//use std::collections::VecDeque;
//use std::collections::BinaryHeap;

//use std::cmp::*;

fn main() {
    input! {
        s: chars,
    }

    //tabで移動
    if s[2] == s[3] && s[4] == s[5] {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

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

    long long sum = 0;
    for (int i = 1; i <= n; i++){
        if ((i % 3 == 0) || (i % 5 == 0)) continue;
        else sum += i;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main(){
  
  int n;
  cin >> n;
  int y, count=0;
  
  for(int x=0;x<n;x++){
    cin >> y;
    if(x%2==0&&y%2==1){
      count++;
    }
  }
  
  cout << count;
}

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

int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int H,W;
    cin>>H>>W;
    char S[H][W];
    for (int i=0; i<H; i++) {
        for (int j=0; j<W; j++) {
            cin>>S[i][j];
        }
    }
    bool f=true;
    for (int i=0; i<H-1; i++) {
        for (int j=0; j<W-1; j++) {
            if (S[i][j]=='.') {
                continue;
            }
            if (!(S[i+1][j]=='#'||S[i][j+1]=='#'||S[i-1][j]=='#'||S[i][j-1]=='#')) {
                f=false;
            }
        }
    }
    cout<<(f?"Yes":"No")<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;
int main()
{
	char a [10];
	scanf("%s",a);
	if(a[1]==a[2]&&(a[1]==a[0]||a[2]==a[3]))
    printf("Yes");
	else
    printf("No");
    return 0;
}


Measured memory_bytes: 256