akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <math.h> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//F
//遠くにいく
//X,Yのabsの最大
int main(){
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    ll a,b,c,d;
    cin >> a >> b >> c >> d;

    ll res = 0;

    res += min(a,b);
    res += min(c,d);

    cout << res << endl;


    return 0;    

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>
 
using namespace std;

class team{
public:
	int ac,pe,num;
	vector<int> wa;
	team(int n){
		ac=0;pe=0;
		wa=vector<int>(n);
	}

	bool operator<(const team& t) const{
		return ac<t.ac || ac==t.ac && pe>t.pe || ac==t.ac && pe==t.pe && num<t.num;
	}
	bool operator==(const team& t) const{
		return ac==t.ac && pe==t.pe;
	}

};

int main()
{

	int M,T,P,R;
	while(cin>>M>>T>>P>>R,M){
		vector<team> vt(T,team(P));
		for(int i=0;i<T;i++) vt[i].num=i+1;
		for(int i=0;i<R;i++){
			int m,t,p,j;
			cin>>m>>t>>p>>j;

			if(j){
				vt[t-1].wa[p-1]++;
			}else{
				vt[t-1].ac++;
				//vt[t-1].last=m;
				vt[t-1].pe+=m+vt[t-1].wa[p-1]*20;
			}
		}
		sort(vt.begin(),vt.end());
		reverse(vt.begin(),vt.end());


		for(int i=0;i<vt.size()-1;i++){
			cout<<vt[i].num;
			if(vt[i]==vt[i+1]) cout<<"=";
			else cout<<",";
		}
		cout<<vt.back().num<<endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include<iostream>

using namespace std;

int main(){

    long long N,K,S;

    cin>>N>>K>>S;

    if(1){
        for(int i=0;i<N;i++){
            if(K>=1) cout<<S;
            else{
                if(S!=1000000000) cout<<"1000000000";
                else cout<<"999999999";
            }
            if(i>=0) K--;
            if(i!=N-1) cout<<" ";
            else cout<<endl;
        }
    }
}


Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
typedef long long int ll;

int main(){
	string s; cin >> s;
	int w; cin >> w;
	for(int i=0;i<s.size();i+=w){
		cout << s[i];
	}
	cout << endl;
}

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

using namespace std;

unsigned long long int a = 0, b = 0, c =1, d = 0, e = 9999, n = 0, maxy = 0, mini = 9999, ans = 1, counter = 0, sur = 0,kuso=0,kuso2=0;
std::vector<unsigned long long int> vec{};
std::vector<std::string>str{};
std::vector<std::string>str2{};

int arraykun[2300] = {}, nyan[1001] = {}, koji[50][50];
std::string output, output2, input,nyahhoi;
int kakunou[50][50] = { 53 }, moji[50];

int ctoi(const char c) {
	if ('0' <= c && c <= '9') return (c - '0');
	return -1;
}
unsigned long long int LCM(unsigned long long int a, unsigned long long int b) {
	unsigned long long int i, j;
	i = a; j = b;
	while (true) {
	
		c = i % j;
		i = j;
		if (c != 0) {
		
			j = c;

		}
		else {
			break;
		}
	}
	return j * (a / j) * (b / j);
}
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d;
		vec.push_back(d);
	}
	std::sort(vec.begin(), vec.end());
	for (int i = 0; i < n; i++) {
		ans = LCM(ans, vec[i]);
	
	}
	cout << ans<<endl;
	
	



}






Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long n,m;
  scanf("%lld%lld",&n,&m);
  if(n*m==1)
    printf("1\n");
  else if(n==1 || m==1)
    printf("%lld\n",n*m-2);
  else
    printf("%lld\n",(n-2)*(m-2));
  return 0;
}


Measured memory_bytes: 128
//周♂雨扬是最强的！！！
//大佬祝您AK
//沈哲♂贝是最强的！！！
//cogi♂to是最强的！！！
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int h,w;
char mp[503][503],ans1[503][503],ans2[503][503];
int main(){
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
        	cin>>mp[i][j];
		}
    }
    for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
    		if(i%2==1){
    			ans1[i][j]='#';
				ans2[i][j]='.';
			}else{
				ans1[i][j]='.';
				ans2[i][j]='#';
			}
		}
	}
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(mp[i][j]=='#'){
				ans1[i][j]='#';
				ans2[i][j]='#';
			}
		}
	}
	for(int i=0;i<h;i++){
		ans1[i][0]='#';
		ans1[i][w-1]='.';
		ans2[i][0]='.';
		ans2[i][w-1]='#';
	}
	for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
    		cout<<ans1[i][j];
		}
		cout<<endl;
	}
	cout<<endl;
	for(int i=0;i<h;i++){
    	for(int j=0;j<w;j++){
    		cout<<ans2[i][j];
		}
		cout<<endl;
	}
    return 0;
}
//cogi♂to是最强的！！！
//沈♂哲♂贝是最强的！！！
//大佬祝您AK
//周雨♂扬是最强的！！！


