akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(c) ((int)((c).size()))
#define st first
#define nd second
#define pb push_back

typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef long long ll;

void solve(){
    int n,k;
    cin>>n>>k;
    cout<<(n%k != 0)<<'\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << '\n';
typedef int64_t Int;
Int mod = 1e9+7;
Int INF = 1e18+7;

Int n, m, s, t;
Int d1[100005], d2[100005];

typedef struct {
    Int to, yen, snuuk;
} edge;

vector<edge> G[100005];
bool visited[100005];

int main() {
    ios::sync_with_stdio(false);   
    cin >> n >> m >> s >> t;
    for (Int i = 0; i < m; i++) {
        Int u, v, a, b;
        cin >> u >> v >> a >> b;
        G[u].emplace_back((edge){v, a, b});
        G[v].emplace_back((edge){u, a, b});
    }
    for (Int i = 0; i < 100001; i++) d1[i] = d2[i] = INF;
    d1[s] = d2[t] = 0;
    queue<Int> q;
    q.push(s);
    while (!q.empty()) {
        Int cur = q.front();
        q.pop();
        for (Int i = 0; i < G[cur].size(); i++) {
            edge e = G[cur][i];
            if (d1[e.to] > d1[cur] + e.yen) {
                d1[e.to] = d1[cur] + e.yen;
                q.push(e.to);
            }
        }
    }
    q.push(t);
    while (!q.empty()) {
        Int cur = q.front();
        q.pop();
        for (Int i = 0; i < G[cur].size(); i++) {
            edge e = G[cur][i];
            if (d2[e.to] > d2[cur] + e.snuuk) {
                d2[e.to] = d2[cur] + e.snuuk;
                q.push(e.to);
            }
        }
    }
  /*   for (Int i = 1; i <= n; i++) cout << d1[i] << " ";
    cout << endl;
    for (Int i = 1; i <= n; i++) cout << d2[i] << " ";
    cout << endl; */
    /* Int sub = d2[t];
    for (Int i = 1; i <= n; i++) d2[i] = sub - d2[i]; */
    priority_queue<pair<Int, Int>> pq;
    for (Int i = 1; i <= n; i++) pq.push({1e15 - (d1[i] + d2[i]), i});
    pair<Int, Int> p = pq.top();
    for (Int year = 0; year < n; year++) {
        while (p.second <= year) {
            pq.pop();
            p = pq.top();
        }
        dump(p.first);
    }
    return 0;
}

Measured memory_bytes: 14064
def main():
    S = str(input())
    cnt = 0
    if S[0] == 'A':
        for i in range(2, len(S)-1):
            if S[i] == 'C':
                cnt += 1
        if cnt == 1:
            for i in range(1, len(S)):
                if S[i] == 'C':
                    continue
                elif S[i].islower():
                    continue
                else:
                    print('WA')
                    return
        else:
            print('WA')
            return
    else:
        print('WA')
        return
    print('AC')
    
main()  

Measured memory_bytes: 9048
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s3 = sc.next();
        String[] split = s3.split("");
        int rain=0;
        int a=0;
        for(int i=0; i<3; i++) {
            if(split[i].equals("R")) {
                rain += 1;
            }else if(split[i].equals("S")){
                if(rain == 2||rain == 1) {
                    break;
                }else {
                    rain = 0;
                }
            }
        }
        System.out.println(rain);
    }
}

Measured memory_bytes: 35560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define rrep(i, n) for (ll i = n - 1; i >= 0; i--)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define RRep(i, r, n) for (ll i = n - 1; i <= r; i--)
#define debug(x) cout << #x << ' ' << '=' << ' ' << (x) << endl;
#define fs first
#define sc second
#define int long long
#define pb push_back
const int dx[] = {0, -1, 0, 1};
const int dy[] = {1, 0, -1, 0};
//const int MOD = (1000000007);
const int MOD = (998244353);
//const int INF = (1 << 30)-1;
const int INF = (1LL << 60) - 1;
const double EPS = (1 >> 30);

ll mod_pow(ll x, ll y)
{
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
        {
            res = res * x % MOD;
        }
        x = x * x % MOD;
        y >>= 1;
    }
    return res;
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    //---------------------------------------------

    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d[i];
	if(d[0]!=0){
      cout<<0<<endl;
      return 0;
    }
    sort(all(d));
    vector<P> a(n);
    int c = 0;
    a[0]=make_pair(d[0],1);
    for (int i = 1; i < n; i++) // 距離ｘがそれぞれいくつあるか
    {
        if (d[i - 1] == d[i])
        {
            a[c].sc++;
        }
        else
        {
            c++;
            a[c].fs = d[i];
            a[c].sc++;
        }
    }
    c++;

    int dame = 0;
    rep(i, c) //　距離がれんぞくになってないとだめ
    {
        if (a[i].fs != i)
        {
            dame++;
        }
    }

    ll ans = 1;
    Rep(i, 1, c) // 距離ｘは距離ｘ－１に繋ぐことになる
    {
        ans *= mod_pow(a[i - 1].sc, a[i].sc);
        ans %= MOD;
    }

    if (n == 1) // n==1の処理
    {
        if (d[0] == 0)
        {
            cout << 1 << endl;
        }
        else
        {
            cout << 0 << endl;
        }
    }
    else if (dame > 0) // 距離が飛んでいてつくれない
    {
        cout << 0 << endl;
    }
    else
    {
        if(d[1]!=1){ // 1は必ずいる
            cout<<0<<endl;
        }
        else{
            cout<<ans<<endl;
        }
    }
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"

