akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
constexpr int mod = 1e9 + 7;
bool tag[N];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	string res; res.resize(n);
	bool ok = 1;
	for(int i=1; i<=m; i++)
	{
		int s, c;
		cin >> s >> c;
		if(tag[s-1] && c+'0'!=res[s-1]) ok = 0;
		res[s-1] = '0' + c;
		tag[s-1] = 1;
	}
	if(!tag[0]) if(n>1) res[0] = '1'; else res[0] = '0';
	if(res[0]=='0'&&n!=1) ok = 0;
	for(int i=1; i<n; i++) if(!tag[i]) res[i] = '0';
	if(ok) cout << res;
	else cout << -1;
	return 0;
}

Measured memory_bytes: 256
#include <deque>
#include <string>
#include <iostream>

using namespace std;

int main(int argc, char** argv) {
    string s;
    cin >> s;
    int q;
    cin >> q;

    int status = 0;
    deque<char> s_deque(s.begin(), s.end());
    for (int i = 0; i < q; i++) {
        int t;
        cin >> t;
        if (t == 1) {
            status++;
            continue;
        }
        else {
            int f;
            char c;
            cin >> f;
            cin >> c;
            if (status % 2 == 0) {
                if (f == 1) {
                    s_deque.push_front(c);
                }
                else {
                    s_deque.push_back(c);
                }
            }
            else {
                if (f == 1) {
                    s_deque.push_back(c);
                }
                else {
                    s_deque.push_front(c);
                }
            }
        }
    }

    string res;
    if (status % 2 == 1) {
        res = string(s_deque.rbegin(), s_deque.rend());
    }
    else {
        res = string(s_deque.begin(), s_deque.end());
    }

    cout << res << endl;

    return 0;
}

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

using namespace std;
using LL = long long;
using P = pair<int,int>;
const LL mod=1e9+7;

LL dp[10010][110][2];

int main(){
	string K;
	cin >> K;
	int N=K.size();
	LL D;
	cin >> D;
	dp[0][0][0]=1;
	rep(i,N){
		int n=K[i]-'0';
		rep(j,D){
			(dp[i+1][(j+n)%D][0]+=dp[i][j][0])%=mod;
			rep(k,10) (dp[i+1][(j+k)%D][1]+=dp[i][j][1])%=mod;
			rep(k,n) (dp[i+1][(j+k)%D][1]+=dp[i][j][0])%=mod;
		}
	}
	LL ans=dp[N][0][0]+dp[N][0][1]-1;
	if(ans<0) ans+=mod;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 17408
import sys
def input():
	return sys.stdin.readline().strip()

N = int(input())
A = list(map(int, input().split()))

A_sum = [0]
for i in range(N):
	A_sum.append(A_sum[-1] + A[i])

ans = 10**14

one = 0
three = 2
for i in range(1, N - 2):
	if three == i:
		three += 1
	sum_half1 = A_sum[i + 1]
	sum_half2 = A_sum[-1] - A_sum[i + 1]
	while one < i - 1:
		if abs(A_sum[one + 1] - sum_half1/2) > abs(A_sum[one + 2] - sum_half1/2):
			one += 1
		else:
			break
	while three < N - 2:
		if abs(A_sum[three + 1] - A_sum[i + 1] - sum_half2/2) > abs(A_sum[three + 2] - A_sum[i + 1] - sum_half2/2):
			three += 1
		else:
			break

	x = max(A_sum[one + 1], A_sum[i + 1] - A_sum[one + 1], A_sum[three + 1] - A_sum[i + 1], A_sum[-1] - A_sum[three + 1])
	y = min(A_sum[one + 1], A_sum[i + 1] - A_sum[one + 1], A_sum[three + 1] - A_sum[i + 1], A_sum[-1] - A_sum[three + 1])
	ans = min(ans, x - y)
	#print(one, i, three, x - y, ans, sum_half2//2)
print(ans)

Measured memory_bytes: 111284
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define vi vector <int>
#define vii vector <int>::iterator 
#define vd vector <double>
#define vdd vector <double>::iterator
#define vs vector <string>
#define vss vector <string>::iterator
#define vc vector <char>
#define vcc vector <char>::iterator
#define maxx(a,b,c) max(a,max(b,c))
#define minn(a,b,c) min(a,min(b,c))
#define SORT(x)     sort(x.begin(),x.end())
#define fill(x,y)   memset(x, y, sizeof(x))
#define PI 2*acos(0.0)
#define fio ios::sync_with_stdio(false);cin.tie(0)
using namespace std;
int main(){
   string s;
    cin >> s;
    int i , cn=0;
    for(i=0; i<s.size(); i++){
        cn+= (s[i]-'0');
    }
    if(cn%9==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}

Measured memory_bytes: 3720
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var N = long.Parse(ReadLine());

        var d = yakusuu(N);
        var ans = 0L;
        for (int i = 0; i < d.Length; i++)
        {
            var k = (N - d[i]) / d[i];
            if (k != 0 && N / k == N % k) ans += k;
        }

        WriteLine(ans);
    }

    static long[] yakusuu(long n)
    {
        var r = new List<long>();
        for (long i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                r.Add(i);
                if (i * i != n) r.Add(n / i);
            }
        }
        return r.ToArray();
    }
}

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

