akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


int main(){
  int n, q;
  int st, t,k;
  
  scanf("%d%d", &n, &q);

  st = 0;
  for(int i=0;i<q;i++){
    scanf("%d%d", &t, &k);
    if(t == 0){
      printf("%d\n", (st + k - 1)%n + 1);
    }else{
      st = (st+k)%n;
    }
  }
  
  return 0;
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
 
using namespace std;
 
 
const int MAX_N = int(1e6) + 10;
long long int MOD=1e9+7;
const long long int INF=1e18;
 
typedef long long int ll;
typedef unsigned long long int llu;
 
 
 
inline ll mul(ll a,ll b){
 
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll c=a*b;
    c=(c+MOD)%MOD;
    return c;
}
inline ll add(ll a,ll b){
    a=(a+MOD)%MOD;
    b=(b+MOD)%MOD;
    ll ans=(a+b);
    ans=(ans+MOD)%MOD;
    return ans;
}
ll power(ll a,ll b,ll c=0){
    ll ans=1;
    while(b){
        if(b&1){
            ans=mul(ans,a);
        }
        a=mul(a,a);
        b=b/2;
    }
    return ans;
}
 
  
 
 
#define all(x) (x).begin(),(x).end()
 
 
 
 
//s.reserve(32768); //updated !
//s.max_load_factor(0.25);

int a[2005];
 
int main(){
   
   int n;
   cin>>n;

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

   sort(a,a+n);

   ll ans22=0;


   for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
        int low=j+1;
        int high=n-1;
        int ans=-1;
        while(low<=high){
            int mid=(low+high)/2;
            if(a[mid]<a[i]+a[j]){
                ans=mid;
                low=mid+1;
            }else{
                high=mid-1;
            }
        }

        if(ans!=-1){
            ans22+=(ans-j);
        }
    }
   }

   cout<<ans22<<endl;


   
    
}
 
 
 
    
 
 
 
    
 
 
 
    
    
    
 
 
 
 
    
 
 
    
 
    
 
 
 
 
 
 
    
    
 
    
 
    
 
 
 
 
    
 


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

vector<int> gr[100001];
int dp[100001];

int solve(int src){

    int isleaf = 1, bestchild = 0;

    if(dp[src]!=-1)
        return dp[src];

    for(auto child : gr[src]){
        isleaf = 0;
        bestchild = max(bestchild,solve(child));
    }
    return dp[src] = isleaf==1 ? 0 : 1 + bestchild;
}

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

    memset(dp,-1,sizeof dp);
    for(int i=0;i<m;i++){
        int u,v;
        cin>>u>>v;
        gr[u].push_back(v);
    }

    int ans = 0;
    for(int i=1;i<=n;i++){
        ans = max(ans,solve(i));
    }

    cout<<ans;
    return 0;
}


Measured memory_bytes: 11464
#include<iostream>
#include<string>
#include <vector>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<iomanip>
#include<cmath>
#include<bitset>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using vs = vector<string>;
using pii = pair<int, int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vsort(v) sort(v.begin(), v.end())
#define rv(v) reverse(v.begin(), v.end())
#define ll long long
#define PI 3.141592653589793
using vll = vector<ll>;
using Graph = vii;
const ll MOD = 1e9 + 7;

int main() {
	string s;
	cin >> s;
	int ans;
	if (s == "SUN") {
		ans = 7;
	}
	if (s == "MON") {
		ans = 6;
	}
	if (s == "TUE") {
		ans = 5;
	}
	if (s == "WED") {
		ans = 4;
	}
	if (s == "THU") {
		ans = 3;
	}
	if (s == "FRI") {
		ans = 2;
	}
	if (s == "SAT") {
		ans = 1;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
N = int(input().strip())
A = list(map(int, input().strip().split()))
bias = sorted([a-i for i, a in enumerate(A, 1)])
if N % 2 == 0:
    b = bias[N // 2 - 1]
else:
    b = bias[(N-1) // 2]
print(sum([abs(a - i - b) for i, a in enumerate(A, 1)]))

Measured memory_bytes: 27640
// Do you knOW what it feels like?

		// To be TorTured by your own MinD?
	
	// I don't wanna feel the PAIN.

// I BeG you to KILL me, pleASE...

#include <bits/stdc++.h>
using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("Os")

#define F first
#define S second
#define pb push_back
#define SZ(x) (ll)(x.size())
#define all(x) x.begin(),x.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;

const ll maxn=1e5+10, mod=1e9+7, inf=1e18;

ll n,a[maxn];

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

	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	sort(a+1,a+1+n,greater<ll>());
	ll x=1,y=1; while(x<n && a[x+1]>y) x++, y++;
	ll l=a[x]-y,r=-1; while(x<=n && a[x]>=y) x++, r++;
	cout<<(l%2 || r%2 ? "First\n":"Second\n");

	return 0;
}









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

int main(){
int y,m,d;
char c1,c2;
cin >>y >>c1 >>m >>c2 >>d; //入力を数字と記号の文字列として受け取る
//yは2019であることが分かっているのでmのみ比べればよい
if(m<=4)cout <<"Heisei" <<endl;
else cout <<"TBD" <<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);

		String a = scan.next();

		if(Character.isUpperCase(a.charAt(0))) {
			System.out.println("A");
		}else {
			System.out.println("a");
		}

	}
}

Measured memory_bytes: 26956
#include<iostream>
// #include<vector>
// #include<algorithm>
// #include<cmath>
// #include<iomanip>
// #include<unordered_set>
// #include<unordered_map>

// #define pb push_back

using namespace std;

// typedef long long long long ll;
// typedef unsigned long long long long ull;
// typedef pair<int,int> pii;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    string s;
    cin>>s;
    int ans = 0;
    for(int i=0;i<3;)
    {
        int count = 0;
        while(i<3 && s[i++] == 'R')
            ++count;
        ans = max(ans,count);
    }
    cout<<ans;
    return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	int n=sz(s);
	
	vector<VL> dp(n+2, VL(4));
	dp[0][0] = 1;
	rep(i, n){
		rep(j, 4){
			if(s[i]=='?') (dp[i+1][j] += dp[i][j] * 3) %=MD;
			else (dp[i+1][j] += dp[i][j]) %=MD;
		}
		rep(j, 3){
			if(s[i]=='A'+j || s[i]=='?') (dp[i+1][j+1] +=dp[i][j]) %=MD;
		}
	}
	
	cout << dp[n][3] <<"\n";
	return 0;
}


