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

int main(){
  int N;
  cin >> N;
  for(int i = 1; i <= 9; i++){
  	for(int j = 1; j <= 9; j++){
      if(i*j == N) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()
Slen = len(S)
cnt=[0,0,0]
flg = True
for i in range(Slen-1):
  
  for j in range(Slen):
    if S[i]==S[j]:
      cnt[i] += 1
  
  if cnt[i] < 2 or cnt[i] > 2:
    flg = False
    break

if flg == True:
  print("Yes")
else:
  print("No")

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

using namespace std;

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

  string s;
  cin >> s;
  int n = s.size() + 1;
  vector<vector<int>> dp(n, vector<int>(2));
  for (int i = 1; i < n; ++i) {
    if (s[i - 1] == '>') {
      dp[i][0] = 0;
    } else {
      dp[i][0] = dp[i - 1][0] + 1;
    }
  }
  for (int i = n - 2; i >= 0; --i) {
    if (s[i] == '<') {
      dp[i][1] = 0;
    } else {
      dp[i][1] = dp[i + 1][1] + 1;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += max(dp[i][0], dp[i][1]);
  }
  cout << ans;

  return 0;
}

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

int main(void) {
    string s;
    int K;
    cin >> s >> K;
    rep(i, s.size()) {
        if(s[i] != 'a') {
            int p = 'z'+1 - s[i];
            if(K >= p) {
                K -= p;
                s[i] = 'a';
            }
        }
        if(i == s.size()-1) {
            s[i] += K%26;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 640
while True:
    result = ""
    m, r, f = map(int, input().split())
    if m == r == f == -1:
        break
    judgement = m + r
    if m == -1 or r == -1:
        result = "F"
    elif judgement >= 80:
        result = "A"
    elif judgement >= 65 and judgement < 80:
        result = "B"
    elif judgement >= 50 and judgement < 65:
        result = "C"
    elif judgement >= 30 and judgement < 50:
        if f >= 50:
            result = "C"
        else:
            result = "D"
    elif judgement < 30:
        result = "F"
    print(result)



Measured memory_bytes: 5592
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
const int inf = 1<<30;
typedef pair<int, int> P;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  vector<P> vec;
  for(int i = 0; i < N; ++i) {
    int a; cin >> a;
    vec.emplace_back(P(a, i));
  }
  sort(vec.begin(), vec.end());
  int ans = 0;
  for(int i = 0; i < N; ++i) {
    ans += (i % 2) != (vec[i].second % 2);
  }
  cout << ans/2 << endl;
  return 0;
}


Measured memory_bytes: 1400
#include <iostream>
#include<cstring> 
#include<cstdlib> 
using namespace std;
void LCS(string text1 ,string text2 ,int len1,int len2){
    int dp[len1+1][len2+1];
    for(int i=0;i<=len1;i++){
        for(int j=0;j<=len2;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
           else if(text1[i-1]==text2[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
           }
           else{
               dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
           }
        }
    }
    int index= dp[len1][len2];
    char lcs[index+1];
    lcs[index] = '\0';
    int i=len1;
    int j=len2;
    while(i>0 && j>0){
        if(text1[i-1]==text2[j-1]){
            lcs[index-1]=text1[i-1];
            i--;
            j--;
            index--;

        }
        else if(dp[i-1][j]>dp[i][j-1]){
            i--;
        }
        else {
            j--;
        }
    }
    
        cout<<lcs;
    
}
int main(){

    string text1;
    string text2;
    getline(cin,text1);
    getline(cin,text2);

    int len1=text1.length();
    int len2=text2.length();
    LCS(text1,text2,len1,len2);
   return 0; 
} 


Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 2e5+5;
ll a[maxn];

int main(){
	ll k, n; cin >> k >> n;
	ll mx = 0, sum = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
	}
	for(int i = 2; i <= n; i++){
		sum += a[i] - a[i-1];
		if(mx <= a[i] - a[i-1]){
			mx = a[i] - a[i-1];
		}
	}
	ll x = k - a[n] + a[1];
	sum += x;
	mx = max(mx, x);
	cout << sum - mx << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
 int a,b;
 cin>>a>>b;
 if(a>b){
  cout<<"safe";
 }
  else{
 cout<<"unsafe";
  }
}


Measured memory_bytes: 3632
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()
    val stack = LinkedList<Char>()
    s.forEach {
        if (stack.isNotEmpty()) {
            val last = stack.last()
            if (it != last) {
                stack.removeLast()
            } else {
                stack.add(it)
            }
        } else {
            stack.add(it)
        }
    }
    println(s.length - stack.size)
}

Measured memory_bytes: 34636
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, x, m[1001], m2 = 0, mi, result;
  cin >> n >> x;
  for (int i = 0; i < n; i++) {
    cin >> m[i];
    m2 += m[i];
    if (i == 0) {
      mi = m[0];
    } else if (mi > m[i]) {
      mi = m[i];
    }
  }
  x -= m2;
  result = n + (x / mi);
  cout << result << endl;
}


Measured memory_bytes: 3608
X = input().split()
A = int(X[0])
B = int(X[1])

ans = -999999999

a = []

a.append(A+B)
a.append(A-B)
a.append(A*B)

add = A+B
sub = A-B
mul = A*B

if add > ans:
    ans = add

if sub > ans:
    ans =sub

if mul > ans:
    ans = mul

print(ans)

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

using namespace std;

signed main() {
    int n;
    cin >> n;
    vector<int> dp1(3);
    for (int day = 0; day < n; day++) {
        vector<int> dp2(3, 0);
        vector<int> c(3);
        for (int i = 0; i < 3; i++) 
            cin >> c[i];
        for (int i = 0; i < 3; i++)     
            for (int j = 0; j < 3; j++) 
                if (i != j) 
                    dp2[j] = max(dp2[j], dp1[i] + c[j]);
        dp1 = dp2;
    }
    cout << max({dp1[0], dp1[1], dp1[2]}) << "\n";
    return false;     
}

Measured memory_bytes: 384
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from operator import mul
from functools import reduce
sys.setrecursionlimit(10 ** 9)



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


n, k = LI()
G = [[] for _ in range(n)]
for a, b in LIR(n - 1):
    G[a - 1] += [b - 1]
    G[b - 1] += [a - 1]


que = [0]
ans = k
visited = [0] * n
c_num = [0] * n
visited[0] = 1
while que:
    u = que.pop()
    for v in G[u]:
        if visited[v] == 0:
            if u == 0:
                ans = ans * (k - 1 - c_num[u]) % mod
            else:
                ans = ans * (k - 2 - c_num[u]) % mod
            c_num[u] += 1
            visited[v] = 1
            que += [v]


print(ans)




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


def read():
    N = int(input().strip())
    D = list(map(int, input().strip().split()))
    M = int(input().strip())
    T = list(map(int, input().strip().split()))
    return N, D, M, T


def solve(N, D, M, T):
    D.sort()
    T.sort()
    ix = 0
    for t in T:
        while D[ix] < t and ix < N-1:
            ix += 1
        if D[ix] == t:
            ix += 1
        else:
            return "NO"
    return "YES"


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))


Measured memory_bytes: 39376
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
ll N,x;
ll a[2000];
ll m[2000];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>x;
    rep(i,0,N)cin>>a[i];
    ll ans=1e17;
    rep(i,0,N) m[i]=a[i];
    rep(i,0,N){
        ll M=0;
        rep(j,0,N){
            m[j]=min(m[j],a[(j-i+N)%N]);
            M+=m[j];
        }
        ans=min(ans,M+i*x);
    }
    cout <<ans<<"\n";
}

