akhauriyash/Code-Regression huggingface dataset:
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}


const int INF = 1e9+7;
struct Edge{
    int to;
    int cost;
};

bool canattain(vector<vector<Edge>> &edges, int from, int to, vector<vector<int>> &cangoal, vector<bool> &used){
    if(cangoal[from][to] != 0){
        return (cangoal[from][to]==1?true:false);
    }

    used[from] = true;
    if(from == to){
        return true;
    }

    for(auto t: edges[from]){
        if(used[t.to])
            continue;
        if(canattain(edges, t.to, to, cangoal, used)){
            cangoal[from][to] = 1;
            return true;
        }
    }
    cangoal[from][to] = -1;
    return false;
}

bool bellman_ford(vector<vector<Edge>> &edges, vector<int> &mini, int src) {
    int n = edges.size();
    vector<vector<int>> cangoal(n, vector<int>(n, 0));
    mini[src] = 0;
    FOR(i, 0, n) {
        FOR(node, 0, n) {
            for (auto edge : edges[node]) {
                if (mini[node] != INF && mini[node] + edge.cost < mini[edge.to]) {
                    vector<bool> tmp(n, false);
                    vector<bool> tmp2(n, false);
                    if (i == n - 1){
                        if(canattain(edges, node, n-1, cangoal, tmp) && canattain(edges, 0, node, cangoal, tmp2))
                            return true;
                    }
                    else
                        mini[edge.to] = mini[node] + edge.cost;
                }
            }
        }
    }
    return false;
}

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

    vector<vector<Edge>> edges(n);
    REP(i, m){
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        edges[a].push_back({b, p-c});
    }
    
    vector<int> mini(n, INF);



    bool ret = bellman_ford(edges, mini, 0);
    if(ret){
        cout << -1 << endl;
    }
    else {
        cout << max(0, -1 * mini[n-1]) << endl;
    }



    return 0;
}


Measured memory_bytes: 27008
n, k = map(int, input().split())
A = list(map(int, input().split()))

dict = {}

for a in A:
	try:
		dict[a] += 1
	except KeyError:
		dict[a] = 1

sorted_dict = sorted(dict.items(), key=lambda x: -x[1])

ans = 0
for i in range(k,len(sorted_dict)):
	ans += sorted_dict[i][1]
print(ans)

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n;
  vector<string> s;
  Solver(LL n) : n(n), s(3){};

  void solve() {
    for (int i = 0; i < 3; ++i) {
      cin >> s[i];
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      set<char> S;
      for (int j = 0; j < 3; ++j) {
        S.insert(s[j][i]);
      }
      ans += S.size() - 1;
    }
    cout << ans << endl;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 256
N,Y = list(map(int, input().split()))

ans = [-1,-1,-1]

for a in range(N+1):
        for b in range(N+1-a):
                c = N - a - b;
                total = 10000 * a + 5000 * b + 1000 * c
                if total == Y:
                        ans = [ a , b , c ]

print(str(ans[0]) + " " + str(ans[1]) + " " + str(ans[2]))


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

int main(){
  int a,b,c,d,sum=0;
  cin>>a>>b>>c>>d;
  if(a<b)sum+=a;
  else sum+=b;
  if(c<d)sum+=c;
  else sum+=d;
  cout <<sum<<endl;
  
  return 0;
}


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

int a, b, ans;
char c;

int main() {
    scanf("%d %c %d", &a, &c, &b);
    if ( c == '+' ) ans = a + b;
    else ans = a - b;
    printf("%d\n", ans);
    return 0;
}


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

int main(){
	int r,outrate,n;
	cin>>n>>r;
	if(n<10)
	outrate=r+100*(10-n);
	else
	outrate=r;
	cout<<outrate<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int N;
  cin>>N;
  string S;
  cin>>S;
  int Rnum = 0;
  for(int i=0;i<S.size();++i) {
    if(S[i]=='R') Rnum++;
  }
  int rnum = 0;
  for(int i=0;i<Rnum;++i) {
    if(S[i]=='R') rnum++;
  }
  cout<<Rnum-rnum<<endl;
}



Measured memory_bytes: 3748
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>

using namespace std;

struct Node {
	int id;
	Node *parent;
	int child_num;
	vector<Node*> children;
};

int n;
vector<Node*> nodes;

int main(void) {

	scanf("%d", &n);
	nodes.reserve(n);
	for (int i = 0; i < n; ++i) {
		nodes[i] = NULL;
	}

	for (int i = 0, id, n2; i < n; ++i) {
		scanf("%d", &id);
		scanf("%d", &n2);

		Node *pnode = nodes[id];
		if (pnode == NULL) {
			pnode = nodes[id] = new Node;
			pnode->parent = NULL;
		}
		pnode->id = id;
		pnode->child_num = n2;
		pnode->children.reserve(n2);
		for (int j = 0, id2; j < n2; ++j) {
			scanf("%d", &id2);
			Node *cnode = nodes[id2];
			if (cnode == NULL) {
				cnode = nodes[id2] = new Node;
			}
			pnode->children[j] = cnode;
			cnode->id = id2;
			cnode->parent = pnode;
		}
	}

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

		int depth = -1;
		Node *node = nodes[i];
		while (node) {
			node = node->parent;
			++depth;
		}

		const char *type = "internal node";
		if (nodes[i]->parent == NULL) {
			type = "root";
		}
		else if (nodes[i]->child_num == 0) {
			type = "leaf";
		}

		printf("node %d: parent = %d, depth = %d, %s, [",
			nodes[i]->id, (nodes[i]->parent ? nodes[i]->parent->id : -1),
			depth, type);
		for (int j = 0, f = 0; j < nodes[i]->child_num; ++j) {
			if (f) {
				printf(", %d", nodes[i]->children[j]->id);
			}
			else {
				f = 1;
				printf("%d", nodes[i]->children[j]->id);
			}
		}
		printf("]\n");
	}

	for (int i = 0; i < n; ++i) {
		delete nodes[i];
	}

	return 0;
}