Measured memory_bytes: 7376
import math
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def numdiv(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table
N = i()
era = numdiv(N)
ans = 0
for i in range(1,N+1):
    ans += era[i]*i
print(ans)

Measured memory_bytes: 151784
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define inf 1000000000000000
#define pb push_back
#define mp make_pair
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
int main(){
IOS;
lli n,i,j,k;
cin>>n>>k;
lli a[n+k],dp[n+k];
dp[n-1]=0;
for(i=1;i<=k;i++){
    a[n+i-1]=inf;
    dp[n+i-1]=inf;
}
for(i=0;i<n;i++){
    cin>>a[i];
}
for(i=n-2;i>=0;i--){
        lli mini=inf;
        for(j=1;j<=k;j++){
        mini=min(dp[i+j]+abs(a[i]-a[i+j]),mini);
        }
        dp[i]=mini;
}
cout<<dp[0]<<endl;
}


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

#define int long long
#define rep(i, n) for (int i = 0; i < (int) (n); i++)
#define reps(i, n) for (int i = 1; i <= (int) (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
constexpr int DX[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
int sign(int x) { return (x > 0) - (x < 0); }
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int cdiv(int a, int b) { return (a - 1 + b) / b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const deque<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const set<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const map<T, U> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

signed main() {
    int N, M;
    cin >> N >> M;
    vint a(N), b(M);
    rep(i, N) { cin >> a[i]; }
    rep(i, M) { cin >> b[i]; }
    auto c = convolution(a, b);
    rep(i, N + M - 1) { cout << c[i] << " "; }
    cout << endl;
}

Measured memory_bytes: 27260
//g++でビルド

#include "bits/stdc++.h"

using namespace std;

int main(){
    string result;
    int N;
    cin >> N;
    int max = -1;
    int sum = 0;
    for(int i = 0; i < N; i++){
        int a;
        cin >> a;
        if(max == -1){
            max = a;
        }else if(max < a){
            sum += max;
            max = a;
        }else{
            sum += a;
        }
    }
    
    if(sum > max){
        result = "Yes";
    }else{
        result = "No";
    }
    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod 1000000007
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int n;
	cin>>n;
	cout<<(n*(n-2)+n%2)/2<<endl;
	f(i,n){
		f(j,n){
			if(i<j&&i+j+1+n%2!=n) cout<<i+1<<" "<<j+1<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair { public int x, y; public Pair(int x, int y) { this.x = x; this.y = y; } }
    public static void Main()
    {
        int[] a = LineInt();
        int A = Math.Min(a[0], a[1]);
        int B = Math.Max(a[0], a[1]);
        int C = a[2];
        Console.WriteLine((A < C && C < B ? "Yes" : "No"));
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

vector <pair <long long, long long> > prime_factorize(long long N){
    vector <pair <long long, long long> > res;
    for(long long a=2; a*a <= N; a++){//a<=N^0.5まで試す
        if(N % a != 0) continue;//素因数でないなら次のforループ
        long long ex = 0;//指数
        while(N % a == 0){
            ex ++;
            N /= a;
        }
        res.push_back({a,ex});//結果を格納{素因数,指数}
    }
    if(N != 1) res.push_back({N,1});//最後が1でなければ素因数
    return res;
}

int main(){
    long long n;
    cin >> n;
    auto table = prime_factorize(n);
    int ans = 0;
    for(int i=0; i<table.size(); i++){
        int tmp=table[i].second;
        for(int j=0; j<100; j++){
            if((j*(j+1)<=2*tmp) && (2*tmp < (j+1)*(j+2))){
                ans += j;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3560
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	as := make([]int, n, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&as[i])
	}

	for i := 0; i < n; i++ {
		if as[i] == 0 {
			fmt.Println(0)
			return
		}
	}

	ret := 1
	for i := 0; i < n; i++ {
		if as[i] <= 1000000000000000000/ret {
			ret *= as[i]
		} else {
			fmt.Println(-1)
			return
		}

	}

	fmt.Println(ret)
}

Measured memory_bytes: 6320
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sc(n) scanf("%d",&n)
#define scl(n) scanf("%lld",&n)
#define pr(n) printf("%d",n)
#define prl(n) printf("%lld",n)
#define nl printf("\n")
#define fr(i,n) for(i=0;i<n;i++)
#define rep(i,st,en) for(i=st;i<=en;i++)
#define repv(i,en,st) for(i=en;i>=st;i--)
#define fout cout<<fixed<<setprecision(7)
#define bi(n) __builtin_popcount(n)
#define bil(n) __builtin_popcountll(n)


typedef long long ll;
typedef pair<int,int> pii;
const int N = 100010;
ll mod = 1e9+7;
ll fmod(ll b,ll exp){
    ll res =1;
    while(exp){if(exp&1ll)res=(res*b)%mod;
    b =(b*b)%mod;exp/=2ll;
    }
    return res;
}

map<string,int> mp1;
string s;

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //ios_base::sync_with_stdio(false);cin.tie(NULL);
    int t=1,n,i,j;
    cin>>n;
    char pre;
    int fl=0;
    fr(i,n)
    {
        cin>>s;
        if(mp1.find(s)!=mp1.end())fl=1;
        if(i && s[0]!=pre)fl=1;
        mp1[s]++;
        pre=s[s.length()-1];
    }
    if(!fl)cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

int main()
{
  int w,n;
  int c[50]={0};
  int a,b;
  //  int temp;

  scanf("%d",&w);
  scanf("%d",&n);

  for(int i=0; i<=w; i++){
    c[i]=i;
  }

  for(int i=0; i<n; i++){
    scanf("%d,%d", &a,&b);
    swap(c[a], c[b]);
  }

  for(int i=1; i<=w; i++){
    printf("%d\n",c[i]);
  }
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <queue>
#define int long long
using namespace std;

int n, m;
int a[200000], b[200000];
vector<int> et[200000];
int color[200000];

void drawColor(int start) {
	queue<int> que;
	
	que.push(start);
	color[start] = 0;
	while (!que.empty()) {
		int v = que.front(); que.pop();
		for (int i = 0; i < et[v].size(); i++) {
			int nv = et[v][i];
			if (color[nv] == -1) {
				que.push(nv);
				color[nv] = !color[v];
			}
		}
	}
}

signed main() {
	int i;
	
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
		et[a[i]].push_back(b[i]);
		et[b[i]].push_back(a[i]);
	}
	
	for (i = 0; i < n; i++) {
		color[i] = -1;
	}
	
	drawColor(0);
	
	for (i = 0; i < m; i++) {
		if (color[a[i]] == color[b[i]]) {
			cout << n * (n - 1) / 2 - m << endl;
			return 0;
		}
	}
	
	//2部グラフ
	int black = 0, white;
	for (i = 0; i < n; i++) {
		if (color[i] == 1) black++;
	}
	white = n - black;
	
	cout << black * white - m << endl;
	return 0;
}

Measured memory_bytes: 12160
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<map>
#include<vector>
#include<sstream>
#include<iostream>
using namespace std;
int main(void){

    int n,p;
    while(cin>>n>>p,n|p){
        int a[100] = {};
        int q = p;
        int now = 0;
        while(true){
            if(q>0){
                a[now]++;
                q--;
                if(a[now] == p){
                    cout<<now<<endl;
                    goto next;
                }
            }
            else{
                q = a[now];
                a[now] = 0;
            }
            now++;
            if(now == n)now -= n;
        }
        next:;
    }

    return 0;
}

Measured memory_bytes: 1160
import Data.List

solve :: [Float] -> String
solve [x, y, x1, y1, x2, y2, x3, y3]
  | x1 == x2 = if x1 < x && y > (y3 - y1) / (x3 - x1) * (x - x1) + y1 && y < (y3 - y2) / (x3 - x2) * (x - x2) + y2 then "YES" else "NO"
  | x2 == x3 = if x < x2 && y > (y2 - y1) / (x2 - x1) * (x - x1) + y1 && y < (y3 - y1) / (x3 - x1) * (x - x1) + y1 then "YES" else "NO"
  | y2 > (y3 - y1) / (x3 - x1) * (x2 - x1) + y1 = if y < (y2 - y1) / (x2 - x1) * (x - x1) + y1 && y > (y3 - y1) / (x3 - x1) * (x - x1) + y1 && y < (y3 - y2) / (x3 - x2) * (x - x2) + y2 then "YES" else "NO"
  | otherwise = if y > (y2 - y1) / (x2 - x1) * (x - x1) + y1 && y < (y3 - y1) / (x3 - x1) * (x - x1) + y1 && y > (y3 - y2) / (x3 - x2) * (x - x2) + y2 then "YES" else "NO"

create :: [Float] -> [[Float]]
create [] = []
create (x:y:xs) = (x : y : []) : create xs

main = getContents >>= mapM_ putStrLn . map (solve . (\x -> concat $ (drop 6 x :) $ sort $ create $ take 6 x) . map read . words) . lines

Measured memory_bytes: 4296
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std; 
int main(void){

  int n;
  cin >> n;
  
  vector<int> vec(n);
  for (int i = 0; i < n; i++) {
    cin >> vec.at(i);
  }
  sort(vec.rbegin(), vec.rend()); 
  int result = 0;
  
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j < n; j++){
      for(int k = j + 1; k < n; k++){
        int a = vec.at(i);
        int b = vec.at(j);
        int c = vec.at(k);

        if(a + b > c && b + c > a && c + a > b){
          result++;
        } else {
          continue;
        }
      }
      if (vec.at(i) > vec.at(j) * 2) continue;
    }
  }
   
  cout << result << endl;
  return 0;
}


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

string s; int k;
int main() {
    cin >> s >> k;
    int n = (int)s.size();
    
    for(int i = 0; i < n; ++i) {
        if(s[i] != 'a' && '{' - s[i] <= k) {
            k -= '{' - s[i];
            s[i] = 'a';
        }
    }

    k %= 26;
    int last = (s[n-1] + k) % 97;
    s[n-1] = last+'a';

    cout << s << endl;
    return 0;
}

Measured memory_bytes: 512
using System;

public class Swap
{
    public int c { get; set; }
}

public class Hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var a = new int[n];
            for (int i = 0; i < n; i++) a[i] = int.Parse(Console.ReadLine().Trim());
            var s = new Swap();
            for (int i = n - 2; i >= 0; i--)
                for (int j = 0; j <= i; j++)
                    doSwap(a, j, s);
            Console.WriteLine(s.c);
        }
    }
    public static void doSwap(int[] a, int p, Swap s)
    {
        if (a[p]> a[p+1])
        {
            var w = a[p];
            a[p] = a[p + 1];
            a[p + 1] = w;
            s.c++;
        }
    }
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< "\n"


int main(){
    for(int x,t=1;;t++){
        cin >> x;
        if(x==0)break;
        else printf("Case %d: %d\n",t,x);
    }
    return 0;
}


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

int main(){
    int n, m, a, b;
    cin >> n >> m >> a >> b;
    int x[n];
    for(int i = 0; i < n; i++)  cin >> x[i];
    int d = 0;
    for(;d < n; d++){
        if(x[d] < a)   break;
    }
    if(n-d < m){
        while(d-1 >= 0 && x[d-1] <= b)  d--;
    }
    cout << d << endl;
    return 0;
}


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

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

  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
  }

  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());

  int Alice = 0;
  int Bob = 0;
  for (int i = 0; i < n; i++) {
    if (i&0x1) Bob += a.at(i);
    else Alice += a.at(i);
  }

  cout << Alice - Bob << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
int dp[1000001];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n , k ;
    cin >> n >> k ;
    int a[n];
    for(int i=0;i < n ;i++)
    {
        cin >> a[i];
        dp[i]=INT_MAX;
    }
    dp[0]=0;
    //for(int i=1;i <=n ; i++)dp[i]=INT_MAX;
    if(n==2)cout << abs(a[0]-a[1]) << '\n';
    else
    {
        for(int i=0; i<n ;i++)
        {
            for(int j=1; j<=k ; j++)
            {
                dp[i+j] = min(dp[i+j], (dp[i]+abs(a[i+j]-a[i])));
            }
        }
        //for(int i =0 ; i <= n ;i++)cout << dp[i] << " ";
        //cout <<'\n';
        cout << dp[n-1] << '\n';
    }

}


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

using ll=long long;
const ll MOD=1000000007;

int main() {
  int N;
  cin >> N;
  ll ans=0;
  vector<int> A(N);
  for(int i=0;i<N;i++)
    cin >> A[i];
  sort(A.begin(),A.end());
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      int r=lower_bound(A.begin(),A.end(),A[i]+A[j])-A.begin();
      ans +=r-j-1;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説通り実装したソースコード
 */
public class Main {

	/** 1000までの素数一覧 */
	private static final int[] PRIMES = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
			73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181,
			191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307,
			311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433,
			439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571,
			577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701,
			709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853,
			857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997 };
	private static final long MOD = 1_000_000_007L;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] counts = new int[PRIMES.length];
			Arrays.fill(counts, 0);
			IntStream.rangeClosed(2, n).forEach(i -> {
				int x = i;
				while (x > 1) {
					for (int j = 0; j < PRIMES.length; j++) {
						if (0 == (x % PRIMES[j])) {
							x /= PRIMES[j];
							counts[j]++;
							break;
						}
					}
				}
			});
			long result = 1L;
			for (int count : counts) {
				result = result * (count + 1) % MOD;
			}
			System.out.println(result);
		}
	}
}


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