Measured memory_bytes: 256
h,n = map(int,input().split())
magic = []
maxa = 0
for _ in range(n):
  a,b = map(int,input().split())
  maxa = max(maxa,a)
  magic.append((a,b))
#magic.sort()

dp = [float('inf') for _ in range(h + maxa)]
dp[0] = 0

for i in range(h):
  for a,b in magic:
    if i+a > h+maxa:
      continue
    dp[i+a] = min(dp[i] + b,dp[i+a])
print(min(dp[h:]))

Measured memory_bytes: 42568
#define taskname "B"

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;
#define long long long

const int N = 1e5 + 10;
const long INF = 1e16;
int n, k, h[N];
long f[N];

int main()
{
//    freopen(taskname".INP", "r", stdin);
//    freopen(taskname".OUT", "w", stdout);

    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; ++i) scanf("%d", &h[i]);
    fill(f + 2, f + N, INF);

    for (int i = 2; i <= n; ++i)
        for (int j = 1; j <= k; ++j) {
            int _j = i - j;
            if (_j < 1) break;
            f[i] = min(f[i], f[_j] + abs(h[i] - h[_j]));
        }
    cout << f[n];

    return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>
int main(){
  int a,b,c;
  int x=0;
  int y=0;
  scanf("%d %d %d",&a,&b,&c);
  if (a==5){
    x = x+1;
  }
  if (a==7){
    y = y+1;
  }
  if (b==5){
    x = x+1;
  }
  if (b==7){
    y = y+1;
  }
  if (c==5){
    x = x+1;
  }
  if (c==7){
    y = y+1;
  }
  if (x==2 && y==1){
    printf("YES");
  }
  else{
    printf("NO");
  }
}
/*
자료형
연산자 (+,-,*,/,%,&&,||)
인풋아웃풋

다음시간 : if for while break continue 2차원 배열
함수 재귀함수
*/


Measured memory_bytes: 128
#include <iostream>
#include <cstdint>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int>> vpii;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<ll>> vvll;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (ll i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define Rev(a) reverse(a.begin(), a.end())
#define MATHPI acos(-1)
#define itn int
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;
}
struct io
{
    io()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
};
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-19;





signed main() {
    ll n, m;
    cin >> n >> m;
    
    priority_queue<int> que;
    
    ll sum = 0;
    
    ll a;
    rep(i, n) {
        cin >> a;
        que.push(a);
    }
    
    
    rep(i, m) {
        a = que.top();
        que.pop();
        a /= 2;
        que.push(a);
    }
    
    while (!que.empty()) {
        sum += que.top();
        que.pop();
    }
    
    
    
    mes(sum);
    
    
    
    
    
    
}

