akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <map>

using namespace std;

map <int, int> mp;

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

    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;

        mp[x]++;
    }

    int m;
    cin >> m;

    bool ans = 1;
    for (int i = 1; i <= m; i++) {
        int x;
        cin >> x;

        int &y = mp[x];

        if (y == 0) ans = 0;
        else y--;
    }

    if (ans == 0) cout << "NO";
    else cout << "YES";

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define mkp make_pair
#define nl cout<<endl
#define MOD 1000000007
#define loop(i,start,end) for(ull i=start;i<end;i++)
#define N 100001
#define all(v) v.begin(),v.end()
#define oa(a,n) for(int i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ov(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" ";nl
int main() 
{
    fastio();
  ll n,w;cin>>n>>w;
  ll a[n+1][2],dp[w+1][n+1];
  loop(i,1,n+1)cin>>a[i][0]>>a[i][1];
  memset(dp,0,sizeof(dp));
  for(int i = 0;i<=w;i++)
  {
    for(int j = 1;j<=n;j++)
    {
      if(i<a[j][0])dp[i][j] = dp[i][j-1];
      else dp[i][j] = max(dp[i][j-1],dp[i-a[j][0]][j-1]+a[j][1]);
    }
  }
  cout<<dp[w][n]<<endl;


  return 0;
}

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

int main(){
    int K, A, B;
    cin >> K >> A >> B;
    int i = K;
    while (true){
        if(i >= A && i <= B && i % K == 0){
            cout << "OK";
            return 0;
        }
        if(i > B){
            cout << "NG";
            return 0;
        }
        i += K;
    }
}

Measured memory_bytes: 3636
object Main{

  def search(str: String): Boolean = {
    var lst = List[Char]()
    str.foreach{ 
      c => c match{
        case '(' => lst = '(' :: lst
        case '[' => lst = '[' :: lst
        case ')' => if(!lst.isEmpty && lst.head == '('){
          lst = lst.tail
        }else{
          return false
        }
        case ']' => if(!lst.isEmpty && lst.head == '['){
          lst = lst.tail
        }else{
          return false
        }
      }
    }
    return lst.isEmpty
  }

  def main(args: Array[String]) = {
    var line = readLine
    while(line != "."){
      val l = line.filter(c=>"()[]".contains(c))
      if( search(l) ){
        println("yes")
      }else{
        println("no")
      }
      line = readLine
    }
  }

}

Measured memory_bytes: 52296
N,M=map(int,input().split())
H=list(map(int,input().split()))
ab = [1]*N
for i in range(M):
    a,b=map(int,input().split())
    a-=1
    b-=1
    if H[a]>H[b]:
        ab[b]=0
    elif H[a]<H[b]:
        ab[a]=0
    else:
        ab[a],ab[b]=0,0
print(sum(ab))

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

