akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    int cnt = 0;
    vector<bool>ok(N+1,false);
    for(int i = 1; i <= N; i++) {
        cnt+=i;
        if(cnt == N) {
            ok[i] = true;
            break;
        }
        else if(cnt > N) {
            ok[i] = true;
            ok[cnt-N] = false;
            break;
        }
        else {
            ok[i] = true;
        }
    }
    for(int i = 1; i <= N; i++) {
        if(ok[i]) {
            cout << i << endl;
        }
    }
}


Measured memory_bytes: 4500
# 最小の移動距離は、一番端から反対側まで一直線に移動する事。
# 行ったり来たりする可能性はない
n = int(input())
a = list(map(int, input().split()))
# 座標は正の整数のみなのでmax-minで計算できそう。
# print(mix-min)
print(max(a)-min(a))

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

int main(){

    int n; cin >> n;
    int i = 0;
    int j = n - 1;
    int num;
    cout << 0 << endl;
    fflush(stdout);
    string s;
    cin >> s;
    if(s == "Male") num = 0;
    else if(s == "Female") num = 1;
    else return 0;

    while(1){
        int idx = i + (j - i) / 2;
        if(j - i == 1) idx++; 
        cout << idx << endl;
        fflush(stdout);
        cin >> s;
        int nextnum;
        if(s == "Male") nextnum = 0;
        else if(s == "Female") nextnum = 1;
        else return 0;

        if(((idx - i) % 2 == 0) && (num == nextnum) || ((idx - i) % 2 == 1) && (num != nextnum)){
            i = idx;
            num = nextnum;
        }else{
            j = idx;
        }

    }
    return 0;
}

Measured memory_bytes: 852
#include <stdio.h>
#include <iostream>
#include <string>
#include <stdlib.h>
#include<cmath>
#include<vector>
#include<map>
#include<algorithm>
#include<numeric>
#include<list>
#include<cmath>
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0])
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)

using namespace std;
typedef long long ll;
//using P = pair<int, int>;


int main(void) {
	int n,l;
	cin >> n;
	vector<ll> vec(n);
	int ans = 0;

	if(n)
	rep(i, n) {
		cin >> l;
		vec[i] = l;

	}
	sort(vec.begin(), vec.end());

	for (ll i = 0; i < n-2; i++) {
		for (ll j = i+1; j < n-1; j++) {
			for (ll k = j+1; k < n;k++) {
				if (vec[i] != vec[j]&& vec[j] != vec[k]&&(vec[i]+vec[j])>vec[k]  ){
					ans++;
				}
			}
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3592
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    ll n;
    cin >> n;
    ll sum = 0;
    ll mx;
    rep(i, n+1){
        sum+=i;
        mx = i;
        if(sum>=n)break;
    }
    rep(i, mx){
        if(i+1==sum-n)continue;
        cout << i+1 << endl;
    }
}

Measured memory_bytes: 256
N = int(input())
A = []

for i in range(N):
    A.append(int(input()))

max_a = max(A)
aa = sorted(A, reverse=True)
second = aa[1]
flag = second == max_a

if second == max_a:
    for i in range(N):
        print(max_a)
else:
    for i in range(N):
        if A[i] == max_a:
            print(second)
        else:
            print(max_a)


Measured memory_bytes: 14112
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define INFI ((ll)1e9)
#define MINI ((ll)-1e9)
using namespace std;
typedef long long ll;       
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }          
int n;
double p[3001];
double dp[3001][3001];
bool dp2[3001][3001];
double solve(int i, int c){
	if(i==n&&c>=(n/2)+1)return 1.0;
	if(i==n)return 0.0;
	if(dp2[i][c])return dp[i][c];
	dp2[i][c]=true;
	dp[i][c]=(1.0-p[i])*solve(i+1,c)+p[i]*solve(i+1,c+1);
	return dp[i][c];
}
int main(){FIN;
	cin >> n;
	fore(i,0,n){
		cin >> p[i];
	}
	memset(dp,-1.0,sizeof(dp));
	cout << setprecision(15) << solve(0,0);
	
	
}

Measured memory_bytes: 79616
#include<stdio.h>
#define rep(i,m,l) for(int i=m ; i < (int)(l) ; i++)

int main(){
  long long int n;
  scanf("%lld",&n);
  long long int sum=0;
  rep(i,1,n+1){
    sum  += n/i*(n/i+1)*i/2;
    //printf("%d %lld\n",i,1/i*(n/i+1)*i/2);
  }
  printf("%lld\n",sum);
}
    


Measured memory_bytes: 1708
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <valarray>
#include <utility>
#include <cctype>
#include <numeric>
#include <memory>
#include <functional>
using namespace std;
#define Debug(x) cerr << #x << " = " << x << endl
#define Debug22(x,y) cerr<<#x<<" = "<<x<<" , "<<#y<<" = "<<y<<endl;
#define Debug2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")\n";
#define Debug3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<")\n";
#define Debug_arr(v,n) for(int i=0;i<n;++i) cerr<<#v<<"["<<i<<"]"<<" = "<<v[i]<<endl;
#define SET(p,v) fill((__typeof(**p)*)p,(__typeof(**p)*)p+sizeof(p),v);
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define prl cerr << "called: " << __LINE__ << endl
//#define FILE_JUDGE
//#define TIMES
//#define LINES
//#define home
int n,dist[2][100005];
vector <int> v[100005];
bool used[100005];
void bfs(int x,int *Dist)
{
	memset(used,0,sizeof(used));
	Dist[x]=0;
	used[x]=true;
	queue <int> q;
	q.push(x);
	while (q.size())
	{
		int cur=q.front();q.pop();
		int d=Dist[cur];
		for (auto &y:v[cur])
		{
			if (!used[y])
			{
				Dist[y]=d+1;
				q.push(y);
				used[y]=true;
			}
		}
	}
}
int main()
{
	#ifdef FILE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	scanf("%d",&n);
	for (int i=1;i<n;++i)
	{
		int x,y;
		scanf("%d%d",&x,&y);
		v[x].push_back(y);
		v[y].push_back(x);
	}
	bfs(1,dist[0]);
	bfs(n,dist[1]);
//	for (int i=1;i<=n;++i) printf("%d%c",dist[0][i]," \n"[i==n]);
//	for (int i=1;i<=n;++i) printf("%d%c",dist[1][i]," \n"[i==n]);
//	puts("");
	int black=0;
	for (int i=2;i<=n-1;++i)
	{
		if (dist[0][i]<=dist[1][i])
		{
			++black;
		}
	}
	int white=n-2-black;
	if (black>white)
	{
		puts("Fennec");
	}
	else
	{
		puts("Snuke");
	}
	#ifdef TIMES
	eprintf("Times = %d ms.\n",clock());
	#endif
	#ifdef LINES
	eprintf("lines : %d line.\n",__LINE__+3);
	#endif
	return 0;
}


Measured memory_bytes: 6784
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int p = Integer.parseInt(sc.next());
		
		int []a = new int [n];
		
		for(int i = 0 ;i < n ;i++) {
			a[i] = Integer.parseInt(sc.next());
		}
		long ans = 0;
		
		for(int k = 0 ; k <= p ; k++) {
			for(int l = 0 ; l <= p ; l++) {
				if(k + l > Math.min(n, p)) {
					break;
				}
				ArrayList <Integer> list = new ArrayList<Integer>();
				long temp1 = 0;
				for(int i = 0 ; i < k ; i++) {
					list.add(a[i]);
				}
				for(int j = 0 ; j < l ; j++) {
					list.add(a[n-j-1]);
				}
				
				Collections.sort(list);
				int r = p - k - l;
				
				for(int i = 0 ;i < r ;i++) {
					if(list.size() > 0) {
						if(list.get(0) < 0) {
						list.remove(0);
					}
				}
			}
				for(int num : list) {
					temp1 +=(long)num;
				}
				ans = Math.max(ans,temp1);
			}
		}
		System.out.println(ans);
				
	

	}
}