Measured memory_bytes: 3916
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
l = Array.new(n, 0)
r = Array.new(n, 0)
for i in 0...(n - 1) do
  for j in (i + 1)...n do
    if a[i] > a[j]
      r[i] += 1
    elsif a[i] < a[j]
      l[j] += 1
    end
  end
end
r[n - 1] = 0
l[0] = 0
count = 0
for i in 0...n do
  count += r[i] * (k * (k + 1) / 2) + l[i] * ((k - 1) * k / 2)
end
puts count % 1000000007


Measured memory_bytes: 1788
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define MAXN 510
int n, m, d;
int main() {
    scanf("%d%d%d", &n, &m, &d);
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            int I = (m + i + j) / d;
            int J = (m + i - j) / d;
            printf("%c", "RYGB"[((I & 1) << 1) | (J & 1)]);
        }
        puts("");
    }
    return 0;
}

Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<limits.h>
#define N 101

enum COLOR{WHITE,BLACK,GRAY}color[N];
int G[N][N],d[N],f[N],n,A[N][N],edg[N]; 
int  Q[N];
int head, tail;
 
void enqueue(int x){
    Q[tail] = x;
    if (tail + 1 == N){
        tail = 0;
    }else{
        tail++;
    }
}
 
int dequeue(){
    int x = Q[head];
    if (head + 1 == N){
        head = 0;
    }else{
        head++;
    }
    return x;
}

void BFS(int s){
  int u,i,j;
  for(i=0;i<N;i++)d[i]=-1;
  for(u=1;u<=n-1;u++){
    color[u]  =WHITE;
    d[u]      =-1;
    color[s]  =GRAY;
  }
  d[s]=0;
  head=1;
  tail=1;
  enqueue(s);

  while(head!=tail){
    u=dequeue();
    for(i=1;i<=edg[u];i++){
      if(color[A[u][i]] == WHITE){
	color[A[u][i]]=GRAY;
	d[A[u][i]]=d[u]+1;
	enqueue(A[u][i]);
      }
    }
    color[u]=BLACK;
  }
}

int main(){
  int i ,j,k,ver,fff;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&ver,&edg[i]);
    for(j=1;j<=edg[i];j++){
      scanf("%d",&fff);
      A[i][j]=fff;
    } 
  }
    BFS(1);
    for(j=1;j<=n;j++)printf("%d %d\n",j,d[j]);
  return 0;
}

Measured memory_bytes: 640
# abc137_a.py
# https://atcoder.jp/contests/abc137/tasks/abc137_a

# A - +-x /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 整数 A, Bがあります。
# A+B,  A−B,  A×Bの中で最大の数を出力してください。

# 制約
#     入力は全て整数である。
#     −100≤A, B≤100

# 入力
# 入力は以下の形式で標準入力から与えられる。
# A B

# 出力
# A+B,  A−B,  A×Bの中で最大の数を出力せよ。

# 入力例 1
# -13 3

# 出力例 1
# -10

# A+B=−10,  A−B=−16,  A×B=−39 の中で最大の数は −10です。

# 入力例 2
# 1 -33

# 出力例 2
# 34

# A+B=−32,  A−B=34,  A×B=−33 の中で最大の数は 34です。

# 入力例 3
# 13 3

# 出力例 3
# 39

# A+B=16,  A−B=10,  A×B=39 の中で最大の数は 39 です。


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    # S = lines[0]
    # N = int(lines[0])
    A, B = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(M):
    #     valueses.append(list(map(int, lines[i+1].split())))

    return [max(A+B, A-B, A*B)]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['-13 3']
        lines_export = [-10]
    if pattern == 2:
        lines_input = ['1 -33']
        lines_export = [34]
    if pattern == 3:
        lines_input = ['13 3']
        lines_export = [39]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9260
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int a,b;
  cin >> a >> b;
  if(a <= b){
    cout << a << endl;
  }else{
    cout << a-1 << endl;
  }
    
  
  
}

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

#define copy(from, to) copy(from.begin(), from.end(), back_inserter(to));
#define sort(a) sort(a.begin(), a.end())

using namespace std;

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

  sort(n);
  cout << n[0] + n[1] << endl;
}

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

int main () {
    string S;
    cin >> S;
    string ans("CODEFESTIVAL2016");

    int count = 0;

    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) != ans.at(i)) count++;
    }

    cout << count << endl;

    return 0;

}

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

int main() {
	int d;
	cin >> d;
	vector<int> c(30);
	vector<int> co(d);
	vector<int> ans(d);
	int ans_c = 0;

	rep(i,26) {
		cin >> c[i];
	}

	vector<int> last(26,-1);

	rep(i, 26) {
		last[i]=0;
	}

	vector<int> t(d + 5);
	int s[370][30];

	rep(j, d) {
		rep(i, 26) {
			cin >> s[j][i];
		}
	}
	
	rep(j, d) {

		int count = 0;
		int max_d=0;

		rep(i, 26) {
			ll tmp = s[d][i] + c[i] * (j - last[i]);
			if (tmp > count) {
				count = tmp;
				max_d = i;
			}
		}
		co[j] = max_d+1;
		last[max_d] = j;
	}

	rep(j, d) {
		cout << co[j]<<endl;
	}

	return 0;
}

