akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <unordered_map>
#include <numeric>
#include <fstream>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)
int main(){
int a;
cin >>a;
if (a<1200) cout << "ABC";
else cout << "ARC";
    return 0;
}


Measured memory_bytes: 764
using System;
using System.Linq;

public class Program
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int[] d = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        Array.Sort(d);
        int ans = d[d.Length / 2] - d[d.Length / 2 - 1];
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 16864
def examC():
    sx, sy, tx, ty = LI()
    ans = ""
    k = 1
    for _ in range(2):
        if k==-1:
            ans = ans + "L"
            ty +=1; tx +=1

        for _ in range(ty - sy):
            ans = ans + "U"
        for _ in range(tx - sx):
            ans = ans + "R"
        k *= (-1)

        if k==1:
            ans = ans + "D"
            ans = ans + "R"

        for _ in range(ty - sy):
            ans = ans + "D"
        for _ in range(tx - sx):
            ans = ans + "L"

        if k==1:
            ans = ans + "U"
    print("".join(map(str,ans)))

import sys
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()

Measured memory_bytes: 3444
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> //Policy Based Data Structure
// using namespace __gnu_pbds;              //Policy Based Data Structure
using namespace std;
// typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds; //Policy Based Data Structure
// #define gc              getchar_unlocked
// #define pqb             priority_queue<int>
// #define pqs             priority_queue<int, vi, greater<int> >
// #define mk(arr,n,type)  type *arr = new type[n]
#define fo(i,n)         for(i=0;i<n;i++)
#define Fo(i,k,n)       for(i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define int             long long
#define endl            '\n'
#define w(t)            int t; cin>>t; while(t--)
#define deb(x)          cout << #x << "=" << x << endl
#define deb2(x,y)       cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb              push_back
#define mp              make_pair
#define F               first
#define S               second
#define all(x)          x.begin(), x.end()
#define clr(x)          memset(x, 0, sizeof(x))
#define sortall(x)      sort(all(x))
#define tr(it,a)        for(auto it = a.begin(); it != a.end(); it++)
#define ps(x,y)         fixed<<setprecision(y)<<x
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define PI              3.1415926535897932384626
#define inf             1e18
// mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());  //Random Shuffler
typedef pair<int, int>   pii;
typedef vector<int>     vi;
typedef vector<pii>     vpii;
typedef vector<vi>      vvi;
typedef map<int, int>    mii;
int mpow(int base, int exp);
void ipgraph(int m);
void dfs(int u, int par);
const int mod = 1000000007;
// const int N = 3e5, M = N;
// vi g[N];
//=======================


void sol()
{
	int k;
	cin >> k;
	for (int i = 0; i < k; i++)
	{
		cout << "ACL";

	}


}

int32_t main() {
	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

	sol();

	return 0;
}

int mpow(int base, int exp) {
	base %= mod;
	int result = 1;
	while (exp > 0) {
		if (exp & 1) result = (result * base) % mod;
		base = (base * base) % mod;
		exp >>= 1;
	}
	return result;
}

// void ipgraph(int n, int m){
//     int i, u, v;
//     while(m--){
//         cin>>u>>v;
//         g[u-1].pb(v-1);
//         g[v-1].pb(u-1);
//     }
// }
//
// void dfs(int u, int par){
//     for(int v:g[u]){
//         if (v == par) continue;
//         dfs(v, u);
//     }
// }

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pl;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define SHOW(x) cout << #x << ": " << x << endl;
template<class T> ll sumArr(const T& a){ return accumulate(all(a), 0LL);}
template<class T> auto minArr(const T& a){ return *min_element(all(a));}
template<class T> auto maxArr(const T& a){ return *max_element(all(a));}
template<class T> void DEBUG_PRINT(T tmp){cout<<tmp<<endl;}
template<class T1,class... T2> void DEBUG_PRINT(T1 tmp,T2... tmp2){cout<<tmp<<" ";DEBUG_PRINT(tmp2...);}
ll gcd(ll a, ll b){ while(b){ ll c = b; b = a % b; a = c; } return a; }
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a / gcd(a, b) * b; }
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    ll x,y,a,b,c,sum = 0;

    cin>>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b<<endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int,input().split()))
D = {}
p = 0
for i in range(N) :
    if L[i] < 400 :
        color = 0
    elif L[i] < 800 :
        color = 1
    elif L[i] < 1200 :
        color = 2
    elif L[i] < 1600 :
        color = 3
    elif L[i] < 2000 :
        color = 4
    elif L[i] < 2400 :
        color = 5
    elif L[i] < 2800 :
        color = 6
    elif L[i] < 3200 :
        color = 7
    else :
        p += 1
    if L[i] < 3200 :
        if color not in D :
            D[color] = 1
        else :
            D[color] += 1
ans1 = len(list(D.keys()))
q = 0
if ans1 == 0 :
    ans1 = 1
    q = 1
ans2 = ans1 + p - q
print(ans1,ans2)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    while(m--){
        int a;
        cin>>a;
        n-=a;
        if(n<0){
            cout<<-1;
            return 0;
        }
    }
    cout<<n;
    return 0;
}


Measured memory_bytes: 3644
#pragma GCC optimize "O3"

#include<bits/stdc++.h>

using namespace std;

constexpr int N = 20;

int n, ans;
string tmp, ans_rev;
vector<string> words[N+1], cands[N+1];
//vector<bool> vis[N+1];

