akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		
		// 入出力高速化 java.io.* とthrows IOExceptionを忘れずに
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] inNM = br.readLine().split(" ");
		int N = Integer.parseInt(inNM[0]);
		int M = Integer.parseInt(inNM[1]);
		
		int[][] submit = new int[M][2];
		int[][] result = new int[N+1][3];
		
		for(int s=0; s<M; s++) {
			String[] inS = br.readLine().split(" ");
			submit[s][0] = Integer.parseInt(inS[0]);
			
			if(inS[1].contentEquals("AC")) {
				submit[s][1] = 1;
			}	
		}
		
		for(int m=0; m<M; m++) {
			if(submit[m][1] == 1) {
				result[submit[m][0]][1] = 1;
			}else {
				if(result[submit[m][0]][1] != 1) {
					result[submit[m][0]][2] ++;
				}
			}
		}
		
		int ac = 0;
		int wa = 0;
		
		for(int n=1; n<N+1; n++) {
			if(result[n][1] == 1) {
				ac += result[n][1]; 
				wa += result[n][2];
			}
		}
		
		System.out.println(ac+" "+wa);
	}
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

//-------------------------------------------------
//--Range Set Counter
//-------------------------------------------------
template<typename T>
class RangeSet
{
private:
    ::std::vector<int> v;
    ::std::unordered_map<T, int> Map;
    ::std::vector<::std::vector<int> > data;
    int kind;
public:
    RangeSet(const ::std::vector<T> &v_):v(v_.size()){
        int sz = v_.size(); kind = 0;
        for(int i=0;i<sz;i++){
            T t = v_[i];
            if (Map.count(t)){
                data[Map[t]].push_back(i);
            }else{
                Map[t] = kind++;
                data.push_back(::std::vector<int>());
                data.back().push_back(i);
            }
            v[i] = Map[t];
        }
    }
    //query for all elements
    int query(T x){
        if (!Map.count(x)) return 0;
        return data[Map[x]].size();
    }
    //query for [a, b]
    int query(int a, int b, T x){
        if (a>b) return 0;
        if (!Map.count(x)) return 0;
        int xi = Map[x];
        auto right = ::std::upper_bound(data[xi].begin(),data[xi].end(),b);
        auto left  = ::std::lower_bound(data[xi].begin(),data[xi].end(),a);
        return right-left;
    }
    //search x for [k, tail]
    int find(int k, T x){
        if (!Map.count(x)) return -1;
        int xi = Map[x];
        auto itr = ::std::lower_bound(data[xi].begin(),data[xi].end(),k);
        if (itr!=data[xi].end()){
            return *itr;
        }else{
            return -1;
        }
    }
    //update for one point
    void update(int k, T x){
        int ei = v[k];
        auto eitr = ::std::lower_bound(data[ei].begin(),data[ei].end(),k);
        data[ei].erase(eitr);
        v[k] = Map[x];
        if (Map.count(x)){
            int xi = Map[x];
            auto itr = ::std::lower_bound(data[xi].begin(),data[xi].end(),k);
            data[xi].insert(itr, k);
        }else{
            Map[x] = kind++;
            data.push_back(::std::vector<int>());
            data.back().push_back(k);
        }
    }
};

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    ll m; cin>>m;
    vll a(n);
    rep(i,n) cin>>a[i];
    rep(i,n) a[i]=a[i]%m;
    vll sum(n+1);
    rep(i,n) sum[i+1]=(sum[i]+a[i])%m;
    RangeSet<ll> rs(sum);
    ll ans=0;
    rep(i,n){
        ans+=rs.query(i+1,n,sum[i]);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 9024
Scanf.scanf "%d %d %d" (fun n x y ->
    let x = x - 1 in
    let y = y - 1 in
    let warp = y - x - 1 in
    let k = Array.make n 0 in
    for st = 0 to n - 2 do
        for en = st + 1 to n - 1 do
            let dist =
                if st <= x then (
                    if en <= x then en - st else
                    if en >= y then en - st -  warp else
                        min (en - st) ((y - warp - st) + (y - en))
                ) else if st >= y then en - st
                else (
                    if en >= y then
                        min (en - st) (1 + (st - x) + (en - y))
                    else
                        min (en - st) (1 + (st - x) + (y - en))
                )
            in
            k.(dist) <- k.(dist) + 1
        done
    done;
    for i = 1 to n - 1 do
        Printf.printf "%d\n" k.(i)
    done
)

Measured memory_bytes: 2432
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#define int long long

template <class T>
bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template <class T>
bool chmax(T &a, const T &b) {if (a < b){ a = b; return 1;} return 0;}
template <class T>
bool chmin(T &a, const T &b) {if (a > b){ a = b; return 1;}return 0;}
template <class T>
void printv(vector<T> v) {for (T t : v) {cout << t << " ";}cout << '\n';}

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

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

    int N, D;
    cin >> N >> D;

    vvi x;
    REP(i,N) {
        vi v(D);
        REP(j,D) cin >> v[j]; 
        x.emplace_back(v);
    }

    int ans = 0;
    REP(f,N) REP(s,N) {
        if (f == s) continue;

        double dist = 0;
        REP(d,D) dist += (x[f][d] - x[s][d])*(x[f][d] - x[s][d]);
        dist = sqrt(dist);

        double x = dist;
        double integral_part = 0;
        double fractional_part = modf(x, &integral_part);
        if (fractional_part == 0) {
            ans++;
            //cout << dist << endl;
        }
    }

    cout << ans/2 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long l,r,mini = 2019;
  cin >> l >> r;
  if(l == 0 || r - l >= 2019)cout << 0 << endl;
  else{
    for(long long i = l;i < r;i++){
      for(long long j = l + 1;j <= r;j++){
      mini = min(mini,(i * j) % 2019);
      }
    }
    cout << mini << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, a;
  a = 1;
  cin >> N;
  vector<int> vec(N);
  for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
  }
  sort (vec.begin(), vec.end());
  for (int j = 0; j < vec.size() - 1; j++) {
    if (vec.at(j) != vec.at(j + 1)) {
      a++;
    }
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <climits>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <functional>
#include <set>
#include <numeric>
#include <stack>
#include <utility>
#include <time.h>
#include <iterator>
//#include "util.h"

using namespace std;
typedef unsigned uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;

//呪文
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const pair<_KTy, _Ty>& m) { cout << "{" << m.first << ", " << m.second << "}"; return ostr; }
template <typename _KTy, typename _Ty> ostream& operator << (ostream& ostr, const map<_KTy, _Ty>& m) { if (m.empty()) { cout << "{ }"; return ostr; } cout << "{" << *m.begin(); for (auto itr = ++m.begin(); itr != m.end(); itr++) { cout << ", " << *itr; } cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const vector<_Ty>& v) { if (v.empty()) { cout << "{ }"; return ostr; }	cout << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _Ty> ostream& operator << (ostream& ostr, const set<_Ty>& s) { if (s.empty()) { cout << "{ }"; return ostr; } cout << "{" << *(s.begin()); for (auto itr = ++s.begin(); itr != s.end(); itr++) { cout << ", " << *itr; }	cout << "}"; return ostr; }
template <typename _KTy, typename _Ty> istream& operator >> (istream& istr, pair<_KTy, _Ty>& m) { cin >> m.first >> m.second; return istr; }
template <typename _Ty> istream& operator >> (istream& istr, vector<_Ty>& v) { for (size_t i = 0; i < v.size(); i++) cin >> v[i]; return istr; }
ll modpow(ll n, ll p, ll m) { ll result = 1; while (p > 0) { if (p & 1) result = (result * n) % m; p >>= 1; n = (n * n) % m; } return result; }
#define PI 3.14159265358979323846
#define EPS 1e-8
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(), (x).end()
#define fake false



int main() {
	string S;
	cin >> S;
	for (int i = 0; i < S.size(); i += 2) cout << S[i];
	cout << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using tiii = tuple<int,int,int>;
using vpii = vector<pii>;
using vpll = vector<pll>;

#define rep(i, n) for(int i=0;i<(int)n;i++)
#define rep2(i, s, n) for(int i=(s);i<(int)n;i++)
int INF=1e9+7;

vector<vpll> e;
int K;

void distance(int i,ll d,vl &dis) {
  dis[i]=d;
  rep(j,e[i].size()) {
    if(!dis[e[i][j].first]&&e[i][j].first!=K) distance(e[i][j].first,d+e[i][j].second,dis);
  }
}

int main() {
  int N;
  cin >> N;
  vi a(N-1),b(N-1),c(N-1);
  e=vector<vpll>(N);
  rep(i,N-1) {
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;b[i]--;
    pii x(b[i],c[i]),y(a[i],c[i]);
    e[a[i]].push_back(x);
    e[b[i]].push_back(y);
  }
  int Q;
  cin >> Q >> K;
  K--;
  vi x(Q),y(Q);
  rep(i,Q) {
    cin >> x[i] >> y[i];
    x[i]--;y[i]--;
  }
  
  vl dis(N);
  distance(K,0,dis);
  rep(i,Q) cout << dis[x[i]]+dis[y[i]] << endl;
}

Measured memory_bytes: 16256
import java.util.Scanner;

public class Main {
    static Scanner sc = new Scanner(System.in);


    public static void main(String[] args) {
        char[] arr = sc.next().toCharArray();
        int[] ans = new int[arr.length + 1];
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == '<') {
                ans[i + 1] = ans[i] + 1;
            }
        }
        for (int i = arr.length - 1; i >= 0; i--) {
            if (arr[i] == '>' && ans[i] <= ans[i + 1]) {
                ans[i] = Math.max(ans[i + 1] + 1, ans[i]);
            }
        }
        long sum = 0;
        for (int i = 0; i < ans.length; i++) {
            sum += ans[i];
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 30748
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define M 100005
#define P 1000000007

int Po[M],Pf[M];

int Fast(int x,int k){
	int res=1;
	while(k){
		if(k&1)res=1ll*res*x%P;
		x=1ll*x*x%P;
		k>>=1;
	}
	return res;
}

int C(int n,int m){
	if(n<m)return 0;
	if(m==n||m==0)return 1;
	return 1ll*Po[n]*Pf[m]%P*Pf[n-m]%P;
}

bool mark[M];
int p,A[M];
int n;

inline void Add(int &a,int b){
	a+=b;
	if(a>P)a-=P;
	else if(a<0)a+=P;
}

int main(){
	scanf("%d",&n);
	Po[0]=1;
	for(int i=1;i<=n+1;i++)Po[i]=1ll*Po[i-1]*i%P;
	for(int i=0;i<=n+1;i++)Pf[i]=Fast(Po[i],P-2);
	for(int i=1,x;i<=n+1;i++){
		scanf("%d",&x);
		if(mark[x]==true)p=x;
		mark[x]=true;
		A[i]=x;
	}
	int l=1,r=n+1;
	while(A[l]!=p)l++;
	while(A[r]!=p)r--;
	for(int i=1;i<=n+1;i++){
		int ans=0;
		Add(ans,C(n+1,i));
		Add(ans,-C(n+1-r+l-1,i-1));
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2432
use std::io;
use std::cmp;
use std::collections::VecDeque;


fn main() {
    let (h, w) = {
        let i = read::<usize>();
        (i[0], i[1])
    };
    let mut g = Vec::new();
    for _ in 0..h {
        let l = read_one::<String>().chars().collect::<Vec<_>>();
        g.push(l);
    }

    let mut ans = 0;
    if h == 1 && w == 1 { println!("0"); return; }
    for sy in 0..h { for sx in 0..w {
        if g[sy][sx] != '.' { continue; }
        let mut q = VecDeque::new();
        let mut done = vec![vec![false; w]; h];
        let mut cost = vec![vec![1_000_000_000; w]; h];
        let mut min = 1_000_000_000;
        done[sy][sx] = true;
        cost[sy][sx] = 0;
        q.push_back((sy, sx, 1));
        while let Some((y, x, c)) = q.pop_front() {
            let mut p = Vec::new();
            if y > 0 && g[y - 1][x] == '.' { p.push((y - 1, x)); }
            if y < h - 1 && g[y + 1][x] == '.' { p.push((y + 1, x)); }
            if x > 0 && g[y][x - 1] == '.' { p.push((y, x- 1)); }
            if x < w - 1 && g[y][x + 1] == '.' { p.push((y, x + 1)); }
            for (vy, vx) in p {
                if done[vy][vx] { continue; }
                done[vy][vx] = true;
                cost[vy][vx] = cmp::min(cost[vy][vx], c);
                q.push_back((vy, vx, c + 1));
            }
        }
        let mut ret = 0;
        for y in 0..h { for x in 0..w {
            if g[y][x] != '.' { continue; }
            ret = cmp::max(ret, cost[y][x]);
        }}
        ans = cmp::max(ans, ret);
    }}
    println!("{}", ans);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<cstdio>
#define DIF 5000
#define all(n) n.begin(),n.end()
using namespace std;

void draw(vector<vector<bool> >& graph,int sx,int sy,int ex,int ey)
{
  for(int i=sy;i<ey;i++)
    for(int j=sx;j<ex;j++)
      graph[i][j] = true;
}

int main()
{
  int n,NARI = 1;
  while(cin >> n,n)
    {      
      vector<double> X,Y,X1,X2,Y1,Y2;
      vector<vector<bool> > graph;
      graph.resize(210);

      for(int i=0;i<210;i++)
	{
	  graph[i].resize(210);
	  for(int j=0;j<210;j++)
	    graph[i][j] = false;
	}

      for(int i=0;i<n;i++)
	{
	  double x,y,r;
	  cin >> x >> y >> r;
	  X.push_back(x+r),X.push_back(x-r);
	  Y.push_back(y+r),Y.push_back(y-r);
	  X1.push_back(x-r),Y1.push_back(y-r);
	  X2.push_back(x+r),Y2.push_back(y+r);
	}

      sort(all(X));
      sort(all(Y));
      X.erase(unique(all(X)),X.end());
      Y.erase(unique(all(Y)),Y.end());

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

	  X1[i] = find(all(X),X1[i]) - X.begin();
	  Y1[i] = find(all(Y),Y1[i]) - Y.begin();

	  X2[i] = find(all(X),X2[i]) - X.begin();
	  Y2[i] = find(all(Y),Y2[i]) - Y.begin();

	}

      for(int i=0;i<n;i++)
	  draw(graph,X1[i],Y1[i],X2[i],Y2[i]);

      double ans = 0;
      for(int i=0;i<Y.size()-1;i++)
	for(int j=0;j<X.size()-1;j++)
	  if(graph[i][j])
	      ans += (X[j+1]-X[j])*(Y[i+1]-Y[i]);
	    
      cout << NARI++ << setiosflags(ios::fixed) << setprecision(2)<< " " << ans << endl;
      
    }
  return 0;
}

Measured memory_bytes: 1356
n = int(input())
s = list(input())
ans = 0
for i in range(n):
    l = list(set(s[:i]))
    r = list(set(s[i:]))
    cnt = 0
    for j in range(len(l)):
        if l[j] in r:
            cnt += 1
    ans = max(ans,cnt)
print(ans)


Measured memory_bytes: 3060
#include <cstdio>
#include <stdio.h>
#include <string>
#include <vector>
#include <functional>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main() {
    long long N, M;
    scanf("%lld %lld", &N, &M);

    long long ans = 0;
    if(N == 1 && M == 1) {    
        ans = 1;
    } else if (N == 1) {
        ans = M - 2;
    } else if (M == 1) {
        ans = N - 2;
    } else {
        ans = (N - 2) * (M - 2);
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 128
from math import floor,ceil,sqrt
import fractions
from collections import deque
import itertools
from collections import deque
import collections
import heapq
import json
N=int(input())
l=[0]*(N+1)
ma=0
ans=0
for i in range(1,N+1):
    ma=(N//i)*i
    ans=ans+(i+ma)*(N//i)//2
print(ans)


Measured memory_bytes: 155716
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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 = 1e9;
const LL LLINF = 1e16;

/*
!) 0-indexed
!) [a, b)に対する演算
!) merge, updateNodeを書く
*/
template<typename Monoid>
struct Segtree{
    int n;
    vector<Monoid> dat;
    Monoid m0; // データの初期化値
    Segtree(int sz, Monoid m0) : m0(m0){
        n = 1;
        while(n < sz) n *= 2;
        dat.assign(2*n-1, m0);
    }

    Monoid merge(Monoid a, Monoid b){ return a | b; }
    void updateNode(int k, Monoid x){ dat[k] = x; }

    void update(int k, Monoid x){
        k += n-1;
        updateNode(k, x);
        while(k > 0) {
            k = (k-1)/2;
            dat[k] = merge(dat[k*2+1], dat[k*2+2]);
        }
    }
    Monoid query(int a, int b){
        Monoid L = m0, R = m0;
        int A = a+n-1;
        int B = b+n-1;
        while(A < B) {
            if((A&1) == 0) L = merge(L, dat[A++]);
            if((B&1) == 0) R = merge(dat[--B], R);
            A >>= 1;
            B >>= 1;
        }
        return merge(L, R);
    }
    Monoid operator[](const int &k) const { return dat[k+n-1]; }
};

int main(){
    fastcin();
    int n;
    cin >> n;
    string s;
    cin >> s;
    Segtree<LL> seg(n, 0);
    rep(i, n){
        seg.update(i, (1<<(s[i]-'a')));
    }
    int q;
    cin >> q;
    rep(i, q){
        int tp;
        cin >> tp;
        if(tp == 1){
            int k;
            char c;
            cin >> k >> c;
            k--;
            seg.update(k, (1<<(c-'a')));
        }else{
            int l, r;
            cin >> l >> r;
            l--;
            cout << __builtin_popcount(seg.query(l, r)) << endl;
        }
    }

}

Measured memory_bytes: 9116
// ABEY SAALE
// QUESTION KHUD KR SOLUTION KYU DEKH RHA H
 
 
 
 
 
 
 
 
//MAAF KIJIYEGA ME GUSSE ME IDHAR UDHAR NIKAL JATA HU
#include<bits/stdc++.h>
#define mod 1000000007
#define fr first
#define se second
#define ll long long
#define PI 3.1415926535 
#define pb push_back
#define mpr make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define senky_bansal ios_base::sync_with_stdio(false);
#define IIIT_ALLAHABAD    cin.tie(NULL);cout.tie(NULL);
using namespace std;

ll fac[2000005];
void pre(){ fac[0]=1; fac[1]=1; for(int i=2;i<200005;i++) fac[i]=(i*fac[i-1])%mod;}
ll power(ll a,ll b){ll res=1;while(b){if(b&1) res=(res*a)%mod;a=(a*a)%mod;b=b/2;}return res%mod;}
ll ncr(ll n,ll r){return ((fac[n]*power(fac[r],mod-2))%mod*power(fac[n-r],mod-2))%mod;}
// DEKHIYE JI  WALID JO THE ABBA HAMARE WO YEH function CHHOD KR GYE THE

signed main()
{   


      
      senky_bansal
      IIIT_ALLAHABAD
      
      // pre();
      ll t;
      // cin>>t;
      t=1;
      while(t--)
      { 
         
          string a,b;
          cin>>a>>b;
          ll c1,c2;
          cin>>c1>>c2;
          string p;
          cin>>p;
          if(p==a)
          c1--;
          else if(p==b)
          c2--;
          cout<<c1<<" "<<c2;
         

      }
      






}



























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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n;
    cin >> n;
    string ans;
    if (n == 0) ans = "0";
    else {
        while (n != 0) {
            int n2 = n - abs(n) % 2;
            ans.pb((n-n2)+'0');
            n = n2 / -2;
        }
    }
    reverse(all(ans));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int n;
ll time10[10];
int main(){
	time10[0] = 1;
	rep(i, 9) {
		time10[i + 1] = time10[i] * 10;
	}
	while(cin >> n, n) {
		vector<ll> v[1 << 10];
		ll coef[10] = {};
		bool zerook[10];
		fill(zerook, zerook + 10, true);
		int alf[26];
		fill(alf, alf + 26, -1);
		int now = 0;
		rep(i, n) {
			string s; cin >> s;
			int len = s.length();
			rep(j, len) {
				int t = s[j] - 'A';
				if (alf[t]<0) {
					alf[t] = now; now++;
				}
				if (len > 1 && j == 0)zerook[alf[t]] = false;
				if (i < n - 1)coef[alf[t]] += time10[len - j - 1];
				else coef[alf[t]] -= time10[len - j - 1];
			}
		}
		int d1 = now / 2; int d2 = now - d1;
		rep(i, 1 << 10) {
			int cnt = 0;
			vector<int> u;
			rep(j, 10) {
				if (i&(1 << j)) {
					cnt++; u.push_back(j);
				}
			}
			if (cnt==d2){
				ll csum = 0; bool nonexi = false;
				rep(j, d2) {
					csum += u[j] * coef[d1+j];
					if (u[j] == 0 && !zerook[d1 + j])nonexi = true;
				}
				if (!nonexi)v[i].push_back(csum);
				while (next_permutation(u.begin(), u.end())) {
					csum = 0; nonexi = false;
					rep(j, d2) {
						csum += u[j] * coef[d1 + j];
						if (u[j] == 0 && !zerook[d1 + j])nonexi = true;
					}
					if (!nonexi)v[i].push_back(csum);
				}
			}
			sort(v[i].begin(), v[i].end());
		}
		ll out = 0;
		rep(i, 1 << 10) {
			int cnt = 0; vector<int> u;
			rep(j, 10) {
				if (i&(1 << j)) {
					cnt++; u.push_back(j);
				}
			}
			if (cnt != d1)continue;
			vector<ll> w;
			ll csum = 0; bool nonexi = false;
			rep(j, d1) {
				csum += u[j] * coef[j];
				if (u[j] == 0 && !zerook[j])nonexi = true;
			}
			if (!nonexi)w.push_back(csum);
			while (next_permutation(u.begin(), u.end())) {
				csum = 0; nonexi = false;
				rep(j, d1) {
					csum += u[j] * coef[j];
					if (u[j] == 0 && !zerook[j])nonexi = true;
				}
				if (!nonexi)w.push_back(csum);
			}
			int len2 = w.size();
			rep(j, 1 << 10) {
				int cnt2 = 0;
				rep(k, 10) {
					if (j&(1 << k)) {
						cnt2++;
					}
				}
				if (((i&j) == 0)&&cnt2==d2) {
					rep(k, len2) {
						out += upper_bound(v[j].begin(), v[j].end(), -w[k]) - v[j].begin();
						out -= lower_bound(v[j].begin(), v[j].end(), -w[k]) - v[j].begin();
					}
				}
			}
		}
		cout << out << endl;
	}
	return 0;
}


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

int main(){
  string s;
  cin >> s;
  if((s[6]-'0')<5 && (s[5]-'0')==0){
    cout << "Heisei" << endl;
  }else{
    cout << "TBD" << endl;
  }
}

Measured memory_bytes: 256
//code by lynmisakura.wish to be accepted!
/****************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

ll n;
vector<ll> a;
int main(void) {
	cin >> n;
	rep(i, n) {
		ll x; cin >> x;
		a.pb(x);
	}

	sort(all(a));
	vector<ll> p, m;
	p.pb(a[n - 1]);
	m.pb(a[0]);
	for (int i = 1; i < n - 1; i++)
	{
		if (a[i] < 0) m.pb(a[i]);
		else p.pb(a[i]);
	}

	vector<pair<ll, ll>> ans;
	int ps = p.size();
	int ms = m.size();
	for (int i = 0; i < ps - 1; i++) {
		ll x = *p.begin();
		p.erase(p.begin());
		ans.pb(mp(*m.begin(), x));
		*m.begin() -= x;
	}
	ll q = *p.begin();
	for (int i = 0; i < ms - 1; i++) {
		ll x = *m.begin();
		ans.pb(mp(q, x));
		m.erase(m.begin());
		q -= x;
	}
	cout << q - *m.begin() << endl;
	ans.pb(mp(q, *m.begin()));
	for (auto i : ans)
	{
		cout << i.first << " " << i.second << endl;
	}
	return 0;
}

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

int main(){
  
  int A,B; cin >> A >> B;
  
  if(A+B < 24){
    cout << A+B << endl;
  }
  
  else if(A+B >= 24){
	cout << (A+B) -24 << 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;

const long long INF = 1e9 + 7;

int main(){
  int n;
  cin >> n;
  
  long long power = 1;
  for(int i = 1; i <= n; i++){
    power = power * i;
    power %= INF;
  }
  
  cout << power << endl;
}

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


int main(void){
    int m, f, b; cin>>m>>f>>b;
    if(m + f < b){
        cout << "NA" << endl;
    }
    else if(m > b){
        cout << 0<< endl;
    }
    else{
        cout << b-m << endl;
    }
    return 0;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int sum(long long n) {
    int s = 0;
    while (n > 0) {
        s += n % 10;
        n /= 10;
    }
    return s;
}
long long pw[20];
int val[(int)1e6];
map < long long, int > pos;
bool cmp(long long i, long long j) {
    long long val1 = i * sum(j);
    long long val2 = j * sum(i);
    if (val1 != val2) return val1 < val2;
    return i < j;
}
bool good(long long i) {
    for (int j = 0; j <= 15; j++) {
        long long n = i + pw[j];
        if (i * sum(n) > n * sum(i)) {
            return false;
        }
    }
    return true;
}
int main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    pw[0] = 1;
    for (int i = 1; i <= 17; i++) pw[i] = 10 * pw[i - 1];
    int k;
    cin >> k;
    long long st = 1;
    for (int i = 1; i <= k; i++) {
        cout << st << endl;
        for (int j = 0; j <= 15; j++) {
            if (good(st + pw[j])) {
                st = st + pw[j];
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
R=range
def F(a,b):A=len(a);return[all([len(set([a[i+j],b[j],'?']))<3for j in R(min(A-i,len(b)))])for i in R(A)]+[1]
def Z(X):
 i,j,k=X;A,B,C=map(len,[S[t]for t in X]);q=1e5
 for l in R(A+1):
  if M[i][j][l]:
   for r in R(l,A+B+1):
    if(B<r-l or M[j][k][r-l])*M[i][k][min(A,r)]:q=min(q,max(A,l+B,r+C))
 return q
T=R(3)
S=[input()for i in T]
M=[[F(S[i],S[j])for j in T]for i in T]
from itertools import *;print(min([Z(i)for i in permutations(T)]))

Measured memory_bytes: 55292
n = int(input())
a = list(map(int, input().split()))
a.append(a[-1])
f = 0
ans = 1
for i in range(n-1):
    if f == 0:
        if a[i] == a[i+1]:
            f = 0
        elif a[i] < a[i+1]:
            f = 1
        else:
            f = 2
    elif f == 1:
        if a[i] <= a[i+1]:
            pass
        else:
            ans += 1
            f = 0
    elif f == 2:
        if a[i] >= a[i+1]:
            pass
        else:
            ans += 1
            f = 0

print(ans)

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

D = input().split()
x = D[0] == D[1]
D = input().split()
y = D[0] == D[1]

for i in range(N - 2):
  D = input().split()
  z = D[0] == D[1]
  if x and y and z:
    print('Yes')
    exit()
  else:
    x = y
    y = z
    
print('No')

Measured memory_bytes: 62104
n = int(input())
 
a = list(map(int,input().split()))
 
cumsum_a = a.copy()
 
for i in range(n-1, -1, -1):
    cumsum_a[i] += cumsum_a[i+1]
 
ans = 0
node = 1
 
for i in range(n + 1):
    if a[i] > node:
        ans = -1
        break
 
    ans += node
 
    if i < n:
        node = min(2 * (node - a[i]), cumsum_a[i + 1])
 
print(ans)

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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll inf = 1ll << 60;

int main(){
    int n, m, c;
    cin >> n >> m >> c;
    vector<int> b(m);
    rp(i, 0, m){
        int x;
        cin >> x;
        b.at(i) = x;
    }
    int ans = 0;
    rp(i, 0, n){
        int score = 0;
        rp(j, 0, m){
            int a;
            cin >> a;
            score += a*b.at(j);
        }
        if(score + c > 0) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int n,a;
	scanf("%d",&n);
	a=n%10;
	if(a==2||a==4||a==5||a==7||a==9)printf("hon\n");
	else if(a==0||a==1||a==6||a==8)printf("pon\n");
	else if(a==3)printf("bon\n");
	return 0;
}

Measured memory_bytes: 1628
#include <iostream>
using namespace std;
int main()
{
	int S;
	int h;
	int m;
	int s;
	cin >> S;
	h = S/3600;
	int amari = S%3600;
	m = amari/60;
	s = amari%60;
	cout << h << ':' << m << ':' << s << '\n';

	return 0;

}

Measured memory_bytes: 3108
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a % b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

///////////////////////////



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

	vector<mint> dp(N + 1, 0), rdp(N + 1, 0);
	dp[N] = N;
	rdp[N] = dp[N];

	for(ll i=N-1; i>=1; i--){
		dp[i] = dp[i + 1];

		if (i + 3 <= N) { dp[i] += rdp[i + 3]; }
		dp[i] += max(0, N - i - 2)*(N - 1);
		dp[i] += N * min(i + 1, N - 1);

		rdp[i] = rdp[i + 1] + dp[i];
	}

	cout << dp[1] << endl;

	
	
	system("PAUSE");
}


Measured memory_bytes: 16120
//list index out of rangeエラー表示用
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep1(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
  int h ,n;
  cin >> h >> n;
  int sum = 0;
  int tem;
  rep1(i, n){
    cin >> tem;
    sum += tem;
  }
  if(sum < h)cout << "No";
  else cout << "Yes";
}

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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;
long long INF = (1LL<<62);
typedef long long LL;

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

	LL Q, H, S, D;
	LL N;
	cin >> Q >> H >> S >> D;
	cin >> N;

	vector<LL> T;
	T.push_back(8*Q);
	T.push_back(4*H);
	T.push_back(2*S);
	T.push_back(D);
	int p = 0;
	LL m = INF;
	for(int i=0; i<T.size(); i++){
		if(T[i] < m){
			m = T[i];
			p = i;
		}
	}

	LL d = 1;
	LL u = 1;
	if(p == 0){ d = 8; u = Q; }
	else if(p == 1){ d = 4; u = H; }
	else if(p == 2){ d = 2; u = S; }
	else if(p == 3){ d = 1; u = D; }

	LL q = N/2;
	LL r = N%2;
	LL ans = (q*d) * u;
	if(r != 0){
		ans += min(S, min(2*H, 4*Q));
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 3700
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a, b, c;
        cin >> a >> b >> c;
        int ans = min({a, b, c});
        a -= ans; b -= ans; c -= ans;
        int ans2 = min(a/2, b);
        a -= ans2*2; b -= ans2;
        cout << ans+ans2+a/3 << "\n";
    }
    return 0;
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const ll INF=mod*mod;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
ll min(ll a,ll b){
  if(a>b){
    return b;
    }
      else{
        return a;
      }
  }
  
  ll max(ll a,ll b){
    if(a>b){
      return a;
    }
    else{
      return b;
    }
  }

ll power(ll a,ll b){
 ll ans=1;
 for(ll i=1;i<=b;i++){
ans*=a;
  }
  return ans;
}

 ll gcd(ll m,ll n){
 	if(n==0){
       return m;
     }
   return gcd(n,m%n);
 }
ll lcm(ll a,ll b){
  ll g=gcd(a,b);
  return a/gcd(a,b)*b;
		

}
int main(){
  
  ll X,Y,Z,K;
  cin>>X>>Y>>Z>>K;
  vector<ll>A(X);
  rep(i,X){
cin>>A[i];
  }
  vector<ll>B(Y);
  rep(i,Y){
    cin>>B[i];
  }
vector<ll>C(Z);
  rep(i,Z){
    cin>>C[i];
  }
sort(all(A),greater<ll>());
  sort(all(B),greater<ll>());
  sort(all(C),greater<ll>());//reverseがgreaterを使ってかける
  
  vector<ll> ans;
  
  rep(i,X){
    rep(j,Y){
rep(k,Z){
  if((i+1)*(j+1)*(k+1)>K){//i*j*kが最大で何回目かがわかる
break;
  }
  else{
ans.push_back(A[i]+B[j]+C[k]);
  }
}
    }
  }

  sort(all(ans),greater<ll>());

  rep(i,K){
    cout<<ans[i]<<endl;
  }
}


Measured memory_bytes: 1404
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

template <typename CLASS1, typename CLASS2>
class HOGE{
  public:
    CLASS1 key;
    CLASS2 value;
    HOGE(ll key, ll value){
      this->key = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "key : " << key << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;

void long_search(const string& s, const string& t, int st_start, vector<string>& dp1, vector<string>& dp2){

  //if(st_start+1 <= s.size() + t.size() + 2) long_search(s, t, st_start+1, dp1, dp2);
  
  for(st_start=s.size()+t.size(); st_start>=0; --st_start){

  int hight = min(st_start+1, (int)s.size());
  for(int s_start=max(0, st_start-(int)t.size()+1); s_start<hight; ++s_start){
    int t_start = st_start-s_start;

    if(s[s_start] == t[t_start]){
      dp2[s_start] = s[s_start] + dp2[s_start+1];
    }else{
      if(dp1[s_start].size() > dp1[s_start+1].size()){
        dp2[s_start] = dp1[s_start];
      }else{
        dp2[s_start] = dp1[s_start+1];
      }
    }
    swap(dp1[s_start], dp2[s_start]);
  }
  swap(dp1[hight], dp2[hight]);

  }

  return;
}

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  string s, t;
  cin >> s >> t;
  if(s.size() > t.size()) swap(s, t);
  vector<string> dp1(s.size()+2, "");
  vector<string> dp2(s.size()+2, "");
  long_search(s, t, 0, dp1, dp2);

  cout << dp1[0] << "\n";

  return 0;
}

Measured memory_bytes: 11264
#!/usr/bin/perl

$line = 0;
while(<>) {
    chomp;
    if($line == 0) {
        ($n, $m) = split /\s/, $_;
    } else {
        ($a, $b) = split /\s/, $_;
        $t->{$a}++;
        $t->{$b}++;
    }
    $line++;
}
 
foreach(1 .. $n) {
    if(defined $t->{$_}) {
        print "$t->{$_}\n";
    } else {
        print "0\n";
    }
}


Measured memory_bytes: 640
from collections import defaultdict
n, m = map(int, input().split())
a = list(map(int, input().split()))
b, c = [0] * m, [0] * m
data = defaultdict(int)
for i in range(m):
    b[i], c[i] = map(int, input().split())
    data[c[i]] += b[i]

for x in a:
    data[x] += 1
data = sorted(data.items(), key = lambda x: x[0])
i = len(data) - 1
cnt = 0
ans = 0
while 1:
    x = min(n - cnt, data[i][1])
    ans += x * data[i][0]
    i -= 1
    cnt += x
    if cnt == n:
        break
print(ans)


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

#define ll long long int

using namespace std;

int main(){
	
  ll a,v,b,w,t;
  cin>>a>>v>>b>>w>>t;
  
  if (a<b)
  {
	b = b + w*t;
    a = a + v*t;
    (a >= b)? cout<<"YES"<<endl : cout<<"NO"<<endl;
    return 0;
  }
  else if (a > b){
  	b = b - w*t;
    a = a - v*t;
      (a <= b) ? cout<<"YES"<<endl : cout<<"NO"<<endl;
    return 0;
  }
  else{
  	cout<<"YES"<<endl;
    return 0;
  }
  

	return 0;
}


Measured memory_bytes: 3616
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()
ans = []
r = 0
l = 0
for s in S:
    if s == "(":
        r += 1
    else:
        if r >= 1:
            # まだ減らせる分がある
            r -= 1
        else:
            l += 1
print(l * "(" + S + r * ")")

Measured memory_bytes: 5180
#include<cstdio>
#include<algorithm>
using namespace std;
int n,f[100000]={},ans=0,l;
long long a[100000],b[100000],suma=0,sumb=0,sa[100000];
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        suma+=a[i];
    }
    for(int i=0;i<n;i++){
        scanf("%lld",&b[i]);
        sumb+=b[i];
        sa[i]=a[i]-b[i];
    }
    if(suma<sumb){
        printf("-1\n");
    }
    else{
        sort(sa,sa+n);
        l=n-1;
        for(int i=0;i<n;i++){
            if(sa[i]>=0){
                break;
            }
            f[i]=1;
            while(sa[i]<0){
                if(sa[i]+sa[l]>=0){
                    sa[l]+=sa[i];
                    sa[i]=0;
                    f[l]=1;
                }
                else{
                    f[l]=1;
                    sa[i]+=sa[l];
                    l--;
                    f[l]=1;
                }
            }
        }
        for(int i=0;i<n;i++){
            ans+=f[i];
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 2816
using System;
using System.Collections.Generic;
using System.IO;

class MainClass
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        string line;
        int counter = 0;

        line = Console.ReadLine();
        string[] tokens = line.Split(' ');
        int[] ConvertedInt = new int[n];

        for (int i = 0; i < n; i++)
        {
            ConvertedInt[i] = int.Parse(tokens[i]);
        }

        int minj = 0;
        for (int i = 0;i < n;i ++)
        {
            minj = i;
            for (int j = i;j < n;j  ++)
            {
                if (ConvertedInt[minj] > ConvertedInt[j])
                {
                    minj = j;
                }
            }
            if(minj != i)
            {
                int temp = ConvertedInt[i];
                ConvertedInt[i] = ConvertedInt[minj];
                ConvertedInt[minj] = temp;
                counter++;
            }


        }

        for (int i = 0; i < n; i++)
        {
            Console.Write(ConvertedInt[i]);
            if(i != n - 1)
            Console.Write(" ");
        }
            Console.WriteLine();
            Console.WriteLine(counter);
    }
}





Measured memory_bytes: 15932
n, m = list(map(int, input().split()))
sc_list = [list(map(int, input().split())) for _ in range(m)]

result = [-1 for _ in range(n)]

for s, c in sc_list:
    if result[s-1] == -1:
        result[s-1] = c
    else:
        if result[s-1] == c:
            continue
        else:
            print(-1)
            exit()

if n > 1 and result[0] == 0:
    print(-1)
    exit()

for i, ele in enumerate(result):
    if i == 0 and ele == -1:
        if not n == 1:
            result[i] = 1
        else:
            result[i] = 0
    elif ele == -1:
        result[i] = 0
print(''.join([str(ele) for ele in result]))

Measured memory_bytes: 3064
from collections import deque

N = int(input())
button = [[i+1, int(input())] for i in range(N)]
button.insert(0, [0, 0])
cnt = 0
times = 0
q = deque([1])

while q:
    p = q.popleft()
    l = button[p][1]
    cnt += 1
    if l == 1:
        print(-1)
    elif l == 2:
        print(cnt)
    else:
        q.append(l)

    times += 1
    if times >= N:
        print(-1)
        exit()

Measured memory_bytes: 24484
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for (int i = (a); i < (b); i++)
#define N 123456

int ans, n, a[N], k;
vector<int> in[N];
set<int> cyc;
int go(int at) {
	int h = 0;
	for (int to : in[at]) if (to) h = max(h, go(to)+1);
	if (!at) return -1;
	if (h == k-1 && a[at] != 0) ans++, h = -1;
	return h;
}
int main() {
	scanf("%d %d", &n, &k);
	fo(i,0,n) scanf("%d", a+i), a[i]--, in[a[i]].push_back(i);
	if (a[0] != 0) ans++;
	go(0);
	printf("%d\n", ans);

	return 0;
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;
vector<ll> v;
ll N;
bool memo[2500][2500][2];
ll dp[2500][2500][2];
ll f(ll n,ll i,int z){
  if(memo[n][i][z]) return dp[n][i][z];
  memo[n][i][z]=true;
  if(i == N-1LL) return dp[n][i][z]=abs(v[N]-v[n]);
  if(i==0){
    ll ans = 0LL;
    for(ll j = i; j < N-1; j++){
      chmax(ans,f(j+1LL,j+1LL,1));
    }
    chmax(ans,abs(v[N]-v[n]));
    dp[n][i][z]=ans;
  }
  if(i==1){
    ll ans = INF;
    for(ll j = i; j < N-1LL; j++){
      chmin(ans,f(j+1LL,j+1LL,0));
    }
    chmin(ans,abs(v[N]-v[n]));
    dp[n][i][z]=ans;
  }
  return dp[n][i][z];
}

int main() {
  ll Z,W;
  cin>>N>>Z>>W;
  v.resize(N+1LL);
  v[0]=W;
  for(ll i = 0LL; i < N; i++) cin>>v[i+1];
  cout<<f(0,0LL,0)<<endl;
}

Measured memory_bytes: 14592
// https://atcoder.jp/contests/abc142/tasks/abc142_d

#include <bits/stdc++.h>
using namespace std;
#define watch(x) cerr << (#x) << " is " << (x) << endl;
#define endl '\n' 
#define int long long

set<int> factors(int n) {
    set<int> res;
    for(int i = 2; i*i <= n; i++) {
        while(n % i == 0) {
            res.emplace(i);
            n /= i;
            // watch(n)
        }
    }

    if(n != 1) {
        res.emplace(n);
    }

    return res;
}

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

    int A, B;
    cin >> A >> B;

    set<int> fa = factors(A), fb = factors(B);

    int ans = 0;
    for(int x: fa) {
        if(fb.count(x)) ans++;
    }

    ans++;

    cout << ans << endl;
}



Measured memory_bytes: 3644