Measured memory_bytes: 26068
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{n:usize, a:[i64; n]};
    let mut map = HashMap::new();
    for i in 0..n {
        for j in -1..2 {
            let j = j as i64;
            let mut count = map.entry(a[i]+j).or_insert(0);
            *count += 1;
        }
    }
    let mut ans:i64 = 0;
    for x in 0..100000 {
        ans = max(ans, match map.get(&(x as i64)) {
            Some(v) => *v,
            _ => 0,
        });
    }
    println!("{}", ans);
}


Measured memory_bytes: 12540
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};

// FHCまでにスタックオーバーフローの罠を解決する


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

    int n;
    cin>>n;
    vector<pair<int,string>> a(n);
    for(int i=0;i<n;i++){
        cin>>a[i].second;
        a[i].first = a[i].second.size();
    }
    sort(a.begin(),a.end());

    const int mod1 = 1000000103, mod2 = 1000000483;
    int mul1=10009;
    int mul2=10007;

    map<int,int> mp1[26],mp2[26];
    ll ans = 0;
    int ma = 0;
    ll one[26]={};
    for(int i=0;i<n;i++){
        string s = a[i].second;
        if(s.size() == 1){
            one[s[0]-'a']++;
            continue;
        }
        ll h1=0;
        ll h2=0;
        int m = s.size(), c=26;
        int cnt[c][m+1]={};
        for(int j=0;j<m;j++){
            cnt[s[j]-'a'][j+1]++;
            for(int k=0;k<26;k++) cnt[k][j+1] += cnt[k][j];
        }
        // one
        for(int j=0;j<26;j++){
            if(cnt[j][m] == 0)continue;
            ans += one[j];
        }
        int now = 0;
        for(int j=m-1;j>=1;j--){
            now++;
            h1 = (ll)(h1*mul1 + s[j]) % mod1;
            h2 = (ll)(h2*mul2 + s[j]) % mod2;
            if(now > ma)continue;
            for(int k=0;k<26;k++){
                if(cnt[k][j] && mp1[k].count((int)h1) && mp2[k].count((int)h2)){
                    ans += min(mp1[k][h1],mp2[k][h2]);
                }
            }
        }
        chmax(ma,s.size());
        mp1[(int)(s[0]-'a')][h1]++;
        mp2[(int)(s[0]-'a')][h2]++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 104544
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main(void) {
  int N, M, K;

  cin >> N >> M >> K;
  vector<int64_t> N_v(N + 1), M_v(M + 1);
  N_v[0] = 0;
  M_v[0] = 0;
  int x;
  for (int i = 1; i <= N; i++) {
    cin >> x;
    N_v[i] = N_v[i - 1] + x;
  }
  for (int i = 1; i <= M; i++) {
    cin >> x;
    M_v[i] = M_v[i - 1] + x;
  }

  int ans = 0, idx = M;
  for (int i = 0; i <= N && N_v[i] <= K; i++) {
    while (N_v[i] + M_v[idx] > K) {
      idx--;
    }
    ans = max(ans, i + idx);
  }
  cout << ans;
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-12;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

inline void add(ll &x, ll y, ll mod = MOD) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

inline ll sum(ll x, ll y, ll mod = MOD) {
    add(x, y, mod);
    return x;
}

inline ll mult(ll x, ll y, ll mod = MOD) {
    return (x * y) % mod;
}

inline ll div(ll x, ll y, ll mod) {
    return x * power(y, mod - 2, mod);
}

template<typename A, typename B> inline bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> inline bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> inline void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> inline void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

const int N = (int) 2e5 + 123;
const int A = 30;

int n;
string s;
int cnt[N][A];

void run() {
    cin >> s;
    n = sz(s);
    ll ans = 1;
    per(i, n, 1) {
        copy(cnt[i + 1], cnt[i + 1] + A, cnt[i]);
        cnt[i][s[i - 1] - 'a']++;
        ans += (n - i + 1 - cnt[i][s[i - 1] - 'a']);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 23956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

const int mod = 998244353;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} comb(200010);

int main(){
    ll N, M, K;
    cin >> N >> M >> K;
    if(M == 1){
        if(N-1 == K){
            cout << M << endl;
        }else{
            cout << 0 << endl;
        }
        return 0;
    }
    mint cur = M;
    rep(i,N-1){
        cur *= M-1;
    }
    mint ans = cur;
    REP(k,1,K+1){
        cur /= M-1;
        ans += cur*comb(N-1,k);
    }
    cout << ans << endl;
}

Measured memory_bytes: 6232
def main():
    n = int(input())
    a = list(map(int, input().split()))
    if 0 in a:
        print(0)
        return
    prod = 1
    for i in a:
        prod *= i
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod)
main()

Measured memory_bytes: 21608
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		if (a == b && a == c) {
			System.out.println("No");
			return;
		}
		
		int max = Math.max(a, Math.max(b, c));
		int min = Math.min(a, Math.min(b, c));
		int mid = (a + b + c) - (max + min);
		if (max == (min + mid)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");			
		}
	}
}