int main(){
	string s;cin>>s;
	int ans=1e9,tmp1=0,tmp0=0;
	for(int i=0;i<26;i++){
	  char c='a'+i;
	  tmp1=0;tmp0=0;
	for(int j=0;j<s.size();j++){  
		if(s[j]!=c)tmp0++;
		 else{
			tmp1=max(tmp1,tmp0);tmp0=0;
			}
	}
	tmp1=max(tmp1,tmp0);
	ans=min(ans,tmp1);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
# わからんわからんわからんわからんわからん
# なんで1500人も解いてんの？この界隈天才しかおらん
table = [0 for i in range(2*10**5+5)]
for i in range(2*10**5+5):
    table[i] = "{:0b}".format(i).count("1")


def main():
    N = int(input())
    X = input()
    t = X.count("1")
    x1, x2 = int(X, 2) % (t+1), int(X, 2) % (t-1) if t != 1 else 0
    for i in range(N):
        ans = 1
        x = 0
        if X[i] == "0":
            # 反転してt+1
            p = pow(2, N-i-1, t+1)
            x = x1 + p
            x %= t+1
        elif t != 1:
            p = pow(2, N-i-1, t-1)
            x = x2 - p
            x %= (t-1)
        else:
            ans = 0
        while x > 0:
            x %= table[x]
            ans += 1
        print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


const int MAX_N = 1e7;
int _par[MAX_N];//親                                                       
int _rank[MAX_N];//木の深さ                                                

//n要素で初期化 parは親の要素の番号                                        
void init(int n){
  for(int i=0; i<n; i++){
    _par[i] = i;
    _rank[i]=0;
  }
}

//木の根を求める                                                           
int find(int x){
  if(_par[x]==x){
    return x;
  }
  else{
    return _par[x] = find(_par[x]);
  }
}

//xとyの属する集合の併合                                                   
void unite(int x, int y){
  x=find(x);
  y=find(y);
  if(x==y) return;

  if (_rank[x] < _rank[y]){
    _par[x] = y;
  }else{
    _par[y]=x;
    if(_rank[x] == _rank[y])_rank[x]++;
  }
}

//xとyが同じ集合に属するか否か                                             
bool same(int x, int y){
  return find(x) == find(y);
}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  ll x[N],y[N];
  tuple<int, int, int> x_sort[N];
  tuple<int, int, int> y_sort[N]; //y, x, index
  rep(i,N){
    cin >> x[i] >> y[i];
    x_sort[i] =make_tuple(x[i],y[i],i);
    y_sort[i] =make_tuple(y[i],x[i],i);      
  }
  sort(x_sort,x_sort+N);
  sort(y_sort,y_sort+N);
  init(N);
  //  rep(i,N) _par[i] = i;
  rep(i,N-1){
    if(get<0>(x_sort[i])==get<0>(x_sort[i+1])){
      unite(get<2>(x_sort[i]),get<2>(x_sort[i+1]));
    }
    if(get<0>(y_sort[i])==get<0>(y_sort[i+1])){
      unite(get<2>(y_sort[i]),get<2>(y_sort[i+1]));
    }
  }
  set<ll> s_x[N];
  set<ll> s_y[N];
  int c[N];
  rep(i, N) c[i]=0;
  rep(i,N){
    s_x[find(i)].insert(x[i]);
    s_y[find(i)].insert(y[i]);
    c[find(i)]++;
  }
  ll ans=0;
  rep(i,N){
    //    cout << s_x[i].size() << " " << s_y[i].size()<< endl;
    if(c[i]>0){
      ans += ((ll)s_x[i].size())*((ll)s_y[i].size());
      //      cout << ans << endl;
    }
  }
  ans -= N;
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 21120
use proconio::*;
use std::collections::BinaryHeap;

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

    for i in k..n {
        if a[i] > a[i - k] {
            println!("Yes");
        } else {
            println!("No");
        }
    }
}


Measured memory_bytes: 5696
#include <cstdio>
#include <string>
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, i, j, k, d[51][27] = {};
	string s;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		cin >> s;
		for (j = 0; j < s.size(); j++) {
			for (k = 0; k < 27; k++) {
				if (s[j] == 'a' + k) {
					d[i][k]++;
				}
			}
		}
	}

	for (i = 0; i < 27; i++) {
		d[50][i] = d[0][i];
		for (j = 1; j < n; j++) {
			d[50][i] = min(d[50][i], d[j][i]);
		}
	}

	for (i = 0; i < 27; i++) {
		for (j = 0; j < d[50][i]; j++) {
			printf("%c", 'a' + i);
		}
	}
	printf("\n");

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    ll k;
    cin >> k;
    vector<ll> vec;
    for(int i=1; i<=9; i++) vec.push_back(i);
    while (1) {
        if (k <= vec.size()){
            cout << vec[k-1] << endl;
            return 0;
        }
        k -= vec.size();
        vector<ll> old; 
        swap(old, vec); // oldに1桁つけたものをvecに格納
    
        for (ll x : old) {
            for (int i=-1; i<=1; ++i){
                int d = x%10 + i; //　末尾の数
                if (d<0 || d>9) continue;
                ll nx = x*10 + d; // 末尾にdをつける
                vec.push_back(nx);
            }
        }
    }

    return 0;

}