Measured memory_bytes: 3652
import sys
sys.setrecursionlimit(8388608)
N=int(input())
nodes=[None]*(N+1)
childs=[]
oya=[]
class node_tree:
    def __init__(self,node):
        self.node=node
        self.left=None
        self.right=None
        self.oya=None
for i in range(N):
    node,child_num,*child=list(map(int,input().split()))
    if nodes[node] is not None:
        parent=nodes[node]
    else:
        parent=node_tree(node)
    if child_num>=1:
        if nodes[child[0]] is not None:
            tree=nodes[child[0]]
        else:
            tree=node_tree(child[0])
        parent.left=tree
        tree.oya=parent
        nodes[node]=parent
        nodes[child[0]]=tree
        for j in range(len(child)-1):
            if nodes[child[j]] is not None:
                treesecond=nodes[child[j]]
            else:
                treesecond=node_tree(child[j])
            if nodes[child[j+1]] is not None:
                treenext = nodes[child[j+1]]
            else:
                treenext = node_tree(child[j+1])
            treesecond.oya=parent
            treenext.oya=parent
            treesecond.right=treenext
            nodes[child[j]]=treesecond
            nodes[child[j+1]]=treenext
    else:
        parent.left=nodes[-1]
        nodes[node]=parent
def oyasearch(u):
    if u.oya is not None:
        oyasearch(u.oya)
    else:
        oya.append(u.node)
oyasearch(nodes[0])
dep=[0]*N
parent_list=[None]*N
parent_list[oya[0]]=-1
child_list=[]
def search_depth(u,p):
    dep[u.node]=p
    if u.right is not None:
        parent_list[u.right.node]=parent_list[u.node]
        search_depth(u.right,p)
    if u.left is not None:
        parent_list[u.left.node]=u.node
        search_depth(u.left,p+1)
search_depth(nodes[oya[0]],0)
def child_search(u,c):
    c.append(u.node)
    if u.right is not None:
        child_search(u.right,c)
for i in range(N):
    c=[]
    if nodes[i].left is not None:
        child_search(nodes[i].left,c)
    child_list.append(c)
word_list=["internal node","leaf"]
for i in range(N):
    if i==oya[0]:
        print(("node %d: parent = %d, depth = %d, root," % (nodes[oya[0]].node, parent_list[oya[0]], dep[oya[0]])),
              child_list[oya[0]])
    else:
        if len(child_list[i])!=0:
            word=word_list[0]
        else:word=word_list[1]
        print(("node %d: parent = %d, depth = %d, %s," % (nodes[i].node, parent_list[i], dep[i],word)), child_list[i])



Measured memory_bytes: 126064
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
using namespace std;

int main(){
	int n,k;cin>>n>>k;
	if(n>k)cout<<n-k<<endl;
	else cout<<0<<endl;
}

Measured memory_bytes: 256
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort()
p1=p[-x:]
q.sort()
q1=q[-y:]
r.sort()
r.reverse()

for i in p1:
  r.append(i)
for i in q1:
  r.append(i)
r.sort()
r.reverse()
ans=0
for i in range(x+y):
  ans+=r[i]
print(ans)


Measured memory_bytes: 23328
// The moment you think of giving up you have already lost the battle
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long int ll;
typedef long double dl;
#define PI  3.14159265358979323846
#define M 1000000007
ll fast(ll n,ll a,ll m)
{
    if(n==0)
        return 1;
    else if(n==1)
        return a;
    else
    {
        ll r=fast(n/2,a,m);
        if(n%2==0)
        {
            return (((r%m)*(r%m))%m);
        }
        else
        {
            return (((((r%m)*a)%m)*r)%m);
        }

    }
}
ll res[10005]={0};
int main()
{
   ll i,n;
   cin>>n;
   ll A[n];
   for(i=0;i<n;i++)
   {
       cin>>A[i];
   }
   ll ans=0;
   for(i=1;i<=n;i++)
   {
       if(A[i-1]%2==1&&i%2==1)
        ans++;
   }
   cout<<ans;
}


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

int main(){
  int N;
  cin>>N;
  vector<pair<int,int>>pa(N);
  int temp;
  for(int i=0;i<N;i++){
    cin>>pa[i].first;
    pa[i].second=i;
  }
  sort(pa.begin(),pa.end());
  for(int i=0;i<N-1;i++){
    cout<<pa[i].second+1<<" ";
  }
  cout<<pa[N-1].second+1<<endl;
  return 0;
}


Measured memory_bytes: 1664
n,x=map(int,input().split())
l=list(map(int,input().split()))
c=0 
for i in range(n-1):
  a=l[i]
  b=l[i+1]
  if a+b<=x:
    continue
  c1=a+b-x
  c+=c1
  if b>=c1:
    l[i+1]-=c1
  else:
    l[i]-=c1-b
    l[i+1]=0
print(c)