Measured memory_bytes: 9044
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

  	vector<long long> v = {1,2,3,4,5,6,7,8,9};
  
  	for(int i=0;v.size()<K;i++)
    {      
     if(v[i] % 10 != 0)v.push_back(v[i]*10 + v[i]%10 - 1);
     v.push_back(v[i]*10 + v[i]%10);
     if(v[i] % 10 != 9)v.push_back(v[i]*10 + v[i]%10 + 1);
    }
  
  //for(int i=0;i<100;i++)
  //{
    //printf("%ld\n",v[i]);
  //}
  
    cout << v[K-1] << endl;

    return 0;
}

Measured memory_bytes: 1464
#include <bits/stdc++.h>
using namespace std ;
int tmp = 0;
int a[33] = {0,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 main() {
	int n ;
	cin >> n ;
	cout << a[n] << endl ;
} 

Measured memory_bytes: 256
#include <stdio.h>

void swap(int x[],int l,int r){
	int tmp;
	tmp=x[l];
	x[l]=x[r];
	x[r]=tmp;
}

void qsort(int x[],int l,int r){
	int i,j,p;
	i=l;
	j=r;
	p=x[(i+j)/2];
	while(1){
		while(p>x[i])i++;
		while(p<x[j])j--;
		if(i>=j)break;
		swap(x,i,j);
		i++;
		j--;
	}
	if(i-l>1)qsort(x,l,i-1);
	if(r-j>1)qsort(x,j+1,r);
}

int main(){
	int a[5];
	int i;
	for(i=0; i<5; i++){
		scanf("%d",&a[i]);
	}
	qsort(a,0,4);
	printf("%d %d %d %d %d\n",a[4],a[3],a[2],a[1],a[0]);

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h> 
#define int long long
using namespace std;
const int N = 2555,M = 5555;


int32_t main(){
	cin.tie(0)->sync_with_stdio(0);
	#ifdef LOCAL
	freopen("input.txt", "r", stdin);
	#endif
	string s;
	cin>>s;
	vector<int> o;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='R') o.push_back(i);
	}
	if(o.size()==0)
	{
		cout<<"0";
		return 0;
	}
	if(o.size()==3)
	{
		cout<<"3\n";
	}
	else{
		if(o.size()==2)
		{
			if(o[0]+1==o[1])
			{
				cout<<"2\n";
			}
			else cout<<"1\n";
		}
		else cout<<"1\n";
	}
}


