akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define pli pair<ll, int>
#define pil pair<int, ll>
#define pll pair<ll, ll>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define endl '\n'
const int inf = 1000000007;
const ll INF = 1e18;
int mod = 998244353;
// int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template<typename T, typename U> T pow_(T a, U b) { return b ? pow_(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b % mod; if (a >= mod) a -= mod; }
template<class T> void operator += (vector<T>& v, vector<T> v2) { rep(i, sz(v2)) v.eb(v2[i]); }

void solve();

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12); // debuged
    int T;
    T = 1;
    while (T--) solve();
}

void solve() {
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z') cout << "A" << endl;
    else cout << "a" << endl;
}


Measured memory_bytes: 3616
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int a, b;
  cin >> a >> b;
  if (a + b >= 10) {
    print("error");
  } else {
    print(a + b);
  }
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll n, a, b;
bool check(int k){
    int sum=0;
    while(k){
        sum+=k%10;
        k/=10;
    }
    if(sum>=a&&sum<=b)return true;
    else return false;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    int ans=0;
    rep(i,n+1){
        if(check(i))ans+=i;
    }
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define maxn 105
#include <bits/stdc++.h>
using namespace std;

ll n, cap, v[maxn], w[maxn], dp[maxn][100005];

ll rec(ll pos, ll taken){
    if(dp[pos][taken] != -1) return dp[pos][taken];
    if(pos == n+1) return 0;
    ll res1 = rec(pos+1, taken);
    if(taken+w[pos] <= cap) res1 = max(res1, v[pos] + rec(pos+1, taken+w[pos]));
    return dp[pos][taken] = res1;
}

int main() {
    cin >> n >> cap;
    for(int i=1;i<=n;i++){
        cin >> w[i] >> v[i];
    }
    memset(dp, -1, sizeof dp);
    cout << rec(1, 0) << endl;



    return 0;
}


Measured memory_bytes: 82304
N = int(input())
C = {"AC":0,"WA":0,"TLE":0,"RE":0}
for _ in range(N):
    C[input().strip()] += 1
print("AC","x",C["AC"])
print("WA","x",C["WA"])
print("TLE","x",C["TLE"])
print("RE","x",C["RE"])

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  string s,t; cin >> s >> t;

  if(s==t){
    cout << "Yes" << endl;
    return 0;
  }

  bool flag = false;
  rep(i,s.size()){
    string test = "";
    for(int j=s.size()-i;j<s.size();j++){
      test+=s[j];
    }
    for(int j=0;j<s.size();j++){
      if(test.size()==s.size()) break;
      test+=s[j];
    }
    if(test==t) flag = true;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, a, b, d, x[100009], y[100009], c[100009]; bool vis[100009]; map<int, set<int> > cx, cy; map<int, vector<int> > vx, vy; map<pair<int, int>, int> inv;
int countval(int px, int py) {
	int la = lower_bound(vx[px - d].begin(), vx[px - d].end(), py - d) - vx[px - d].begin();
	int ra = lower_bound(vx[px - d].begin(), vx[px - d].end(), py + d) - vx[px - d].begin();
	int lb = lower_bound(vy[py + d].begin(), vy[py + d].end(), px - d) - vy[py + d].begin();
	int rb = lower_bound(vy[py + d].begin(), vy[py + d].end(), px + d) - vy[py + d].begin();
	int lc = lower_bound(vx[px + d].begin(), vx[px + d].end(), py - d + 1) - vx[px + d].begin();
	int rc = lower_bound(vx[px + d].begin(), vx[px + d].end(), py + d + 1) - vx[px + d].begin();
	int ld = lower_bound(vy[py - d].begin(), vy[py - d].end(), px - d + 1) - vy[py - d].begin();
	int rd = lower_bound(vy[py - d].begin(), vy[py - d].end(), px + d + 1) - vy[py - d].begin();
	return (ra - la) + (rb - lb) + (rc - lc) + (rd - ld);
}
vector<int> around(int px, int py) {
	set<int>::iterator la = cx[px - d].lower_bound(py - d);
	set<int>::iterator ra = cx[px - d].lower_bound(py + d);
	set<int>::iterator lb = cy[py + d].lower_bound(px - d);
	set<int>::iterator rb = cy[py + d].lower_bound(px + d);
	set<int>::iterator lc = cx[px + d].lower_bound(py - d + 1);
	set<int>::iterator rc = cx[px + d].lower_bound(py + d + 1);
	set<int>::iterator ld = cy[py - d].lower_bound(px - d + 1);
	set<int>::iterator rd = cy[py - d].lower_bound(px + d + 1);
	vector<int> ret;
	while (la != ra) ret.push_back(inv[make_pair(px - d, *la)]), la++;
	while (lb != rb) ret.push_back(inv[make_pair(*lb, py + d)]), lb++;
	while (lc != rc) ret.push_back(inv[make_pair(px + d, *lc)]), lc++;
	while (ld != rd) ret.push_back(inv[make_pair(*ld, py - d)]), ld++;
	return ret;
}
void dfs(int pos) {
	vis[pos] = true;
	vector<int> res = around(x[pos], y[pos]);
	for (int i : res) {
		cx[x[i]].erase(y[i]);
		cy[y[i]].erase(x[i]);
	}
	for (int i : res) {
		dfs(i);
	}
}
int main() {
	cin >> n >> a >> b; a--, b--;
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		int tx = x[i] + y[i], ty = x[i] - y[i];
		x[i] = tx; y[i] = ty;
		cx[x[i]].insert(y[i]);
		cy[y[i]].insert(x[i]);
		inv[make_pair(x[i], y[i])] = i;
	}
	for (pair<int, set<int> > i : cx) vx[i.first] = vector<int>(i.second.begin(), i.second.end());
	for (pair<int, set<int> > i : cy) vy[i.first] = vector<int>(i.second.begin(), i.second.end());
	d = max(abs(x[a] - x[b]), abs(y[a] - y[b]));
	for (int i = 0; i < n; i++) c[i] = countval(x[i], y[i]);
	dfs(a);
	long long ret = 0;
	for (int i = 0; i < n; i++) {
		if (vis[i]) ret += c[i];
	}
	cout << ret / 2 << endl;
	return 0;
}

Measured memory_bytes: 91392
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

//繰り返し二乗法
template <typename T>
T doubling(T a, T p) {
	if (p == 0)return 1;//出口
	if (p % 2 == 0) {//pを半分にしていく
		T half = doubling<T>(a, p / 2);
		return half % mod * half % mod;
	}
	else {//pが奇数ならpを偶数にする
		return a * doubling<T>(a, p - 1) % mod;
	}
}



//combination その2(逆元) O(nlonP):PはmodP
template<typename T>
T combination(T n, T r) {
	if (r > n - r)return combination<T>(n, n - r);
	T mul = 1;
	T div = 1;
	for (unsigned long long int i = 0; i < r; i++) {
		mul *= n - i;
		div *= i + 1;
		mul %= mod;
		div %= mod;
	}
	//逆元
	T ans = mul * doubling<T>(div, mod - 2) % mod;//a^(-1)=a~(p-2) (mod p)
	return ans;
}

int main() {
	ll n, k;
	cin >> n >> k;
	repp(i, 0, k) {
		if (i <= n - k)cout << combination<ll>(n - k + 1, (ll)i + 1) % mod * combination<ll>(k - 1, (ll)i) % mod << endl;
		else cout << 0 << endl;//これを満たす並べ方が存在しない
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;

int n;
int a[100005];
long long flag[10];
int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	sort(a + 1, a + 1 + n);
	int ans = 0;
	for(int i = n; i >= 2; i--)
	{
		if(a[i] == a[i - 1]) {
			flag[++ans] = a[i];
			i--;
		}
		if(ans > 2) break;
	}
	long long pp = flag[1] * flag[2];
	printf("%lld\n", pp);
	return 0;
}

Measured memory_bytes: 512
import queue

k = int(input())
a = queue.Queue()
for i in range(9):
    a.put(i + 1)
for i in range(k):
    test = a.get()
    temp = test % 10
    if temp == 0:
        a.put(test * 10)
        a.put(test * 10 + 1)
    elif temp == 9:
        a.put(test * 10 + 8)
        a.put(test * 10 + 9)
    else:
        a.put(test * 10 + temp - 1)
        a.put(test * 10 + temp)
        a.put(test * 10 + temp + 1)
print(test)

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

    long long ansa, ansb;
    bool endf = false;

    for (int i = -1000; i <= 1000; i++)
    {
        for (int j = -1000; j <= 1000; j++)
        {
            if(powl(i, 5) - powl(j, 5) == x)
            {
                ansa = i;ansb = j;endf = true;break;
            }
        }
        if(endf)break;
    }

    cout << ansa << " " << ansb << endl;
}


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

signed main(){
    // cout << fixed << setprecision(10) << flush;

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i=0; i<n; i++){
        cin >> p[i];
        p[i]--;
    }
    vector<int> c(n);
    for(int i=0; i<n; i++){
        cin >> c[i];
    }
    
    vector<vector<int>> point(n, vector<int>());
    for(int i=0; i<n; i++){
        if(p[i] == i){
            point[i].push_back(c[i]);
            continue;
        }
        point[i].push_back(c[p[i]]);
        int now_p = c[p[i]];
        int now = p[p[i]];
        while(i != now){
            now_p += c[now];
            point[i].push_back(now_p);
            now = p[now];
        }
        point[i].push_back(now_p + c[now]);
    }

    int max_p = point[0][0];
    for(int i=0; i<n; i++){
        int loop_size = point[i].size();
        int pp = point[i][loop_size-1];
        int p = (k-1)/loop_size * pp;
        if(pp < 0) p = 0;
        int max_plus = point[i][0];
        for(int j=0; j<k - (k-1)/loop_size*loop_size; j++){
            max_plus = max(max_plus, point[i][j]);
        }
        p += max_plus;
        // if(k - k/loop_size*loop_size != 0){
        //     p += point[i][k - k/loop_size*loop_size - 1];
        // }
        max_p = max(max_p, p);
    }

    for(int i=0; i<n; i++){
        int lim = ((k > point[i].size())? point[i].size(): k);
        for(int j=0; j<lim; j++){
            max_p = max(max_p, point[i][j]);
        }
    }
    cout << max_p << endl;

    return 0;
}