vector<int> FindSource(vector<int> indegree, int n)
{
    vector<int> res;
    for(int i=1; i<=n; ++i)
    {
        if (indegree[i] == 0)
            res.push_back(i);
    }

    return res;
}


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
 
    int N, M, u, v;
    cin >> N >> M;

    vector<int> adjList[N + 1];
    vector<int> indegree(N + 1, 0);
    vector<int> distance(N + 1, 0);
    
    for(int i=0; i<M; ++i)
    {
        cin >> u >> v;
        adjList[u].push_back(v);
        ++indegree[v];
    }

    vector<int> sources = FindSource(indegree, N);

    queue<int> q;
    
    for(int source: sources)
        q.push(source);

    int ans = 0;
    while (!q.empty())
    {
        int currentNode = q.front(); q.pop();

        for(int i=0; i < adjList[currentNode].size(); ++i)
        {
            int nextNode = adjList[currentNode][i];
            distance[nextNode] = max(distance[nextNode], distance[currentNode] + 1);
            ans = max(ans, distance[nextNode]);
            --indegree[nextNode];
            if (indegree[nextNode] == 0)
            {
                q.push(nextNode);
            }
        }
    }

    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 6912
#include <iostream>

using namespace std;
int main(){
	int i,j,h,w,a,b;
	cin >> h >> w >> a >> b;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if((i<b && j<a) || (i>=b && j>=a)){
				cout << 0;
			}else{
				cout << 1;
			}
		}
		cout << endl;
	}
}
	

