akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <numeric>
#include <vector>

class UnionFind {
public:
    std::vector<int> par, num;

    explicit UnionFind(int N) : par(N), num(N, 1) {
        std::iota(par.begin(), par.end(), 0);
    }

    int find(int v) {
        return (par[v] == v) ? v : (par[v] = find(par[v]));
    }

    void unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return;

        if (num[u] < num[v]) std::swap(u, v);
        num[u] += num[v];
        par[v] = u;
    }

    bool same(int u, int v) { return find(u) == find(v); }
    bool ispar(int v) { return v == find(v); }
    int size(int v) { return num[find(v)]; }
};

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

    int N, Q;
    std::cin >> N >> Q;
    UnionFind uf(N);
    for (int q = 0; q < Q; ++q) {
        int t, u, v;
        std::cin >> t >> u >> v;
        if (t == 0) {
            uf.unite(u, v);
        } else {
            std::cout << uf.same(u, v) << "\n";
        }
    }
    return 0;
}


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

using namespace std;

typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int main(){
    int a,b,out;
    cin>>a>>b;
    out=3;
    if(a==out||b==out)out=1;
    if(a==out||b==out)out=2;
    cout<<out<<endl;
    return 0;
}




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

int main() {
    vector<int> num = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;

    cin >> k;
    cout << num[k-1] << endl; 

    return 0;
}



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

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

	

	for(int i =0;i<s.length();i++){
		s[i] = char((s[i] - 'A' + n) % 26 + 65);
	}

	cout<<s;

	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    import numpy as np

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

    X_arr = np.array(X)
    mean = X_arr.mean()

    x1 = int(mean)
    x2 = int(mean)+1

    v1 = np.sum((X_arr-x1)**2)
    v2 = np.sum((X_arr-x2)**2)
    print(min(v1, v2))


if __name__ == "__main__":
    main()


Measured memory_bytes: 20888
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>

using namespace std;
int n;
int a[100000];
int cnt[100003];
int tmp ,ans = 0;

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

	for (int i = 0; i < 100002; i++) {
		tmp = cnt[i] + cnt[i + 1] + cnt[i + 2];
		ans = max(ans, tmp);
	}

	cout << ans << endl;



	return(0);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define mo 998244353
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
long long len,n,m,f[10005][5005],i,j,jc[10005],ny[10005],ans;
long long ksm(long long u,long long v){
	long long o=1;
	while(v){
		if(v&1)
			o=o*u%mo;
		u=u*u%mo;
		v>>=1;
	}
	return o;
}
long long C(long long u,long long v){
	return jc[u]*ny[v]%mo*ny[u-v]%mo;
}
char s[10005],c[10005];
int main(){
	scanf("%s%s",s+1,c+1);
	len=strlen(s+1);
	for(i=1;i<=len;i++)
		if(s[i]=='1'&&c[i]=='1')
			n++;
		else if(s[i]=='1'&&c[i]=='0')
			m++;
	jc[0]=1;
	for(i=1;i<=n+m;i++)
		jc[i]=jc[i-1]*i%mo;
	ny[n+m]=ksm(jc[n+m],mo-2);
	for(i=n+m-1;i>=0;i--)
		ny[i]=ny[i+1]*(i+1)%mo;
	f[0][0]=1;
	for(i=0;i<=n;i++)
		for(j=0;j<=m;j++){
			if(j!=0)
				f[i][j]=(f[i][j]+f[i][j-1]*j*j)%mo;
			if(i!=0)
				f[i][j]=(f[i][j]+f[i-1][j]*i*j)%mo;
		}
	for(i=0;i<=n;i++)
		ans=(ans+C(n,i)*jc[i]%mo*jc[i]%mo*C(n+m,i)%mo*f[n-i][m])%mo;
	pus(ans,2);
	return 0;
}

Measured memory_bytes: 389760
n = int(input())

def solve(n):
    if n == 0:
        print(0)
        return
    ans = ''
    while n != 0:
        if n%2 == 1:
            ans = '1'+ans
            n = int((n-1)/(-2))
        else:
            ans  = '0'+ans
            n = int(n/(-2))
    print(ans)
    return
        
solve(n)


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

s = list(input())

ans = 'Yes'
for i in range(len(s)):
    if i == a:
        if s[i] != '-':
            ans = "No"
            break
    else:
        if s[i] not in "0123456789":
            ans = "No"
            break

print(ans)

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