#pragma warning(disable:4996)
using namespace std;
using ld = long double;
ld eps=1e-9;
#define Seg_Max_N (1<<18) 

using Value = pair<bool, long long int>;
const Value ini = make_pair(false,0);
struct segtree {
	int N;
	vector<Value>dat;

	segtree() {}
	segtree(int n) :dat(2 * Seg_Max_N) {
		N = 1;
		while (N < n) N *= 2;
		for (int i = 0; i < 2 * N - 1; i++) {
			dat[i] = ini;
		}
	}
	Value connect(const Value&l, const Value&r) {
		if (l.first) {
			if (r.first) {
				return make_pair(false,r.second-l.second);
			}
			else {
				return make_pair(true,l.second+r.second);
			}
		}
		else {
			if (r.first) {
				return make_pair(true,r.second-l.second);
			}
			else {
				return make_pair(false,l.second+r.second);
			}
		}
	}
	// update k th element
	void update(int k, Value a) {
		k += N - 1;
		dat[k] = a;

		while (k > 0) {
			k = (k - 1) / 2;
			const Value al(dat[k * 2 + 1]);
			const Value ar(dat[k * 2 + 2]);
			dat[k] = connect(al, ar);
		}
	}
	// min [a, b)
	Value  query(int a, int b) { return query(a, b, 0, 0, N); }
	Value  query(int a, int b, int k, int l, int r) {
		if (r <= a or b <= l) return ini;
		if (a <= l and r <= b) return dat[k];
		const int m = (l + r) / 2;
		const Value al(query(a, b, k * 2 + 1, l, m));
		const Value ar(query(a, b, k * 2 + 2, m, r));
		return connect(al, ar);
	}
};
int main() {
	int X;cin>>X;
	if(X==3||X==5||X==7)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int n, p[25], i, c;
    scanf("%d", &n);
    for (i=1; i<=n; i++) {
        scanf("%d", &p[i]);
    }
    c=0;
    for (i=2; i<=n-1; i++) {
        if ((p[i] > p[i+1] && p[i] < p[i-1]) || (p[i] < p[i+1] && p[i] > p[i-1])) c++;
    }
    printf("%d", c);
    return 0;
}


Measured memory_bytes: 888
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a,b;
		int d,r;
		double f;

		a = scan.nextInt();
		b = scan.nextInt();

		d = a / b;
		r = a % b;
		f = (double)a / (double)b;

		System.out.printf("%d %d %.5f\n", d, r, f);
	}
}

Measured memory_bytes: 26132
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
)

type Pair struct {
	a, b int
}

func main() {
	N, K := ReadInt(), ReadInt()
	pairs := make([]*Pair, N)
	for i := 0; i < N; i++ {
		pairs[i] = &Pair{
			a: ReadInt(),
			b: ReadInt(),
		}
	}
	sort.Slice(pairs, func(i, j int) bool {
		return pairs[i].a < pairs[j].a
	})
	s := 0
	for i := 0; i < N; i++ {
		s += pairs[i].b
		if s >= K {
			fmt.Println(pairs[i].a)
			return
		}
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 7076
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (size_t i = 0; i < size_t(n); i++)
#define forn1(i,n) for (size_t i = 1; i <= size_t(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

template <long long mod>
long long mod_pow(long long a, long long b) {
    if (b == 0) return 1;
    long long ret = mod_pow<mod>(a, b / 2);
    ret = ret * ret % mod;
    if (b % 2 == 1) ret = a * ret % mod;
    return ret;
}

template <long long mod>
struct Comb {
    int n;
    vector<long long> fact, inv;

    Comb(int n)
        : n(n), fact(n + 1, 0), inv(n + 1, 0) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; i++) fact[i] = fact[i - 1] * i % mod;
        inv[n] = mod_pow<mod>(fact[n], mod - 2);
        for (int i = n; i >= 1; i--) inv[i - 1] = inv[i] * i % mod;
    }

    long long operator()(int m, int k) {
        if (m > n || m < k || k < 0)
            return 0;
        else
            return fact[m] * inv[m - k] % mod * inv[k] % mod;
    }
};

int n, k;
const ll MOD = TEN(9) + 7;

