akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>          
using namespace std;               

int gcd(int a, int b, int c) {
    if (a==1 and b==1 and c==1) {
        return 1;
    }
    int minimum = min(min(a,b),c);
    int ans;
    for (int i=1; i<=minimum; i++) {
        if (a%i==0 and b%i==0 and c%i==0) {
            ans = i;
        }
    }
    return ans;
}

int sum_gcd(int x) {
    if (x == 1) {
        return 1;
    }
    long long ans = 0;
    for (int i=1; i<x; i++) {
        ans += 3*gcd(i,x,x);
        for (int j=1; j<x; j++) {
            ans += 3*gcd(i,j,x);
        }
    }
    ans += x;
    return ans;
}

int main() {
    int K;
    cin >> K;
    
    vector<long long> A(K);
    A[0] = 1;

    if (K==1) {
        cout << 1 << endl;
        exit(0);
    }

    for (int i=1; i<K; i++) {
        A[i] = A[i-1] + sum_gcd(i+1);
    }

    cout << A[K-1] << endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int a,b;
  cin >> a >> b;
  int ans=a*(a-1)/2+b*(b-1)/2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b;
char c,c1,c2;
int k,t,i,n;
char s1[1000],s2[1000];
int main()
{
cin>>a>>b;
if (a%b!=0) cout<<a<<endl;
  else         cout<<-1<<endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int main(int argc, const char * argv[]) {
  ll a, b, x;
  cin >> a >> b >> x;

  if (a == 0) {
    cout << b / x + 1 << endl;
  } else {
    cout << b / x - (a - 1 )/ x << endl;
  }
  
  return 0;
}


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


	class A
	{
		public static void Main ()
		{

			string w = Console.ReadLine ().ToUpper();
			
			string t = null;
			string line;
			while (true) {
				line = Console.ReadLine ();
				if (line == "END_OF_TEXT") {
					break;
				}

				t += " " + line.ToUpper ();
			}

			string[] s = t.Split (' ');
			int count = 0;
			for (int i=0; i<s.Length; i++) {
				if (s [i] == w) {
					count++;
				}
			}
			Console.WriteLine (count);
		}
	}

Measured memory_bytes: 9048
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		int n = scan.nextInt();
		String s = scan.next();

		if(n%2 != 0) {
			System.out.println("No");
		}else {
			boolean f = true;

			for(int i = 0; i < n/2; i++) {
				if(s.charAt(i) != s.charAt(i+n/2)) {
					f = false;
				}
			}

			if(f) {
				System.out.println("Yes");
			}else {
				System.out.println("No");
			}
		}

	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define range(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, b) for (int i = 0; i < (b); i++)
#define ranger(i, a, b) for (int i = (a)-1; i >= (b); i--)
#define repr(i, b) for (int i = (b)-1; i >= 0; i--)
#define all(a) (a).begin(), (a).end()
#define show(x) cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}
template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
	rep(i, v.size()) { os << v[i] << (i == v.size() - 1 ? "" : " "); }
	return os;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S>& p) {
	os << '(' << p.first << ',' << p.second << ')';
	return os;
}
template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
	for (T& x : v) { is >> x; }
	return is;
}

const int INF = 1e18;

int n;
vector<int> a;
int memo[3005][3005];

int dfs(int l, int r, bool t) { // [l,r]
	if (not(l == -1 or r == n + 1)) {
		if (memo[l][r] != -1) return memo[l][r];
	}

	if (t) { // min
		int res = INF;
		if (l + 1 < r) res = min(res, dfs(l + 1, r, t ^ 1) - a[l + 1]);
		if (l < r - 1) res = min(res, dfs(l, r - 1, t ^ 1) - a[r - 1]);
		if (res == INF) res = 0;
		//cout << l << ' ' << r << ' ' << res << endl;
		if (not(l == -1 or r == n + 1)) { return memo[l][r] = res; }
		return res;
	} else { // max
		int res = -INF;
		if (l + 1 < r) res = max(res, dfs(l + 1, r, t ^ 1) + a[l + 1]);
		if (l < r - 1) res = max(res, dfs(l, r - 1, t ^ 1) + a[r - 1]);
		if (res == -INF) res = 0;
		//cout << l << ' ' << r << ' ' << res << endl;
		if (not(l == -1 or r == n + 1)) { return memo[l][r] = res; }
		return res;
	}
}

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

	a = vector<int>(n);
	cin >> a;

	rep(i, 3005) rep(j, 3005) memo[i][j] = -1;
	cout << dfs(-1, n, 0) << endl;
}


Measured memory_bytes: 70912
#include <iostream>

using namespace std;

int main() {
  int K, N, dist;
  int* A;
  cin >> K >> N;
  A = new int[N];
  for (int i = 0; i < N; i++) cin >> A[i];
  
  dist = (K - A[N - 1]) + A[0];
  for (int i = 0; i < N - 1; i++) {
    if (dist < A[i + 1] - A[i]) {
      dist = A[i + 1] - A[i];
    }
  }
  
  cout << K - dist << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	string s; cin >> s;
	sort(all(s));
	cout << (s[0] == s[1] && s[1] != s[2] && s[2] == s[3] ? "Yes" : "No") << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int a = sc.nextInt();
        int b = sc.nextInt();
        sc.close();

        int[] s = new int[999];
        for(int i = 0; i < 999; i++){
            if(i == 0){
                s[i] = 1;
            } else {
                s[i] = s[i-1]+(i+1);
            }
        }
        int diff = b-a;

        System.out.println(s[diff-2] - a);
    }
}