int main() {
  string s, t;
  cin >> s >> t;
  int n = sz(s), m = sz(t);

  vector<vector<int>> is(26); // アルファベット分のvectorを用意
  rep(i, n) is[s[i]-'a'].push_back(i); // "-'a'"で、abc...を数字に変換
  rep(i, n) is[s[i]-'a'].push_back(i+n);

  ll ans = 0;
  int p = 0; // 今の場所
  rep(i, m) {
    int c = t[i] - 'a'; // 今の文字のID

    // 該当文字が一度も現れない場合はその時点でreturnする
    if (sz(is[c]) == 0) {
      puts("-1");
      return 0;
    }

    p = *lower_bound(is[c].begin(), is[c].end(), p) + 1;
    if(p >= n) {
      p -= n;
      ans += n;
    }
  }
  ans += p;
  cout << ans << endl;

  return 0;
}


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

int main() {
  string S;
  cin >> S;
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

int n,m,l,cnt,mx,my;
char a[1009][1009];
int vis[1009][1009];
pair<int,int> p[10],st;
int mov[4][2] = {1,0,0,-1,-1,0,0,1};
struct status
{
    int x,y;
    int ord;
    int fx;
    status(int a=0,int b=0,int c=0,int s=0)
    {
        x = a, y = b, ord = c, fx = s;
    }
    bool operator < (struct status t) const
    {
        if(ord != t.ord) return ord > t.ord;
        else return fx > t.fx;
    }
}tt[4];

void bfs(int x,int y,int color)
{
    queue <struct status> q;
    struct status temp(x,y,0,fabs(x-p[color].first) + fabs(y - p[color].second));
    q.push(temp);
    int flag = 0;
    while(!q.empty())
    {
        struct status nw = q.front();
        q.pop();
        if(nw.x == p[color].first && nw.y == p[color].second)
        {
            cnt += nw.ord;
            break;
        }
        vis[nw.x][nw.y] = 1;
        int cct = 0;
        for(int i=0;i<4;i++)
        {
            int tx = mov[i][0] + nw.x, ty = nw.y + mov[i][1];
            if(tx>=0 && tx< n && ty>=0 && ty< m && !vis[tx][ty] && a[tx][ty] != 'X')
            {
                struct status tmp(tx,ty,nw.ord+1,fabs(tx-p[color].first) + fabs(ty - p[color].second));
                tt[cct++] = tmp;
                vis[tx][ty] = 1;
            }
        }
        sort(tt,tt+cct);
        for(int i=0;i<cct;i++) q.push(tt[i]);
    }
}

int main()
{
    while(~scanf("%d%d%d",&n,&m,&l))
    {
        getchar();
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                scanf("%c",&a[i][j]);
                if(a[i][j]>='0' && a[i][j]<='9')
                    p[a[i][j]-'0'].first = i, p[a[i][j]-'0'].second = j;
                if(a[i][j] == 'S') st.first = i, st.second = j;
            }
            getchar();
        }

        int sx = st.first, sy = st.second;
        cnt = 0;
        for(int i=1;i<=l;i++)
        {
            memset(vis,0,sizeof(vis));
            bfs(sx,sy,i);
            sx = p[i].first, sy = p[i].second;
        }
        printf("%d\n",cnt);
    }
    return 0;
}

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
const double PI = acos(-1.0);

void header() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

ll a[maxn], b[maxn];

void solve() {
    ll n, res = 0;
    cin >> n;
    map<ll, ll> mp;
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
        b[i] = a[i] - i;
    }
    
    for (int i = n; i >= 1; i--) mp[-(a[i] + i)]++;

    for (int i = 1; i<= n; i++) res += mp[b[i]];

    cout << res << endl;
}

int main() {
	header();
	solve();
	return 0;
}

Measured memory_bytes: 29444
import java.util.*;