int main() {
    int n,k;
    cin>>n>>k;
    ll ans=k*pow(k-1,n-1);
    cout<<ans<<endl;
}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {

	var N int
	fmt.Scanf("%d", &N)

	var count int64
	count = 0

	for i := 1; i <= N; i++ {
		if i%3 == 0 || i%5 == 0 {
			continue
		} else {
			count = count + int64(i)
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 1832
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <math.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const int inf = 1000000000;
const double eps = 1e-7;

void solve() {
	int n, m;
	cin >> n >> m;
	cout << n * (n - 1) / 2 + m * (m - 1) / 2 << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; ++i)
		solve();
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
ii = lambda: int(input())
mis = lambda: map(int,input().split())
lmis = lambda: list(mis())
INF = float('inf')

import itertools as it

def main():
    N=ii()
    L=sorted(lmis(),reverse=True)

    ans=0
    for i in range(N-2):
        a=L[i]
        j=i+1
        k=N-1
        while j<k:
            if a<L[j]+L[k]:
                j+=1
                ans+=k-j+1
            else:
                k-=1
    
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(){
	int k,x;
	cin>>k>>x;
	int l = ((x-k+1)<-1e6? -1e6:(x-k+1));
	int r = ((x+k-1)>1e6? 1e6:(x+k-1));
	for(int i = l; i <= r; i++){
		if(i != l)
			cout<<" ";
		cout<<i;
	} 
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
/* Author: Dhruv Rastogi */
#include<iostream>
#include<algorithm>
#include<set>
#include<vector>
#include<map>
#include<ctime>
#include<string>
#include<random>
#include<ctime>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){ 
    int n;
    cin>>n;
    int od=0;
    rep(i,0,n){
        int x;
        cin>>x;
        if(x%2) ++od;
    }
    if(od%2==0){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    cond = s[2] == s[3] and s[4] == s[5]
    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 2940
# -*- coding: utf-8 -*-
while 1:
    H, W = map(int, input().split())
    if H == 0 and W == 0:
        break
    print("#"*W)
    for i in range(H-2):
        print("#"+"."*(W-2)+"#")
    print("#"*W)
    print()


Measured memory_bytes: 5616
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int a, b, c;
	cin >> a >> b >> c;
	
	if((a <= c && c <= b) ||(b <= c && c <= a))
	{
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
import copy
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    A = map(int, input().split())
    if sum([a * b for a, b in zip(A, B)]) + C > 0:
        ans += 1
print(ans)


Measured memory_bytes: 3444
#pragma region
#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define reps(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; --i)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; --i)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << x << '\n'
#define INF 1e9
using namespace std;
template <class T = int>
T in() {
  T x;
  cin >> x;
  return (x);
}

typedef long long ll;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}

#pragma endregion

int main() {
  int n = in();
  set<string> s;
  rep(i, n) { s.insert(in<string>()); }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 19228
//Keep working hard :)
#include<bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(nullptr); cout.precision(10); cout << fixed;
#define long long long

bool odd(int n)
{
	int cnt = 0;
	while(n)
	{
		cnt++;
		n /= 10;
	}
	return cnt%2 == 1;
}

int main()
{
	IOS;
	#ifdef LOCAL
	freopen("input.txt","rt",stdin);
	freopen("output.txt","wt",stdout);
	#endif

	int n,cnt = 0;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		if(odd(i))
			cnt++;
	}
	cout << cnt <<endl;
	return 0;
}


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

using namespace std;

const int maxn=1e5+5;

#define BOTTOM 0
#define LEFT 1
#define RIGHT 2
#define TOP 3

struct point{
    double x,y;
    point(){}
    point(double x,double y):x(x),y(y){}
    point operator + (point &p){
        return point(x+p.x,y+p.y);
    }
    point operator - (point &p){
        return point(x-p.x,y-p.y);
    }
    point operator * (double k){
        return point(x*k,y*k);
    }
    point operator / (double k){
        return point(x/k,y/k);
    }
};

struct segment{
    point p1,p2;
};

struct endpoint{
    point p;
    int seg,st;
    endpoint(){}
    endpoint(point p,int seg,int st):p(p),seg(seg),st(st){}
    bool operator < (const endpoint &ep)const{
        if(p.y==ep.p.y){
            return st<ep.st;//y相同时，按照下断点，左端点，右端点，上端点的顺序排列
        }else{
            return p.y<ep.p.y;
        }
    }
};
endpoint ep[2*maxn];

int manhattanIntersection(vector<segment>s)
{
    int n=s.size();
    for(int i=0,k=0;i<n;i++){
        if(s[i].p1.y==s[i].p2.y){
            if(s[i].p1.x>s[i].p2.x){
                swap(s[i].p1,s[i].p2);
            }
        }else if(s[i].p1.y>s[i].p2.y){
            swap(s[i].p1,s[i].p2);
        }
        if(s[i].p1.y==s[i].p2.y){
            ep[k++]=endpoint(s[i].p1,i,LEFT);
            ep[k++]=endpoint(s[i].p2,i,RIGHT);
        }else{
            ep[k++]=endpoint(s[i].p1,i,BOTTOM);
            ep[k++]=endpoint(s[i].p2,i,TOP);
        }
    }
    sort(ep,ep+(2*n));
//    for(int i=0;i<2*n;i++){
//        cout<<ep[i].p.x<<" "<<ep[i].p.y<<endl;
//    }
//    cout<<endl;
    set<int>bt;
    bt.insert(1000000001);
    int cnt=0;
    for(int i=0;i<2*n;i++){
        if(ep[i].st==TOP){
            bt.erase(ep[i].p.x);
        }else if(ep[i].st==BOTTOM){
            bt.insert(ep[i].p.x);
        }else if(ep[i].st==LEFT){
            set<int>::iterator b=bt.lower_bound(s[ep[i].seg].p1.x);
            set<int>::iterator e=bt.upper_bound(s[ep[i].seg].p2.x);
            cnt+=distance(b,e);
        }
    }
    return cnt;
}

int main()
{
    int n;
    cin>>n;
    vector<segment>s;
    segment temp;
    for(int i=0;i<n;i++){
        cin>>temp.p1.x>>temp.p1.y>>temp.p2.x>>temp.p2.y;
        s.push_back(temp);
    }
    int res=manhattanIntersection(s);
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 16548
#include <bits/stdc++.h>
using namespace std;
using str = string;
using ll = long long;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define RREP(i,n) for(int i=int(n)-1; i>=0; i--)
#define FOR(i,f,t) for(int i=int(f); i<=int(t); i++)
#define RFOR(i,f,t) for(int i=int(f); i>=int(t); i--)
#define ALL(vec) (vec).begin(),(vec).end()
#define ASORT(vec) sort(ALL(vec))
#define DSORT(vec) sort(ALL(vec), greater<int>());
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define YES(ans) if(ans) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define Yes(ans) if(ans) cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define yes(ans) if(ans) cout<<"yes"<<endl; else cout<<"no"<<endl;
#define INF 1000000000000
#define NOD 1000000007
#define PI 3.141592653589793238462643

int main() {
    int n, m;
    cin >> n >> m;
    cout << n*(n-1)/2+m*(m-1)/2;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            var list = new List<int>();
            for (int i = 0; i < n; i++) list.Add(int.Parse(Console.ReadLine()));
            int ans = list.Sum();
            if (ans % 10 == 0)
            {
                list = list.Where(x => x % 10 != 0).OrderBy(x => x).ToList();
                ans = list.Any() ? ans - list.First() : 0;
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13396
from collections import deque


n, q = map(int, input().split())
info = [list(map(int, input().split())) for i in range(n-1)]
p = [list(map(int, input().split())) for i in range(q)]

tree = [[] for i in range(n)]
for i in range(n-1):
    tree[info[i][0] - 1].append(info[i][1] - 1)
    tree[info[i][1] - 1].append(info[i][0] - 1)

memo = {}
for i in range(n):
    memo[i] = 0
for i in range(q):
    memo[p[i][0] - 1] += p[i][1]

dp = [0] * n
visited = [False]*n
q = deque([0])
visited[0] = True
dp[0] = memo[0]

while q:
    pos = q.popleft()
    for next_pos in tree[pos]:
        if visited[next_pos]:
            continue
        visited[next_pos] = True
        dp[next_pos] += dp[pos] + memo[next_pos]
        q.append(next_pos)
print(*dp)

Measured memory_bytes: 136360
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

#define YES(n) cout << (n?"YES":"NO")<<endl;
#define Yes(n) cout << (n?"Yes":"No")<<endl;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A == B)cout << C << endl;
    else if (B == C)cout << A << endl;
    else cout << B << endl;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,ans=1e9+7;cin>>n;
  lvector X(n,0);rep(i,n) cin>>X[i];
  for(ll i=1;i<=100;++i) {
    ll ans_=0;
    rep(j,n) ans_+=(X[j]-i)*(X[j]-i);
    ans=min(ans,ans_);
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import numpy as np
A, B, H, M = [int(i) for i in input().split(" ")]

T = H * 3600 + M * 60

oA = T / (12 * 3600)
oB = T / 3600
oA = (oA - int(oA)) * 2 * np.pi
oB = (oB - int(oB)) * 2 * np.pi

# print(oA)
# print(oB)
# print(np.degrees(oA - oB))
diff = np.abs(oA - oB)
if diff > np.pi:
  t = 2 * np.pi - diff
else:
  t = diff
print(np.sqrt(B**2 + A**2 - 2 * A * B * np.cos(t)))

Measured memory_bytes: 27264
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,h,w;
  cin>>n>>h>>w;
  vector<Int> a(n),b(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i];
  Int ans=0;
  for(Int i=0;i<n;i++) ans+=a[i]>=h&&b[i]>=w;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	return n
}

func main() {
	sc.Split(bufio.ScanWords)

	a, b, c, d, e := nextInt(), nextInt(), nextInt(), nextInt(), nextInt()
	x := a
	if b < x {
		x = b
	}
	if c < x {
		x = c
	}
	y := d
	if e < y {
		y = e
	}

	fmt.Println(x + y - 50)
}



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

int main() {
	int q,w,e,r,t;
	cin>>q>>w>>e>>r>>t;
	if(q==0){cout<<1;}
	else if(w==0){cout<<2;}
	else if(e==0){cout<<3;}
	else if(r==0){cout<<4;}
	else if(t==0){cout<<5;}
	return 0;
}


Measured memory_bytes: 3636
n = int(input())
a = [input() for _ in range(n)]

l = []
for s in ['S', 'H', 'C', 'D']:
    for i in range(1, 14):
        l.append(s + ' ' + str(i))

for i in range(n):
    l.remove(a[i])

if l:print(*l, sep='\n')


Measured memory_bytes: 5604
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9+7;
const ll LLINF = 7e18;
using namespace std;

long double x[1000], y[1000];

pair<long double, long double> get_mid(int a1, int a2, int a3){
	long double mid_x = ((x[a2]-x[a3])*(x[a2]+x[a3])*(y[a2]-y[a1]) - (x[a1]-x[a2])*(x[a1]+x[a2])*(y[a3]-y[a2]))/(2*((x[a2]-x[a3])*(y[a2]-y[a1])-(x[a1]-x[a2])*(y[a3]-y[a2]))) + (y[a1]-y[a3])*(y[a3]-y[a2])*(y[a2]-y[a1])/(2*((x[a2]-x[a3])*(y[a2]-y[a1])-(x[a1]-x[a2])*(y[a3]-y[a2])));
	long double mid_y = (x[a1]-x[a2])/(y[a2]-y[a1])*(mid_x-(x[a1]+x[a2])/2) + (y[a1]+y[a2])/2;
	return make_pair(mid_x, mid_y);
}

long double get_abs(pair<long double, long double> p, int a){
	return (p.first - x[a])*(p.first - x[a]) + (p.second - y[a])*(p.second - y[a]);
}

int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> x[i] >> y[i];
	}
	if (n == 2){
		cout << setprecision(10) << sqrt((x[0] - x[1])*(x[0] - x[1]) + (y[0] - y[1])*(y[0] - y[1]))/2 << endl;
		return 0;
	}
	long double ans = MOD;
	for (int i = 0; i < n; i++){
		for (int j = 0; j < n; j++){
			for (int k = 0; k < n; k++){
				pair<long double, long double> p;
				if ((y[i] == y[j] && y[j] == y[k]) || (x[i] == x[j] && x[j] == x[k])){
					p = make_pair((max(x[i], max(x[j], x[k]))+min(x[i], min(x[j], x[k])))/2, (max(y[i], max(y[j], y[k]))+min(y[i], min(y[j], y[k])))/2);
				}else if(y[i] == y[j]){
					p = get_mid(i, k, j);
				}else if(y[j] == y[k]){
					p = get_mid(j, i, k);
				}else{
					if (x[i] == x[j] || x[j] == x[k]) p = get_mid(i, j, k);
					else if ((y[j]-y[i])/(x[j]-x[i]) == (y[k]-y[j])/(x[k]-x[j])) p = make_pair((max(x[i], max(x[j], x[k]))+min(x[i], min(x[j], x[k])))/2, (max(y[i], max(y[j], y[k]))+min(y[i], min(y[j], y[k])))/2);
					else p = get_mid(i, j, k);
				}
				auto q = get_mid(i, j, k);
				long double rr = max(get_abs(p, i), max(get_abs(p, j), get_abs(p, k)));
				int coun = 0;
				for (int l = 0; l < n; l++){
					if (get_abs(p, l) <= rr + 0.1) coun++;
				}
				if (coun == n){
					ans = min(ans, sqrt(rr));
				}
			}
		}
	}
	cout << setprecision(10) << ans << endl;
	return 0;
}

Measured memory_bytes: 3740
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(M)]
from operator import itemgetter
BC.sort(key=itemgetter(1), reverse=True)

for b, c in BC:
  A += [c]*b
  if len(A) > 2*N:
    break

A.sort(reverse=True)
print(sum(A[:N]))


Measured memory_bytes: 34884
#include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
class Graph 
{ 
    int V;    
    list<int> *adj;    
public: 
    Graph(int V);  // Constructor 
  
    // function to add an edge to graph 
    void addEdge(int v, int w);  
  
    // prints BFS traversal from a given source s 
    void BFS(int s);   
}; 
  
Graph::Graph(int V) 
{ 
    this->V = V; 
    adj = new list<int>[V]; 
} 
  
void Graph::addEdge(int v, int w) //How to add edge
{ 
    adj[v].push_back(w); 
} 
  
void Graph::BFS(int s) //BFS 
{ 
   
    bool *visited = new bool[V]; 
    for(int i = 0; i < V; i++) 
        visited[i] = false; 
 
    list<int> queue; 
    visited[s] = true; 
    queue.push_back(s); 
    list<int>::iterator i; 
  
    while(!queue.empty()) 
    { 
        s = queue.front(); 
        cout << s << " "; 
        queue.pop_front(); 
  
        for (i = adj[s].begin(); i != adj[s].end(); ++i) 
        { 
            if (!visited[*i]) 
            { 
                visited[*i] = true; 
                queue.push_back(*i); 
            } 
        } 
    } 
} //To create a graph
//Graph g(4); 
    //g.addEdge(0, 1); 
    //g.addEdge(0, 2); 
int gcd(int x, int y) {
        if (x == 0) {
            return y;
        }
        
        return gcd(y % x, x);
    }
ll factorial(ll a)
{
  ll fact[a+1];
  fact[0]=1;
  fact[1]=1;
  for(int i=2;i<=a;i++)
  fact[i]=fact[i-1]*i;
  return fact[a];
  
}
bool isPali(string s)
{
    string copy=s;
    reverse(s.begin(),s.end());
    if(s.compare(copy)!=0)
    return false;
    return true;
    
}

int main()
{
 string s;
 cin>>s;int n=s.size();
 string s1=s.substr(0,(n-1)/2);
 string s2=s.substr(((n+3)/2)-1,n-(n+3)/2+1);
 if(isPali(s) && isPali(s1) && isPali(s2))
 cout<<"Yes\n";
 else
 cout<<"No\n";
 
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
	int i;
	int n;
	long long sum;
	
	cin >> n;
	vector<long long> v(n);

	for (i = 0;i < n;i++) {
		cin >> v[i];
	}
	sort(v.rbegin(), v.rend());
	sum = v[0];
	double k = 1;
	for (i = 2;i < n;i++) {
		sum += v[(int)k];
		k += 0.5;
	}
		
	cout << sum;
}

Measured memory_bytes: 4852
#include<stdio.h>

int main(){
    char s[100];
    scanf("%s",s);
    for(int i=0;i<100;i++){
        if(s[i]=='\0')break;
        if(i%2==0){//kisuu
            if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
                printf("No\n");
                return 0;
            }
        }else{//guusuu
            if(s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}

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

const int maxn = 100005;

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

  int n;
  cin >> n;
  vector < int > cnt(maxn, 0);
  for (int i = 0; i < n; ++i) {
    int x;
    cin >> x;
    ++cnt[x];
  }
  int bad = 0;
  for (int i = 0; i < maxn; ++i) {
    if (cnt[i])
      bad += cnt[i] - 1;
  }
  cout << n - 2 * ((bad + (bad % 2)) / 2) << '\n';
}

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

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

    if(s.find('a') == string::npos) {
        cout << "No" << endl;
    }else{
        if(s.find('b') == string::npos){
            cout << "No" << endl;
        }else{
            if(s.find('c') == string::npos){
                cout << "No" << endl;
            }else{
                cout << "Yes" << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    static final long MOD = (1000000000L+7L);
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        long r = 0L;
        for(long t=K; t<=N+1; t++) {
            long tmp = t*N-t*(t-1)+1;
//            System.out.println(String.format("t=%d, tmp=%d", t, tmp));
            r=(r + tmp) % MOD;
        }
        System.out.println(r);
    }
}


Measured memory_bytes: 35844
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
#define INF 1000000000
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t)
{
    std::ostringstream os;
    os << t;
    return os.str();
}
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int main()
{
    int n, a, b;
    cin >> n >> a >> b;
    int ans;
    if (a + b <= n)
    {
        ans = 0;
    }
    else
    {
        ans = (a + b - n);
    }
    cout << min(a, b) << " " << ans << endl;
    return 0;
}

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

using namespace std;

int main(void) {
    string S;
    cin >> S;

    if (S[0] != 'A') {
        cout << "WA" << endl;
        return 0;
    }

    int count = 0;
    int C_index;
    for (int i = 2; i < S.size()-1; i++) {
        if (S[i] == 'C') {
            count++;
            C_index = i;
        }
    }
    if (count != 1) {
        cout << "WA" << endl;
        return 0;
    }

    for (int i = 1; i < S.size(); i++) {
        if (i == C_index) {
            continue;
        }
        if ('a' > S[i] || S[i] > 'z') {
            cout << "WA" << endl;
            return 0;
        }
    }

    cout << "AC" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)

int n,m,q;
vector<vector<int> > g;
vector<int> p;
vector<int> res;


int main(){
    cin >> n >> m;
    g.resize(n);
    p.resize(n,-1);
    res.resize(n);
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    cin >> q;
    vector<pair<int,pair<int,int> > > query;
    rep(i,q){
        int v,d,c;
        cin >> v >> d >> c;
        v--;
        query.push_back(MP(v,MP(d,c)));
    }
    reverse(query.begin(),query.end());
    rep(i,q){
        int vv = query[i].first;
        int dd = query[i].second.first;
        int c = query[i].second.second;
        queue<pair<int,int> > que;
        que.push(MP(vv,dd));
        while(!que.empty()){
            auto x = que.front();
            que.pop();
            int v = x.first;
            int d = x.second;
            if(p[v]>=d)continue;
            p[v] = d;
            if(res[v]==0)res[v] = c;
            if(d==0)continue;
            for(auto y:g[v]){
                if(p[y]<d-1){
                    que.push(MP(y,d-1));
                }
            }
        }
        
    }
    rep(i,n)cout << res[i] << endl;
    return 0;
}

Measured memory_bytes: 10992
#include <iostream>
#include <algorithm>
using namespace std;
int n,t,e,a[100005];
long long f[100005];
int main(){
	cin>>n>>e>>t;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	long long cur=1e18;
	for(int i=1,l=1;i<=n;i++){
		while(2*(a[i]-a[l])>=t){
			cur=min(cur,f[l-1]-2*a[l]);
			l++;
		}
		f[i]=min(f[l-1]+t,cur+2*a[i]);
	}
	cout<<f[n]+e<<endl;
	return 0;
}

Measured memory_bytes: 1408
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>

int main() {
	int i, j, k, n, x, cnt = 0;
	while (1) {
		scanf("%d%d", &n, &x);
		if (!(n + x)) break;
		cnt = 0;
		for (i = 1; i <= n; i++)for (j = i + 1; j <= n; j++)for (k = j + 1; k <= n; k++) if (i + j + k == x) cnt++;	
		printf("%d\n", cnt);
	}
	
	return 0;
}

Measured memory_bytes: 600
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let mut n: i32 = read();
    let odd_count: i32 = if n % 2 == 0 { n / 2 } else { n / 2 + 1 };

    let probability: f64 = odd_count as f64 / n as f64;

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


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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int Ab[30][200010], Bb[30][200010];
int SUM[30];

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

	cin >> N;
	int A, B;
	rep(i, 0, N)
	{
		cin >> A;
		int b = 2;
		rep(d, 0, 30)
		{
			Ab[d][i] = A % b;
			b *= 2;
		}
	}
	rep(i, 0, N)
	{
		cin >> B;
		int b = 2;
		rep(d, 0, 30)
		{
			Bb[d][i] = B % b;
			b *= 2;
		}
	}

	rep(d, 0, 30)
	{
		sort(Ab[d], Ab[d] + N);
	}

	int b = 1;
	rep(d, 0, 30)
	{
		rep(i, 0, N)
		{
			int x = lower_bound(Ab[d], Ab[d] + N, b - Bb[d][i]) - Ab[d];
			int y = lower_bound(Ab[d], Ab[d] + N, 2 * b - Bb[d][i]) - Ab[d];
			int z = lower_bound(Ab[d], Ab[d] + N, 3 * b - Bb[d][i]) - Ab[d];
			SUM[d] += (y - x) + (N - z);
		}
		b *= 2;
	}

	int ans = 0;
	b = 1;
	rep(d, 0, 30)
	{
		if (SUM[d] % 2 == 1)
		{
			ans += b;
		}
		b *= 2;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 94080
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll a,b;
  cin >> a >> b;
  cout << 100 << " " << 100 << endl;
  vector<string> ans(100);
  for(ll i=0;i<50;i++) {
    string s;
    for(ll i=0;i<100;i++) {
      s+='#';
    }
    ans[i]=s;
  }
  for(ll i=0;i<50;i++) {
    string s;
    for(ll i=0;i<100;i++) {
      s+='.';
    }
    ans[i+50]=s;
  }
  a--;
  b--;
  for(ll i=0;i<50&&a>0;i+=2) {
    for(ll j=0;j<100&&a>0;j+=2) {
      ans[i][j]='.';
      a--;
    }
  }
  for(ll i=51;i<100&&b>0;i+=2) {
    for(ll j=0;j<100&&b>0;j+=2) {
      ans[i][j]='#';
      b--;
    }
  }
  for(ll i=0;i<100;i++) {
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;

//上無限
const long long Inf = 1LL << 60;

//下無限
const long long MInf = -(Inf);

#define tmax(n,l,m) std::max(n,std::max(l,m))

//2要素比較して小さいほうを第一引数に代入
template <class T> inline bool chmin(T&a,T b);
//2要素比較して大きいほうを第一引数に代入
template <class T> inline bool chmax(T&a,T b);


long long dp[100010][3];
int main()
{
    int N;
    cin >> N;
    long long a[100010][3];
    for(int i = 0; i < N;i++)
    {
        for(int j = 0;j < 3;j++)
        {
            cin >> a[i][j];
        }
    }
    for(int i = 0;i < N;++i)
    {
        for(int j = 0;j < 3;++j)
        {
            for(int k = 0; k < 3;++k)
            {
                if(j != k)
                    chmax(dp[i + 1][k],dp[i][j] + a[i][k]);
            }
        }
    }
    cout << tmax(dp[N][0],dp[N][1],dp[N][2]) <<endl;;
}



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;
}

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

int main(void){
    // input
    int H, W; cin >> H >> W;
    vector<string> maze(H);
    rep(i,H) cin >> maze[i];

    // initialization
    int sx = 0, sy = 0;
    int gx = H-1, gy = W-1;
    P p; p.first = sx; p.second = sy;
    queue<P> que;
    que.push(p);

    // 上下左右
    int dx[4] = { 0, 0,-1,+1};
    int dy[4] = {+1,-1, 0, 0};

    // 距離を管理
    // 中身を-1で初期化
    vector<vector<int> > dist(52, vector<int>(52, -1));
    dist[sx][sy] = 0;
    int count = 0;
    rep(i,H){
        rep(j,W) if(maze[i][j] == '#' )count++ ;
    }


    while(!que.empty()){
        P v = que.front();
        que.pop();
        
        if(v.first == gx && v.second == gy) break;

        rep(i,4) {
            int nx = v.first + dx[i];
            int ny = v.second + dy[i];
            if (nx < 0 || ny < 0 || nx >= H || ny >= W) continue;
            if (maze[nx][ny] == '#') continue;
            if (dist[nx][ny] != -1) continue;
            dist[nx][ny] = dist[v.first][v.second] + 1;
            P p; p.first = nx; p.second = ny;
            que.push(p);
        }
    }

    int ans = 0;
    int sum = 0;

    // 到達不可能
    if (dist[H-1][W-1] == -1) {
        cout << "-1" << endl;
        return 0;
    }

    cout << H * W - dist[H-1][W-1] - count - 1  << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = gets.split.map(&:to_i)
ways = M.times.map { gets.split.map(&:to_i) }
grouped_ways = ways.group_by { |way| way[0] }.map { |k, v| [k, v.map { |vv| vv[1]}] }.to_h
start, goal = gets.split.map(&:to_i)

history = [start]
already_visits = Array.new(N + 1, false)
already_visits[start] = true

counter = 0
success_cost = -1
while !history.empty?
  3.times do
    target_ways = history.flat_map do |now_place|
      grouped_ways[now_place]
    end
    history = target_ways.uniq.compact
  end
  history = history.reject do |place|
    already_visits[place]
  end
  history.each do |place|
    already_visits[place] = true
  end

  counter += 1
  if history.include?(goal)
    success_cost = counter
    break
  end
end

p success_cost

Measured memory_bytes: 58340
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Numerics;

namespace abc168
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
            if (File.Exists("input.txt"))
            {
                Console.SetIn(new StreamReader("input.txt"));
            }
            solve_abc168B();
            Console.Out.Flush();
        }

        public static void solve_abc168B()
        {
            int k = Convert.ToInt32(Console.ReadLine());
            string s = Console.ReadLine();
            if (s.Length > k)
            {
                Console.WriteLine(s.Substring(0, k) + "...");
            }
            else
            {
                Console.WriteLine(s);
            }

        }

        public static void solve_abc168A()
        {
            string hon = "24579";
            string pon = "0168";
            string n = Console.ReadLine();
            if (hon.Contains(n.Substring(n.Length - 1, 1)))
            {
                Console.WriteLine("hon");
            }
            else if (pon.Contains(n.Substring(n.Length - 1, 1)))
            {
                Console.WriteLine("pon");
            }
            else
            {
                Console.WriteLine("bon");
            }
        }
        
        public static int binSearchLeft(int[] a, int x)
        {
            int l = 0;
            int r = a.Length - 1;
            while (r - l > 1)
            {
                int m = (r + l) / 2;
                if (a[m] < x)
                {
                    l = m + 1;
                }
                else
                {
                    r = m;
                }
            }
            return l;
        }        
    }
}

Measured memory_bytes: 28500
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;




int main(){
    
    string S; cin >> S;
    ll K; cin >> K;

    char ans;
    rep(i,S.size()){
        if (S[i] != '1') {
            ans = S[i];
            break;
        }
        if (K-1 == i){
            ans = S[i];
            break;
        }
    }
    
    cout << ans << endl;
}



Measured memory_bytes: 3580
def partition(num_list, start, end):
    split = start -1
    x = int(num_list[end][1])
    for i in range(start, end):
        if int(num_list[i][1]) <= x:
            split += 1
            num_list[split], num_list[i] = num_list[i], num_list[split]
    num_list[split+1], num_list[end] = num_list[end], num_list[split+1]
    return split+1

def quickSort(num_list, start, end):
    if start < end:
        q = partition(num_list, start, end)
        quickSort(num_list, start, q-1)
        quickSort(num_list, q+1, end)

import sys, copy
n = int(input())
input_list = [sys.stdin.readline().rstrip().split() for i in range(n)]
check_list = copy.deepcopy(input_list)
quickSort(input_list, 0, n-1)
for i in range(n-1):
    if input_list[i][1] == input_list[i+1][1]:
        if check_list.index(input_list[i]) > check_list.index(input_list[i+1]):
            print('Not stable')
            break
else:
    print('Stable')
for i in input_list:
    print('{} {}'.format(i[0], i[1]))


Measured memory_bytes: 49796
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(ALL(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e5 + 5;

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin >> s;
    map<char, int> mp;
    for(auto &c : s){
        mp[c]++;
    }
    vector<int> v = {mp['a'], mp['b'], mp['c']};
    sort(ALL(v));
    if(v[2] - v[1] <= 1 && v[1] - v[0] <= 1 && v[2] - v[0] <= 1){
        cout << "YES";
    }else{
        cout << "NO";
    }
    return 0;
}
/*
    *** Most Impo.. -> check base case always
    1. Overflow Check (*, +)
    2. Index check (0 - based or 1 - based)
    3. Check for n = 1, 2, 3, 4....
    4. Corner Cases
*/

Measured memory_bytes: 512
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int k,a,b,flag=0;
	cin>>k>>a>>b;
	int i;
	for(i=a;i<=b;i++)
	{
	    if(i%k==0)
	  {  flag=1;
	    break;
	  }
	}
	if(flag==1)
	cout<<"OK";
	else
	cout<<"NG";
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

/////////////////////////////////////
ll N, M, K;

vll id;

vll con(vll a,vll b){
	vll ret(N);
	repn(i, N-1)ret[i] = a[b[i]];
	return ret;
}

vll cc(vll a, ll t) {
	if (t == 0) { return id; }
	vll c = cc(a, t / 2);

	vll ret = con(c, c);
	if (t % 2 == 1)ret = con(ret, a);
	return ret;
}

int main() {
	cin >> N;
	vll x(N + 1);
	repn(i, N)cin >> x[i];
	cin >> M >> K;
	vll a(M + 1);
	repn(i, M)cin >> a[i];

	id.resize(N);
	repn(i, N - 1)id[i] = i;

	vll c = id;
	repn(i, M) {
		swap(c[a[i] - 1], c[a[i]]);
	}
	//repn(i, N - 1)cout << c[i]<<" ";
	//cout << endl;

	c = cc(c, K);
	//repn(i, N - 1)cout << c[i] << " ";
	//cout << endl;

	vll d(N);
	repn(i, N - 1) { d[i] = x[i + 1] - x[i]; }
	vll newd(N);
	repn(i, N - 1) { newd[i] = d[c[i]]; }
	//repn(i, N - 1)cout << newd[i] << " ";
	//cout << endl;

	vll ans(N + 1);
	ans[1] = x[1];
	repn(i, N - 1)ans[i + 1] = ans[i] + newd[i];
	repn(i, N)cout << ans[i] << endl;

}


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

using namespace std;
#define INF 1000007
#define MOD 1000000007
#define maxn 101
#define maxh 1001
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
const int dx[4] = {0, 1, -1, 0}, dy[4] = {1, 0, 0, -1};
typedef std::pair<int, int> P;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void) {
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++) {
        if (!prime[i]) {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i) {
            prime[j] = false;
        }
    }
}

int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b) { return a / gcd(a, b) * b; }

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2) {
        if (num % i == 0) {
            return false;
        }
    }

    return true;
}

vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i - 1);
            if (i * i != n) {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}

