akhauriyash/Code-Regression huggingface dataset:
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<vector>
#define MN 100000
#define N 131072
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
long long ans;
vector<pair<int,int> > v[2][MN*2+5];
int n,a,b,x[MN+5],y[MN+5],D,num1,num2,res[MN+5],q[MN+5],top;
long long L1[MN*2+5],L2[MN*2+5];
inline int Abs(int x){return x<0?-x:x;}
inline int Check(const vector<pair<int,int> >&s,int l,int r)
{
	return upper_bound(s.begin(),s.end(),make_pair(r,n+1))
		  -lower_bound(s.begin(),s.end(),make_pair(l,0));	
}
void Del(int i)
{
	int s=lower_bound(L1+1,L1+num1+1,1LL*x[i]+y[i])-L1;
	if(s<=num1&&L1[s]==x[i]+y[i]) v[0][s].erase(lower_bound(v[0][s].begin(),v[0][s].end(),make_pair(x[i],i)));
	int S=lower_bound(L2+1,L2+num2+1,1LL*y[i]-x[i])-L2;
	if(S<=num2&&L2[S]==y[i]-x[i]) v[1][S].erase(lower_bound(v[1][S].begin(),v[1][S].end(),make_pair(x[i],i)));	
}
#define G() lower_bound(s.begin(),s.end(),make_pair(l,0))-s.begin()
void Find(const vector<pair<int,int> >&s,int l,int r)
{
	for(int i=G();i<s.size()&&s[i].first<=r;i=G())
		q[++top]=s[i].second,Del(s[i].second);
}
int main()
{
	n=read();a=read();b=read();
	for(int i=1;i<=n;++i) x[i]=read(),y[i]=read();
	D=Abs(x[a]-x[b])+Abs(y[a]-y[b]);
	for(int i=1;i<=n;++i)
	{
		L1[++num1]=1LL*x[i]+y[i]-D;L1[++num1]=1LL*x[i]+y[i]+D;
		L2[++num2]=1LL*y[i]-x[i]-D;L2[++num2]=1LL*y[i]-x[i]+D;
	} 
	sort(L1+1,L1+num1+1);num1=unique(L1+1,L1+num1+1)-L1-1;
	sort(L2+1,L2+num2+1);num2=unique(L2+1,L2+num2+1)-L2-1;
	for(int i=1;i<=n;++i)
	{
		int s=lower_bound(L1+1,L1+num1+1,1LL*x[i]+y[i])-L1;
		if(s<=num1&&L1[s]==x[i]+y[i]) v[0][s].push_back(make_pair(x[i],i));
		int S=lower_bound(L2+1,L2+num2+1,1LL*y[i]-x[i])-L2;
		if(S<=num2&&L2[S]==y[i]-x[i]) v[1][S].push_back(make_pair(x[i],i));
	}
	for(int i=1;i<=num1;++i) sort(v[0][i].begin(),v[0][i].end());
	for(int i=1;i<=num2;++i) sort(v[1][i].begin(),v[1][i].end());
	for(int i=1;i<=n;++i) 
	{
		int a=lower_bound(L1+1,L1+num1+1,1LL*x[i]+y[i]-D)-L1;
		res[i]+=Check(v[0][a],x[i]-D+1,x[i]);
		int b=lower_bound(L1+1,L1+num1+1,1LL*x[i]+y[i]+D)-L1;
		res[i]+=Check(v[0][b],x[i],x[i]+D-1);
		int c=lower_bound(L2+1,L2+num2+1,1LL*y[i]-x[i]+D)-L2;
		res[i]+=Check(v[1][c],x[i]-D,x[i]-1);
		int d=lower_bound(L2+1,L2+num2+1,1LL*y[i]-x[i]-D)-L2;
		res[i]+=Check(v[1][d],x[i]+1,x[i]+D);
	}
	q[top=1]=a;q[top=2]=b;Del(a);Del(b);
	for(int j=1;j<=top;++j)
	{
		int i=q[j];ans+=res[i];
		int a=lower_bound(L1+1,L1+num1+1,1LL*x[i]+y[i]-D)-L1;
		Find(v[0][a],x[i]-D+1,x[i]);
		int b=lower_bound(L1+1,L1+num1+1,1LL*x[i]+y[i]+D)-L1;
		Find(v[0][b],x[i],x[i]+D-1);
		int c=lower_bound(L2+1,L2+num2+1,1LL*y[i]-x[i]+D)-L2;
		Find(v[1][c],x[i]-D,x[i]-1);
		int d=lower_bound(L2+1,L2+num2+1,1LL*y[i]-x[i]-D)-L2;
		Find(v[1][d],x[i]+1,x[i]+D);
	}
	cout<<ans/2;
	return 0;
}