Measured memory_bytes: 10648
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
//C++14 (GCC 5.4.1)
int main() {
    int N;
    cin >>N;
    vector<int> A(N);
    rep(i,N) cin >> A.at(i);
    //-----------------------------------
    int Al=0,Bb=0;
    std::sort(A.begin(),A.end());
    int s=N%2;

    for(int i=N-1;i>=0;i--){
        if(i%2==s){
            Bb+=A.at(i);
        }else{
            Al+=A.at(i);
        }
    }
    cout << Al-Bb <<endl;
}

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

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int A, B, K;
    cin >> A >> B >> K;
    int cnt = 0;
    for(int i = min(A, B); i > 0; i--) {
        if (A % i == 0 && B % i == 0) {
            cnt++;
            if (cnt == K) {
                cout << i << endl;
                return;
            }
        }
    }
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int arr[] = new int[M];
    int cnt = 0;
    
    for (int i = 0; i < N; i++) {
      int K = sc.nextInt();
      for (int j = 0; j < K; j++) {
        arr[sc.nextInt()-1]++;
      }
    }
    
    for (int i = 0; i < M; i++) {
      if (arr[i] == N) {
        cnt++;
      }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 21632
# python 3.8.2用
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from decimal import *
from collections import deque
from math import gcd
sys.setrecursionlimit(10**7)
MOD = 10**9+7
INF = float('inf') #無限大
def lcm(a,b):return (a*b) // gcd(a,b) #最小公倍数
def iin(): return int(sys.stdin.readline()) #整数読み込み
def ifn(): return float(sys.stdin.readline()) #浮動小数点読み込み
def isn(): return sys.stdin.readline().split() #文字列読み込み
def imn(): return map(int, sys.stdin.readline().split()) #整数map取得
def imnn(): return map(lambda x:int(x)-1, sys.stdin.readline().split()) #整数-1map取得
def fmn(): return map(float, sys.stdin.readline().split()) #浮動小数点map取得
def iln(): return list(map(int, sys.stdin.readline().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, sys.stdin.readline().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD
def lprint(l): print(*l, sep='\n')

S,W = imn()

print('unsafe' if S <= W else 'safe')

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

using namespace std;
int main(){
    string s;
    cin>>s;
    bool A=false,B=false;
    for(int i=0;i<3;i++){
        if(s[i]=='A') A=true;
        if(s[i]=='B') B=true;
        if(A&&B) break;
    }
    
    if(A&&B) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    ll n, x, t;    cin >> n >> x >> t;
    cout << t*(n/x+ min(1LL, n%x)) << endl;
}


Measured memory_bytes: 3588
N, K = (int(x) for x in input().split())
Plot = [tuple(int(x) for x in input().split()) for _ in range(N)]
X = [p[0] for p in Plot]
Y = [p[1] for p in Plot]
X.sort()
Y.sort()
#全2点間で長方形の辺を作り、その内内部点がK個のものだけ面積を比較する。
ans = 10e20
from itertools import combinations
for x1, x2 in combinations(X, 2):
    for y1 in Y:
        y2 = [y for x,y in Plot if x1 <= x <= x2 and y1 <= y]
        if len(y2) < K:
            break
        y2.sort()
        S = (x2-x1)*(y2[K-1]-y1)
        ans = min(ans, S)
print(ans)


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

//create arrays outside of main()

int a[100];

int main(){

    int a;
    int b;
    cin >> a >> b;

    int aTwice = a*2-1;
    int bTwice = b*2 -1;
    int ab = a+b;
    
    int biggestNum;

    if(aTwice > bTwice){
        biggestNum = aTwice;
    } else {
        biggestNum = bTwice;
    }

    if (ab > biggestNum){
        biggestNum = ab;
    }

    cout << biggestNum;

    return 0;
}

Measured memory_bytes: 256
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 9000000000000000000 //9e18:極めて大きい値
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
#define LOGMAXR 18 // floor(log2(10^5)) + 1: 配列の最大のrangeのlog
//略記
//#define PB push_back //vectorヘの挿入
//#define MP make_pair //pairのコンストラクタ
//#define F first //pairの一つ目の要素
//#define S second //pairの二つ目の要素

int main(){
  ll N, K;
  cin >> N >> K;
  ll A[N];
  REP(n, N){
    cin >> A[n];
    A[n]--;
  }
  ll n = 0;
  ll t = 0;
  map<ll, ll> town_num;
  map<ll, ll> num_town;
  while(town_num.count(t) == 0){
    town_num.emplace(t, n);
    num_town.emplace(n, t);
    t = A[t];
    ++n;
  }
  //cout << t << endl;
  //cout << n << endl;
  //cout << town_num[t] << endl;
  ll ret = K;
  if(ret >= n){
    ret = (K - town_num[t]) % (n - town_num[t]) + town_num[t];
  }
  cout << num_town[ret] + 1 << endl;
  return 0;
}


Measured memory_bytes: 29468
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	char b='-';
	string s;
	bool flag=true;
	map<string,int>mp;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s[0]!=b&&b!='-')flag=false;
		if(mp[s]++==1)flag=false;
		b=s.back();
	}
	if(flag)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 100 + 10;
char s[MAXN];
bool ok,k;
int main(){
	gets(s);
	int now = 0,len = strlen(s) - 1;
	while(now <= len){
		if(s[now] == 'C')ok = true;
		if(s[now] == 'F' && ok){
			k = true;
			break;
		}
		now++;
	}
	if(k)puts("Yes");
	else puts("No");
	return 0;
}


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

int main() {
    int H,W;
    cin >> H >> W;
    vector<string> a(H);
    for (int i=0;i<H;i++) {
        cin >> a.at(i);
    }

    vector<bool> row(H,false);
    vector<bool> col(W,false);
    for (int i=0;i<H;i++) {
        for(int j=0;j<W;j++) {
            if (a.at(i).at(j)=='#') {
                row.at(i)=true;
                col.at(j)=true;
            }
        }
    }

    for (int i=0;i<H;i++){
        if (row.at(i)) {
            for (int j=0;j<W;j++) {
                if (col.at(j)) {
                    cout << a.at(i).at(j);
                }
            }
            cout << endl;
        }
    }
}

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

#define pb push_back
#define fi first
#define se second
typedef long long ll;

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

	int n;
	cin >> n;
	int A[n], cnt = 0, ans = 0;
	for (int i = 0; i < n; ++i)
		cin >> A[i];
	for (int i = 1; i < n; ++i) {
		if (A[i] > A[i - 1]) {
			ans = max(ans, cnt);
			cnt = -1;
		}
		cnt++;
	}
	ans = max(ans, cnt);
	cout << ans << '\n';
}


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