Measured memory_bytes: 1536
import math

S = int(input())
X = [0,0,0]
Y = [0,0,0]
ans = []

s = math.sqrt(S)
if S <= 10**9:
    X[1] = 1
    Y[2] = S
elif S <= 10**12:
    for x in range(math.ceil(s)):
        if S % x == 0 and x * 10**9 >= S:
            X[1] = x
            Y[2] = int(S//x)
else:
    X[1] = math.ceil(s)
    Y[2] = math.ceil(s)

    d = X[1]*Y[2] - S
    X[2] = 1
    Y[1] = d

for i in range(3):
    ans.append(str(X[i]))
    ans.append(str(Y[i]))
print(' '.join(ans))


Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a,p;
  cin >> a >> p;
  p += a * 3;
  cout << p / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int i,cnt,len;
	char s[200001],t[200001];
	scanf("%s %s",s,t);
	len=strlen(s);
	cnt=0;
	for(i=0;i<len;i++)	{
		if(s[i]!=t[i])	cnt++;
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
 char s[200010];
 int main(){
     scanf("%s",s);
     int len=strlen(s);
     int sum=0;
     for(int i=0;i<len;i++)sum+=s[i]-'0';
     if(sum%9==0){
         puts("Yes");
     }else{
         puts("No");
     }
 }


Measured memory_bytes: 3852
package main

import (
	"fmt"
	"os"
)

func main() {
	var k int
	fmt.Scanf("%d", &k)

	var l int
	if k%7 == 0 {
		l = 9 * k / 7
	} else {
		l = 9 * k
	}

	pow, rem := 1, 10%l
	for pow < l {
		if rem == 1 {
			fmt.Printf("%d\n", pow)
			os.Exit(0)
		} else {
			rem = (rem * 10) % l
			pow++
		}
	}

	fmt.Println("-1")
}


Measured memory_bytes: 1872
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <cmath>
#include <complex>
#include <algorithm>
#include <utility>
#include <regex>
#include <cstdint>
#include <numeric>
#include <functional>
#include <cassert>

using namespace std;
using ll = int64_t;
using ull = uint64_t;

constexpr ll INF = 1'000'000'000'000'000'000;
namespace utils{
    template<class T, class Compare> using p_queue = priority_queue<T, vector<T>, Compare>;
    template<class T> using min_queue = p_queue<T, greater<T>>;
    template<class T> using max_queue = p_queue<T, less<T>>;

    template<class T> bool min_update(T& X, const T& A){ if(X > A) {X = A; return true;} return false; }
    template<class T> bool max_update(T& X, const T& A){ if(X < A) {X = A; return true;} return false; }
    using V_Set = unordered_set<int>;
    using E_Set = unordered_map<int, V_Set>;

    ll operator"" _64(unsigned long long x){ return ll(x); }

    ull operator"" _64u(unsigned long long x){ return ull(x); }

#define ALL(x) begin(x), end(x)
#define rALL(x) rbegin(x), rend(x)
}
using namespace utils;


void sub_main(istream &is) {
    ll N;
    is >> N;
    if(!is) return;
    vector<ll> A(N);
    for (auto &&a : A) {
        is >> a;
    } // end a
    ll ds = 0;
    int np = 1;
    for (auto i : A) {
        ds += np * i;
        np *= -1;
    } // end i
    assert(ds >= 0);
    cout << ds;
    for (int i = 0; i < N-1; ++i) {
        ds = (A[i] - ds/2)*2;
        cout << ' ' << ds;
        assert(ds >= 0);
    } // end i
    cout << endl;

}

int main(int argc, char *argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(16) << scientific;
#ifdef DEBUG
    string test_cases = "test_D.txt";
    cerr << "DEBUG MODE" <<  endl;
    cerr << test_cases << " -->" << endl;
    auto fs = fstream(test_cases, fstream::in);
    int lp = 0;
    while(fs) {
        lp++;
        cout << lp <<  "#------\n";
        sub_main(fs);
    }
    cout << "------#" << endl;
    if(lp <= 1) sub_main(cin);
#else
    sub_main(cin);
#endif
    return 0;
}


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

int main() {
  ll k, x;
  cin >> k >> x;
  if (500 * k >= x) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
S = input()
j = True
for i in range(len(S)):
    if j is not True:
        break
    if i % 2 == 0:
        if S[i] == 'L':
            print('No')
            j = False
    else:
        if S[i] == 'R':
            print('No')
            j = False
if j:
    print('Yes')


Measured memory_bytes: 2940
#include<stdio.h>
int w,n,i;
int main(void){
        scanf("%d",&w);
        scanf("%d",&n);
        int data[w];
        for(i=0;i<w;i++) data[i] = i+1;
        for(i=0;i<n;i++){
                int data1,data2;
                scanf("%d,%d",&data1,&data2);
                int temp = data[data1-1];
                data[data1-1] = data[data2-1];
                data[data2-1] = temp;
        }
        for(i=0;i<w;i++) printf("%d\n",data[i]);
        return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2) % mod;
}
/*--------Library Zone!--------*/

int n, a[50], ans;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	REP(i, n - 1) {
		if ((a[i - 1] < a[i] && a[i] < a[i + 1]) || (a[i - 1] > a[i] && a[i] > a[i + 1]))ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define st first
#define nd second

using ll = long long ;
using namespace std;
using pii = pair<int,int>;

int main(){
	int n;
	scanf("%d", &n);
	if(n % 2 == 0 || n % 5 == 0) return !printf("-1");
	if(n == 7 ||n == 1) return !printf("1");
	if(n % 7 == 0) n /= 7;
	int rem = 1, ad = 1;
	for(int i = 2; i <= n; i++){
		ad *= 10;
		ad %= n;
		rem += ad;
		rem %= n;
		if(rem == 0) return !printf("%d", i);
	}


}

Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define STARTUP {(cin.tie(0));\
 (ios::sync_with_stdio(false));}

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define CINVEC(vec) REP(i,(vec).size()) cin>>(vec)[i];

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
std::istream& operator>>(std::istream& is, std::pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

using ll = long long;
using namespace std;
ll mod = 1'000'000'007;

const int INF = 1'050'000'000;

int main() {
    STARTUP;

    unordered_map<int, int> m;
    REP(i, 3) {
        int a;
        cin >> a;
        m[a]++;
    }

    YESNO(m[5] == 2 && m[7] == 1, "YES", "NO");

    return 0;
}

Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;
const LL MOD = 1000000007;

struct UnionFind {
	std::vector<int> _parent;
	std::vector<int> _size;
	std::vector<int> _values;
	UnionFind(int size) : _parent(size, -1), _size(size, 1), _values(size, -1) { }
	void unite(int a, int b) {
		int ra = root(a), rb = root(b); if (ra == rb) { return; }
		if (_size[ra] >= _size[rb]) {
			_parent[rb] = ra, _size[ra] += _size[rb];
			if (_values[rb] >= 0) {
				_values[ra] = _values[rb];
			}
		} else {
			_parent[ra] = rb, _size[rb] += _size[ra];
			if (_values[ra] >= 0) {
				_values[rb] = _values[ra];
			}
		}
	}
	int root(int a) {
		int p = _parent[a];
		if (p < 0) { return a; }
		while (_parent[p] >= 0) { p = _parent[p]; }
		return _parent[a] = p;
	}
	int size(int a) { return _size[root(a)]; }
	int& value(int node) { return _values[root(node)]; }
};

int main(int argc, char *argv[]) {
	string s;
	cin >> s;
	int len = (int)s.length();
	vector<LL> vis(len, -1);
	UnionFind uf(len);
	for (int i = 0; i < len; ++i) {
		int x = i;
		while (vis[x] < 0) {
			vis[x] = 0;
			if (s[x] == 'L') {
				uf.unite(x, x - 1);
				--x;
			} else {
				uf.unite(x, x + 1);
				++x;
			}
			if (vis[x] >= 0) {
				if (uf.value(x) < 0) {
					uf.value(x) = x;
				}
			}
		}
	}
	vector<int> count(len);
	for (int i = 0; i < len; ++i) {
		int pos = uf.value(i);
		if (abs(pos - i) % 2) {
			if (s[pos] == 'L') {
				--pos;
			} else {
				++pos;
			}
		}
		count[pos] += 1;
	}
	for (int i = 0; i < len; ++i) {
		if (i) cout << " ";
		cout << count[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
int main() {
    string a,b;
    cin>>a>>b;
    int A,B;
    A=a.length(),B=b.length();
    vector <vector <int>> answer(A+1,vector<int>(B+1,0));
    for(int i=1;i<=A;i++){
        for(int j=1;j<=B;j++){
            if(a[i-1]==b[j-1])answer[i][j]=answer[i-1][j-1]+1;
            else answer[i][j]=max(answer[i][j-1],answer[i-1][j]);
        }
    }
    int x=A,y=B;
    string s="";
    while(x!=0 && y!=0){
        if(answer[x][y]==answer[x][y-1]){
            y--;
            continue;
        }
        if(answer[x][y]==answer[x-1][y]){
            x--;
            continue;
        }
        s=a[x-1]+s;
        x--;y--;
    }
    cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 38964
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class AACOrWA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            if (a == b)
                out.println("Yes");
            else
                out.println("No");

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1) {
                throw new InputMismatchException();
            }
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0) {
                    return -1;
                }
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c)) {
                c = read();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9') {
                    throw new InputMismatchException();
                }
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null) {
                return filter.isSpaceChar(c);
            }
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector< vector<int> > vvi;

#define FOR(k,a,b) for(int k=(a); k<=(b); ++k)
#define IFOR(k,a,b) for(int k=(a); k>=(b); --k)
#define REP(k,a) for(int k=0; k<(a);++k)
#define IREP(k,a) for(int k=a-1; k>=(0);--k)
#define SZ(a) int((a).size())
#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define x first
#define y second
#define INF 1000000001
#define INFLONG 1000000000000000000
#define MOD 1000000007
#define MAX 100
#define ITERS 100
#define MAXM 200000
#define MAXN 1000000
#define PI 3.1415926535897932384626
#define ERR -987654321
#define MEM(a,b) memset(a,b,sizeof(a));
#define read1(a) scanf("%d",&a)
#define read2(a,b) scanf("%d%d",&a,&b)
#define read3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define readl1(a) scanf("%lld",&a)
#define readl2(a,b) scanf("%lld%lld",&a,&b)
#define readl3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	// int rn = uniform_int_distribution<int>(0, MAXN)(rng);

	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);

    int n;
    cin>>n;
    int a1[MAXN] = {0}, a2[MAXN] = {0};
    set<pii> m1, m2;
    int p;
    FOR(i,1,n) {
        cin>>p;
        if(i%2 == 0) {
            auto itr = m1.find(MP(a1[p],p));
            if(itr != m1.end()) m1.erase(itr);
            a1[p]++;
            m1.insert(MP(a1[p],p));
        }
        else {
            auto itr = m2.find(MP(a2[p],p));
            if(itr != m2.end()) m2.erase(itr);
            a2[p]++;
            m2.insert(MP(a2[p],p));
        }
    }


    auto l = m1.end(), r = m2.end();
    l-- ,r--;
    if(m1.size() == 1 && m2.size() == 1) {
        if((*l).y == (*r).y) cout<<n/2;
        else cout<<"0";
    } else if(m1.size() == 1 && m2.size() > 1) {
        if((*l).y == (*r).y) cout<<(n/2-(*(--r)).x);
        else cout<<(n/2-(*r).x);
    } else if(m1.size() > 1 && m2.size() == 1) {
        if((*l).y == (*r).y) cout<<(n/2-(*(--l)).x);
        else cout<<(n/2-(*l).x);
    } else {
        if((*l).y != (*r).y) cout<<(n-(*l).x-(*r).x);
        else {
            int p = (*l).x, q = (*r).x;
            p += (*(--r)).x , q+= (*(--l)).x;
            cout<<min((n-p), (n-q));
        }
    }
    
	
	return 0;
}

Measured memory_bytes: 12800
use proconio::input;
use std::cmp::*;

fn main() {
    input! {
        n: usize,
        a: [i64;n]
    }

    let mut ai: Vec<(i64, i64)> = a.iter().enumerate().map(|(i, &a)| (a, i as i64)).collect();
    ai.sort();
    ai.reverse();
    // 降順に並んだ。
    // println!("{:?}", ai);
    let mut dp = vec![vec![0; n + 1]; n + 1];
    dp[0][0] = 0;

    for (i, &(a, j)) in ai.iter().enumerate() {
        for l in 0..i + 1 {
            let r = i - l;
            dp[l + 1][r] = max(dp[l + 1][r], dp[l][r] + a * (j - (l as i64)));
            dp[l][r + 1] = max(dp[l][r + 1], dp[l][r] + a * ((n - 1 - r) as i64 - j));
        }
    }
    let mut ans = 0;
    for l in 0..n {
        let r = n - l;
        ans = max(dp[l][r], ans);
    }
    println!("{}", ans);
}


Measured memory_bytes: 33468
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
     
using namespace std;
     
typedef long long ll;
typedef pair<ll, ll> P;

     
int main(){
  ll A, B;

  cin >> A >> B;

  cout << A * B - A - B + 1 << endl;

  return 0;
}


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

using namespace std;

int *num_array;
int array_len;
int num_max;
int score_len;

vector<int> as;
vector<int> bs;
vector<int> cs;
vector<int> ds;

bool array_next(int index);

int main(void)
{
    cin >> array_len >> num_max >> score_len;

    for(int i = 0; i < score_len; i++){
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        as.push_back(a - 1);
        bs.push_back(b - 1);
        cs.push_back(c);
        ds.push_back(d);
    }

    num_array = new int[array_len];

    for(int i = 0; i < array_len; i++){
        num_array[i] = 1;
    }
    num_array[array_len - 1] = 0;

    int max_score = 0;
    while(array_next(array_len - 1)){
        bool ascend = true;
        for(int i = 0; i < array_len - 1; i++){
            if(num_array[i] > num_array[i + 1]){
                ascend = false;
                break;
            }
        }

        if(ascend){
            int current_sum = 0;
            for(int i = 0; i < score_len; i++){
                if(num_array[bs[i]] - num_array[as[i]] == cs[i]){
                    current_sum += ds[i];
                }
            }

            if(current_sum > max_score){
                max_score = current_sum;
            }
        }
    }

    cout << max_score << endl;

    return 0;
}

bool array_next(int index)
{
    if(num_array[index] == num_max){
        if(index == 0){
            return false;
        }
        bool cont = array_next(index - 1);
        if(cont){
            for(int i = index; i < array_len; i++){
                num_array[i] = num_array[i - 1];
            }
        }
        return cont;
    }

    num_array[index] += 1;
    return true;
}

Measured memory_bytes: 3592
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long n,m,i,j,k,dp[505][505],w1[505][505],w2[505][505],a[505][505],ans;
int main()
{
	scanf("%lld",&n);
	fz1(i,n){
		fz1(j,n)if(i!=j){
			scanf("%lld",&a[i][j]);
		}
	}
	fz1(i,n){
		fd(j,n,i+1){
			w1[i][j]=w1[i][j+1];
			fz1(k,i){
				w1[i][j]+=a[j][k];
			}
		}
	}
	fz1(i,n){
		fz(j,i,n+1){
			w2[i][j]=w2[i][j-1];
			fz(k,i,j-1){
				w2[i][j]+=a[k][j];
			}
		}
	}
	memset(dp,0x3f,sizeof(dp));
	dp[0][0]=0;
	fz0g(i,n){
		fz(j,i,n)if(dp[i][j]<0x3f3f3f3f3f3f3f3fll){
			fz(k,j+1,n+1){
				long long f=dp[i][j];
				f+=w2[j+1][k];
				f+=w1[j][k+1]-w1[i][k+1];
				dp[j][k]=min(dp[j][k],f);
			}
		}
	}
	ans=0x3f3f3f3f3f3f3f3fll;
	fz0g(i,n){
		ans=min(ans,dp[i][n+1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int D;
    cin>>D;

    if(D==25){
        cout<<"Christmas"<<endl;
    } else if(D==24) {
        cout<<"Christmas Eve"<<endl;
    } else if(D==23) {
        cout<<"Christmas Eve Eve"<<endl;
    } else if(D==22) {
        cout<<"Christmas Eve Eve Eve"<<endl;
    }


    
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;

bool judge(vll & vec, ll length, ll K) {
	ll cnt = 0;
	for (auto v : vec) {
		cnt += (v + length - 1) / length - 1;
	}
	
	return cnt <= K;
}

bool judge_2(vll& vec, ll length, ll K) {
	ll cnt = 0;
	for (auto v : vec) {
		if (v % length) {
			return false;
		}

		cnt += v / length - 1;
	}

	return cnt <= K;
}
ll quasi_max(ll lhs, ll rhs) {
	if (lhs > rhs) {
		return lhs;
	}
	else {
		return rhs;
	}
}
int main() {
	ll n, k; cin >> n >> k;
	vll vec(n); rep(i, n) cin >> vec[i];

	ll min = 1;
	ll max = 1e10;
	ll mid;
	while (max - min > 1) {
		mid = (max + min) / 2;

		if (judge(vec,mid,k)) {
			max = mid;
		}
		else {
			min = mid;
		}
	}
	ll Mid = quasi_max(max - 1, 1);

	if (judge_2(vec, Mid, k)) {
		max = Mid;
	}
	cout << max << endl;
}

Measured memory_bytes: 4812
#include <bits/stdc++.h>
#include <vector>
#include <stack>

using namespace std;


int main(){

 int k;
 string s;
 cin>>k;
 cin>>s;

 if(s.length() > k){
    for(int i=0;i<k;i++)
     cout<<s[i];

     cout<<"..."<<endl;
 }
 else cout<<s<<endl;


return 0;
 }



Measured memory_bytes: 3564
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <math.h>
#include <map>

typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl


int main(){
    string s;cin >> s;
    map<char,int> mp;
    for(char c:s){
        mp[c]++;
    }
    
    for(int i=0;i<26;i++){
        if(mp[i+'a']==0){
            cout << char(i+'a')<< endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


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

using namespace std;

int main() {
    int n, k, x, y;
    cin >> n >> k >> x >> y;

    int ans;
    if (n <= k) {
        ans = x * n;
    } else {
        ans = k * x + (n - k) * y;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import Counter
import sys
N, K = map(int, input().split())
A = list(map(int, input().split()))

c = Counter(A)
kv = c.most_common()

count = 0
ans = 0
if len(kv) <= K:
    print(0)
    sys.exit(0)

for l in kv[::-1]:
    count += 1
    ans += l[1]
    if count == (len(kv) - K):
        break

print(ans)


Measured memory_bytes: 103368
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define F first
#define S second
#define INF 1 << 30

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int n;
int a[128];

int dfs(int p, int g, int c){
  if(n == c) return abs(p-g);
  return min(dfs(p+a[c], g, c+1), dfs(p, g+a[c], c+1));
}

int main(){
  while(scanf("%d", &n) && n){
    rep(i, n) scanf("%d", a+i);
    printf("%d\n", dfs(0, 0, 0));
  }
  return 0;
}

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

#define ll long long
#define N 500 
int n, k;
int arr[N][N];

bool ok()
{
	for (int i = 2; ; ++i)
	{
		ll tmp = (ll)i * (i - 1) / 2;
		if (tmp > n) return false;
		if (tmp == n) 
		{
			k = i;
			return true;
		}
	}
	return false;
}

int main()
{
	while (scanf("%d", &n) != EOF)
	{
		if (n == 1)
		{
			puts("Yes");
			puts("2");
			puts("1 1");
			puts("1 1");
			continue;
		}
		if (!ok()) puts("No"); 
		else
		{
			puts("Yes");
			for (int i = 1, cnt = 0; i < k; ++i)
			{
				for (int j = 1; j <= i; ++j)
					arr[i][j] = ++cnt; 
			}
			printf("%d\n", k);
			for (int i = 1; i < k; ++i)
			{
				printf("%d ", k - 1);
				vector <int> v;
				for (int j = 1; j <= i; ++j) v.push_back(arr[i][j]);
				for (int j = i + 1; j < k; ++j) v.push_back(arr[j][i]);
				for (int i = 0; i < k - 1; ++i) printf("%d%c", v[i], " \n"[i == k - 2]);
			}
			printf("%d ", k - 1);
			for (int i = 1; i < k; ++i) printf("%d%c", arr[i][i], " \n"[i == k - 1]);
		}
	}
}


Measured memory_bytes: 2304
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll n,arr[405],dp[405][405],pre[205];

ll dfs(ll l,ll h)
{
	if(dp[l][h]!=-1)
		return dp[l][h];
	if(l+1==h)
	{
		dp[l][h]=arr[l]+arr[h];
		return arr[l]+arr[h];
	}
	ll mini=ass;
	for(ll i=l;i<h;i++)
		mini=min(mini,pre[i]-pre[l-1]+pre[h]-pre[i]+dfs(l,i)+dfs(i+1,h));
	dp[l][h]=mini;
	return dp[l][h];
}

int main()
{
	boost
	ll i;
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(i=1;i<=n;i++)
	{
		cin>>arr[i];
		pre[i]=pre[i-1]+arr[i];
	}
	for(i=1;i<=n;i++)
		dp[i][i]=0;
	dp[1][n]=ass;
	for(i=1;i<=n;i++)
		dp[1][n]=min(dp[1][n],pre[n]+dfs(1,i)+dfs(i+1,n));
	cout<<dp[1][n];
	return 0;
}

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

using namespace std;

#define rep(a, b) for(int i = 0; i < n; i++)
typedef long long ll;
template<typename T> bool chmax(T &a, T b) {if(a <= b){a = b; return true;}return false;}
template<typename T> bool chmin(T &a, T b) {if(a >= b){a = b; return true;}return false;}

int main(void){
    int H, W, h, w;
    cin >> H >> W >> h >> w;
    cout << H * W - h * W - w * H + h * w << endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

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

  vector<int> A;
  A.eb(0);
  rep(i, n) {
    int a;
    cin >> a;
    A.eb(a);
  }
  A.eb(0);

  n += 2;

  vector<int> sum(n);
  rep(i, n - 1) { sum[i + 1] = sum[i] + abs(A[i] - A[i + 1]); }

  REP(i, 1, n - 1) {
    int ans = sum[n - 1] - sum[i + 1] + sum[i - 1] + abs(A[i - 1] - A[i + 1]);
    cout << ans << endl;
  }
}


Measured memory_bytes: 2168
#include <iostream>

using namespace std;

int n, a[10000];
int mi, ma;
long long su = 0;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	mi = a[0];
	ma = a[0];

	for (int i = 0; i < n; i++) {
		if (mi > a[i])mi = a[i];
		if (ma < a[i])ma = a[i];
		su += a[i];
	}
	cout << mi << " " << ma << " " << su << "\n";
	return 0;
}

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

using namespace std;

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (b <= a) {
		cout << "delicious" << endl;
	}
	else if (x + a < b) {
		cout << "dangerous" << endl;
	}
	else {
		cout << "safe" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int i,j,k,count=0,W,H;
    while(1==1){
        scanf("%d%d",&H, &W);
        if (W==0&&H==0){
            return 0;
        }
        for (j=0;j<H; j++){
            for (k=0;k<W;k++){
                if (j==0||j==H-1){
                    printf("#");
                }
                else{
                    (k==0||k==W-1)?printf("#"):printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2496
//JI SRI KRISHNA.//
#include<iostream>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,c=1,d,mini;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        if(i>0)
        {
            if(a[i]<=mini)
            {
                c++;
                mini=a[i];
            }
        }
        else
        {
            mini=a[i];
        }

    }
    cout<<c<<endl;

}


Measured memory_bytes: 5136
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

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();}

typedef long long LL;
typedef unsigned long long ULL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int dp[100001]; // 1-iに出現するAC数

void solve()
{
  int N, Q; cin >> N >> Q;
  char s_prev = '\0';
  REP1(i, N)
  {
      char s; cin >> s;
      dp[i] = dp[i-1];
      if (s_prev=='A' and s=='C') dp[i]++;
      s_prev = s;
  }
  
  REP0(i, Q) {
      int l, r; cin >> l >> r;
      cout << dp[r] - dp[l] << endl;
  }
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
long long cnt[100005];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
	cin>>n;
	long long ans=0;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		cnt[x]++;
		ans+=x;
	}
	int q;
	cin>>q;
	while(q--){
		int b, c;
		cin>>b>>c;
		cnt[c]+=cnt[b];
		ans+=cnt[b]*c;
		ans-=cnt[b]*b;
		cnt[b]=0;
		cout<<ans<<"\n";
	}
}

Measured memory_bytes: 4432
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL
using ll = long long;
template<typename T>
using vec = vector<T>;
using P = pair<ll, ll>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//ll pas[51][52];
ll all[51];
ll p[51];

signed main(){
	IOS;
	ll n, x;
	cin >> n >> x;
	p[0] = 1;
	all[0] = 1;
	for(ll i = 1;i <= n;i++){
		p[i] = 2 * p[i - 1]  + 1;
		all[i] = 2 * all[i - 1] + 3;
	}
	ll ans = 0;
	for(int i = n - 1;i >= 0;i--){
		if(x == 1){
			break;
		}
		if(x == all[i] + 2){
			ans += (1 + p[i]);
			break;
		}
		else if(x == 2 * all[i] + 3){
			ans += 2 * p[i] + 1;
			break;
		}
		else if(x > all[i] + 2){
			ans += p[i] + 1;
			x -= all[i] + 2;
		}
		else {
			x--;
		}
		if(i == 0){
			ans++;
			break;
		}
	}
	dump(ans);
}	

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

int main(){
  string S;
  cin>>S;
  int K;
  cin>>K;
  int N=S.length();
  int C[N];
  for(int i=0;i<N;i++){
    C[i]=('z'-S.at(i)+1)%26;
    //cout<<i<<" "<<S.at(i)<<" "<<C[i]<<endl;
  }
  int temp=0;
  while(temp<N-1){
    if(C[temp]<=K){
      cout<<"a";
      K-=C[temp];
      temp++;
      continue;
    }
    cout<<S.at(temp);
    temp++;
  }
  K=K%26;
  if(S.at(N-1)+K >'z'){
    cout<<char(S.at(N-1)+K-26)<<endl;
  }
  else cout<<char(S.at(N-1)+K)<<endl;

  return 0;
}


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

int n, m, a[100009], b[100009], p[100009], col[100009], cnts; vector<int>x[100009], S[100009];

void dfs(int pos) {
	if (col[pos] >= 1) return;
	col[pos] = cnts; S[cnts].push_back(pos);
	for (int i = 0; i < x[pos].size(); i++) dfs(x[pos][i]);
}

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; i++) cin >> p[i];
	for (int i = 1; i <= m; i++) {
		cin >> a[i] >> b[i];
		x[a[i]].push_back(b[i]);
		x[b[i]].push_back(a[i]);
	}
	for (int i = 1; i <= n; i++) {
		if (col[i] == 0) { cnts++; dfs(i); }
	}
	int cnt = 0;
	for (int i = 1; i <= n; i++) {
		if (col[i] == col[p[i]]) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 12284
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    res = N*(N-1)/2;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
N,K = map(int,input().split())
ab = [0]*N
for i in range(N):
    ab[i] = tuple(map(int,input().split()))
ab.sort(key= lambda x:x[0])
m = 10**5
for a,b in ab:
    K -= b
    m = a
    if K <= 0:
        print(m)
        break

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

#define M 1046527
#define L 14

char H[M][L]; 

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
}

long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key) 
{ 
  return key % M; 
}
int h2(int key)
{ 
  return 1 + (key % (M-1)); 
}

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i=0;;i++)
  {
    h = (h1(key) + i*h2(key) )%M;
    if (strcmp(H[h],str) ==0)
    {
      return 1;
    }
    else if (strlen(H[h]) == 0)
    {
      return 0;
    }
  }
  return 0;
}

int insert(char str[]){
  long long key, i , h;
  key = getKey(str);
   for(i=0;;i++)
  {
    h = (h1(key) + i*h2(key) )%M;
    if (strcmp(H[h],str) ==0)
    {
      return 1;
    }
    else if (strlen(H[h]) == 0)
    {
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
    int i, n, h;
    char str[L], com[9];
    for ( i = 0; i < M; i++ ) H[i][0] = '\0';
    
    scanf("%d", &n);
    
  for ( i = 0; i < n; i++ ){
	  scanf("%s %s", com, str);
	
	  if ( com[0] == 'i' ){
	      insert(str);
	    } 
    else {
	      if (find(str)){
	        printf("yes\n");
	      } 
        else {
		      printf("no\n");
	      }
	    }
    }

    return 0;
}


Measured memory_bytes: 16048
#include<iostream>
using namespace std;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ll x;   cin >> x;
        ans += x-i-1;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3120
N = int(input())
ABC = [list(map(int,input().split())) for _ in range(N)]

#dp[day][その日Aを選択した場合,Bを選択,Cを選択]=累積幸福度の最大値
dp = [[0] * 3 for _ in range(N+2)]

for i in range(1,N+1):
    dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + ABC[i-1][0]
    dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + ABC[i-1][1]
    dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + ABC[i-1][2]

print(max(dp[N]))

Measured memory_bytes: 74712
#include<iostream>
#include<vector>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<char> c(n);
	for (int i = 0; i < n; i++) cin >> c[i];

	int strt = 0;
	int counter = 0;
	vector<char>::iterator itr;
	int rnum = count(c.begin(), c.end(), 'R');
	itr = find(c.begin(), c.end(), 'R');
	while (true) {
		if (itr == c.end())
			break;
		if (distance(c.begin(),itr)>=rnum) {
			iter_swap(c.begin() + strt, itr);
			counter++;
			strt++;
		}
		itr = find(itr+1, c.end(), 'R');
	}
	cout << counter;
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
#include <numeric>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<Pll> vp;
typedef vector<bool> vb;
#define rep(i, a, n) for (ll i = (a); i < (n); ++i)
#define rrep(i, a, n) for (ll i = (a); i > (n); --i)
#define erep(i, a, n) for (ll i = (a); i <= (n); ++i)
#define rerep(i, a, n) for (ll i = (a); i >= (n); --i)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int)x.size())
#define vec_max(V) *max_element(all(V))
#define vec_min(V) *min_element(all(V))
#define vec_sum(V) accumulate(all(V), 0LL)
#define print(X) cout << (X) << "\n"
#define _ << " " <<
#define Yes print("Yes")
#define No print("No")
static const int INF = 1e+9+7;

int main(){
  int a,b;
  cin >> a >> b;
  if(a != b )print(2 * max(a,b) - 1);
  else print(2 * a);

 return 0;
}


Measured memory_bytes: 256
import sys
readline = sys.stdin.readline

MOD = 10**9+7
def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%MOD
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], MOD -2, MOD)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % MOD
    return frac, fraci
frac, fraci = frac(1398)
def comb(a, b):
    if not a >= b >= 0:
        return 0
    return frac[a]*fraci[b]*fraci[a-b]%MOD


N, K = map(int, readline().split())
A = list(map(int, readline().split()))

dp = [0]*(N+1)
dp[0] = 1

for i in range(K):
    a = A[i]
    dp2 = [0]*(N+1)
    for j in range(N+1):
        d = dp[j]
        if not d:
            continue
        for k in range(min(a, N-j)+1):
            dp2[j+k] = (dp2[j+k] + d*comb(N-j, k)*comb(N-k, a-k)) %MOD
    dp = dp2[:]
print(dp[N])


Measured memory_bytes: 63964
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef unsigned long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
    cin>>N;
    cout<<3*N*N<<endl;
}


Measured memory_bytes: 256