Measured memory_bytes: 18176
#include <iostream>
#include <string>
using namespace std;
int main(){

    char ch;
    int alp[26];
    char all[]="abcdefghijklmnopqrstuvwxyz";
    for(int i=0;i<26;i++){
        alp[i]=0;
    }
    
    while(cin>>ch){
    
    
        
        if(ch>='a'&&ch<='z'){
        int j=ch-'a';
        alp[j]++;
        }else if(ch>='A'&&ch<='Z'){
            int j=ch-'A';
            alp[j]++;
        }
    }
    for(int i=0;i<26;i++){
        cout<<all[i]<<" : "<<alp[i]<<endl;
    }
    

return 0;
}


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

#define name "vd"
#define ini freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout)
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define oo 1e9 + 7;
#define PII pair<int, int>
#define long long long
using namespace std;

const int NMAX = 1e4 + 5;
const int MOD = 1e9 + 7;
string s;
int d, n, nxt;
long dp[NMAX][2][105];

int main()
{
    //ini;
    fastio;
    cin >> s >> d;
    n = s.size();
    s = "0" + s;

    memset(dp, 0, sizeof dp);

    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++){
        for (int lss = 0; lss <= 1; lss++){
            for (int j = 0; j < d; j++){
                for (int dg = 0; dg <= 9; dg++){
                    if (!dp[i - 1][lss][j]) continue;
                    if (!lss && dg > (s[i] - '0')) continue;

                    if (!lss && dg == (s[i] - '0')) nxt = 0;
                    else nxt = 1;

                    dp[i][nxt][(j + dg) % d] += dp[i - 1][lss][j] % MOD;
                }
            }
        }
    }

    cout << ((dp[n][0][0] + dp[n][1][0] - 1) % MOD + MOD) % MOD;
    return 0;
}


Measured memory_bytes: 20076
n, yen = map(int, input().split())
for x in range(n+1):
    for y in range(n+1):
        z = n - (x+y)
        if 10000*x + 5000*y + 1000*z == yen and z >= 0:
            print('{} {} {}'.format(x, y, z))
            exit()
else:
    print('-1 -1 -1')

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define LL  long long
#define LIM 100000

int ara[102], mex[LIM+5];
int n, k;

void calMex(){
    mex[0] = 0;
    for(int i = 1; i <= LIM; i++){
        set<int> grundy;
        for(int j = 1;  j <= n; j++){
            if(i < ara[j]) break;
            grundy.insert(mex[i-ara[j]]);
        }
        int mn = 0;
        auto it = grundy.begin();
        while(it != grundy.end()){
            if(*it != mn) break;
            mn++;
            it++;
        }
        mex[i] = mn;
    }
    //for(int i = 0; i < 12; i++) cout<<mex[i]<<' ';
}

int main(){
    //freopen("ip.txt", "r", stdin);
    //araonacci();
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++) scanf("%d", &ara[i]);
    sort(ara, ara+n+1);
    calMex();
    if(mex[k]) printf("First\n");
    else printf("Second\n");
}



Measured memory_bytes: 4084
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

/*
#ifdef IZI_KATKA
#define int __int64_t
#else
#define int __int64
#endif
*/

const long long MOD = 1e9 + 7;
const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;

long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

int sum(int x) {
	int res = 0;
	while(x) {
		res += (x % 10);
		x /= 10;
	}
	return res;
}