int a, b;

void f(int x) {
    while (x) {
        a++;
        b = x;
        x /= 10;
    }
}

signed main() {
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    bool AB[3];
    fill(AB, AB + 3, true);
    AB[A] = false;
    AB[B] = false;
    rep(i, 3) {
        if (AB[i]) {
            cout << i + 1 << endl;
        }
    }

}



Measured memory_bytes: 256
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  int a[n];
  int b[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    b[i] = a[i];
    while (b[i] % 2 == 0) {
      b[i] /= 2;
    }
  }
  for (int i = 1; i < n; i++) {
    if (a[i] / b[i] != a[i - 1] / b[i - 1]) {
      cout << "0\n";
      return 0;
    }
  }
  int lcm = b[0];
  for (int i = 1; i < n; i++) {
    lcm = b[i] * lcm / __gcd(b[i], lcm);
    if (lcm > 2e9) {
      cout << "0\n";
      return 0;
    }
  }
  if (a[0] != b[0]) lcm *= a[0] / b[0] / 2;
  cout << (m / lcm) - (m / (2 * lcm)) << "\n";
}



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

using namespace std;

#define forn(i0, n0) for (int i0 = 0; i0 < n0; i0++)
#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvl (v) for (ll x : v) cout << x << ' '; cout << '\n'
#define ff first
#define ss second
#define all(a) (a).begin(), (a).end()
#define Sort(a) sort(all(a))
#define Reverse reverse (all(a))

