akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		int m = Integer.parseInt(sa[1]);
		int d = Integer.parseInt(sa[2]);
		br.close();

		if (d == 0) {
			System.out.println(1.0 * (m - 1) / n);
		} else {
			System.out.println(2.0 * (n - d) * (m - 1) / n / n);
		}
	}
}


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

using namespace std;

#define sp << " " <<

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    long long h=0,s=0;
    int a[n],b[n];
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        h+=a[i];
    }
    for(int i=0;i<n;i++)
    {
        cin >> b[i];
        s+=b[i];
    }
    if(h<s)
        cout << -1;
    else
    {
        int t=0;
        vector <int> r;
        long long dp=0;
        for(int i=0;i<n;i++)
        {
            if(a[i]>=b[i])
                r.push_back(a[i]-b[i]);
            else
                dp+=b[i]-a[i],t++;
        }
        int i=0;
        sort(r.begin(),r.end(),greater <int>());
        while(dp>0)
        {
            dp-=r[i];
            i++;
            t++;
        }
        cout << t;
    }
    return 0;
}


Measured memory_bytes: 1660
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>

using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;

int main() {
  int N, A, B; cin>>N>>A>>B;
  int ans1 = min(A, B);
  int ans2 = max(0, (A+B)-N);
  cout << ans1 << " " << ans2 << endl;
  return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, Y, Z = MAP()

print(Z, X, Y)


Measured memory_bytes: 5840
#include <iostream>
#include <vector>
#include <algorithm>
#ifndef repeat
#define repeat(i,n) for (int i = 0; i < (n); ++i)
#endif
#ifndef repeat_from
#define repeat_from(i,m,n) for (int i = (m); i < (n); ++i)
#endif
#ifndef repeat_one
#define repeat_one(i,n) for (int i = 1; i <= (n); ++i)
#endif
#ifndef repeat_rev
#define repeat_rev(i,n) for (int i = (n)-1; 0 <= i; --i)
#endif
#ifndef foreach
#define foreach(it, cont) for (typeof(cont.begin()) it = cont.begin(); it != cont.end(); ++it)
#endif
using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    while (true) {
        int n, r; cin >> n >> r;
        if (n == 0 and r == 0) break;
        vector<int> v(n); repeat (i,n) v[i] = n-i;
        repeat (i,r) {
            int p, c; cin >> p >> c;
            vector<int> vp(v.begin(),   v.begin()+p-1);
            vector<int> vc(v.begin()+p-1, v.begin()+p-1+c);
            copy(vp.begin(), vp.end(), v.begin()+c);
            copy(vc.begin(), vc.end(), v.begin());
        }
        cout << v.front() << endl;
    }
    return 0;
}

Measured memory_bytes: 1224
N,K,Q=[int(i) for i in input().split()]
A = list(map(int,[input() for i in range(Q)]))
 
points = [K] * N
answers = [0] * N

for a in A :
   answers[a-1] += 1

sum = [x + y for (x, y) in zip(points, answers)]
aaa = [x - Q for (x) in sum]
for p in aaa :
    print('No') if p <= 0 else print('Yes')

Measured memory_bytes: 17308
#include <bits/stdc++.h>
using namespace std;
#define gc getchar_unlocked
#define fo(i, n) for (i = 0; i < n; i++)
#define Fo(i, k, n) for (i = k; k < n ? i < n : i > n; k < n ? i += 1 : i -= 1)
#define ll long long
#define si(x) scanf("%d", &x)
#define sl(x) scanf("%lld", &x)
#define ss(s) scanf("%s", s)
#define pi(x) printf("%d\n", x)
#define pl(x) printf("%lld\n", x)
#define ps(s) printf("%s\n", s)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
typedef pair<int, int> pii;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<char> vc;
typedef vector<vc> vcc;
typedef vector<pii> vpii;
typedef vector<pl> vpl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim)
{
    uniform_int_distribution<int> uid(0, lim - 1);
    return uid(rang);
}

int mpow(int base, int exp);
void ipgraph(int n, int m);
void dfs(int u, int par);

const int mod = 1'000'000'007;
const int N = 3e5, M = N;
//=======================

vi g[N];
int a[N];

void solve()
{
    ll n, k, x, y;
    cin >> n >> k >> x >> y;
    if (n <= k)
    {
        cout << n * x << endl;
        return;
    }
    else
    {
        ll cost = x * k;
        n -= k;
        cost += (n * y);
        cout << cost << endl;
        return;
    }
}

