akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<vector>
#include <algorithm>

using namespace std;
typedef long long ll;

int main() {
	int ans = 0;
	vector<int> v(3);
	vector<int> V(3);
	cin >> v[0] >> v[1] >> v[2];
	sort(v.begin(), v.end());
	for (int i = 0; i < 3; i++)V[i] = v[i] % 2;
	if (V[0] != V[1] && V[0] != V[2]){
		ans++;
		v[1]++;
		v[2]++;
	}
	if (V[1] != V[0] && V[1] != V[2]) {
		ans++;
		v[0]++;
		v[2]++;
	}
	if (V[2] != V[0] && V[2] != V[1]) {
		ans++;
		v[0]++;
		v[1]++;
	}
	ans += (v[2] - v[0]) / 2;
	ans += (v[2] - v[1]) / 2;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
int n,m,tot,now,ans,sum;
int a[N],b[N],c[N],f[N];
signed main(){
	scanf("%lld%lld",&n,&m);
	for (register int i=1; i<=n; ++i) scanf("%lld",&a[i]); 
	if (m<=n)
	{
		now=1;
		for (register int i=1; i<=m; ++i) now=a[now];
		printf("%lld\n",now);
		return 0;
	}
	
	m++;
	now=1;
	tot=1; f[1]=tot; b[tot]=1;
	while (true)
	{
		if (f[a[now]]) 
		{
			m-=f[a[now]]-1;
			for (register int i=1; i<=tot-f[a[now]]+1; ++i) c[i]=b[i+f[a[now]]-1];
			break;
		}
		tot++;
		f[a[now]]=tot;  b[tot]=a[now]; now=a[now];
	}
//	for (register int i=1; i<=tot-f[a[now]]+1; ++i) printf("%lld ",c[i]); puts("");
	sum=tot-f[a[now]]+1;
	if (m%sum==0) ans=sum; else ans=m%sum;
	printf("%lld\n",c[ans]);
return 0;	
}

Measured memory_bytes: 8972
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N, A, B;
        cin >> N >> A >> B;
        ll ans = N / (A+B) * A;
        ll tmp = N % (A+B);
        if (tmp >= A) ans += A;
        else ans += tmp;

        cout << ans << endl;
}

Measured memory_bytes: 3592
def resolve():
  N = int(input())
  C = [0 if x == "W" else 1 for x in list(input())]
  red_seacher_index = N - 1
  white_seacher_index = 0

  counter = 0
  while white_seacher_index <= red_seacher_index:
    if C[white_seacher_index] == 0:
      # 赤を Tail 側から探して見つけたら入れ替える
      while white_seacher_index <= red_seacher_index:
        if C[red_seacher_index] == 1:
          C[white_seacher_index] = 1
          C[red_seacher_index] = 0
          counter += 1
          break
        red_seacher_index -= 1
    white_seacher_index += 1
  print(counter)

if __name__ == "__main__":
  resolve()

Measured memory_bytes: 90572
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] str = scanner.nextLine().split(" ");

        if (str[1].equals("+")) {
            System.out.println(Integer.valueOf(str[0]) + Integer.valueOf(str[2]));
        } else if (str[1].equals("-")) {
            System.out.println(Integer.valueOf(str[0]) - Integer.valueOf(str[2]));
        }
    }
}