public class Main {
    public static void main (String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int y = sc.nextInt();
        int z = sc.nextInt();
        int cnt = 0;

        x -= 2 * z;
        while (x > 0) {
            x -= y;
            if (x < 0) break;
            cnt++;
            x -= z;
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef vector<PP> V;

class Ant {
    public:
        char d;
        int p;
};

P compute(int n, int l, Ant ants[]) {
    int index[20];
    P residual_time[20];
    V exchanges;
    for (int i=0; i<n; i++) {
        index[i] = i;
        if (ants[i].d == 'R') {
            residual_time[i] = P(l-ants[i].p, i);
        }
        else {
            residual_time[i] = P(ants[i].p, i);
        }
    }
    sort(residual_time, residual_time+n);
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            int delta = ants[j].p-ants[i].p;
            if (ants[i].d != 'R' || ants[j].d != 'L') {
                continue;
            }
            if (delta%2 == 1) {
                continue;
            }
            exchanges.push_back(PP(delta, P(i, j)));
        }
    }
    sort(exchanges.begin(), exchanges.end());
    for (int k=0; k<(int)exchanges.size(); k++) {
        int i = exchanges[k].second.first;
        int j = exchanges[k].second.second;
        int tmp = index[i];
        index[i] = index[j];
        index[j] = tmp;
    }
    if (n > 1 && residual_time[n-1].first == residual_time[n-2].first) {
        if (ants[residual_time[n-1].second].d == 'R') {
            return P(residual_time[n-2].first, index[residual_time[n-2].second]);
        }
    }
    return P(residual_time[n-1].first, index[residual_time[n-1].second]);
}

int main() {
    int n, l;
    Ant ants[20];
    P answer;
    while (true) {
        cin >> n >> l;
        if (n == 0) {
            return 0;
        }
        for (int i=0; i<n; i++) {
            cin >> ants[i].d >> ants[i].p;
        }
        answer = compute(n, l, ants);
        cout << answer.first << ' ' << answer.second+1 << endl;
    }
}

Measured memory_bytes: 1200
//---------- Begin IO utilities ----------
// Thanks to https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:tt : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! p {
    ($v:ident) => {
        println!("{}", $v);
    };
    ($v:ident, $($t:ident),*) => {
        print!("{}", $v);
        ($(print!(" {}", $t)),*);
        println!();
    }
}
#[allow(unused_macros)]
macro_rules! ps {
    ($v:ident) => {
        println!("{}", $v.iter().collect::<String>());
    };
    ($v:ident, $($t:ident),*) => {
        print!("{}", $v.iter().collect::<String>());
        ($(print!(" {}", $t.iter().collect::<String>())),*);
        println!();
    }
}
#[allow(dead_code)]
fn pv<T: std::string::ToString>(v: &[T], sep: &str) {
    let s = v.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep);
    println!("{}", s);
}
#[allow(dead_code)]
fn pvs(v: &[Vec<char>], sep:&str) {
    let s = v.iter().map(|e| e.iter().collect::<String>()).collect::<Vec<String>>().join(sep);
    println!("{}", s);
}
//---------- End IO utilities ----------

fn main() {
    input!{
        s: usize,
        w: usize,
    }
    if s <= w {
        println!("unsafe");
    } else {
        println!("safe");
    }
}


Measured memory_bytes: 2120
N,*A = $<.read.split.map(&:to_i)
B = [0]*(N+1)
A.each{|a|
  B[a] += 1
}
C = B.inject(0){|c,b|
  c + b*(b-1)/2
}
A.each{|a|
  b = B[a]
  p C+1-b
}

Measured memory_bytes: 31996
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int A1 = sc.nextInt();
		int A2 = sc.nextInt();
		int A3 = sc.nextInt();


		int ans=A1+A2+A3;

		if(ans>=22)
		System.out.println("bust");
		else
			System.out.println("win");



	}
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21076
#include<stdio.h>

int main(void){
  long int n,s,i,j;
  long int a[3001];
  long int x[3001][3001];
  
  scanf("%ld %ld\n",&n,&s);
  for(i=1;i<=n;i++){
    scanf("%ld ",&a[i]);
  }
  
  for(j=1;j<=s;j++){
    x[1][j]=0;
  }
  x[1][a[1]]=1;
  
  for(i=2;i<=n;i++){
    for(j=1;j<=s;j++){
      if(j<a[i]){
        x[i][j]=x[i-1][j];
      }else if(j==a[i]){
        x[i][j]=(x[i-1][j]+i)%998244353;
      }else{
        x[i][j]=(x[i-1][j]+x[i-1][j-a[i]])%998244353;
      }
    }
  }
  
  x[0][s]=0;
  long int m=0;
  for(i=0;i<=n-1;i++){
    m=(m+(x[i+1][s]-x[i][s])*(n-i))%998244353;
  }
  
  if(m<0){
    m=m+998244353;
  }
  printf("%ld",m);
  
  return 0;
}

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


int main(){
    int n, k;
    cin >> n >> k;
    ll a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    vector<ll> v;
    for(int i = 0; i < n; i++){
        ll sum = 0;
        for(int j = i; j < n; j++){
            sum += a[j];
            v.push_back(sum);
        }
    }
    ll x = 0;
    for(int m = 40; m >= 0; m--){
        ll t = x + (1LL << m);
        int cnt = 0;
        for(int i = 0; i < v.size(); i++){
            if((t & v[i]) == t) cnt++;
        }
        if(cnt >= k) x += 1LL << m;
    }
    cout << x << endl;
    return 0;
}

Measured memory_bytes: 6384
N = int(input())
A = [int(a) for a in input().split()]

Mcashe = 1000
Mkabu = 0

for i in range(len(A) - 1):
    Mcashe += (Mkabu * A[i])
    Mkabu = 0
    if A[i] < A[i+1]:
        Mkabu = Mcashe // A[i]
        Mcashe = Mcashe % A[i] 

