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

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define rer(i, a, b) for (int i = (int)a; i <= (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;

const int inf = 1000000000;
const int mod = 1000000007;
const double eps = 1e-9;
const int dx[] = { -1, 0, 1, 0};
const int dy[] = { 0, -1, 0, 1};

int main() {
	string s;
	int ans = 0;
	while (cin >> s) {
		rep(i, s.size()) {
			int n = 0;
			while ('0' <= s[i + n] && s[i + n] <= '9') n++;
			ans += atoi(s.substr(i, n).c_str());
			i += n;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1200
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm> // sort
#include <iomanip>
#include <queue>
#include <map>
#include <bits/stdc++.h>


using namespace std;

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll INF = 1000000000000000000LL;
typedef pair<int,int> pint;


const int MOD = 1000000007;

//1,2,3,4
//
//1,2
//1,2,3
//1,2,3,4
//2,3
//2,3,4
//3,4

int main(){

#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    string s;
    cin >> s;
    ll res;
    ll a[26] = {};
    REP(i,s.size())
    {
        a[s[i]-'a']++;
    }

    REP(i,26)
    {
        if(a[i] == 0)
        {
            char t = 'a' + i;
            cout << t << endl;
            return 0;
        }

    }




    

    cout << "None" << endl;

    return 0;     
}



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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = 10e10;
const ll MINF = -10e10;
//const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)

typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;
//ifstream myfile("C:\\Users\\riku\\Downloads\\01.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;

int main() {

    int h, w;
    cin >> h >> w;


    vector<vector<char>> board(h, vector<char>(w));
    rep(y, h)
        rep(x, w) {
            cin >> board[y][x];
        }

    set<int> delete_x;
    set<int> delete_y;

    rep(y, h) {
        bool white = [&] {
            rep(x, w) {
                if (board[y][x] == '#') {
                    return false;
                }
            }
            return true;
        }();
        if (white) {
            delete_y.insert(y);
        }
    }

    rep(x, w) {
        bool white = [&] {
            rep(y, h) {
                if (board[y][x] == '#') {
                    return false;
                }
            }
            return true;
        }();
        if (white) {
            delete_x.insert(x);
        }
    }


    rep(y, h) {
        if (delete_y.find(y) != delete_y.end()) continue;
        rep(x, w) {
            if (delete_x.find(x) != delete_x.end()) continue;
            cout << board[y][x];
        }
        cout << endl;
    }

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int count =0;
		for (int i=0;i<N;i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			count +=r-l+1;
		}
		System.out.println(count);
	}

	public class People implements Comparable<People> {
		int a;
		int b;
		@Override
		public int compareTo(People o) {
			return this.a - o.a;
		}

	}
}

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

ll N;
ll A[21],B[20],C[20];
ll ans=0;

int main(void){
    A[20] =0;
    cin >> N;
    rep(i,N)cin >> A[i];
    rep(i,N)cin >> B[i];
    rep(i,N-1)cin >> C[i];
    rep(i,N){
        ans += B[A[i]-1];
        if(A[i]+1 == A[i+1]) ans +=C[A[i]-1];
    }
    
    cout << ans << endl;


    
}


Measured memory_bytes: 256
d, g = [int(x) for x in input().split()]
g //= 100
problems = {}
max = 0
for i in range(d):
  # num + comp
  problems[i + 1] = [int(x) for x in input().split()]
  max += problems[i + 1][0]

dp = {} # pt -> problem count
dp[0] = 0
for (point, p) in problems.items():
  tmp = list(dp.items())
  num = p[0]
  bonus = p[1] // 100
  for i in range(0, num):
    i += 1
    pt = point * i
    if i == num:
      pt += bonus
    for (k, v) in tmp:
      idx = k + pt
      if idx in dp:
        if dp[idx] > v + i:
          dp[idx] = v + i
      else:
        dp[idx] = v + i

ans = max
for i in dp:
  if i >= g:
    if ans > dp[i]:
      ans = dp[i]

print(ans)


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&a!=c){
    cout<<"Yes"<<endl;
  }
  else if(a==c&&b!=c){
    cout<<"Yes"<<endl;
  }
  else if(b==c&&a!=b){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

Measured memory_bytes: 256
import sys
def rec(N,dp,i,j,k):
    if dp[i][j][k]>=0.0:return dp[i][j][k]
    if all([i==0,j==0,k==0]):return 0.0
    res=0.0
    if i>0:res+=rec(N,dp,i-1,j,k)*i
    if j>0:res+=rec(N,dp,i+1,j-1,k)*j
    if k>0:res+=rec(N,dp,i,j+1,k-1)*k
    res=(res+N)*1.0/(i+j+k)
    dp[i][j][k]=res
    return dp[i][j][k]
def main():
    N=int(sys.stdin.readline())
    a=tuple(map(int,sys.stdin.readline().split()))
    n1,n2,n3=a.count(1),a.count(2),a.count(3)
    dp=[[[-1.0 for _ in range(n3+1)] for _ in range(n2+n3+1)] for _ in range(n1+n2+n3+1)]
    print(rec(N,dp,n1,n2,n3))
if __name__=='__main__':main()


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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  return __gcd(a,b);
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  
  VI C(N-1), S(N-1), F(N-1);
  
  REP(i,N-1){
    cin >> C.at(i) >> S.at(i) >> F.at(i);
  }
  
  
  REP(i,N){
    int t = 0;
    FOR(j,i,N-1){
      
      if(t <= S.at(j)){
        t = S.at(j) + C.at(j);
      }
      else if(t % F.at(j) == 0){
        t += C.at(j);
      }else{
        t += F.at(j) - t % F.at(j) + C.at(j);
      }
      
    }
    cout << t << endl;
  }
  
  
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

n=input().rstrip()
if n[0]==n[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int n;
char s[1010];
bool hv[4];
int main () {
	scanf ("%s", s + 1);
	n = strlen (s + 1);
	for (int i = 1; i <= n; i++) {
		if (s[i] == 'N') hv[0] = true;
		if (s[i] == 'W') hv[1] = true;
		if (s[i] == 'S') hv[2] = true;
		if (s[i] == 'E') hv[3] = true;
	}
	if (hv[0] == hv[2] && hv[1] == hv[3]) printf ("Yes\n");
	else printf ("No\n");
	return 0;
}

Measured memory_bytes: 256
solve :: Int -> Int
solve x = (d * 2) + r
  where
    (d,m) = x `divMod` 11
    r = case m of
          _ | m == 0 -> 0
            | m <= 6 -> 1
            | m >  6 -> 2

main :: IO ()
main = do
    x <- readLn :: IO Int
    print $ solve x

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

int main() {
    int n, k, r, s, p;
    string t;
    vector<string> g(101010);
    cin >> n >> k >> r >> s >> p >> t;
    rep(i, n) g[i % k] += t[i];
    int ans = 0;
    rep(i, k) {
        int m = g[i].size();
        vector<vector<int>> dp(m, vector<int>(3, 0));
        if (g[i][0] == 'r') dp[0][2] = p;
        if (g[i][0] == 's') dp[0][0] = r;
        if (g[i][0] == 'p') dp[0][1] = s;

        for (int j=1;j<m;++j) {
            dp[j][2] = max(dp[j-1][0], dp[j-1][1]);
            dp[j][0] = max(dp[j-1][1], dp[j-1][2]);
            dp[j][1] = max(dp[j-1][2], dp[j-1][0]);

            if (g[i][j] == 'r') dp[j][2] += p;
            if (g[i][j] == 's') dp[j][0] += r;
            if (g[i][j] == 'p') dp[j][1] += s;
        }
        int h = max(dp[m-1][0], dp[m-1][1]);
        h = max(h, dp[m-1][2]); 
        ans += h;
    }
    cout << ans << endl;
}


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

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

    ll ng = 0, r = 0, g = 0, b = 0;
    rep(i, n) {
        s[i] == 'R' ? r++ : s[i] == 'G' ? g++ : b++;
        for (int j = i + 1; j < n - 1; j++) {
            int k = 2 * j - i;
            if (k >= n) break;
            if (s[i] != s[j] && s[i] != s[k] && s[j] != s[k]) ng++;
        }
    }

    cout << r * g * b - ng << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<cstring>
#include<queue>
#include<algorithm>
#include <map>

using namespace std;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define reep(i, s, t) for(int i=s;i<(int)t;i++)
#define irep(i, n) for(int i=(int)n-1;i>=0;i--)
#define ireep(i, n, s) for(int i=(int)n-1;i>=s;i--)
#define all(v) v.begin(), v.end()
#define vc vector
#define pb push_back

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

struct Edge
{
	int to, from;
	int cost;

	Edge( int to, int from, int cost ) :to(to), from(from), cost(cost)
	{}

	friend bool operator < ( const Edge& e1, const Edge& e2 )
	{
		return e1.cost < e2.cost;
	}
};

int root[200];
int Get_root ( int x )
{
	if( root[x] == x ){
		return x;
	}
	return root[x] = Get_root(root[x]);
}

void add ( int x, int y )
{
	x = Get_root(x); y = Get_root(y);
	if( x != y ){
		root[y] = x;
	}
}

int kruskal ( vi node, vector<Edge> e)
{
	sort(all(e));

	int ret = 0;
	rep(i,e.size()){
		bool flag = true;
		rep(j, node.size()){
			if( node[j] == e[i].to ){
				flag = false;
				break;
			}
		}
		if( flag ){
			continue;
		}

		flag = true;
		rep(j, node.size()){
			if( node[j] == e[i].from ){
				flag = false;
				break;
			}
		}
		if( flag ){
			continue;
		}
		
		if( Get_root(e[i].to) != Get_root(e[i].from) ){
			ret += e[i].cost;
			add(e[i].to, e[i].from);
		}
	}
	rep(i, (int)node.size()-1){
		if(Get_root(node[i]) != Get_root(node[i+1])) return -(1<<30);
	}
	return ret;
}

int main(){
	int N, M;
	while( cin >> N >> M, N != 0 ){
		map<int, vi> nodes;
		vector<Edge> e;

		rep(i, N){
			root[i] = i;
		}

		rep(i, N){
			int h;
			cin >> h;
			nodes[-h].pb(i);
		}

		rep(i, M){
			int a, b, c;
			cin >> a >> b >> c;
			--a; --b;
			e.pb( Edge(a, b, c) );
		}

		int ans = 0;
		vi cur_node;
		map<int, vi>::iterator itr = nodes.begin();
		while( itr != nodes.end() ){
			rep(i, itr->second.size()){
				cur_node.pb( itr->second[i] );
			}
			ans += kruskal(cur_node, e);
			if(ans < 0){
				ans = 0;
				rep(i, N) root[i] = i;
			}
			// cout << ans << endl;
			++itr;
		}

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

Measured memory_bytes: 1820
import numpy as np
n, m, q = map(int, input().split())
lst = [[0]*(n+1) for _ in range(n+1)]
for i in range(m):
    l, r = map(int, input().split())
    lst[l][r] += 1
lst = np.array(lst)
for i in range(1, n+1):
    lst[:, i] += lst[:, i-1]
for j in range(1, n+1):
    lst[j, :] += lst[j-1, :]
for i in range(q):
    p, q = map(int, input().split())
    print(lst[q, q] - lst[p-1, q] - lst[q, p-1] + lst[p-1, p-1])

Measured memory_bytes: 21688
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
namespace AtCoder {
    class MainClass {
        public static void Main(string[] args) { new MainClass().solve(); }

        Scanner cin = new Scanner();

        long a, b, c;
        void solve() {
            a = cin.nextLong();
            b = cin.nextLong();
            c = cin.nextLong();

            long ans = (a!=0)?b/c-(a-1)/c:b/c+1;



            Console.WriteLine(ans);

        }
        class Scanner {
            string[] nextBuffer; int BufferCnt; char[] cs = new char[] { ' ' };
            public Scanner() { nextBuffer = new string[0]; BufferCnt = 0; }
            public string next() {
                if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
                string st = Console.ReadLine();
                while (st == "") st = Console.ReadLine();
                nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
                BufferCnt = 0;
                return nextBuffer[BufferCnt++];
            }
            public int nextInt() { return int.Parse(next()); }
            public long nextLong() { return long.Parse(next()); }
            public double nextDouble() { return double.Parse(next()); }
        }

        class Mathf {
            public int mod = 1000000007;//10^9+7
            public long Pow(long a, long b) {
                if (b == 0) return 1;
                if (b % 2 == 1) return (a % mod * Pow(a % mod, b - 1) % mod) % mod;
                else return Pow(a * a % mod, b / 2) % mod;
            }
            public long Fact(long n) { return n != 0 ? (n % mod * (Fact(n - 1) % mod) % mod) : 1; }
            public long C(long n, long r) {
                if (r == 0 || n == r) return 1;
                else return (Fact(n) % mod * Pow((Fact(n - r) % mod * Fact(r) % mod) % mod, mod - 2) % mod) % mod;
            }
            public int GCD(int a, int b) { if (a < b) Swap(ref a, ref b); return b == 0 ? a : GCD(b, a % b); }
            public int GCD(int[] array) { return array.Aggregate((v, next) => GCD(v, next)); }
            public void Swap<T>(ref T a, ref T b) { T tmp = a; a = b; b = tmp; }
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
using namespace std;
int main(){
    int n;
    cin >> n;
    
    int num[n];
    for(int i=0;i<n;i++){
        cin >> num[i];
        
    }
    for(int j=0;j<n/2;j++){
        int t =num[j];
        num[j]=num[n-j-1];
        num[n-j-1]=t;
    }
    for(int l=0;l<n;l++){
        if(l>0){
            cout << " ";
            
        }cout <<num[l];
    }cout << endl;
}


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

template <typename T>
T set_oparate(T &sorted_a, T &sorted_b, char op) {
#define abc(a, b, c) begin(a), end(a), begin(b), end(b), inserter(c, end(c))
    T ret;
    switch (op) {
    case 'u':   // 和集合（A ∪ B）
        set_union(abc(sorted_a, sorted_b, ret)); break;
    case 'i':   // 積集合（A ∩ B）
        set_intersection(abc(sorted_a, sorted_b, ret)); break;
    case 'd':   // 差集合（A \ B, A ∩ B^c）
        set_difference(abc(sorted_a, sorted_b, ret)); break;
    case 's':   // 対称差（A Δ B, (A\B) ∪ (B\A)）
        set_symmetric_difference(abc(sorted_a, sorted_b, ret)); break;
    }
    return ret;
#undef abc
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (int &ai: a) cin >> ai;
    int m; cin >> m;
    vector<int> b(m);
    for (int &bi: b) cin >> bi;
    for (int x: set_oparate(a, b, 'i')) cout << x << endl;
    return 0;
}


Measured memory_bytes: 4820
#include <iostream>
#include <string>

using namespace std;

typedef long long ll;

ll f[5], res;
ll n, m, a, r, c, h;
int f1[] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2};
int f2[] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3};
int f3[] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4};

int main()
{
	string s;

	cin >> n;

	for (int i = 0; i < n; ++i)
	{
		cin >> s;
		if (s[0] == 'M') ++m;
		if (s[0] == 'A') ++a;
		if (s[0] == 'R') ++r;
		if (s[0] == 'C') ++c;
		if (s[0] == 'H') ++h;
	}

	f[0] = m; f[1] = a; f[2] = r; f[3] = c; f[4] = h;

	for (int i = 0; i < 10; ++i)
		res += f[f1[i]] * f[f2[i]] * f[f3[i]];

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main() {
	int N, D, X, A[100], i, a = 0, b = 0;
	scanf("%d", &N);
	scanf("%d %d", &D, &X);
	for (i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (i = 0; i < N; i++) {
		if (D%A[i] == 0) {
			a = D / A[i];
			b = b + a;
		}
		else {
			a = D / A[i] + 1;
			b = b + a;
		}
	}
	b = b + X;
	printf("%d", b);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll      long long
#define pii     pair<int, int>
#define f       first
#define s       second
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d ", a)
#define pfl(a) printf("%lld\n", a)
#define Case(a) printf("Case %d: ", a)

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

    int a[n];
    ll tot = 0;
    for(int i=0;i<n;i++){
        cin>>a[i];
        tot += a[i];
    }
    sort(a, a+n, greater<int>());
//    for(int i=0;i<n;i++){
//        cout<<a[i]<<" ";
//        tot += a[i];
//    }
    if(a[m-1]*4*m < tot){
        cout<<"No\n";
    }
    else
        cout<<"Yes\n";
}



Measured memory_bytes: 256
a, b = gets.split(" ").map(&:to_i)
result = 0.to_f

(1..a).each do |i|
  if i >= b
    result += 1.fdiv(a)
  else
    num = Math.log(b.fdiv(i), 2).ceil
    result += (0.5 ** num) * 1.fdiv(a)
  end
end

puts result

Measured memory_bytes: 3836
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >> s;
    string temp = s;
    reverse(s.begin(), s.end());
    if(s == temp) printf("Yes");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
# 入力が10**5とかになったときに100ms程度早い
import sys
read = sys.stdin.readline


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_matrix(H):
    '''
    H is number of rows
    '''
    return [list(map(int, read().split())) for _ in range(H)]


def read_map(H):
    '''
    H is number of rows
    文字列で与えられた盤面を読み取る用
    '''
    return [read()[:-1] for _ in range(H)]


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H, n_cols):
    '''
    H is number of rows
    n_cols is number of cols

    A列、B列が与えられるようなとき
    '''
    ret = [[] for _ in range(n_cols)]
    for _ in range(H):
        tmp = list(map(int, read().split()))
        for col in range(n_cols):
            ret[col].append(tmp[col])

    return ret


N, K = read_ints()

ans = ''
a = N
while a >= K:
    a, b = divmod(a, K)
    ans += str(b)

print(len(ans[::-1]) + 1)


Measured memory_bytes: 38256
s = input()
f = []
c = []
for i in range(len(s)):
    if s[i] == "F":
        f.append(i)
    elif s[i] == "C":
        c.append(i)
if f and c and (max(f)-min(c) > 0):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
///In the name of ALLAH

#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;
 
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define endl '\n'
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define mx_int_prime 999999937
 
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007
 
#define mem(a,b) memset(a, b, sizeof(a) )
#define gcd(a,b) __gcd(a,b)
#define sqr(a) ((a) * (a))
 
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


const int mx = 1e5+123;

int dp[mx][4], n;
int h[mx][4];

int solve ( int i, int f1 )
{
  if ( i > n ) return 0;
  if ( dp[i][f1] != -1 ) return dp[i][f1];

  int ret = 0;
  for ( int j = 1; j <= 3; j++ ) {
    if ( j != f1 ) {
      ret = max ( ret, h[i][j] + solve ( i+1, j ) );
    }
  }

  return dp[i][f1] = ret;

}

int main()
{
  optimize();

  cin >> n;
  for ( int i = 1; i <= n; i++ ) {
    cin >> h[i][1] >> h[i][2] >> h[i][3];
  }

  memset ( dp, -1, sizeof(dp) );
  cout << solve ( 1, 0 ) << endl;

  return 0;
}

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

#define sc second
#define fr first
#define mk make_pair
#define pb push_back
#define int long long

using namespace std;

const int N = (1e6 + 5);
const int inf = (1e9 + 7);

main () {
    int a,b;
    cin >> a >> b;
    cout << 6 - a - b << endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int num = 0;
  int ans = 0;
  for(int i = 0; i < n; i++) {
    if(s.at(i) == 'W') {
      num++;
    }
  }
  for(int i = 0; i < num; i++) {
    if(s.at(n-1-i) == 'R') {
      ans++;
    }
  }
  cout << ans;
}

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

//QUEENは、縦、横にバッティングすることはない→0~7でできる順列に従って、上の列から対応する行にQUEENを配置する方法しか候補はない
int main() {
  int k;
  
  cin >> k ;

  vector<int> r(k);//縦の座標(左上基準)
  vector<int> c(k);//横の座標

  rep(i,k) cin >> r.at(i) >> c.at(i) ;//入力終了

  vector<int> order(8);//初期順列の作成
  rep(i,8) order.at(i)=i;//iとすることで、0~8で初期化

  do{
    vector<vector<bool>> queen(8,vector<bool>(8,false));//queenを置いた位置
    rep(i,8){
      queen.at(i).at(order.at(i))=true;      
    }//queenを配置

    bool bad_condition=false;//入力にそぐわない場合

    rep(i,k){
      int Y=r.at(i),X=c.at(i);
      if(!queen.at(Y).at(X)) bad_condition=true;
    }//queenが入力された位置にいるか確認

    if(bad_condition) continue;//入力に合わないものはボツ

    bool slant=false;//斜めにほかのコマがいないかどうか
    //ナナメのバッティングを確認
    rep(i,8){
      for(int j=1;j<=7;j++){
        int k=order.at(i);
        int O=i-j,U=i+j,L=k-j,R=k+j;
        if(O>=0){//上側
          if(L>=0){//左上側
            if(queen.at(O).at(L)) slant=true;
          }
          if(R<=7){//右上側
            if(queen.at(O).at(R)) slant=true;
          }
        }

        if(U<=7){//下側
          if(L>=0){//左下側
            if(queen.at(U).at(L)) slant=true;
          }
          if(R<=7){//右下側
            if(queen.at(U).at(R)) slant=true;
          }          
        }
      }
    }

    if(slant) continue;//斜めのバッティングがあるものはボツ

      rep(i,8){
        rep(j,8){
          if(queen.at(i).at(j)) cout << 'Q';
          else cout << '.';
        }
        cout << endl;
      }
    

  }while(next_permutation(all(order)));
  
  return 0;
}


Measured memory_bytes: 3136
# coding: utf-8
# Your code here!

n = int(input())

binary_heap = [int(i) for i in input().split()]
binary_heap = [0]+binary_heap

for i in range(1, n+1):
    s = 'node {}: key = {}, '.format(i, binary_heap[i])
    if i > 1:
        s += 'parent key = {}, '.format(binary_heap[i//2])
    if i * 2 <= n:
        s += 'left key = {}, '.format(binary_heap[i*2])
    if i * 2 + 1 <= n:
        s += 'right key = {}, '.format(binary_heap[i*2+1])

    print(s)




Measured memory_bytes: 5628
n,m,l=map(int,input().split())
a=[list(map(int,input().split()))for _ in[0]*n]
b=[list(map(int,input().split()))for _ in[0]*m]
for x in[[sum([s*t for s,t in zip(c,l)])for l in zip(*b)]for c in a]:print(*x)


Measured memory_bytes: 6992
#include<bits/stdc++.h>
#define ll long long
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(i, n) for(int i=0; i<=n; i++)
#define repr(i, n) for(int i=n; i>0; i--)
#define REPR(i, n) for(int i=n; i>=0; i--)
const ll INF = 1e18;
const int INT_INF = 1e9;
const ll MOD = 1e9+7;
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; }
using namespace std;

ll A, B;

int main() {
    cin >> A >> B;
    if ((A + B) % 2 == 0) {
        cout << (A + B) / 2 << endl;
    } else {
        cout << "IMPOSSIBLE" << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=1005;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll a,b,c,d;cin>>a>>b>>c>>d;
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d) )cout<<"Yes";
    else cout<<"No";
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = 1e9 + 7;
const ll INF = 1e9;
int main() {
	cin.sync_with_stdio(false);
	string S;
	cin >> S;
	rep(i, S.size() - 1) {
		if (S[i] == 'A'&&S[i + 1] == 'C') {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

using namespace std;

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

const uint64_t UNREACHABLE = static_cast<uint64_t>(-1);

struct QueueItem
{
  uint64_t x, y, d;

  QueueItem(uint64_t x, uint64_t y, uint64_t d) : x(x), y(y), d(d) {}
};

int search(
  uint64_t H, uint64_t W,
  const vector<string> &S,
  vector<vector<uint64_t>> &dist,
  uint64_t x, uint64_t y
)
{
  queue<QueueItem> q;
  dist[y][x] = 0;
  q.emplace(x, y, 0);
  
  while (!q.empty()) {
    QueueItem item = q.front(); q.pop();
    
    int dy[4] = {+1, -1, 0, 0}, dx[4] = {0, 0, +1, -1};
    N_TIMES(dir, 4) {
      uint64_t nx = item.x + dx[dir], ny = item.y + dy[dir];
      uint64_t nd = item.d + 1;
      
      if (nx < W && ny < H && S[ny][nx] == '.') {
        if (dist[ny][nx] > nd) {
          dist[ny][nx] = nd;
          q.emplace(nx, ny, nd);
        }
      }
    }
  }
  
  return 0;
}

pair<uint64_t, uint64_t> max_postition(
  uint64_t H, uint64_t W,
  const vector<vector<uint64_t>> &dist
)
{
  uint64_t max_dist = 0;
  pair<uint64_t, uint64_t> max_pos = make_pair(UNREACHABLE, UNREACHABLE);

  N_TIMES(h, H) {
    N_TIMES(w, W) {
      if (dist[h][w] == UNREACHABLE) { continue; }
      
      if (dist[h][w] >= max_dist) {
        max_dist = dist[h][w];
        max_pos = make_pair(w, h);
      }
    }
  }

  return max_pos;
}

int main()
{
  uint64_t H, W;
  cin >> H >> W;
  
  vector<string> S(H);
  N_TIMES(h, H) {
    cin >> S[h];
  }
  
  uint64_t max_dist = 0;
  
  N_TIMES(sy, H) {
    N_TIMES(sx, W) {
      if (S[sy][sx] != '.') { continue; }
      
      vector<vector<uint64_t>> dist(H);
      N_TIMES(h, H) {
        dist[h] = vector<uint64_t>(W, UNREACHABLE);
      }
      
      search(H, W, S, dist, sx, sy);
      
      pair<uint64_t, uint64_t> p = max_postition(H, W, dist);
      
      max_dist = max(max_dist, dist[p.second][p.first]);
    }
  }
  
  cout << max_dist << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
const int N = 100005, P = 1000000007;
int pw3[N];
char L[N];
int main()
{
	scanf("%s", L + 1);
	int N = strlen(L + 1), pre = 1, ans = 0;
	for (int i = pw3[0] = 1; i <= N; ++i)
		pw3[i] = pw3[i - 1] * 3LL % P;
	for (int i = 1; i <= N; ++i)
		if (L[i] == '1')
		{
			ans = (ans + 1LL * pre * pw3[N - i]) % P;
			pre = pre * 2 % P;
		}
	ans = (ans + pre) % P;
	printf("%d\n", ans);
	return 0;
}


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

using namespace std;
typedef long long ll;

int main()
{
    string S;
    cin >> S;
    string ymd;
    ymd = S.substr(0, 4) + S.substr(5, 2) + S.substr(8, 2);
    int int_ymd;
    int_ymd = atoi(ymd.c_str());
    if (int_ymd <= 20190430)
    {
        cout << "Heisei";
    }
    else
    {
        cout << "TBD";
    }
    // system("pause");
}

Measured memory_bytes: 256
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush,heapify
import math
from copy import deepcopy
import queue
#import sympy as syp(素因数分解とか)
Mod = 1000000007
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[y] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

def main():  #startline-------------------------------------------
    all = []

    def dfs(d, val):
        all.append(val)
        if d == 10:
            return
        for i in range(-1, 2):
            add = val % 10 + i
            if add >= 0 and add <= 9:
                dfs(d + 1, val * 10 + add)

    k = int(input())
    for i in range(1, 10):
        dfs(1, i)
        
    all.sort()
    print(all[k-1])

if __name__ == "__main__":
    main() #endline===============================================

Measured memory_bytes: 20076
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n + 1];
        for(int i = 0 ; i < n + 1; i++) {
            a[i] = sc.nextInt();
        }
        int[] b = new int[n];
        for(int i = 0 ; i < n; i++) {
            b[i] = sc.nextInt();
        }
        long c = 0;
        for(int i = 0 ; i < n; i++) {
            int k0 = Integer.min(a[i], b[i]);
            c += k0;
            a[i] -= k0;
            b[i] -= k0;
            int k1 = Integer.min(a[i + 1], b[i]);
            c += k1;
            a[i + 1] -= k1;
            b[i] -= k1;
        }
        System.out.println(c);
    }
}


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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;


ll sum(ll n) {
  ll m=0;
  FOR(i,0,12){
    m+=n%10;
    n/=10;
  }
  return m;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/


signed main() {
  ll n;
  	ci(n);
  ll t,x,y;
  bool a=true;
  ll nowx=0;
  ll nowy=0;
  ll nowt=0;
  FOR(i,0,n){
    ci(t>>x>>y);
    
    if((t-x-y)%2==0&&(t-nowt)>=(x-nowx+y-nowy)){
      nowx=x;
      nowy=y;
      continue;
    }
    else{
      co("No")
        a=false;
      break;
    }
  }
  if(a){
    co("Yes")
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  






void solve(){
	int a , b ;
	cin >> a >> b; 
	int n = 1e6+6;
	rep(i,0,n){
		if(8*i/100 ==a and 10*i/100 ==b){
			cout << i << endl;
			return;
		}
	}
	cout << -1 << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();













#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll MOD = 1000000007;
const double PI = acos(-1);
//or-> ||
#define DBG(a,b,c,d) cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	int H,W;
	cin>>H>>W;
	char s;
	int ans[H+2][W+2]={0};
	rep(i,1,H+1){
		rep(j,1,W+1){
			cin>>s;
			if(s=='#') ans[i][j]=1;
		}
	}
	rep(i,1,H+1){
		rep(j,1,W+1){
			if(ans[i][j]){
				if(ans[i-1][j]) continue;
				if(ans[i+1][j]) continue;
				if(ans[i][j-1]) continue;
				if(ans[i][j+1]) continue;
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


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

int main()
{
  std::vector<int> ns;
  std::vector<std::vector<int>> data;
  while(true){
    int n;
    std::cin>>n;
    if(n==0) break;
    std::vector<int> d(n);
    for (int i = 0; i < n; i++){
      std::cin>>d[i];
    }
    ns.push_back(n);
    data.push_back(d);
  }

  for (int loop = 0; loop < ns.size(); loop++){
    std::vector<std::vector<int>> dp(ns[loop]+3, std::vector<int>(ns[loop]+3, 0)); // dp[l][r] [l,r)で削除できるブロックの最大値
    const int n = ns[loop];
    const std::vector<int> d = data[loop];
    for (int w = 2; w <= n; w++){
      for (int l = 0; l < n; l++){
        const int r = l + w;
        if(r > n) continue;
        if(dp[l+1][r-1] == w-2 && std::abs(d[l] - d[r-1]) <= 1){
          dp[l][r] = w;
        }

        for (int mid = l+1; mid < r; mid++){
          dp[l][r] = std::max(dp[l][r], dp[l][mid] + dp[mid][r]);
        }
      }
    }
    std::cout << dp[0][n] << std::endl;
  }
}



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

int main() {
    ll A,B,C,K;
    cin>>A>>B>>C>>K;
    ll Ans=0;
    if(A>=K){
        Ans=K;
    }else if(A+B>=K&&K>A){
        Ans=A;
    }else {
        Ans=A-(K-A-B);
        
    }

    cout<<Ans<<endl;
}//cin忘れて時間食った反省しろ
//-1の処理ミスりすぎ

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define show(...) cerr << "[" << #__VA_ARGS__ << "] :", debug_out(__VA_ARGS__)
#else
#define show(...) 42
#endif

#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define two pair<int,int>
#define ll long long int
#define int long long int
#define mod(x,m) ((x%m+m)%m)
#define oo 1e15
#define all(v) v.begin(),v.end()
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define rep(a1,b1,c1) for(int a1=b1;a1<c1;a1++)
#define repb(a2,b2,c2) for(int a2=b2;a2>=c2;a2--)
#define speedforces std::ios::sync_with_stdio(false)
#define watch(x) cerr << (#x) << " is " << (x) << "\n"
#define input_from_file  freopen("input.txt", "r", stdin);
#define output_to_file  freopen("output.txt", "w", stdout);

int dp[3005][3005];

signed main(){
//input_from_file;
speedforces;
string s1,s2; cin>>s1>>s2;
int n = s1.size();
int m = s2.size();
memset(dp,0,sizeof dp);
rep(i,1,n+1) rep(j,1,m+1){
if(s1[i-1] == s2[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 = n , j = m;
while(i > 0 && j > 0){
  if(s1[i-1] == s2[j-1]) ans = s1[i-1]+ans , i-- , j--;
  else if(dp[i-1][j] == dp[i][j]) i--;
  else j--;
}
cout<<ans<<endl; 
}

Measured memory_bytes: 70784
#include <iostream>
#include <string>

using namespace std;
int main(){
  int n; cin >> n;
  string s; cin >> s;
  
  int nw = 0;
  for (int i=0; i<n; i++) if (s.at(i) == '.') nw++;
  int nwr=nw, nbl=0, r=nw;
  for (int i=0; i<n; i++) {
    if (s.at(i) == '.') nwr--;
    else nbl++;
    r = min(nwr+nbl, r);
  }
  cout << r << endl;
}


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

using namespace std;

#define all(v) (v).begin(), (v).end()

using li = long long;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    li Q, H, S, D, N;
    cin >> Q >> H >> S >> D >> N;
    
    H = min(H, 2 * Q);
    S = min(S, 2 * H);
    D = min(D, 2 * S);
    
    li answer = (N / 2) * D + (N % 2) * S;
    cout << answer << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

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

	int n, i, j, k, ans, MAXN = 10010;
	cin >> n;
	vector<int> a(n);
	for (i = 0; i < n; i++) cin >> a[i];
	vector<bool> valid(MAXN, false);
	valid[0] = true;
	for (i = 0; i < n; i++) {
		for (j = MAXN - a[i] - 1; j >= 0; j--) {
			if (valid[j]) valid[j + a[i]] = true;
		}
	}

	ans = 0;
	for (i = 0; i < MAXN; i++) {
		if ((valid[i]) && (i % 10 != 0)) ans = i;
	}
	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 888
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<vector>
#include<set>
const int MAXN=5e5+10;
const double eps=1e-8;
const int MOD=1000000007;
using namespace std;
typedef  long long ll;
int main()
{
    int L,R,ans=2019,l1,r1;
    cin>>L>>R;
    l1=L;
    r1=R;
    if(R-L>=2019)
        cout<<0<<endl;
    else
    {
        l1%=2019;
        r1%=2019;
        if(r1<=l1)
            r1+=2019;
        for(int i=l1;i<=r1;i++)
        {
            for(int j=i+1;j<=r1;j++)
            {
                ans=min(ans,i*j%2019);
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}



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

const int MAX = 1000000;
const int MOD = 1000000007;

signed main() {
 int h,w,n;
 cin>>h>>w>>n;
 int a[n],c[w];
 for(int i=0;i<n;i++)cin>>a[i];
 int k=0;
 for(int i=0;i<h;i++ ){
     if(i%2){
         for(int j=0;j<w;j++){
             if(a[k]==0)k++;
             c[j]=k+1;a[k]--;
         }
     }else{
          for(int j=w-1;j>=0;j--){
             if(a[k]==0)k++;
             c[j]=k+1;a[k]--;
         }
     }
     for(int j=0;j<w;j++)cout<<c[j]<<' ';
     cout<<endl;
 }

return 0;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()

using namespace std;

int A, B;

signed main()
{
	cin >> A >> B;
	if (A < 10 && B < 10)
		cout << (A * B) << endl;
	else
		cout << -1 << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll p,ll n){
   ll result=1;
   while(n!=0){
   if(n%2==0){
    n/=2;
    p*=p;
   }
   else{
    n--;
    result=result*p;
   }
   }
    return result;
}
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);

   ll n,t,a,b,c;
   ll mod =1e9+7;
   cin>>a;
   cout<<a+power(a,2)+power(a,3)<<endl;
}


Measured memory_bytes: 3584
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args){
	Scanner s = new Scanner(System.in);
	while(s.hasNext()){
		int cnt = s.nextInt();
		if(cnt==0)
			break;
		int[] times = new int[cnt];
		for(int i=0 ; i<cnt ; i++) {
			times[i] = s.nextInt();
		}
		Arrays.sort(times);
		System.out.println(solve(times));
	}
	}

	public static long solve(int[] times) {
		long sum = 0;
		long tmp = 0;
		for(int i=0 ; i<times.length ; i++) {
			tmp += times[i];
			sum += tmp;
		}
		return sum;
	}
}

Measured memory_bytes: 27764
n = int(input())

l = []
for i in range(n):
    tmp = list(input())
    tmp.sort()
    tmp = ''.join(tmp)
    l.append(tmp)

from collections import Counter
c = Counter(l)
num = tuple(c.values())

from math import factorial
def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))

ans = 0
for i in num:
    if i > 1:
        ans += combinations_count(i, 2)

print(ans)


Measured memory_bytes: 19888
#include <iostream>
#include <string>

int main(){
	int num;
	std::string english,dammy;
	std::cin >> num;
	std::getline(std::cin,dammy);
	for(int i=0;i<num;++i){
		std::getline(std::cin,english);
		while(english.find("Hoshino") != -1){
			size_t find = english.find("Hoshino");
			english.replace(find, 7, "Hoshina");
		}

		std::cout << english << std::endl;
	}
    return 0;
}


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


int main(){
  int n;
  cin >> n;
  map<int,int> mp;
  rep(i,n) {
    int a;
    cin >> a;
    mp[a]++;
  }
  int res = 0;
  for (auto e : mp) {
    if (e.second & 1) res++;
  }
  cout << res << endl;
  return 0;
} 

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

int main(){
    int n, suitn=4, numn=13;
    bool card[suitn][numn];
    cin >> n;
    for (int i=0; i<suitn; i++){
        for (int j=0; j<numn; j++){
            card[i][j]=false;
        }
    }
    for (int i=0; i<n; i++){
        char c;
        int suit, num;
        cin >> c >> num;
        if (c=='S') suit=0;
        else if (c=='H') suit=1;
        else if (c=='C') suit=2;
        else suit=3;
        card[suit][num-1]=true;
    }
    for (int i=0; i<suitn; i++){
        for (int j=0; j<numn; j++){
            if (!card[i][j]){
                if (i==0) cout << 'S';
                else if (i==1) cout << 'H';
                else if (i==2) cout << 'C';
                else cout << 'D';
                cout << ' ' << j+1 << endl;
            }
        }
    }
}


Measured memory_bytes: 3080
#include<stdio.h>
int main(void)
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(a>=b){
        if(a-b>=2) printf("%d",2*a-1);
        else printf("%d",a+b);
    }else{
        if(b-a>=2) printf("%d",2*b-1);
        else printf("%d",a+b);
    }
    return 0;
}


Measured memory_bytes: 128
from collections import defaultdict, deque

N = int(input())
adj_list = defaultdict(list)
E = []
V_number = [None]*N
for _ in range(N-1):
    a, b = map(int, input().split())
    E.append((a, b))
    adj_list[a].append(b)
    adj_list[b].append(a)
C = sorted(list(map(int, input().split())), reverse=True)
q = deque([1])
i = 0
while q:
    v = q.popleft()
    V_number[v-1] = C[i]
    i += 1
    for u in adj_list[v]:
        if V_number[u-1] is None:
            q.append(u)

print(sum(C[1:]))
print(*V_number)

Measured memory_bytes: 7496