int main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt();
    int res = 1;
    while(res < n) res *= 10;
    if (res == n) {
    	cout << 10;
    	return 0;
    } else {
    	cout << sum(n);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=998244353, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

struct mint {
    ll x; // typedef long long ll;
    mint(ll 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 { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= 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 { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

ll fac[200007],finv[200007],inv[200007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<200007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll n,k;
    mint m;
    cin >> n;
    cin >> m.x;
    cin >> k;
    mint ans = 0;
    for(ll i=0;i<=k;i++){
    	mint num = m * (m-1).pow(n-i-1);
    	num *= com(n-1, i);
    	ans += num;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8344
using System;
using System.Collections.Generic;
using System.Windows;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    public class Program
    {
        static void Main(string[] args)
        {
            var n = Read().Int();
            var s = Read();
            var r = 0L;
            var g = 0L;
            var b = 0L;
            for (int i = 0; i < n; i++)
            {
                var str = s[i].ToString();
                if (str == "R")
                {
                    r++;
                }
                else if (str == "G")
                {
                    g++;
                }
                else if (str == "B")
                {
                    b++;
                }
            }
            var ans = r * g * b;
            if (ans == 0)
            {
                WriteRead(ans);
                return;
            }
            var sub = 0L;
            for (int i = 0; i < n; i++)
            {
                for (int j = 1; j < n; j++)
                {
                    var a1 = s[i].ToString();
                    if (i + j >= n || i + (j * 2) >= n) break;
                    var a2 = s[i + j].ToString();
                    var a3 = s[i + (j * 2)].ToString();
                    if (a1 != a2 && a1 != a3 && a2 != a3)
                    {
                        sub++;
                    }
                }
            }
            WriteRead(ans - sub);
        }

        public static string Read()
        {
            return Console.ReadLine();
        }

        public static string[] ReadSplit()
        {
            return Console.ReadLine().Split(' ');
        }

        public static void WriteRead(object str)
        {
            Console.WriteLine(str);
            Read();
        }

        public static void Write(object str)
        {
            Console.WriteLine(str);
        }

        private static bool ChangeMin<T>(ref T a, T b) where T : IComparable
        {
            if (a.CompareTo(b) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }

        private static bool ChangekMax<T>(ref T a, T b) where T : IComparable
        {
            if (b.CompareTo(a) > 0)
            {
                a = b;
                return true;
            }
            return false;
        }
    }
}


public static class Extentions
{
    public static int Int(this object obj)
    {
        return int.Parse(obj.ToString());
    }

    public static long Long(this object obj)
    {
        return long.Parse(obj.ToString());
    }

    public static decimal Decimal(this object obj)
    {
        return decimal.Parse(obj.ToString());
    }

    public static double Double(this object obj)
    {
        return double.Parse(obj.ToString());
    }

    public static T2 GetValueZero<T1, T2>(this Dictionary<T1, T2> d, T1 key) where T2 : struct
    {
        T2 value;
        if (d.TryGetValue(key, out value))
        {
            return value;
        }
        return new T2();
    }
}



Measured memory_bytes: 21696
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>a;
    if(n%500<=a)
    	yes;
 	else
      no;
}


Measured memory_bytes: 256
#include <cstdio>
	#include <algorithm>
	#include <vector>
	
	#define Rep(i, n) for (int i = 1; i <= n; i ++)
	#define mp(a, b) make_pair(a, b)
	
	using namespace std;
	
	const int N = 200010;
	
	pair<int, int> l1[N], l2[N], l3[N], l4[N];
	int cl1, cl2, cl3, cl4;
	
	int st[N], top;
	
	void push(int col)
	{
		if (st[top] == col) top --;
		else st[++ top] = col;
	}
	
	int main()
	{
		int n, m, p;
		scanf("%d%d%d", &n, &m, &p);
		Rep(i, p) {
			int x1, y1, x2, y2;
			scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
			if ((x1 && x1 < n && y1 && y1 < m) || (x2 && x2 < n && y2 && y2 < m))
				continue;
			if (!x1) l1[++ cl1] = mp(y1, i);
			else if (y1 == m) l2[++ cl2] = mp(x1, i);
			else if (x1 == n) l3[++ cl3] = mp(-y1, i);
			else l4[++ cl4] = mp(-x1, i);
			
			if (!x2) l1[++ cl1] = mp(y2, i);
			else if (y2 == m) l2[++ cl2] = mp(x2, i);
			else if (x2 == n) l3[++ cl3] = mp(-y2, i);
			else l4[++ cl4] = mp(-x2, i);
		}
		
		sort(l1 + 1, l1 + 1 + cl1);
		sort(l2 + 1, l2 + 1 + cl2);
		sort(l3 + 1, l3 + 1 + cl3);
		sort(l4 + 1, l4 + 1 + cl4);
		
		Rep(i, cl1) push(l1[i].second);
		Rep(i, cl2) push(l2[i].second);
		Rep(i, cl3) push(l3[i].second);
		Rep(i, cl4) push(l4[i].second);
		
		if (top) printf("NO\n");
		else printf("YES\n");
		
		return 0;
	}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long n;
  cin>>n;
    int check=0;
  string a="7";
    if(n%2==0)
    { cout<<-1;
    check=1;
    }
  long long   num=7
    ;

    for(int i=1;i<=2*1000000;i++)
    {
   
   
    //cout<<num<<endl;
    //cout<< num<<endl;
      if(num%n==0)
      {check=1;
         cout<<i;
        break;
      }
       num=(num*10+7)%n;
    }
  if(check==0)
    cout<<-1;
  
 }


Measured memory_bytes: 3616
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int A, B;
	cin >> A >> B;
	if (A <= 5) cout << 0 << endl;
	else if (A >= 13) cout << B << endl;
	else cout << B / 2 << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#define ll long long
#define mo 1000000007

using namespace std;
long long n,i,k,ans;
struct lgy{
	long long x,y,z;
}o[105];

double ans2;

ll read(){
	ll xx=0; char ch=getchar();
	for(; !isdigit(ch); ch = getchar());
	for(; isdigit(ch); ch = getchar()) xx = xx * 10 + (ch - '0');
	return xx;
}

ll pus(ll xx,int flagg){
	if(xx>=10) pus(xx/10,0);
	putchar(xx%10+'0');
	if(flagg==1)
		putchar(' ');
	if(flagg==2)
		putchar('\n');
}
int ss(ll j,ll u,ll v){
	if(j>n){
		ans=max(ans,u*u+v*v);
		return 0;
	}
	if(j<=10||u*u+v*v<=(u+o[j].x)*(u+o[j].x)+(v+o[j].y)*(v+o[j].y))
		ss(j+1,u+o[j].x,v+o[j].y);
	if(j<=10||u*u+v*v>(u+o[j].x)*(u+o[j].x)+(v+o[j].y)*(v+o[j].y))
		ss(j+1,u,v);
	return 0;
}

bool cmp(lgy u,lgy v){
	return u.z<v.z;
}

int main(){
	n=read();
	for(i=1;i<=n;i++)
		scanf("%lld%lld",&o[i].x,&o[i].y);
	for(i=1;i<=1000;i++){
		srand(i*i*123+i*456);
		for(k=1;k<=n;k++)
			o[k].z=rand();
		sort(o+1,o+n+1,cmp);
		ss(1,0,0);
	}
	ans2=sqrt(ans);
	printf("%.13lf\n",ans2);
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	string s; cin >> s;
	LL cnt = 0, ans = 0;
	rep(i, sz(s)) {
		if (s[i] == 'W')ans += i, cnt++;
	}
	LL d = (cnt - 1)*cnt / 2;
	cout << ans - d << endl;
}

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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf=1e9;
const int64_t inf64=1e18;
const double eps=1e-9;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i,0,n) cin >> x[i];
    int m;
    int64_t k;
    cin >> m >> k;
    vector<int> a(m);
    rep(i,0,m){
        cin >> a[i];
        --a[i];
    }
    vector<int> perm(n-1);
    rep(i,0,n-1) perm[i]=i;
    rep(i,0,m){
        int j=a[i];
        swap(perm[j-1],perm[j]);
    }
    vector<int> f(n-1);
    rep(i,0,n-1) f[perm[i]]=i;

    //元の場所 |-> 飛ばされる場所
    vector<int> v(n-1);
    rep(i,0,n-1) v[i]=i;
    while(k>0){
        if(k&1){
            const vector<int> w(v);
            rep(i,0,n-1) v[i]=f[w[i]];
        }
        const vector<int> g(f);
        rep(i,0,n-1) f[i]=g[g[i]];
        k>>=1;
    }

    vector<int64_t> d(n-1);
    rep(i,0,n-1) d[i]=x[i+1]-x[i];
    vector<int64_t> e(d);
    rep(i,0,n-1) d[v[i]]=e[i];
    vector<int64_t> ans;
    ans.push_back(x[0]);
    rep(i,0,n-1) ans.push_back(ans.back()+d[i]);
    rep(i,0,n) cout << ans[i] << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}


Measured memory_bytes: 6132
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          tree.dispRoundPath();
        }
      }

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode(-1);
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode(val);

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  void dispRoundPath() {

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    System.out.print(buf);
    buf.setLength(0);
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode(int key) {
    this.key = key;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


Measured memory_bytes: 125128
using System;
using System.IO;
using System.Linq;

namespace Tree
{
    class Rooted_Trees
    {
        struct Node
        {
            public int id;
            public int parent;
            public int depth;
            public int[] childlen;
            public int type;
            public string Type { get { switch (type) { case 0: return "root"; case 1: return "internal node"; case 2: return "leaf"; default: return null; } } }
        }

        static void SetDepth(Node[] nodes, int id, int depth)
        {
            nodes[id].depth = depth;
            if (nodes[id].childlen != null)
                for (int i = 0; i < nodes[id].childlen.Length; i++)
                    SetDepth(nodes, nodes[id].childlen[i], depth + 1);
        }

        static void Main(string[] args)
        {
            int size = int.Parse(Console.ReadLine());
            var nodes = new Node[size];

            for (int i = 0; i < size; i++)
                nodes[i].parent = -1;

            for (int i = 0; i < size; i++)
            {
                var token = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                var id = token[0];
                nodes[id].id = id;

                var k = token[1];
                if (k == 0) nodes[id].type = 2;
                else
                {
                    nodes[id].type = 1;
                    nodes[id].childlen = new int[k];
                    for (int j = 0; j < k; j++)
                    {
                        nodes[id].childlen[j] = token[2 + j];
                        nodes[token[2 + j]].parent = id;
                    }
                }
            }

            for (int i = 0; i < size; i++)
                if (nodes[i].parent == -1)
                {
                    nodes[i].type = 0;
                    SetDepth(nodes, i, 0);
                    break;
                }

            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            for (int i = 0; i < size; i++)
            {
                Console.Write("node {0}: parent = {1}, depth = {2}, {3}, [", nodes[i].id, nodes[i].parent, nodes[i].depth, nodes[i].Type);
                if (nodes[i].childlen != null) Console.Write(string.Join(", ", nodes[i].childlen.Select(s => s.ToString()).ToArray()));
                Console.WriteLine("]");
            }

            Console.Out.Flush();

        }
    }
}

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

	int main() {
		int H, M;
		for (;;) {
			cin >> H >> M;
			if (H == 0 && M == 0)break;
			for (int i = 0; i < H; i++) {
				if (i % 2 == 0) {
					for (int j = 0; j < M; j++) {
						if (j % 2 == 0) { cout << "#"; }
						else { cout << "."; }
					}
				}
				else {
					for (int j = 0; j < M; j++) {
						if (j % 2 == 0) { cout << "."; }
						else { cout << "#"; }
					}
				}
				cout << endl;
			}
			cout << endl;
		}
		return 0;
	}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define pi 3.141592653589793238

int main( )
{
     float r,ans;
     cin>>r;
     ans = 2*pi*r;
     cout<<fixed<<setprecision(20)<<ans<<endl;
    return 0;
}


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

using namespace std;

using ll = long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)

int main() {
	int N;
	ll T, A;
	cin >> N;
	cin >> T >> A;
	
	rep(i, N-1) {
		ll t, a;
		cin >> t >> a;
		ll add = max((T + t - 1) / t, (A + a - 1) / a);
		T = t * add; A = a * add;
	}

	cout << T + A << endl;


	return 0;
}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {
	
	
	int n;
	cin >> n;
	vector<long long int>p(n),x(n);
	vector<int>r;
	int a = 0,b=0;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (p[i] <= 0)a++;
		else {
			if (a % 2)b++;
			//a = 0;
		}
		x[i] = abs(p[i]);
		
	}
	sort(x.begin(), x.end());
	long long int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += x[i];
	}
	if (a % 2)ans -= x[0]*2;
	cout << ans << endl;

	return 0;


}

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