Mcashe += (Mkabu * A[-1])
print(Mcashe)


Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define Endl '\n'
typedef long long int lli;
typedef pair<int, int> ii;
void solve();
int main(int argc, char const *argv[]){
   ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}
void solve(){
  lli N, K;
  cin>>N>>K;
  N%=K;
  lli ans = min(N, abs(N-K));
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin() , v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)


int main(){
    string s; cin >> s;
    cout << s.substr(0, s.length() - 8) << endl;
}

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

int main() {
  long a1,a2,a3;
  cin >> a1 >>a2 >> a3;
  long sum = a1+a2+a3;
  string ans;
  if(sum>21){
    ans = "bust";
  }else{
   ans = "win" ;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n;
    cin >> n;

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

    ll r = 0;
    map<int, int> mp;

    for (int i = n - 1; i >= 0; i--) {
        r += mp[-a[i] - i];
        mp[a[i] - i]++;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 21096
#include <stdio.h>
int main(void){
    int H,W,i,j;
    for( ;scanf("%d %d",&H,&W)!=EOF; ){
        if(H==0 && W==0){
            break;
        }
    for(i=1;i<=H;i++){
        for(j=1;j<=W;j++){
            if((i+j)%2==0){
                printf("#");
            }
            else{
                printf(".");
            }
        }
    printf("\n");
    }
    printf("\n");
    }
return 0;
}



Measured memory_bytes: 2072
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  cin >> A >> B;
  int ans = 0;
  
  for (int i = A; i <= B; i++){
    vector<int> dig(5);
    int tempi = i;
    for (int j=0; j<5; j++){
      dig.at(j) = tempi%10;
      tempi /= 10;
    }
    if(dig.at(0) == dig.at(4) && dig.at(1) == dig.at(3)) ans++;
  }
  cout << ans << endl; 
  
} 


Measured memory_bytes: 3592
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	double mx,mn,mou;
	cin>>mou;
	mx=mou;mn=mou;
	for(;cin>>mou;){
		if(mx<mou)mx=mou;
		if(mn>mou)mn=mou;
	}
	cout<<mx-mn<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >=0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
 
typedef long long ll;
#define INF 1e9
 
int main(){
  int N;
  cin >> N;
  vector<int> t(N), x(N), y(N);
  int ct, cx, cy, dt, dx, dy;
  ct = cx = cy = 0;
  REP(i, N){
    cin >> t[i] >> x[i] >> y[i];
    dt = t[i] - ct;
    dx = abs(x[i] - cx);
    dy = abs(y[i] - cy);

    if(dt < dx+dy){
      cout << "No" << endl;
      return 0;
    }
    else{
      dt -= dx+dy;
      if(dt % 2 == 1){
        cout << "No" << endl;
        return 0;
      }
      ct = t[i];
      cx = x[i];
      cy = y[i];
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <cstdio>

bool b[26];

int main()
{
  char s[100001];
  scanf("%s", s);
  for (char *p = s; *p; ++p)
  {
    b[*p - 'a'] = true;
  }
  for (int i = 0; i < 26; ++i)
  {
    if (b[i] == false)
    {
      printf("%c\n", i + 'a');
      return 0;
    }
  }
  puts("None");
  return 0;
}

Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
half=int(N/2)
ans=[-1]*N

for i in range(half, N):
    ans[i]=a[i]
for i in range(half-1, -1, -1):
    s=0
    j=i+(i+1)
    while j<N:
        s^=ans[j]
        j+=(i+1)
    ans[i]=s^a[i]

print(sum(ans))
for i,a in enumerate(ans):
    if a==1:
        print(i+1)


Measured memory_bytes: 7148
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		String kye=sc.next();
		int sche[][]=new int[7][n];
		int v=10007;
		int patt=0;
		
		if(kye.charAt(0)=='J'){
			sche[0][0]=sche[3][0]=sche[4][0]=sche[6][0]=1;
		}
		else if(kye.charAt(0)=='O'){
			sche[3][0]=sche[6][0]=1;
		}
		else if(kye.charAt(0)=='I'){
			sche[4][0]=sche[6][0]=1;
		}//おk
		for(int i=1;i<kye.length();i++){
			if(kye.charAt(i)=='J'){
				sche[0][i]=(sche[0][i-1]+sche[3][i-1]+sche[4][i-1]+sche[6][i-1])%v;
			}
			if(kye.charAt(i)=='O'){
				sche[1][i]=(sche[1][i-1]+sche[3][i-1]+sche[5][i-1]+sche[6][i-1])%v;
			}
			if(kye.charAt(i)=='I'){
				sche[2][i]=(sche[2][i-1]+sche[4][i-1]+sche[5][i-1]+sche[6][i-1])%v;
			}
			if(kye.charAt(i)=='J' || kye.charAt(i)=='O'){
				sche[3][i]=(sche[0][i-1]+sche[1][i-1]+sche[3][i-1]+sche[4][i-1]+sche[5][i-1]+sche[6][i-1])%v;
			}
			if(kye.charAt(i)=='J' || kye.charAt(i)=='I'){
				sche[4][i]=(sche[0][i-1]+sche[2][i-1]+sche[3][i-1]+sche[4][i-1]+sche[5][i-1]+sche[6][i-1])%v;
			}
			if(kye.charAt(i)=='O' || kye.charAt(i)=='I'){
				sche[5][i]=(sche[1][i-1]+sche[2][i-1]+sche[3][i-1]+sche[4][i-1]+sche[5][i-1]+sche[6][i-1])%v;
			}
			if(kye.charAt(i)=='J' || kye.charAt(i)=='O' ||kye.charAt(i)=='I'){
			sche[6][i]=(sche[0][i-1]+sche[1][i-1]+sche[2][i-1]+sche[3][i-1]+sche[4][i-1]+sche[5][i-1]+sche[6][i-1])%v;
			}
		}
		for(int j=0;j<7;j++){
			patt=patt%v+sche[j][n-1]%v;
		}
		System.out.println(patt%v);
	}

}

Measured memory_bytes: 18216
import numpy as np
import sys
#import copy


def xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example:
        input   1
        retrun  1

        input   1 2 3
        return  [1,2,3]
        input   1 2 3
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        temp = list(map(int, input().split()))
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        temp = [list(map(int, input().split())) for _ in range(n)]
        return temp


def sp_xnxn(n=0):
    """
    args:
        int n: a number of lows to read
    example
        input   1
        retrun  [1]

        input   123
        return  [1,2,3]

        input   123
                4 
        return  [[1,2,3],
                [4]]
    """
    if n == 0:
        return [int(k) for k in xsxs()]
    else:
        return [[int(k) for k in xsxs()] for _ in range(n)]


def xsxs(n=0):
    """
    args:
        int n: a number of lows to read 
    example:
        input   AA
        retrun  AA

        input   A BBB CC
        return  ["A","BBB","CC"]

        input   A BB CCC
                D
        return  [["A","BBB","CC"],
                ["D"]]
    """
    if n == 0:
        temp = list(input().split())
        if len(temp) == 1:
            return temp[0]
        elif len(temp) > 1:
            return temp
    else:
        return [list(input().split()) for _ in range(n)]


def sp_xsxs(n=0):
    """
    args:
        int n: a number of lows to read 
        example:
            input   A
            retrun  ["A"]

            input   ABC
            return  ["A","B","C"]

            input   ABC
                    D
            return  [["A","B","C"],
                    ["D"]]
    """
    if n == 0:
        return [s for s in xsxs()]
    else:
        return [[s for s in xsxs()] for _ in range(n)]


a, b = xnxn()
print(a*b)


Measured memory_bytes: 27096
import java.util.*;
import java.util.stream.Collectors;

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

        List<Integer> intList = new ArrayList<>();
        for (int i = 0; i < count; i++) {
            intList.add(sc.nextInt());
        }

        List<Integer> filteredList = intList.stream().filter(e -> e % 2 == 0).collect(Collectors.toList());

        int resultCount = (int)filteredList.stream().filter(e -> (e % 3 == 0) || (e % 5 == 0)).count();

        System.out.println(resultCount == filteredList.size() ? "APPROVED": "DENIED");
    }
}


Measured memory_bytes: 28756
#include<stdio.h>

int main() {
	
	int a, b;
	char s[11];
	int i;
	int suitti=0;

	scanf("%d%d%s",&a,&b,s);

	if (s[a] == '-') {
		for (i = 0; i < a; i++) {
			if (s[i] == '-') suitti++;
		}
		for (i = a + 1; i < a + b+1; i++) {
			if (s[i] == '-') suitti++;
		}

		if (suitti > 0) printf("No");
		else printf("Yes");

	
	}
	else printf("No");

	return 0;
}

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

int main() {
  int n,k,r,s,p;
  ll ans = 0;
  string t;
  cin >> n >> k >> r >> s >> p >> t;
  rep(i,k){
    if(t[i] == 'r') ans += p;
    if(t[i] == 's') ans += r;
    if(t[i] == 'p') ans += s;
  }
  for(int i = k;i < n;i++){
    if(t[i-k] == t[i]){
      t[i] = 'l';
      continue;
    }
    if(t[i] == 'r') ans += p;
    if(t[i] == 's') ans += r;
    if(t[i] == 'p') ans += s;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
n,y = map(int,input().split())

for i in range(n+1):
    for j in range(n+1):
        k = n-(i+j) #1000円の枚数
        sum = 10000 * i + 5000 * j
        if k >= 0 and (sum + 1000*k) == y:
            print(i,j,k)
            quit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

//素因数分解する
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  //引数にretを入れてn回使う時用
  if (n != 1 && ret.find(n) == ret.end())
    ret[n] = 1;
  else if (n != 1)
    ret[n] += 1;
  return ret;
}
ll GCD(ll a, ll b) {
  if (b == 0)
    return a;
  return GCD(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll A, B;
  cin >> A >> B;
  ll C = GCD(A, B);
  if (C == 1) {
    cout << 1 << endl;
    return 0;
  }
  auto P = prime_factor(C);
  ll ans = 1;
  cout << P.size() + 1 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(long long N, std::vector<long long> A){
    vl cnt(N+1);
    rep(i,N)cnt[A[i]]++;

    ll sum=0;
    rep(i,N+1)sum+=cnt[i]*(cnt[i]-1)/2;

    rep(i,N){
        ll ans=sum;
        ans-=cnt[A[i]]*(cnt[A[i]]-1)/2;
        ans+=(cnt[A[i]]-1)*(cnt[A[i]]-2)/2;
        cout<<ans<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define vi   vector<int>
#define vvi  vector<vi >
#define vvvi vector<vvi >
#define pii  pair<int,int>
#define INF  (int)1e9
#define MOD  (int)1e9+7
typedef long long llong;
using namespace std;

int main(){
	int n;
	cin>>n;
	
	vi a(n+1);
	vi b(n+1);
	a[0]=-1;
	b[0]=-1;
	int st=n/2;
	int m=0;
	
	for(int i=1;i<=n;++i){
		cin>>a[i];
		if(i>st){
			b[i]=a[i];
			if(a[i]) m++;
		}
	}
	
	for(int i=st;i>=1;--i){
		int sum=0;
		for(int j=2*i;j<=n;j+=i){
			sum+=b[j];
		}
		if(sum%2){
			if(a[i]) b[i]=0;
			else{
				b[i]=1;
				m++;
			}
		}else{
			if(a[i]){
				b[i]=1;
				m++;
			}else b[i]=0;
		}
	}
	
	cout<<m<<endl;
	for(int i=1;i<=n;++i){
		if(b[i]) cout<<i<<endl;
	}
}

Measured memory_bytes: 2432
n=int(input())
s=[int(input()) for _ in range(n)]
x=sum(s)
if x%10!=0:
    print(x)
else:
    l=[]
    for i in s:
        if i%10!=0:
            l.append(i)
    if l:
        print(max(x-min(l),0))        
    else:
        print(0)


Measured memory_bytes: 38384
n = int(input())
a = list(map(int, input().split()))

b = [(a[i]-i-1) for i in range(n)]
b = sorted(b)

if n % 2 == 1:
  res = b[(n-1)//2]
else:
  res = (b[n//2-1] + b[n//2])//2
  
print(sum(map(abs, [b[i]-res for i in range(n)])))

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

#include <atcoder/all>
typedef long long ll;
#define rep(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (ll i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (ll i = ((ll)(n)-1); i >= 0; --i)
#define rreps(i, n) for (ll i = ((ll)(n)); i > 0; --i)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define repc2(i, s, n) for (ll i = (s); i <= (ll)(n); i++)
#define inf 2e9
#define linf 9000000000000000000ll
#define all(v) v.begin(), v.end()
using namespace std;
using namespace atcoder;

int t;

int main() {
    cin >> t;
    rep(i, t) {
        ll n, m, a, b;
        scanf("%lld%lld%lld%lld", &n, &m, &a, &b);
        printf("%lld\n", floor_sum(n, m, a, b));
    }
    return 0;
}

Measured memory_bytes: 3820
#include<bits/stdc++.h>
using namespace std;
#define lop(i,n) for(ll i=0;i<n;i++)
#define lop1(i,n) for(ll i=1;i<=n;i++)
#define lopr(i,n) for(ll i=n-1;i>=0;i--)
#define ll long long int
#define pb push_back
#define all(v) v.begin(),v.end()
#define IOS  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define endl "\n"
#define F first
#define S second	
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define pii pair<int,int>
#define pll pair<ll,ll>
#define LCM(a,b) (a*b)/__gcd(a,b)
#define mii map<int,int>
#define mll map<ll,ll>
#define ub upper_bound
#define lb lower_bound
#define sz(x) (ll)x.size()
#define ld long double
#define pcnt(x) __builtin_popcountll(x)
const long long I1=1e9;
const long long I2=1e18;
const int32_t M1=1e9+7;
const int32_t M2=998244353;
template<typename T,typename T1>T maxn(T &a,T1 b){if(b>a)a=b;return a;}
template<typename T,typename T1>T minn(T &a,T1 b){if(b<a)a=b;return a;}
ll dp[100001][101];
pll w[101];
void solve()
{
  //code begins from here//
  int n,k;
  cin>>n>>k;
  lop1(i,n) cin>>w[i].F>>w[i].S;
  sort(w+1,w+n+1);
  lop(i,101) dp[0][i]=0;
  lop1(i,k)
  {
      lop1(j,n)
      {
        if(i-w[j].F>=0 ) maxn(dp[i][j],dp[i-w[j].F][j-1]+w[j].S);
        maxn(dp[i][j],dp[i][j-1]);
      }
      //cout<<endl;
  }
  ll ans=0;
  lop1(i,k) maxn(ans,dp[i][n]);
  cout<<ans<<endl;
}

signed main()
{
    IOS;
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #ifdef MODULO
        initialize();
    #endif
    #ifdef SIEVE
        sieve();
    #endif
    int testcase=1;
   // cin>>testcase;
    while(testcase--) solve();
    return 0;
}


Measured memory_bytes: 82332
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    int ans = 0;
    for (; ans <= 32; ans++){
        if ((a&1)||(b&1)||(c&1)) break;
        a >>= 1; b >>= 1; c >>= 1;
        int x = a+b+c;
        a = x-a;
        b = x-b;
        c = x-c;
    }
    printf("%d ",ans==33?-1:ans);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
  string in;
  cin >> in;
  bool is_bad = false;
  for(int i = 1; i < 4; ++i) {
    if(in[i] == in[i-1]) is_bad = true;
  }
  if(is_bad) cout << "Bad";
  else cout << "Good";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<ll(n); i++)
#define REPR(i, n) for(ll i=n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=m; i<ll(n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
const int INF = 2e9;

int n,k;
vector<int> a;

bool solve(int x)
{
  int cnt = 0;
  REP(i,n){
    if(a[i]>x) cnt += a[i]/x;
  }
  return (cnt<=k);
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n >> k;
  a.resize(n);
  REP(i,n) cin >> a[i];

  int ok = 1e9;
  int ng = 0;
  while((ok-ng)>1){
    double mid = (ok+ng)/2.0;
    if(solve(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
  return 0;
}


Measured memory_bytes: 3888
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

const ll MAX = 5000001;//10^7が限界
const ll MOD = Mod;
//const ll MOD = INT64_MAX;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll 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;
    }
}

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll h,w,a,b;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    cin>>h>>w>>a>>b;
    COMinit();
    ll ans = COM(h+w-2,h-1);
    rep(i,a){
        ll x = b;
        ll y = i+h-a+1;
        ans += Mod - COM(x+y-2,x-1)*COM(h+w-x-y-1,h-y)%Mod;
        ans %= Mod;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 117504
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
      	String s="";
      for(int i=0;i<15;i++){
        if(n==0){break;}
      	long a =n%26;
      	s=s+alphabet(a);
      	if(a!=0)n=n/26;
        else{n=n/26-1;}
      }
      StringBuffer buf = new StringBuffer(s);
      String ans = buf.reverse().toString();
      System.out.println(ans);
    }
  
  public static String alphabet(long i){
  	if(i==1){return("a");}
    if(i==2){return("b");}
    if(i==3){return("c");}
    if(i==4){return("d");}
    if(i==5){return("e");}
    if(i==6){return("f");}
    if(i==7){return("g");}
    if(i==8){return("h");}
    if(i==9){return("i");}
    if(i==10){return("j");}
    if(i==11){return("k");}
    if(i==12){return("l");}
    if(i==13){return("m");}
    if(i==14){return("n");}
    if(i==15){return("o");}
    if(i==16){return("p");}
    if(i==17){return("q");}
    if(i==18){return("r");}
    if(i==19){return("s");}
    if(i==20){return("t");}
    if(i==21){return("u");}
    if(i==22){return("v");}
    if(i==23){return("w");}
    if(i==24){return("x");}
    if(i==25){return("y");}
    if(i==0){return("z");}
    return("");
  }
  
}

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

int main(){
  string s;
  cin>>s;
  if(s=="Sunny")
    cout<<"Cloudy"<<endl;
  else if(s=="Cloudy")
    cout<<"Rainy"<<endl;
  else 
    cout<<"Sunny"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define mod 1000000007

int main(void){
	int N;
	long long sum=0;
	long long ans=0;
	scanf("%d",&N);

	int A[N];

	for(int i=0;i<N;i++) scanf("%d",&A[i]);
    
	for(int i=0;i<N;i++){
		sum+=A[i];
		sum%=mod;
	}

    for(int i=0;i<N-1;i++){
		sum-=A[i];
		if(sum<0) sum+=mod;

		ans+=A[i]*sum;
		ans%=mod;
	}

	printf("%lld\n",ans);


	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
    int h, w; cin >> h >> w;
    vector<vector<char> > a(h, vector<char>(w));
    rep(i, h){
        rep(j, w){
            cin >> a[i][j];
        }
    }

    vector<vector<bool> > b(h, vector<bool>(w));

    rep(i, h){
        bool flag = true;
        rep(j, w){
            if(a[i][j] == '.'){
                continue;
            }else{
                flag = false;
                break;
            }
        }
        if(flag){
            rep(j, w){
                b[i][j] = true;
            }
        }
    }

    rep(i, w){
        bool flag = true;
        rep(j, h){
            if(a[j][i] == '.'){
                continue;
            }else{
                flag = false;
                break;
            }
        }
        if(flag){
            rep(j, h){
                b[j][i] = true;
            }
        }
    }

    rep(i, h){
        int cnt = 0;
        rep(j, w){
            if(b[i][j]){
                cnt++;
                continue;
            }
            cout << a[i][j];
        }
        if(cnt != w) cout << endl;
    }
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
  llong a, b;
  cin >> a >> b;

  cout << a * b << endl;

  return 0;
}

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

using namespace std;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);

    int n;
    cin >> n;
    vector< pair<int, int> > a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int ind = a[i].second;
        if ((i - ind) % 2 != 0) {
            ans++;
        }
    }
    cout << ans / 2 << '\n';
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int v[]=new int[n];
        int c[]=new int[n];
        int ans=0;
        for(int i=0; i<n; i++)
            v[i]=sc.nextInt();
        for(int i=0; i<n; i++){
            c[i]=sc.nextInt();
            if(v[i]>c[i])
                ans+=(v[i]-c[i]);
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21204
module.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=0)}([function(e,t,r){r(1)(r(2).readFileSync("/dev/stdin","UTF-8"))},function(e,t,r){"use strict";function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var r=[],n=!0,i=!1,o=void 0;try{for(var a,u=e[Symbol.iterator]();!(n=(a=u.next()).done)&&(r.push(a.value),!t||r.length!==t);n=!0);}catch(e){i=!0,o=e}finally{try{n||null==u.return||u.return()}finally{if(i)throw o}}return r}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}class i{constructor(){this.size=0,this.head={value:void 0,pre:void 0,next:void 0},this.tail={value:void 0,pre:void 0,next:void 0}}enq(e){this.size+=1;var t={value:e,pre:void 0,next:void 0};this.head.next?(this.tail.pre.next=t,t.pre=this.tail.pre,t.next=this.tail,this.tail.pre=t):(this.head.next=t,this.tail.pre=t,t.pre=this.head,t.next=this.tail)}deq(){if(0!=this.size){this.size-=1;var e=this.head.next.value;return this.head.next=this.head.next.next,this.head.next.pre=this.head,e}}getValuesArray(){for(var e=[],t=this.head.next;t.next;)e.push(t.value),t=t.next;return e}}e.exports=function(e){for(var t=e.split("\n"),r=n(t[0].split(" ").map(function(e){return Number(e)}),2),o=r[0],a=r[1],u=new Array(o),l=0;l<o-1;l++){var s=n(t[l+1].split(" ").map(function(e){return Number(e)-1}),2),f=s[0],d=s[1];u[f]||(u[f]=[]),u[d]||(u[d]=[]),u[f].push(d),u[d].push(f)}for(var c=new Array(o).fill(0),h=0;h<a;h++){var p=n(t[h+o].split(" ").map(function(e){return Number(e)}),2),v=p[0],y=p[1];c[v-1]+=y}var x=new i,b=new Array(o).fill(0);for(x.enq(0);x.size>0;){var m=x.deq();b[m]=1;var g=!0,w=!1,j=void 0;try{for(var S,O=u[m][Symbol.iterator]();!(g=(S=O.next()).done);g=!0){var q=S.value;1!=b[q]&&(c[q]+=c[m],x.enq(q))}}catch(e){w=!0,j=e}finally{try{g||null==O.return||O.return()}finally{if(w)throw j}}}console.log(c.join(" "))}},function(e,t){e.exports=require("fs")}]);

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

int n, k;
int hi[100005];
int dp[100005];

void solve(){
	for (int i = 2; i <= n; i++){
		dp[i] = 0x3f3f3f3f;
		for (int j = i-1; j > max(i-k-1,0); --j){
			dp[i] = min(dp[i], dp[j] + abs(hi[i] - hi[j]));
		}
	}
	cout << dp[n] << '\n';
}
int main(){
	cin >> n >> k;
	for (int i = 1; i <= n; i++)
		cin >> hi[i];
	solve();
	return 0;
}


Measured memory_bytes: 1024