void init() {
  for(int i = 0; i<=N; ++i)
    words[i].clear(), cands[i].clear();//, vis[i].clear();
  ans = 0;
}
bool valid(const string &tar, const string &s, string &rev) {
  assert(s.size() == tar.size());
  for(size_t i = 0; i<s.size(); ++i) {
    if(rev[s[i]] != -1 && rev[s[i]] != tar[i])
      return false;
    if(rev[tar[i]] != -1 && rev[tar[i]] != s[i])
      return false;
    if(rev[s[i]] == -1 && rev[tar[i]] != -1)
      return false;
    if(rev[tar[i]] == -1 && rev[s[i]] != -1)
      return false;
  }
  return true;
}
void dfs(int l, size_t x, string rev) {
  if(ans > 1)
    return;
  while(l && x >= words[l].size()) {
    x = 0;
    --l;
  }
  if(l == 0) {
    ans_rev = rev;
    //cerr << "here" << endl;
    //for(auto c : ans_rev) {
    //  cerr << int(c) << endl;
    //  if(c != -1) {
    //    cerr << char(c+'A') << " " << char(ans_rev[c]+'A') << endl;
    //    assert(c == ans_rev[ans_rev[c]]);
    //  }
    //}
    ++ans;
    return;
  }
  const string &tar = words[l][x];
  for(size_t j = 0; j<cands[l].size(); ++j) {
    //if(vis[l][j])
    //  continue;
    const string &s = cands[l][j];
    if(valid(tar, s, rev)) {
      string nrev = rev;
      for(size_t i = 0; i<s.size(); ++i)
        if(nrev[s[i]] == -1) {
          nrev[s[i]] = tar[i];
          nrev[tar[i]] = s[i];
        }
      //vis[l][j] = true;
      dfs(l, x+1, nrev);
      //vis[l][j] = false;
    }
  }
}
void cleanup(vector<string> &v) {
  sort(v.begin(), v.end());
  v.resize(unique(v.begin(), v.end()) - v.begin());
}
void solve() {
  init();
  for(int i = 0; i<n; ++i) {
    cin >> tmp;
    for_each(tmp.begin(), tmp.end(), [](char &c) { c -= 'A'; });
    cands[tmp.size()].push_back(tmp);
  }
  //for(int i = 0; i<=N; ++i)
  //  vis[i].resize(cands[i].size());
  vector<string> sent;
  bool cont = true;
  while(cont) {
    cin >> tmp;
    if(tmp.back() == '.') {
      tmp.pop_back();
      cont = false;
    }
    sent.push_back(tmp);
    for_each(tmp.begin(), tmp.end(), [](char &c) { c -= 'A'; });
    words[tmp.size()].push_back(tmp);
  }
  for(int i = 0; i<=N; ++i)
    cleanup(words[i]);
  dfs(N, 0, string(26, -1));
  assert(ans > 0);
  if(ans == 1) {
    for(size_t i = 0; i<sent.size(); ++i) {
      for(auto c : sent[i]) {
        assert(ans_rev[c - 'A'] != -1);
        putchar(ans_rev[c - 'A'] + 'A');
      }
      putchar(i+1 == sent.size() ? '.' : ' ');
    }
    puts("");
  } else
    puts("-.");
}
int main() {
  while(scanf("%d", &n) == 1 && n)
    solve();
}