int main() {
  string s;
  cin>>s;
  
  rep(i,s.size()){
    if(s.at(i)=='?'){
      s.at(i)='D';
    }
  }
  cout<<s;
}

Measured memory_bytes: 3756
#include<iostream>
#include<string.h>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

int main()
{
  int n=0;
  int i,j;
  char str[30];
  char s[30]={"CODEFESTIVAL2016"};
  cin>>str;
  rep(i,16)
    if(str[i]!=s[i])
      n++;

  cout<<n<<endl;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    string s;cin>>s;
    int k;cin>>k;
    int sum=0;
    int n=s.size();
    rep(i,0,n){
        int t=s[i]-'a';
        int co=26-t;
        co%=26;
        if(sum+co>k){
            continue;
        }
        sum+=co;
        s[i]='a';
    }
    int zan=k-sum;
    zan%=26;
    int u=s[n-1]-'a';
    u+=zan;
    u%=26;
    s[n-1]=u+'a';
    cout<<s<<endl;
}










Measured memory_bytes: 592
#include <stdio.h>
#include <stdlib.h>
//#include <string.h>
//#include <limits.h>
//#include <math.h>

#define Max(a, b) ((a > b) ? a : b)
int n;
long k, a[200000], f[200000];

//昇順
int acs(const void *a, const void *b)
{
  return *(long *)a - *(long *)b;
}