typedef long long ll;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    ll k;
    cin >> k;
    if (k < 10) {
        cout << k << endl;
        return 0;
    }
    vector <vll> d(11, vll());
    for (int i = 1; i < 10; i ++) {
        d[1].emplace_back(i);
    }
    ll c = 9;
    ll u = 0;
    for (int i = 2; i < 12; i ++) {
        for (int j = 0; j < d[i - 1].size(); j ++) {
            u = d[i - 1][j] * 10 + d[i - 1][j] % 10;
            if (d[i - 1][j] % 10 == 0) {
                d[i].emplace_back(u); c ++;
                if (c == k) {
                    cout << d[i][d[i].size() - 1];
                    return 0;
                }
                d[i].emplace_back(u + 1); c ++;
                if (c == k) {
                    cout << d[i][d[i].size() - 1];
                    return 0;
                }
            }
            else if (d[i - 1][j] % 10 == 9) {
                d[i].emplace_back(u - 1); c ++;
                if (c == k) {
                    cout << d[i][d[i].size() - 1];
                    return 0;
                }
                d[i].emplace_back(u); c ++;
                if (c == k) {
                    cout << d[i][d[i].size() - 1];
                    return 0;
                }
            }
            else {
                d[i].emplace_back(u - 1); c ++;
                if (c == k) {
                    cout << d[i][d[i].size() - 1];
                    return 0;
                }
                d[i].emplace_back(u); c ++;
                if (c == k) {
                    cout << d[i][d[i].size() - 1];
                    return 0;
                }
                d[i].emplace_back(u + 1); c ++;
                if (c == k) {
                    cout << d[i][d[i].size() - 1];
                    return 0;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

int main(void){
  vector<pair<int, int>> a(5);
  for (int i = 0; i < 5; i++){
    cin >> a[i].second;
    a[i].first = a[i].second % 10;
    if (a[i].first == 0)
      a[i].first = 10;
  }
  sort(a.begin(), a.end());


  int t = 0;
  for (int i = 1; i < 5; i++){
    t += a[i].second;
    t += 10 - a[i].first;
  }

  cout << t + a[0].second << endl;

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256