Measured memory_bytes: 3636
main=do
 [a,b,c]<-map read.words<$>getLine
 print$if a==b&&b==c&&a`mod`2==0 then -1 else f a b c
f a b c
 |a`mod`2==0&&b`mod`2==0&&c`mod`2==0=1+f(div(b+c)2)(div(c+a)2)(div(a+b)2)
 |otherwise=0

Measured memory_bytes: 508
#include<bits/stdc++.h>
using namespace std;
pair<int,int>e[50];
bool u[50];
int z;
vector<int>g[50];
void dfs(int i)
{
	u[i]=true;
	z++;
//	cout<<i<<" "<<z<<endl; 
	for(int pp=0;pp<g[i].size();pp++)
	{
		if(!u[g[i][pp]])dfs(g[i][pp]);
	}
}
int main()
{
	int n,m,cnt=0;
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;
		cin>>x>>y;
		e[i]=make_pair(x-1,y-1);
	}
	for(int i=0;i<m;i++)
	{
		z=0;
		for(int k=0;k<50;k++)
		{
			u[k]=0;
			g[k].clear();
		}
		for(int j=0;j<m;j++)
		{
		
			if(j!=i)
			{
				g[e[j].first].push_back(e[j].second);
				g[e[j].second].push_back(e[j].first);
			}
		}
		dfs(0);
		if(z!=n) cnt++;
	//	cout<<i<<" "<<z<<" "<<cnt<<endl;
		
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>

using namespace std;

int dp[100001] = {};
int a[100001] = {};

int saisyo(int i) {
	if (i == 0) {
		dp[0] = 0;
		return 0;
	}
	if (i == 1) {
		dp[1] = abs(a[1] - a[0]);
		return dp[1];
	}
	dp[i] = min(dp[i-2] + abs(a[i] - a[i - 2]), dp[i -1 ] + abs(a[i] - a[i - 1]));
	return dp[i];
}

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long int cnt = 0;
	for (int i = 0; i < n; i++) {
		cnt += saisyo(i);
	}
	cout << dp[n - 1] << endl;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(void) {
	int N, H, W, A, B, count=0;
	cin >> N >> H >> W;

	for (int i = 0; i < N; i++) {
		cin >> A >> B;
		if (A >= H && B >= W)
			count++;
	}

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

Measured memory_bytes: 256
#include <iostream>
using namespace std;
bool dp[5000000];
int menu[30];
int main()
{
    while(1)
    {
        int n,x;
        cin>>n>>x;if(!n)return 0;
        for(int i=0;i<n;++i){
            cin>>menu[i];
        }
        fill(dp,dp+5000000,false);
        dp[0]=true;
        for(int i=0;i<=x;++i){
            if(dp[i]){
                for(int j=0;j<n;++j){
                    dp[i+menu[j]]=true;
                }
            }
        }
        int m=0;
        for(int i=x;i>=0;--i){
            bool flag=true;
            if(dp[i]){
                for(int j=2;j*j<=i;++j){
                    if(!(i%j)){
                        flag=false;
                    }
                }
                if(flag){
                    m=i;
                    break;
                }
            }
        }
        if(m)cout<<m<<endl;
        else cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 6044
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  bool cards[4][13] = {};
  int n;
  cin >> n;
  REP(i, n) {
    string s;
    int k;
    cin >> s >> k;
    k--;
    int m = s == "S" ? 0 : (s == "H" ? 1 : (s == "C" ? 2 : 3));
    cards[m][k] = true;
  }

  REP(i, 4) {
    REP(j, 13) {
      if (!cards[i][j]) {
        string s = i == 0 ? "S" : (i == 1 ? "H" : (i == 2 ? "C" : "D"));
        cout << s << " " << j + 1 << endl;
      }
    }
  }
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll binpow(ll x,ll y){
    ll res=1;
    while(y>0){
        if(y&1)
            res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll n,i,m,temp;
    double ans,sum=0,temp1,num,l=1.0,k,ii;
    cin>>n>>k;
    num=n;
    for(i=1;i<=n;i++){
        ii=i;
        if(i>=k)
            m=0;
        else
            m=ceil(log2(k/ii));
        temp=binpow(2,m);
        temp1=temp;
        ans=num*temp1;
        sum+=(l/ans);
    }
    cout<<fixed<<setprecision(12)<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
if N < 10:
    print(N)
elif N < 99:
    print(9)
elif N < 1000:
    print(N-(99-10+1))
elif N < 9999:
    print(999 - (99-10+1))
elif N < 100000:
    print(N-(9999-1000+1)-(99-10+1))
else:
    print(N-1-(9999-1000+1)-(99-10+1))


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

const int INF = 1<<30;
struct ST{
private:
    int n;
    vector<int> node;
public:
    ST(int siz){
        n = 1;
        while(n < siz)   n *= 2;
        node.resize(2*n-1, 0);
    }

    void update(int x, int val){
        x += (n-1);
        node[x] += val;
        while(x > 0){
            x = (x-1)/2;
            node[x] = node[2*x+1] + node[2*x+2];
        }
    }

    // focus on k-th node, who controls [l, r)
    int query(int a, int b, int k = 0, int l = 0, int r = -1){
        if(r < 0)   r = n;
        if(r <= a || b <= l)    return 0;
        if(a <= l && r <= b)    return node[k];

        int lx = query(a, b, 2*k+1, l, (l+r)/2);
        int rx = query(a, b, 2*k+2, (l+r)/2, r);
        return lx + rx;
    }
};

int main(){
    int n;
    ll k;
    cin >> n >> k;
    vector<ll> v(n);
    for(int i = 0; i < n; i++)  cin >> v[i], v[i]-=k;
    vector<ll> x;
    ll sum = 0;
    for(int i = 0; i < n; i++){
        sum += v[i];
        x.push_back(sum);
    }
    sort(x.begin(), x.end());
    x.erase(unique(x.begin(), x.end()), x.end());
    auto pos = [&](ll val)->int{
        return lower_bound(x.begin(), x.end(), val)-x.begin();
    };
    ST segment(x.size());
    sum = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++){
        sum += v[i];
        ans += segment.query(0, pos(sum)+1);
        segment.update(pos(sum), 1);
        if(sum >= 0) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
int B, W;
const int N = 200001;
const int mod = 1000000007;
int fct[N];
int rfct[N];
int T[N];
int G[N];
int my_pow(int n, int k) {
	if (k == 0) {
		return 1;
	}
	int g = my_pow(n, k / 2);
	g = 1ll * g * g % mod;
	if (k & 1) {
		g = 1ll * g * n % mod;
	}
	return g;
}

int cnk(int n, int k) {
	if (k > n) {
		return 0;
	}
	if (k < 0) {
		return 0;
	}
	int ans = 1ll * fct[n] * rfct[k] % mod;
	ans = 1ll * ans * rfct[n - k] % mod;
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin >> B >> W;
	fct[0] = 1;
	rfct[0] = 1;
	for (int i = 1; i < N; i++) {
		fct[i] = 1ll * fct[i - 1] * i % mod;
		rfct[i] = my_pow(fct[i], mod - 2);
	}
	T[0] = 0;
	for (int i = 1; i <= B + W; i++) {
		T[i] = 1ll * cnk(i - 1, W - 1) * my_pow(my_pow(2, mod - 2), i) % mod;
		G[i] = 1ll * cnk(i - 1, B - 1) * my_pow(my_pow(2, mod - 2), i) % mod;
		if (i == B + W) {
			T[i] = 2ll * T[i] % mod;	
			G[i] = 2ll * G[i] % mod;
		}
		T[i] += T[i - 1];	
		if (T[i] >= mod) {
			T[i] -= mod;
		}
		G[i] += G[i - 1];	
		if (G[i] >= mod) {
			G[i] -= mod;
		}	
	}
	for (int i = 1; i <= B + W; i++) {	
		int p1 = T[i - 1];
		int p2 = (1 - p1 + mod) % mod;
		p2 = p2 - G[i - 1];
		if (p2 < 0) {
			p2 += mod;
		}
		cout << (p1 + 1ll * p2 * (mod + 1) / 2) % mod << "\n";
		
	}
	return 0;
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
using namespace std;
int main(){
    int n,d;
    cin>>n>>d;
    int ans=0;
    rep(i,n){
        vector<int> a(2);
        rep(i,2)cin>>a[i];
        double distance=sqrt(pow(a[0],2)+pow(a[1],2));
        
        if(distance<=d)ans++;
    }
    cout<<ans;
    

    }

Measured memory_bytes: 3728
#[allow(unused_macros)]
macro_rules ! read_value {($ next : expr , ($ ($ t : tt ) ,* ) ) => {($ (read_value ! ($ next , $ t ) ) ,* ) } ; ($ next : expr , [$ t : tt ; $ len : expr ] ) => {(0 ..$ len ) . map (| _ | read_value ! ($ next , $ t ) ) . collect ::< Vec < _ >> () } ; ($ next : expr , chars ) => {read_value ! ($ next , String ) . chars () . collect ::< Vec < char >> () } ; ($ next : expr , usize1 ) => {read_value ! ($ next , usize ) - 1 } ; ($ next : expr , $ t : ty ) => {$ next () . parse ::<$ t > () . expect ("Parse error" ) } ; }
#[allow(unused_macros)]
macro_rules ! input_inner {($ next : expr ) => {} ; ($ next : expr , ) => {} ; ($ next : expr , $ var : ident : $ t : tt $ ($ r : tt ) * ) => {let $ var = read_value ! ($ next , $ t ) ; input_inner ! {$ next $ ($ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input {(source = $ s : expr , $ ($ r : tt ) * ) => {let mut iter = $ s . split_whitespace () ; let mut next = || {iter . next () . unwrap () } ; input_inner ! {next , $ ($ r ) * } } ; ($ ($ r : tt ) * ) => {let stdin = std :: io :: stdin () ; let mut bytes = std :: io :: Read :: bytes (std :: io :: BufReader :: new (stdin . lock () ) ) ; let mut next = move || -> String {bytes . by_ref () . map (| r | r . unwrap () as char ) . skip_while (| c | c . is_whitespace () ) . take_while (| c |! c . is_whitespace () ) . collect () } ; input_inner ! {next , $ ($ r ) * } } ; }

fn main() {
    input! {
        a: i32,
        b: i32,
        t: i32,
    }
    println!("{}", b * (t / a));
}


Measured memory_bytes: 2152
#include <iostream>
#include <queue>

int main()
{
	std::priority_queue<int> que;
	
	std::string buf;
	while (true) {
		getline(std::cin, buf);
		int sp_pos = buf.find(' ', 0);
		if (sp_pos>=0) {
			// insert
			int key = std::stoi(buf.substr(sp_pos+1));
			que.push(key);
		}
		else {
			std::string op = buf.substr(0, sp_pos);
			if (op == "end") break;
			else {
				// extract
				std::cout << que.top() << std::endl;
				que.pop();
			}
		}
	}
	
	return 0;
}



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

int main() {
  int a,b;
  cin>>a>>b;
  double p=0;
  for(int i=1;i<=a;i++){
    int c=0,j=i;
    while(j<b){
      j*=2;
      c++;
    }
    p+=(1/pow(2,c)/a);
  }
  cout<<setprecision(15)<<p<<endl;
}

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

#define ll long long int
#define mk make_pair
#define ff first
#define ss second
#define finput ifstream cin;cin.open("in.txt")
#define foutput ofstream cout;cout.open("out.txt")  
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define mod 1000000007

ll gcd(ll x, ll y){ 
	if(x<y) 
		swap(x,y); 
	if(x%y==0)
		return y;
	return gcd(y, x%y);
}

ll pwm(ll a, ll n){
	ll ans = 1;
	while(n>0){
		if(n%2==1){
			ans = (ans * a)%mod;
		}
		a = (a*a)%mod;
		n /= 2;
	}
	return ans%mod;
}

const int pwn = 100010;
ll pw[pwn];
void pwtwo(){
	pw[0] = 1;
	for(int i=1; i<pwn; i++){
		pw[i] = (pw[i-1]*2)%mod;
	}
}


ll gcdExtended(ll a, ll b, ll *x, ll *y); 
  
ll modInverse(ll a, ll m) 
{ 	
	if(a==1)
		return 1;
	//cout<<"mi "<<a<<" "<<m<<" ";
    ll x, y; 
    ll g = gcdExtended(a, m, &x, &y); 
    if (g != 1){
        //cout << "Inverse doesn't exist"<<endl; 
        return -1;
    }
    else
    { 
        // m is added to handle negative x 
        ll res = (x%m + m) % m; 
        //cout<<res<<endl;
        return res;
        // cout << "modular multiplicative inverse is " << res; 
    } 
} 
  
ll gcdExtended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1;
    ll gcd = gcdExtended(b%a, a, &x1, &y1); 
  
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
} 

ll fact[1010];
ll init(){
	fact[0] = 1;
	for(int i=1; i<1010; i++)
		fact[i] = (fact[i-1]*i)%mod;
}

ll ncr(ll n, ll r){
	ll ans = fact[n];

	//if(r!=0)
	ans = (ans*modInverse(fact[r], mod))%mod;
	// if(n-r!=0)
	ans = (ans*modInverse(fact[n-r], mod))%mod;

	return ans;
}

int main(){
	// finput;
	// foutput;
	fast;

	int n, k, i, j, x, m;
	ll ans;
	string s;
	cin>>s;

	ans = 0;

	int b = 0;
	for(i= 0; i<s.size(); i++){
		if(s[i]=='B'){
			b++;
		}
		else{
			ans += b;
		}
	}

	// ans += b;
	cout<<ans;

	return 0;
}

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

const int MAXN = 3e5+5;
const int INF = 1e9+7;
#define ll long long
#define pb push_back
#define endl '\n'
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second

ll poww(ll a, ll b, ll md) {
    return (!b ? 1 : (b & 1 ? a * poww(a * a % md, b / 2, md) % md : poww(a * a % md, b / 2, md) % md));
}

ll MOD(ll a){
    return ((a%INF)+INF)%INF;
}

ll inv(ll a){
    return poww(a,INF-2,INF);
}

int h[MAXN],dp[MAXN];

int main()
{
    fast_io;
    //cout << fixed << setprecision(15);

    int n,k;cin >> n >> k;
    for(int i=1;i<=n;++i) cin >> h[i];
    dp[n] = 0;
    for(int i=n-1;i>=1;--i){
        dp[i] = INF;
        for(int j =i+1;j<=min(n,i+k);++j){
            dp[i] = min(dp[i],dp[j] + abs(h[i] - h[j]));
        }
    }
    cout << dp[1];
}


Measured memory_bytes: 1024
import sys
input = lambda: sys.stdin.readline()


class BIT:
    def __init__(self, n):
        self.n = n
        self.data = [0] * (n + 1)

    def sum(self, i):
        s = 0
        while i > 0:
            s += self.data[i]
            i -= i & -i
        return s

    def add(self, i, x):
        while i <= self.n:
            self.data[i] += x
            i += i & -i


n, m = map(int, input().split())
c = list(map(int, input().split()))
b = BIT(n)
for i in range(n):
    b.add(i + 1, c[i])

res = []
for i in range(m):
    t, x, y = map(int, input().split())
    if t == 1:
        res.append(b.sum(y) - b.sum(x))
    else:
        b.add(x + 1, y)
print("\n".join(map(str, res)))


Measured memory_bytes: 175676
//Tue Dec 22 22:01:34 JST 2009
#include<set>
#include<iostream>
#include<queue>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false

class state{
public:
  int len;
  int x[8],y[8];
  int cnt;
  int path[8];
  bool is_connected(int me,int you){
    if ( x[me]==x[you]){
      if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
    }else if ( x[me]+1 == x[you]){
      if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
    }else if ( x[me]-1==x[you]){
      if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
    }

    return UNCONNECT;
  }

  bool can_good_pos(int cur){
    rep(i,cur-1){
      if ( is_connected(cur,i)==CONNECT)return false;//
    }
    if (cur==0 ||  is_connected(cur,cur-1)==CONNECT)return true;//
    return false;
  }
  
  void make_next(int now,queue<state>&Q,set<state>&S,bool flag,set<pair<int,int> > & NG){
    if ( now == len){
      if ( S.find((*this))==S.end()){
	cnt++;
	S.insert(*this);
	Q.push(*this);
	cnt--;
      }
      return;
    }

    //don't move
    
    if (can_good_pos(now) ){
      path[now]=-1;
      make_next(now+1,Q,S,CANMOVE,NG);
    }

    if ( flag == CANNOTMOVE)return;//

    rep(i,6){
      x[now]+=dx[i];
      y[now]+=dy[i];

      path[now]=i;

      if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
	make_next(now+1,Q,S,CANNOTMOVE,NG);//
      }
      x[now]-=dx[i];
      y[now]-=dy[i];
    }
        
  }
  
  bool operator<(const state & a)const{
    rep(i,len){
      if ( x[i]!=a.x[i])return x[i]<a.x[i];
      if ( y[i]!=a.y[i])return y[i]<a.y[i];
    }
    return false;
  }
  
};



int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
  queue<state> Q;
  set<state> S;
  Q.push(ini);
  S.insert(ini);
  while(!Q.empty()){
    state now = Q.front();
    Q.pop();
if (19<now.cnt+(max(now.x[0],dx)-min(now.x[0],dy)+
max(now.y[0],dy)-min(now.y[0],dy))/2 )continue;
    if ( now.x[0]==dx && now.y[0]==dy){
      return now.cnt;
    }
    now.make_next(0,Q,S,CANMOVE,NG);
  }
  return 20;
}


main(){
  int n,m,dx,dy;
  while(cin>>n && n){
    state ini;
    set<pair<int,int> > NG;
    
    ini.len=n;
    ini.cnt=0;
    rep(i,n)cin>>ini.x[i]>>ini.y[i];
    cin>>m;
    rep(i,m){
      int f,s;
      cin>>f>>s;
      NG.insert(mp(f,s));
    }
    cin>>dx>>dy;
    cout << bfs(ini,dx,dy,NG)<<endl;
  }
  return false;
}

Measured memory_bytes: 14000
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = Long.parseLong(sc.next());
        long B = Long.parseLong(sc.next());     
        long C = Long.parseLong(sc.next());
        long ans = 0;
        if(A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
            ans = 0;
        }else {
            if(A >= B && A >= C) {
                ans = B * C;
            }else if(B >= A && B >= C) {
                ans = A * C;
            }else {
                ans = A * B;
            }
        }
        System.out.println(ans);
    }
}

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

const int N=110;

int main()
{
  string s[N];
  int n,length;
  cin>>n>>length;
  string ans="";
  string temp;
  for( int i = 0 ;i < n ; i++)
  {
    // getline(cin,s[i]);
    cin>>s[i];
  }
  for(int i = 0; i<n-1;i++)
  {
    for( int j = i+1;j<n;j++)
    {
      if(s[i]>s[j]){
        temp=s[i];
        s[i]=s[j];
        s[j]=temp;
      }
    }
  }
  for(int i = 0;i<n;i++)
  {
    ans=ans+s[i];
  }
  cout<<ans;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 2147483647;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}

int a, b;
string h;
vector<int>ans;
int main() {
	cin >> a >> b >> h;

	while (a) {
		for (int i = max(a - b, 0); i <= a; ++i) {
			if (h[i] == '1') { continue; }

			if (i == a) {
				cout << -1 << endl;
				return 0;
			}

			ans.push_back(a - i);
			a = i;
			break;
		}
	}

	reverse(all(ans));

	outp(ans);
}

Measured memory_bytes: 1528
#[allow(dead_code)]
fn main() {
    let s = i::s();
    let len = s.len();
    if len == 1 {
        println!("{}", 1);
        return;
    }
    if len % 2 == 0 {
        if s[len / 2] != s[len / 2 - 1] {
            println!("{}", len / 2);
            return;
        }
        let center = s[len / 2];
        let mut i = 0;
        let mut ans = len / 2;
        while len / 2 >= i + 1 {
            if s[len / 2 - 1 - i] != center || s[len / 2 + i] != center {
                println!("{}", ans);
                return;
            }
            ans += 1;
            i += 1;
        }
        println!("{}", len);
        return;
    } else {
        let center = s[len / 2];
        let mut i = 0;
        let mut ans = len / 2 + 1;
        while len / 2 >= i + 1 {
            if s[len / 2 - 1 - i] != center || s[len / 2 + 1 + i] != center {
                println!("{}", ans);
                return;
            }
            ans += 1;
            i += 1;
        }
        println!("{}", len);
        return;
    }
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
read k n
a=(`dd`)
m=$[k+${a[0]}-${a[n-1]}]
for((i=0;i<n-1;i++));do
	d=$[${a[i+1]}-${a[i]}]
	if [ $m -lt $d ];then
		m=$d
	fi
done
echo $[k-m]


Measured memory_bytes: 41284
#include <iostream>
#include<iomanip>
#include <string>
#include<vector>
#include<algorithm>
#include<utility>
#include<queue>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<ctime>
#include<cstdlib>
#define INF long long int(1e18+1)
#define rep(i,n,m) for(int i=n;i<m;i++)

using namespace std;

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


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  vector<ll>a(n),b(n);
  for(int i=0; i<n ;i++) cin >> a[i];
  for(int i=0; i<n; i++) cin >> b[i];
  
  vector<ll>d(n);
  for(int i=0; i<n; i++) d[i] = a[i] - b[i];
  
  ll counta = 0;
  for(int i=0; i<n; i++){
    if(d[i]<0){
      if(-1*d[i]%2==1) counta += -1*d[i]/2+1;
      else counta += -1*d[i]/2;
      d[i] = -1*d[i]%2;
    }
  }
  
  ll countb = 0;
  for(int i=0; i<n; i++){
    countb+=d[i];
  }
  
  if(counta-countb>=0) cout << "Yes" << endl;
  else cout << "No" << endl;
  
}
       
        
      
  
    


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
const long long N = 5e5+5 , M = 1e9+7, OO = 0x3f3f3f3f;
typedef long long ll;
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
const double Pii = 3.14159265359;
ll n, m;
ll fac[N];
ll c[N];

ll power(ll a, ll b, ll m){
    if(!b)  return 1;
    ll t = power(a, b>>1, m)%m;
    return ((t*t)%m * (b&1 ? a : 1)%m)%m;
}
ll modInverse(ll n, ll m)
{
    return power(n, m-2, m);
}

void Calc()
{
    c[0]=1;
    for(int r=1; r<=n; ++r)
    {
        c[r] = (((fac[n]*modInverse(fac[r], M))%M)*modInverse(fac[n-r], M))%M;
    }
}



ll P(ll m, ll n)
{
    ll ret = 1;
    while(n--)
    {
        ret*=m;
        ret%=M;
        m--;
    }
    return ret;
}


int main()
{
    FIO
    cin >> n >> m;
    fac[0]=1;
    for (int i=1; i<=m; i++)
        fac[i]=(fac[i-1]*i)%M;
    Calc();

    bool f = 1;
    ll no = 0;
    ll st = 1;
    if(n%2 == 0) f=0;
    //for(int i=0; i<=n; ++i) cout << c[i] << " ";
    //cout << endl;
    for(int i=n; i>0; --i)
    {
        if(f) no += ((st*c[i])%M);
        else no -= ((st*c[i])%M);
        //cout << st << " " << c[i] << " " <<  no << endl;
        f = !f;
        st*=((m-i)+1);
        st%=M;
    }
    ll tot=P(m, n);
    //cout << tot << " " << no << endl;
    cout << ((tot-no+M*M)%M * tot)%M << endl;


    return 0;
}



Measured memory_bytes: 11504
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
//#define endl "\n"
#define vint vector<int>

int main()
{
    string s;
    cin >> s;
    if (s[0] == 'S'){
        cout << "Cloudy" << endl;
    }else if (s[0] == 'C'){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
}

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

using namespace std;

typedef long long int li;
typedef long double ld;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"
#define debug(x) cout<<#x<<" = "<<x<<endl;

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

void solve()
{
    li a;

    cin>>a;

    cout<<a+a*a+a*a*a;
}

int main()
{    
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li t=1;

    // cin>>t;

    while(t--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3660
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val n = sc.nextInt()

  println(b(n))
}

private fun b(n: Int): String {
  var ans = -1
  for (i in 1..50000) {
    if (i * 108 / 100 == n) {
      ans = i
      break;
    }
  }
  if (ans == -1) return ":("

  return ans.toString()
}


Measured memory_bytes: 31264