//降順
int des(const void *a, const void *b)
{
  return *(long *)b - *(long *)a;
}

long binary_search(long b, long t)
{
  if (t-b <= 1)
    return t;
  long cnt = 0, mid = (t+b)/2;
  for (int i=0; i<n; i++) {
    if (mid >= a[i]*f[i])
      continue;
    cnt += a[i] - mid/f[i];
  }
  if (cnt > k)
    return binary_search(mid, t);
  return binary_search(b, mid);
}

int main() {
  scanf("%d%ld", &n, &k);
  for (int i=0; i<n; i++)
    scanf("%ld", a+i);
  for (int i=0; i<n; i++)
    scanf("%ld", f+i);
  qsort(a, n, sizeof(long), acs);
  qsort(f, n, sizeof(long), des);
  long maxt = 0, ans;
  for (int i=0; i<n; i++)
    maxt = Max(maxt, a[i]*f[i]);
  ans = binary_search(-1, maxt);
  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 4860
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

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

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;

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

    cout<<((x-t>0)?(x-t):0)<<endl;




}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
    
    vector<int> L;
    int N;
    int ans = 0;
    
    cin >> N;
    
    for ( int i = 0; i < N*2; i++ ) {
        int a;
        cin >> a;
        L.push_back(a);
    }
    
    sort( L.begin(), L.end() );
    
    for ( int i = 0; i < N*2; i+=2 ) {
        ans += L[i];
    }
    
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	int T,P,R;
	while(cin>>T>>P>>R,T+P+R){
		int miss[51][11]={0};
		int pe[51]={0};
		int co[51]={0};
		bool h[51][11]={false};
		rep(i,R){
			int a,b,c;
			string s;
			cin>>a>>b>>c>>s;
			a--;b--;
			if(h[a][b])continue;
			if(s=="CORRECT"){
				pe[a]+=miss[a][b]*1200+c;
				co[a]++;
				h[a][b]=true;
			}else miss[a][b]++;
		}
		int out[51];
		rep(i,51)out[i]=i;
		loop(i,1,T)for(int j=T-1;j>=i;j--){
			if(co[out[j-1]]<co[out[j]])swap(out[j],out[j-1]);
			else if(co[out[j-1]]==co[out[j]]&&pe[out[j-1]]>pe[out[j]])swap(out[j],out[j-1]);
			else if(co[out[j-1]]==co[out[j]]&&
					pe[out[j-1]]==pe[out[j]]&&
					out[j-1]>out[j])swap(out[j],out[j-1]);
		}
		rep(i,T)cout<<out[i]+1<<" "<<co[out[i]]<<" "<<pe[out[i]]<<endl;
	}
}

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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_H = 6;
int H, W;
int K;
char C[MAX_H][MAX_H];