Measured memory_bytes: 1712
while True:
    X,Y=map(int,input().split())
    if X==0 and Y==0:
        break
    n=0
    while True:
        if Y==0:
            break
        elif X<=Y:
            X,Y=Y,X
        X%=Y
        X,Y=Y,X
        n+=1
    print(X,n)


Measured memory_bytes: 5612
using System;
class Program
    {
        static void Main(string[] args)
        {
            string a = Console.ReadLine();
            string b = Console.ReadLine();
            string c = new Calu().calu(a, b);
            Console.WriteLine(c);
        }
        public class Calu
        {
            public Calu(){ }
            public string calu(string s,string t){

                string a = null;
                

                for (int i = 0; i < t.Length; i++) {
                    a += s[i];
                    a += t[i];
                    
                }
                if (s.Length != t.Length){
                    a += s[s.Length - 1]; 
                }
                return a;
            }
        }
    }

Measured memory_bytes: 11092
import math
a,b,x = map(int,input().split())

if 2 * x <= a**2 * b:
    # x = a * b * w / 2
    w = 2 * x / (a*b)
    print(math.degrees(math.atan(b/w)))
else:
    # a * a * b - x = (h * a * a) / 2
    h = 2 * (a**2 * b - x) / (a**2)
    print(math.degrees((math.atan(h/a))))


Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
  ll k;
  cin >> k;
  if(k<=1000000){
    if(k%2){
      ll x = (k+1LL)/2;
      cout << 2 << endl;
      cout << x-1 << " " << x+2 << endl;
    }
    else{
      ll x = (k/2)+1;
      cout << 2 << endl;
      cout << x << " " << x << endl;
    }
  }
  else{
    ll x = (k/50)+49LL;
    ll m = k%50;
    cout << 50 << endl;
    for(int i=0;i<50-m;++i)
      cout<<x-m<<" ";
    for(int i=0;i<m;++i)
      cout<<x+50-m<<" ";
    cout << endl;
  }
  return 0;
}


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

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    if(N % 2 == 0){
        cout << std::fixed << std::setprecision(15) << 0.5 << endl;
    }else{
        cout << std::fixed << std::setprecision(15) << (double)((N + 1) / 2) / (double)N << endl;
    }

    return 0;
}