Measured memory_bytes: 1280
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        String input =  "";
        try {
            input = bufferedReader.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        int count = 0;
        for (int i = 0; i < input.length(); i++) {
            if ('1' == input.charAt(i)){
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int, int>;
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n, M[N][N];
int color[N], d[N], f[N], tt;

// 再帰関数による深さ優先探索

void dfs_visit(int u) {
    int v;
    color[u] = GRAY;
    d[u] = ++tt; // 最初の訪問
    for (v = 0; v < n; ++v) {
        if (M[u][v] == 0) continue;
        if (color[v] == WHITE) {
            dfs_visit(v);
        }
    }

    color[u] = BLACK;
    f[u] = ++tt; // 訪問の完了
}

void dfs() {
    int u;
    // 初期化
    for (u = 0; u < n; ++u) color[u] = WHITE;
    tt = 0;

    for (u = 0; u < n; ++u) {
        // 未訪問の u を始点として深さ優先探索
        if (color[u] == WHITE) dfs_visit(u);
    }
    for (u = 0; u < n; ++u) {
        printf("%d %d %d\n", u+1, d[u], f[u]);
    }
}

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

    scanf("%d", &n);
    for (i = 0; i < n; ++i) {
        for (j = 0; j < n; j++) M[i][j] = 0;
    }

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

    dfs();

    return 0;
}


Measured memory_bytes: 3244
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author parsa bahrami
 */

#pragma GCC optimize("O2")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;
typedef pair<string, string> pss;

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define sz(x)                       (ll) x.size()
#define jjoin(x)                    for (auto i : x) cout << i << endl;
#define all(x)                      (x).begin(),(x).end()
#define F                           first
#define S                           second
#define Mp                          make_pair
#define sep                         ' '
#define error(x)                    cerr << #x << " = " << x << endl
#define fast_io                     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random                  mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#define kill(x)                     return cout << x << endl , 0;
#define endl                        '\n'

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

const ll MAXN = 2e5 + 10;
const ll MAXA = 101;
const ll INF = 8e18;
const ll MOD = 998244353; //1e9 + 7
const ld PI = 4 * atan((ld) 1);
vector<ll> adj[MAXN];
bool mark[MAXN];

void dfs(ll v) {
    mark[v] = true;
    for (auto u : adj[v]) {
        if (!mark[u]) dfs(u);
    }
    return;
}

int main() {
    fast_io;
    set_random;
    ll n, m;
    cin >> n >> m;
    for (ll i = 1; i <= m; i++) {
        ll x, y, z;
        cin >> x >> y >> z;
        adj[y].push_back(x);
        adj[x].push_back(y);
    }
    ll cnt = 0;
    for (ll i = 1; i <= n; i++) {
        if (!mark[i]) {
            dfs(i);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    rep(i, n) {
        int a;
        cin >> a;
        a /= 400;
        mp[a]++;
    }
 
    int ans = 0;
    int free = 0;
    for (auto x : mp) {
        if (x.fi >= 8) free += x.se;
        else ans++;
    }
 
    cout << max(ans, 1) << " " << ans+free << endl;
    return 0;
}

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

using namespace std;

#define INPUT_OUTPUT { \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout); \
}
#define ll long long

int main()
{
    // INPUT_OUTPUT;
    int a, b;
    cin >> a >> b;
    cout << max((a+b),max((a-b),(a*b))) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N; cin >> N;
  string S; cin >> S;
  map<char, long int> count;
  for(int i = 0; i < N; i++) count[S[i]] += 1;
  long int ans = count['R'] * count['G'] * count['B'];
  for(int i = 1; i < N - 1; i++){
    for(int r = 1; r <= min(i, N - 1 - i); r++){
      if(S[i - r] != S[i] && S[i + r] != S[i] && S[i - r] != S[i + r]) ans -= 1;
    }
  }
  cout << ans;
  return 0;
}

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

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

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

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

	ll l, r;
	l = (a + x - 1) / x;
	r = b / x;
	cout << r - l + 1 << endl;
	return 0;
}

Measured memory_bytes: 384
n = int(input())
arr = list(map(int, input().split()))
alice = 0
bob = 0
chance = "A"
for _ in range(len(arr)):
	i = max(arr)
	if chance == "A":
		alice += i
		chance = "B"
	else:
		bob += i
		chance = "A"
	indx = arr.index(i)
	del arr[indx]
print(alice - bob)

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  ll a, b, n;
  cin >> a >> b >> n;
  n = min(n, b-1);
  ll ans = (a*n/b) - a*(n/b);
  cout << ans << endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<ll> d(n),dd(n);
    
    for (int i=0;i<n;i++) {
        cin >> d[i];
        dd[d[i]]++;
    }
    ll ans=0;
    int j=0;
    if (d[0]==0&&dd[0]==1) {
        ans=1;
        while (dd[j]!=0) {
            ll s=1;
            for (int k=0;k<dd[j+1];k++) {
                s*=dd[j];
                s=s%md;
            }
            ans*=s;
            ans=ans%md;
            j++;
        }
    }
    auto itr=max_element(d.begin(),d.end());
    if (*itr!=j-1) ans=0;

    cout << ans << endl;
}

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

int main() {
  int i, j, n, m, cnt, max = 0;
  cin >> n;
  string *s = new string[n];
  for (i = 0; i < n; i++)
    cin >> s[i];
  cin >> m;
  string *t = new string[m];
  for (i = 0; i < m; i++)
    cin >> t[i];
  
  for (i = 0; i < n; i++) {
    cnt = 1;
    for (j = 0; j < n; j++)
      if (s[i] == s[j] && i != j) cnt++;
    for (j = 0; j < m; j++)
      if (s[i] == t[j]) cnt--;
    if (cnt > max)
      max = cnt;
  }
  cout << max << endl;
  delete[] s;
  delete[] t;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	char S[10] = {0};
	scanf("%s",S);
	int i,len = 10;
	for(i = 0;i<10;i++){
		if(S[i] == 0){
			len = i;
			break;
		}
	}
	int min = 1000;
	for(i = 0;i<=len-3;i++){
		int num = (S[i]-'0')*100+(S[i+1]-'0')*10+S[i+2]-'0';
		int abs = num >= 753 ? num - 753 : 753 - num;
		if(abs < min)min = abs;
	}
	printf("%d\n",min);

}

Measured memory_bytes: 128
#include <iostream>
#include <string>

using namespace std;

int main() {
    string t;   int l; cin >> l >> t;
    int ans = 0;
    for (int i = 0; i <= 9; i++) {
        for (int j = 0; j <= 9; j++) {
            for (int k = 0; k <= 9; k++) {
                bool flag = false;
                int l = 0;
                for (; l < t.length(); l++) {
                    if (t[l]-'0' == i) {
                        flag = true;
                        l++;
                        break;
                    }
                }
                
                if (flag == false)
                    break;
                flag = false;
                for (; l < t.length(); l++) {
                    if (t[l]-'0' == j){
                        flag = true;
                        l++;
                        break;
                    }
                }
                if (flag == false)
                    break;
                flag = false;
                for (; l < t.length(); l++) {
                    if (t[l]-'0' == k) {
                        flag = true;
                        l++;
                        break;
                    }
                }
                if (flag)
                    ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3672
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define MAX 2000000
#define INFITY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i) // sink(int i)
{
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;

    if (l <= H && A[l] > A[i]) largest = l;
    else largest = i;
    if (r <= H && A[r] > A[largest]) largest = r;

    if (largest != i) {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int extract()
{
    int maxv;
    if (H < 1) return -INFITY;
    maxv = A[1];
    A[1] = A[H--];
    maxHeapify(1);
    return maxv;
}

void increaseKey(int i, int key) // swim(int i)
{
    if (key < A[i]) return;
    A[i] = key;
    while (i > 1 && A[i/2] < A[i]) {
        swap(A[i], A[i/2]);
        i = i / 2;
    }
}

void insert(int key)
{
    H++;
    A[H] = -INFITY;
    increaseKey(H, key);
}

int main(int argc, char const *argv[])
{
    int key;
    char com[10];
    while (1) {
        scanf("%s", &com);
        if (com[0] == 'e' && com[1] == 'n') break;
        if (com[0] == 'i') {
            scanf("%d", &key);
            insert(key);
        } else {
            printf("%d\n", extract());
        }
    }

    return 0;
}



Measured memory_bytes: 6504
s = list(input())
k = int(input())

for i, c in enumerate(s):
    t = (ord("z") - ord(c) + 1) % 26
    if k >= t:
        s[i] = "a"
        k -= t

t = k % 26
s[-1] = chr(ord(s[-1]) + t)

print("".join(s))


Measured memory_bytes: 10048
n = gets.chomp.to_i
d,x = gets.chomp.split(" ").map(&:to_i)

a_arr = []
n.times do |i|
  a_arr << gets.chomp.to_i
end

count = 0
a_arr.each do |a|
  t = 0
  while t * a + 1 <= d do
    count += 1
    t += 1
  end
end

puts count + x


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

inline vector<P> countVec(vector<int> vec){
    vector<P> ans;
    sort(vec.begin(),vec.end());
    vec.push_back(0);
    int cnt=0;
    rep(i,vec.size()-1){
        cnt++;
        if(vec.at(i)!=vec.at(i+1)){
            ans.push_back(P(cnt,vec.at(i)));
            cnt=0;
        }
    }
    return ans;
}

signed main(){
    int n; cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a.at(i);
    vector<P> p=countVec(a);
    int ans=0;
    rep(i,p.size()){
        if(p.at(i).first%2==1) ans++;
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main()
{
	int N,A[100010]={};
	int ans=0;	
	cin >> N;
	for(int i=0;i<N;i++){
		cin >> A[i];
	}	
	sort(A,A+N);	
	int cnt=0;
	for(int i=0;i<N;i++){
		cnt++;
		if(A[i]!=A[i+1]){
			ans+=(cnt%2);
			cnt=0;
		}
	}
	cout << ans << endl;
}


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

int main(){
	int n;
	scanf("%d",&n);
	int a[5];
	int l = 0;
	while(n>0){
		l++;
		a[l] = n%10;
		n/=10;
	}
	int flag = 0;
	for(int i = 1; i<= l; i++){
		if(a[i] == 7){
			flag = 1;
			break;
		} 
	}
	if(flag == 1) printf("Yes\n");
	else printf("No\n");
} 

Measured memory_bytes: 3736
//“ In order to be irreplaceable, one must always be different”
#include <bits/stdc++.h>
using namespace std;
# define ll long long
#define endl "\n"
# define pi 3.14159265359
# define str string
# define vll vector<ll>
# define vstr vector<str>
# define vchar vector<char>
# define pb push_back
# define popb pop_back
# define pf push_front
# define popf pop_front
# define sll set<ll>
# define schar set<char>
//find()
//erase(x) removes element x
//erase(position,position)
# define qll queue<ll>
# define qstr queue<str>
//front(),back()
# define stll stack<ll>
# define ststr stack<str>
//top()
# define dll deque<ll>
//at()
# define mll map<ll,ll>
#define mchar map<char, ll>
# define mstr map<str,ll>
# define mss map<str,str>
# define mci map<char,ll>
# define vp vector< pair<ll,ll> >
#define mp make_pair
#define ff first
#define ss second
#define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
# define r(x,y) for(int x=y;x>=0;x--)
# define fr(x,y,z) for(int x=y;x<z;x++)
# define rr(x,y,z) for(int x=y;x>z;x--)
ll power(ll a , ll b){ll res=1;for(ll i=0; i<b; ++i){res*=a;}return res;}
ll logx(ll base, ll num){int cnt=0;while(num!=1){num/=base; ++cnt;}return cnt;}
ll gcd(ll a, ll b){
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a, b);
}
void print(vll a){
    for(int i=0;i<a.size();i++){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}
vll inp(int n){
    vll a;
    ll x;
    f(i,n){
        cin>>x;
        a.pb(x);
    }
    return a;
}




int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    ll x;
    cin>>x;
    ll a[x];
    mll m;
    f(i,x){
        cin>>a[i];
        m[a[i]]++;
    }
    mll m2;
    ll s2=0;
    for(auto j:m){
            ll k=j.second;
            k--;
            s2+=(k)*(k+1)/2;
    }
    //cout<<s2;
    ll s;
    f(i,x){
        s=s2;
        ll k=m[a[i]];
        k--;
        ll k1=k*(k+1)/2;
        s-=k1;
        k=m[a[i]];
        k--;
        k--;
         k1=k*(k+1)/2;
         s+=k1;
         cout<<s<<endl;
    }
}




Measured memory_bytes: 11136
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

use std::cmp;

fn main() {
    let nmxy = (read::<usize>(), read::<usize>(), read::<i32>(), read::<i32>());
    let mut x = vec![0; nmxy.0];
    let mut y = vec![0; nmxy.1];

    for i in 0..nmxy.0 {
        x[i] = read::<i32>();
    }
    for i in 0..nmxy.1 {
        y[i] = read::<i32>();
    }


    let mut x_max = *x.iter().max().unwrap();
    let mut y_min = *y.iter().min().unwrap();
    x_max = cmp::max(x_max, nmxy.2);
    y_min = cmp::min(y_min, nmxy.3);

    if x_max >= y_min {
        println!("War");
    } else {
        println!("No War");
    }
}

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

#define SZ size()
#define MIN LLONG_MIN
#define MAX LLONG_MAX
#define M 1000000007
#define MP make_pair
#define F first
#define S second
#define endl "\n"
#define sqr(x) ((x)*(x))
#define INF 0x3f3f3f3f

#define pb push_back
#define N 100005
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(v) (v).begin(),(v).end()
//#define f(i,n) for(int i=1;i<(int)n;i++)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<char> vc;
typedef vector< vc > vvc;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector< vb > vvb;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
typedef set<pii> spii;
typedef set<int> si;
typedef map<int, int> mii;
typedef map<char, int> mci;
typedef map<string, int> msi;





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

ll h[n+1] = {0};
	for(int i =1;i<=n;i++) cin >> h[i];

ll dp[n+1] = {0};
	dp[0] = h[0] = 0;
		dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[n] << " ";
	
	
	
	return 0;
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

double cross_product (xy_t a, xy_t b) {
    return (conj(a) * b).imag();
}

double interpoint (xy_t a, xy_t b, xy_t c, xy_t d) {
    xy_t p = b - a;
    xy_t q = d - c;
    return cross_product(q, c - a) / cross_product(q, p);
}

int main() {
    cout << setprecision(12);
    xy_t p[3];
    for (int j = 0; j < 3; j++) {
        double x, y;
        cin >> x >> y;
        p[j] = xy_t(x, y);
    }
    xy_t base = p[0];
    for (int i = 0; i < 3; i++) {
        p[i] -= base;
    }
    double theta = arg(p[1]);
    double d = abs(p[1]);
    p[1] = (xy_t)(d);
    p[2] *= exp(- theta * xy_t(0, 1));
    if (p[2].imag() < 0) {
        p[2] = conj(p[2]);
    }
    // for (int i = 0; i < 3; i++) {
    //     cout << p[i] << endl;
    // }
    double hi = 10000;
    double lo = 0;
    while (hi - lo > eps) {
        double mid = (hi + lo) / 2;
        bool ok = false;
        xy_t q[3];
        double arga = arg(p[2]);
        //cout << arga << endl;
        xy_t mva = mid * xy_t(cos(arga - pi / 2), sin(arga - pi / 2));
        //cout << mva << endl;
        double disa = interpoint(mva, mva + p[2], xy_t(0, mid), xy_t(10, mid));
        //cout << disa << endl;
        //cout << endl;
        q[0] = mva + p[2] * disa;
        double argb = arg(p[2] - p[1]);
        xy_t mvb = mid * xy_t(cos(argb + pi / 2), sin(argb + pi / 2));
        double disb = interpoint(p[1] + mvb, p[2] + mvb, xy_t(0, mid), xy_t(10, mid));
        q[1] = p[1] + mvb + (p[2] - p[1]) * disb;
        double disc = interpoint(mva, mva + p[2], p[1] + mvb, p[2] + mvb);
        q[2] = mva + p[2] * disc;
        //cout << mid << endl;
        //cout << q[0] << " " << q[1] << " " << q[2] << endl;
        if (q[0].real() < q[1].real()) {
            if (q[2].imag() > q[0].imag()) {
                if (abs(q[0] - q[1]) >= 2 * mid || abs(q[0] - q[2]) >= 2 * mid || abs(q[1] - q[2]) >= 2 * mid) {
                    ok = true;
                }
            }
        }
        if (ok) {
            lo = mid;
        } else {
            hi = mid;
        }
    }
    cout << lo << endl;
}


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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll N,K;
	cin >> N>>K;
	vector<ll> v;
	for(int i = 0; i<N;i++)
	{
		ll temp;
		cin >>temp;
		v.push_back(temp);
	}
	queue<ll> q;
	for(int i = 0; i<K;i++)
	{
		q.push(v[i]);
	}
	for(int i = K; i<N;i++)
	{
		ll t = q.front();
		q.pop();
		if(v[i] > t)
		{
			cout <<"Yes\n";
		}
		else
		{
			cout <<"No\n";
		}
		q.push(v[i]);
	}

}


Measured memory_bytes: 6304
import collections as co
n = int(input())

test = co.Counter(list(input() for i in range(n)))

print("AC x " + str(test.get('AC') if test.get('AC') != None else 0))
print("WA x " + str(test.get('WA') if test.get('WA') != None else 0))
print("TLE x " + str(test.get('TLE') if test.get('TLE') != None else 0))
print("RE x " + str(test.get('RE') if test.get('RE') != None else 0))




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

h,w = MAP()
s = [STR() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            flag = [False for _ in range(4)]
            if i > 0 and s[i-1][j] == '#':
                flag[0] = True
            if i < h - 1 and s[i+1][j] == '#':
                flag[1] = True
            if j > 0 and s[i][j-1] == '#':
                flag[2] = True
            if j < w - 1 and s[i][j+1] == '#':
                flag[3] = True
            if sum(flag) == 0:
                print('No')
                exit()
print('Yes')

Measured memory_bytes: 62444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

int main() {
    int n;
    cin>>n;
    int p[n],q[n];
    rep(i,n) cin>>p[i];
    rep(i,n) cin>>q[i];
    vector<int> ord(n);
    rep(i,n) ord[i]=i+1;

    int x=1,a=0,b=0;
    do{
        bool ok1=true,ok2=true;;
        rep(i,n){
            if(p[i]!=ord[i]) ok1=false;
            if(q[i]!=ord[i]) ok2=false;
        }
        if(ok1) a=x;
        if(ok2) b=x;
        x++;
    }while(next_permutation(all(ord)));

    cout<<abs(a-b)<<endl;
}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define ll long long


int main()
{
	ll n;
	cin>>n;
	ll x,y;
	ll i;
	ll cnt=0;
	ll f=0;
	for(i=0;i<n;i++)
	{
		cin>>x>>y;
		if(x==y)
		{
			cnt++;
		}
		else
		{
			cnt=0;
		}
		if(cnt>=3)
		{
			f=1;
		}
	}
	if(f==0)
	{
		cout<<"No"<<"\n";
	}
	else
	{
		cout<<"Yes"<<"\n";
	}
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<fstream>
using namespace std;
string st;
int main(){
	getline(cin,st);
	int s=0;
	for(int i=0;i<st.size();i++)
	{
		if(st[i]=='C'&&s==0) s++;
		if(st[i]=='F'&&s==1) s++;
	}
	if(s==2) cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
program c
    real :: x, k, exist, rest
    exist = 0
    
    read *, x

    ! k個買うと仮定
    ! 100k円をxから引き、残りが[0, 5*k] なら帳尻合わせ可能
    do k = 0, x
        rest = x - 100 * k
        if (0 .le. rest .and. rest .le. 5*k) then
        	exist = 1
            exit
        end if
    end do
    
    ! 結果出力
    print '(i0)', int(exist)
    
end program c

Measured memory_bytes: 384
// orignal author is :https://cp-wiki.vercel.app

#include <iostream>
#include <queue>
#include <vector>

using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> a(n), b(n), cb(n + 1);
  vector<bool> taken(n);
  vector<vector<int>> ca(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    ca[a[i]].emplace_back(i);
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
    cb[b[i]]++;
  }
  priority_queue<pair<int, int>> pq;
  for (int i = 1; i <= n; ++i) {
    int lo = min((int)ca[i].size(), cb[i]);
    if (lo)
      pq.emplace(lo, i);
  }
  while (pq.size() >= 2) {
    auto [cx, x] = pq.top();
    pq.pop();
    auto [cy, y] = pq.top();
    pq.pop();
    if (cx == 1 && pq.size() == 1) {
      auto [cz, z] = pq.top();
      pq.pop();
      int px = ca[x].back();
      int py = ca[y].back();
      int pz = ca[z].back();
      taken[px] = taken[py] = taken[pz] = true;
      b[px] = y;
      b[py] = z;
      b[pz] = x;
      ca[x].pop_back();
      ca[y].pop_back();
      ca[z].pop_back();
      cb[x]--;
      cb[y]--;
      cb[z]--;
    } else {
      int px = ca[x].back();
      int py = ca[y].back();
      taken[px] = taken[py] = true;
      b[px] = y;
      b[py] = x;
      ca[x].pop_back();
      ca[y].pop_back();
      cb[x]--;
      cb[y]--;
      if (cx > 1)
        pq.emplace(cx - 1, x);
      if (cy > 1)
        pq.emplace(cy - 1, y);
    }
  }
  int idx = 0;
  if (!pq.empty()) {
    auto [cx, x] = pq.top();
    pq.pop();
    while (cb[x]) {
      while (idx < n && (taken[idx] || a[idx] == x))
        idx++;
      if (idx >= n)
        break;
      b[idx] = x;
      cb[x]--;
      taken[idx] = true;
    }
    if (cb[x]) {
      cout << "No" << flush;
      return 0;
    }
  }
  vector<int> rest;
  idx = 0;
  for (int i = 1; i <= n; ++i)
    if (cb[i]) {
      for (int j = 0; j < cb[i]; ++j)
        rest.emplace_back(i);
    }
  for (int i : rest) {
    while (taken[idx])
      idx++;
    b[idx] = i;
    taken[idx] = true;
  }
  cout << "Yes" << endl;
  for (int i : b)
    cout << i << " ";
  cout << flush;
}

Measured memory_bytes: 18572
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
#define pb(n) push_back(n)
#define ue(N) N.erase(unique(N.begin(),N.end()),N.end());
#define nou(S) cout << S
#define hou(S) cout << setprecision(30) << S << endl
#define vec(K,L,N,S) vector<L> K(N,S)
#define dv(K,L,N,M,S) vector<vector<L>> K(N,vector<L>(M,S))
#define tv(K,L,N,M,R,S) vector<vector<vector<L>>> K(N,vector<vector<L>>(M,vector<L>(R,S)))
#define pint pair<lli,lli>
#define paf(L,R) pair<L,R>
#define mod 1000000007
#define maxx 5100000
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
using namespace std;
int main(){
  string n;
  cin>>n;
  rep(i,0,n.size())
    if(n.at(i)=='9'){
      ou("Yes");
      return 0;
    }
  ou("No");
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;

public class Main {
	static int v = 0;
	static List<List<Integer>> ansList = null;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());

		String[] sa = br.readLine().split(" ");
		int[] t = new int[n];
		for (int i = 0; i < n; i++) {
			t[i] = Integer.parseInt(sa[i]);
		}

		sa = br.readLine().split(" ");
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int[] min = new int[n];
		int[] max = new int[n];
		Arrays.fill(min, 1);
		Arrays.fill(max, Integer.MAX_VALUE);
		min[0] = t[0];
		max[0] = t[0];
		for (int i = 1; i < n; i++) {
			if (t[i - 1] == t[i]) {
				max[i] = max[i - 1];
			} else {
				min[i] = t[i];
				max[i] = t[i];
			}
		}

		if (min[n - 1] <= a[n - 1] && a[n - 1] <= max[n - 1]) {
			min[n - 1] = a[n - 1];
			max[n - 1] = a[n - 1];
		} else {
			System.out.println(0);
			return;
		}
		for (int i = n - 2; i >= 0; i--) {
			if (a[i + 1] == a[i]) {
				max[i] = Math.min(max[i], max[i + 1]);
			} else {
				if (min[i] <= a[i] && a[i] <= max[i]) {
					min[i] = a[i];
					max[i] = a[i];
				} else {
					System.out.println(0);
					return;
				}
			}
		}

		long ans = 1;
		for (int i = 0; i < n; i++) {
			int d = max[i] - min[i] + 1;
			ans *= d;
			ans %= 1000000007;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 52532
#include<stdio.h>

int main(){
    int i;
    double a[7]={35.5,37.5,40.0,43.0,50.0,55.0,70.0};
    double b[7]={71.0,77.0,83.0,89.0,105.0,116.0,148.0};
    char e[7][4]={{'A','A','A','\0'},{'A','A','\0'},{'A','\0'},{'B','\0'},{'C','\0'},{'D','\0'},{'E','\0'}};
    //char e[7][4]={{"AAA"},{"AA"},{"A"},{"B"},{"C"},{"D"},{"E"}};
    double c,d;

    while(scanf("%lf%lf",&c,&d)!=EOF){
        for(i=0;(a[i]<=c||b[i]<=d)&&i<7;i++);
        if(i==7)puts("NA");
        else printf("%s\n",e[i]);
    }
    return 0;
}

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

vector<int> g[100000];
int ans[100000];
void bfs() {
  queue<int> q;
  q.push(0);
  while (!q.empty()) {
    int cur = q.front();
    q.pop();
    for (int to: g[cur]) {
      if (to != 0 && ans[to] == -1) {
        ans[to] = cur;
        q.push(to);
      }
    }
  }
}
int main() {
  int n, m;
  cin>>n>>m;
  for (int i=0; i<m; i++) {
    int a, b;
    cin>>a>>b;
    --a;
    --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  for (int i=0; i<n; i++) ans[i] = -1;
  bfs();
  cout<<"Yes"<<endl;
  for (int i=1; i<n; i++) {
    cout<<ans[i]+1<<endl;
  }
}

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

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  string s;
  cin >> s;
  int n = s.length();
  REP(i, 0, n) {
    // ranges
    vector<VI> ranges(26, VI(n - i, 0));
    REP(j, 0, n) {
      int c = s[j] - 'a';
      REP(k, max(j - i, 0), min(j, n - 1 - i) + 1) {
	ranges[c][k] = 1;
      }
    }
    // exists some letter
    REP(c, 0, 26) {
      bool all = true;
      REP(j, 0, n - i) {
	if (ranges[c][j] == 0) {
	  all = false;
	  break;
	}
      }
      if (all) {
	cout << i << endl;
	return 0;
      }
    }
  }
  assert (0);
}


Measured memory_bytes: 256
a = input().rstrip().split(" ")
N = int(a[0])
K = int(a[1])

n = []
for i in range(N):
    n.append(i + 1)

#print(n)
k = 0
for i in range(N):
    if i % 2 == 0:
#        print(n[i])
        k += 1
        if k == K:
            break
    else:
        continue

if k == K:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
const int maxn=51;
using namespace std;

struct node
{
	int x,y,w;
};
int G[maxn][maxn];
int vis[maxn][maxn];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
int ans=0;
int n,m;
void bfs(int x,int y,int acout)
{
	vis[x][y]=1;
	queue<node> q;
	q.push({x,y,0});
	while(!q.empty())
	{
		node np=q.front();q.pop();
		int x1=np.x;
		int y1=np.y;
		int w=np.w;
		ans=max(ans,w);
		for(int i=0;i<4;i++)
		{
			int nx=x1+dx[i];
			int ny=y1+dy[i];
			if(nx<=n && nx>0 && ny<=m && ny>0 && G[nx][ny]==1 && vis[nx][ny]==0)
			{
				vis[nx][ny]=1;
				q.push({nx,ny,w+1});
			}
		}
	}
}
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		for(int j=0;j<s.length();j++)
		{
			if(s[j]=='.') G[i][j+1]=1;
			else G[i][j+1]=0;
		}
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(G[i][j]==1)
			{
				memset(vis,0,sizeof(vis));
				bfs(i,j,0);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i,m,n) for (int i = (m); (i) < (n); ++(i))
#define repeat_reverse(i,n) for (int i = (n)-1; (i) >= 0; --(i))
#define repeat_from_reverse(i,m,n) for (int i = (n)-1; (i) >= (m); --(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
typedef long long ll;
using namespace std;
template <class T> void setmax(T & a, T const & b) { if (a < b) a = b; }
template <class T> void setmin(T & a, T const & b) { if (b < a) a = b; }
template <typename T, typename X> auto vectors(T a, X x) { return vector<T>(x, a); }
template <typename T, typename X, typename Y, typename... Zs> auto vectors(T a, X x, Y y, Zs... zs) { auto cont = vectors(a, y, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> T input(istream & in) { T a; in >> a; return a; }
int main() {
    // input
    int n, m; cin >> n >> m;
    map<int,int> xs;
    repeat (i,n) {
        int x; cin >> x;
        xs[x] += 1;
    }
    // compute
    vector<int> cnt(m), pr(m);
    for (auto it : xs) {
        int x, k; tie(x, k) = it;
        cnt[x % m] += k;
        pr [x % m] += k / 2 * 2;
    }
    int ans = 0;
    repeat (i,m) {
        int j = (m - i) % m;
        if (i == j) {
            ans += cnt[i] / 2;
        } else if (i < j) {
            int k = min(cnt[i], cnt[j]);
            ans += k;
            ans += min(cnt[i] - k, pr[i]) / 2;
            ans += min(cnt[j] - k, pr[j]) / 2;
        }
    }
    // output
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>
#define N 100
#define WHITE 0
#define BLACK 2
#define GRAY 1
#define INFTY 100000

int prim(void);

int n,G[N][N];

int main(){
  int i,j;
  scanf("%d",&n);
  for(i = 0;i < n;i++){
    for(j = 0;j < n;j++){
      scanf("%d",&G[i][j]);
    }
  }
  printf("%d\n",prim());
  return 0;
}

int prim(){
  int i,u,v,d[N],p[N],color[N],min,sum=0;
  for(i = 0;i < n;i++){
    p[i]=-1;
    color[i]=WHITE;
    d[i]=INFTY;
  }
  
  d[0]=0;

  while(1){
    min = INFTY;
    for(i = 0;i < n;i++){
      if(color[i] != BLACK && d[i] < min){
	min = d[i];
	u = i;
      }
    }
    if(min == INFTY)break;
    color[u]= BLACK;
    for(v = 0;v < n;v++){
      if(color[v] != BLACK && G[u][v] != -1 && G[u][v] < d[v]){
	d[v] = G[u][v];
	p[v] = u;
	//printf("%d ",p[v]);
	color[v] = GRAY;
      }
    }
  }
  for(i = 0;i < n;i++){
    if(p[i] != -1){
      sum += G[i][p[i]];
      //printf("%d\n",G[i][p[i]]);
    }
  }
  return sum;
}

Measured memory_bytes: 632
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int main(void) {
  int a;
  string s;
  cin >> a >> s;
  cout << (a >= 3200 ? s : "red") << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
list1 = list(S)
#例えば4つ
a = list1[0]
b = list1[1]
c = list1[2]
d = list1[3]

if a == b:
    if c == d and a != c:
        print("Yes")
    else:
        print("No")
elif a == c:
    if b ==d and a != b:
        print("Yes")
    else:
        print("No")
elif a == d:
    if b == c and a != b:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    vector<pll> a;
    for (int i = 0; i < n; ++i) {
        ll aa;
        cin >> aa;
        a.emplace_back(aa, i);
    }
    sort(a.begin(), a.end());
    set<int> idx;
    idx.insert(-1);
    idx.insert(n);
    ll ret = 0;
    for (auto &p : a) {
        ll r   = *idx.upper_bound(p.second);
        ll l   = *prev(idx.upper_bound(p.second));
        ll cnt = (r - p.second-1) * (p.second - l-1) + (r - l - 1);
        ret += p.first * cnt;
        idx.insert(p.second);
    }
    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 13548