Measured memory_bytes: 23252
import java.util.*;


public class Main{
	public static void main(String args[]){
        int key = 1;
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] array = new String[str.length()];
        for(int i = 0; i < str.length(); i++){
            String str2 = String.valueOf(str.charAt(i));
            array[i] = str2;
        }
        if( (str.length() % 2) == 0){
            for(int j = 0; j < str.length() / 2; j++){
                if(array[2*j].equals("L")){
                    key = 0;
                }
                if(array[2*j+1].equals("R")){
                    key = 0;
                }
            }
        }else{
            for(int j = 0; j < (str.length() / 2) + 1; j++){
                if(array[2*j].equals("L")){
                    key = 0;
                }
            }
            for(int j = 0; j < str.length() / 2; j++){
                if(array[2*j+1].equals("R")){
                    key = 0;
                }
            }
        }
        if(key == 1){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23124
#pragma GCC optimize("Ofast")
#include <stdio.h>
#include <algorithm>
#define maxn 200005
using namespace std;
typedef long long loli;
 
 
loli A[maxn], F[maxn];
loli N, K;
 
bool cal(loli x) {
    loli tmp, cnt = 0;
    for(int i = 1; i <= N; i++) {
        tmp = x / F[i];
        if(A[N - i + 1] > tmp) {
            cnt += A[N - i + 1] - tmp;
        }
    }
    return cnt <= K;
}
 
int main() {
    scanf("%lld%lld", &N, &K);
    for(int i = 1; i <= N; i++) {
        scanf("%lld", A + i);
    }
    for(int i = 1; i <= N; i++) {
        scanf("%lld", F + i);
    }
    sort(A + 1, A + N + 1);
    sort(F + 1, F + N + 1);
    loli L = -1, R = 1e12;
    while(R - L > 1) {
        loli M = (L + R) >> 1;
        if(cal(M))
            R = M;
        else
            L = M;
    }
    printf("%lld\n", R);
    return 0;
}

Measured memory_bytes: 3328
import           Control.Applicative
import           Control.Monad

startWith _  [] = False
startWith [] _  = True
startWith a@(t : ts) b@(x : xs) | a == b = True
                                | t == x    = startWith ts xs
                                | otherwise = False

hoge :: String -> String
hoge [] = []
hoge str@(x : xs) | startWith "Hoshino" str = "Hoshina" ++ hoge (drop 7 str)
                  | otherwise               = x : hoge xs

main = do
  n  <- readLn
  rs <- replicateM n $ fmap hoge getLine
  mapM_ putStrLn rs



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

int main() {
  ios::sync_with_stdio(false);
  int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  typedef long long LL;
  
  vector<LL> A(X);
  vector<LL> B(Y);
  vector<LL> C(Z);
  for(int i = 0; i < X; i++) cin >> A[i];
  for(int i = 0; i < Y; i++) cin >> B[i];
  for(int i = 0; i < Z; i++) cin >> C[i];
  
  auto rev = [](LL a, LL b) { return a > b; };
  priority_queue<LL, vector<LL>, decltype(rev)> pq(rev);
  sort(A.begin(), A.end(), rev);
  sort(B.begin(), B.end(), rev);
  sort(C.begin(), C.end(), rev);
    
  for(int a = 0; a < X; a++) {
    for(int b = 0; b < Y; b++) {
      for(int c = 0; c < Z; c++) {
        LL cur = A[a] + B[b] + C[c];
        if(pq.size() < K) pq.push(cur);
        else {
          if (pq.top() < cur) {
            pq.push(cur);
            pq.pop();
          } else {
            break;
          }
        }
      }
    }
  }
  
  vector<LL> ans(K);
  for(int i = K-1; i >= 0 ; i--)
    ans[i] = pq.top(), pq.pop();
  for(int i = 0; i < K; i++)
    cout << ans[i] << "\n";
}

Measured memory_bytes: 384
#include<stdio.h>
long long a[100010];

int main(){
        int n, i;
        scanf("%d", &n);
        for(i=0; i<n; i++){
                scanf("%lld", &a[i]);
        }
        int zero=0;
        for(i=0; i<n; i++){
                if(a[i]==0){
                        zero++;
                }
                if(zero>0){
                        printf("0");
                        return 0;
                }
        }

        long long prod=1;
        for(i=0; i<n; i++){
                if(a[i]<=1000000000000000000/prod){
                        prod*=a[i];
                }else{
                        printf("-1");
                        return 0;
                }
        }
        printf("%lld", prod);
}


Measured memory_bytes: 2476
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64
#define n_max int(2*1e5)



int main(){
    int n;
    llong k;
    cin >> n;
    cin >>k;
    llong ans=k*n;
    llong t_b,t_n;
    cin >> t_b;
    REP(i,n-1){
        scanf("%lld",&t_n);
        ans-= max(llong(0), k - (t_n - t_b));
        t_b=t_n;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
// SwappingTwoNumbers.cc
// ２つの整数 x, y を読み込み、それらを値が小さい順に出力するプログラムを作成して下さい。
// ただし、この問題は以下に示すようにいくつかのデータセットが与えられることに注意して下さい。
// 【入力】
// 入力は複数のデータセットから構成されています。
// 各データセットは空白で区切られた２つの整数 x, y を含む１行から構成されています。
// x と y がともに 0 のとき入力の終わりを示し、このデータセットに対する出力を行ってはいけません。
// 【出力】
// 各データセットごとに、x と y を小さい順に並べたものを１行に出力して下さい。
// x と y の間には１つの空白を入れて下さい。
// 【制約】
// 0 ≤ x, y ≤ 10,000
// データセットの数は 3,000 を超えない。
// 【例】
// 入力：
// 3 2
// 2 2
// 5 3
// 0 0
// 出力：
// 2 3
// 2 2
// 3 5
#include<stdio.h>

int main( void) {
  int x, y;

  while ( 1) {
    scanf( "%d %d", &x, &y);

    if ( x == 0 && y == 0) break;

    if ( x > y) printf( "%d %d\n", y, x);
    else printf( "%d %d\n", x, y);
  }

  return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




ll power(ll x,ll k){
  ll ret=1;
  while(k>0){
    if(k&1) (ret*=x) %= M;
    (x*=x) %= M;
    k >>= 1;
  }
  return ret;
}

int inverse(int a){
  return power(a,M-2);
}


int comb(int n,int k){
  int res=1;
  rep(i,k){
    res*=n-i;
    res%=M;
    res*=inverse(i+1);
    res%=M;
  }
  return res;
}



main(){
  int n,m,k;
  cin>>n>>m>>k;
  int t=comb(n*m-2,k-2);

  int ans=0;
  rep(i,n){
    int s=((((((n-1-i)*(n-i)/2)%M)*m)%M)*m)%M;
    ans+=s;
    ans%=M;
  }

  rep(i,m){
    int s=((((((m-1-i)*(m-i)/2)%M)*n)%M)*n)%M;
    ans+=s;
    ans%=M;
  }

  cout<<(ans*t)%M<<endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
nl=[]
ml=[]
for i in range(n):
    nl.append(input())
for i in range(m):
    ml.append(input())

cnt=0
Yes=False
for i in nl:
    if(ml[0] in i):
        idx = i.find(ml[0])
        cnt2=cnt+1
        if m==1:
            Yes = True
            break
        for j in range(1,m):
            if cnt2>n-1:
                break
            elif(not ml[j]==nl[cnt2][idx:idx+m]):
                break
            elif(j==m-1):
                Yes = True
                break
            cnt2+=1
    if(Yes):
        break
    cnt+=1
if Yes:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;

vector<ll> m(ll a) {
  vector<ll> ans;
  for (ll i = 2; i * i <= a; i++) {
    if (a % i == 0) {
      ans.push_back(i);
      while (a % i == 0) {
        a /= i;
      }
    }
  }
  if (a != 1) {
    ans.push_back(a);
  }
  return ans;
}

int main() {
  int N;
  cin >> N;
  ll A[N];
  unordered_map<ll,bool> mp;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  sort(A,A+N);
  reverse(A,A+N);
  bool Flag = true;
  for (int i = 0; i < N; i++) {
    if (A[i] == 1) {
      break;
    } else {
      vector<ll> vec = m(A[i]);
      for (int j = 0; j < (int)vec.size(); j++) {
        if (mp[vec[j]]) {
          Flag = false;
          break;
        } else {
          mp[vec[j]] = true;
        }
      }
    }
  }

  if (Flag) {
    cout << "pairwise coprime" << endl; 
  } else {
    ll gc = A[0];
    for (int i = 0; i < N; i++) {
      gc = __gcd(gc,A[i]);
      if (gc == 1) {
        break;
      }
    }
    if (gc == 1) {
      cout << "setwise coprime" << endl;
    } else {
      cout << "not coprime" << endl; 
    }
  }
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl '\n';
#define FASTER ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);

template <typename T> inline T bigMod(T A,T B,T M = MOD){A %= M;T ret = 1;while(B){if(B & 1) ret = (ret * A) % M;A = (A * A) % M;B = B >> 1;}return ret;}
template <typename T> inline T invMod (T A,T M = MOD){return bigMod(A,M-2,M);}

const int N = 200005;

int main(){
  FASTER;
  int n;
  cin >> n;
  int A[n + 5], B[n + 5], C[n + 5];
  for (int i = 1; i <= n; i++){
    cin >> A[i];
  }
  for (int i = 1; i <= n; i++){
    cin >> B[i];
  }
  for (int i = 1; i < n; i++){
    cin >> C[i];
  }
  ll sum = 0;
  int prev = -1;
  for (int i = 1; i <= n; i++){
    sum += B[A[i]];
    int curr = A[i];
    if (curr - prev == 1){
      sum += C[curr - 1];
    }
    prev = curr;
  }
  cout << sum << "\n";
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

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

func inputIntSlice(n int) []int {
	strSlice := strings.Split(inputAsString(), " ")
	arr := make([]int, n)
	for i, a := range strSlice {
		arr[i] = mustAtoi(a)

	}
	return arr
}

func mustAtoi(s string) int {
	i, err := strconv.Atoi(s)
	if err != nil {
		panic(err)
	}
	return i
}

//
//type sortable [][]int
//
//func (s sortable) Len() int { return len(s) }
//
//func (s sortable) Less(i, j int) bool { return s[i][0] < s[j][0] }
//
//func (s sortable) Swap(i, j int) { s[i], s[j] = s[j], s[i] }

func main() {
	sc.Buffer([]byte{}, 100000000)

	var n, k int
	fmt.Scan(&n, &k)
	his := inputIntSlice(n)

	count := 0
	for _, a := range his {
		if a >= k {
			count++
		}
	}
	fmt.Println(count)
}


Measured memory_bytes: 4352
#include<stdio.h>

int n;
int a[20];
int flg[10000000];

void dfs(int x,int sum){
  if(x==n){
    flg[sum]=1;
    return;
  }
  dfs(x+1,sum);
  dfs(x+1,sum+a[x]);
}

int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  dfs(0,0);
  int q,key;
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&key);
    if( flg[key]==1 ){
      printf("yes\n");
    }else{
      printf("no\n");
    }
  }
  return 0;
}


Measured memory_bytes: 2144
#include<cstdio>
#include<cstring>
typedef long long ll;
const int N=52;
const ll mod=1000000007;
char s1[N+5],s2[N+2];
int n;
ll ans=1;
int main(){
//	freopen("ex.in","r",stdin);
	scanf("%d",&n);
	scanf("%s%s",s1+1,s2+1);
	for(int i=1;i<=n;++i){
		if(s1[i]==s2[i]){
			if(i==1) ans*=3,ans%=mod;
			else if(s1[i-1]==s2[i-1]) ans*=2,ans%=mod;
		}
		else if(i+3<=n&&s1[i]==s1[i+1]&&s2[i]==s2[i+1]&&s1[i+2]==s1[i+3]&&s2[i+2]==s2[i+3]){
			if(i==1) ans*=18,ans%=mod;
			else if(i>1&&s1[i-1]==s2[i-1]) ans*=6,ans%=mod;
			else if(i>2&&s1[i-1]==s1[i-2]&&s2[i-1]==s2[i-2]) ans*=9,ans%=mod;
			i+=3;
		}
		else if(i+1<=n&&s1[i]==s1[i+1]&&s2[i]==s2[i+1]){
			if(i==1) ans*=6,ans%=mod;
			else if(i>1&&s1[i-1]==s2[i-1]) ans*=2,ans%=mod;
			else if(i>2&&s1[i-1]==s1[i-2]&&s2[i-1]==s2[i-2]) ans*=3,ans%=mod;
			i++;
		}
	}
	printf("%lld",ans);
	return 0;
}
//else if(s1[i-1]==s1[i-2]&&s2[i-1]==s2[i-2]) ans*=1;

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main() {
    long long a = 0;
    long long b  =0;
    cin >> a >> b;
    if (a > 0 && b > 0){
        cout << "Positive";
    } else if (a > 0 && b < 0){
        cout << "Zero";
    } else if (a < 0 && b < 0){
        long long m = a - b;
        if (m % 2 == 0){
            cout << "Negative";
        } else{
            cout << "Positive";
        }
    } else if (a == 0 && b == 0){
        cout << "Zero";
    } else if (a < 0 && b > 0){
        cout << "Zero";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>  
 
using namespace std;
 
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define FORr(i, j, k) for(int i = j; i >= k; --i)
#define repr(i, j) FOR(i, j, 0)
#define INF (1 << 30)
#define MOD 1e9 + 7
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

int N;
ll T, ans, t;

int main() {
	bool flag = true;
	scanf("%d %lld", &N, &T);
	scanf("%lld", &t);
	ll tmp = t, min = t;
	rep(i, N - 1) {
		scanf("%lld", &t);
		if(t - tmp < T) {
			tmp = t;
			flag = true;
		}
		else {
			ans += tmp - min + T;
			min = t;
			tmp = t;
			flag = false;
		}
	}
	if(flag) {
		ans += tmp - min + T;
		min = t;
		tmp = t;
	}
	else {
		ans += T;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define N 100005
#define mod 1000000007
#define For(i,x,y) for(int i=x;i<=y;i++)
#define Rep(i,x,y) for(int i=x;i>=y;i--)
using namespace std;
inline int read(){
	int x=0,f=0;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar()) if(ch=='-') f=1;
	for(;ch>='0'&&ch<='9';ch=getchar()) x=(x<<1)+(x<<3)+ch-48;
	return f?-x:x;
}
int n,m;
ll f[3005][3005][2];
int main(){
	n=read();m=read()-2;
	For(i,0,n-1) f[0][i][i==0]=1;
	For(i,0,m) For(j,0,n) For(k,0,1) if(f[i][j][k]>0){
		if(j) f[i+1][j-1][(k)||j-1==0]=(f[i+1][j-1][(k)||j-1==0]+f[i][j][k])%mod;
		if(j<n-1) f[i+1][j+1][k]=(f[i+1][j+1][k]+f[i][j][k])%mod;
		f[i+1][j][k]=(f[i+1][j][k]+f[i][j][k]*2)%mod;
	}
	ll ans=0;
	For(i,0,n-1) ans=(ans+f[m+1][i][1])%mod;
	printf("%d\n",ans*4%mod);
	return 0;
}


Measured memory_bytes: 141056
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
const int MAXN = 2e5+5,MAXM = 2e5+5,MOD = 20130427,INF = 0x3f3f3f3f,N=100050;
const ll INFL = 0x3f3f3f3f3f3f3f3f;
const db eps = 1e-9;
#define lson o<<1,l,m
#define rson o<<1|1,m+1,r
#define mid l + ((r-l)>>1)
#define rep(i,a,b) for(register int i=(a);i<=(b);i++)
#define vii vector<pair<int,int>>
#define vi vector<int>
using namespace std;

char s[MAXN];
int n;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    //freopen("../A.in","r",stdin);
    //freopen("../A.out","w",stdout);
    cin>>(s+1);
    n=strlen(s+1);
    ll ans=0;
    int sum=0;
    for(int i=1;i<=n;i++){
        if(s[i]=='W'){
            ans+=sum;
        }else sum++;
    }
    cout<<ans<<'\n';
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<string>

using namespace std;

int main(){
    vector<int> a(5);
    int k;
    for(int i=0;i<5;i++){
        cin >> a[i];
    }
    cin >> k;
    for(int i=0;i<5;i++){
        for(int j=0;j<5;j++){
            if(abs(a[i]-a[j]) > k){
                cout << ":(" << endl;
                return 0;
            }
        }
    }
    cout << "Yay!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define N 101


int x;
int P[N];
int M[N][N];


int main(){
   
  int n,i,a,count;
  scanf("%d",&x);
   
  for(i=0;i<x;i++){
    scanf("%d %d",&P[i+1],&a);}

  
  P[i+1]=a;
   
  Matrix_Chain_Order();
   
  return 0;
}






void Matrix_Chain_Order(){
  int i,j,l,k,q,n;
  n=x;
 
  for(i=1;i<=n;i++){
    M[i][i]=0;}
  
  for(l=2;l<=n;l++){
    
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
      M[i][j]=100000;
      for(k=i;k<=j-1;k++){
	q=M[i][k]+M[k+1][j]+P[i]*P[k+1]*P[j+1];
	if(q<M[i][j]){
	  M[i][j]=q;
	}
      }
    }
  }
  printf("%d\n", M[1][x]);
}

Measured memory_bytes: 636
# https://atcoder.jp/contests/abc071/tasks/arc081_a

import itertools
import collections
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))

    c = collections.Counter(A)
    a = 0
    b = 0
    c = sorted(c.items(), key=lambda i: i[0], reverse=True)
    # print(c)
    for item in c:
        # print(item)
        if a == 0:
            if item[1] >= 4:
                a = item[0]
                b = item[0]
                break
            elif item[1] >= 2:
                a = item[0]
        else:
            if item[1] >= 2:
                b = item[0]
                break
    print(a * b)


if __name__ == '__main__':
    main()


Measured memory_bytes: 22156
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int n, r; cin >> n >> r;
    int ans;
    if (n >= 10) ans = r;
    else ans = r + 100 * (10 - n);
    cout << ans << endl;
}


Measured memory_bytes: 764
/**
 * author:    Ziel
 * created:   15.04.2020 19:51:56
**/

// ~zaletaet~

//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#define fi first
#define se second
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define pb push_back

using namespace std;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const ll N = 1e5 + 123, MOD = 1e9 + 7, oo = 1e9 + 9, INF = 1e18 + 9;
const double EPS = 1e-9, PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1}, dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	
	int n, m;
	cin >> n >> m;

	vector<int> a(m);
	ll sum = 0;
	for (int i = 0; i < m; i++) { cin >> a[i]; sum += a[i]; }

	if (sum > n) return !(cout << -1);
	
	cout << n - sum;

	return 0;
}




Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N; cin >> N;
    int A[N];
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A, A + N);
    for (int i = 0; i < N; i++)
    {
        int now = A[i];
        int p = lower_bound(A, A + N, A[i]) - A + 1;
        if(A[i] == A[p]) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const int MAXLEN = 50;

char s[MAXLEN + 1];

void run() {
	scanf("%s", s); s[strlen(s) - 8] = '\0'; printf("%s\n", s);
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){int n,k,i;
cin>>k;
string s,ans;
ans="";
cin>>s;
n=s.size();
if(n<=k){cout<<s;return 0;};
for(i=0;i<k;i++){ans+=s[i];}
ans+="...";
cout<<ans;
    return 0;}

Measured memory_bytes: 3608
import sys

N = int(input())
H = list(map(int, input().split()))

gyakuten = [0]

for i in range(N-1):
    if H[i] < H[i+1]:
        gyakuten.append(i+1)

gyakuten.append(N)

# print(gyakuten)

saidai = 0
for i in range(len(gyakuten)-1):
    saidai = max(saidai, gyakuten[i+1]-gyakuten[i]-1)

print(saidai)


Measured memory_bytes: 14252
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 20






int main() {
	int a[N][N];
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d", &n, &k);
	f(i, n) {
		f(j,k)scanf("%d", &a[i][j]);
	}
	ans = 0;
	f(i, n) {
		f(j, i) {
			x = 0;
			f(ii, k) {
				y = (a[i][ii] - a[j][ii]);
				x += (y*y);
			}
			z = 0;
			while (true) {
				if ((z*z) == x)ans++;
				if ((z*z) > x)break;
				z++;
			}
		}
	}

	printf("%d\n", ans);


	return 0;
}

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

if (A+B) < C*2:
    print(A*X + B*Y)
else:
    if X < Y:
        print(X * C*2 + (Y-X) * min(C*2, B))
    else:
        print(Y * C*2 + (X-Y) * min(C*2, A))


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



int main() {


    char s[1200];
    long long int n,topopd=0,i,opd[205]={0},nr;

    cin.getline(s,1200);

    n=strlen(s);

    i=0;
    while(i<n)
    {
        nr=0;
        if(s[i]==' ') i++;
        if(s[i]=='*')
        {
            opd[topopd-1]=opd[topopd]*opd[topopd-1];
            topopd--;

        }
        else if(s[i]=='+')
        {

            opd[topopd-1]=opd[topopd]+opd[topopd-1];
            topopd--;
        }
        else if(s[i]=='-')
        {

            opd[topopd-1]=opd[topopd-1]-opd[topopd];
            topopd--;
        }
        else
        {
            while(s[i]!=' ')
            {
                nr=nr*10+s[i]-'0';
                i++;
            }
            opd[++topopd]=nr;
        }

        i++;

    }

    cout<<opd[topopd]<<'\n';


    return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
//#pragma GCC optimize "-O3"
typedef unsigned long long ull;
typedef unsigned int ui;
typedef unsigned short us;
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll infll=(1ull<<63)-1;
const int inf=(1ull<<31)-1;
ll k,x;

int main()
{
	//freopen("in.txt","r",stdin);freopen("out.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);cout.precision(15);
	cin>>k>>x;
	cout<<((k*500>=x)?"Yes":"No");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main() {
  int K,X;
  cin>>K>>X;
  if(500*K>=X){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
  return 0;
}

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

using ll=long long;

ll check(vector<pair<ll,ll>> vt){
  ll n = vt.size();
  for(int i=0;i<n;i++) vt[i].first=min(vt[i].first,n);
  vector<vector<ll>> vs(n+1);
  for(int i=0;i<n;i++) vs[vt[i].first].emplace_back(vt[i].second);
  priority_queue<ll> que;
  ll ans=0;
  for(int i=n;i>0;i--){
    for(auto u:vs[i]){
      que.push(u);
    }
    if(!que.empty()){
      ans+=que.top();
      que.pop();
    }
  }
  //cout << "ans:" << ans << endl;
  return ans;
}

ll solve(){

  int n;
  cin >> n;

  ll k,l,r;
  ll ans = 0;
  vector<pair<ll,ll>> right,left;
  ll m;
  for(int i=0;i<n;i++){
    cin >> k >> l >> r;
    /*m=min(l,r);
    l-=m;
    r-=m;
    ans+=m;
    if(l>0){
      left.emplace_back(k,l);
    }else{
      right.emplace_back(n-k,r);
    }*/

    if(l>r){
      ans+=r;
      left.emplace_back(k,l-r);
    }else{
      ans+=l;
      right.emplace_back(n-k,r-l);
    }
  }
  //cout << "befor:" << ans << endl;
  ans+=check(left);
  ans+=check(right);
  return ans;
}

int main(){

  ll t;
  cin >> t;
  vector<ll> ans;
  for(ll i=0;i<t;i++){
    //solve();
    ans.push_back(solve());
  }

  //cout << "ans" << endl;
  for(ll i=0;i<t;i++){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 14304
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define pb(a) push_back(a)
#define pr(a) cout<<(a)<<endl
#define PR(a,b) cout<<(a)<<" "<<(b)<<endl
#define R cin>>
#define F first
#define S second
#define ll long long
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

string s;
string::iterator p;
ll fact();
ll term();
ll exp();

set<char> se[3];

ll fact() {
  ll x;
  string num;
  while(isdigit(*p)) {
    num += *p;
    ++p;
  }
  if(num.size()) {
    stringstream ss;
    ss << num;
    ss >> x;
  } else {
    ++p;
    x = exp();
    ++p;
  }
  return x;
}
 
ll termz() {
  ll x = fact();
  while(se[2].count(*p)) {
    if(*p == '+') {
      ++p;
      x += fact();
    } else if(*p == '*') {
      ++p;
      x *= fact();
    } else {
      ++p;
      x -= fact();
    }
  }
  return x;
}

ll term() {
  ll x = termz();
  while(se[1].count(*p)) {
    if(*p == '+') {
      ++p;
      x += termz();
    } else if(*p == '*') {
      ++p;
      x *= termz();
    } else {
      ++p;
      x -= termz();
    }
  }
  return x;
}
 
ll exp() {
  ll x = term();
  while(se[0].count(*p)) {
    if(*p == '+') {
      ++p;
      x += term();
    } else if(*p == '*') {
      ++p;
      x *= term();
    } else {
      ++p;
      x -= term();
    }
  }
  return x;
}

int main() {
  R s;
  ll ans=-LLONG_MAX;
  rep(i,3) rep(j,3) rep(k,3) {
    rep(l,3) se[l].clear();
    se[i].insert('+');
    se[j].insert('-');
    se[k].insert('*');
    p=s.begin();
    ans=max(ans,exp());
  }
  pr(ans);
  return 0;
}


Measured memory_bytes: 1224
def pluss_zero(a, L):
    a = str(a)
    while len(a) < L:
        a = "0" + a
    return a

def make_maxminnum(a):
    a = list(a)
    a.sort()
    maxa = int("".join(a[::-1]))
    mina = int("".join(a))
    return maxa - mina

ans_list = []

while True:
    a, L = map(int, input().split())
    if a == 0 and L == 0:
        break
    a_list = [a]
    for i in range(21):
        a = make_maxminnum(pluss_zero(a, L))
        a_list.append(a)

    ans = 0
    for i in range(21):
        for j in range(21):
            if i < j and a_list[i] == a_list[j]:
                ans = [str(i), str(a_list[i]), str(j - i)]
                break
        if ans:
            break
    ans_list.append(ans)

#print(ans_list)
for i in ans_list:
    #print(i)
    print(" ".join(i))


Measured memory_bytes: 5616
#include<bits/stdc++.h>
#define N 2100005
using namespace std;
int n;
void solve(){
	scanf("%d",&n);
	double res=0;
	for(int a,i=1;i<=n;i++){
		scanf("%d",&a);
		res+=1.0/a;
	}
	printf("%.6f\n",1.0/res);
}
int main(){
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long int ll;
#define pb push_back
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
ll p=1e9+7;
ll inf=1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	ll i,j,w,h,y,r,k,d,q,m,t,a,b,n;
	ld x;
	cin>>a>>b>>n;
	ll temp=std::min(b-1,n);
	temp*=a;
	temp/=b;
	cout<<temp;
	return 0;
	
	
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define MAX 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

ll ans;

// a^n mod を計算する
ll modpow(ll a, ll n) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % 2019;
		a = a * a % 2019;
		n >>= 1;
	}
	return res;
}

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

	string s;
	cin >> s;

	rep(i, s.size()) {
		if (s[i] == '+') {
			ans++;
		}
		else {
			ans--;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let mut S = io.chars();
    S.reverse();

    let mut map = vec![0usize; 2020];
    map[0] = 1;
    let mut s = 0usize;
    let mut now = 0usize;
    let mut ten = 1usize;
    for &ch in S.iter() {
        let num = ch.to_digit(10).unwrap() as usize;
        now += num * ten;
        map[now % 2019] += 1;
        ten *= 10;
        ten %= 2019;
    }

    let mut ans = 0usize;
    for i in 0..2019 {
        if map[i] > 0 {
            ans += (map[i] * (map[i] - 1)) / 2;
        }
    }

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

// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug>(&mut self, val1: S, val2: S) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}


Measured memory_bytes: 3132
func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}
    
let abc = readInts()
let a = abc[0]
let b = abc[1]
let c = abc[2]
if (a+b+c)<=21{
  print("win")
}else{
  print("bust")
}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define ture ture
#define flase false
#define falg flag

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;//llの最大9*10^18
const int INF = pow(2, 30) - 1;

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

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

    ll N,p_num,q_num;
    ll num = 0;
    cin >> N;
    vector<int> v;
    REPS(i,N){
        v.push_back(i);
    }
    vector<int> p(N),q(N);

    REP(i,N){
        cin >> p.at(i);
    }
    REP(i,N){
        cin >> q.at(i);
    }

    do
    {
        num++;
        REP(i, N)
        {
            if(!(p.at(i)==v.at(i))){
                break;
            }
            if(i==N-1){
                p_num = num;
            }
        }
        REP(i, N)
        {
            if (!(q.at(i) == v.at(i)))
            {
                break;
            }
            if (i == N - 1)
            {
                q_num = num;
            }
        }
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(p_num - q_num) << endl;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N = 200000 + 10;
char s[N]; 
int n;
int dp[N][3];
int main() {
	scanf("%s",s+1); n=strlen(s+1);
	for(int i=0;i<N;i++){
		for(int j=1;j<=2;j++) dp[i][j]=-1e9;
	}
	if(n<=1){
		return !printf("1\n");
	}
	dp[1][1]=1; dp[2][2]=1;
	if(s[1]!=s[2]) dp[2][1]=2;
	for(int i=3;i<=n;i++){
		dp[i][1]=dp[i-1][2]+1;
		if(s[i]!=s[i-1]) dp[i][1]=max(dp[i][1],dp[i-1][1]+1);

		dp[i][2]=dp[i-2][1]+1;
		// i,i-1 i-2,i-3
		if(s[i]!=s[i-2] || s[i-1]!=s[i-3]){
			dp[i][2]=max(dp[i][2],dp[i-2][2]+1);
		}
	}
	cout<<max(dp[n][1],dp[n][2])<<endl;
}

Measured memory_bytes: 2816
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define LOOP(i) while(i--)
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class ConnectNodeInfo{
	vector<vector<pair<ll,ll>>> graph;
public:
	ConnectNodeInfo(int node_num){
		graph.resize(node_num);
	}
	void AddNonDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
		graph[v].emplace_back(u,w);
	}
	void AddDirectionalConnection(ll u,ll v,ll w){
		graph[u].emplace_back(v,w);
	}
	vector<pair<ll,ll>>& operator[](ll index){
		return graph[index];
	}
	size_t size(){return graph.size();}
};

class RootedNode{
public:
	vector<ll> parent;
	ll depth,dist;
	RootedNode():depth(0),dist(0){}
};

class RootedTree{
	int parent_size;

	void DFS(ConnectNodeInfo& connection,ll child,ll parent,ll dep,ll dist){
		node[child].parent[0] = parent;
		node[child].depth = dep;
		node[child].dist = dist;

		for(int i = 0;i < connection[child].size();i++){
			if(connection[child][i].first != parent){
				DFS(connection,connection[child][i].first,child,dep+1,dist+connection[child][i].second);
			}
		}
	}
public:
	vector<RootedNode> node;

	RootedTree(ConnectNodeInfo& connection,int root){
		auto connection_size = connection.size();
		parent_size = 1;
		while((1LL<<parent_size)<connection_size) parent_size++;

		node.resize(connection_size);
		for(auto& x:node) x.parent.resize(parent_size,-1);
		DFS(connection,root,-1,0,0);
		for(int k=0;k<parent_size-1;k++){
			for(int v=0,ev=connection_size;v<ev;v++){
				if(node[v].parent[k] < 0) node[v].parent[k+1] = -1;
				else node[v].parent[k+1] = node[node[v].parent[k]].parent[k];
			}
		}
	}
	ll FindLCA(ll u,ll v){
		if(node[u].depth > node[v].depth) swap(u,v);
		for(int k=0;k<parent_size;k++){
			if((node[v].depth - node[u].depth) & (1LL<<k)){
				v = node[v].parent[k];
			}
		}
		if(u==v) return u;
		for(int k=parent_size-1;k>=0;k--){
			if(node[u].parent[k] != node[v].parent[k]){
				u = node[u].parent[k];
				v = node[v].parent[k];
			}
		}
		return node[u].parent[0];
	}
};

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

	ll N=in();
	ConnectNodeInfo connect(N);
	REP(i,N-1){
		int u=in()-1,v=in()-1,w=in();
		connect.AddNonDirectionalConnection(u,v,w);
	}
	
	int M=in(),K=in()-1;
	RootedTree tree(connect,K);
	REP(i,M){
		int u=in()-1,v=in()-1;
		out(tree.node[u].dist+tree.node[v].dist);
	}

	return 0;
}


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

int main() {
  int A, B, C, K, ans;
  cin >> A >> B >> C >> K;
  if (A >= K) ans = K;
  else if (A + B >= K) ans = A;
  else ans = 2 * A + B - K;
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll n;
  cin >> n;
  
  string S;
  vl com(26, 100);
  
  rep(i, n){
    cin >> S;
    ll len = S.size();
    map<ll, ll> cnt;

    rep(j, len) cnt[S[j] - 'a']++;

    rep(j, 26) com[j] = min(com[j], cnt[j]);
  }
  
  rep(i, 26){
    rep(j, com[i]){
      cout << (char)(i + 'a');
    }
  }
  
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    H, W = map(int, readline().split())
    A = [list(map(int, readline().split())) for _ in range(H)]
    B = [list(map(int, readline().split())) for _ in range(H)]

    G = [[0] * W for _ in range(H)]
    for i in range(H):
        for j in range(W):
            G[i][j] = abs(A[i][j] - B[i][j])

    dp = [[set() for j in range(W)] for i in range(H)]
    dp[0][0].add(G[0][0])

    for i in range(H):
        for j in range(W):
            if i == 0 and j == 0:
                continue
            s = dp[i][j]
            b = G[i][j]
            if i > 0:
                for k in dp[i - 1][j]:
                    s.add(k + b)
                    s.add(abs(k - b))
            if j > 0:
                for k in dp[i][j - 1]:
                    s.add(k + b)
                    s.add(abs(k - b))

    print(min(dp[H - 1][W - 1]))
    return


if __name__ == '__main__':
    main()


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

int main() {
  int K,S;
  cin >> K >> S;
  
  int cnt=0;
  for(int i=0; i<=K; i++){
    for(int j=0; j<=K; j++){
      if(S-i-j<=K && S-i-j>=0) cnt++;
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;

int n,ans;
string s;
int main(){
  cin >> n >> s;
  for(int i = 0;i < n;i++) ans += (s.substr(i,3) == "ABC");
  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;
const ll mod = 998244353;

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

    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    REP(i, n) cin >> a[i];

    vector<ll> dp(s + 1, 0);

    dp[0] = 1;

    REP(i, n) {
        vector<ll> tmp(s + 1, 0);
        swap(dp, tmp);
        REP(j, s + 1) {
            dp[j] += tmp[j] * 2;
            dp[j] %= mod;
            if (j + a[i] <= s) {
                dp[j + a[i]] += tmp[j];
                dp[j + a[i]] %= mod;
            }
        }
    }

    cout << dp[s] << '\n';
    return 0;
}


Measured memory_bytes: 3684