Measured memory_bytes: 3164
#include<iostream>
using namespace std;
int main()
{
	int n, m;
	cin >> n >> m;
	int a[100][100], b[100];
	for(int i = 0;i < n;i++)
	{
		for(int j = 0;j < m;j++)
		{
			cin >> a[i][j];
		}
	}
	for(int i = 0;i < m;i++)
	{
		cin >> b[i];
	}
	int sum;
	for(int i = 0;i < n;i++)
	{
		sum = 0;
		for(int j = 0;j < m;j++)
		{
			sum += a[i][j] * b[j];
		}
		cout << sum << endl;
	}

	return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define scanVec(vec , n) for(int i = 0; i < n ; i++){ cin>>vec[i];} 
#define printVec(vec , n) for(int i = 0; i < n ; i++){ cout<<vec[i]<<" ";} cout<<endl;
#define S second
#define F first
#define SZ(x) (int)x.size()
typedef long long ll;
typedef long double ld;
const int  MOD = 1e9 + 7;
const int  N = 1e6 + 7;

void solve(){
    int h , n , a;
    cin>>h>>n;
    for(int i = 0 ; i < n ; i++){
        cin>>a;
        h -= a;
    }
    if(h <= 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}	
 
int main(){
    ios::sync_with_stdio(0);  cin.tie(0); cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
S = input()
S1 = S[0::2]
S2 = S[1::2]

S1white = S1.count("1")  # 黒にしなければいけない個数
S2white = S2.count("1")

print(min(S1white + len(S2) - S2white, len(S1) - S1white + S2white))


Measured memory_bytes: 3188
a = int(input())
list1 = []
for i in range(9):
  for j in range(9):
    list1.append((i+1)*(j+1))
b = len(list1)
flag = 0
for k in range(b):
  if a == list1[k]:
    flag = 1
    break;
if flag == 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
from fractions import gcd
from functools import reduce
N, M = map(int, input().split())
A = list(map(int, input().split()))
AA = list(map(lambda x: x//2, A))
def lcm(x, y):
    return x * y // gcd(x, y)
b0 = AA[0]&-AA[0]
for a in AA[1:]:
    if b0 != a&-a:
        print(0)
        break
else:
    a = reduce(lcm, AA)
    print(M//a - M//(2*a))

Measured memory_bytes: 16344
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))


def main():
    a = LI()

    return sum(a) - max(a)


print(main())



Measured memory_bytes: 5080
# エラトステネスを素因数分解とlcm


N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7

def inverse(a): #aに対し、a**(mod-2)、つまり逆元を返す
  T=[a]
  while 2**(len(T))<mod: #a**1,a**2.a**4,a**8,...を計算しておく
      T.append(T[-1]**2%mod)
  b=bin(mod-2) #mod-2を2進数表記にする
  ans=1
  for i in range(len(b)-2):
      if int(b[-i-1])==1:
          ans=ans*T[i]%mod
  return ans

def eratosthenes(n): #エラストテネスの篩(最大の素因数を格納した配列)
    A = [0] * n
    A[0], A[1] = -1, -1
    for i in range(2, n):
      if A[i] == 0:
        j = i
        while j < n:
          A[j] = i
          j += i
    return A

E = eratosthenes(10**6+5)
l = {}

for a in A:
  now = a
  f = [] #素因数格納配列

  while now > 1:
    f.append(E[now])
    now //= E[now]

  chk = 0 

  for p in f:
    if chk == p: #同じ素因数が複数あるときに飛ばす
      continue
    chk = p
    if p in l.keys(): #辞書に素因数がある場合、個数の多いほう
      l[p] = max(l[p], f.count(p))
    else: #辞書にない場合新規追加
      l[p] = f.count(p)
 
lcm = 1
for k in l:
  for i in range(l[k]):
      lcm= lcm * k % mod

s = 0
for i in range(N):
    s += lcm * inverse(A[i]) % mod
    s %= mod
print(s)

Measured memory_bytes: 14476
import java.util.Scanner;

/**
 * https://abc048.contest.atcoder.jp/tasks/arc064_b
 */
public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		sc.close();
		
		String ans = null;
		if(s[0]==s[s.length-1]){
			ans = s.length%2==1 ? "Second" : "First";
		}else{
			ans = s.length%2==0 ? "Second" : "First";
		}
		
		System.out.println(ans);

	}

}

Measured memory_bytes: 27604
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll X, N;
  cin >> X >> N;
  vl M(505, 0);
  REP(i, N) {
    ll p;
    cin >> p;
    M[p + 100] = 1;
  }

  ll dist = 101;
  ll ans = 0;
  FOR(x, -100, 202) {
    if (M[x + 100] == 0 && abs(x - X) < dist) {
      dist = abs(x - X);
      ans = x;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3656
n,m = STDIN.gets.strip.split.map(&:to_i)

fav = Array.new(35) { 0 }

n.times do
  aa = STDIN.gets.strip.split.map(&:to_i)
  k = aa.shift
  for a in aa
    fav[a]+=1
  end
end

ans = 0
for i in 0..35
  ans += 1 if fav[i] == n
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, m;
  cin >> n >> m;

  ll x = min(n, m / 2);
  n -= x;
  m -= 2 * x;

  if (m > 1) {
    x += m / 4;
  }

  cout << x << endl;
}

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

using namespace std;

#define boost ios::sync_with_stdio(0);cin.tie(0);
#define forn(i,n) for ( int i=0 ; i < n ; i++ )
#define all(a) (a).begin(), (a).end()
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ll long long
#define endl '\n'
#define mod 1000000007

#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void ZZ(const char* name, Arg1&& arg1){std::cerr << name << " = " << arg1 << endl;}
template <typename Arg1, typename... Args>void ZZ(const char* names, Arg1&& arg1, Args&&... args)
{
	const char* comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}

int n;
const int N = 100022;
vector<vector<int> > graph(N);
int paro[N];
int level[N];
int vis[N];

void dfs(int node){
	int here = 0;
	int via = 0;
	for(auto it:graph[node]){
		if(vis[it]==0) dfs(it);
		if(level[it]>here){
			here = level[it];
			via = it;
		}
	}	
	level[node] = here+1;
	paro[node] = via;
	vis[node] = 1;
	return ;
}

int main()
{
	//freopen ("f.in","r",stdin);
 	//freopen ("f.out","w",stdout);
	boost
	//code
	cin >> n;
	int m;
	cin >> m;
	m += n-1;
	map<int,int> mp;
	while(m--){
		int a,b;
		cin >> a >> b;
		graph[b].PB(a);
		mp[b]++;
	}
	forn(i,n) level[i+1] = -1;
	int root = -1;
	forn(i,n) if(mp.count(i+1)){} else root = i+1;
	paro[root] = 0;
	level[root] = 1;
	vis[root] = 1;
	forn(i,n){
		if(vis[i+1]) continue;
		dfs(i+1);
	}
	forn(i,n) cout << paro[i+1] << endl;
		return 0;
}

Measured memory_bytes: 17152
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,T = MI()
	max_T = -1
	dish = []
	for i in range(N):
		A,B = MI()
		dish.append([A,B])
		dish.sort(key=lambda x : x[0])
		max_T = max(max_T, A)

	dp=[-1 for _ in range(T+max_T)]
	dp[0] = 0
	for i in range(N):
		for j in range(T-1, -1, -1):
			if(dp[j]>=0):
				dp[j+dish[i][0]] = max(dp[j+dish[i][0]], dp[j]+dish[i][1])
	print(max(dp))
main()

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

using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using pint = pair<int, int>;
#define repi(n) for (int i = 0; i < n; i++)
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
#define repv(itr) for (auto&& v : itr)

const int dx[] = {-1, 0, 0, 1, -1, -1, 1, 1};
const int dy[] = {0, -1, 1, 0, -1, 1, -1, 1};
template <typename T>
T minptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i < *re) re = i;
  }
  return re;
}
template <typename T>
T maxptr(T begin, T end) {
  T re = begin;
  for (T i = begin + 1; i != end; i++) {
    if (*i > *re) re = i;
  }
  return re;
}
int __vmax(int x) {
  return INT_MAX;
}
double __vmax(double x) {
  return 1e+300;
}
ll __vmax(ll x) {
  return LLONG_MAX;
}
int __vmin(int x) {
  return INT_MIN;
}
double __vmin(double x) {
  return -1e+300;
}
ll __vmin(ll x) {
  return LLONG_MIN;
}
template <typename T>
vector<T> lis(T begin, T end, bool allowequal = false, bool lds = false) {
  using V = typename iterator_traits<T>::value_type;
  int n = end - begin;
  vector<V> a(n, lds ? __vmin(*begin) : __vmax(*begin));
  vector<int> id(n);
  if (lds && allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (lower_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (lds) {
    for (int i = 0; i < n; i++) {
      id[i] = n - 1 -
              (upper_bound(a.rbegin(), a.rend(), begin[i]) - 1 - a.rbegin());
      a[id[i]] = begin[i];
    }
  } else if (allowequal) {
    for (int i = 0; i < n; i++) {
      id[i] = upper_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  } else {
    for (int i = 0; i < n; i++) {
      id[i] = lower_bound(a.begin(), a.end(), begin[i]) - a.begin();
      a[id[i]] = begin[i];
    }
  }
  int m = *maxptr(id.begin(), id.end());
  vector<T> re(m + 1);
  for (int i = n - 1; i >= 0; i--) {
    if (id[i] == m) re[m--] = begin + i;
  }
  return re;
}
// class segtree {
//  private:
//   int n;
//   bool maxmode;
//   vint* data;
//   void update(int i) {
//     (*data)[i] = maxmode ? max((*data)[i * 2 + 1], (*data)[i * 2 + 2])
//                          : min((*data)[i * 2 + 1], (*data)[i * 2 + 2]);
//     if (i) update((i - 1) / 2);
//   }

//  public:
//   segtree(int n_, bool maxmode_ = false) {
//     n = pow(2, ceil(log2(n_)));
//     cout << n << endl;
//     maxmode = maxmode_;
//     data = new vint(n * 2 - 1, maxmode ? INT_MIN : INT_MAX);
//   }
//   ~segtree() { delete data; }
//   void set(int i, int v) {
//     (*data)[n - 1 + i] = v;
//     if (n) update((n + i - 2) / 2);
//   }
//   int calc(int a, int b) {
//     // TODO
//     return 0;
//   }
// };

ll a[100001], b[100000];
int main() {
  int n;
  cin >> n;
  repi(n + 1) cin >> a[i];
  repi(n) cin >> b[i];
  ll re = 0;
  repi(n) {
    ll x = min(a[i], b[i]);
    re += x;
    a[i] -= x;
    b[i] -= x;
    x = min(a[i + 1], b[i]);
    re += x;
    a[i + 1] -= x;
    b[i] -= x;
  }
  cout << re << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll n; cin >> n;
    string s; cin >> s;
    vll r, g, b;
    rep(i, s.size()) {
        if (s[i] == 'R') r.push_back(i);
        if (s[i] == 'G') g.push_back(i);
        if (s[i] == 'B') b.push_back(i);
    }
    //for (auto elem : r) cout << elem << " "; cout << endl;
    //for (auto elem : g) cout << elem << " "; cout << endl;
    //for (auto elem : b) cout << elem << " "; cout << endl;

    ll sum = 0;
    rep(i, r.size()) {
        rep(j, g.size()) {
            sum += b.size();
            if (r[i] < g[j]) {
                ll diff = g[j] - r[i];
                ll low = r[i] - (diff);
                if (0 <= low && s[low] == 'B') sum--;

                ll high = g[j] + diff;
                if (high < n && s[high] == 'B') sum--;

                ll middle = (r[i] + diff / 2);
                if (diff % 2 == 0 && s[middle] == 'B') sum--;
            } else {
                ll diff = r[i] - g[j];
                ll low = g[j] - diff;
                if (0 <= low && s[low] == 'B') sum--;

                ll high = r[i] + diff;
                if (high < n && s[high] == 'B') sum--;

                ll middle = (g[j] + diff / 2);
                if (diff % 2 == 0 && s[middle] == 'B') sum--;
            }
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
#define ll long long
vector<int> f(int x){
	vector<int> bb;
	while(x){
		bb.push_back(x%10);
		x/=10;
	}
	reverse(bb.begin(),bb.end());
	return bb;
}
int main(){
	int t; t=1;
	while(t--){
	   ll a,b,c; cin>>a>>b>>c;
	   ll k; cin>>k;
	   int flag=0;
	   ll cc=c*(ll)pow(2,k);
	   if(a<b&&b<cc)flag=1;
	   for(int i=10;i<100;++i){
	   	vector<int> ff=f(i);
	   	int sum=0;
	   	for(auto x: ff)sum+=x;
	   	if(sum!=k)continue;
	    ll bx=b*(ll)pow(2,ff[0]);
	    ll cx=c*(ll)pow(2,ff[1]);
	    if(a<bx&&bx<cx)flag=1;
	    if(flag)break;
	   }
	   for(int i=100;i<=700;++i){
	   	vector<int> bb=f(i);
	   	int sum=0;
	   	for(auto x: bb)sum+=x;
	   	if(sum!=k)continue;
        ll ax=a*(ll)pow(2,bb[0]);
	    ll bx=b*(ll)pow(2,bb[1]);
	    ll cx=c*(ll)pow(2,bb[2]);
	    if(ax<bx&&cx>bx)flag=1;
	    if(flag)break;
	    if(flag){
	    	cout<<i<<endl;
	    }
	   }
	   if(flag)cout<<"Yes";
	   else cout<<"No";
	}
}

Measured memory_bytes: 4068
#include <bits/stdc++.h>
//#include <atcoder/all>
#define rep(i, n) for (int i=0; i < (n); i++)
using namespace std;
//using namespace atcoder;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int NIL = -1;
const int MAX = 10000;
const int MOD = 1000000007;
const double pi = 3.141592653589;

int main() {
    int n, k;
    cin >> n >> k;
    int a[n];
    rep(i,n) cin >> a[i];
    int count = 0;
    if(k >= n) cout << 1 << endl;
    else{
        n -= k;
        count++;
        count += n / (k-1);
        if(n % (k-1) != 0)count++;
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3912
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;



int main()
{
    int n;
    scanf("%d",&n);
    n=n%1000;
    if(n==0)
    {
        n=1000;
    }
    n=1000-n;

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


    return 0;
}

Measured memory_bytes: 1736
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <numeric>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<((x))<<endl
#define fi first
#define se second

#define INF 2147483600
#define long long long

class UnionFind {
public:
  vector<int> par, rank; // parent(negative := its root and abs-value is its size), depth
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;  // already belong to same tree
    if(rank[x] < rank[y]){  // y becomes parent node
      par[y] += par[x];
      par[x] = y;
    } else {  // x becomes parent node
      par[x] += par[y];
      par[y] = x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int size(int x){ return -par[find(x)]; }
}; // END class UnionFind

int main(){
  int n,k,l;
  cin>>n>>k>>l;

  UnionFind uk(n), ul(n);

  rep(i,k){
    int a,b;
    scanf("%d %d", &a, &b);
    a--;b--;
    uk.unite(a,b);
  }
  rep(i,l){
    int a,b;
    scanf("%d %d", &a, &b);
    a--;b--;
    ul.unite(a,b);
  }

  map<long, int> m;
  rep(i,n){
    m[(long)uk.find(i)*n + ul.find(i)]++;
  }

  rep(i,n){
    printf("%d%c", m[(long)uk.find(i)*n + ul.find(i)], " \n"[i==n-1]);
  }


  return 0;
}


Measured memory_bytes: 15104
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>//STL vetor
#include <list>//STL list
#include <map>// STL map
#include <queue>// STL queue
#include <stack>//sTL stack
#include <bitset>
#include <algorithm>
using namespace std;

int main() {
    string str;
    cin>>str;
    for (auto ch : str) {
        char c = ch == '1' ? '9' : '1';
        cout<<c;
    }
    return 0;
}



Measured memory_bytes: 256
S = input()

# S = 'ATCODER'

ATGC = {'A': 'T', 'T': 'A', 'C': 'G', 'G': 'C'}

max = 0
cnt = 0
for i in S:
    if i in ATGC:
       cnt += 1
    else:
        cnt = 0

    if max < cnt:
        max = cnt
print(max)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int N = S.size();
  if(S[N - 1] == 's') {
    cout << S << "es" << endl;
  }
  else {
    cout << S << 's' << endl;
  }
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>
#include <climits>
#include <set>
#include <deque>
#include <queue>
#include <bitset>
#include <stack>

#define mod 1000000007
#define INF2 9999999999
#define INF (1<<30)
#define rep(i,n) for(int (i)=0; (i)<(n); (i)++)
#define P pair<int, int>

using namespace std;
using ll = long long;

int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};
int DX[] = {1, 1, 0, -1, -1, -1, 0, 1};
int DY[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct edge {int from, to, cost; };

void solve(){
    int n, m;
    map<string, int> ma;
    cin >> n;
    string s[n];
    rep(i, n){
        cin >> s[i];
        if(ma.find(s[i]) != ma.end()){
            ma[s[i]]++;
        }else{
            ma.insert(make_pair(s[i], 1));
        }
    } 

    cin >> m;
    string t[m];
    rep(i, m){
        cin >> t[i];
        if(ma.find(t[i]) != ma.end()){
            ma[t[i]]--;
        }else{
            ma.insert(make_pair(t[i], -1));
        }
    }

    int ans = 0;

    for(auto i = ma.begin(); i != ma.end(); i++){
        if(ans < i->second){
            ans = i->second;
        }
    }
    cout << ans << endl;
}

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


Measured memory_bytes: 256
fun main(args: Array<String>){
    val ramen :Int = 700
    var count :Int = 0
    val menu :String? = readLine()
    var sum :Int
    if(menu != null){
        //println(menu)
        for(i in menu.indices){
            //println(menu[i])
            //count = if(menu[i] == 'o') count.inc() else count.plusAssign()
            if(menu[i] == 'o'){
                count++
            }
            //println(count)
        }
        sum = ramen + 100*count
        println(sum)
    }
}



Measured memory_bytes: 33788
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

long yukuriddo(long a, long b) {
	if (a < b) swap(a, b);

	while (a % b > 0) {
		long c = a % b;
		a = b;
		b = c;
	}

	return b;
}

int main()
{
	long a, b;
	cin >> a >> b;
	vector<long> yakusuu;
	yakusuu.push_back(1);
	long pluss[] = { 2,4 };

	long max = yukuriddo(a, b);

	if (max % 2 == 0) {
		max /= 2;
		yakusuu.push_back(2);
		while (max % 2 == 0) max /= 2;
	}
	if (max % 3 == 0) {
		max /= 3;
		yakusuu.push_back(3);
		while (max % 3 == 0) max /= 3;
	}

	//遅いならこの式をどうにかしろ
	int ind = 1;
	bool f = false;
	for (long index = 5; max > 1; index += pluss[ind]) {
		f = true;
		if (sqrt(max) < index) break;
		ind = (ind + 1) % 2;
		if (max % index == 0) {
			max /= index;
			yakusuu.push_back(index);
			while (max % index == 0) max /= index;
		}
      		f = false;

	}

	if(f) yakusuu.push_back(max);

	cout << yakusuu.size() << endl;

}

Measured memory_bytes: 256
import fractions

[n, m] = list(map(int, input().split()))
s = input()
t = input()

flag = False
gcd = fractions.gcd(n, m)
lcm = n * m // gcd
if s[0] == t[0]:
    if gcd == 1:
        flag = True
    else:
        if s[::lcm//len(t)] == t[::lcm//len(s)]:
            flag = True
if flag:
    print(lcm)
else:
    print(-1)

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

typedef long long LL;
typedef long double LD;
typedef pair < int, int > PII;
typedef pair < LL, LL > PLL;
typedef pair < LD, LD > PDD;

#define _upgrade ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
template < typename _T > inline void _DBG(const char *s, _T x) { cerr << s << " = " << x << "\n"; }
template < typename _T, typename... args > void _DBG(const char *s, _T x, args... a) { while(*s != ',') cerr << *s++; cerr << " = " << x << ','; _DBG(s + 1, a...); }

#ifdef LOCAL
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) (__VA_ARGS__)
#define cerr if(0) cout
#endif

// ********************** CODE ********************** //

int n;
bool vis[101][101], ans[101][101];

bool solve(int a, int b)
{
    if(vis[a][b]) return ans[a][b];
    if(a == n && b == n - 1)
        return 0;
    if(a == 1 && b == 2)
        return 0;
    vis[a][b] = 1;
    bool win = 1;
    if(a > 1 && solve(b, a - 1))
        win = 0;
    if(a < n && solve(b, a + 1))
        win = 0;
    return win;
}

int main()
{
    _upgrade
    int a, b;
    cin >> n >> a >> b;
    if(solve(a, b))
        cout << "Alice\n";
    else
        cout << "Borys\n";
	return 0;
}


Measured memory_bytes: 892
//120
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int H, W, h, w, A, B, C;

int main() {
	cin >> A >> B >> C;
	cout << (A*C <= B ? C : B / A) << endl;



	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
list_ab = []
for i in range(n):
    ab = list(map(int, input().split()))
    list_ab.append(ab)
cnt = 0
b_sum = 0
list_ab.sort()

for j in list_ab:
    if b_sum < k:
        b_sum += j[1]
        cnt += 1
    else:
        break

print(list_ab[cnt-1][0])


Measured memory_bytes: 29528
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
using namespace std;
typedef long long ll;
int L, edge;
const ll mod = 1000000007;
char b;

ll pow(ll x, ll y)
{
	if (y == 0) return 1;
	if (y % 2)
	{
		return pow(x, y - 1) * x % mod;
	}
	else
	{
		ll yyy = pow(x, y / 2);
		return yyy * yyy % mod;
	}
}

ll div(ll x)
{
	return pow(x, mod - 2);
}

int main(void)
{
	cin >> b;
	if (b == 'A') cout << 'T' << endl;
	if (b == 'G') cout << 'C' << endl;
	if (b == 'C') cout << 'G' << endl;
	if (b == 'T') cout << 'A' << endl;
	int www;
	cin >> www;
}


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

int f(int n){
    int sum =0;
    while(n){
        sum += n%10;
        n/=10;
    }
    return sum;
}

int main(){
    int n;
    cin>>n;
    int ans = 1e9;
    for(int i=1;i<=n/2;i++){
        ans = min(ans,f(i)+f(n-i));
    }
    cout<< ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>                                             
#include <cstdio>                                               
using namespace std;                                            
                                                                
int main() {                                                    
  long long  n;                                                 
  scanf("%lld", &n);                                            
  long long R[n];                                               
  for (int t=0; t<n; t++) {                                     
    scanf("%lld", &R[t]);                                       
  }                                                             
  long long  minv = R[0];                                       
  long long  maxv = R[1]-R[0];                             
  for (long long j=1; j<n; j++) {                               
    maxv = (long long)max(maxv,R[j]-minv);                      
    minv = (long long)min(minv,R[j]);                           
  }                                                             
  printf("%lld\n", maxv);                                       
  return 0;                                                     
}                                                               
                                                                
                                                                
                                

Measured memory_bytes: 4788
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

import itertools

n, k = map(int, readline().split())
memo = [i for i in range(n + 1)]
cumsum = list(itertools.accumulate(memo))
mod = 10 ** 9 + 7
if n < k:
    print(1)
    exit()
ans = 1
for i in range(k - 1, n):
    ans += (cumsum[-1] - cumsum[n - i - 1]) - cumsum[i]
    ans += 1
    ans %= mod
print(ans % mod)


Measured memory_bytes: 83268
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


ll dp[51][51];
int E;
ll N;

void func(){
	scanf("%lld %d",&N,&E);

	for(int num = 0; num <= 50; num++){
		if(dp[E][num] >= N){
			printf("%d\n",num);
			return;
		}
	}
}

void makeDP(){

	for(int i = 0; i <= 50; i++){
		for(int k = 0; k <= 50; k++)dp[i][k] = 0;
	}

	for(int i = 1; i <= 50; i++){
		for(int k = 1; k <= 50; k++){
			dp[i][k] = dp[i-1][k-1]+dp[i][k-1]+1;
		}
	}
}

int main(){

	makeDP();

	int test_case;
	scanf("%d",&test_case);

	for(int loop = 0; loop < test_case; loop++){
		func();
	}

	return 0;
}



Measured memory_bytes: 3244
#include <stdio.h>

int main(void)
{
	float w;
	
	while (scanf("%f", &w) != EOF){
		
		if (w <= 48.0){
			printf("light fly\n");
		}
		else if (w <= 51.0){
			printf("fly\n");
		}
		else if (w <= 54.0){
			printf("bantam\n");
		}
		else if (w <= 57.0){
			printf("feather\n");
		}
		else if (w <= 60.0){
			printf("light\n");
		}
		else if (w <= 64.0){
			printf("light welter\n");
		}
		else if (w <= 69.0){
			printf("welter\n");
		}
		else if (w <= 75.0){
			printf("light middle\n");
		}
		else if (w <= 81.0){
			printf("middle\n");
		}
		else if (w <= 91.0){
			printf("light heavy\n");
		}
		else {
			printf("heavy\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n;
vector<string> w,v;
vector<string> xyz[30];
string s;
vector<char> vc,ans;
typedef pair<int,int> P;
vector<P> vp;
vector<int> used;
int valid;
vector<int> wc1,wc2;
void dfs(){
  for(int i=0;i<(int)v.size();i++){
    string& t=v[i];
    bool flg=0;
    for(int j=0;j<(int)xyz[t.size()].size();j++){
      string& u=xyz[t.size()][j];
      bool ok=1;
      for(int k=0;k<(int)t.size();k++){
	if(!used[t[k]-'A']) continue;
	if(!used[u[k]-'A']){
	  ok=0;
	  break;
	}
	ok&=vc[t[k]-'A']==u[k]-'A';
	if(!ok) break;
      }
      //cout<<t<<" "<<u<<":"<<ok<<endl;
      if(ok){
	flg=1;
	break;
      }
    }
    if(!flg) return;
  }
  int cnt=0;
  for(int i=0;i<26;i++) if(used[vp[i].second]) cnt++;
  //cout<<cnt<<endl;
  //if(cnt>1) return;
  if(cnt==26){
    valid++;
    ans=vc;
    return;
  }
  int x=0;
  while(used[vp[x].second]) x++;
  //cout<<x<<endl;
  if(vp[x].first){
    for(int k=0;k<26;k++){
      if(used[vp[k].second]) continue;
      used[vp[x].second]=used[vp[k].second]=1;
      vc[vp[x].second]=vp[k].second;
      vc[vp[k].second]=vp[x].second;
      //cout<<x<<" "<<k<<endl;
      //cout<<(char)(vp[x].second+'A')<<"<->"<<(char)(vp[k].second+'A')<<endl;
      dfs();
      if(valid>1) return; 
      used[vp[x].second]=used[vp[k].second]=0;
      vc[vp[x].second]=vc[vp[k].second]=0;   
    }
  }else{
    used[vp[x].second]=1;
    vc[vp[x].second]=vp[x].second;
    dfs();
    used[vp[x].second]=0;
    vc[vp[x].second]=0;
  }
}
signed main(){
  while(cin>>n,n){
    for(int i=0;i<30;i++) xyz[i].clear(); 
    w.resize(n);
    for(int i=0;i<n;i++) cin>>w[i],xyz[w[i].size()].push_back(w[i]);
    cin.ignore();
    getline(cin,s);
    assert(s.back()=='.');
    s.pop_back();
    v.clear();
    for(int i=0;i<(int)s.size();i++){
      string t;
      while(i<(int)s.size()&&s[i]!=' ') t+=s[i++];
      //cout<<t<<endl;
      v.push_back(t);
    }
    vc.clear();
    vc.resize(26,0);
    wc2.clear();
    wc2.resize(26,0);
    for(int i=0;i<(int)v.size();i++)
      for(int j=0;j<(int)v[i].size();j++)
	wc2[v[i][j]-'A']++;
    vp.resize(26);
    for(int i=0;i<26;i++) vp[i]=P(wc2[i],i);
    sort(vp.rbegin(),vp.rend());
    used.clear();
    used.resize(26,0);
    valid=0;
    dfs();
    //cout<<valid<<endl;
    if(valid!=1){
      cout<<"-."<<endl;
      continue;
    }
    //puts("found");
    for(int i=0;i<(int)v.size();i++){
      if(i) cout<<" ";
      for(int j=0;j<(int)v[i].size();j++){
	//cout<<v[i][j]-'A'<<endl;
	cout<<(char)(ans[v[i][j]-'A']+'A');
      }
    }
    cout<<"."<<endl;
  }
  return 0;
}

Measured memory_bytes: 3180
n, c, k = map(int, input().split())
t = []
for i in range(n):
    t.append(int(input()))
t.sort()

bus = 0
new_bus = True
start_time = 0
capacity = 0

while t:
    time = t[0]
    if new_bus:
        new_bus = False
        capacity = 0
        start_time = time
        bus += 1

    wait_time = time - start_time
    if wait_time > k:
        if t:
            new_bus = True
            continue
        else:
            bus += 1
            break

    t.pop(0)
    capacity += 1

    if capacity == c:
        new_bus = True
        continue

print(bus)


Measured memory_bytes: 7384
n=input()
m=[[]for _ in range(len(n))]
m[0]+=[[0,int(n[0])]]
for i in range(1,len(n)):
  a=int(n[i])
  for m0,m1 in m[i-1]:
    m[i]+=[[m0+m1,a]]
    m[i]+=[[m0,m1*10+a]]
ans=0
for m0,m1 in m[len(n)-1]:
  ans+=m0+m1
print(ans)


Measured memory_bytes: 3064
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input! {
        n: usize,
    }

    let cand = vec![3, 5, 7];
    let mut ans = 0;
    for i in 3..10 {
        ans +=  solve(0, i, &cand, n, 0);
    }

    println!("{}", ans);

}

fn solve(num: usize, digit: usize, cand: &Vec<usize>, input: usize, pos: usize) -> usize {
    if pos == digit {
        //println!("{}", num);
        if check(num) && num <= input {
            return 1;
        } else {
            return 0;
        }
    }
    let mut tmp = 0;
    for n in cand {
        tmp+=solve(num+*n*10usize.pow(pos as u32), digit, cand, input, pos+1);
    }
    tmp 
}

fn check(mut num: usize) -> bool {
    //premiss digit numbers is either 3 or 5 or 7.
    let mut three = false;
    let mut five = false;
    let mut seven = false;

    while num > 0 {
        let tmp = num % 10;
        if tmp == 3 {
            three = true;
        } else if tmp == 5 {
            five = true;
        } else if tmp == 7 {
            seven = true;
        }
        num /= 10;
    }

    if three && five && seven {
        return true;
    } else {
        return false;
    }
}

Measured memory_bytes: 4352
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int total = 0;
    
    for (int i = n; n > 0; n --) {
      total += n;
    }
    
    System.out.println(total);
  }
}

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

int main(){
	char S[4];
	cin>>S;
	char S1[2] = {S[0],S[1]};
	char S2[2] = {S[2],S[3]};
		
	int dato1 = atoi(S1);
	int dato2 = atoi(S2);
	
	if(((dato1<=12)&&(dato1!=0))&&((dato2>12)||(dato2==0)))cout<<"MMYY";
	else if(((dato1>12)||(dato1==0))&&((dato2<=12)&&(dato2!=0)))cout<<"YYMM";
	else if(((dato1<=12)&&(dato2<=12))&&((dato1!=00)&&(dato1!=0)))	cout<<"AMBIGUOUS";
	
	else cout<<"NA";
	return 0;
}

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

int main(){
  long N,W,V;
  long i,j;
  V = 100001;
  cin >> N >> W;
  vector<long> w(N);
  vector<long> v(N);
  vector<vector<long>> dp(N+1,vector<long>(V,LLONG_MAX / 2));
  for(i=0;i<N;i++)
    dp[i][0] = 0;
  for(i=0;i<N;i++)
    cin >> w[i] >> v[i];
  for(i=0;i<N;i++)
    for(j=0;j<V;j++){
      dp[i+1][j] = dp[i][j];
      if (j >= v[i])
        dp[i+1][j] = min(dp[i+1][j], dp[i][j - v[i]] + w[i]);
    }
  long res = 0;
  for(i=0;i<V;i++)
    if (dp[N][i]<=W)
      res = i;//max(res,dp[i][V]);

  cout << res << endl;
  
  return 0;
}


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

int dp[3001][3001];

string LCS(string s,string t,int len)
{
	string ls;
	int i=0,j=0;
	while(len>0)
	{
		if(s[i]==t[j])
		{
			ls.push_back(s[i]);
			i++;
			j++;
			len--;
		}
		else
		{
			if(dp[i][j+1]>dp[i+1][j])
				j++;
			else
				i++;
		}
	}
	return ls;
}

int lcs(string& s,string& t,int i,int j)
{
	if(i>=s.length() || j>=t.length())
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	if(s[i]==t[j])
		return dp[i][j]=1+lcs(s,t,i+1,j+1);
	else
		return dp[i][j]=max(lcs(s,t,i+1,j),lcs(s,t,i,j+1));
}
string solve(string s,string t)
{
	memset(dp,-1,sizeof(dp));
	int len=lcs(s,t,0,0);
	return  LCS(s,t,len);
}
int main()
{
// 	#ifndef ONLINE_JUDGE
// 	freopen("input.txt","r",stdin);
// 	freopen("ouput.txt","w",stdout);
// 	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s,t;
	cin >> s;
	cin >> t;
	cout << solve(s,t);
	return 0;
}

Measured memory_bytes: 39284