signed main()
{
  cin >> H >> W >> K;
  REP(h,H) {
    REP(w,W) {
      cin >> C[h][w];
    }
  }

  int ans = 0;
  REP(hS, (1 << H)) {
    REP(wS, (1 << W)) {
      int tmp = 0;
      REP(y,H) {
        if ((hS >> y) & 1) {
          continue;
        }
        REP(x,W) {
          if ((wS >> x) & 1) {
            continue;
          }
          if (C[y][x] == '#') {
            tmp++;
          }
        }
      }
      if (tmp == K) {
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


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

using namespace std;


int main()
{
	int t;
	t=1;
	while(t--)
	{
	long long int a[300000];
	
	long long int i,j,k,n;
   long long  dp[300000],prod;
	
	cin>>n>>k;
	
	for(i=0;i<n;i++)
	cin>>a[i];
	
     prod=1;
     
     prod=a[0];
     
     if(k==1)
     {
     	  for(i=1;i<n;i++)
    {
    	if(  a[i]>a[i-1]   )
    	cout<<"Yes\n";
    	
    	else
    	cout<<"No\n";
    	
    
    	
    	
	  }
     	
     	
     	
     	
     	
     	
	 }
     
     else
     {
	 
     
     
     for(i=k;i<n;i++)
    {
    	if(  a[i]>a[i-k]    )
    	cout<<"Yes\n";
    	
    	else
    	cout<<"No\n";
    	
    //	prod=(prod*a[i])/(a[i-k]);
    	
    	
	  }
	  
   }
		
	}
		
	



}


Measured memory_bytes: 5192
def isPrime(x):
    if x==2:
        return True
    if x<2 or x%2==0:
        return False
    if pow(2,x-1,x)==1:
        return True
    else:
        return False

n=input()
ct=0
for i in xrange(n):
    if isPrime(input()):
        ct+=1
print(ct)
         

Measured memory_bytes: 6440
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<int ,int> pairs;
int main()
{
    ll n,weight,value,a=0,b=0,re,r,blue;
  string s;
  char c;
  cin>>n>>a>>b;

 re=n/(a+b);
 r=n%(a+b);
 if(r>a)
 {
     r=a;
 }
 blue=re*a+r;
 cout<<blue<<endl;

}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
from collections import Counter
d=Counter(a)
f=True
tt=0
ans=0
for i ,j in sorted(d.items(),reverse=True):
    if j==1:
        continue
    elif j>=4 and f:
        print(i*i)
        exit()
    else:
        f=False
        ans=tt*i
        tt=i
        if ans>0:
            break
print(ans)

Measured memory_bytes: 69912
s = input()

a = 0
b = 0
c = 0

for i in range(2):
	for j in range(2):
		for k in range(2):
			#print(i,j,k)
			check = int(s[0])+int(s[1])*(2*i-1)+int(s[2])*(2*j-1)+int(s[3])*(2*k-1)
			if check ==7:
				a = (2*i-1)
				b = (2*j-1)
				c = (2*k-1)

#print(a,b,c)

if a == 1:
	stra = '+'
else:
	stra = '-'
	
if b == 1:
	strb = '+'
else:
	strb = '-'

if c == 1:
	strc = '+'
else:
	strc = '-'

print(s[0]+stra+s[1]+strb+s[2]+strc+s[3]+'=7')



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

using ll = long long;
//print(fixed << setprecision(10));
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repk(i,n,k) for(ll i = k; i < (n); i++)
#define all(n) n.begin(), n.end()
#define print(n) cout << n << endl
double PI = acos(-1.0);
int INF = 1e9;
ll LINF = 1e18;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    string s,t;
    cin >> s >> t;
    int cnt=0,min=1000;
    rep(i,s.length()-t.length()+1){
        cnt = 0;
        rep(j,t.length()){
            if(s[i+j]!=t[j]) cnt++;
        }
        if(min>cnt) min = cnt;
    }
    print(min);
    return 0;
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;

int n, k;
bool f[20];


bool good(int x) {
  string s = to_string(x);
  for (char c: s) {
    int d = c-'0';
    if (!f[d]) return false;
  }
  return true;
}

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

  cin>>n>>k;

  for (int d=0; d<=9; d++) {
    f[d]=true;
  }

  for (int i=0; i<k; i++) {
    int x; cin>>x;
    f[x]=false;
  }

  int x=n;
  while (!good(x)) x++;
  out(x);
 

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
using namespace std;
int n,m,d[301][301],f[301][301],v[301],now[301];
bool vis[301];
int main() {
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++) {
			scanf("%d",&f[i][j]);
			d[i][f[i][j]]=j;
			if (j==1) {
				v[f[i][j]]++;
				now[i]=f[i][j];
			}
		}
	int ans=n;
	for (int i=1;i<m;i++) {
		int k=1;
		for (int j=2;j<=m;j++) if (v[j]>v[k]) k=j;
		ans=min(ans,v[k]);
		vis[k]=1;
		v[k]=0;
		for (int j=1;j<=n;j++) {
			if (now[j]!=k) continue;
			int nowx=d[j][k];
			while (vis[f[j][nowx]]) nowx++;
			now[j]=f[j][nowx];
			v[now[j]]++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

signed main(){
    cin.tie(0); 
    ios::sync_with_stdio(false);
    int n;
    int value[4];
    int count;
    int comp;
    int temp;
    bool judge;
    int l,s;
    cin>>n;
    while( n != 0){
        judge = true;
        for(int i=1;i<=9;i++){
            comp = i;
            for(int j=1;j<4;j++){
                comp = comp*10;
                comp += i;
            }
            if(comp == n){
                judge = false;
                break;
            }
        }
        if(judge){
            count=0;
            while(n != 6174){
                temp = n;
                for(int i=0;i<4;i++){
                    value[i] = temp % 10;
                    temp = temp / 10;
                }
                sort(value,value+4,greater<int>());
                l = 0;
                for(int i=0;i<4;i++){
                    l *= 10;
                    l += value[i];
                }
                sort(value,value+4);
                s = 0;
                for(int i=0;i<4;i++){
                    s *= 10;
                    s += value[i];
                }
                n = l - s;
                count++;
            }
            cout<<count<<"\n";
        }else{
            cout<<"NA\n";
        }
        cin>>n;
    }
    return 0;
}




Measured memory_bytes: 3176
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
//void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 55;
const ll mm = 1e+18;
void solve()
{
    int n;
    cin>>n;
    int mx=1000;
    int a[n];
    rep0(i,n){
        cin>>a[i];
    }
    int dp[n];
    rep0(i,n)dp[i]=1000;
    rep1(i,n-1){
        if(i) dp[i]=dp[i-1];
        for(int j=i-1;j>=0;j--){
            dp[i]=max(dp[i],(dp[j]/a[j])*a[i]+dp[j]%a[j]);
        }
        //deb(dp[i]);
    }
    pr(dp[n-1]);
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    // freopen("sp.txt","r",stdin);
    // freopen("out.txt","w",stdout);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}

Measured memory_bytes: 3640
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef pair<ll,P> pp;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tup;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}

int main(){
    string s; ll d; cin >> s >> d;
    ll n = s.size();
    ll dp[n+1][d][2];
    rep(i,n+1) rep(j,d) rep(k,2) dp[i][j][k] = 0;
    dp[0][0][0] = 1;
    rep(i,n){
        ll t = s[i] - '0';
        rep(j,d){
            rep(k,t) rep(l,2) dp[i+1][(j+k)%d][1] += dp[i][j][l];
            rep(k,2) dp[i+1][(j+t)%d][k] += dp[i][j][k];
            REP(k,t+1,10) dp[i+1][(j+k)%d][1] += dp[i][j][1];
        }
        rep(j,d) rep(k,2) dp[i+1][j][k] %= mod;
    }
    ll ans = dp[n][0][0]+dp[n][0][1];
    if(ans==0) cout << mod-1 << endl;
    else cout << (ans-1)%mod << endl;
}

Measured memory_bytes: 15872
import collections
n = int(input())
li = list(map(int,input().split()))
c = collections.Counter(li)
d = c.copy()
ans_1 = 0
for v in d.values():
  v = int(v)
  ans_1 += v*(v-1)//2
for k in li:
  print(ans_1 - (c[k]-1))

Measured memory_bytes: 27452
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;
const int INF = 1001001001;

struct mint {
  ll x; // typedef long long ll;
  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 { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main() {
  int n;
  cin >> n;
  mint ans = 0;
  combination comb(1000001);
  ans = mint(10).pow(n); // Aの順列

  mint t = mint(9).pow(n);  // 0が存在しない順列
  t *= 2;                  // 9が存在しない順列の個数
  t -= mint(8).pow(n);     // 両方存在しない順列
  ans -= t;
  cout << ans << endl;
}

Measured memory_bytes: 18792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using namespace std;
using namespace __gnu_pbds;

const int MAXN = 328;

ll mod;
ll f[MAXN][MAXN];
ll cnk[MAXN][MAXN];
ll d[MAXN];

int main() {
#ifdef BZ
    freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout.setf(ios::fixed); cout.precision(20);
    int n, k;
    cin >> n >> k >> mod;
    fill(f[0], f[0] + k + 1, 1);


    for (int i = 0; i <= n; ++i) {
        cnk[i][0] = 1;
        for (int j = 1; j <= n; ++j) {
            cnk[i][j] = (cnk[i - 1][j] + cnk[i - 1][j - 1]) % mod;
        }
    }

    for (int i = 1; i <= n; ++i) {
        f[i][0] = 0;
        fill(d, d + n + 1, 0);

        for (int ck = 1; ck <= k; ++ck) {
            for (int j = 0; j < i; ++j) {
                d[j] = (d[j] + f[i - 1 - j][ck - 1] * cnk[i - 1][j]) % mod;
            }

            for (int j = 0; j < i; ++j) {
                f[i][ck] = (f[i][ck] + d[j] * f[j][ck]) % mod;
            }
        }
    }

    cout << f[n][k] << "\n";
}

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

typedef long long int ll;

#define mod 1000000007
#define pb push_back
#define prt1(a) cout<<a<<" ";
#define prt2(a,b) cout<<a<<" "<<b<<" ";
#define prt3(a,b,c) cout<<a<<" "<<b<<" "<<c<<" ";
#define rep(i,st,end) for(int i=st;i<(int)end;i++)
#define repv(i,st,end) for(int i=st;i>=end;i--)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

//vector<ll> adj1[21],adj2[21];
//ll roadid1[21][21],roadid2[21][21];

int main() {
	int r;
	cin>>r;
	cout<<pow(r,2)<<endl;
	

	return 0;
}

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

using namespace std;

// 10^5のくらいまで
int sumDigit(int x)
{
	int sum = 0;

	for ( int i = 0; i <= 5; i++ )
	{
		sum += (int)(x / pow(10, i)) % 10;
	}

	return sum;
}

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

	int ans = 1000000;

	for (int a = 1; a <= n / 2; a++)
	{
		int s = sumDigit(a) + sumDigit(n - a);

		if ( s < ans )
		{
			ans = s;
		}
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 384
N, M = list(map(int ,input().split()))
X = list(map(int, input().split()))
dis = []
if N >= M:
    print(0)
else:
    X.sort()
    for i in range(M-1):
        dis.append(abs(X[i+1] - X[i]))
    dis.sort(reverse=True)
    ans = max(X) - min(X) - sum(dis[:N-1])
    print(ans)

Measured memory_bytes: 13968
def examD():
    St = S(); X, Y = LI()
    N = len(St)
    ans = "No"
    Fx = deque(); Fy = deque()
    ve = int(1); cur = int(0)
    for i in range(N):
        if St[i] == "F":
            cur += 1
        else:
            if ve == 1:
                Fx.append(cur)
                cur = int(0)
                ve *= -1
            else:
                Fy.append(cur)
                cur = int(0)
                ve *= -1
    if ve == 1:
        Fx.append(cur)
    else:
        Fy.append(cur)
    xfirst = Fx.popleft()
    X = X - xfirst
#    print(Fx)
#    print(Fy)
    xlen = len(Fx); ylen = len(Fy)
    xneed = -1; yneed = -1
    if (sum(Fx) - X) % 2 == 0:
        xneed = (sum(Fx) - X) // 2
    if (sum(Fy) - Y) % 2 == 0:
        yneed = (sum(Fy) - Y) // 2
#    print(xneed)
    dp = [[0] * (xneed + 1) for _ in range(xlen + 1)]
    if xneed > 0:
        dp[0][0] = 1
        for i in range(xlen):
            for j in range(max(xneed + 1, 0)):
                if dp[i][j] != 0:
                    if xneed + 1 - Fx[i] > j:
                        dp[i + 1][j + Fx[i]] = dp[i][j]
                    dp[i + 1][j] = dp[i][j]
    #    print(dp)
    #    print(dp[xlen][xneed])
    if (xneed > 0 and dp[xlen][xneed] == 1) or xneed == 0:
        dp = [[0] * (yneed + 1) for _ in range(ylen + 1)]
        if yneed>0:
            dp[0][0] = 1
            for i in range(ylen):
                for j in range(max(yneed + 1, 0)):
                    if dp[i][j] != 0:
                        if yneed + 1 - Fy[i] > j:
                            dp[i + 1][j + Fy[i]] = dp[i][j]
                        dp[i + 1][j] = dp[i][j]
        if (yneed > 0 and dp[ylen][yneed] == 1) or yneed == 0:
            ans = "Yes"
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
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')

examD()


Measured memory_bytes: 102364
// AtCoder Beginner Contest 157 B.cpp :

#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n;
	int a[3][3];
	bool z[3][3];
	for (int i = 0; i < 3; i++) {
		for (int j = 0; j < 3; j++) {
			cin >> a[i][j];
			z[i][j] = false;
		}
	}
	cin >> n;
	vector<int>b(n);
	for (auto& k : b) {
		cin >> k;
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				if (k == a[i][j])
					z[i][j] = true;
			}
		}
	}
	if (z[0][0] && z[0][1] && z[0][2]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (z[0][0] && z[1][0] && z[2][0]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (z[2][0] && z[2][1] && z[2][2]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (z[0][2] && z[1][2] && z[2][2]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (z[0][0] && z[1][1] && z[2][2]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (z[0][2] && z[1][1] && z[2][0]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (z[1][0] && z[1][1] && z[1][2]) {
		cout << "Yes" << endl;
		return 0;
	}
	if (z[0][1] && z[1][1] && z[2][1]) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<deque>
#include<cmath>
#include<stack>
#include<string.h>
#include <iomanip>
#define rep(i,n) for(int i = 0;i<n;i++)
#define _GLIBCXX_DEBUG
using ll = long long; 
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    int l,r;
    cin >> l >> r;
    int mod = 2019;
    ll ans = 2020;
    for(ll i = l;i<l+2019;i++) {
        for(ll j = l;j<l+2019;j++) {
            if(i<j && i < r&& j<=r)ans = min(ans,i*j%mod);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(int argc, char const* argv[])
{
  int a, b;
  cin >> a >> b;
  int ans = 0;
  if( a > b)
  {
    ans += a;
    a--;
  }
  else
  {
    ans += b;
    b--;
  }
  ans += max(a,b);
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> X(N + 1);
  for (int i = 1; i <= N; i++) cin >> X[i];
  vector<int> Y = X;
  sort(Y.begin(), Y.end());
  for (int i = 1; i <= N; i++) {
    if (X[i] <= Y[N / 2]) cout << Y[N / 2 + 1] << endl;
    else cout << Y[N / 2] << endl;
  }
  return 0;
}

Measured memory_bytes: 3712
#include <stdio.h>
#include <stdlib.h>

int main(int argc, char** argv)
{
	int n, i;
	int a[100000] = {0}, max = 0;
	int k = 0;
	
	scanf("%d", &n);
	for(i=0;i<n;++i){
		scanf("%d", a+i);
		a[i] = a[i] * 2;
		if( a[i] > max ) max = a[i];
	}
	for(i=0; i<n; ++i){
		int d1, d2;
		d1 = (max/2) < k ? (k-max/2) : (max/2-k);
		d2 = (max/2) < a[i] ? (a[i] - max/2) : (max/2 - a[i]);
		if( d2 < d1 ) k = a[i];
	}
	
	printf("%d %d\n", max/2, k/2);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define print(n) cout << n << endl
#define in(v) int v; cin >> v
#define vint vector<int>
#define pb push_back
typedef long long int ll;

int main(){
  ll a,b,x;cin>>x;
  for(int i=-1000;i<=1000;i++){
    for(int j=-1000;j<=1000;j++){
      if(pow(i,5)-pow(j,5)==x){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 4012
s=input()
t=input()
c=""
d=""
lista=list()
sa=sorted(s)
ta=sorted(t,reverse=True)
for i in sa:
    c=c+i
for x in ta:
    d=d+x
lista.append(c)
lista.append(d)
if s==t:
    print("No")
elif lista==sorted(lista):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define Debug(v) for (auto i:v) printf("%lld ",i);puts("")
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define ep emplace_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef pair<ll,ll> PA;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

inline ll calc(ll l,ll r){
	return (l+r)*(r-l+1)/2;
}

int main(){
	int n=read(),k=read();
	if (k>n) return puts("-1"),0; 
	if (calc(k+2*n,k+3*n-1)<calc(k,k+2*n-1)) return puts("-1"),0;
	vector<pair<PA,ll>>ans;
	ll a=k,b=k+n+(n/2),c=k+2*n;
	For(i,1,(n+1)/2) ans.pb(mp(mp(a,b),c)),a++,b++,c+=2;
	b=k+n,c=k+2*n+1;
	For(i,1,n-(n+1)/2) ans.pb(mp(mp(a,b),c)),a++,b++,c+=2;
	for (auto i:ans) if (i.fi.fi+i.fi.se>i.se) return puts("-1"),0;
	for (auto i:ans) printf("%lld %lld %lld\n",i.fi.fi,i.fi.se,i.se);
}

Measured memory_bytes: 6336