Measured memory_bytes: 23636
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

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

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N; cin>>N;
    string W[N]; REP(i,N) cin>>W[i];
    REP(i,N-1) {
        if (W[i][W[i].size()-1]!=W[i+1][0]) {
            cout<<"No"<<endl;
            return 0;
        }
        REP(j,i) {
            if (W[i+1]==W[j]) {
                cout<<"No"<<endl;
                return 0;
            }
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
using namespace std;
typedef long long int ll;

int main() {
  int N;
  cin>>N;
  
  vector<ll> a(N+1);
  vector<ll> b(N),f(N),g(N);
  
  for(int i=0;i<N+1;++i){
    cin>>a[i];
  }
  for(int i=0;i<N;++i){
    cin>>b[i];
  }
  
  ll ans=0;
  f[0]=min(a[0],b[0]);
  g[0]=min(a[1],b[0]-f[0]);
  ans+=(f[0]+g[0]);
  
  for(int i=1;i<N;++i){
    f[i]=min(a[i]-g[i-1],b[i]);
    g[i]=min(a[i+1],b[i]-f[i]);
    ans+=(f[i]+g[i]);
  }
 
  cout<<ans<<endl;
}


Measured memory_bytes: 3456
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
4 5
0 1 2
0 2 1
1 2 1
1 3 1
2 3 2

output:
3
"""

import sys
from collections import deque


def graph_bfs(source, target, parent):
    visited = [False] * v_num
    queue = deque()
    queue.appendleft(source)
    visited[source] = True

    while queue:
        current = queue.popleft()
        for adj, cp in adj_table[current].items():
            if cp and not visited[adj]:
                queue.append(adj)
                visited[adj] = True
                parent[adj] = current

    return True if visited[target] else False


def graphFordFulkerson(source, sink):
    parent = [-1] * v_num
    max_flow = 0

    while graph_bfs(source, sink, parent):
        path_flow = float('inf')

        bk_1 = sink
        while bk_1 is not source:
            path_flow = min(path_flow, adj_table[parent[bk_1]][bk_1])
            bk_1 = parent[bk_1]

        max_flow += path_flow

        bk_2 = sink
        while bk_2 is not source:
            parent_bk_2 = parent[bk_2]
            assert parent_bk_2 != -1
            adj_table[parent_bk_2].setdefault(bk_2, 0)
            adj_table[bk_2].setdefault(parent_bk_2, 0)

            # print(bk_2, parent_bk_2, path_flow, bk_1, parent[bk_1], parent, adj_table)
            adj_table[parent_bk_2][bk_2] -= path_flow
            adj_table[bk_2][parent_bk_2] += path_flow
            bk_2 = parent[bk_2]

    return max_flow


def generate_adj_table(_edges):
    for edge in _edges:
        source, target, cp = map(int, edge)
        init_adj_table[source][target] = cp

    return init_adj_table


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    v_num, e_num = map(int, _input[0].split())
    edges = map(lambda x: x.split(), _input[1:])

    init_adj_table = [dict() for _ in range(v_num)]
    adj_table = generate_adj_table(edges)
    ans = graphFordFulkerson(source=0, sink=v_num - 1)
    print(ans)

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

constexpr int MAX_ROOM = 100;

vector<int> sequence;

int next_v;
int degree[MAX_ROOM];
int dist[MAX_ROOM];
vector<int> G[MAX_ROOM];

void dfs(int v, int &idx) {
	if(idx == sequence.size()) return;

	degree[v] = sequence[idx++] - (v ? 1 : 0);

	while(degree[v]) {
		if(sequence[idx] > 0) {
			G[v].emplace_back(next_v);
			G[next_v].emplace_back(v);
			--degree[v];
			dist[next_v] = dist[v] + 1;
			dfs(next_v++, idx);
		}
		else {
			for(int u = 0; u < v; ++u) {
				if(dist[u] - dist[v] == sequence[idx] && degree[u]) {
					G[v].emplace_back(u);
					G[u].emplace_back(v);
					--degree[v];
					--degree[u];
					++idx;
					break;
				}
			}
		}
	}
}

void init() {
	sequence.clear();
	next_v = 1;
	dist[0] = 0;
	for(auto &vec : G) vec.clear();
}

void solve() {
	init();
	for(int number; cin >> number && number;) {
		sequence.emplace_back(number);
	}

	int idx = 0;
	dfs(0, idx);

	for(int v = 0; v < next_v; ++v) {
		sort(G[v].begin(), G[v].end());
		cout << v + 1;
		for(const auto &to : G[v]) cout << " " << to + 1;
		cout << "\n";
	}
}

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

	while(t--) solve();
}

Measured memory_bytes: 1240
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(str, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

H, W = MAP()

S = [LIST() for _ in range(H)]

for i in range(H):
	for j in range(W):
		if S[i][j] == "snuke":
			print(ascii_uppercase[j], i+1, sep="")
			exit()

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 2e5 + 3;
int N;
int X[MC],a[MC];

int main(){
	cin >> N;
	repp(i,0,N){
		cin >> X[i];
		a[i] = X[i];
	}
	sort(a,a+N);
	repp(i,0,N) cout << (a[N/2] > X[i] ? a[N/2] : a[N/2-1]) << endl;
	return 0;
}


Measured memory_bytes: 3712
n, p = list(map(int,input().split()))
a = list(map(int,input().split()))
count = 0
for i in range(n):
    if a[i]%2 == 1:
        count =1
        break

if count == 1:
    print(2**(n-1))
else:
    if p == 0:
        print(2**n)
    else:
        print(0)


Measured memory_bytes: 3060
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;


public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		int a,b,c;
        Scanner scan=new Scanner(System.in);
        a=scan.nextInt();
        b=scan.nextInt();
        while(a!=0)
        {
        	if(a>=b)
            {
            	a=a%b;
            }
             else if(b>a)
        	{
        		c=b;
        		b=a;
        		a=c;
        		a=a%b;
        	}
        }
        System.out.println(b);
        
	}

}

Measured memory_bytes: 17308
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]){
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 3620
def fib(n):
    if n==1:
        a=1
        return a
    if n==2:
        a=1
        return a
    a0=1
    a1=1
    cnt=2
    while cnt <n:
        a=a0+a1
        cnt+=1
        a0=a1
        a1=a
    return a


N,M=map(int,input().split())

mod=10**9+7

if N==1:
    print(1)
    exit()

a0=-1
ans=1
for i in range(M):
    a=int(input())
    n=(a-1)-(a0+1)
    if a-a0==1:
        print(0)
        exit()
    c=fib(n+1)
    ans=(ans*c)%mod
    a0=a

a = N+1
n = (a - 1) - (a0 + 1)
c = fib(n+1)
ans=(ans*c)%mod

print(ans)




Measured memory_bytes: 3064
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}


a=int(input())
if a==3 or a==5 or a==7:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <iostream>
#include <map>
#include<cmath>
using namespace std;
int main() {
	int n;
	cin>>n;
	int a[100500];
	int cnt;
	a[0]=0;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
		cnt+=abs(a[i]-a[i-1]);
	}
	a[n+1]=0;
	cnt+=abs(a[n+1]-a[n]);
	for(int i=1; i<=n; i++) {
		if(a[i]>=a[i-1]&&a[i]<=a[i+1]||a[i]<=a[i-1]&&a[i]>=a[i+1]) {
			cout<<cnt<<endl;
		} else {
			int mn=min(abs(a[i]-a[i-1]),abs(a[i+1]-a[i]));
			cout<<cnt-2*mn<<endl;
		}
	}
	return 0;
}

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

int main(){
  string O,E;
  cin >> O >> E;
  
  for (int i=0;i<(O.length()+E.length());i++){
    if(i%2==0){
      cout<<O.at(i/2);
    }
    else{
    cout<<E.at(i/2);
    }
  }
  cout<<endl;

  return 0;

}

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int main() {
#ifdef LOCAL_EXEC
//	freopen("sample.in", "r", stdin);
//	freopen("sample.out", "w", stdout);
#else
  ios_base::sync_with_stdio(false); cin.tie(NULL);
#endif

  string s, t; cin >> s >> t;
  int ns = s.size(), nt = t.size();
  s = "#" + s, t = "#" + t;
  vector<VI> lcs(ns + 1, VI(nt + 1));
  for (int i = 1; i <= ns; i++) {
    for (int j = 1; j <= nt; j++) {
      lcs[i][j] = max(lcs[i - 1][j], lcs[i][j - 1]);
      if (s[i] == t[j]) {
        lcs[i][j] = max(lcs[i][j], lcs[i - 1][j - 1] + 1);
      }
    }
  }

  string ans;
  for (int i = ns, j = nt; i > 0 && j > 0; ) {
    if (s[i] == t[j]) {
      ans.push_back(s[i]);
      i--, j--;
    } else {
      (lcs[i - 1][j] > lcs[i][j - 1] ? i : j)--;
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef int64_t ll;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define ALL(v) (v).begin(), (v).end()
#define SZ(v) ((int)(v).size())
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1);



int main(void) {
    long double a, b;
    cin >> a >> b;
    cout << (ll)trunc(a * b) << endl;
    return 0;
}


Measured memory_bytes: 3764
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力

      int money = sc.nextInt();
      int happy = 0;
      int happy1000 = 1000;
      int happy5 = 5;
      
      while(money >= 500)
      {
      happy = happy + happy1000;
        money -= 500;
      }
      while(money >= 5)
      {
      happy = happy + happy5;
        money -= 5;
      }

		System.out.println(happy);

	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

vector<int> v[26];
string s,t;

int main(){
    cin >> s;
    cin >> t;
    for(int i=0;i<s.size();i++){
        v[(int)s[i]-'a'].push_back(i);
    }
    for(int i=0;i<t.size();i++){
        if(v[(int)t[i]-'a'].size() == 0){
            cout << -1 << endl;
            return 0;
        }
    }
    int count = 0;
    int p = 0;
    for(int i=0;i<t.size();i++){
        if(p == s.size()){
            count++;
            p = 0;
        }
        auto itr = lower_bound(v[(int)t[i]-'a'].begin(),v[(int)t[i]-'a'].end(),p);
        if(itr != v[(int)t[i]-'a'].end()){
            p = (*itr) + 1;
        }else{
            itr = lower_bound(v[(int)t[i]-'a'].begin(),v[(int)t[i]-'a'].end(),0);
            p = (*itr) + 1;
            count++;
        }
        //cout << count << " " << p << endl;
    }
    cout << count*s.size()+p << endl;
    return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vvi             vector<vi>
#define vb              vector<bool>
#define vvb             vector<vb>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,a,b)      for(int i=a;i<=b;i++)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

void c_p_c()
{
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
  //c_p_c();
  int  n, d;
  cin >> n >> d;
  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    int x, y;
    cin >> x >> y;
    if (x * x + y * y <= d * d)
      cnt++;
  }
  cout << cnt;
  return 0;
}


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

int main(){

    long long n,k;
    cin>>n>>k;

    long long res=0;
    for(long long b=1;b<=n;b++){
        long long r=n%b,p=(n-r)/b; //n=pb+r
        res+=p*max(0LL,b-k)+max(0LL,r-k+1LL);
        if(k==0) res--; // a=0
    }
    cout<<res<<endl;

}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

# 右端を色1として、(色2の末尾、色3の末尾) -> 何通り
# よくわからなくなるので、0番：色3、1番：色2、2番：色1を置いた状態から始める。
# 本来のL,RをL+2,R+2に設定

MOD = 10 ** 9 + 7

N,M = map(int,readline().split())
m = map(int,read().split())
LRX = zip(m,m,m)

R_to_LX = [[] for _ in range(N+3)]
for l,r,x in LRX:
    R_to_LX[r+2].append((l+2,x))

dp = np.zeros((N+3,N+3),np.int64)
dp[1,0] = 1
for r in range(3,N+3):
    # まず、末尾に色を置く
    prev = dp
    dp = np.zeros((N+3,N+3),np.int64)
    # 末尾に色 1
    dp += prev
    # 末尾に色 2
    dp[r-1,:] += prev.sum(axis=0)
    # 末尾に色 3
    dp[r-1,:] += prev.sum(axis=1)
    # 禁止条件を処理
    for l,x in R_to_LX[r]:
        if x == 1:
            dp[l:] = 0
        elif x == 2:
            # 2つはある
            dp[:l] = 0
            # 3つはない
            dp[:,l:] = 0
        else:
            # 3つある
            dp[:,:l] = 0
    dp %= MOD

answer = dp.sum() % MOD
print(answer)

Measured memory_bytes: 18112
from collections import defaultdict
dic = defaultdict(int) 
N = int(input()); MOD = pow(10,9)+7
A = list(map(int,input().split()))
#for x in A:
#  dic[x] += 1
ans = 1
for x in A:
  if x == 0:
    if dic[x] == 0:
      ans *= 3%MOD
    elif dic[x] == 1:
      ans *= 2%MOD
    elif dic[x] == 2:
      ans *= 1%MOD
    else:
      print(0);exit()
  else:
    if dic[x-1]-dic[x] == 0:
      print(0);exit()
    elif dic[x-1]-dic[x] == 1:
      ans *= 1
    elif dic[x-1]-dic[x] == 2:
      ans *= 2%MOD
    elif dic[x-1]-dic[x] == 3:
      ans *= 3%MOD
  dic[x] += 1
print(ans%MOD)
      

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<bool> vb;

template <typename T, typename U> std::istream&operator>>(std::istream&i, pair<T,U>&p) {i >> p.x >> p.y; return i;}
template<typename T>std::istream&operator>>(std::istream&i,vector<T>&t) {for(auto&v:t){i>>v;}return i;}
template <typename T, typename U> std::ostream&operator<<(std::ostream&o, const pair<T,U>&p) {o << p.x << ' ' << p.y; return o;}
template<typename T>std::ostream&operator<<(std::ostream&o,const vector<T>&t) {if(t.empty())o<<'\n';for(size_t i=0;i<t.size();++i){o<<t[i]<<" \n"[i == t.size()-1];}return o;}

#define deb(x) cout << '>' << #x << ':' << x << endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define END '\n'
#define inf 9e18
#define ff first
#define ss second
#define pb push_back

void solve(){
    string a, b, c;
    cin >> a >> b >> c;
    cout << char(toupper(a[0])) << char(toupper(b[0])) << char(toupper(c[0]));
}
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N, M;

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

  std::cin >> N >> M;

  if(N == M){
      std::cout << "Yes" << std::endl;
  }else{
      std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int MIN(int a,int b){return a<b?a:b;}
int MAX(int a,int b){return a<b?b:a;}
int main(){
  int n,i,w[200010]={},r[200010]={},ans=1e9;
  char s[200010];
  scanf("%d %s",&n,s);
  for(i=0;i<n;i++)w[i+1]=w[i]+(s[i]=='W');
  for(i=n;i--;)r[i]=r[i+1]+(s[i]=='R');
  //for(i=0;i<=n;i++)printf("%d ",w[i]);printf("\n");
  //for(i=0;i<=n;i++)printf("%d ",r[i]);printf("\n");
  for(i=0;i<=n;i++)ans=MIN(ans,MAX(w[i],r[i]));
  printf("%d\n",ans);
  return 0;
}
  


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int n, m; cin >> n >> m;
	int total = 0;
	vector<int>v(n);
	for (int i = 0; i < n; i++){
		cin >> v[i];
		total += v[i];
	}
	int c = 0;
  	double d = 1.0*total / (4 * m);
	for (int i = 0; i < n; i++)
	{
		if (v[i] >=d)
			c += 1;
	}
 
	if (c >= m)
		cout << "Yes";
	else
		cout << "No";
 
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

func main() {
	N, C, K := ReadInt(), ReadInt(), ReadInt()
	T := ReadInts(N)
	c := 0
	curL := -1 << 62
	curRest := 0
	sort.Ints(T)
	for _, t := range T {
		if t > curL+K || curRest <= 0 {
			c++
			curL = t
			curRest = C
		}
		curRest--
	}
	fmt.Println(c)
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 4284
n = int(input())
h = list(map(int, input().split()))
can_build = True
for i in range(n-1, 0, -1):
    diff = h[i-1] - h[i]
    if diff == 1:
        h[i - 1] -= 1
    elif diff > 1:
        can_build = False
        break
print("Yes" if can_build else "No")

Measured memory_bytes: 85344
import collections
N = int(input())
A = list(map(int, input().split()))
num = []
for i in range(N):
    num.append(A[i])
    num.append(A[i] + 1)
    num.append(A[i] - 1)
#print(num)
num_count = collections.Counter(num)
#print(num_count.values())
print(max(num_count.values()))

Measured memory_bytes: 27360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<endl;
#define PI 2*acos(0.0)
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define yes cout<<"Yes"<<endl
#define no cout<<"-1"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
///................Graph's Move.................
///const int dx[] = {+1,-1,+0,+0}; ///Rock's Move
///const int dy[] = {+0,+0,+1,-1}; ///Rock's Move
///const int dx[] = {+0,+0,+1,-1,-1,+1,-1,+1}; ///King's Move
///const int dy[] = {-1,+1,+0,+0,+1,+1,-1,-1}; ///king's Move
///const int dx[] = {-2,-2,-1,-1,+1,+1,+2,+2}; ///knight's Move
///const int dy[] = {-1,+1,-2,+2,-2,+2,-1,+1}; ///knight's Move
///*.....................-_-........................*///
int main()
{
    FIO;
    ll n,w,i,j;
    cin>>n>>w;
    vpll v(n+1);
    for(i=1; i<=n; i++)
        cin>>v[i].ff>>v[i].ss;
    vvll dp(n+1, vll (w+1));
    for(i=1; i<=n; i++)
    {
        for(j=1; j<=w; j++)
        {
            if(j>=v[i].ff)
                dp[i][j] = max(dp[i-1][j-v[i].ff]+v[i].ss,dp[i-1][j]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    /**for(i=1; i<=n; i++)
    {
        for(j=1; j<=w; j++)
            cout<<dp[i][j]<<' ';
        cout<<endl;
    }**/
    cout<<dp[n][w]<<endl;
}


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

int main(){
    string S;
    cin >> S;

    string s = S.substr(0, 1), t, u;
    int l = S.size(), ans = 1, i, j, k;
    for(i=0;i<l;){
        for(j=i+1;j<l;j++){
            t = S.substr(i+1, j-i);
            if(t != s){
                ans++;
                break;
            }
        }
        i = j;
        s = t;
    }

    cout << ans << endl;

}

Measured memory_bytes: 640
#include <stdio.h>


int main() {
    
    long long int N;
    long long int total = 0;
    
    scanf("%lld", &N);
    int i;
    for( i = 1; i <= N; i++){
        if(i % 3 != 0 && i % 5 != 0 ){
            total = total + i;
        }
    }
    
    printf("%lld\n", total);
    
    
    return 0;
}

Measured memory_bytes: 1708
#include <iostream>
using namespace std;
int main(){//整数論的アプローチ
  long long int n,k,ans,b;
  cin >> n>>k;
  ans=(n/k)*(n/k)*(n/k);
  if(k%2==1){
    cout << ans<<endl;
  }
  else{
    b=(n+(k/2))/k;
    cout << ans+b*b*b<<endl;
  }
}


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

int main()
{
    int D;
    cin >> D;
    switch (D)
    {
    case 22:
        cout << "Christmas Eve Eve Eve";
        break;
    case 23:
        cout << "Christmas Eve Eve";
        break;
    case 24:
        cout << "Christmas Eve";
        break;
    case 25:
        cout << "Christmas";
        break;
    default:
        break;
    }

    return 0;
}

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

using namespace std;

int minM = 2e8;
bool found = false;

bool check_state(vector<int> state, int X){
  for(int i = 0; i < state.size(); i++){
    if(state[i] < X){
      return false;
    }
  }
  return true;
}

void money(vector<vector<int> > &A, vector<int> &C, int pos, vector<int> state, int m, int X){

  if(check_state(state, X)) { if(m < minM) {minM = m;} found = true; return;}
  
  if(pos == C.size()){
    return;
  }


  money(A,C,pos + 1,state,m, X);

  for(int i = 0; i < state.size(); i++){
    state[i] += A[pos][i];
  }

  money(A,C,pos + 1,state,m + C[pos], X);

}


int main(){

  int N, M , X;
  cin >> N >> M >> X;

  vector<int> C;
  vector<vector<int> > A;

  for(int i = 0; i < N; i++){
    int t;
    cin >> t;
    C.push_back(t);
    vector<int> As;
    for(int j = 0; j < M ; j++){
      cin >> t;
      As.push_back(t);
    }
    A.push_back(As);
  }

  vector<int> state;
  for(int i = 0; i < M; i++){
    state.push_back(0);
  }

  money(A,C,0,state,0, X);

  if(found) cout << minM << endl;
  else cout << -1 << endl;
  
  
  return 0;

}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  vector<int> A(N - 1), ans(N);
  for (int i = 0; i < N - 1; i++) {
    cin >> A.at(i);
    int a = A.at(i) - 1;
    ans.at(a) = ans.at(a) + 1;
  }
  for (int i = 0; i < N; i++) {
    cout << ans.at(i) << endl;
  }
}

Measured memory_bytes: 4828
import itertools
N, Q, row, col = input(), [], range(8), range(8)
for _ in range(N):
    r, c = map(int, raw_input().split())
    Q.append((r, c))
    row.remove(r)
    col.remove(c)
for l in itertools.permutations(col):
    queen = Q + list(zip(row, l))
    if not any((r1 != r2 or c1 != c2) and (r1 == r2 or c1 == c2 or r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2) for r2, c2 in queen for r1, c1 in queen):
        print '\n'.join(''.join('Q' if (r, c) in queen else '.' for c in range(8)) for r in range(8))
        break

Measured memory_bytes: 6540
#include<iostream>

using namespace std;

int main(void)
{
	int a,b,c;
	cin >> a >> b >> c;
	int gcd=1;

	for(int i=100;i>=1;i--)
	{
		if(a%i==0 && b%i==0)
		{
			gcd=i;
			break;
		}
	}

	cout << (c%gcd==0 ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
// https://abc086.contest.atcoder.jp/tasks/abc086_a

#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

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

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

    int a, b, c;
    cin >> a >> b;
    c = a * b % 2;

    if (c == 0)
    {
        cout << "Even" << endl;
    }
    else
    {
        cout << "Odd" << endl;
    }

    return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

const ll mod = 1000000007;



int main() {
	map<string, ll> ms;
	int n;
	cin >> n;
	rep(i, n) {
		string c;
		cin >> c;
		ms[c]++;
	}
	cout << "AC x " << ms["AC"] << endl;
	cout << "WA x " << ms["WA"] << endl;
	cout << "TLE x " << ms["TLE"] << endl;
	cout << "RE x " << ms["RE"] << endl;

	return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <memory>
#include <cstring>
#include <cstdlib>
using namespace std;
 
int main() {
int a, b; cin>>a>>b;
  if(a <= 8 && b <= 8) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
using namespace std;
const int MAXN=200005,MOD=1000000007;

int PowMod(int a,int b)
{
    int ret=1;
    while(b)
    {
        if(b&1)
            ret=1LL*ret*a%MOD;
        b>>=1;
        a=1LL*a*a%MOD;
    }
    return ret;
}

int n,X,Y;
int c[MAXN],w[MAXN];

vector<int> id[MAXN];
int mnid[MAXN];

vector<int> col[MAXN];
int cnt[MAXN];

int fac[MAXN],ifac[MAXN];

int fa[MAXN];
int Root(int x)
{return fa[x]==0?x:(fa[x]=Root(fa[x]));}
void Union(int x,int y)
{
    int r1=Root(x),r2=Root(y);
    if(r1==r2)
        return;
    fa[r1]=r2;
}

int main()
{
    scanf("%d%d%d",&n,&X,&Y);
    for(int i=1;i<=n;i++)
    {
        scanf("%d%d",&c[i],&w[i]);
        id[c[i]].push_back(i);
    }

    int mn,pos;
    for(int i=1;i<=n;i++)
    {
        mn=0x3F3F3F3F,pos=-1;
        for(int j=0;j<(int)id[i].size();j++)
            if(mn>w[id[i][j]])
                mn=w[id[i][j]],pos=id[i][j];
        for(int j=0;j<(int)id[i].size();j++)
            if(mn+w[id[i][j]]<=X)
                Union(pos,id[i][j]);
        mnid[i]=pos;
    }
    mn=0x3F3F3F3F,pos=-1;
    for(int i=1;i<=n;i++)
        if(mnid[i]!=-1&&mn>w[mnid[i]])
            mn=w[mnid[i]],pos=mnid[i];
    for(int i=1;i<=n;i++)
        if(mn+w[i]<=Y&&c[i]!=c[pos])
            Union(pos,i);
    int pos2=-1;
    mn=0x3F3F3F3F;
    for(int i=1;i<=n;i++)
        if(mnid[i]!=-1&&mn>w[mnid[i]]&&i!=c[pos])
            mn=w[mnid[i]],pos2=mnid[i];
    if(pos2!=-1)
        for(int i=1;i<=n;i++)
            if(mn+w[i]<=Y&&c[i]!=c[pos2])
                Union(pos2,i);
    fac[0]=1;
    for(int i=1;i<=n;i++)
        fac[i]=1LL*fac[i-1]*i%MOD;
    ifac[n]=PowMod(fac[n],MOD-2);
    for(int i=n-1;i>=0;i--)
        ifac[i]=(1LL*ifac[i+1]*(i+1))%MOD;

    for(int i=1;i<=n;i++)
        col[Root(i)].push_back(c[i]);
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        int all=0;
        for(int j=0;j<(int)col[i].size();j++)
            cnt[col[i][j]]++,all++;
        ans=1LL*ans*fac[all]%MOD;
        for(int j=0;j<(int)col[i].size();j++)
        {
            ans=1LL*ans*ifac[cnt[col[i][j]]]%MOD;
            cnt[col[i][j]]=0;
        }
    }
    printf("%d\n",ans);

    return 0;
}


Measured memory_bytes: 24960
#include<bits/stdc++.h>
using namespace std;
int main(){
	char s1[10], s2[10], s3[10];

	cin>>s1>>s2>>s3;
	cout<<char(toupper(s1[0]));
	cout<<char(toupper(s2[0]));
	cout<<char(toupper(s3[0]));
	return 0;

}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <numeric>
#include <functional>
#include <cmath>
#include <cassert>
#include <string>
#include <iostream>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
const ll MOD = 1000000007;
const int mod = 1000000007;
ll INF = 1LL << 60;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
   for (auto &v : vec)
      is >> v;
   return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec)
{
   os << "[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &vec)
{
   os << "deq[";
   for (auto v : vec)
      os << v << ",";
   os << "]";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &vec)
{
   os << "{";
   for (auto v : vec)
      os << v << ",";
   os << "}";
   return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{
   os << "(" << pa.first << "," << pa.second << ")";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp)
{
   os << "{";
   for (auto v : mp)
      os << v.first << "=>" << v.second << ",";
   os << "}";
   return os;
};
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
   fill((T *)array, (T *)(array + N), val);
}



ll a[202020];
int solve()
{
   ll n,k;
   cin >> n >> k;
   map<ll,ll> m;
   set<ll> s;
   for(int i=0; i < n; i++){
      cin >> a[i];
      m[a[i]]++;
      s.insert(a[i]);
   }
   if(s.size() <= k){
      cout << 0 << endl;
      return 0;
   }
   vector<ll> v;
   for(ll t : s){
      v.push_back(m[t]);
   }
   sort(v.begin(), v.end());
   ll ans = 0;
   for(int i=0; i < s.size() - k; i++){
      ans += v[i];
   }
   cout << ans << endl;



   return 0;
}

int main()
{
   //cout.precision(10)
   ios::sync_with_stdio(false);
   cin.tie(0);

   solve();
}

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

using namespace std;

int main(){
  string S, T; cin >> S >> T;
  if (S[0] == T[2] && S[1] == T[1] && S[2] == T[0]){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
N,M,C=map(int,input().split())
B=list(map(int,input().split()))
A=[list(map(int,input().split())) for _ in range(N)]
cnt=0
for a in A:
  ans=C
  for i in range(M):
    ans+=a[i]*B[i]
  if ans>0:
    cnt+=1
print(cnt)


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>

using namespace std;


int c[6];
int h, w, k;

int f(int m, int n)
{
    int y = 0;
    for (int i = 0; i < h; i++)
    {
        if ((m >> i) & 1)
        {
            int x = c[i] & n;
            for (int j = 0; j < w; j++)
            {
                if ((x >> j) & 1)
                {
                    y++;
                }
            }
        }
        else
        {
            continue;
        }
    }
    return (k == y);
}

int main()
{
    cin >> h >> w >> k;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            char ch;
            cin >> ch;
            c[i] = (c[i] << 1) | (ch == '.' ? 0 : 1);
        }
    }
    int a = 0;
    for (int i = 0; i < (1 << h); i++)
    {
        for (int j = 0; j < (1 << w); j++)
        {
            a += f(i, j);
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define forr(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define ford(i, n) for (int i = (int)(n); i > 0; i--)
#define forin(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define debug(x) cerr<<#x<<" "<<x<<"\n";
#define yn {puts("YES");}else{puts("NO");}
#define maxs(x,y) (x = max(x,y))
#define sz(x) (int)(x).size()
#define mins(x,y) (x = min(x,y))
#define newline cout<<"\n"
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
const int LINF = 1e9+5;
const int MX = 3e3+1;

int dp[MX][MX] = {0};

int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
	string s,t,ans = "";
	cin >> s >> t;
	s = '#'+s;
	t = '&'+t;
	for1(i,sz(s)-1){ 
		for1(j,sz(t)-1){
			if(s[i] == t[j]) dp[i][j] = 1+dp[i-1][j-1];
			else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
		}
	}
	int i = sz(s)-1, j = sz(t) -1;
	while(i > 0 && j > 0){
		if(s[i] == t[j]){
			ans += s[i];
			i--; j--;
		}
		else{
			if(dp[i][j-1] < dp[i-1][j]) i--;
			else j--;
		}
	}
	reverse(all(ans));
	cout << ans;
	return 0;
}




Measured memory_bytes: 35456
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int main(){
    double x1,y1,x2,y2,a,b,c,n;
    cin>>x1>>y1>>x2>>y2;
    a=(x1-x2)*(x1-x2);
    b=(y1-y2)*(y1-y2);
    c=a+b;
    n=sqrt( c);
    printf("%f\n",n);
    
    return 0;
}


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

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

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

int main()
{
   int a, b;
   cin >> a;

   b = 360;

   //cout << "最小公倍数:" << lcm(a, b) << endl;
   cout << lcm(a, b)/a << endl;
   return 0;
}

Measured memory_bytes: 3164
use proconio::input;

fn main() {
    input! {
        a: f64,
        b: f64,
        c: f64,
        d: f64,
    };
    let ans = if (a / d).ceil() >= (c / b).ceil() {
        "Yes"
    } else {
        "No"
    };
    println!("{}", ans);
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()

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

  int N;
  cin >> N;
  int i = N - 1;
  while(true) {
    i++;
    if(i % 2 != 0) continue;
    if(i % N != 0) continue;
    cout << i << endl;
    break;

  }
}


Measured memory_bytes: 256
# import sys
# # sys.setrecursionlimit(1000000)
# input = sys.stdin.readline
# # from bisect import *
# from collections import *
# # from heapq import *
# # INF = 500000
# mod = 10**9+7
#
# class UnionFind:
#
#     def __init__(self, n):
#         self.n = n
#         self.par = [i for i in range(n)]
#         self.height = [0] * n
#         self.size = [1] * n
#
#     def find(self, x):
#         if self.par[x] == x:
#             return x
#         self.par[x] = self.find(self.par[x])
#         return self.par[x]
#
#     def getsize(self, x):
#         return self.size[self.find(x)]
#
#     def unite(self, x, y):
#         x, y = self.find(x), self.find(y)
#         if x == y:
#             return
#         if self.height[x] < self.height[y]:
#             self.par[x] = y
#             self.size[y] += self.size[x]
#         else:
#             self.par[y] = self.par[x]
#             self.size[x] += self.size[y]
#             if self.height[x] == self.height[x]:
#                 self.height[x] += 1
#
#     def same(self, x, y):
#         return self.find(x) == self.find(y)
#
# N, M, K = map(int, input().split())
# es = [[] for i in range(N)]
# for i in range(M):
#     u, v = map(int, input().split())
#     u -= 1
#     v -= 1
#     es[u].append(v)
#     es[v].append(u)
# uf = UnionFind(N)
# g = [-1]*N
# def dfs(v, num):
#     g[v] = num
#     for u in es[v]:
#         if g[u] == -1:
#             uf.unite(v, u)
#             dfs(u, num)
# num = 0
# for v in range(N):
#     if g[v] == -1:
#         dfs(v, num)
#         num += 1
# ans = [uf.getsize(v)-len(es[v])-1 for v in range(N)]
# for i in range(K):
#     u, v = map(int, input().split())
#     u -= 1
#     v -= 1
#     if uf.same(u, v):
#         ans[u] -= 1
#         ans[v] -= 1
# print(*ans)

A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
for i in range(N):
    x = int(input())
    for i in range(3):
        for j in range(3):
            if A[i][j] == x:
                A[i][j] = 0
flg = 0
for i in range(3):
    for j in range(3):
        if sum(A[i]) == 0:
            flg = 1
for j in range(3):
    s = 0
    for i in range(3):
        s += A[i][j]
    if s == 0:
        flg = 1
flg |= 0 == sum([A[i][i] for i in range(3)])
flg |= 0 == sum([A[2-i][i] for i in range(3)])
if flg:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

typedef long long ll;
typedef unsigned long long ull;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i) = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

// const int dx[8] = {1, 1, 0,-1,-1,-1, 0, 1};
// const int dy[8] = {0, 1, 1, 1, 0,-1,-1,-1};

#define SUM(vec) accumulate(all(vec),0LL) // 配列の中身を全部足す
template<typename T>void print(T&& x){cout<<x<<endl;}// 改行付き出力
ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}

// TODO: write
int main() {
  ll n,k;cin>>n>>k;
  n %= k;
  while(chmin(n,abs(n-k)));
  print(n);
  return 0;
}


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

int main() {
  string number;
  cin >> number;
  
  int count = 0;
  if (number[0] == '1') {
    count++;
  }
  if (number[1] == '1') {
    count++;
  }
  if (number[2] == '1') {
    count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

//ll ncr(ll n,ll r){ll ans=1;r=min(r,n-r);for (int i=1;i<=r;i++){ans*=(n-r+i);ans/=i;}return ans;}

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI=3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

#define fi first
#define se second
#define SSIZE 100005

ll ans[SSIZE];

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n;
	cin>>n;
	for(ll i=0;i<n;i++)
	{
	    ll val;
	    cin>>val;
	    ans[val]=i+1;
	}
	for(ll i=1;i<=n;i++)
	{
	    cout<<ans[i]<<" ";
	}
    return 0;
}


//252908XL

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    long long int a,b;
    cin >> a >> b;
    
    long long int d,r;
    double f;
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    
    cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;
}


Measured memory_bytes: 3244
/* https://atcoder.jp/contests/abc086/tasks/abc086_b */

#include <iostream>
#include <cmath>

void solve()
{
  return;
}

int main(int argc, char *argv[])
{
  // Input
  int a, b;

  std::cin >> a >> b;

  int b_len = std::to_string(b).length();

  for (int i = 0; i < b_len; ++i) {
    a *=10;
  }

  int num = a+b;

  for (int i = 0; i*i <= num; ++i) {
    if (num == i*i) {
      std::cout << "Yes" << std::endl;
      return 0;
    }
  }

  std::cout << "No" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using Int = long long;
using namespace std;
int main(){
    int N; cin >> N;
    constexpr Int mod = 1000000007;
    vector<int>v(N);
    for(auto& e : v) cin >> e;
    map<Int,Int>cnt;
    map<Int,Int>data;
    Int ans = 1;
    for(int i = 0; i < N; ++i){
        int num = v[i];
        data[num]++;
        if(data[num] > 3) return puts("0") * 0;
        if(cnt[num - 1] != 0){
            ans *= cnt[num - 1];
            ans %= mod;
            cnt[num - 1]--;
        } else if( num != 0)
            return puts("0") * 0;
        cnt[num]++;
    }
    Int maxi = accumulate(v.begin(), v.end(), 0LL,[](Int val, int e){
        return val += (e == 0);
    });
    ans *= (maxi >= 2 ? 6 : 3);
    ans %= mod;
    cout << ans << endl;
}



Measured memory_bytes: 13184