int main() {
    fastio();

    cin >> n >> k;

    Comb<MOD> comb(n - 1);

    multiset<int, greater<int>> cnt;
    multiset<int> cnt2;
    forn(i, n) {
        int a;
        cin >> a;
        cnt.insert(a);
        cnt2.insert(a);
    }

    ll cur = 0;
    ll ans = 0;
    for (auto v : cnt) {
        ans = (ans + comb(n - cur - 1, k - 1) * v % MOD) % MOD;
        cur++;
    }

    cur = 0;
    for (auto v : cnt2) {
        ans = (ans - comb(n - cur - 1, k - 1) * v % MOD + MOD) % MOD;
        cur++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const ll mod=1e9+7;
const ll LL_MAX=9223372036854775807;
int vis[105][105];
int n,k;
int main()
{
    scanf("%d%d",&n,&k);
    if(k>(n-2)*(n-1)/2)
    {
        printf("-1\n");
        return 0;
    }
    int ans=n*(n-1)/2-k;
    printf("%d\n",ans);
    for(int i=1; i<=n-2&&k; i++)
        for(int j=i+1; j<=n-1&&k; j++)
        {
            k--;
            vis[j][i]=vis[j][i]=1;
        }
    for(int i=1; i<=n; i++)
        for(int j=1; j<i; j++)
            if(!vis[i][j])
                printf("%d %d\n",i,j);

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int head[600100],cnt,n,m,lim,dis[600100];
struct Node{
	int to,next,val;
}edge[4001000];
void ae(int u,int v,int w){
	edge[cnt].next=head[u],edge[cnt].to=v,edge[cnt].val=w,head[u]=cnt++;
}
map<pair<int,int>,int>mp;
priority_queue<pair<int,int> >q;
bool vis[600100];
int dijkstra(){
	dis[1]=0,q.push(make_pair(0,1));
	while(!q.empty()){
		int x=q.top().second;q.pop();
		if(vis[x])continue;vis[x]=true;
		for(int i=head[x];i!=-1;i=edge[i].next)if(dis[edge[i].to]>dis[x]+edge[i].val)dis[edge[i].to]=dis[x]+edge[i].val,q.push(make_pair(-dis[edge[i].to],edge[i].to));
	}
	return dis[n]==0x3f3f3f3f?-1:dis[n];
}
int hs(int x,int c){
	if(mp.find(make_pair(x,c))!=mp.end())return mp[make_pair(x,c)];
	lim++;
//	printf("(%d,%d)->%d\n",x,c,lim);
	ae(x,lim,1);
	ae(lim,x,0);
	return mp[make_pair(x,c)]=lim;
}
int main(){
	scanf("%d%d",&n,&m),memset(head,-1,sizeof(head)),memset(dis,0x3f3f3f3f,sizeof(dis)),lim=n;
	for(int i=1,u,v,w;i<=m;i++){
		scanf("%d%d%d",&u,&v,&w);
		ae(hs(u,w),hs(v,w),0),ae(hs(v,w),hs(u,w),0);
	}
	printf("%d\n",dijkstra());
	return 0;
}

Measured memory_bytes: 47740
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <numeric>
#include <algorithm>
#include <math.h>

using namespace std;

int N;
string S;

int main(){
    cin >> N >> S;
    
    vector<int> numW(N), numE(N);
    numW[0] = 0, numE[N-1] = 0;
    for(int i=1;i<N;i++){
        if( S[i-1] == 'W' ) numW[i] = numW[i-1] + 1;
        else    numW[i] = numW[i-1];
    }
    for(int i=N-2;i>=0;i--){
        if( S[i+1] == 'E' ) numE[i] = numE[i+1] + 1;
        else    numE[i] = numE[i+1];
        
    }

   int ans = 1000000000;
   for(int i=0;i<N;i++){
       ans = min(ans, numW[i] + numE[i]);
   }

    cout << ans << endl;
}

Measured memory_bytes: 3076
n = int(input())
if n < 11:
    if n <= 6:
        print(1)
    else:
        print(2)
    exit()
if n%11 == 0:
    print((n//11)*2)
elif n%11 <=6:
    print((n//11)*2 + 1)
else:
    print((n//11)*2 + 2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>


using namespace std;

int main() {
  int A, B,C;
  cin >> A>> B>>C;
  int g,m;
  g = max(A,B);
  m = min(A,B);
  if(m < C && C < g) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

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

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

using namespace std;

#define BLK 0
#define CHG 1
#define ATK 2

int n, opr[2][111];

void compute() {
  int power[2] = {0,0};
  rep(i,n) {
    if( opr[0][i] == ATK || opr[1][i] == ATK ) {
      if( opr[0][i] == ATK && opr[1][i] == ATK ) {
	if( power[0] == power[1] ) {
	  power[0] = power[1] = 0;
	  continue;
	} 
	if( power[0] < power[1] ) {
	  puts("Nakajima-kun");
	  return;
	} else {
	  puts("Isono-kun");
	  return;
	}
      } else if( opr[0][i] == ATK ) {
	if( power[0] == 0 ) {
	  puts("Nakajima-kun");
	  return;
	}
	if( opr[1][i] == CHG ) {
	  puts("Isono-kun");
	  return;
	} else if( opr[1][i] == BLK ) {
	  if( power[0] == 5 ) {
	    puts("Isono-kun");
	    return;
	  } else {
	    power[0] = 0;
	  }
	}
      } else {
	if( power[1] == 0 ) {
	  puts("Isono-kun");
	  return;
	}
	if( opr[0][i] == CHG ) {
	  puts("Nakajima-kun");
	  return;
	} else if( opr[0][i] == BLK ) {
	  if( power[1] == 5 ) {
	    puts("Nakajima-kun");
	    return;
	  } else {
	    power[1] = 0;
	  }
	}
      }
    } else {
      if( opr[0][i] == CHG ) power[0] = min(5,power[0]+1);
      if( opr[1][i] == CHG ) power[1] = min(5,power[1]+1);
    }
  }
  puts("Hikiwake-kun");
}

int main() {
  cin >> n;
  rep(i,2) rep(j,n) {
    string tmp;
    cin >> tmp;
    if( tmp[0] == 'm' ) opr[i][j] = BLK;
    if( tmp[0] == 't' ) opr[i][j] = CHG;
    if( tmp[0] == 'k' ) opr[i][j] = ATK;
  }
  compute();
  return 0;
}

Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
 
#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair
 
typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    string s; cin >> s;
    string ans;
    for (char c : s) {
        if (c == '?') ans += 'D';
        else ans += c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3892
#include <vector>
#include <iostream>
using namespace std;
int dx[] = { 1, 0, 0, -1, 0, 0 };
int dy[] = { 0, 1, 0, 0, -1, 0 };
int dz[] = { 0, 0, 1, 0, 0, -1 };
int H, W, D, N, a[1009], b[1009], c[1009];
int main() {
	cin >> H >> W >> D >> N;
	for (int i = 0; i < N; i++) cin >> a[i] >> b[i] >> c[i];
	long long ret = (1LL * H * W + 1LL * W * D + 1LL * D * H) * 2;
	for (int i = 0; i < N; i++) {
		ret += 6;
		for (int j = 0; j < 6; j++) {
			int tx = a[i] + dx[j], ty = b[i] + dy[j], tz = c[i] + dz[j];
			if (!(0 <= tx && tx < H && 0 <= ty && ty < W && 0 <= tz && tz < D)) ret -= 2;
			else {
				for (int k = 0; k < i; k++) {
					if (a[k] == tx && b[k] == ty && c[k] == tz) {
						ret -= 2; break;
					}
				}
			}
		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3060
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);
		
		long a = in.nextInt();
		long fivehand = 0;
		long five = 0;
		
		fivehand = (a/500)*1000;
		five = ((a%500)/5)*5;
		
		System.out.println(fivehand + five);
      
	}
}

Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
#include <cstring>

std::vector<int> G[100000];
int color[100000];

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

    int N;
    std::cin >> N;

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        std::cin >> a >> b;
        a--; b--;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    using P = std::pair<int, int>;  // (頂点, プレイヤー)
    std::queue<P> Q;

    memset(color, -1, sizeof(color));

    int counter[2] = {};

    auto push = [&](int v, int c) {
        Q.push(P(v, c));
        color[v] = c;

        counter[c]++;
    };

    push(0, 0);
    push(N - 1, 1);

    while (!Q.empty()) {
        int v = Q.front().first,
            c = Q.front().second; Q.pop();
        
        for (int to : G[v]) {
            if (color[to] < 0) push(to, c);
        }
    }

    if (counter[0] > counter[1]) {
        std::cout << "Fennec" << std::endl;
    } else {
        std::cout << "Snuke" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 6400
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
#include <iomanip>
#define M_PI acos(-1)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
struct edge {
	int t;
	edge(int _t) : t(_t) {}
};

ll gcd(int a, int b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

void Solve() {
	
	string s;
	cin >> s;
	int k;
	cin >> k;
	for (size_t i = 0; i < s.size() - 1; i++)
	{
		if (s[i] == 'a') continue;
		int v = 'z' - s[i];
		if (k < v + 1) continue;
		s[i] = 'a';
		k -= (v + 1);
	}
	if (k > 0) {
		int re = k % 26;

		s[s.size() - 1] = ((s[s.size() - 1] - 'a') + re) % 26 + 'a';
	}
	cout << s << endl;
}


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



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

public class Main {
	public static void main(String[] args) throws IOException {
		// ???????????\???
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String input = br.readLine();
		String str[] = input.split(" ");

		int h = Integer.parseInt(str[0]); // ??????
		int w = Integer.parseInt(str[1]); // ??????

		while (true) {
			if (h == 0 && w == 0) {
				//??¨??????0
				break;
			} else {
				//????????\???
				for (int i = 0; i < h; i++) {
					for (int j = 0; j < w; j++) {
						// ??????(#?????????)
						System.out.print("#");
					}
					// ??????(??????)
					System.out.println();
				}
				System.out.println();
				// ?¬??????\??????????????????
				input = br.readLine();
				str[0] = null;
				str[1] = null;
				str = input.split(" ");
				h = Integer.parseInt(str[0]);
				w = Integer.parseInt(str[1]);
			}
		}

	}
}

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

int main(){
   vector<int> x(3);
   cin >> x[0] >> x[1] >> x[2];
   sort(x.begin(), x.end());
   if (x[0]==x[1]&&x[0]==5&&x[2]==7){
       cout << "YES" << endl;
   }
   else {
       cout << "NO" << endl;
   }
}
   

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

int main() {
  int n;
  std::cin >> n;
  std::vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; ++i) {
    std::cin >> a[i];
    a[i]--;
  }
  for (int i = 0; i < n; ++i)
    std::cin >> b[i];
  for (int i = 0; i < n - 1; ++i)
    std::cin >> c[i];

  int sum = 0;
  int prev = -1;
  for (int i = 0; i < n; ++i) {
    sum += b[a[i]];
    if (prev >= 0 && (prev + 1 == a[i]))
      sum += c[prev];
    prev = a[i];
  }

  std::cout << sum << std::endl;
}


Measured memory_bytes: 3140
s = input()
t = input()
if len(s) <= len(t):
    a = s; s = t; t = a
res = 0
for i in range(len(s)-len(t)+1):
    temp = 0
    for j in range(len(t)):
        if s[j+i] == t[j]:
            temp+=1
    res = max(temp, res)

ans =len(t) - res
print(ans)

Measured memory_bytes: 67544
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	if v1, v2 := a*b, c*d; v1 > v2 {
		fmt.Println(v1)
	} else {
		fmt.Println(v2)
	}
}


Measured memory_bytes: 512
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve()
	{
		long n = nl();
		out.println(n * (n - 1) / 2);
	}

	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

	public static void main(String[] args) throws Exception {
		new Main().run();
	}

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private float nf() {
		return Float.parseFloat(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 20820
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		long[] a = new long[n+1];
		for(int i = 0; i < n; i++){
		    a[i] = sc.nextLong();
		}
		
		// 計算
		long result = 0;
		long xor = a[0];
		long sum = a[0];
		int r = 0;
		int l = 0;
		while(l < n && r < n){
		    if(xor == sum){
		        result += r - l + 1;
		        r++;
		        xor = xor ^ a[r];
		        sum = sum + a[r];
		    }else{
		        xor = xor ^ a[l];
		        sum = sum - a[l];
		        l++;
		    }
		}
		
		// 出力
		System.out.println(result);
	}
}


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



int hassh[27];

double eps=0.0000000000000000001;

int main() {

    ios::sync_with_stdio(0);
    long long val=0;

    long long a,b;
    cin>>a>>b;

    for(val=0;;val++){

        long long ta=(long long)(0.08*(double)(val));
        long long tb=(long long)(0.1*(double)(val));
        // cout<<ta<<" : "<<tb<<"\n";
        if(ta==a&&tb==b){
            cout<<val;
            return 0;
        }

        if(ta>a&&tb>b){
            cout<<-1;
            return 0;
        }

    }

    return 0;
}

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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] input = br.readLine().split(" ");

            int parkingMinute = Integer.parseInt(input[0]);
            int parkingChargePerMinute = Integer.parseInt(input[1]);

            int parkingChargeOfPlanA = parkingMinute * parkingChargePerMinute;
            int parkingChargeOfPlanB = Integer.parseInt(input[2]);

            int selectCharge = parkingChargeOfPlanA;
            if (parkingChargeOfPlanA > parkingChargeOfPlanB) {
                selectCharge = parkingChargeOfPlanB;
            }

            System.out.println(selectCharge);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 21204
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>
#include <cassert>


using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<n;++i)
#define FOR(i, a, b) for(int i=a;i<b;++i)
#define RREP(i, n) for(int i=n-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=b-1;i>=a;--i)

#define all(x) begin(x),end(x)
#define dump(x) cerr<<#x<<" = "<<(x)<<endl
#define debug(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;

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

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


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

template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}

// edit

void solve() {
    int n;
    cin >> n;
    vector<vector<int>> C(n, vector<int>(n));
    
    REP(i,n){
        REP(j,n){
            cin >> C[i][j];
        }
    }
    
    ll ans = 0;
    
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < i; ++j){
            ll tmp = min(C[i][j], C[j][i]);
            ans += tmp;
        }
    }
    
    cout << ans << endl;

}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
//    std::ifstream in("input.txt");
//    std::cin.rdbuf(in.rdbuf());

    solve();


    return 0;
}



Measured memory_bytes: 3264
# Partition
def partition(A, p, r):
    x = A[r]
    i = p - 1
    for j in range(p, r):
        if (A[j] <= x):
            i += 1
            A[i],A[j] = A[j],A[i]
    A[i+1],A[r] = A[r],A[i+1]
    return i+1

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

idx = partition(A, 0, len(A) - 1)
A[idx] = f'[{A[idx]}]'
print(*A)


Measured memory_bytes: 16400
import numpy as np
H, W, D = map(int, input().split())
grid = [[] for h in range(H)]

for h in range(H):
    grid[h] = [int(_) for _ in input().split()]
memo = [None] * (H * W + 1)
for h in range(H):
    for w in range(W):
        memo[grid[h][w]] = (h, w)

distance = [0 for i in range(H * W + 1)]

for d in range(D + 1, H * W + 1):
    h_1, w_1 = memo[d]
    h_0, w_0 = memo[d - D]
    distance[d] = distance[d - D] + abs(h_1 - h_0) + abs(w_1 - w_0)

Q = int(input())
for q in range(Q):
    L, R = map(int, input().split())
    print(distance[R] - distance[L])

Measured memory_bytes: 27104
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define sz size()
#define ll long long
#define all(_v) _v.begin(), _v.end()
#define pii pair <int, int>
#define pll pair <ll, ll>
#define pvllvll pair <vector <ll>, vector <ll> >
#define ld long double
#define veci vector <int>
#define vecll vector <ll>


const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const double PI = 3.1415926535897932384626433832795;
const double eps = 1e-9;
const int MOD1 = 1e9 + 7;
const int MOD2 = 998244353;

ll fw[(int)5e5+10];
int n, q;

void upd(int p, ll val) {
    for(;p <= n; p += (p & -p)) fw[p] += val;
}

ll sum(int r) {
    ll res = 0;
    for(; r > 0; r -= (r & -r)) res += fw[r];
    return res;
}
void solve() {
    cin >> n >> q;
    for(int i = 1; i <= n; ++i) {
        ll x;
        cin >> x;
        upd(i, x);
    }
    while(q--) {
        int t, p, x;
        cin >> t >> p >> x;
        if(!t) upd(p + 1, x);
        else cout << sum(x) - sum(p) << '\n';
    }
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    ///cin >> T;
    while(T--) solve(), cout << '\n';
    return 0;
}


Measured memory_bytes: 8252
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;L M(L f){return f?B[f]+M(f^f&-f):0;}L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,Z[d]=1,D(d),Z[f]+=Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;for(D(a=n=0);Z[n];a=H[P[n++]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 38056
def examA():
    L = LI(); L.sort()
    ans = L[0]*L[1]//2
    print(ans)
    return

def examB():
    def fun(s):
        if s%2==0:
            return s//2
        else:
            return s*3+1
    S = I()
    d = defaultdict(bool)
    d[S] = True; cur = 1
    while(True):
        cur +=1
        S = fun(S)
        if d[S]:
            break
        d[S] = True
    print(cur)
    return

def examC():
    N = I()
    H = LI()
    cur = 0
    ans =0
    for i in range(N):
        if cur<H[i]:
            ans += H[i]-cur
        cur = H[i]
    print(ans)
    return

def examD():
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,ALPHABET, _ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 1e-9
alphabet = [chr(ord('a') + i) for i in range(26)]
ALPHABET = [chr(ord('A') + i) for i in range(26)]

if __name__ == '__main__':
    examC()


Measured memory_bytes: 3536
# -*- coding: utf-8 -*-
from itertools import combinations

def inpl(): return tuple(map(int, input().split()))

N = int(input())
res = 0
exist = True
A = []

for _ in range(N):
    A.append(inpl())

for i, j in combinations(range(N), 2):
    vervose = False

    for k in range(N):
        if A[i][j] > A[i][k] + A[k][j]:
            exist = False
            break
    
    if not exist:
        break
    
    for k in range(N):
        if i == k or j == k:
            pass
        elif A[i][j] == A[i][k] + A[k][j]:
            vervose = True
            break
        
    if not vervose:
        res += A[i][j]
if exist:
    print(res)
else:
    print(-1)

Measured memory_bytes: 46812
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007

long long pow_mod(long long a,int k){
	long long ret = 1;
	while(k){
		if(k & 1){
			ret *= a;
			ret %= MOD;
		}
		a *= a;
		a %= MOD;
		k >>= 1;
	}
	return ret;
}

long long dp[401][401],c[401][401],tb[401][401];
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);

	long long N,C;
	cin >> N >> C;
	vector<long long> A(N),B(N);
	for(int i=0;i<N;i++)
		cin >> A[i];
	for(int i=0;i<N;i++)
		cin >> B[i];

	for(int i=1;i<=400;i++){
		for(int j=0;j<=400;j++){
			tb[i][j] = pow_mod(i,j);
		}
	}
	// c[i][j] := i番目の奴をj乗した奴の累積和
	for(int i=0;i<N;i++){
		for(int j=A[i];j<=B[i];j++){
			for(int k=0;k<=C;k++){
				c[i][k] += tb[j][k]; //pow_mod(j,k);
				c[i][k] %= MOD;
			}
		}
	}

	dp[0][0] = 1;
	for(int i=1;i<=N;i++){
		for(int j=0;j<=C;j++){
			for(int k=0;k<=j;k++){
				dp[i][j] += dp[i-1][k] * c[i-1][j-k];//* pow_mod(A[i-1],j-k);
				dp[i][j] %= MOD;
			}
		}
	}
	cout << dp[N][C] << endl;

	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <map>

using namespace std;

int main() {
  int n,m;
  map<string,int> freq;
  cin >> n;
  //cout << "kimsdgoewq";
  //cout << n << endl;
  //cout << "kimsdgoewq";
  for (int i = 0; i < n; i++) {
    //cout << "--------" << endl;
    string s;
    cin >> s;
    if (freq.count(s) == 0) {
      freq[s] = 0;
    }
    freq[s]++;
  }
  //cout << "===============";
  cin >> m;
  for (int i = 0; i < m; i++) {
    string s;
    cin >> s;
    if (freq.count(s) == 0) {
      freq[s] = 0;
    }
    freq[s]--;
  }
  int max_count = 0;
  for (auto i = freq.begin(); i != freq.end(); i++) {
    if (i->second > max_count) {
      max_count = i->second;
    }
  }
  cout << max_count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    ll N,ans,rs=0;
    cin >> N;
    bool fla = false;
    
    for(ll i = N;;i++){
        if(N == 2){
            ans = 2;
            break;
        }else if(N == 3){
            ans = 3;
            break;
        }
        else{
            for(ll j = 2;j <= i / 2;j++){
                if(i % j == 0 and j != 1)
                    break;
                else if(j >= i /2 and i % j != 0){
                    fla = true;
                    ans = i;
                    break;
                }
            }
        }   
        if(fla)
            break;
    }

    cout << ans << endl;    

}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int mod = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y){x += y; if(x >= mod) x -= mod;}
void sub_self(int &x, int y){x -= y; if(x < 0) x += mod;}
void mul(int &x, int y){x = x * 1LL * y % mod;}


int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	int n;
	cin >> n;
	
	for(int cnt = 1; cnt <= n / 100; ++cnt){
		int rem = n - cnt * 100;
		if(rem >= 0 && rem <= 5 * cnt){
			cout << 1 << endl;
			return 0;
		}
	}

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

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

int main() {
  ll A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  ll ans = C*2*max(X,Y);
  int i = 0;
  while(i<2*max(X,Y)) {
     int x=X-i/2, y=Y-i/2;
     if(x<0) x=0;
     if(y<0) y=0;
     ll sum = C*i+A*x+B*y;
     ans = min(ans, sum);
     i += 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
long long calc(int n, int c1, int c2, int s1, int s2, const vector<int>& options,
               int d, int nt, int ot) {
  int b1(d-1), a1(d+1), b2(d-1), a2(d+1);
  while (b1 >= 0 && options[b1] != nt) b1--;
  while (b2 >= 0 && options[b2] != ot) b2--;
  while (a1 < n && options[a1] != nt) a1++;
  while (a2 < n && options[a2] != ot) a2++;
  int x1(d-b1-1), y1(a1-d-1), z1(a1-b1-1), x2(d-b2-1), y2(a2-d-1), z2(a2-b2-1);
  int diff1 = z1*(z1+1)/2-x1*(x1+1)/2-y1*(y1+1)/2;
  int diff2 = z2*(z2+1)/2-x2*(x2+1)/2-y2*(y2+1)/2;
  return (long long) diff1 * c1 - (long long) diff2 * c2 + s1 - s2;
}
bool check(int diff, int time) {
  if (diff < 0) return true;
  return rand() >= diff * (clock()-time)*1.4;
}
int main() {
  int n;
  cin >> n;
  vector<int> c(26), last(26, -1);
  vector<array<int, 26>> s(n);
  
  for (int i = 0; i < 26; ++i) cin >> c[i];
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 26; ++j)
      cin >> s[i][j];
  
  long long total(0);
  vector<int> options(n);
  
  for (int i = 0; i < n; ++i) {
    int neg(0), test(-1), max_score(-1e9);
    for (int j = 0; j < 26; ++j) neg -= c[j] * (i - last[j]);
    for (int j = 0; j < 26; ++j) {
      int ss = s[i][j] + neg + c[j] * (i - last[j]);
      if (ss > max_score) {
        max_score = ss;
        test = j;
      }
    }
    total += max_score;
    options[i] = test;
    last[test] = i;
  }
  //cout << total << endl;
  // stochastic
  time_t time = clock();
  while ((clock()-time)<=1.6*CLOCKS_PER_SEC) {
    if (rand() & 1) {
      int dd = rand() % n;
      int tt = rand() % 26;
      int ot = options[dd];
      while (ot == tt) tt = rand() % 26;
      options[dd] = tt;
      long long ns = calc(n, c[tt], c[ot], s[dd][tt], s[dd][ot],
                          options, dd, tt, ot);
      if (!check(-ns,time)) {
        options[dd] = ot;
      } else {
        //options[dd] = tt;
        total += ns;
      }
    } else {
      //continue;
      int dd1 = rand() % n;
      //int tt1 = rand() % 26;
      int ot1 = options[dd1];
      int dd2 = rand() % n;
      //int tt2 = rand() % 26;
      int ot2 = options[dd2];
      options[dd1] = ot2;
      long long ns1 = calc(n, c[ot2], c[ot1], s[dd1][ot2], s[dd1][ot1],
                          options, dd1, ot2, ot1);
      options[dd2] = ot1;
      long long ns2 = calc(n, c[ot1], c[ot2], s[dd2][ot1], s[dd2][ot2],
                          options, dd2, ot1, ot2);
      if (!check(-ns1-ns2,time)) {
        options[dd1] = ot1;
        options[dd2] = ot2;
      } else {
        total += ns1 + ns2;
      }
    }
  }
  
  for (const int& i: options) cout << i + 1 << endl;
  //cout << total << endl;
  return 0;
}

Measured memory_bytes: 3652
#include <cstdio>
 
int main()
{
  char N[5];
  scanf("%s", &N);
  if(N[0]==N[1]&&N[1]==N[2]) {
    puts("Yes");
  }else if(N[1]==N[2]&&N[2]==N[3]) {
    puts("Yes");
  }else{
    puts("No");
  }
}

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

int main(){
	int a, b;
	cin >> a >> b;
	if(a <= b){
		rep(i, b) cout << a;
	}else{
		rep(i, a) cout << b;
	}
	cout << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main (){
int W,a,b;
int c=0;
scanf("%d %d %d", &W, &a, &b);
if(b>=a){
if (a+W>=b) printf("%d\n",c);
if (a+W<b) {
c=b-a-W;
printf("%d\n",c);
}
}
if(a>b){
if (b+W>=a) printf("%d\n",c);
if (b+W<a) {
c=a-b-W;
printf("%d\n",c);
}
}
return 0;
}

Measured memory_bytes: 128
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String T = sc.next();
		for(int i = 0; i < N; i++) {
			System.out.print(S.charAt(i));
			System.out.print(T.charAt(i));
		}
		System.out.println();

	}

}


Measured memory_bytes: 21716
#include<stdio.h>
#include<iostream>
#include<vector>
using namespace std;
int main() {
	int A, B;
	cin >> A >> B;
	if (A >= 13)
		cout << B;
	else if (A > 5)
		cout << B / 2;
	else
		cout << 0;
	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]

# n, m = 3, 2
# a = [[1, 2], [2, 3]]

pot_starts = []
pot_ends = []

for i in a:
    if i[0] == 1:
        pot_starts.append(i[1])
    elif i[1] == n:
        pot_ends.append(i[0])

if set(pot_starts).intersection(pot_ends):
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

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

int main()
{
    cin >> s; 
    if (s[0] == 'S')
        if (s[1] == 'U')
        	cout << 7; 
        else
        	cout << 1; 
    if (s[0] == 'F')
        cout << 2; 
    if (s[0] == 'T')
        if (s[1] == 'H')
        	cout << 3; 
        else
        	cout << 5; 
    if (s[0] == 'W')
        cout << 4; 
    if (s[0] == 'M')
        cout << 6; 
    return 0; 
}

Measured memory_bytes: 888
//FIRST THINK THEN CODE.

#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
//#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define FOR(i,n)  for(ll i=0;i<n;i++)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define d1(x) cout<<(x)<<endl
#define d2(x,y) cout<<(x)<<" "<<(y)<<endl
#define d3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define d4(a,b,c,d) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "<<(d)<<endl
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define rev(p) reverse(p.begin(),p.end());
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define popcount(x) __builtin_popcountll(x)
#define sz(x) ((ll)x.size())
const ll M=1000000007;
const ll MM=998244353;
ll begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";

 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  if(a<=0)return 0;
  a%=m;
  if(!b)return 1;
  ll ans=1LL;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}


 
ll poww(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;

}

template<typename T,typename F>
void chmax( T &a,F b){
  if(b>a)a=b;
}

template<typename T,typename F>
void chmin( T &a,F b){
  if(b<a)a=b;
}



const ll N=2e5+5;




int main()
{ 

IOS;

ll n;cin>>n;

map<string,ll>m;

ll ans=0;

for(int i=1;i<=n;i++){
  string s;cin>>s;
  sort(all(s));
  ans+=m[s];
  m[s]++;
}

cout<<ans;


//end_routine();

return 0;
 
 }

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

def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x, 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] += 1

cnt = 0
for i in range(M):
    par = list(range(N + 1))
    rank = [0] * (N + 1)
    for j, (u, v) in enumerate(X):
        if i == j:
            continue
        unite(u, v)
    
    res = True
    for j in range(1, N + 1):
        for k in range(1, N + 1):
            res &= find(j) == find(k)

    cnt += int(not res)
        
print(cnt)


Measured memory_bytes: 48112