int main(){
    int i;
    string s;
    cin>>s;
    for(i=0;i<s.length();i++){
        if(i%2==0&&s[i]=='L'){
            cout<<"No"<<endl;
            return 0;
        }
        else if(i%2==1&&s[i]=='R'){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

    return 0;
}

Measured memory_bytes: 256
N = list(input())
ans1,ans2 = 0,0
for i in range(len(N)):
    if(i == 0): ans1 += int(N[i])-1
    else: ans1 += 9
    ans2 += int(N[i])   
 
ans = max(ans1,ans2)
print(ans)          

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < int(n); ++i)
#define REPE(i, a, b) for (int i = (a); i <= int(b); ++i)
using LL = long long;

int n;
LL b;
LL a[100010];
int t[100010];

LL dp[100010][5];
bool v[100010][5];
LL f(int x, int y) {
  if (y == 5) y -= 2;
  if (x >= n) return 0;
  LL &ret = dp[x][y];
  if (v[x][y]) return ret;
  v[x][y] = true;
  if (t[x] == 1) {
    if (y == 0)
      return ret = f(x + 1, y + 1) - a[x];
    else if (~y & 1) {
      return ret = max(f(x + 1, y) + a[x], f(x + 1, y + 1) - a[x]);
    }
    else
      return ret = f(x + 1, y + 1) + a[x];
  } else {
    if (~y & 1)
      return ret = f(x + 1, y) + a[x];
    else
      return ret = max(f(x + 1, y - 1) + a[x], f(x + 1, y) - a[x]);
  }
  return ret;
}

int main() {
  scanf("%d%lld", &n, &b);
  n--;
  char s[4];
  REP(i, n) {
    scanf("%s%lld", s, &a[i]);
    t[i] = s[0] == '+' ? 0 : 1;
  }
  cout << b + f(0, 0) << endl;
  return 0;
}



Measured memory_bytes: 12032
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
 long long MOD = 1e9 + 7;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 
int binomialCoeff(int n, int k) 
{ 
	int C[n + 1][k + 1]; 
	int i, j; 


	for (i = 0; i <= n; i++) 
	{ 
		for (j = 0; j <= min(i, k); j++) 
		{ 
			
			if (j == 0 || j == i) 
				C[i][j] = 1; 

			else
				C[i][j] = C[i - 1][j - 1] + 
						C[i - 1][j]; 
		} 
	} 

	return C[n][k]; 
}

void solve()
{
	ll x , y ; 
	cin>>x>>y ;

	if(2*x-y>=0 && (2*x-y)%3==0){
		ll m2 = (2*x-y)/3 ;
		if(x-2*m2>=0){
			ll m1 = x - 2*m2 ; 
			ll facm1 = 1 ;
			ll facm2 = 1 ;
			ll up = 1 ;
			// cout<<m1<<" "<<m2<<endl;
			for(ll i = 1 ; i<= m1+m2 ; i++){
				up = (up*i)%MOD ;
			}
			for(ll i = 1 ;  i<=m1; i++){
				facm1 = (facm1*i)%MOD ;
			}
			for(ll i = 1 ; i<=m2 ; i++){
				facm2 = (facm2*i)%MOD ;
			}
			facm1  = modpow(facm1 , MOD-2) ;
			facm2 = modpow(facm2 , MOD-2) ;
			ll ans = up ;
			ans  = (ans*facm1)%MOD  ;
			ans = (ans*facm2)%MOD ;
			cout<<ans<<endl;
		}
		else{
			cout<<0<<endl;
		}
	}
	else{
		cout<<0<<endl;
	}
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    // cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3856
#include<iostream>
using namespace std;
string s;
main()
{
    while(cin>>s)
    {
        int f=0;
        for(int i=0;i<3;i++)
        {
            if(s[i*3]!='s'&&s[i*3]==s[i*3+1]&&s[i*3]==s[i*3+2])
            {
                f=1;
                cout<<s[i*3]<<endl;
            }
        }
        for(int i=0;i<3;i++)
        {
            if(s[i]!='s'&&s[i]==s[i+3]&&s[i]==s[i+6])
            {
                f=1;
                cout<<s[i]<<endl;
            }
        }
        if(s[0]!='s'&&s[0]==s[4]&&s[0]==s[8])
        {
            f=1;
            cout<<s[0]<<endl;
        }
        if(s[2]!='s'&&s[2]==s[4]&&s[2]==s[6])
        {
            f=1;
            cout<<s[2]<<endl;
        }
        if(!f)cout<<"d"<<endl;
    }
}


Measured memory_bytes: 3048
import heapq

def dijkstra_heap(s):
    #始点sから各頂点への最短距離
    d = [float("inf")] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for e in edge[s]:
        heapq.heappush(edgelist,e)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        d[v] = minedge[0]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,[e[0]+d[v],e[1]])
    return d

# n,w = map(int,input().split()) #n:頂点数　w:辺の数
n = int(input()) #n:頂点数　w:辺の数
w = n - 1

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    edge[x].append([1,y])
    edge[y].append([1,x]) 

d0 = dijkstra_heap(0)
d1 = dijkstra_heap(n-1)

f = 0
s = 0
for i in range(1,n-1):
    if d0[i] <= d1[i]:
        f +=1
    else:
        s += 1

if f > s:
    print('Fennec')
else:
    print('Snuke')
    




Measured memory_bytes: 48876
#include<deque>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
char a[100005];
int main() {
	scanf("%s", a + 1);
	int n = strlen(a + 1), l = -1, r = -1;
	for (int i = 1; i <= n; ++i) {
		if (i + 1 <= n && a[i] == a[i+1]) {
			l = i; r = i + 1; break;
		}
		if (i + 2 <= n && a[i] == a[i+2]) {
			l = i; r = i + 2; break;
		}
	} printf("%d %d\n", l, r);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int l = 0, r = 0;
	stack<char> sc;
	rep(i, n){
		if(s[i] == '('){
			sc.push(s[i]);
		}else{
			if(sc.empty()){
				l++;
			}else{
				sc.pop();
			}
		}
	}
	r = sc.size();
	rep(i, l) cout << '(';
	cout << s;
	rep(i, r) cout << ')';
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


inline int f(int x)
{
  x |= x << 1;
  x |= x << 2;
  x |= x << 4;
  x |= x << 8;
  x |= x << 16;

  return x;
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  int N, A, cm = INF;

  std::cin >> N;

  for (int i = 0; i < N; i ++) {
    std::cin >> A;

    cm = std::min(__builtin_popcount(~ f(A)), cm);
  }

  std::cout << cm << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define int long long
#define sz(x) (int)x.size()
#define mp make_pair
#define fi first
#define se second
#define io ios_base::sync_with_stdio(false),cin.tie(NULL)
using namespace std;
#define INF 1e7
void dfs(vi v[],vector<bool>& visited,int src)
{
	visited[src]=1;
	for(auto it:v[src])
	{
		if(!visited[it]) dfs(v,visited,it);
	}
}
signed main()
{
	io;
	int n,m;
	cin >> n >>m;
	vi v[n];
	for(int i=0;i<m;i++)
	{
		int a,b;
		cin >>a >>b;
		a--;
		b--;
		v[a].pb(b);
		v[b].pb(a);
	}
 	vector<bool> visited(n,false);
 	int ct=0;
 	for(int i=0;i<n;i++)
 	{
 		if(!visited[i])
 		{
 			dfs(v,visited,i);
 			ct++;
 		}
 	}
 	cout << ct-1<<endl;
	
}
 
	

Measured memory_bytes: 10748
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

long long int a[1000000];

int main(){
	
	int n, k;
	
	while(true){
	
	cin >> n >> k;
		if(n == 0){
			break;
		}
	
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	long long int max = -1000000000000000;
	
	long long int cur = 0;
	
	for(int i = 0; i < k; i++){
		cur += a[i];
	}
	
	for(int i = k; i < n; i++){
		if(max < cur){
			max = cur;
		}
		cur += a[i] - a[i - k];
		if(max < cur){
			max = cur;
		}
	}
	
	cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 3776
#include<iostream>
#include<iomanip>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cassert>
#include<ctime>
#include<algorithm>
#include<utility>
#include<map>
#include<set>
#include<vector>
#include<functional>

using namespace std;

typedef  long long           ll;
typedef  unsigned            ui;
typedef  unsigned long long  ull;
typedef  pair<int,int>       i_i;
typedef  pair<ll,int>        ll_i;
typedef  pair<ll,ll>         ll_ll;
typedef  pair<double,int>    d_i;
typedef  pair<double,double> d_d;

#ifdef DEBUG
#define dprintf      printf
#define dputs        puts
#define dout(x)      cout<<#x" = "<<(x)<<endl
#define darray(x,n)  {int i;rep(i,n)cout<<#x"["<<i<<"] = "<<*((x)+i)<<endl;}
#define dloop(i,s,g) for(int (i)=(s);(i)<(g);(i)++)
#define drep(i,n)    for(int (i)=0;(i)<(n);(i)++)
#define dstop()      scanf("%*c")
#else
#define dprintf      (1)?0:printf
#define dputs        (1)?0:puts
#define dout(x)
#define darray(x,n)
#define dloop(i,s,g) if(int i=0){}else
#define drep(i,n)    if(int i=0){}else
#define dstop()
#endif

#define F    first
#define S    second
#define pb   push_back
#define mp   make_pair

#define loop(i,s,g) for((i)=(s);(i)<(g);(i)++)
#define rep(i,n)    for((i)=0;(i)<(n);(i)++)
#define all(x)      (x.begin(),x.end())
#define in(T,...) T __VA_ARGS__; impl(__VA_ARGS__)
#define array(T,id,n) T id[(n)]; for(int i=0;i<(n);i++)cin>>id[i]
#define putv(n)     cout<<(n)<<endl

//#define int long long
#ifndef int
#define INF 2000
#else
#define INF __INT64_MAX__
#endif

void impl(){};
template <typename T,typename... TS >
void impl(T &head,TS &... tail)
{
  cin>>head;
  impl(tail ...);
}

#define MAX_V 200
int d[MAX_V][MAX_V];
int V;

void warshall_floyd()
{
  int i,j,k;
  rep(k,V)rep(i,V)rep(j,V)
    d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
}

struct Edge
{
  int s;
  int t;
  int c;
};

signed main(void)
{
  int i,j,k;
  rep(i,MAX_V)rep(j,MAX_V)
    d[i][j]=i==j?0:INF;
  Edge e[2000]={};

  cin>>V;
  in(int,M);
  rep(i,M)
    {
      in(int,a,b,c);
      if(a>b)swap(a,b);
      e[i]=(Edge){a-1,b-1,c};
      d[a-1][b-1]=c;
      d[b-1][a-1]=c;
    }

  warshall_floyd();

  drep(i,V)
    {
      drep(j,V)
	dprintf("%4d,",d[i][j]);
      puts("");
    }

  int count=M;
  rep(k,M)
    {
      bool flg=false;
      for(i=0;i<V;i++)
	{
	  for(j=0;j<V;j++)
	    {
	      if(d[i][e[k].s]+e[k].c+d[e[k].t][j]==d[i][j])
		flg=true;
	    }
	}
      count-=flg;
    }
  putv(count);
  return 0;
}


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

#define gcd(a,b)		__gcd(a,b)
#define lcm(a,b)		(a*b)/gcd(a,b)
#define ff              first
#define ss              second
#define int             long long
#define pb              emplace_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             INT_MAX
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(x)			x.begin(),x.end()
#define digits(x)		floor(log10(x))+1
#define FIO				ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

class dsu {
private:
	int *id;
	int* sz;

	int root(int i) {
		while (i != id[i]) {
			id[i] = id[id[i]];
			i = id[i];
		}
		return i;
	}
public:
	int n;
	dsu(int v) {
		n = v;
		id = new int[n];
		sz = new int[n];

		for (int i = 0; i < n; i++) {
			id[i] = i;
			sz[i] = 0;
		}
	}

	bool find(int p , int q) {
		return root(p) == root(q);
	}

	void join(int p , int q) {
		int i = root(p);
		int j = root(q);
		if (i == j) {
			return;
		}
		if (sz[i] < sz[j]) {
			id[i] = j ;
			sz[j] += sz[i];
		}
		else {
			id[j] = i;
			sz[i] += sz[j];
		}
	}
};

int nCr(int n , int r ) {
	int p = 1, k = 1;

	if (n - r < r ) {
		r = n - r;
	}
	if (r != 0) {
		while (r != 0) {
			p *= n ;
			k *= r ;
			int m = __gcd(p, k);
			p /= m;
			k /= m;
			n--;
			r--;
		}
	}
	else {
		p = 1;
	}
	return p ;
}

int modPower(int x, int y , int p) {
	//Used to calculate (x^y)%p
	int res = 1;
	if (y == 0) {
		return 1;
	}

	x = x % p;
	if (x == 0) {
		return 0  ;
	}

	while (y > 0) {
		if (y & 1) {
			res = (res * x) % p;
		}

		y >>= 1;
		x = (x * x) % p;
	}
	return res ;

}


int32_t main() {
	FIO;


	int n ;
	cin >> n;

	vi a(n + 1), b(n);
	for (int i = 0 ; i < n + 1; i++) {
		cin >> a[i];
	}
	for (int i = 0 ; i < n ; i++) {
		cin >> b[i];
	}

	int count = 0 ;
	for (int i = 0 ; i < n ; i++) {
		if (a[i] < b[i] ) {
			count += a[i];
			b[i] -= a[i];
			if (b[i] < a[i + 1]) {
				count += b[i];
				a[i + 1] -= b[i];
			}
			else {
				count += a[i + 1];
				a[i + 1] = 0 ;
			}
		}
		else {
			a[i] -= b[i];
			count += b[i];
		}
	}
	cout << count;





	return 0;
}


Measured memory_bytes: 4748
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

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

    ll n;
    cin >> n;
    vll a(n);
    vector<P> p(n);
    REP(i, n) {
        cin >> a[i];
        p[i] = {a[i], i + 1};
    }
    VSORTR(p);

    // dp[i][j] : 移動先について [0, i] || [j , n + 1] を確定したときの総和の最大値
    vvll dp(n + 2, vll(n + 2));
    REP(s, n) {
        ll val = p[s].first, pos = p[s].second;
        // dp[i][j] が判明した状態で s 番目を左右に振った場合の更新
        REP(i, s + 1) {
            ll j = i + (n - s) + 1;
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + val * abs(pos - (i + 1)));
            dp[i][j - 1] = max(dp[i][j - 1], dp[i][j] + val * abs(pos - (j - 1)));
        }
    }
    ll res = 0;
    REP(i, n + 1) {
        res = max(res, dp[i][i + 1]);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 34616
a,b,c,x,y = map(int,input().split())

C = c*2
ans = []
if C<a+b:
    if x>y:
        ans.append(C*x)
        ans.append(C*y+a*(x-y))
    else:
        ans.append(C*y)
        ans.append(C*x+b*(y-x))
else:
    ans.append(a*x+b*y)
print(min(ans))

Measured memory_bytes: 3060
// abc056_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    ll X;
    cin >> X;

    ll n = (ll)ceil((-1 + sqrt(1 + 8 * X)) / 2);

    int ans = n;
    print(ans);

    return 0;
}


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

int main()
{
    string S;
    cin >> S;
    if(S[0]==S[1]&&S[1]==S[2]&&S[0]==S[2])cout << "No" << endl;
    else{
        cout << "Yes" << endl;
    }
}

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

string s;
int ans;

void solve()
{
    ans = 700;

    for (int i = 0; i < 3; i++) {
        char c = s[i];
        if (c == 'o') ans += 100;
    }
}

int main()
{
    cin >> s;

    solve();

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import combinations_with_replacement

n, m, q = map(int, input().split())
a = [0] * q
b = [0] * q
c = [0] * q
d = [0] * q
ans = 0

for i in range(q):
    a[i], b[i], c[i], d[i] = map(int, input().split())

for seq in combinations_with_replacement([i for i in range(1, m+1)], n):
    now = 0
    for j in range(q):
        if seq[b[j] - 1] - seq[a[j] - 1] == c[j]:
            now += d[j]
    ans = max(ans, now)

print(ans)


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

int main(void){
  int AB[2], CD[2], value;
  for(int i = 0; i < 2; i++)
    cin >> AB[i];
  for(int i = 0; i < 2; i++)
    cin >> CD[i];
  sort(begin(AB), end(AB));
  sort(begin(CD), end(CD));
  value = AB[0] + CD[0];
  cout << value << "\n";
  return 0;
}


Measured memory_bytes: 3600
import collections
h, w, m = map(int, input().split())
h = [None]*m
w = [None]*m
for i in range(m):
    u, v = map(int, input().split())
    h[i] = u
    w[i] = v
hc = collections.Counter(h)
wc = collections.Counter(w)
hm = hc.most_common()[0][1]
hs = set([])
for hi, ci in hc.most_common():
    if ci == hm:
        hs.add(hi)
    else:
        break
wm = wc.most_common()[0][1]
ws = set([])
for wi, ci in wc.most_common():
    if ci == wm:
        ws.add(wi)
    else:
        break
cnt = 0
for i in range(m):
    if h[i] in hs and w[i] in ws:
        cnt += 1
if cnt == len(hs)*len(ws):
    print(hm + wm -1)
else:
    print(hm + wm)

Measured memory_bytes: 236296
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
using vll=vector<ll>;
using vi=vector<int>;

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;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}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(){
    string s;
    ll k;
    cin>>s>>k;
    ll ans=0;
    string tmp=s;
    rep(i,tmp.size()-1){
        if(tmp.at(i)==tmp.at(i+1)){
            tmp.at(i+1)='0';ans++;
        }
    }
    ans*=k;
    if(s.at(s.size()-1)==s.at(0)){
        char kind=s.at(0);
        int front=0,back=s.size()-1;
        int cfront=0,cback=0;
        while(front+cfront<s.size()&&s.at(front+cfront)==kind){
            cfront++;
        }
        while(back-cback>=0&&s.at(back-cback)==kind){
            cback++;
        }
        if(cfront==cback&&cfront==s.size()&&s.size()%2){
            ans+=k/2;
        }
        else ans+=(ll)((cfront+cback)/2-(cfront/2+cback/2))*(k-1);
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 256