Measured memory_bytes: 218608
def main():
    n, d = map(int, input().split())
    # 2d + 1が1人の範囲
    # nを (2*d + 1)で割り切れたらそのまま、割り切れなかったら整数部分 + 1
    ans = n / (2*d + 1)
    if ans.is_integer():
        print(int(ans))
    else:
        print(int(ans) + 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
#
# abc047 a
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """10 30 20"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """30 30 100"""
        output = """No"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """56 25 31"""
        output = """Yes"""
        self.assertIO(input, output)


def resolve():
    C = list(map(int, input().split()))
    C.sort()

    if C[2] == C[0] + C[1]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAX=300005;
int n,k,seq[MAX];
void dec(int x){
    if(seq[x]==0){
        dec(x-1);
    }
    else{
        seq[x]--;
        if(seq[x]!=0) for(int i=x+1;i<=n;i++) seq[i]=k;
    }
}
int main(){
    scanf("%d%d",&k,&n);
    if(k==1){
        for(int i=1;i<=n-n/2;i++) seq[i]=k;
    }
    else if(k%2==0){
        seq[1]=k/2;
        for(int i=2;i<=n;i++) seq[i]=k;
    }
    else{
        for(int i=1;i<=n;i++) seq[i]=(k+1)/2;
        for(int i=1;i<=n/2;i++) dec(n);
    }
    for(int i=1;i<=n&&seq[i]!=0;i++) printf("%d ",seq[i]);
    printf("\n");
}


Measured memory_bytes: 3456
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}
class out {
    public static function println($str = "") {
        echo $str . PHP_EOL;
    }
}

$AC=$WA=$TLE=$RE=0;
$sc = new Scanner();
$a = $sc->nextInt();
for($i=0;$i<$a;$i++){
  $b = $sc->next();
  $$b++;
}
out::println("AC x {$AC}");
out::println("WA x {$WA}");
out::println("TLE x {$TLE}");
out::println("RE x {$RE}");

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

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

  ll m = n%k;
  cout << min(m, k-m) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K,S;
  cin >> K >> S;
  int z;
  int cnt=0;
  for(int x=0; x<=K; x++){
    for(int y=0; y<=K; y++){
      z = S-x-y;
      if(0<=z && z<=K){
        cnt++;
      }else{
        continue;
      }
    }
  }
  cout << cnt << endl;
}

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

#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

const int N = 1e5 + 12;
int n, m;
int hp[N], h[N], ans;

int main() {
	cin >> n >> m;
	for (int i = 0; i < n; i++) cin >> h[i];
	for (int i = 0; i < m; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		hp[u] = max(hp[u], h[v]);
		hp[v] = max(hp[v], h[u]);
	}
	for (int i = 0; i < n; i++) {
		if (h[i] > hp[i]) ans++;
	}
	cout << ans;
	return 0;
}


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

int main() {
    int N; cin >> N;
    int ans = 0;
    for(int i = 1; i <= N; ++i) {
        for(int j = 1; j <= N; ++j) {
            int g = gcd(i, j);
            for(int k = 1; k <= N; ++k) {
                ans += gcd(g, k);
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3636
//### In The Name Of GOD ###

// %% Remember; (((He))) is The (((Accepter))) %%

#include <bits/stdc++.h>

using namespace std;

typedef long long ll ;

#define int ll
#define pb push_back
#define bp pop_back
#define pf push_front
#define fp pop_front
#define X first
#define Y second
#define IO ios_base::sync_with_stdio(false);
#define sz(a) (int)(a.size())
#define sg(a, b) (a + b - 1) / b

const int MOD = 1000 * 1000 * 1000 + 7;
const int INF = 2 * 1000 * 1000 + 200;
const int MAXN = 100 * 1000 + 1;
const int MLOG = 18;
const int NMAX = 1 * 1000;

signed main(){
  IO;
  int n, t;
  cin >> n >> t;
  int  cnt = 0;
  int a[n] = {}, mx[n + 1] = {}, ans = 0;
  vector<int> vec;
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  for(int i = n - 1; i >= 0; i--)
    mx[i] = max(mx[i + 1], a[i]);
  for(int i = 0; i < n - 1; i++){
    // cout << mx[i + 1] << ' ' << a[i] << ' ';
    if(mx[i + 1] - a[i] > ans) ans = mx[i + 1] - a[i], cnt = 1;
    else if(mx[i + 1] - a[i] == ans) cnt++;
  }
  cout << cnt;
}


Measured memory_bytes: 1792
from collections import defaultdict
from collections import deque
from sys import stdin

def sp(G,R,V):
    d = {}
    INF = float('inf')
    for i in range(V):
        d[i] = INF
    d[R] = 0
    q = deque([(R)])
    while q:
        u = q.popleft()
        for v in G[u].keys():
            if d[v] > d[u] + G[u][v]:
                d[v] = d[u] + G[u][v]
                q.append(v)
    return d


V, E, R = [int(x) for x in stdin.readline().split()]
G = defaultdict(dict)
for case in range(E):
    s, t, w = [int(x) for x in stdin.readline().split()]
    G[s][t] = w
d = sp(G, R, V)
for k in range(V):
        if d[k] == float('inf'):
            print("INF")
        else:
            print(d[k])

Measured memory_bytes: 99024
def lotate(dic, dire):
    if dire == 'N':
        x,y,z,w = dic['up'], dic['back'], dic['bottom'], dic['front']
        dic['back'], dic['bottom'], dic['front'], dic['up'] = x,y,z,w
    elif dire == 'S':
        x, y, z, w = dic['up'], dic['back'], dic['bottom'], dic['front']
        dic['front'], dic['up'], dic['back'], dic['bottom'] = x, y, z, w
    elif dire == 'W':
        x, y, z, w = dic['up'], dic['left'], dic['bottom'], dic['right']
        dic['left'], dic['bottom'], dic['right'], dic['up'] = x, y, z, w
    elif dire == 'E':
        x, y, z, w = dic['up'], dic['left'], dic['bottom'], dic['right']
        dic['right'], dic['up'], dic['left'], dic['bottom'] = x, y, z, w
    return dic


n = int(input())
dice = []
for i in range(n):
    a1,b1,c1,d1,e1,f1 = map(int, input().split())
    dice.append({'up': a1, 'front': b1, 'right': c1, 'left': d1, 'back': e1, 'bottom': f1})
ans = 'Yes'
for i in range(1, n):
    for j in range(1, i+1):
        if dice[i-j] == dice[i]:
            ans = 'No'
        else:
            s = 'EEENEEENEEESEEESEEENEEEN'
            for k in s:
                dice[i-j] = lotate(dice[i-j], k)
                if dice[i-j] == dice[i]:
                    ans = 'No'
print(ans)


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

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

  int d[n + 1];
  rep(i, n) { cin >> d[i]; }

  int sum = 0;

  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      sum += d[i] * d[j];
    }
  }

  cout << sum << endl;
  return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;

    Vl cnts(N + 1);
    for (ll i = 1; i <= 100; i++) {
        for (ll j = 1; j <= 100; j++) {
            for (ll k = 1; k <= 100; k++) {
                ll t = i * i + j * j + k * k + i * j + j * k + k * i;
                if (t > N) continue;
                ++cnts[t];
            }
        }
    }

    for (ll i = 1; i <= N; i++) {
        cout << cnts[i] << "\n";
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
using namespace std;



int main(){
    double ans =0;
    map<int, int> check;
    string S;
    cin >> S;
    int temp=20001;
    vector<int> hight(S.length()+1);
    int hmin = 0;
    for (int i=0; i<=S.length(); i++) {
        hight[i]=temp;
        check[temp]++;
        hmin = min(hmin, temp);
        if (S[i]=='\\') {
            temp--;
            continue;
        }
        if (S[i]=='/') {
            temp++;
            continue;
        }
        if (S[i]=='_') {
            continue;
        }
    }
    hight[S.length()]=temp;
    /*for (int i=0; i<=S.length(); i++) {
        cout << hight[i] << " " << check[hight[i]]<<endl;
    }*/
    int st = hight[0];
    vector<double> Q;
    int i=0;
    while(i<=S.length()) {
        while (S[i]=='/' || S[i]=='_') {
            if(S[i]=='/'){
                check[hight[i]]--;
                st++;
                i++;
            }else if(S[i]=='_'){
                i++;
                check[hight[i]]--;
            }
        }
        if (i>S.length()) {
            break;
        }
        while (check[st]<=1) {
            i++;
            st--;
            while (S[i]=='_') {
                check[hight[i]]--;
                i++;
            }
            if (i>S.length()) {
                break;
            }
        }
        if (i>S.length()) {
            break;
        }
        int ff=0;
        double count=0;
        check[hight[i]]--;
        for (int j=i+1; j<=S.length(); j++) {
            if (hight[j] == st and ff) {
                if (count == 0) {
                    break;
                }
                count += 0.5;
                Q.push_back(count);
                ans += count;
                i = j-1;
                //cout << j<<"|"<<count<<endl;
                count =0;
                break;
            }else{
                double hoge = (2*st-hight[j-1]-hight[j])/2.0;
                count += hoge;
                check[hight[j]]--;
                ff=1;
                //cout << "|"<<count<<"("<<hoge<<")" << "|"<<endl;
            }
        }
        i++;
    }
    printf("%d",(int)ans);
    cout << endl;
    if (Q.size()!=0){
        cout << Q.size()<<" ";
    }else{
        cout << 0;
    }
    for (int i=0; i< Q.size(); i++) {
        if (i==Q.size()-1) {
            printf("%d",(int)Q[i]);
        }else{
            printf("%d ",(int)Q[i]);
        }
    }
    cout << endl;
}

Measured memory_bytes: 2244
a,b,k = map(int,input().split())

for i in range(k):
    if i%2==0:
        if a%2!=0:
            a-=1
        a,b = a//2,a//2+b
    if i%2!=0:
        if b%2!=0:
            b-=1
        a,b = a+b//2,b//2

print(a,b)

Measured memory_bytes: 9104
#include <cstdio>
#include <cmath>
#include <climits>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <cassert>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <fstream>
#include <functional>
#include <utility>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <iomanip>


#define memtst(x) (sizeof(x) / 1024. / 1024.)
#define mem0(x) memset((x), 0, (sizeof x))
#define meminf(x) memset((x), INF, (sizeof x))
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define pq std::priority_queue
#define iter iterator
#define mp(x, y) std::make_pair((x), (y))
#define fst first
#define sec second
#define lc(x) ((x) * 2)
#define rc(x) ((x) * 2 + 1) 
#define md(x, y) (((x) + (y)) / 2)
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef std::pair <int, int> pii;
const double PI = acos(-1);
const double EPS = 1e-6;
const ll MOD = 998244353;
const ll N = 1e5 + 10;
template <typename T>
inline T Abs(T x)
{
    return x < 0 ? x * -1 : x;
}
template <typename T>
inline T Max(T x, T y, T z)
{
    return std::max(std::max(x, y), z);
}
template <typename T>
inline T Min(T x, T y, T z)
{
    return std::min(std::min(x, y), z);
}
template <typename T>
inline void Ckmax(T &x, T y)
{
    x = std::max(x, y);
}
template <typename T>
inline void Ckmin(T &x, T y)
{
    x = std::min(x, y);
}
template <typename T>
inline T Sqr(T x)
{
    return x * x;
}
template <typename T>
inline T Pow(T x, T y)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= MOD;
        (x *= x) %= MOD;
        y /= 2;
    }
    return r % MOD;
}
template <typename T>
T Pow(T x, T y, T z)
{
    T r = 1;
    while (y > 0)
    {
        if (y % 2 > 0)
            (r *= x) %= z;
        (x *= x) %= z;
        y /= 2;
    }
    return r % z;
}
template <typename T>
inline T gcd(T x, T y)
{
    return y > 0 ? gcd(y, x % y) : x;
}
template <typename T>
inline T lcm(T x, T y)
{
    return x / gcd(x, y) * y;
}
inline void cinspu(void)
{
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
}
inline ll fac(ll x)
{
	ll r = 1;
	for (; x > 1; --x)
		(r *= x) %= MOD;
	return r;
}

int a[110], b[110];

int calc(int x)
{
	for (int i = 2; i * i <= x; ++i)
		if (!(x % i))
			return i;
	return 0;
}

int main()
{
	cinspu();
	int n;
	std::cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		int j = i;
		while (1)
		{
			int x = calc(j);
			if (!x)
				break;
			++a[x];
			j /= x;
		}
		++a[j];
	}
	int tot = 0;
	for (int i = 2; i <= n; ++i)
		if (a[i])
			b[++tot] = a[i];
	std::sort(b + 1, b + 1 + tot);
	int ans = 0;
	for (int i = tot; b[i] >= 4; --i)
	{
		for (int j = i - 1; b[j] >= 4; --j)
		{
			for (int k = tot; b[k] >= 2; --k)
				if (i != k && j != k)
				{
					++ans;
				}
		}
	}
	for (int i = tot; b[i] >= 14; --i)
		for (int j = tot; b[j] >= 4; --j)
			if (i != j)
				++ans;
	for (int i = tot; b[i] >= 24; --i)
		for (int j = tot; b[j] >= 2; --j)
			if (i != j)
				++ans;
	for (int i = tot; b[i] >= 74; --i)
		++ans;
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lli;
typedef long double ldb;
 
#define endl '\n'
#define loop(i, m, n) for (lli i = m; i < n; i++)
#define loope(i, m, n) for (lli i = m; i <= n; i++)
#define epool(i, m, n) for (lli i = m; i >= n; i--)
#define pool(i,m,n) for(lli i=m; i>n; i++)
#define maxe *max_element
#define mine *min_element
#define plli pair<lli, lli>
#define mod 1000000007
#define mod2 998244353
#define vt vector<lli>
#define fi first
#define se second
#define pb push_back
#define umap unordered_map
#define mmap multimap
#define mp make_pair
#define inp1(a) cin >> a
#define inp2(a, b) cin >> a >> b
#define inp3(a, b, c) cin >> a >> b >> c
#define inp4(a, b, c, d) cin >> a >> b >> c >> d
#define inp5(a, b, c, d, e) cin >> a >> b >> c >> d >> e
#define inp6(a, b, c, d, e, f) cin >> a >> b >> c >> d >> e >> f
#define pr0() cout << " "
#define pr1(a) cout << a << " "
#define pr2(a, b) cout << a << " " << b << " "
#define pr3(a, b, c) cout << a << " " << b << " " << c << " "
#define pr4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << " "
#define emp emplace //used to push a pair etc..
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x, 0;
#define all(v) v.begin(),v.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
//especially for deque both sides dynamic
#define pf push_front
//list doubly linked lists can insert at mid. splice fn can be used
#define fast_io                       \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
 
lli gcd(lli a, lli b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
 
lli lcm(lli a, lli b){
    return (a * b) / gcd(a, b);
}
 
lli modi(lli n,lli m=mod){ 
    if(n==0) return 0;
    n%=m;
    n+=m;
    n%=m;
    return n;
}
 
 
lli mpow(lli base, lli exp){
    base %= mod;
    lli result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((lli)result * base) % mod;
        base = ((lli)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

//lli dp[1005][2010][2][2];

lli f(lli* arr,lli l, lli r){
    bool sorted=1;
    loop(i,l+1,r){
        if(arr[i-1]>arr[i]){
            sorted=0;
            break;
        }
    }
    if(sorted) return r-l;
    lli mid=(l+r)/2;
    return max(f(arr,l,mid),f(arr,mid,r));
}

int32_t main(){
    fast_io
    lli i = 0,j = 0;
//   freopen("input.txt","r",stdin);
//   freopen("output.txt","w",stdout);

    lli n,k;
    cin >> n >> k;

    if(n<=k) cout << min(n,abs(n-k));

    else{
        if(n%k==0) cout << 0;
        else{
            n=n%k;
            cout << min(n,abs(k-n));
        }
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
 
int main() {
    ll a,v;
    cin>>a>>v;
    ll b,w;
    cin>>b>>w;
    ll t;
    cin>>t;
    ll d=abs(a-b);
    if (v<=w){
        cout<<"NO"<<endl;
        return 0;
    }
    if (d<=t*(v-w)){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n,k;
    cin>>n>>k;
    vector<ll> h(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> h[i];
    }
    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        if (h[i] >= k)
        {
            ans++;
        }
    }
    cout << ans << endl;
}


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

int main(){

	int answer;
	int a,b,c,d,n;

	cin >> n >> a >> b >> c >> d;
	
	int X = ((n - 1) / a + 1) * b;
	int Y = ((n - 1) / c + 1) * d;

	cout << min(X, Y) << endl;


	/*
	int datanum = 0;
	for(int dataset = 0; dataset < 1; dataset++){
		if(input == 0) break;


		answer[dataset] = sum;

		datanum++;
	}

	for(int dataset = 0; dataset < datanum; dataset++){
		cout << answer[dataset] << endl;
	}
	*/

	

	return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int n,q,xl,xr,res;
int a[500010],cnt[500010],ans[500010];
struct Node{
	int l,r,num;
}f[500010];
inline bool cmp(Node a,Node b){
	if(a.l/800==b.l/800)
		return a.r<b.r;
	return a.l<b.l;
}
inline void Add(int x){
	if(cnt[x]==0)
		res++;
	cnt[x]++;
}
inline void Delete(int x){
	if(cnt[x]==1)
		res--;
	cnt[x]--;
}
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=q;i++){
		scanf("%d%d",&f[i].l,&f[i].r);
		f[i].num=i;
	}
	sort(f+1,f+q+1,cmp);
	xl=1,xr=1,res=1;
	cnt[a[1]]=1;
	for(int i=1;i<=q;i++){
		while(xl<f[i].l){
			Delete(a[xl]);
			xl++;
		}
		while(xl>f[i].l){
			xl--;
			Add(a[xl]);
		}
		while(xr<f[i].r){
			xr++;
			Add(a[xr]);
		}
		while(xr>f[i].r){
			Delete(a[xr]);
			xr--;
		}
		ans[f[i].num]=res;
	}
	for(int i=1;i<=q;i++)
		printf("%d\n",ans[i]);
	return 0;
}

Measured memory_bytes: 15488
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(), v.end()
#define PI 3.141592653589793238462643383279
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
typedef long long int ll;
typedef unsigned long long ull;
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;}
typedef pair<ll,ll> P;
const long long MOD = 1e9+7;
const ll INF = 1LL << 60;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};

int main(){
    int l,r,d;
    cin >> l >> r >> d;

    int cnt = 0;
    for(int i = l; i <= r; i++){
        if(i % d == 0)cnt++;
    }

    cout << cnt << endl;


}

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

class Node {
public:
  int key;
  Node* left;
  Node* right;
  Node(int key) {
    this->key = key;
    this->left = NULL;
    this->right = NULL;
  }
  void append_left(Node* left) {
    this->left = left;
  }
  void append_right(Node* right) {
    this->right = right;
  }
};

void insert(Node* root,Node* z) {
  Node* cur = root;
  Node* x = root;
  while(cur != NULL) {
    x = cur;
    if(z->key > cur->key)
      cur = cur->right;
    else
      cur = cur->left;
  }
  if(z->key > x->key)
    x->append_right(z);
  else
    x->append_left(z);
}
bool find(Node* root,int key) {
  Node* cur = root;
  while(cur != NULL) {
    if(key == cur->key)
      return true;
    else if(key > cur->key)
      cur = cur->right;
    else
      cur = cur->left;
  }
  return false;
}

void print_crawl_preorder(Node* node) {
  cout << " " << node->key;
  if(node->left != NULL) {
    print_crawl_preorder(node->left);
  }
  if(node->right != NULL) {
    print_crawl_preorder(node->right);
  }
  return;
}
void print_crawl_inorder(Node* node) {
  if(node->left != NULL) {
    print_crawl_inorder(node->left);
  }
  cout << " " << node->key;
  if(node->right != NULL) {
    print_crawl_inorder(node->right);
  }
  return;
}

int main() {
  int n; cin >> n;
  Node* root = NULL;
  for(int i=0;i<n;i++) {
    string command; cin >> command;
    if(command == "insert") {
      int key; cin >> key;
      if(root == NULL) {
        root = new Node(key);
      }
      else {
        Node* z = new Node(key);
        insert(root,z);
      }
    }
    else if(command == "find") {
      int key; cin >> key;
      if(find(root,key)) cout << "yes" << endl;
      else cout << "no" << endl;
    }
    else if(command == "print") {
      print_crawl_inorder(root); cout << endl;
      print_crawl_preorder(root); cout << endl;
    }
  }
}

Measured memory_bytes: 13716
#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 n, m;
  cin >> n >> m;
  vector<ll> p(n+10);
  vector<ll> wa(n+10);
  ll pen = 0;
  ll ans = 0;
  rep(i,m) {
    ll prob;
    string res;
    cin >> prob >> res;
    if(p[prob] == 1) {
    }
    else {
      if(res == "WA") {
        wa[prob] += 1;
      }
      else {
        ans += 1;
        p[prob] = 1;
      }
    }
  }
  rep(i,n+1) {
    if(p[i] == 1) {
      pen += wa[i];
    }
  }
  cout << ans << " " << pen << endl;
  return 0;
}


Measured memory_bytes: 1792
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq as hq
import itertools as its
import operator as op


# globals
inf = float('inf')
N = 0


def set_inputs():
    global N
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    n = get_int()
    A = get_li()
    A.sort()
    if n == 2:
        print(A[1] - A[0])
        print(A[1], A[0])
        return
    numbers = deque(A)
    _min = numbers.popleft()
    _max = numbers.pop()
    ans = sum(abs(x) for x in A)
    operations = []
    if _min > 0:
        operations.append((_min, _max))
        ans -= _min * 2
        _min, _max = _min - _max, numbers.pop()
    elif _max < 0:
        operations.append((_max, _min))
        ans += _max * 2
        _min, _max = numbers.popleft(), _max - _min
    # _min <= 0 and 0 <= _max
    for x in numbers:
        if x > 0:
            operations.append((_min, x))
            _min -= x
        else:
            operations.append((_max, x))
            _max -= x
    operations.append((_max, _min))
    print(ans)
    for x, y in operations:
        print(x, y)
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    main()


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

const int INF = 1e9;

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

    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++) {
        s[i] = 'A' + (s[i] - 'A' + n) % 26;
    }
    cout << s << endl;

	return 0;
}

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

int main(){
  int k, a, b;
  cin >> k >> a >> b;
  int n = a;
  while(n  <=  b){
    if(n  % k == 0){
      cout << "OK" << endl;
      return 0;
    }
    n ++;
  }
  
  cout << "NG" << endl;
}

  

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

void ABC106D()
{
	int N, M, Q;
	cin >> N >> M >> Q;

	vector<vector<int> > ctTrain(N,vector<int>(N));
	for (int i = 0; i < M; ++i)
	{
		int L, R;
		cin >> L >> R;
		++ctTrain[L - 1][R - 1];
	}

	vector<vector<int> > nCover(N, vector<int>(N));
	for (int i = 0; i < N; ++i)
	{
		nCover[i][i] = ctTrain[i][i];
	}
	for (int k = 1; k < N; ++k)
	{
		for (int i = 0; i + k < N; ++i)
		{
			nCover[i][i + k] = nCover[i][i + k - 1] + nCover[i + 1][i + k] - nCover[i + 1][i + k - 1] + ctTrain[i][i + k];
		}
	}

	for (int i = 0; i < Q; ++i)
	{
		int p, q;
		cin >> p >> q;
		--p; --q;
		cout << nCover[p][q] << endl;
	}

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

Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int h = scan.nextInt();
		scan.close();
		System.out.println((a+b)*h/2);
	}
}

Measured memory_bytes: 21332
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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() {
  vector<int> X(3);
  rep(i, 3) cin >> X[i];

  map<int, int> m;
  rep(i, 3) { m[X[i]]++; }

  for (auto itr = m.begin(); itr != m.end(); itr++) {
    if(itr->se==1){
      cout << itr->fi << endl;
    }
  }
}

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

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int k=1;
    while(a>0||c>0){
    	if(k&1){
    		c-=b;
    		k++;
    		if(c<=0){
    			cout<<"Yes";
    			break;
			}
		}
		else{
			a-=d;
			k++;
			if(a<=0){
				cout<<"No";
				break;
			}
		}
	}
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef unsigned char ubyte;

const ld EPS = 1e-10;
const ld PI = acos(-1.0);
const int INF = (int)1e9 + 5;
const ll LINF = (ll)1e18 + 5;

template<class T> 
ll abs(const T & x) { return x < 0 ? -x : x; }

template<class T> 
ll round(const T & x) { return x < 0 ? x - 0.5 : x + 0.5; }

template<class T> 
bool chmin(T & x, const T & y) {
	if (y < x) {
		x = y;
		return true;
	}
	return false;
}

template<class T>
ostream & operator <<(ostream & os, const vector<T> & v) {
	os << "{";
	for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it) {
		os << *it;
		if ((it + 1) != v.end()) os << ", ";
	}
	os << "}";
	return os;
}

template<class P, class Q>
ostream & operator <<(ostream & os, const pair<P, Q> & p) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template<class T> 
bool chmax(T & x, const T & y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

#define all(a) (a).begin(), (a).end()


int main() {
	srand(time(0));
#ifdef LOCAL 
	freopen("input.txt", "r", stdin);
#else
#endif

	int n, l;
	scanf("%d%d", &n, &l);

	vector<int> a(n);

	for (int & x : a) {
		scanf("%d", &x);
	}

	int idx = -1;

	for (int i = 0; i + 1 < n; i++) {
		if (a[i] + a[i + 1] >= l) {
			idx = i;
		}
	}

	if (idx == -1) {
		puts("Impossible");
		exit(0);
	}

	vector<int> res = {idx};

	for (int i = idx - 1; i >= 0; i--) {
		res.push_back(i);
	}

	for (int i = idx + 1; i + 1 < n; i++) {
		res.push_back(i);
	}

	reverse(all(res));

	puts("Possible");
	for (int x : res) {
		printf("%d\n", x + 1);
	}

}


Measured memory_bytes: 1784
import java.util.Scanner;

public class Main {
    public static void main(String [] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long [][] dist = new long[n + 1][n + 1];
        for (int i = 1; i <= n; ++i) {
            for (int j = 1; j <= n; ++j) {
                long a = scanner.nextInt();
                dist[i][j] = a;
            }
        }
        long totalLength = 0;
        for (int i = 1; i <= n; ++i) {
            for (int j = i + 1; j <= n; ++j) {
                boolean isNecessary = true;
                for (int k = 1; k <= n; ++k) {
                    if (i == k || j == k) {
                        continue;
                    }
                    if (dist[i][k] + dist[k][j] < dist[i][j]) {
                        System.out.println(-1);
                        return;
                    } else if (dist[i][k] + dist[k][j] == dist[i][j]) {
                        isNecessary = false;
                        break;
                    }
                }
                if (isNecessary) {
                    totalLength += dist[i][j];
                }
            }
        }
        System.out.println(totalLength);
    }
}


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

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

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

int A,B;
int main(){
    ios::sync_with_stdio(false);
    cin >> A >> B;
    if (A==1) A=14;
    if (B==1) B=14;
    if (A==B) {
        cout << "Draw" << endl;
    }
    else if (A < B) {
        cout << "Bob" << endl;
    }
    else if (A > B) {
        cout << "Alice" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if(abs(a-x) > abs(b-x)){
        cout << "B";
    }
    else
    {
        cout << "A";
    }
    
    cout << endl;
}


Measured memory_bytes: 256