Measured memory_bytes: 14052
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Azhan Khan
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EKnapsack2 solver = new EKnapsack2();
        solver.solve(1, in, out);
        out.close();
    }

    static class EKnapsack2 {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            long w = in.nextLong();

            long[] weights = new long[n];
            int[] values = new int[n];

            for (int i = 0; i < n; i++) {
                weights[i] = in.nextLong();
                values[i] = in.nextInt();
            }

            long[] dp = new long[n * 1000 + 1];     //dp[j] = min weight to get value of J
            Arrays.fill(dp, w + 1);
            dp[0] = 0;
            for (int i = 0; i < n; i++) {
                for (int j = n * 1000; j >= values[i]; j--) {
                    dp[j] = Math.min(dp[j], dp[j - values[i]] + weights[i]);
                }
            }
            //out.println(Arrays.toString(dp));
            long ans = 0;
            for (int i = 0; i <= n * 1000; i++) {
                if (dp[i] <= w) {
                    ans = i;
                }
            }
            out.print(ans);

        }

    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}



Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

map<int,int> ma;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n; cin>>n;
	for(int i=0;i<n;i++){int x; cin>>x; ma[x]++;}
	int m; cin>>m;
	for(int i=0;i<m;i++)
	{
		int x; cin>>x;
		ma[x]--;
		if(ma[x]<0)
		{
			cout<<"NO\n";
			return 0;
		}
	}
	cout<<"YES\n";
}


Measured memory_bytes: 9600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());

		ArrayList<Pair> list = new ArrayList<>();
		for (int i = 0; i < n; i++) {
			String str[] = br.readLine().split(" ");

			long x = Long.parseLong(str[0]);
			long l = Long.parseLong(str[1]);

			list.add(new Pair(x, l));
		}

		Collections.sort(list);

		long now = Long.MIN_VALUE;
		int ans = 0;

		for (int i = 0; i < n; i++) {
			if (now > list.get(i).left) {
				continue;
			}
			ans++;
			now = list.get(i).right;
		}

		System.out.println(ans);
	}
}

class Pair implements Comparable<Pair> {
	long left;
	long right;

	public Pair(long x, long l) {
		left = x - l;
		right = x + l;
	}

	@Override
	public int compareTo(Pair p) {
		return Long.compare(this.right, p.right);
	}
}

Measured memory_bytes: 60400
s = input()
t = input()

def solve(S, T):
    L1 = len(S)
    L2 = len(T)
    dp = [[0]*(L2+1) for i in range(L1+1)]

    for i in range(L1-1, -1, -1):
        for j in range(L2-1, -1, -1):
            r = max(dp[i+1][j], dp[i][j+1])
            if S[i] == T[j]:
                r = max(r, dp[i+1][j+1] + 1)
            dp[i][j] = r

    # dp[0][0] が長さの解

    # ここからは復元処理
    res = []
    i = 0; j = 0
    while i < L1 and j < L2:
        if S[i] == T[j]:
            res.append(S[i])
            i += 1; j += 1
        elif dp[i][j] == dp[i+1][j]:
            i += 1
        elif dp[i][j] == dp[i][j+1]:
            j += 1
    return "".join(res)

print(solve(s,t))

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

void dfs(int);
void visit(int, int);

int time, d[N], f[N], color[N], list[N][N];

int main(){
  int n, i, j, k, u, v;

  scanf("%d", &n);

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      list[i][j] = 0;
    }
  }

  for(i = 1; i <= n; i++){
    scanf("%d%d", &u, &k);
    for(k; k > 0; k--){
      scanf("%d", &v);
      list[u][v] = 1;
    }
  }

  dfs(n);

  for(i = 1; i <= n; i++){
    printf("%d %d %d\n", i, d[i], f[i]);
  }
  
  return 0;
}

void dfs(int n){
  int i;
  for(i = 1; i <= n; i++) color[i] = 0;
  for(i = 1; i <= n; i++){
    if(color[i] == 0) visit(i, n);
  }
}