Measured memory_bytes: 3716
N,K = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
minTotalCostList = [0 for i in range(N)]
minTotalCostList[0] = 0
for i in range(1,N) :
	for j in range(1,K+1) :
		if j == 1 :
			minTotalCostList[i] = (abs(h[i] - h[i-j]) + minTotalCostList[i-j] )
		elif j > i or minTotalCostList[i] == 0 :
			break
		else :
			minTotalCostList[i] = min(minTotalCostList[i], (abs(h[i] - h[i-j]) + minTotalCostList[i-j] ))

print(minTotalCostList[N-1])

Measured memory_bytes: 56544
#include <stdio.h>

int main() {
	int N;
	scanf("%d",&N);
	int ans = 1;
	int max;
	for (int i = 0; i < N; i++) {
		int hight;
		scanf("%d",&hight);
		if (i == 0) {
			max = hight;
			continue;
		}
		if (max <= hight) {
			ans++;
			max = hight;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};
const int PrimeMax = 1000001;
int is_prime[PrimeMax];
void Eratosthenes(int N){
  for(int i = 0; i < N; i++){
    is_prime[i] = 1;
  }
  is_prime[1] = 0;
  for(int i = 2; i*i < N ; i++){
    if(is_prime[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Eratosthenes(PrimeMax);
  ll a, d, n;
  while(cin >> a >> d >> n && a && d && n){
    ll cnt = 0;
    while(n){
      if(is_prime[a + cnt * d]){
        --n;
        if(!n) cout << a+cnt * d<<endl;
      }
      ++cnt;
    }
  }
  return 0;
}

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

int main() {
  long A,B,K;
  cin >> A>>B>>K;
  long b=B-(K-A);
  long C=0;
  if(A<=K){
    cout << 0<<" "<<max(b,C)<<endl;
  }
  else{
    cout << A-K<<" "<<B<<endl;
  }
}


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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    VL arr(n);
    fr(i,0,n)
        cin>>arr[i];
    sort(ALL(arr));
    VL pref(n+2,0);
    frr(i,n,0)
    {
        pref[i+1]=arr[i]+pref[i+2];
    }  
    ll ans=0; 
    fr(i,1,n)
    {
        ans+=(((pref[i+1])%mod)*arr[i-1])%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

Measured memory_bytes: 6360
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
var obj;
var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + (end) + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  var returnObj = {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(!this.hasNext()){throw "ArrayIndexOutOfBoundsException ‚There is no more input";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var X = one[1];
  var list = nextIntArray();
  var zahyo = 0;
  var count = 1;
  for(var i = 0; i < N; i++){
    zahyo = zahyo + list[i];
    if(zahyo > X){
      break;
    }
    count++;
  }
  myout(count);
}


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

#define PI 4*atan(1)
#define INF 1e8

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

int main(){
  string s;
  cin >> s;
  long long K;
  cin >> K;
  long long tmp = K;
  for(int i = 0; i < s.size(); i++){
    if(s[i] != 'a' && 'z' - s[i] < tmp){
      tmp -= 'z' - s[i] + 1;
      s[i] = 'a';
    }
  }
  // cout << s << endl;
  tmp %= 26;
  s[s.size() - 1] += tmp;
  cout << s << endl;
}


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

int up=0;

int calculate(int x, int y){
  int temp;

  temp=up+x+y;
  up=temp/10;
  return temp%10;
}

int main(){
  char a[1000],b[1000];
  int c[1000],d[1000];
  int e[1000];
  char f[1000];
  int i,j,n;
  int a_len,b_len,max_len;
  int of_flag=0,st_flag=0,st_flag2=0;
  int s,t,u,ee;
  //  int q;
  
  scanf("%d",&n);
  for(j=0;j<n;j++){

    //init
    for(i=0;i<1000;i++){
      a[i]=0;
      b[i]=0;
      c[i]=0;
      d[i]=0;
      e[i]=0;
      f[i]=0;
    }
    ee=0;

    scanf("%s",a);
    scanf("%s",b);
    
    a_len=strlen(a);
    b_len=strlen(b);

    up=0;
    of_flag=0;

    if(a_len>80||b_len>80){
      printf("overflow\n");
      of_flag=1;
    }
    
    for(i=0;i<a_len;i++){
      c[80-a_len+i]=a[i]-'0';
    }
    for(i=0;i<80-a_len;i++){
      c[i]=0;
    }
    for(i=0;i<b_len;i++){
      d[80-b_len+i]=b[i]-'0';
    }
    for(i=0;i<80-b_len;i++){
      d[i]=0;
    }
    for(i=0;i<80;i++){
      e[i]=0;
    }

    if(a_len>b_len){
      max_len=a_len;
    }
    else{
      max_len=b_len;
    }

    if(of_flag!=1){
      st_flag=0;

      if(max_len==80){
	u=0;
      }
      else{
	u=79-max_len;
      }

      for(i=79;i>=u;i--){
	e[i]=calculate(c[i],d[i]);
	if(i==0 && up!=0){
	  printf("overflow\n");
	  st_flag2=1;
	  break;
	}
      }

      if(st_flag2!=1){
	s=0;
	while(e[s]==0){
	  s++;
	  if(s==79){
	    break;
	  }
	}
	for(t=s;t<80;t++){
	  f[ee]=e[t]+'0';
	  ee++;
	}
	f[ee]=0;
	printf("%s\n",f);

	//elements check
	//	for(q=0;q<=ee;q++){
	//	  printf("f[%d]=%c\n",q,f[q]);
	//	}
      }
      st_flag2=0;
    }
  }
  return(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back 
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
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;}
 
int main(){

  while(1){
	int n;
	cin >> n;
	if(n==0) break;
	int ans = 0;
	int w,h;
	cin >> w >> h;
	int tree[100][100];

	REP(i,100){
	  REP(j,100){
		tree[i][j]=0;
	  }
	}

	int x,y;
	REP(i,n){
	  cin >> x >> y;
	  x--;
	  y--;
	  tree[x][y] = 1;
	}
	int s,t;
	cin >> s >> t;
	int now=0;

	// //
	// REP(j,h){
	//   REP(i,w){
	// 	if(tree[i][j]>0) cout << i <<" "<<j<<endl;
	//   }
	// }
	// //

	REP(j,h-t+1){
	  REP(i,w-s+1){
		now = 0;
		FOR(l,j,j+t){
		  FOR(k,i,i+s){
			now += tree[k][l];
		  }
		}
		if(now>ans) ans = now;
		//		  cout << i << " " << j << endl;}//
	  }
	}

	cout << ans << endl;

  }
}

Measured memory_bytes: 1200
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>

intmax_t ok(std::vector<intmax_t> const& a, std::vector<intmax_t> const& f,
            intmax_t k, intmax_t r) {

  size_t n = a.size();
  for (size_t i = 0; i < n; ++i) {
    intmax_t x = a[i];
    intmax_t y = f[i];
    if (x*y <= r) continue;
    k -= x - r/y;
  }
  return k >= 0;
}

int main() {
  size_t n;
  intmax_t k;
  scanf("%zu %jd", &n, &k);

  std::vector<intmax_t> a(n), f(n);
  for (auto& ai: a) scanf("%jd", &ai);
  for (auto& fi: f) scanf("%jd", &fi);

  std::sort(a.begin(), a.end());
  std::sort(f.rbegin(), f.rend());

  intmax_t lb = -1;
  intmax_t ub = 2e12;
  while (ub-lb > 1) {
    intmax_t mid = (lb+ub) >> 1;
    (ok(a, f, k, mid)? ub: lb) = mid;
  }
  printf("%jd\n", ub);
}


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

using namespace std;

typedef long long ll;

double pi = 3.1416;

int main() {
  int n; cin >> n;
  vector <int> cnt(n, 0);
  for(int i = 0; i < n - 1; i++) {
    int x; cin >> x;
    x--;
    cnt[x]++;
  }
  for(int i = 0; i < n; i++) {
    cout << cnt[i] << '\n';
  }
}

Measured memory_bytes: 4048
#include<stdio.h>
 
int main(void){
  int i,j;
  int n;
  int m;
  int flag;
  char a[70],b[70];
  char s;
 
  while(1){
    scanf("%d ",&n);
    if(!n)break;
 
    for(i=0;i<n;i++)scanf("%c %c ",&a[i],&b[i]);
     
    scanf("%d ",&m);
    for(i=0;i<m;i++){
      scanf("%c ",&s);
      flag = 0;
      for(j=0;j<n;j++){
    if(s == a[j]){
      printf("%c",b[j]);
      flag = 1;
      break;
    }
      }
      if(!flag)printf("%c",s);
    }
    putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 580
#include <iostream>

using namespace std;

int main() {
	int n;
	cin >> n;
	int* v = new int[n];
	int* d = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	d[0] = 0;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0) {
			d[0] += v[i];
		}
		else {
			d[0] -= v[i];
		}
	}
	for (int i = 1; i < n; i++) {
		d[i] = 2*v[i - 1] - d[i - 1];
	}
	for (int i = 0; i < n; i++){
		cout << d[i] << endl;
	}
}


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

int main(){
	int k,n;	cin>>k>>n;
	vector<int> a(n);	for(int i=0;i<n;i++)cin>>a[i];

	int d=(k-a[n-1]+a[0]);
	for(int i=0;i+1<n;i++){
		d=max(d, a[i+1]-a[i]);
	}

	cout<<k-d<<endl;

	return 0;
}


Measured memory_bytes: 1024
fun main (args : Array<String>) {
	val (a, b) = readLine()!!.split(" ")
	val A : Long = a.toLong()
	val B : Long = b.toLong()
	val N : Long = 0
	var i : Long = 1
	if (A > B) {
		while ((A * i) % B != N) {
			i++
		}
		return println("${A * i}")
	} else {
		while ((B * i) % A != N) {
			i++
		}
		return println("${(B * i)}")
	}
}

Measured memory_bytes: 37856
#include<bits/stdc++.h>
#define pr pair<int,int>
using namespace std;
const int N=1005;
int n,m;
int nx,my,dx,dy;
char a[N][N];
int d[N][N];
int ox[4]={0,1,0,-1};
int oy[4]={-1,0,1,0};
bool ok(int x,int y){
	if(x>=1 &&x<=n &&y>=1&&y<=m&& a[x][y]!='#'){
		return true;
	}
	return false;
}
int bfs01(){
	if(ok(nx,my)==false)return -1;
	deque<pair<int,pr>>dq;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			d[i][j]=INT_MAX;
		}
	}
	d[nx][my]=0;
	dq.push_back({0,{nx,my}});
	while(dq.size()){
		pr u=dq.front().second;
		int value=dq.front().first;
		dq.pop_front();
		int x=u.first;
		int y=u.second;
		//cout<<x<<" "<<y<<" "<<value<<"\n";
		if(value!=d[x][y] )continue;
		if(x==dx && y==dy)return value;
		for(int i=0;i<4;i++){
			int oox=x+ox[i];
			int ooy=y+oy[i];
			if(ok(oox,ooy)==false){
				continue;
			}
			if(d[oox][ooy]>d[x][y]){
				d[oox][ooy]=d[x][y];
				dq.push_front({d[x][y],{oox,ooy}});
			}
		}
		for(int i=-2;i<=2;i++){
			for(int j=-2;j<=2;j++){
				int nx=i+x,ny=j+y;
				if(ok(nx,ny)==false)continue;
				if(i==0 &&j==0){continue;}
				if(d[nx][ny]>d[x][y]+1){
					d[nx][ny]=d[x][y]+1;
					dq.push_back({d[x][y]+1,{nx,ny}});
				}
			}
		}
	}
	return -1;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>n>>m;
	cin>>nx>>my>>dx>>dy;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
		}
	}
	cout<<bfs01();
}

Measured memory_bytes: 8660
#include <bits/stdc++.h>
 
using namespace std;
int main()
{
  int a,b;
  cin>>a>>b;
  int i;
  if(a>b)
  {
    for(i=0;i<a;i++)
    {
      cout<<b;
    }
  }
  if(a<b)
  {
    for(i=0;i<b;i++)
    {
      cout<<a;
    }
  }
  if(a==b)
  {
    for(i=0;i<a;i++)
    {
      cout<<b;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n;
  cin >> n;
  vector<int> P(n);
  for(int i=0;i<n;i++){
    cin >>P[i];}
int h=0;
  for(int i=0;i<n;i++){
  h =  h + (P[i])*(P[i]);
  }
  int j=1;
while(j <=100){
  int sum=0;
  for(int i=0;i < n; i++){
   
  sum = sum + (P[i] - j) * (P[i] - j);
   
  
  }
   h= min(sum, h);
  
j++;

}
  cout<< h <<endl;
}

Measured memory_bytes: 3636