akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
#define dame { printf("No\n"); return 0;}
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)


signed main(){

    string s;
    cin >> s;
    int k;
    cin >>k;
    int n = s.length();
    string res = "";
    REP(i,n-1){
        int num = int(s[i]) - 'a';
        if(num ==0){
            res += 'a';
            continue;
        }
        if(26-num <= k){
            res += 'a';
            k -= 26 -num;

        }
        else{
            res += s[i];
        }
    }
    k %=26;
    res += moji[ (int(s[n-1]) + k - 'a') %26 ];
    cout << res << endl;



}


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

int main(void){
    string s;
    cin >> s;
    string t = "keyence";
    int n = s.size();
    int p = 0;
    rep(i,n){
        if (s[i] == t[p]) p++;
        else break;
    }
    cout << (s.substr(n-(7-p)) == t.substr(p) ? "YES" : "NO") << endl;
    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

bool judge(ll x) {
  VI a(10, 0);
  while(x) {
    a[x%10]++;
    x /= 10;
  }
  return a[3] > 0 && a[5] > 0 && a[7] > 0;
}

ll solve(ll s, ll n) {
  if(s > n) return 0;
  else {
    if(judge(s)) return solve(s * 10 + 3, n) + solve(s * 10 + 5, n) + solve(s * 10 + 7, n) + 1;
    else return solve(s * 10 + 3, n) + solve(s * 10 + 5, n) + solve(s * 10 + 7, n);
  }
}

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  out(solve(0, n));
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
//using ll = boost::multiprecision::cpp_int;
using ll = long long;
#define FORi(N) for(ll i = 0; i < N; ++i)
#define FORj(N) for(ll j = 0; j < N; ++j)
#define FORk(N) for(ll k = 0; k < N; ++k)
//using int = ll;
ll gcd(ll m, ll n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
void swap(ll &a, ll &b) {
    ll tmp = a;
    a = b;
    b = tmp;
}
ll combi(ll n, ll k) {
    ll r = 1 ,rr =1;
    for(ll i=0;i<k;++i) {
      r*=(n-i);
      rr*=(i+1);
      //r %= 1000000007;
      //rr %= 1000000007;
    }
    r/=rr;
    //r %= 1000000007;
    return r;
}

int main() {
  ll N,K;
  cin>>N>>K;
  vector<vector<ll>> v(N,vector<ll>());
  FORi(N-1){
    ll a,b;
    cin>>a>>b;
    v[a-1].push_back(b-1);
    v[b-1].push_back(a-1);
  }
  function<ll(ll,ll,ll,ll)> f=[&](ll a,ll now,ll par,ll nc){
    ll i=0;
    ll num=1;
    ll b = a+1;
    if(b>=3)b=2;
  	for(ll n:v[now]){
      if(n==par)continue;
      num*=f(b,n,now,i);
      num%=1000000007;
      i++;
    }
    //cout<<(K-a-nc)<<endl;
    return num*(K-a-nc)%1000000007;
  };
  cout<<f(0,0,-1,0)<<endl;
  return 0;
}


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

// iterator
#define REP(i,init, n) for(lli i=init;i<n;i++)
#define REPE(i,init, n) for(lli i=init;i<=n;i++)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

typedef long long int lli;
typedef pair<lli, lli> P;

int main() {
    lli n, T;
    cin2(n, T);
    lli t[n+1];
    ncin1(n, t);
    t[n] = t[n-1] + T;

    lli ans = 0;
    lli start_time = 0;
    bool flowing = false;
    REP(i, 0, n) {
        lli cur = t[i];
        lli finish_time = t[i] + T;
        lli next = t[i+1];
        if (!flowing) {
            flowing = true;
            start_time = cur;
        }
        if (next >=  finish_time) {
            ans += finish_time - start_time;
            flowing = false;
        }
    }

    cout << ans << endl;

}


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

#define X first
#define Y second
#define mp make_pair
#define pb pop_back
#define eb emplace_back
#define sz(v) (int) v.size()

using namespace std;

typedef long long LL;
typedef long double LD;

void solve() {
	int a, b;
	cin >> a >> b;
	for (int k = 0; ; ++k) {
		int cur = k * a - k + 1;
		if (cur >= b) {
			cout << k << "\n";
			return;
		}
	}
}

signed main() {
// #define TASK ""
#if !defined(LOCAL) && defined(TASK)
	freopen(TASK".in", "r", stdin);
	freopen(TASK".out", "w", stdout);
#endif
	ios::sync_with_stdio(0); cin.tie(0);
	int tests = 1;
	// cin >> tests;
	while (tests--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
typedef long long ll;
const int N=100010,Mo=1000000007;
ll f[N],s[N];
inline ll gi() {
    ll x=0,o=1;
    char ch=getchar();
    while(ch!='-'&&(ch<'0'||ch>'9')) ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
int main() {
    int n,p=0,ans=0,la=0;
    ll A,B;
    cin>>n>>A>>B;
    if(A<B) swap(A,B);
    s[0]=-1LL<<60,f[0]=1;
    for(int i=1,j=0;i<=n;i++) {
	s[i]=gi();
	if(i>1&&s[i]-s[i-2]<B) return puts("0"),0;
	while(s[i]-s[j]>=A) la=(la+f[j++])%Mo;
	f[i]=la;
	if(s[i]-s[i-1]<B) j=p=i-1,la=0;
    }
    while(p<=n) ans=(ans+f[p++])%Mo;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;

vecll AS(200001);
int main(int argc, char const *argv[])
{
  ll N; cin >> N;
  map<ll, ll> MP;
  REP(i, N) {
    cin >> AS[i];
    auto itr = MP.find(AS[i]);
    if (itr != MP.end()) itr->second += 1;
    else MP.insert(pair<ll, ll>(AS[i], 1LL));
  }
  ll SM = 0;
  for (const auto &pr : MP) SM += pr.second*(pr.second-1)/2;
  REP(i, N) {
    ll cnt = MP.find(AS[i])->second;
    ll res = SM - cnt*(cnt-1)/2 + (cnt-1)*(cnt-2)/2;
    cout << res << endl;
  }
  return 0;
}


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

int main() {
  int N;
  scanf("%d", &N);
  int i;
  int str[N];
  for (i = 0; i < N; i++) {
    scanf("%d", &str[i]);
  }
  int j, k, l;
  int count = 0;
  for (j = 0; j < N; j++) {
    for (k = 0; k < N; k++) {
      for (l = 0; l < N; l++) {
        if (j < k && k < l) {
          if (str[j] == str[k] || str[k] == str[l] || str[j] == str[l]) {
            continue;
          } else {
            int ab = str[j] + str[k];
            int bc = str[k] + str[l];
            int ca = str[l] + str[j];
            if (ab > str[l] && bc > str[j] && ca > str[k]) {
              count++;
            }
          }
        }
      }
    }
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1736
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
 string s;
 for(;;)
 {
	  getline(cin >> ws, s);
	  stringstream str(s);
	  int a, b;
	  char o;
	  str >> a >> o >> b;
	  
	  if(o == '+') cout << a + b << endl;
	  else if (o == '-') cout << a - b << endl;
	  else if (o == '*') cout << a * b << endl;
	  else if (o == '/') cout << a / b << endl;
	  else break;
 }
 return 0;
}

Measured memory_bytes: 3220
#include <bits/stdc++.h>
#include<limits.h>
#include<stdio.h>
#include<cstring>
#include<string>
using namespace  std;
typedef long long ll;
typedef long double ld;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define fi first
#define se second
#define rsz(a,n) a.resize(n)
#define test(t) ll t;cin>>t;while(t--)
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define fillv(a,k) memset(a,k,sizeof(a))
#define leadzero(a) __builtin_clz(a) //count leading zeros
#define trailzero(a) __builtin_ctz(a) //count trailing zeros
#define bitcount(a) __builtin_popcount(a) // count set bits (add ll)
#define ln cout<<"\n"
// #define sp cout<<" "
#define spaceprint(a,i,s,n) {forsn(i,s,n) { cout<<a[i]; sp;}}
#define lineprint(a,i,s,n) {forsn(i,s,n) {cout<<a[i]; ln;}}
#define maxe(a) *max_element(a.begin(),a.end())
#define maxi(a) max_element(a.begin(),a.end())-a.begin()
#define mine(a) *min_element(a.begin(),a.end())
#define mini(a) min_element(a.begin(),a.end())-a.begin()
#define all(c) c.begin(),c.end()
#define trav(container, it) for(typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element)  (find(all(container),element) != container.end())// check the presence of element
//copy(from_begin, from_end, to_begin); copy function
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<string> vs;
typedef vector<int> v32;
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
typedef map<ll,ll> m64;
const int LIM = 1e5+5, MOD =  1e9;
#define sumv(v) accumulate(all(v),ll(0))
#define productv(v) accumulate(all(v), ll(1), multiplies< ll >())
ll gcd(ll a, ll b) { if(b == 0) return a; return gcd(b, a % b); }
ll fastpowMOD(ll a, ll p,ll MOD){ if(p==0) return 1; ll z = fastpowMOD(a,p/2,MOD); z = (z*z)%MOD; if(p%2) z = (z*a)%MOD; return z; }
bool seive[100005];
void SieveOfEratosthenes(ll n)
{ memset(seive, true, sizeof(seive)); for (ll p=2; p*p<=n; p++) if (seive[p] == true) for (ll i=p*p; i<=n; i += p) seive[i] = false; }
// ll a[11*LIM]={0},b[11*LIM]={0};
// vp64 v[LIM];
typedef struct 
{
	ll one,two,three;
}data;





int main()
{
	fast;
	ll n,k;
	cin>>k>>n;
	ll a[n];
	for (ll i=0;i<n;i++)
		cin>>a[i];
	ll ans=1e9;
	for (ll i=0;i<n;i++)
	{
		if (i==0)
		{
			ans=min(ans,a[n-1]-a[0]);
		}
		else
		{
			ans=min(ans,k-(a[i]-a[i-1]));
		}
	}
	cout<<ans;
} 

Measured memory_bytes: 1792
n=int(input())
flag='OK'
maeWord=''
nowWord=''
wordList=[]

for i in range (1,n+1):
  if(i==1):
      maeWord=input()
      wordList.append(maeWord)
  else:
    nowWord=input()
    if(nowWord in wordList):
      flag='NG'
    
    if(list(maeWord)[-1] != list(nowWord)[0]):
      flag='NG'
      
    maeWord=nowWord
    wordList.append(maeWord)
    
if(flag=='NG'):
  print('No')
else:
  print('Yes')
  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
    using namespace std;
     
    int main() {
      int n;
      string s;
      cin >> n >> s;
      char last = s[0];
      int ans = 1;
      for (int i = 1; i < n; ++i) {
      	if (s[i] != last) {
        	++ans;
        	last = s[i]; 
        }
      }
      cout << ans;
    }

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

int main(void) {
	int i;
	int x, y;
	int group[13];
	char buf[128], *ch;
	group[0] = 0;
	group[1] = 1;
	group[2] = 3;
	group[3] = 1;
	group[4] = 2;
	group[5] = 1;
	group[6] = 2;
	group[7] = 1;
	group[8] = 1;
	group[9] = 2;
	group[10] = 1;
	group[11] = 2;
	group[12] = 1;

	fgets(buf, sizeof(buf), stdin);
	ch = strtok(buf, " ");
	x = atoi(ch);
	ch = strtok(NULL, " ");
	y = atoi(ch);

	if(group[x] == group[y]) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}

	return 0;
}


Measured memory_bytes: 2024
use std::io::Read;
 
fn main() {
    let mut buf = String::new();
    let stdin = std::io::stdin();
    stdin.lock().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n = iter.next().unwrap().parse::<usize>().unwrap();
    let m = iter.next().unwrap().parse::<usize>().unwrap();

    if n == m {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void)
{
    int test[10000];
    int i, j;
    
    do{
        scanf("%d", &test[i]);
        i++;
    }while(test[i-1]);
    
    i--;
    
    for(j=0; j<i; j++){
        printf("Case %d: %d\n", j+1, test[j]);
    }
    
    return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

long long int f(const long long int x){
    const long long int m = log2(x)+1;
    long long int res = 0;
    for(long long int i = 1; i <= m; ++i){
        long long int n = 1LL<<i;
        long long int c = ((x+1)/n)*(n/2);
        c += max(0LL, ((x+1)%n)-(n/2));

        if(c & 1) res += n>>1;
    }

    return res;
}

int main(){
    long long int A, B;
    cin >> A >> B;

    long long int ans = f(A-1)^f(B);
    cout << ans << endl;
}

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

using ll = long long;
using P = pair<int, int>;
#define rep1(i,n) for (int i=1; i<=n; i++)
#define rep0(i,n) for (int i=0; i<n; i++)
#define zarray(x,n) x[n+1]; rep1(i,n) {x[i]=0;} 

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

    vector<int> p;
    rep1(i, n) {
        int x;
        cin >> x;
        p.push_back(x);
    }

    std::sort(p.begin(), p.end());

    int ans = 0;
    rep0(i,k) {
        ans += p[i];
    }

    cout << ans << endl;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;


int main(void)
{
    IOS
    int n,m; cin >> n >> m;
    vector<set<int>> vs(n+1);
    REP(i,m) {
        int u,v; cin >> u >>v;
        vs[u].emplace(v);
    }
    int s,t; cin >> s >> t;

    int dp[3][100010];
    REP(i,3) REP(j,100010) dp[i][j] = 0;
    dp[0][s] = 1;

    set<int> next(vs[s]);

    int ans = 1;
    while(true) {
        set<int> tmp;
        FOR(i,0,3) {
            //cerr << next.size() << endl;
            int j = i == 2 ? 0:i+1;
            for(auto x:next) {
                if (dp[j][x]!=1) {
                    dp[j][x] = 1;
                    tmp.insert(ALL(vs[x]));
                }
            }
            next = tmp;
            tmp.clear();
        }
        if (dp[0][t]== 1) break;
        //cerr << next.size()<<endl;
        if (next.size() == 0) {
            ans = -1;
            break;
        }
        ans++;
    }

    cout << ans << endl;

    return 0;
}


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

int main(){
  int N;
  cin >> N;
  vector<int> p(N);
  int S = 0, M = 0;
  for(int i = 0; i < N; i++){
    cin >> p[i];
    S += p[i];
    M = max(M, p[i]);
  }
  
  int ans = S - M/2;
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N,i,max=0;
  scanf("%d",&N);
  int C[N],V[N];
  for(i=0;i<N;i++){
    scanf("%d",&V[i]);
  }
  for(i=0;i<N;i++){
    scanf("%d",&C[i]);
  }
  for(i=0;i<N;i++){
    if(V[i]>C[i]){
      max = max + (V[i]-C[i]);
    }
  }
  printf("%d\n",max);
return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007 
long long noofpath[1005][1005];
char path[1005][1005];
int main()
{
	int h,w;
	long long ans;
	cin>>h>>w;
	for(int i=0;i<1005;i++)
	{
		for(int j=0;j<1005;j++)
			noofpath[i][j]=0;
	}
	for(int i=0;i<=h;i++)
	{
		for(int j=0;j<=w;j++)
		{
			if(i==0 ||j==0) path[i][j]='#';
			else cin>>path[i][j];
		}
	}
	noofpath[1][1]=1;
	for(int i=1;i<=h;i++)
	{
		for(int j=1;j<=w;j++)
		{
			if(i==1&&j==1) continue;
			if(path[i-1][j]=='.' && path[i][j-1]=='.')
				noofpath[i][j]=(noofpath[i-1][j]+noofpath[i][j-1])%mod;
			else if(path[i][j-1]=='.')
				noofpath[i][j]=(noofpath[i][j-1])%mod;
			else if(path[i-1][j]=='.')
				noofpath[i][j]=(noofpath[i-1][j])%mod;
			//cout<<noofpath[i][j]<<" ";
		}
		//cout<<endl;
	}
	cout<<noofpath[h][w]<<endl;
	return 0;
}

Measured memory_bytes: 9088
import java.util.Scanner;

public class Main {
	public static double Dxy(int[] x, int[] y, int p, int n) {
		double output = 0;
		for(int i = 0; i < n; i++) {
			output += Math.pow(Math.abs(x[i] - y[i]), (double)p);
		}
		output = Math.pow(output, (double)1.0 / p);
		return output;
	}
	public static void main(String[] args) {
		int p, i;
		double max = 0;
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] a = new int[n];
			int[] b = new int[n];
			for(i = 0; i < n; i++) {
				a[i] = sc.nextInt();
			}
			for(i = 0; i < n; i++) {
				b[i] = sc.nextInt();
			}
			for(p = 1; p <= 3; p++) {
				System.out.println(Dxy(a, b, p, n));
			}
			for(i = 0; i < n; i++) {
				if(max < Math.abs(a[i] - b[i])) {
					max = Math.abs(a[i] - b[i]);
				}
			}
			System.out.println(max);
		}
	}
}



Measured memory_bytes: 26756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Set;
import java.util.StringTokenizer;

public class Main {
  public static void main(String[] args) {
	  FastReader sc = new FastReader();
	  boolean[] primes = new boolean[100002];
	  int[] counts = new int[100002];
	  Arrays.fill(primes, true);
	  primes[0] = false;
	  primes[1] = false;
	  
	  // pre-process
	  // 1.エラトステネスの篩
	  for (int i = 2; i < 100002; i++) {
		  if (primes[i]) {
			  for (int j = i * 2; j < 100002; j += i) {
				  primes[j] = false;
			  }
		  }
	  }
	  
	  // 2. 2017に似た数を計算
	  for (int i = 2; i < 100002; i++) {
		  if (primes[i] && primes[(i + 1) / 2]) {
			  counts[i]++;
		  }
	  }
	  
	  // 3. prefix sum
	  for (int i = 1; i < 100002; i++) {
		  counts[i] += counts[i-1];
	  }
	  
	  int q = sc.nextInt();
	  
	  for (int i = 0; i < q; i++) {
		  int l = sc.nextInt();
		  int r = sc.nextInt();
		  System.out.println(counts[r] - counts[l-1]);
	  }
  }
  
  static class FastReader {
    BufferedReader br;
    StringTokenizer st;

    public FastReader() {
      br = new BufferedReader(new InputStreamReader(System.in));
    }
  
    String next() { 
      while (st == null || !st.hasMoreElements()) {
        try {
          st = new StringTokenizer(br.readLine());
        } catch (IOException  e) {
          e.printStackTrace();
        }
      }
      return st.nextToken();
    }

    int nextInt() {
      return Integer.parseInt(next());
    }

    long nextLong() {
      return Long.parseLong(next());
    }

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

    String nextLine() {
      String str = "";
        try{
            str = br.readLine();
        } catch (IOException e) {
            e.printStackTrace();
        }
        return str;
      }
  }
}


Measured memory_bytes: 47984
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	a[0] -= 32;
	b[0] -= 32;
	c[0] -= 32;
	cout << a[0] << b[0] << c[0]<< endl;
}

Measured memory_bytes: 256
import std.stdio, std.range, std.conv, std.string, std.array, std.functional, std.math;
import std.algorithm.comparison, std.algorithm.iteration, std.algorithm.mutation, std.algorithm.searching, std.algorithm.setops, std.algorithm.sorting;
import std.container.binaryheap;
import std.typecons; 

struct S{
    long all;
    long patti;
}

S[51] memo;
void main()
{
    const input = readln().strip.split.to!(long[]);
    const N = input[0];
    const X = input[1];
    memo[0] = S(1, 1);

    foreach(i; 1..51) {
        memo[i] = S(memo[i-1].all*2+3, memo[i-1].patti*2+1);
    }

    writeln(func(N, X));
}

long func(long n, long x)
{
    if(n==0)
        return x<=0?0:1;
    else if(x <= 1+memo[n-1].all)
        return func(n-1, x-1);
    else
        return memo[n-1].patti+1+func(n-1, x-2-memo[n-1].all);
}

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    char arr[200][200];
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i=0,j=0;i<=m+1&&j<=m+1;i++,j++)
    {
        arr[0][i]='#';
        arr[n+1][j]='#';
    }
    for(int k=0,f=0;k<=n+1&&f<=n+1;k++,f++)
    {
        arr[k][0]='#';
        arr[f][m+1]='#';
    }
    for(int i=0;i<=n+1;i++)
    {
        for(int j=0;j<=m+1;j++)
        {
            cout<<arr[i][j];
        }
        cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<math.h>
using namespace std;
#define ll long long
int main(){

	double B;
	ll A;
	cin >> A >> B;

	ll iB=(B * 100)+0.5;
	A *= iB;
	A /= 100;
	cout << A << endl;

	return 0;
}

Measured memory_bytes: 3640
n, x = map(int, input().split())
a = sorted(list(map(int, input().split())))
ans, i = 0, 0
while i < (n - 1):
    if x - a[i] >= 0:
        x -= a[i]
        ans += 1
    else:
        break
    i += 1
if x == a[i]:
	ans += 1
print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;while(n--){ans*=x;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

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

long long INF = 1LL<<60;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    rep(i,n)cin>>a[i];
    vector<ll> sum(n+1,0);
    for(int i=0;i<=n-1;i++){
        sum[i+1]=a[i]+sum[i];
    }
    map<ll,ll>  num;
    for(int i=0;i<=n;i++){
        num[sum[i]]++;
    }

    ll ans=0;
    for(auto it :num){
        ll v=it.second;
        ans+=v*(v-1)/2;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 15104
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	void run() {
		int n = sc.nextInt();
		int[] c = new int[n];
		long mod = 1_000_000_007;
		int cmax = 2 * 100_000;
		
		long dp[] = new long[cmax+1];
		dp[0] = 1;
		
		for(int i = 0 ; i < n ; i++) {
			c[i] = sc.nextInt();
			if( i > 0 && c[i] == c[i-1]) {
				continue;
			}
			
			long next0 = (dp[0] + dp[c[i]]) % mod;
			long nextci = (dp[c[i]] + dp[0]) % mod;
			
			dp[0] = next0;
			dp[c[i]]= nextci;
		}
		
		System.out.println(dp[0]);
	}
}


Measured memory_bytes: 86028
n,k=map(int,input().split())
a=list(map(int,input().split()))
adj=[1]*n
b=[1]
now=0
while adj[now]:
  adj[now]=0
  now=a[now]-1
  b.append(now+1)
loop_start=b.index(b[-1])
loop=b[loop_start:-1]
p=len(loop)
if k<loop_start:
  print(b[k])
else:
  k-=loop_start
  k%=p
  print(loop[k])


Measured memory_bytes: 103516
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
String s[]=sc.next().split("",0);
int a=Integer.parseInt(s[0]);
int b=Integer.parseInt(s[1]);
int c=Integer.parseInt(s[2]);
int d=Integer.parseInt(s[3]);
  if(a+b+c+d==7)System.out.println(a+"+"+b+"+"+c+"+"+d+"=7");
  else if(a+b+c-d==7)System.out.println(a+"+"+b+"+"+c+"-"+d+"=7");
  else if(a+b-c+d==7)System.out.println(a+"+"+b+"-"+c+"+"+d+"=7");
  else if(a+b-c-d==7)System.out.println(a+"+"+b+"-"+c+"-"+d+"=7");
  else if(a-b+c+d==7)System.out.println(a+"-"+b+"+"+c+"+"+d+"=7");
  else if(a-b+c-d==7)System.out.println(a+"-"+b+"+"+c+"-"+d+"=7");
  else if(a-b-c+d==7)System.out.println(a+"-"+b+"-"+c+"+"+d+"=7");
  else System.out.println(a+"-"+b+"-"+c+"-"+d+"=7");
  
}
}

Measured memory_bytes: 23892
package main

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

const size = 1000000
var reader = bufio.NewReaderSize(os.Stdin,size)
func NextLine() string {
  var line,buffer []byte
  var isPrefix bool = true
  var err error
  for ;isPrefix; {
    line,isPrefix,err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer,line...)
  }
  return string(buffer)
}
func NextIntArray() []int {
  var s []string = strings.Split(NextLine()," ")
  var n int = len(s)
  var a []int = make([]int,n)
  for i:=0;i<n;i++ {
    a[i],_ = strconv.Atoi(s[i])
  }
  return a
}
func NextInt() int {
  var n int
  n,_ = strconv.Atoi(NextLine())
  return n
}

func main() {
  var n int = NextInt()
  var a []int = NextIntArray()
  var b []int = make([]int,n)
  for i:=0;i<n;i++ { b[i] = a[i] }
  var ma,mb,s,t int64
  ma = 0
  mb = 0
  s = 0
  for i:=0;i<n;i++ {
    t = s + int64(a[i])
    if i%2 == 0 && t <= 0 {
      ma += 1-t
      s = 1
    } else if i%2 == 1 && t >= 0 {
      ma += t+1
      s = -1
    } else {
      s = t
    }
  }
  s = 0
  for i:=0;i<n;i++ {
    t = s + int64(b[i])
    if i%2 == 1 && t <= 0 {
      mb += 1-t
      s = 1
    } else if i%2 == 0 && t >= 0 {
      mb += t+1
      s = -1
    } else {
      s = t
    }
  }
  fmt.Println(min(ma,mb))
}
func min(n int64,m int64) int64 {
  if n < m {
    return n
  } else {
    return m
  }
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
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 string YES = "Yes";
const string NO = "No";

vector<string> s;
vector<string> ans;
bool memo[100001][8][8][8];
bool visi[100001][8][8][8];
bool dfs(int i, int a, int b, int c) {
    if (i == s.size()) return true;
    a = min(a, 5);
    b = min(b, 5);
    c = min(c, 5);
    if (visi[i][a][b][c]) return memo[i][a][b][c];
    visi[i][a][b][c] = true;

    bool ret = false;
    if (s[i] == "AB") {
        if (0 < a && dfs(i + 1, a - 1, b + 1, c)) {
            ans.push_back("B");
            ret = true;
            goto RETURN;
        }
        if (0 < b && dfs(i + 1, a + 1, b - 1, c)) {
            ans.push_back("A");
            ret = true;
            goto RETURN;
        }
    } else if (s[i] == "AC") {
        if (0 < a && dfs(i + 1, a - 1, b, c + 1)) {
            ans.push_back("C");
            ret = true;
            goto RETURN;
        }
        if (0 < c && dfs(i + 1, a + 1, b, c - 1)) {
            ans.push_back("A");
            ret = true;
            goto RETURN;
        }
    } else if (s[i] == "BC") {
        if (0 < b && dfs(i + 1, a, b - 1, c + 1)) {
            ans.push_back("C");
            ret = true;
            goto RETURN;
        }
        if (0 < c && dfs(i + 1, a, b + 1, c - 1)) {
            ans.push_back("B");
            ret = true;
            goto RETURN;
        }
    }
    RETURN:
    return memo[i][a][b][c] = ret;
}

void solve(long long N, int A, int B, int C, std::vector<std::string> s_) {
    memset(memo, 0, sizeof(memo));
    memset(visi, 0, sizeof(visi));
    s = move(s_);
    bool ok = dfs(0, A, B, C);
    if (!ok) {
        cout << NO << endl;
    } else {
        reverse(ans.begin(), ans.end());
        cout << YES << endl;
        rep(i, N) { cout << ans[i] << endl; }
    }
}

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


Measured memory_bytes: 124708
#include <stdio.h>
#include <iostream>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <limits.h>
#include <map>
#include <string>
#include <bitset>
#include <vector>
using namespace std;
int main() {
    long long n, ans = 0;
    cin >> n;
    ans += (n / 500) * 1000;
    n %= 500;
    ans += (n / 5) * 5;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3644
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
As = Is()
As.sort(reverse=True)
alice = As[::2]
bob = As[1::2]
print(sum(alice)-sum(bob))



Measured memory_bytes: 3436
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space 100005
//<<fixed << setprecision(9)

int main()
{
    int i,j,n,t;
    boost;
    
    ll m;
    cin>>m;
    ll ans=0;
    if(m%2)cout<<0;
    else
    {
        m/=2;
        while(m!=0)
        {
            ans+=m/5;
            m/=5;
        }
        cout<<ans;
    }

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Node{
	int p,l,r;
};
const int maxn=30;
Node a[maxn];
int rt;
void preorder(int x){
	if(x==-1) return;
	cout<<" "<<x;
	preorder(a[x].l);
	preorder(a[x].r);
}
void inorder(int x){
	if(x==-1) return;
	inorder(a[x].l);
	cout<<" "<<x;
	inorder(a[x].r);
}
void postorder(int x){
	if(x==-1) return;
	postorder(a[x].l);
	postorder(a[x].r);
	cout<<" "<<x;
}
void tree_walk(){
	cout<<"Preorder\n";
	preorder(rt);
	cout<<"\nInorder\n";
	inorder(rt);
	cout<<"\nPostorder\n";
	postorder(rt);
	cout<<endl;
	return;
}
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++) a[i].p=-1; //初始化父节点 
	for(int i=0;i<n;i++){  //输入 
		int v,l,r;
		cin>>v>>l>>r;
		a[v].l=l;
		a[v].r=r;
		if(l!=-1) a[l].p=v;
		if(r!=-1) a[r].p=v;
	}
	for(int i=0;i<n;i++) if(a[i].p==-1) rt=i; //寻找根结点 
//	rt--;
	
	tree_walk();
	
	return 0;
}


Measured memory_bytes: 3080
import sys

X, Y = map(int, sys.stdin.readline().split())

for x in range(X+1):
    kame = x
    tsuru = X - x
    
    y = kame * 4 + tsuru * 2
    # print(kame, tsuru, y)
    if y==Y:
        print("Yes")
        break
else:
    print("No")

Measured memory_bytes: 9172
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define pint pair<int,int>
using namespace std;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	char s[200002];	cin>>s;
	int i,j,n=strlen(s);
	ll ans=0,count=0;
	for(i=0;i<n-1;i++){
		if(s[i]=='B')	count++;
		if(s[i]=='B' && s[i+1]=='W'){
			s[i]='W';	s[i+1]='B';
			ans+=count;	count--;
		}
		else if(s[i]=='W')	count=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<vector>
#include<queue>
#include<string>
#include<stack>
#include<algorithm>
#include<memory.h>
#include<set>
#include<map>
#include<cmath>
#include<time.h>
#include<iomanip>
#include<time.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N = 1e6, M = 1e9 + 7;
const double PI = acos(-1);
int n;
vector<ll>v;
ll cs[N],C;
ll back[N],seg1[4*N],seg2[4*N],front[N];
int range[N];
void build(int p,int s,int e){
	if(s==e){
		seg1[p]=back[s];
		seg2[p]=front[s];
		return;
	}
	build(2*p,s,(s+e)/2);
	build(2*p+1,(s+e)/2+1,e);
	seg1[p]=max(seg1[2*p],seg1[2*p+1]);
	seg2[p]=max(seg2[2*p],seg2[2*p+1]);
}
int l,r;
ll get1(int p,int s,int e){
	if( s>r || e<l)return 0;
	if(s>=l && e<=r)return seg1[p];
	return max(get1(2*p,s,(s+e)/2),get1(2*p+1,(s+e)/2+1,e));
}
ll get2(int p,int s,int e){
	if( s>r || e<l)return 0;
	if(s>=l && e<=r)return seg2[p];
	return max(get2(2*p,s,(s+e)/2),get2(2*p+1,(s+e)/2+1,e));
}
int main() {
	scanf("%d%lld",&n,&C);
	for(int i=0;i<n;i++){
		ll x;
		scanf("%lld%d",&x,&cs[i]);
		v.pb(x);
		
	}
	ll sm=0;
	int idx=0;
	for(int i=n-1;i>=0;i--){
		sm+=cs[i];
		ll tmp=sm-(C-v[i]);
		back[idx]=tmp;
		range[i]=idx;
		idx++;
	}
	sm=0;
	for(int i=0;i<n;i++){
		sm+=cs[i];
		ll tmp=sm-v[i];
		front[i]=tmp;
		
	}
	ll ans=0;
	sm=0;
	build(1,0,n-1);
	for(int i=0;i<n;i++){
	sm+=cs[i];
	ll tmp=sm-v[i];
	ans=max(ans,tmp);
	tmp-=v[i];
	if(i!=n-1){
		l=range[n-1];
		r=range[i+1];
		tmp+=get1(1,0,n-1);
	}
	
	ans=max(ans,tmp);
	}
	sm=0;
	for(int i=n-1;i>=0;i--){
		sm+=cs[i];
		ll tmp=sm-(C-v[i]);
		ans=max(ans,tmp);
		tmp-=(C-v[i]);
		if(i!=0){
			l=0,r=i-1;
			tmp+=get2(1,0,n-1);
		}
		ans=max(ans,tmp);
	}
	cout<<ans<<endl;
	
	
	
	
	
}

Measured memory_bytes: 17908
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int a, b, h; cin >> a >> b >> h;
	cout << (a+b)*h/2;
}


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

int main(){
    
    size_t n;
    std::cin >> n;

    std::set<size_t> d;

    for(size_t i = 0; i < n; i++){
        size_t in;
        std::cin >> in;
        d.emplace(in);
    }

    std::cout << d.size() << std::endl;
    
    return 0;
}


Measured memory_bytes: 256
N,A = list(map(int,input().split()))
listA = list(map(int,input().split()))
listB = []
if N >= len(listA):
    print(0)
    exit()
listA.sort()
max_n = listA[-1] - listA[0]
for i in range(A-1):
    listB.append(listA[i+1]-listA[i])
listB.sort(reverse=True)
max_n -= sum(listB[:N-1])
print(max_n)

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

int main(){

  int N;
  int A[210];
  int count = -1;
  bool exist_odd = false;


  //入力値の代入
  cin >> N;
  for (int i = 0; i < N; i++) cin >> A[i];

  //操作が可能な限り繰り返す  
  while (!exist_odd){
      //
      for (int i=0; i < N; ++i){
         if(A[i] % 2 !=0){
           exist_odd = true;
           break;
         }     
      }
      for (int i = 0; i < N; i++){
          A[i] /= 2;
      }
      count++;

  }
  //集計結果の出力
  cout << count;
}

Measured memory_bytes: 256
n=int(input())
a=[[int(i) for i in input().split()] for i in range(n)]
import itertools as it
import math
pe=list(it.permutations(range(n),n))

total=0
for i in pe:
    for x in range(len(i)-1):
        total+=((a[i[x]][0]-a[i[x+1]][0])**2+(a[i[x]][1]-a[i[x+1]][1])**2)**0.5

print(total/math.factorial(n))

Measured memory_bytes: 7972
#include<bits/stdc++.h>
using namespace std;
#define DICE 6
int dice[DICE];
 
void N_move(){
    int temp;
    temp = dice[0]; dice[0] = dice[1]; dice[1] = dice[5]; dice[5] = dice[4]; dice[4] = temp;
}
void E_move(){
    int temp;
    temp = dice[0]; dice[0] = dice[3]; dice[3] = dice[5]; dice[5] = dice[2]; dice[2] = temp;
}
void S_move(){
    int temp;
    temp = dice[0]; dice[0] = dice[4]; dice[4] = dice[5]; dice[5] = dice[1]; dice[1] = temp;
}
void W_move(){
    int temp;
    temp = dice[0]; dice[0] = dice[2]; dice[2] = dice[5]; dice[5] = dice[3]; dice[3] = temp;
}
int main(void){
    for(int i=0; i<6; i++){
        cin >> dice[i];
    }
    string S; cin >> S;
    for(int i=0; i<S.size(); i++){
        if(S[i] == 'N') N_move();
        if(S[i] == 'E') E_move();
        if(S[i] == 'S') S_move();
        if(S[i] == 'W') W_move();
    }
    cout << dice[0] << endl;
             
    return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N,M;
    cin >> N >> M;
    vector<ll> dp(N+1,-1);
    rep(i,M) {
        int a;
        cin >> a;
        dp[a] = 0;
    }
    dp[0] = 1;
    rep(i,N) {
        if (dp[i+1]==0) continue;
        if (i==0) dp[i+1]=dp[i];
        else {
            dp[i+1] = dp[i]+dp[i-1];
            dp[i+1] %= MOD;
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 4008
x = int(input())

if  x < 600:
    print(8)
    exit()
elif x < 800:
    print(7)
    exit()
elif x < 1000:
    print(6)
    exit()
elif x < 1200:
    print(5)
    exit()
elif x < 1400:
    print(4)
    exit()
elif x < 1600:
    print(3)
    exit()
elif x < 1800:
    print(2)
    exit()
else:
    print(1)


Measured memory_bytes: 9180
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  int h, w;
  readf("%s %s\n", &h, &w);

  foreach (i; 0..w+2) {
    write("#");
  }
  writeln("");

  foreach (i; 0..h) {
    auto s = readln.chomp;
    writeln("#", s, "#");
  }

  foreach (i; 0..w+2) {
    write("#");
  }
  writeln("");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#define int long long
using namespace std;

int n;

signed main() {
	int i;
	int ans = 0;
	
	cin >> n;
	for (i = 1; i * i < n; i++) {
		if (n % i == 0 && (n / i - 1 == 0 || n % (n / i - 1) != 0)) {
			ans += n / i - 1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <numeric>
#include <string>
#include <functional>

using namespace std;

int main(void){
    int N,Q;
    cin>>N>>Q;
    vector<pair<int,int>> ab(N-1);
    for(int i=0;i<N-1;i++){
        cin>>ab[i].first>>ab[i].second;
    }
    sort(ab.begin(),ab.end());

    vector<int> p(Q);
    vector<long long> x(Q);
    for(int i=0;i<Q;i++){
        cin>>p[i]>>x[i];
    }
    
    vector<long long> ans(N);
    for(int i=0;i<N;i++){
        ans[i]=0;
    }
    for(int i=0;i<Q;i++){
        ans[p[i]-1]+=x[i];
    }
    for(int i=0;i<N-1;i++){
        ans[ab[i].second-1] += ans[ab[i].first-1];
    }

    for(int i=0;i<N-1;i++){
        cout<<ans[i]<<" ";
    }
    cout<<ans[N-1]<<endl;

    return 0;
}

Measured memory_bytes: 7808
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
//#include<bits/extc++.h>
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define pi acos(-1)
#define index Index
#define Line pll
typedef long long LL;
LL dp[10005][105];
int mod=1e9+7;
int main(){
    char c[100005];
    scanf("%s",c);
    int d;
    scanf("%d",&d);
    int sum=0;
    for(int i=0;c[i]!=0;i++){
        for(int j=0;j<c[i]-'0';j++){
            if(i==0&&j==0)continue;
                dp[i][(sum+j)%d]++;
        }
        sum+=c[i]-'0';
    }
    for(int i=1;c[i]!=0;i++){
        for(int j=1;j<=9;j++){
            dp[i][j%d]++;
        }
    }
    for(int i=0;c[i+1]!=0;i++){
        for(int j=0;j<d;j++){
            dp[i][j]%=mod;
            for(int k=0;k<10;k++){
                dp[i+1][(j+k)%d]+=dp[i][j];
            }
        }
    }
    printf("%d\n",(dp[strlen(c)-1][0]+(sum%d==0))%mod);
}


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

int arr[100001];

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

	int n,k,q,a;
	memset(arr,0,sizeof(arr));

	cin >> n >> k >> q;

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

	for(int i=1;i<=n;i++)
	{
		int score = k - q + arr[i];
		if(score>0)
		{
			cout << "Yes" << '\n';
		}
		else
		{
			cout << "No" << '\n';
		}
	}
	return 0;	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e6+100;
const int mod = 1e9+7;
int occ[upperlimit];
int main() {
//	freopen(".in","r",stdin);freopen(".out","w",stdout);
	ll ans=0;
	int inp,n,q,a,b;
	sd(n);
	for(int i = 1; i <= n; i++){
		sd(inp);
		occ[inp]++;
		ans+=inp;
	}
	sd(q);
	while(q--){
		sd(a);sd(b);
		ll calc=b-a;calc*=occ[a];
		ans+=calc;
		occ[b]+=occ[a];
		occ[a]=0;
		plldn(ans);
	}
	return 0;
}

Measured memory_bytes: 4208
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
int main()
{
     int x,y,z;
     scanf("%d%d%d",&x,&y,&z);
     for(int i=1;;i++)
     {
          int sum=i*y+(i-1)*z+2*z;
          if(sum>x)
          {
               printf("%d\n",i-1);
               break;
          }
     }
     return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

#define true 1
#define false 0
#define N 100

int isApproved(int num[],int n){
	int Ok=0;
	for(int i = 0; i < n; i++){
		if(num[i] % 2 != 0){
			continue;
		}
		if ( (num[i]% 3) != 0 && (num[i]%5) != 0){
			return false;
		}
	}
	return true;
}
int main(){
	int isCorrect = true;
	int *a;
	int n;
	int ans;
	fscanf(stdin,"%d",&n);
	a = (int *)malloc(sizeof(int)*n);
	for(int i = 0; i< n; i++){
		fscanf(stdin,"%d",&a[i]);
	}

	ans = isApproved(a,n);
	if(ans){
		printf("APPROVED\n");
	}
	else{
		printf("DENIED\n");
	}
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i > 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

int main() {
  string o, e, anser = "";
  cin >> o >> e;
  REP(i, e.size()) {
    anser += o[i];
    anser += e[i];
  }
  if (o.size() != e.size()) anser += o[o.size() - 1];
  cout << anser << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from collections import deque
sys.setrecursionlimit(10**7)
k=int(input())
g=[[] for i in range(k)]
for i in range(k):
  g[i].append(((i+1)%k,1))
  if i:
    g[i].append((10*i%k,0))
dq=deque([1])
res=[float('inf')]*k
res[1]=1
while dq:
  v=dq.popleft()
  if v==0:
    break
  for t,cost in g[v]:
    if res[t]<=res[v]+cost:
      continue
    res[t]=res[v]+cost
    if cost:
      dq.append(t)
    else:
      dq.appendleft(t)
print(res[0])

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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  if(n % 2) {
    for(int i = n-1; i >= 0; i -= 2) cout << a[i] << " ";
    for(int i = 1; i < n; i += 2) cout << a[i] << " ";
    cout << endl;
  } else {
    for(int i = n-1; i >= 0; i -= 2) cout << a[i] << " ";
    for(int i = 0; i < n; i += 2) cout << a[i] << " ";
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 2944
n = int(input())
s = list()
for i in range(n):
    s.append(str(input()))
print('AC x '+str(s.count('AC')))
print('WA x '+str(s.count('WA')))
print('TLE x '+str(s.count('TLE')))
print('RE x '+str(s.count('RE')))

Measured memory_bytes: 16224