void visit(int r, int n){
  int i;

  color[r] = 1;
  d[r] = ++time;
  for(i = 1; i <= n; i++){
    if(list[r][i] == 1 && color[i] == 0)
      visit(i, n);
  }
  color[r] = 2;
  f[r] = ++time;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
const int mod = 1000000007;
struct mint {
ll x;
mint(ll 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 pow(ll t) const {
if (!t) return 1;
mint a = pow(t>>1);
a *= a;
if (t&1) a *= *this;
return a;
}
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;
}
};
int main(){
    ll n,k;cin>>n>>k;
    mint ans=0;
    for(ll i=k;i<=n+1;i++){
        ll l=(i*(i-1))/2;
        ll r=(n*i)-l;
        ans+=r-l+1;
    }
    cout<<ans.x<<endl;
}

Measured memory_bytes: 3632
def main():
    n = int(input())
    weight = [int(x) for x in input().split()]

    l_sum = [0] * (n+1)

    for i in range(n):
        l_sum[i+1] = (l_sum[i] + weight[i])

    min_abs = float('inf')

    for j in range(1, n):
        tmp = abs(l_sum[n] - 2 * l_sum[j])
        if tmp <= min_abs:
            min_abs = tmp

    print(min_abs)


if __name__ == "__main__":
    main()


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

bool ispa(int now) {
	char A[100];
	sprintf(A, "%d", now);
	int n = strlen(A);
	for(int i = 0; i < n; ++i) {
		if(A[i] != A[n-i-1]) return false;
	}
	return true;
}

int main() {
	#ifdef INPUT
	freopen("r", "r", stdin);
	#endif
	int a, b, cnt = 0;
	scanf("%d %d", &a, &b);
	for(int i = a; i <= b; ++i) {
		cnt += ispa(i);
	}
	printf("%d\n", cnt);
}

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

int main(){
    unsigned long N;
    cin >> N;
    vector<long long> A(N), B(N);
    for(auto &i : A)cin >> i;
    transform(A.cbegin(), A.cend(), B.begin(), [](auto a){return max(a, -a);});
    cout << accumulate(B.cbegin(), B.cend(), 0L) -
            (1 & count_if(A.cbegin(), A.cend(), [](auto a){return a < 0;}) ? *min_element(B.cbegin(), B.cend()) * 2 : 0) << endl;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P> Q;

ll n, m, h, a, b, c;
P p[200];
Q d[40000];
bool ok[200];

class UF {
public:
  ll par[200], depth[200];
  UF() {
    for (ll i = 0; i < n; i++) par[i] = i, depth[i] = 0;
  }
  void clear() {
    for (ll i = 0; i < n; i++) par[i] = i, depth[i] = 0;
  }
  ll find(ll x) { return x == par[x] ? x : par[x] = find(par[x]); }
  void merge(ll x, ll y) {
    x = find(x), y = find(y);
    if (x == y) return;
    if (depth[x] < depth[y]) par[x] = y;
    else if (depth[x] > depth[y]) par[y] = x;
    else par[x] = y, depth[y]++;
  }
  bool same(ll x, ll y) { return find(x) == find(y); }
  void copy(const UF& uf) {
    for (ll i = 0; i < n; i++) par[i] = uf.par[i], depth[i] = uf.depth[i];
  }
};

int main() {
  while (scanf("%lld%lld", &n, &m), n) {
    for (ll i = 0; i < n; i++) scanf("%lld", &h), p[i] = P(h, i), ok[i] = false;
    sort(p, p+n, greater<P>());
    UF uf;
    for (ll i = 0; i < m; i++) {
      scanf("%lld%lld%lld", &a, &b, &c);
      a--; b--;
      d[i] = Q(c, P(a, b));
    }
    sort(d, d+m);
    ll ans = 0, counter = 0;
    for (ll i = 0; i < n; i++) {
      ll num = p[i].second;
      ok[num] = true;
      if (i == n-1 || p[i].first != p[i+1].first) {
        ll tempans = 0, tempcounter = 0;
        for (ll j = 0; j < m; j++) {
          Q q = d[j];
          ll from = q.second.first, to = q.second.second;
          if (ok[from] && ok[to] && !uf.same(from, to)) {
            uf.merge(from, to);
            tempans += q.first;
            tempcounter++;
          }
        }
        if (counter + tempcounter == i) {
          ans += tempans;
          counter += tempcounter;
        } else uf.clear(), ans = counter = 0;
      }
    }
    printf("%lld\n", ans);
  }
}



Measured memory_bytes: 3208
# Author: cr4zjh0bp
# Created: Thu Mar 12 07:37:08 UTC 2020
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda y: [ni() for _ in range(y)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda y: [na() for _ in range(y)]
nf = lambda: float(ns())
nfn = lambda y: [nf() for _ in range(y)]
nfa = lambda: list(map(float, stdin.readline().split()))
nfan = lambda y: [nfa() for _ in range(y)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda y: [ns() for _ in range(y)]
ncl = lambda y: [list(ns()) for _ in range(y)]
nas = lambda: stdin.readline().split()

def gcd(m, n):
    if n == 0:
        return m
    else:
        return gcd(n, m % n)

def lcm(m, n):
    return m * n // gcd(m, n)

N = ni()
print(lcm(2, N))

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

int main() {
	// your code goes here
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	sort(a,a+n,greater<int>());
	int count=0;
	for(int i=0;i<n;i++){
		if(i%2==0){
			count=count+a[i];
		}
		else count=count-a[i];
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  string s,t; 
  cin >> s >> t;
  int cnt = 0;
  for(int i = 0; i < 3; i++) {
    if(s[i] == t[i]) cnt++;
  }
  cout << cnt << endl;
}


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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (int i = 1; i <= N; i++)

using ll = long long;
using namespace std;

int main(){
    int N,index;
    //char S[4010];
    int ans=0;
    //char s[200];
    //vector<int> a(N,0);

    cin >> N;
    vector<int> A(N,0);
    rep(i,N) cin >> A[i];

    vector<int>::iterator It = max_element(A.begin(),A.end());
    ans = *It;
    index = distance(A.begin(),It);

    sort(A.begin(),A.end(),std::greater<int>());

    rep(i,N){
        if(i!=index) cout << ans << endl;
        else cout << A.at(1) << endl;
    }
    //cout << ( (ans) ? "Yes" : "No" ) << endl;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
 
using namespace std;
 
#define send {ios_base::sync_with_stdio(false);}
#define help {cin.tie(NULL); cout.tie(NULL);}
#define f first
#define s second
#define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());}
typedef long long ll;
typedef long double lld;
typedef unsigned long long ull;
 
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { return cout << "(" << p.f << ", " << p.s << ")"; }
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
	cout << "["; for(int i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
	cin >> p.first;
	return cin >> p.second;
}
 
mt19937 rng(std::chrono::steady_clock::now().time_since_epoch().count());
// mt19937 rng(61378913);
/* usage - just do rng() */
 
void usaco(string filename) {
  // #pragma message("be careful, freopen may be wrong")
	freopen((filename + ".in").c_str(), "r", stdin);
	freopen((filename + ".out").c_str(), "w", stdout);
}
 
const lld pi = 3.14159265358979323846;
const ll mod = 1000000007;
// const ll mod = 998244353;
// ll mod;
 

 
ll n, m, k, q, l, r, x, y, z;
const ll template_array_size = 1e6 + 1389;
ll a[template_array_size];
ll b[template_array_size];
ll c[template_array_size];
string s, t;
ll ans = 0;
 

 
void solve(int tc = 0) {
	ll dp[2005] = {0};
	dp[0] = 1;
	
	cin >> n;
	for (ll i = 0; i < n; i++) {
		for (ll j = i + 3; j <= n; j++) {
			dp[j] = (dp[j] + dp[i]) % mod;
		}
	}
	
	cout << dp[n] << '\n';
}
 
int main() {
	#ifdef galen_colin_local
		auto begin = std::chrono::high_resolution_clock::now();
	#endif
	
	send help
 
	#ifndef galen_colin_local
		// usaco("moop");
	#endif
	
	// usaco("cowland");
	
	// freopen("tc.cpp", "r", stdin);
 
	int tc = 1;
	// cin >> tc;
	for (int t = 0; t < tc; t++) solve(t);
	
	#ifdef galen_colin_local
		auto end = std::chrono::high_resolution_clock::now();
		cout << setprecision(4) << fixed;
		// cout << "Execution time: " << std::chrono::duration_cast<std::chrono::duration<double>>(end - begin).count() << " seconds" << endl;
	#endif
} 


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

using namespace std;

struct Edge{
	int to;
};

vector<vector<int>> List_to_Mat(vector<vector<Edge>>& G){
	int V = G.size();
	vector<vector<int>> result;
	result = vector<vector<int>>(V, vector<int>(V, 0));

	for(int i = 0; i < V; i++){
		for(int j = 0; j < G[i].size(); j++){
			int v = G[i][j].to;
			result[i][v - 1] += 1;
		}
	}
	return result;
}


int main(void)
{
	int V;
	cin >> V;

	vector<vector<Edge>> AdjList(V);
	for(int i = 0; i < V; i++){
		int u, k;
		cin >> u >> k;
		for(int j = 0; j < k; j++){
			int v;
			cin >> v;
			AdjList[i].push_back(Edge{v});	
		}
	}

	vector<vector<int>> AdjMat = List_to_Mat(AdjList);
	for(int i = 0; i < V; i++){
		for(int j = 0; j < V; j++){
			if(j != V - 1)
				cout << AdjMat[i][j] << " ";
			else
				cout << AdjMat[i][j] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3120
#include <stdio.h>
#include <string.h>

char dict[30600000];

long encode(const char *key){
  int n=strlen(key),i;
  long sum=0;
  long keta=1;
  for(i=0;i<n;i++){
    if (key[i]=='A')      sum = sum + keta;
    else if (key[i]=='C') sum = sum + (keta << 1);
    else if (key[i]=='G') sum = sum + (keta << 1) + keta;
    else if (key[i]=='T') sum = sum + (keta << 2);
    keta=(keta<<2)+keta;
  }
  return (sum);
}

void insert(const char *key2) {
  long key=encode(key2);
  long keta=key/8;
  dict[keta]=(dict[keta]|(1<<(key%8)));
}

int find_h(const char *key2) {
  long key=encode(key2);
  return (dict[key/8] & 1<<(key%8));
}

int main(void) {
  long n,i;
  scanf("%ld\n",&n);
  for(i=0;i<n;i++){
    char cmd[8], str[14]; scanf("%s %s\n",cmd, str);
    if(cmd[0]=='i') {
      insert(str);
    }
    else {
      if(find_h(str)) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}

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

int main() {
  int n, a, b, c, d;
  string s;
  cin >> n >> a >> b >> c >> d;
  cin >> s;

  s[a-1] = 'a';
  s[b-1] = 'b';
  s[c-1] = 'c';
  s[d-1] = 'd';
  int ct = 0;
  bool as, bs, cs, ds;
  as = bs = cs = ds = true;
  for ( int i = a-1; i < c; i++ ) {
    if ( s[i] == '#' ) {
      ct++;
    } else {
      ct = 0;
    }
    if ( ct == 2 ) { cout << "No" << endl; return 0; }
  }
  ct = 0;
  for ( int i = b-1; i < d; i++ ) {
    if ( s[i] == '#' ) {
      ct++;
    } else {
      ct = 0;
    }
    if ( ct == 2 ) { cout << "No" << endl; return 0; }
  }
  ct = 0;
  for ( int i = a-1; i < c; i++ ) {
    if ( s[i] == '#' || s[i] == 'b' ) {
      ct++;
    } else {
      ct = 0;
    }
    if ( ct == 2 ) { as = false; break; }
  }
  ct = 0;
  for ( int i = a-1; i < c; i++ ) {
    if ( s[i] == '#' || s[i] == 'd' ) {
      ct++;
    } else {
      ct = 0;
    }
    if ( ct == 2 ) { ds = false; break; }
  }
  ct = 0;
  for ( int i = b-1; i < d; i++ ) {
    if ( s[i] == '#' || s[i] == 'a' ) {
      ct++;
    } else {
      ct = 0;
    }
    if ( ct == 2 ) { bs = false; break; }
  }
  ct = 0;
  for ( int i = b-1; i < d; i++ ) {
    if ( s[i] == '#' || s[i] == 'c' ) {
      ct++;
    } else {
      ct = 0;
    }
    if ( ct == 2 ) { cs = false; break; }
  }

  s[a-1] = s[b-1] = s[c-1] = s[d-1] = '.';
  if ( (!as) && (!ds) ) {
    ct = 0;
    for ( int i = b-1; i < d; i++ ) {
      if ( s[i] == '.' ) {
        ct++;
        if ( ct == 3 ) { break; }
      } else {
        ct = 0;
      }
    }
    if ( ct != 3 ) { cout << "No" << endl; return 0; }
  }
  if ( (!bs) && (!cs) ) {
    ct = 0;
    for ( int i = a-1; i < c; i++ ) {
      if ( s[i] == '.' ) {
        ct++;
        if ( ct == 3 ) { break; }
      } else {
        ct = 0;
      }
    }
    if ( ct != 3 ) { cout << "No" << endl; return 0; }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

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

  long long K;
  cin >> K;

  char result;
  int length = S.size();
  if(K < length){
    length = K;
  }

  for(int i=0;i<length;i++){
    result = S[i];
    if(result != '1'){
      break;
    }
  }

  cout << result << endl;
  return 0;
}


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

using namespace std;

int main()
{
    double r,l,S;

    cin>>r;

    l = 2 * r * M_PI;

    S = r * r * M_PI;

    cout<<fixed<<setprecision(6)<<S<<' '<<l<<'\n';


}


Measured memory_bytes: 3284
#include <stdio.h>

#define MAX 1000000

int partition(int *, int, int);

int main(){

  int n, i, j, A[MAX];

  scanf("%d", &n);

  for(i = 0; i < n; i++) scanf("%d", &A[i]); 
  
  j = partition(A, 0, n-1);
 
  for(i = 0; i < j; i++){
    printf("%d", A[i]);
    if(i != n) printf(" ");
  }
  
  printf("[%d] ", A[j]);
  
  for(i = j+1; i < n; i++){
    printf("%d", A[i]);
    if(i != n-1) printf(" ");
  }

  printf("\n");
  
  return 0;
}

int partition(int *A, int p, int r){

  int i, j, x, y;

  x = A[r];
  i = p - 1;
  
  for(j = p; j < r; j++){
    if(A[j] <= x){
      
      i++;
   
      y = A[i];
      A[i] = A[j];
      A[j] = y;
    }
  }
  
  y = A[i+1];
  A[i+1] = A[r];
  A[r] = y;
  
  return i+1;
  
}

Measured memory_bytes: 1004
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
typedef pair<int, int> PI;
typedef vector<int> VI;
const LL MOD = 1000000007LL;
int main() {
	int N;
	cin >> N;
	map<int, int> cnt;
	rep(i, N) {
		int A;
		cin >> A;
		cnt[A]++;
	}
	int odd = 0, even = 0;
	for (auto e : cnt) {
		if (e.second % 2 == 1) odd++;
		else even++;
	}
	if (even % 2 == 0) {
		cout << odd + even << endl;
	}
	else {
		cout << odd + even - 1 << endl;
	}
}

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

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int k;
    string s;
    cin >> k;
    cin >> s;
    if(s.size()>k)
        cout << s.substr(0,k) + "...";
    else
        cout << s;
}


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

#define FOR(i, a, n) for(int i = (a); i < (n); i++)
#define REP(i, n) FOR(i, 0, (n))
#define ALL(a) (a.begin(), a.end())
typedef vector<int> vi;

int64_t h(const vector<vi> &t, int i, int p, vi &v) {
    int64_t res = 1;
    for (int c : t[i]) {
        if (c == p) continue;
        res += 1000000009 * h(t, c, i, v);
    }
    v[i] = res;
    return res;
}

int main() {
    int n;
    cin>>n;
    vector<vi> t(n);
    REP(i,n-1) {
        int a,b;
        cin>>a>>b;
        --a;
        --b;
        t[a].push_back(b);
        t[b].push_back(a);
    }
    vi v(n);
    h(t, 0, -1, v);
    map<int64_t, int> m;
    int64_t cnt = 0;
    REP(i,n) {
        cnt += m[v[i]];
        ++m[v[i]];
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 22624