int main()
{
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

int mpow(int base, int exp)
{
    base %= mod;
    int result = 1;
    while (exp > 0)
    {
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

void ipgraph(int n, int m)
{
    int i, u, v;
    while (m--)
    {
        cin >> u >> v;
        u--, v--;
        g[u].pb(v);
        g[v].pb(u);
    }
}

void dfs(int u, int par)
{
    for (int v : g[u])
    {
        if (v == par)
            continue;
        dfs(v, u);
    }
}


Measured memory_bytes: 10572
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define PB push_back
#define MP make_pair
#define ll long long

inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}

bool field[2002][2002];
int horizontal[2002][2002];
int vertical[2002][2002];
int main(){
    std::ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    for(int i=1;i<=h;++i){
        for(int j=1;j<=w;++j){
            char c;
            cin >> c;
            if(c == '.')
            {
                field[i][j] = true;
            }
        }
    }

    for(int i=1;i<=h;++i)
    {
        int cnt = 0;
        for(int j=1;j<=w;++j)
        {
            if(field[i][j]){
                cnt++;
            }
            else
            {
                cnt = 0;
            }
            horizontal[i][j] = cnt;            
        }

        int fill = 0;
        for(int j=w;j>=0;--j)
        {
            if(fill == 0)
            {
                fill = horizontal[i][j];
            }

            if(field[i][j]){
                horizontal[i][j] = fill;
            }
            else
            {
                fill = 0;
            }
        }
    }

    for(int i=1;i<=w;++i)
    {
        int cnt=0;
        for(int j=1;j<=h;++j)
        {
            if(field[j][i]){
                cnt++;
            }
            else
            {
                cnt = 0;
            }
            vertical[j][i] = cnt;            
        }

        int fill = 0;
        for(int j=h;j>=0;--j)
        {
            if(fill == 0)
            {
                fill = vertical[j][i];
            }

            if(field[j][i]){
                vertical[j][i] = fill;
            }
            else
            {
                fill = 0;
            }
        }

    }

    int ret = 0;
    for(int i=1;i<=h;++i)
    {
        for(int j=1;j<=w;++j)
        {
            ret = max(ret, horizontal[i][j] + vertical[i][j] - 1);
        }
    }

    cout << ret << endl;
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
using ll =long long;
int main(){
  string s;
  cin>>s;
  if (s.substr(2,1)==s.substr(3,1) && s.substr(4,1)==s.substr(5,1)) cout <<"Yes";
  else cout << "No";
}

Measured memory_bytes: 256
N = int(input())
S = input()
# N = 8
# S = 'WWWWWEEE'
right = 0
left = 0
# N = 3
# for j in range(N - 1, 0, -1):
#     print(j)

for i in range(N):
    if i == 0:
        right = 0
        left = 0
        for j in range(N-1, 0, -1):
            if S[j] == 'E':
                left += 1
        sum = right + left
        min = right + left
    else:
        if S[i-1] == 'W':
            right += 1
        if S[i] == 'E':
            left -= 1

        sum = right + left
        if sum < min: min = sum

print(min)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int sum = 0;
  cin >> N;
  int N_origin = N;
  
  while(N > 0){
    sum += N%10;
    N /= 10;
  }
  
  if(N_origin%sum == 0){
    cout << "Yes" << endl;
  }
  else 
    cout << "No" << endl;
}
  

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.1415926535
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

int main()
{
    int n;
    cin>>n;
    double sum=0;
    double a[n];
    ffor(i,0,n) cin>>a[i];
    sort(a,a+n);
    ffor(i,0,n-1)
    {
        a[i+1]=(a[i+1]+a[i])/2;
    }
    cout<<a[n-1];
    return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<vector<int>>miti(2,vector<int>(n));
  for(int i=0;i<n;i++)
    cin >> miti.at(0).at(i);
  for(int i=0;i<n;i++)
    cin >> miti.at(1).at(i);
  int ans=0,nw;
  for(int i=0;i<n;i++){
    nw=0;
    for(int j=0;j<n;j++){
      if(j<=i)
        nw+=miti.at(0).at(j);
      if(j>=i)
        nw+=miti.at(1).at(j);
    }
    ans=max(ans,nw);
  }
  cout << ans << endl;
  return 0;
}

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

int n,q,a[20];
bool can[2001] = {};

void dfs(int i,int sum){
	if(i == n){
		if(sum <= 2000) can[sum] = true;
		return;
	}
	dfs(i + 1,sum);
	dfs(i + 1,sum + a[i]);
}

int main() {
	cin >> n;
	for(int i = 0;i < n;i++) cin >> a[i];
	dfs(0,0);
	cin >> q;
	for(int i = 0;i < q;i++){
		int m;
		cin >> m;
		if(can[m]) cout << "yes" << endl;
		else cout << "no" << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define mp make_pair
#define ll long long 
int main() {
	int i,j,k,l,n,m,a[3][3];
	for(i=0;i<3;i++)
		for(j=0;j<3;j++)
			cin>>a[i][j];
	cin>>n;
	for(i=0;i<n;i++) {
		cin>>j;
		for(k=0;k<3;k++)
			for(l=0;l<3;l++)
				if(a[k][l]==j)
					a[k][l]*=-1*(abs(a[k][l]));
	}
	for(i=0;i<3;i++)
		if(a[i][0]<0 && a[i][1]<0 && a[i][2]<0) {
			cout<<"Yes\n";
			return 0;
		}
	for(i=0;i<3;i++)
		if(a[0][i]<0 && a[1][i]<0 && a[2][i]<0) {
			cout<<"Yes\n";
			return 0;
		}
	if(a[0][0]<0 && a[1][1]<0 && a[2][2]<0) {
		cout<<"Yes\n";
		return 0;
	}
	if(a[2][0]<0 && a[1][1]<0 && a[0][2]<0) {
		cout<<"Yes\n";
		return 0;
	}
	cout<<"No\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstdlib>
#include <stack>
#include <vector>
#define INF 0x3f3f3f3f
#define MOD 1000000009
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
typedef long long ll;
typedef unsigned long long ull;

inline int scan() {
    int x=0,f=1; char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1; ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
    return x*f;
}
inline void Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
using namespace std;
int a[100005];
int main()
{
    int n;
    cin >> n;
    int ji = 1;
    int ID = 0;
    int l = 0, r = n-1;
    while(1)
    {
        cout << ID << endl;
        string str;
        cin >> str;
        if(ji == 1)
        {
            if(str == "Male")
            {
                for(int i = 0; i < n; i++)
                {
                    if(i%2 == 0)a[i] = -1;
                    else a[i] = 1;
                }
            }
            if(str == "Female")
            {
                for(int i = 0; i < n; i++)
                {
                    if(i%2 == 0)a[i] = 1;
                    else a[i] = -1;
                }
            }
            if(str == "Vacant")break;
            ID = (l+r)/2;
        }
        else
        {
            if(str == "Male")
            {
                if(a[ID] == -1)
                {
                    int k = ID;
                    ID = (ID+r)/2;
                    l = k;
                }
                else
                {
                    int k = ID;
                    ID = (ID+l)/2;
                    r = k;
                }
            }
            if(str == "Female")
            {
                if(a[ID] == 1)
                {
                    int k = ID;
                    ID = (ID+r)/2;
                    l = k;
                }
                else
                {
                    int k = ID;
                    ID = (ID+l)/2;
                    r = k;
                }
            }
            if(str == "Vacant")break;
        }
        ji++;
        if(r-l == 1)ID = r;
    }
    return 0;
}
/*
                 ___====-_  _-====___
           _--^^^#####//      \\#####^^^--_
        _-^##########// (    ) \\##########^-_
       -############//  |\^^/|  \\############-
     _/############//   (@::@)   \\############\_
    /#############((     \\//     ))#############\
   -###############\\    (oo)    //###############-
  -#################\\  / VV \  //#################-
 -###################\\/      \//###################-
_#/|##########/\######(   /\   )######/\##########|\#_
|/ |#/\#/\#/\/  \#/\##\  |  |  /##/\#/  \/\#/\#/\#| \|
`  |/  V  V  `   V  \#\| |  | |/#/  V   '  V  V  \|  '
   `   `  `      `   / | |  | | \   '      '  '   '
                    (  | |  | |  )
                   __\ | |  | | /__
                  (vvv(VVV)(VVV)vvv)
                  ÁúÉñ±£ÓÓ ÓÀÎÞbug
*/


Measured memory_bytes: 1236
use proconio::*;
use proconio::marker::*;

fn main() {
    input! {
        s: Chars,
        t: Chars
    }

    let mut count = 0;

    for i in 0 .. s.len() {
        if s[i] != t[i] {
            count += 1;
        }
    }

    println!("{}", count);
}


Measured memory_bytes: 3996
import sys
input = sys.stdin.readline

N = int(input())
a = [int(input()) for _ in range(N)]
ans = -1
step = 0
idx = 0
while True:
    if step == N:
        break
    next = a[idx]
    idx = next-1
    step += 1
    if next == 2:
        ans = step
        break
print(ans)

Measured memory_bytes: 7084
#include<bits/stdc++.h>
#define mp make_pair
#define pr pair<ll,ll>
#define MAX 1000000
using namespace std;
typedef unsigned long long int ll;
#define mod 998244353
void sync(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
}

int main(){
	sync();
	ll n,k;
	//ll p=1e18;
	//cout<<p<<endl;
	cin>>n>>k;
	long long int p=n%k;
	long long int q=k-p;
	q=abs(q);
//	cout<<p<<" "<<q<<endl;
	cout<<min(p,q)<<endl;

}

Measured memory_bytes: 384
mod = 998244353
n = int(input())
d = list(map(int, input().split()))

if d[0] != 0:
    print(0)
    exit(0)

max_d = max(d)
cnt = [0] * (max_d + 1)

for num in d:
    cnt[num] += 1

if cnt[0] > 1:
    print(0)
    exit(0)

ans = 1

for i in range(1, len(cnt)):
    ans *= pow(cnt[i - 1], cnt[i], mod)
    ans %= mod

print(ans)


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

int main(){
	
	while(1){
		int n,m;
		cin>>n>>m;
		if(n==0&&m==0){
			break;
		}
		int a[1000];
		for(int i=0;i<n;i++){
			cin>>a[i];
		}
		int x=-1;
		for(int i=0;i<n-1;i++){
			for(int j=i+1;j<n;j++){
				int t=a[i]+a[j];
				if(t<=m&&t>x){
					x=t;
				}
			}
		}
		if(x==-1){
			cout<<"NONE";
		}else{
			cout<<x;
		}
		cout<<endl;
	}

	return 0;
}

Measured memory_bytes: 3000
import qualified Data.ByteString.Char8 as B
import Data.Maybe (fromJust)

main :: IO ()
main = do
    [x, y] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine
    print $ length $ takeWhile (\i -> x * (2 ^ (i - 1)) <= y) [1..]


Measured memory_bytes: 508
import numpy as np

h, w = map(int, input().split())
a = [list(input()) for _ in range(h)]

b = []
c = []
cnt = 0

for i in range(h):
    if set(a[i]) != {'.'}:
        b.append(a[i])
        cnt += 1

b = np.array(b)
b =b[::-1,:].T
b = list(b)

for j in range(w):
    if set(b[j]) != {'.'}:
        c.append(b[j])

c = np.array(c)
c = c[::-1,:].T
c = c[::-1,::-1]
c = list(c)

for i in range(cnt):
    print(''.join(map(str, c[i])))

Measured memory_bytes: 12876
fun main(args: Array<String>) {
    val (n, m) = readLine()?.split(" ")?.map(String::toInt) ?: return
    val a = readLine()?.split(" ")?.map(String::toInt) ?: return

    val threshold: Double = 1.0 / (4.0 * m)
    val total = a.sum().toDouble()
    val count = a.filter {
        val ratio: Double = it / total
        ratio >= threshold
    }.size
    if (count >= m) {
        println("Yes")
    } else {
        println("No")
    }
}


Measured memory_bytes: 37804
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;


int main()
{
    int dir[256];
    dir['E'] = 0;
    dir['N'] = 1;
    dir['W'] = 2;
    dir['S'] = 3;

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

    for(;;){
        int w, h;
        cin >> w >> h;
        if(w == 0)
            return 0;

        vector<string> s(h);
        for(int i=0; i<h; ++i)
            cin >> s[i];

        int n = 0;
        vector<int> y, x, d;
        for(int i=0; i<h; ++i){
            for(int j=0; j<w; ++j){
                if('E' <= s[i][j] && s[i][j] <= 'W'){
                    y.push_back(i);
                    x.push_back(j);
                    d.push_back(dir[s[i][j]]);
                    ++ n;
                    s[i][j] = '!';
                }
            }
        }

        int m = n;
        for(int t=1; t<=180; ++t){
            vector<bool> move(n, false);
            for(int i=0; i<n; ++i){
                if(s[y[i]][x[i]] == 'X')
                    continue;
                for(int j=0; j<4; ++j){
                    int d1 = (d[i] + j + 3) % 4;
                    int y1 = y[i] + dy[d1];
                    int x1 = x[i] + dx[d1];
                    if(s[y1][x1] == '.' || s[y1][x1] == 'X'){
                        d[i] = d1;
                        move[i] = true;
                        break;
                    }
                }
            }

            for(int i=0; i<4; ++i){
                for(int j=0; j<n; ++j){
                    if(!move[j] || d[j] != (i+2)%4)
                        continue;
                    int y1 = y[j] + dy[d[j]];
                    int x1 = x[j] + dx[d[j]];
                    if(s[y1][x1] == '.' || s[y1][x1] == 'X'){
                        s[y[j]][x[j]] = '.';
                        if(s[y1][x1] == 'X'){
                            s[y1][x1] = 'Y';
                            -- m;
                        }else{
                            s[y1][x1] = '!';
                        }
                        y[j] = y1;
                        x[j] = x1;
                    }
                }
            }
            for(int i=0; i<n; ++i){
                if(s[y[i]][x[i]] == 'Y')
                    s[y[i]][x[i]] = 'X';
            }

            if(m == 0){
                cout << t << endl;
                break;
            }
        }

        if(m != 0)
            cout << "NA" << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include<queue>
struct cheese{
    int x,y;
};
using namespace std;
int map[1001][1001],walk[1001][1001];
int main(void){
    int X,Y,sx,sy,gx,gy,xx,yy,N,Ncnt=1,i,i2,ans=0,bx[4]={1,-1,0,0},by[4]={0,0,1,-1};
    char nyuryoku[1001][1001];
    queue<cheese> jotai;
    cheese ima,tugi;
    cin>>Y>>X>>N;
    for(i=1;i<=Y;i++){
        for(i2=1;i2<=X;i2++){
            cin>>nyuryoku[i2][i];
        }
    }
    for(i=1;i<=Y;i++){
        for(i2=1;i2<=X;i2++){
            switch(nyuryoku[i2][i]){
                case 'S':
                    map[i2][i]=0;
                    sx=i2;
                    sy=i;
                    break;
                case 'X':
                    map[i2][i]=-1;
                    break;
                case '.':
                    map[i2][i]=0;
                    break;
                case '1':
                    map[i2][i]=1;
                    break;
                case '2':
                    map[i2][i]=2;
                    break;
                case '3':
                    map[i2][i]=3;
                    break;
                case '4':
                    map[i2][i]=4;
                    break;
                case '5':
                    map[i2][i]=5;
                    break;
                case '6':
                    map[i2][i]=6;
                    break;
                case '7':
                    map[i2][i]=7;
                    break;
                case '8':
                    map[i2][i]=8;
                    break;
                case '9':
                    map[i2][i]=9;
                    break;
            }
        }
    }
    while(Ncnt<=N){
        for(i=1;i<=Y;i++)for(i2=1;i2<=X;i2++)walk[i2][i]=-1;
        walk[sx][sy]=0;
        ima.x=sx;
        ima.y=sy;
        jotai.push(ima);
        while(!jotai.empty()){
            ima=jotai.front();
            jotai.pop();
            for(int I=0;I<4;I++){
                xx=ima.x+bx[I];
                yy=ima.y+by[I];
                //cout<<"xx="<<xx<<" yy="<<yy<<endl<<map[ima.x][ima.y]<<endl;
                if(map[ima.x][ima.y]==Ncnt){
                    gx=ima.x;
                    gy=ima.y;
                }
                else if(xx>0&&yy>0&&xx<=X&&yy<=Y&&((walk[xx][yy]>walk[ima.x][ima.y]+1)||walk[xx][yy]==-1)&&map[xx][yy]!=-1){
                    tugi.x=xx;
                    tugi.y=yy;
                    walk[xx][yy]=walk[ima.x][ima.y]+1;
                    /*
                    for(i=1;i<=Y;i++){
                        for(i2=1;i2<=X;i2++){
                            if(walk[i2][i]>-1)cout<<' ';
                                cout<<walk[i2][i]<<' ';
                            }
                        cout<<endl;
                    }
                    cout<<endl;
                    */
                    jotai.push(tugi);
                }
            }
        }
        ans+=walk[gx][gy];
        sx=gx;
        sy=gy;
        Ncnt++;
    }
    cout<<ans<<endl;
    /*for(i=1;i<=Y;i++){
        for(i2=1;i2<=X;i2++){
            if(map[i2][i]>-1)cout<<' ';
            cout<<map[i2][i]<<' ';
        }
        cout<<endl;
    }*/
}

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

int main()
{
    ll N; cin >> N;
    string S; cin >> S;
    ll w_num = 0;
    ll r_num = 0;
    rep (i,N) {
        if (S[i] == 'W') {
            w_num++;
        }
        else {
            r_num++;
        }
    }
    ll ans = 0;
    for (int i = r_num - 1; i >= 0; i--) {
        if (S[i] == 'W') {
            ans++;
        }
    }
    cout << ans << endl;


    




}


Measured memory_bytes: 3752
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <climits>
#include <numeric>
#include <cmath>
#include <queue>
#include <sstream>

using namespace std;
typedef long long ll;

int ketawa(int n ) {
  int sum = 0;
  while(n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

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

  if (n % ketawa(n) == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

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

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define divceil(a, b) ((a) + (b)-1) / (b)
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;

double d(double x1, double y1, double x2, double y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

int solve() {
    double a, b, h, m;
    cin>>a>>b>>h>>m;

    double x = 6.0*m;
    double y = 30.0*(h+m/60.0);
    dump(b*cos(x/180.0 * M_PI));
    dump(b*sin(x/180.0 * M_PI));
    dump(a*cos(y/180.0 * M_PI));
    dump(a*sin(y/180.0 * M_PI));
    double ans = d(
            // b*cos(x/180.0 * M_PI), b*sin(x/180.0 * M_PI), \
            // a*cos(y/180.0 * M_PI), a*sin(y/180.0 * M_PI)
            b*cos(x*M_PI/180.0), b*sin(x/180.0 * M_PI), \
            a*cos(y*M_PI/180.0), a*sin(y/180.0 * M_PI)
            );
    printf("%.12f", ans);

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


Measured memory_bytes: 4192
#include<iostream>
#include<algorithm>
#include<cstdio>
#define INF 10000000
using namespace std;
int main(){
  int n,m,p,a,b;
  double cost[30][257],ticket[8],edge[30][30];
  bool done[30];
  while(cin >>n>>m>>p>>a>>b,n||m||p||a||b){
    for(int i=0; i<m; i++) done[i] = false;
    for(int i=0; i<m; i++) for(int j=0; j<30; j++) edge[i][j] = -1;
    for(int i=0; i<m; i++) for(int j=0; j<(1<<n); j++) cost[i][j] = INF;
    for(int i=0; i<n; i++) cin >>ticket[i];
    for(int i=0; i<p; i++){
      int x,y; double z;
      cin >>x>>y>>z;x--;y--;
      edge[x][y] = edge[y][x] = z;
    }
    a--;b--;
    cost[a][0] = 0;
    for(;;){
      int next=-1;double n_c=INF;
      for(int i=0; i<m; i++){
	if(done[i]) continue;
	for(int j=0; j<(1<<n); j++){
	  if(n_c > cost[i][j]){
	    n_c = cost[i][j];
	    next = i;
	  }
	}
      }
      if(next == -1) break;
      done[next] = true;
      for(int i=0; i<m; i++){
	if(edge[next][i] == -1 || done[i]) continue;
	for(int j=0; j<(1<<n); j++){
	  if(cost[next][j] == INF) continue;
	  for(int k=0; k<n; k++){
	    if((j&(1<<k)) == 0) cost[i][j|(1<<k)] = min(cost[i][j|(1<<k)],cost[next][j]+edge[next][i]/ticket[k]);
	  }
	}
      }
    }
    double ans = INF;
    for(int i=0; i<(1<<n); i++) ans = min(ans,cost[b][i]);
    if(ans == INF) cout <<"Impossible"<<endl;
    else printf("%.3lf\n",ans);
  }
  return 0;
}

Measured memory_bytes: 1352
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ii pair<int,int>
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define mod 998244353
#define int long long int
using namespace std;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
   //   freopen("q.gir","r",stdin);
   //   freopen("q.cik","w",stdout);
      string s;
      cin>>s;
      int n=s.length(),ans=0;
      for(int i=0;i<n/2;i++){
            if(s[i]!=s[n-i-1])ans++;
      }
      cout<<ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

const double PI = acos(-1.0);

bool bit(long long n, int k) { return (n >> k) & 1LL; }


long long a,b,c;
long long dfs(int i, long long x) {
    long long m = 1LL << 62;
    if (a <= x) return m;
    if (i == 41) {
        if ((a - x) ^ (b + x) == c, i) {
            return x;
        } else {
            return m;
        }
    }

    auto y = x;
    if (bit((a - x) ^ (b + x), i) == bit(c, i)) {
        m = min(m, dfs(i + 1, x));
    }
    y = x | (1LL << i);
    if (bit((a - y) ^ (b + y), i) == bit(c, i)) {
        m = min(m, dfs(i + 1, y));
    }
    return m;
}

void solve(long long N, std::vector<long long> A) {
    a = A[0];
    b = A[1];
    c = 0;
    loop(i, 2, N) c ^= A[i];
    // t == 0 となる x を見つけたい. 最小のもの.

    long long x = dfs(0, 0);

    if (x < a && (a - x) ^ (b + x) == c) {
        cout << x << endl;
    } else {
        cout << -1 << endl;
    }
    return;

    for (long long k = 0; k < A[0];) {
        auto t = (A[0] - k) ^ (A[1] + k) ^ x;
        if (t == 0) {
            cout << k << endl;
            return;
        }

        int s = 0;
        while (((t >> s) & 1) == 0) s++;
        k += 1 << s;
    }
    cout << -1 << 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));
    return 0;
}


Measured memory_bytes: 3708
"use strict";
function main(input) {
    const args = input.split(" ");

    const r = parseInt(args[0]);
    const D = parseInt(args[1]);
    let x = parseInt(args[2]);

    for(let i = 0; i < 10; i++) {
        console.log(r * x - D);
        x = r * x - D
    }
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21320
n,q=list(map(int,input().split()))
s=input()

acum=[0]*(n+1)

for i in range(1,n):
    if s[i]=='C' and s[i-1]=='A':
        acum[i]=acum[i-1]+1
    else:
        acum[i]=acum[i-1]

for _ in range(q):
    l,r=list(map(int,input().split()))
    l-=1
    r-=1
    print(acum[r]-acum[l])

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

using namespace std;

int main(){
	int N;
	while(cin >> N){
		vector<int> A(N);
		for(auto& t : A) cin >> t;
		int valid = 0;
		long long x = A[0];
		long long s = A[0];
		long long res = 0;
		for(int i=0;i<N;i++){
			while(valid < N-1 && (x^A[valid+1]) == (s + A[valid+1])){
				++valid;
				x ^= A[valid];
				s += A[valid];
			}
			res += (valid - i + 1);
			x ^= A[i];
			s -= A[i];
		}
		cout << res << endl;
	}
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int cnt[4];
int main(){
    REP(i, 0, 3){
        int a, b;
        cin>>a>>b;
        cnt[a-1]++;
        cnt[b-1]++;
    }

    if((cnt[0]==1 && cnt[1]==1 && cnt[2]==2 && cnt[3]==2) ||
       (cnt[0]==1 && cnt[1]==2 && cnt[2]==2 && cnt[3]==1) ||
       (cnt[0]==2 && cnt[1]==2 && cnt[2]==1 && cnt[3]==1) ||
       (cnt[0]==2 && cnt[1]==1 && cnt[2]==1 && cnt[3]==2)){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<numeric>
#include<string>
#include<utility>
#include<vector>
using namespace std;

const long mod = 1000000007;
const long indlim = 5368709119;
long gcd(long x, long y) { if (x > y) { return gcd(y, x); } long r; while (y != 0) { r = x % y; x = y; y = r; }return x; }
long lcm(long x, long y) { return(x / gcd(x, y)) * y; }
long fact(long x) { if (x == 0) return 1; else return((fact(x - 1) * x) % mod); }
long mybase(long N, long B) { if (N == 0) return 0; string S = ""; while (N != 0) { string M = to_string(N % B); N -= N % B; N /= B; S = M + S; }return stol(S); }
void indexsort(long* first, long* last, long* func) { sort(first, last, [&](long a, long b) {return func[a] < func[b]; }); }
//--------------------

int main() {

	long N, M; cin >> N >> M;
	long a[100009]; for (int i = 0; i < M; i++) cin >> a[i];
	bool isbroken[100009] = {}; for (int i = 0; i < M; i++) isbroken[a[i]] = true;
	long res[100009] = {};

	res[0] = 1; res[1] = 1;

	for (int i = 2; i <= N; i++) {
		if (isbroken[i - 2] == false) res[i] += res[i - 2];
		if (isbroken[i - 1] == false) res[i] += res[i - 1];
        res[i] %= mod;
	}
	cout << res[N] << endl;
}

Measured memory_bytes: 1920
import math
import itertools
N = int(input())
x = []
result = 0
for _ in range(N):
    x.append(list(map(int, input().split())))
for i in itertools.permutations(list(range(N))):
    for j in range(len(i)-1):
        result += math.sqrt((x[i[j]][0] - x[i[j+1]][0])**2 +
                            (x[i[j]][1] - x[i[j+1]][1])**2)
print(result/math.factorial(N))


Measured memory_bytes: 3064
n,W = list(map(int,input().split()))
w = []
v = []
for i in range(n):
    w_,v_ = list(map(int,input().split()))
    w.append(w_)
    v.append(v_)

dp = [[0]*(W+1) for _ in range(n+1)]
for i in range(n):
    for sum_w in range(W+1):
        dp[i+1][sum_w] = max(dp[i+1][sum_w],dp[i][sum_w])
        if sum_w-w[i]>=0:
            dp[i+1][sum_w] = max(dp[i+1][sum_w],dp[i][sum_w-w[i]]+v[i])

print(dp[n][W])

Measured memory_bytes: 152052
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<array>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<unordered_map>
#include<queue>
#include<vector>
using namespace std;

//#define int long long
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) {cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) {cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
const int MOD = 1e9 + 7;

signed main() {
	for (int w; cin >> w&&w != -1;) {
		int ans = 1150;
		int a[] = { 125,140,160 };
		rep(i, 0, 3) {
			if (w > 10) {
				w -= 10;
				if (i == 2)ans += a[i] * w;
				else ans += a[i] * (w >= 10 ? 10 : w % 10);
			}
		}
		ans = 4280 - ans;
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2992
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#define pb push_back
using namespace std;
const int N=1e5+5;

long long n,m;

vector <int> nb[N];
bool vis[N];
int depth[N];

long long odd,even;

bool odd_cycle=false;

void DFS(int v,int level,int parent)
{
    if(level % 2 ==0)
        even++;
    else
        odd++;

    depth[v]=level;

    vis[v]=true;

    for(int i=0;i<nb[v].size();i++)
    {
        if(!vis[nb[v][i]])
         DFS(nb[v][i],level+1,v);
        else
        {
            if(nb[v][i] != parent)
            {
                if((depth[v] - depth[nb[v][i]] + 1) % 2 == 1)
                    odd_cycle=true;
            }
        }

    }
}


long long ans;

int abs(int x)
{
    if(x < 0)
        return -x;

    return x;
}

int main()
{
   int i,j;
   int u,v;

   cin>>n>>m;
   for(i=1;i<=m;i++)
   {
       scanf("%d%d", &u, &v);

       nb[u].pb(v);
       nb[v].pb(u);
   }

   if(n <= 3)
   {
       printf("0\n");

       return 0;
   }


   DFS(1,1,0);

   if(odd_cycle)
   {
       cout<< ((n*(n-1))/2) - m <<endl;

       return 0;
   }


   int rmv=0;
   for(i=1;i<=n;i++)
   {
       for(j=0;j<nb[i].size();j++)
       {
           if(abs(depth[i] - depth[nb[i][j]]) % 2 == 1)
            rmv++;
       }
   }

   rmv/=2;

   ans =(odd * even) - rmv;

   cout<<ans<<endl;




   return 0;
}


/*

5 4
1 2
2 3
2 4
4 5

*/

/*

5 5
1 2
1 5
2 3
5 3
5 4

*/


Measured memory_bytes: 7808
#include <bits/stdc++.h>
#define MAX_N 100010
#define N MAX_N
#define rank Asdfiasofsad
#define int long long
using namespace std;

class UF{
public:
  vector<int> par,rank;
  UF(){
    par.resize(MAX_N),rank.resize(MAX_N);
    for(int i=0;i<MAX_N;i++)par[i]=i,rank[i]=0;
  }

  UF(int n){
    par.resize(n),rank.resize(n);
    for(int i=0;i<n;i++)par[i]=i,rank[i]=0;
  }

  int find(int x){
    if(par[x]==x)return x;
    return par[x]=find(par[x]);
  }
  
  void unite(int x,int y){
    x=find(x), y=find(y);
    if(x==y)return;
    if(rank[x]<rank[y])par[x]=y;
    else{
      par[y]=x;
      if(rank[x]==rank[y])rank[x]++;
    }
  }

  bool same(int x,int y){return find(x)==find(y);}
};

vector<int> G[N];
map<int,int>M[N];
vector<int> grp[N];

typedef pair<int,int> P;
signed main(){
  int n,m;
  cin>>n;
  P C[N];

  for(int i=0,a;i<n;i++)cin>>a,C[i]=P(a,i);

  cin>>m; 
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  UF A; 
  for(int i=0;i<n;i++) M[i][C[i].first] = i;

  for(int i=0;i<n;i++)
    for(int p:G[i])
      if(M[p].count(C[i].first)) A.unite(i,M[p][C[i].first]);
      else M[p][C[i].first] = i;

  for(int i=0;i<n;i++)grp[A.find(i)].push_back(i);

  sort(C,C+n);
  int money[N]={};
  int ans = 0;
  for(int i=0;i<n;i++){
    int c = C[i].first;
    int p = C[i].second;
    if(A.find(p) != p) continue;

    int mx = 0;
    for(int pos:grp[p]){
      mx = max(mx,money[pos]);
      for(int nx:G[pos]) mx = max(mx,money[nx]);
    }
    mx++;
    ans += mx*grp[p].size();
    for(int pos:grp[p]){
      money[pos] = mx;
      for(int nx:G[pos]) money[nx] = mx;
    }
  }
  cout<<ans<<endl;


  return 0;
}

Measured memory_bytes: 54620
package main

import (
	"fmt"

	"os"
	"io"
	"bufio"
	"bytes"

	"strings"
	"strconv"
	"sort"
)

//  長い入力を読む
func ReadLongLines(times int) ([]string, error) {
	result := make([]string, times)
	reader := bufio.NewReader(os.Stdin)
	buffer := bytes.NewBuffer(make([]byte, 0))
	readBytes := int64(2)
	for i := 0; i < times; i++ {
		for {
			readBuf, isPrefix, err := reader.ReadLine()
			// fmt.Printf("Reader.Read: %d\n", len(readBuf))
			readBytes += int64(len(readBuf) + 1)
			if err != nil {
				if err == io.EOF {
					fmt.Println("EOF")
					break
				} else {
					return result, err
				}
			}
			_, err = buffer.Write(readBuf)
			if err != nil {
				return result, err
			}
			// end of line
			if !isPrefix {
				result[i] = buffer.String()
				buffer.Reset()
				// reader = bufio.NewReader(os.Stdin)
				break
			}
		}
	}
	// 先読みしてしまうようなので、戻しておく
	os.Stdin.Seek(-int64(reader.Buffered()), os.SEEK_CUR)
	return result, nil
}

// 出力 for 競プロ
type Console struct {
	writer *bufio.Writer
}
func NewConsole() Console {
	return Console{ bufio.NewWriter(os.Stdout) }
}
func (this *Console) Printf(format string, a ...interface{}) {
	fmt.Fprintf(this.writer, format, a...)
}
func (this *Console) Println(s string) {
	fmt.Fprintln(this.writer, s)
}
func (this *Console) Close() {
	this.Flush()
}
func (this Console) Flush() {
	this.writer.Flush()
}

func Pow(b, e int) int {
	result := 1
	for i := 0; i < e; i++ {
		result = result * b
	}
	return result
}

var permutationResult = make([]int, 0)
func Permutation(list []int, index int, current int) {
	// fmt.Printf("[%d] -> %d\n", index, list[index])
	// fmt.Printf("cur:%d\n", current)
	// fmt.Println(list)
	// fmt.Printf("%d ? %d\n", Pow(10, len(list)-1), current)

	// use
	current *= 10
	current += list[index]
	list[index] = -1

	if Pow(10, len(list)-1) <= current {
		permutationResult = append(permutationResult, current)
		return
	}

	// fmt.Println(list)
	for i := 0; i < len(list); i++ {
		if (list[i] == -1) {
			continue
		}
		c := make([]int, len(list))
		copy(c, list)
		Permutation(c, i, current)
	}

}
func CreatePermutation(list []int) []int {
	for i := 0; i < len(list); i++ {
		c := make([]int, len(list))
		copy(c, list)
		Permutation(c, i, 0)
	}
	return permutationResult
}

func Print(i int) {
	s := strconv.Itoa(i)
	t := strings.Split(s, "")
	u := strings.Join(t, " ")
	fmt.Println(u)
}

func main() {
	con := NewConsole()
	defer con.Flush()

	// create list
	var n int
	theNumber := 0
	fmt.Scanf("%d", &n)
	list := make([]int, n)
	for i := range list {
		var x int
		fmt.Scanf("%d", &x)
		list[i] = x
		theNumber += x
		theNumber *= 10
	}
	theNumber /= 10

	sort.Slice(list, func(lhs, rhs int) bool {
		return list[lhs] < list[rhs]
	})
	p := CreatePermutation(list)
	for i := range p {
		if theNumber == p[i] {
			if 1 <= i {
				Print(p[i-1])
			}
			Print(p[i])
			if i + 1 < len(p) {
				Print(p[i+1])
			}
		}
	}
}


Measured memory_bytes: 13536
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <tuple>
#include <cassert>
using namespace std;
typedef long long ll;
#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;

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

    string s;
    cin >> s;
    
    REP(i,s.size()) {
        s[i] = (char)((((int)(s[i] - 'A') + N) % 26) + 'A');
    }

    cout << s << endl;

    return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func divisor(n int) []int {
	res := []int{}
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	return res
}

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	ma := 1
	for i := 1; i*i <= N; i++ {
		if N%i == 0 {
			ma = i
		}
	}

	fmt.Fprintln(wtr, max(len(strconv.Itoa(ma)), len(strconv.Itoa(N/ma))))
	wtr.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define NMAX 200005
using namespace std;
typedef long long ll;
ll n, i, j, p[5], q, used[10];
vector<ll> a[3], sol;
void bkt(ll k)
{
    if(k<n)
    {
        for(int i=1;i<=n;i++)
            if(!used[i])
        {
            used[i]=1;
            sol.pb(i);
            bkt(k+1);
            sol.pop_back();
            used[i]=0;
        }
    }
    else
    {
        q++;
        for(int i=1;i<=2;i++)
            if(sol==a[i])
                p[i]=q;
    }
}
void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie();
}
int main()
{
    fast();
    cin>>n;
    for(j=1;j<=2;j++)
    for(i=1;i<=n;i++)
        {
            ll x;
            cin>>x;
            a[j].pb(x);
        }
    bkt(0);
    cout<<abs(p[1]-p[2]);
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import numpy as np

K, N = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]

A_diff = np.diff(A, n= 1).tolist()
A_diff.append(K+A[0]-A[-1])
print(K-max(A_diff))


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

typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = INT_MAX;



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

	FOR(i, -1000, 1000) {
		FOR(j, -1000, 1000) {
			if((ll)((ll)pow(j,5) - (ll)pow(i,5)) == n) {
				cout << j << " " << i << "\n";
				return;
			}
		}
	}
}

int32_t main() {_
	//tc(t)
		solve();
}



Measured memory_bytes: 4080