akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cassert>
#include <map>
#include <set>
#include <algorithm>
#include <string>
#include <queue>
#define PIE 3.14159265358979
#define MAX_N 16
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0;i < (n);i++)
#define show(x) cout<<(#x)<<":"<<x<<" ";
#define showl(x) cout<<(#x)<<":"<<x<<endl;

using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;

ll fact[200010];

void init(ll N){
    fact[0]=1;
    ll i = 1;
    while(i<=N){
        fact[i]=i*fact[i-1];
        fact[i]%=MOD;
        i++;
    }
}

ll mpow(ll a,ll n){//a^n
    ll ret = 1;
    while(n>0){
        if((n&1)!=0){
            ret *= a;
            ret %= MOD;
        }
        a=(a*a)%MOD;
        n>>=1;
    }
    return ret;
}

ll inv(ll x){
    return mpow(x,MOD-2);
}

ll combination(ll a,ll b){
    if(a<b||b<0)
        return 0;
    ll ret = 1;
    ret = (fact[a]*inv(fact[b]))%MOD;
    ret = (ret*inv(fact[a-b]))%MOD;
    return ret;
}

int main(){
    int H,W,N;
    init(200005);
    cin>>H>>W>>N;
    vector<ll> dp(N+1,0);
    vector<pair<int,int> > rc;
    rc.reserve(N+1);
    rep(i,N){
        int r,c;
        cin>>r>>c;
        rc.pb(mp(--r,--c));
    }
    rc.pb(mp(H-1,W-1));
    sort(rc.begin(),rc.end());
    for(int i = 0; i < rc.size();i++){
        int r = rc[i].first,c = rc[i].second;
        dp[i]=combination(r+c,r);
        for(int j = 0;j < i;j++){
            int pr = rc[j].first,pc = rc[j].second;
            if(pr<=r&&pc<=c){
                dp[i] += MOD-(dp[j]*combination(r+c-pr-pc,r-pr))%MOD;
                dp[i] %= MOD;
            }
        }
    }
    cout<<dp[N]<<endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
using namespace std;
#define MAX 51
typedef pair<double,double> P;
 
int main(){
  int n,t = 1;
 
  while(cin >> n,n){
    vector<P> v;
    double ans = 0, x ,y;
    for(int i = 0 ; i < n ; i++){
      cin >> x >> y;
      v.push_back(P(x,y));
    }  
    for(int i = 1; i < n+1 ; i++){
      ans += (v[i%n].first-v[i-1].first)*(v[i%n].second+v[i-1].second);
    }
    ans /= 2.0;
    printf("%d %.1f\n" ,t++ ,abs(ans));
  }
 
  return 0;
}
 

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

int bubble_sort(int A[],int n){
    int m=0;
    for(int i=0;i<n-1;i++){
        for(int j=0;j<n-i-1;j++){
            if(A[j]>A[j+1]){
                int t=A[j];
                A[j]=A[j+1];
                A[j+1]=t;
                m++;
            }
        }
    }
    return m;
}

int main(){
    int A[100],n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>A[i];
    int m=bubble_sort(A,n);
    for(int i=0;i<n;i++){
        if(i==0)cout<<A[i];
        else cout<<' '<<A[i];
    }
    cout<<endl;
    cout<<m<<endl;
    return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <cstdio>
#include <cctype>
#include <cstring>
#define il inline
#define vd void
#define rg register
#define rep(i,x,y) for(rg int i=x;i<=y;++i)
#define drp(i,x,y) for(rg int i=x;i>=y;--i)
using namespace std;
const int Len=2333333;
char buf[Len],*p1=buf,*p2=buf,duf[Len],*q1=duf;
il char gc(); il int rd(); il vd pc(char c); il vd rt(int x); il vd flush();
int n,t,ans[100005];
char s[100005];
int main(){
    scanf("%s",s+1),n=strlen(s+1);
    rep(i,1,n){
        if(s[i]=='R') t=i;
        else{
            if((i-t)&1) ++ans[t+1];
            else ++ans[t];
        }
    }
    drp(i,n,1){
        if(s[i]=='L') t=i;
        else{
            if((t-i)&1) ++ans[t-1];
            else ++ans[t];
        }
    }
    rep(i,1,n) rt(ans[i]),pc(' ');
    return flush(),0;
}

il char gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,Len,stdin),p1==p2)?-1:*p1++;}
il int rd(){char c;
    while(!isdigit(c=gc())&&c!='-');
    int f=c=='-'?c=gc(),1:0,x=c^48;
    while(isdigit(c=gc())) x=((x+(x<<2))<<1)+(c^48);
    return f?-x:x;
}
il vd pc(char c){q1==duf+Len&&fwrite(q1=duf,1,Len,stdout),*q1++=c;}
il vd rt(int x){x<0?pc('-'),x=-x:0,pc((x>=10?rt(x/10),x%10:x)+48);}
il vd flush(){fwrite(duf,1,q1-duf,stdout);}

Measured memory_bytes: 1152
from math import log

x, k, d = (int(x) for x in input().split())
if x < 0:
    x *= -1
logk = log(k, 10)
logd = log(d, 10)
if logk + logd <= 16 and x >= k * d:
    ans = x - k * d
    print(ans)
    exit()

l = x // d
if (k - l) % 2 == 0:
    ans = x - l * d
else:
    ans = abs(x - l * d - d)
print(ans)


Measured memory_bytes: 62492
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;
ll bur[100],pat[100];


ll cnt(ll n,ll x)
{
  //cout<<"nx"<<n<<" "<<x<<endl;
  ll res=0;

  if(n==0)
  {
    return 1;
  }
  if(x==0)return 0;
  if(x<=bur[n-1])
  {
    res+=cnt(n-1,x-1);
  }
  else if(x==bur[n-1]+1)
  {
    res+=pat[n-1]+1;
  }
  else
  {
    res+=pat[n-1]+1+cnt(n-1,x-bur[n-1]-2);
  }
  return res;
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,x;
  cin>>n>>x;
  bur[0]=1;
  pat[0]=1;
  rep(i,n)
  {
    bur[i+1]=bur[i]*2+3;
    pat[i+1]=pat[i]*2+1;
  }
  //rep(i,n+1)cout<<bur[i]<<" "<<pat[i]<<endl;

  
  cout<<cnt(n,x-1)<<endl;


  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long int;
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; }
const ll INF = 1e10;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;

int main() {
    ll n,k,v[52];
    cin >> n >> k;
    rep(i,n) cin >> v[i];
    ll ans = -INF,c,cnt;
    rep(i,n+1){
        rep(j,n-i+1){
            priority_queue<ll> q;
            c = 0;
            cnt = 0;
            if (i+j > k) continue;
            rep(a,i){
                if (v[a] < 0) q.push(-v[a]);
                c += v[a];
            }
            rep(b,j){
                if (v[n-b-1] < 0) q.push(-v[n-b-1]);
                c += v[n-b-1];
            }
            while(!q.empty()){
                if (cnt >= k-i-j) break;
                c += q.top();q.pop();
                cnt++;
            }
            chmax(ans,c);
        }
    }
    PRINT(ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
typedef long double ld;
#define fr first
#define sc second
#define pb push_back
const ll mod = 998244353;
const int N = 1e6+205;
void solve(){
	int n; 
	cin>>n; 
	cout<<((n+110)/111)*111<<endl;
}
int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1; 
//	cin>>t; 
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3592
import java.util.*;
import java.lang.*;

public class Main{
    
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        while (true) {
            String s = sc.next();
            int l = s.length();
            if (s.equals("-")) {
                break;
            }
            
            int m = sc.nextInt();
        
            for (int i = 0; i < m; i++) {
                int h = sc.nextInt();
                s = s + s.substring(0, h);
                s = s.substring(h);
            }
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 26344
import numpy as np
def resolve():
    N = int(input())
    A = np.zeros(N + 1, dtype = int)
    for i in range(1, N + 1):
        A[i] = int(input())
    current_num = 1
    ans = 0
    Found = False
    for _ in range(N):
        next_num = A[current_num]
        ans += 1 
        if next_num == 2:
            Found = True
            break
        current_num = next_num
    if (Found):
        print(ans)
    else:
        print(-1)
resolve()

Measured memory_bytes: 27588
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  int k;
  cin >> k;
  int i = 1;
  int a = 7 % k;
  if(a == 0) {
    cout << i << endl;
    return 0;
  }
  vector<bool>v(k);
  v[a] = true;
  while(1) {
    i++;
    int an = (10 * a + 7) % k;
    if(an == 0) {
      cout << i << endl;
      return 0;
    }
    if(v[an]) break;
    v[an] = true;
    a = an;
  }
  cout << -1 << endl;
  return 0;
}

Measured memory_bytes: 3732
#include <iostream>
#include <string>
#include <algorithm> 
#include <cstdlib>
#include <map>
using namespace std;
int main(){
    int N,T,A;
    int  H[1009],ans;
    double tem,B[1009],min=10000000;
    cin >> N >> T >> A;
    for(int i=0;i<N;i++){
        cin >> H[i];
    }

    for(int i=0;i<N;i++){
        tem = T - H[i]*0.006;
        B[i] = A - tem;
        if(B[i]<0){
            B[i] = B[i]*(-1);
        }
    }

    for(int i=0;i<N;i++){
        if(min>B[i]){
            min = B[i];
            ans = i;
        }
    }
    cout << ans+1 << endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		boolean[] ans=new boolean[n];
		Unionfind uf=new Unionfind(n);
		for(int i = 0; i<m; i++){
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			int z = sc.nextInt();
			uf.unite(x,y);
		}
		long count=0;
		for(int i=0; i<n; i++){
			if(!ans[uf.root(i)]){
				ans[uf.root(i)]=true;
				count++;
			}
		}
		System.out.println(count);
	}
	static class Unionfind{
		int[] parent;
		public Unionfind(int n){
			this.parent=new int[n];
			for(int i = 0; i<n; i++){
				parent[i]=i;
			}
		}
		public int root(int t){
			if(parent[t]==t){
				return t;
			}else{
				return parent[t]=root(parent[t]);
			}
		}
		public void unite(int x,int y){
			if(same(x,y)){
				return;
			}
			int xroot = root(x);
			int yroot = root(y);
			parent[yroot]=xroot;
		}
		public boolean same(int x,int y){
			return root(x)==root(y);
		}
	}
}


Measured memory_bytes: 89508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  string s;
  cin >> s;
  ll ans=0;
  rep(i,s.size()){
    if(i%2==0){
      if(s[i]=='p') ans--;
    }
    else{
      if(s[i]=='g') ans++;
    }
  }
  cout << ans << endl;

  
  return 0;
    

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	int n;
	cin >> n;
	
	map<string, int> mp;
	string s;
	while(n--){
		cin >> s;
		mp[s]++;
	}
	
	cout << "AC x " << mp["AC"] << '\n';
	cout << "WA x " << mp["WA"] << '\n';
	cout << "TLE x " << mp["TLE"] << '\n';
	cout << "RE x " << mp["RE"];
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3660
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>

int main(void){
	int n , i , buf;
	float x1,x2,x3,y1,y2,y3,a1,a2,b1,b2,c1,c2,xp,yp,r;
	scanf("%d" , &n);
	for(i=1;i<=n;i++){
		scanf("%f %f %f %f %f %f" , &x1 , &y1 , &x2 , &y2 , &x3 , &y3);
		a1 = 2 * (x2 - x1);
		b1 = 2 * (y2 - y1);
		c1 = x1 * x1 - x2 * x2 + y1 * y1 - y2 * y2;
		a2 = 2 * (x3 - x1);
		b2 = 2 * (y3 - y1);
		c2 = x1 * x1 - x3 * x3 + y1 * y1 - y3 * y3;
		xp = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1);
		yp = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1);
		r = sqrt((xp - x1) * (xp - x1) + (yp - y1) * (yp - y1));
		printf("%.3f %.3f %.3f\n" , xp , yp , r);
	}
	return 0;
}

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

int main(){ 
    int n;
    cin >> n;
    double ans=0;
    for(int i=0;i<n;i++){
        double a;
        string b;
        cin >> a >> b;
        if(b == "JPY")ans +=a;
        else ans += a*380000;
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
a,b = map(int,input().split())
c=[]
for i in range(a):
    c.append(input())
c=sorted(list(map(int,c)))
b = b - sum(c) #一通り作った。
count = a
while 1:
    if b < min(c) :break
    b -= min(c)
    count += 1
print(count)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int h1, m1, h2, m2, k, m;
	cin>> h1 >> m1 >> h2 >> m2 >> k;

	m=60*(h2-h1);
	m+=m2-m1-k;

	cout<< max(0, m) << endl;
 
	return 0;
}

Measured memory_bytes: 3628
mod = 1e9+7
def add(a, b):
    c = a + b
    if c >= mod:
        c -= mod
    return c

def main():
    H, N = [int(x) for x in raw_input().split()]
    
    s = sum([int(x) for x in raw_input().split()])
    
    if s >= H:
        print('Yes')
    else:
        print('No')
    
    

main()

Measured memory_bytes: 42476
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

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 (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

int main() {
    int N; cin>>N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i) {
        cin>>a[i];
    }
    vector<int> ref=a;
    sort(ref.begin(),ref.end());
    int ans=0;
    for (int i = 0; i < N; ++i) {
        auto itr=lower_bound(ref.begin(),ref.end(),a[i]);
        int idx=itr-ref.begin();
        if((i&1)!=(idx&1)) ans++;
    }
    cout<<ans/2<<endl;
    return 0;
}


Measured memory_bytes: 1024
n, y = map(int,input().split())
s = (-1,-1,-1)
for i in range(n+1):
  m = n-i
  for j in range(m+1):
    k = m-j
    if i*10000+j*5000+k*1000 ==y:
      s = (i,j,k)
      break
print(s[0],s[1],s[2])


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <string>
#include <queue>
#include <unordered_map>
#include <iterator>
#include <stack>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <cstring>
#include <bitset>

#include <random>
#define all(x) (x).begin(), (x).end()


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl

using ll = long long;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec) {
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}

#define solvsh
//#define multi
#ifdef solvsh

const int MAXN = 1e5 + 20;

vector<int> g[MAXN];


bool usd[MAXN];
int vals[MAXN];

void bfs() {

    queue<int> q;
    q.push(1);

    for (; !q.empty();) {

        auto top = q.front();
        q.pop();

        for (auto out : g[top]) {
            if (!usd[out]) {
                usd[out] = true;
                vals[out] = top;
                q.push(out);
            }
        }
    }
}

void solve() {

    int n, m;
    cin >> n >> m;

    for (int i = 0; i < m; ++ i){
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    bfs();

    for (int i = 1; i <= n; ++ i){
        if (!usd[i]){
            cout << "No";
            return;
        }
    }
    cout << "Yes\n";
    for (int i = 2; i <= n; ++ i){
        cout << vals[i] << "\n";
    }

}

#else

void solve() {

}

#endif

void multisolve() {

    int t;
    cin >> t;

    int i = 1;
    while (t--) {
//        cout << "Case #" << (i++) << ": ";
        solve();
        cout << "\n";
    }
}


#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);



#ifdef multi
    multisolve();
#else
    solve();
    //    gen();
#endif

}


Measured memory_bytes: 10568
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/STACK:1024000000,1024000000")

#include "bits/stdc++.h"
using namespace std;

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

#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e6+5, LG = 17, MOD = 1e9+7;
const int SQ = 390;
const long double EPS = 1e-7;
ll h, w;
int n;
set<ii> cnt[10];
set<ii> go;
int32_t main(){
#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(0);
  cin.tie(0);
#endif // ONLINE_JUDGE

  cin >> h >> w >> n;

  f(i,0,n){
    int x, y;
    cin >> x >> y;
    go.insert({x,y});
  }
  ll tot = (h-2)*(w-2);
  for(auto cell : go){
    int x = cell.F;
    int y = cell.S;
    f(prvx,0,3)
      f(prvy,0,3){
        int a = x - prvx;
        int b = x + (2 - prvx);
        int c = y - prvy;
        int d = y + (2 -prvy);
        if(a<=0||c<=0||b>h||d>w)continue;
        int sum = 0;
        f(i,a,b+1)
          f(j,c,d+1)
            sum+=go.count(ii(i,j));
        tot+=cnt[sum].size();
        cnt[sum].insert(ii(a,c));
        tot-=cnt[sum].size();
      }


  }

  cout<<tot<<endl;
  f(i,1,10)cout << cnt[i].size() << '\n';

  return 0;
}


Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
	ll n;
	cin >> n;
	vector<int> a(n);
	map<ll, ll> mp;
	for(int i=0; i<n; ++i){
		cin >> a[i];
		++mp[a[i]];
	}
	
	ll msum =0;
	for(auto m : mp){
		ll t=m.second;
		ll tmp = t*(t-1)/2;
		if(t<2)tmp = 0;
		msum += tmp;
	}
	
	
	for(int i=0;i <n; ++i){
		ll t= mp[a[i]];
		ll tmp = t*(t-1)/2;
		if(t<2)tmp = 0;
		--t;
		ll tmp2 = t*(t-1)/2;
		if(t<2)tmp2 = 0;
		ll ans = msum - tmp + tmp2;
		cout << ans << endl;
	}
}

Measured memory_bytes: 10240
import java.util.*;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.contains("a") && s.contains("b") && s.contains("c")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 24404
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<numeric>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(lli i = 0;i<((lli)(n));i++)
#define reg(i,a,b) for(lli i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int, int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))

int main(void){
	lli n, p; cin >> n >> p;
	lli e = 0, o = 0, t;
	rep(i, n){
		cin >> t;
		if(t%2 == 0) e++;
		else o++;
	}
	
	lli ans = 0, pre;
	rep(i, o+1){
		if(i == 0) pre = 1;
		else pre = pre*(o-i+1)/i;
		if(i%2 == p) ans += pre;
	}
	
	if(ans != 0 && e != 0) ans *= (1ll<<e);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }
#define INF 2e16
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef pair<int, int> p;
typedef priority_queue<p> pq;
typedef priority_queue<p, vector<p>, greater<p>> gpq;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll n;
    cin >> n;

    vector<ll> a(n);
    vector<ll> s(n+1);
    ll l = 0;
    s[0] = 0;

    REP(i, n)
    {
        ll temp;
        cin >> temp;
        a[i] = temp;
        l += temp;
        s[i + 1] = s[i] + temp;
    }

    ll minv = INF;
    int idx = INF;

    REP(i, n)
    {
        if ( minv > abs(l - s[i + 1] * 2) )
        {
            idx = i;
            minv = abs(l - s[i + 1] * 2);

        }
    }

    cout << minv << endl;

}

Measured memory_bytes: 3456
#include<stdio.h>

int main()
{
	double n,s,c;
	int b;
	s = 0;
	scanf("%lf",&n);
	if(n >= 1&&n <= 100){
		for(b = 1;b <= n;b++)
	{
		if(b % 2 != 0)
		{
			s = s + 1;
		}
	}
	}
	c = s / n;
	printf("%f",c);
}

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

signed main(){

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int ans = 0;
    int n, q;
    set<int> s;
    cin >> n;
    int tmp;
    rep(i,n){
        cin >> tmp;
        s.insert(tmp);
    }
    cin >> q;
    rep(i,q){
        cin >> tmp;
        if (s.count(tmp)) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3168
A, B = map(int, input().split())
sum = 0
if A >= B:
  sum = sum + A
  A = A - 1
  if A >= B:
    sum = sum + A
  else:
    sum = sum + B
elif B >= A:
  sum = sum + B
  B = B - 1
  if B >= A:
    sum = sum + B
  else:
    sum = sum + A
print(sum)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){

	char a[100000];
	char b[100000];
    string w;
	while(getline(cin,w)){
	for(int i=0;i<w.size();i++){
       w[i]=toupper(w[i]);
	}
    cout<<w<<endl;
	}

	return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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 const INF = 1001001001;


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

string s;
cin >> s;

int n = s.size();
for(int i = 0;i < n - 1;i++){
    for(int j = i + 1;j < n;j++){
        if(s[i] == s[j]){
            cout << "no" << endl;
            return 0;
        }
    }
}

cout << "yes" << endl;

return 0;
}

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

int main(void)
{
    string S, T;
    
    cin >> S;
    cin >> T;
    
    for (int i = 0; i < S.length(); i ++) {
        if (S[i] != T[i]) {
            cout << "No" << endl;
            return 0;
        }
    }
    
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    long int n,i;
    cin>>n;
    vector<vector<long int>>dp(n,vector<long int>(3));
    for(i=0;i<n;i++)
    {
        cin>>dp[i][0]>>dp[i][1]>>dp[i][2];
        if(i!=0)
        {
            dp[i][0]+=max(dp[i-1][1],dp[i-1][2]);
            dp[i][1]+=max(dp[i-1][0],dp[i-1][2]);
            dp[i][2]+=max(dp[i-1][0],dp[i-1][1]);
        }

    }
    cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Measured memory_bytes: 5760
n=int(input())
a={}
for i in range(n):
    key=input()
    if key in a:
        a[key]+=1
    else:
        a[key]=1
b=max(list(a.values()))
c=[]
for k,v in a.items():
    if v==b:
        c.append(k)
c=sorted(c)
for i in range(len(c)):
    print(c[i])

Measured memory_bytes: 145376
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s); sin>>v; return v;}
template<class T> inline string toString(T x) {ostringstream sout; sout << x; return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI = acos(-1.0);

struct node{
    int index,ticket;
	double cost;
    node(int index,int ticket,double cost):index(index),ticket(ticket),cost(cost){}
    bool operator<(const node& other)const{
        return cost>other.cost;
    }
};
const int MAX=INT_MAX/10;
const int NONE=-1;
typedef vector<double> vd;
typedef vector<vd> vvd;
int main(){
	cout.precision(16);
	int n,m,p,a,b;
	while(cin>>n>>m>>p>>a>>b,n){
		vi tickets(n);
		REP(i,n){
			cin>>tickets[i];
		}
        vvi dist(m,vi(m,NONE));
        REP(i,p){
			int x,y,z;
			cin>>x>>y>>z;
            dist[x-1][y-1]=z;
            dist[y-1][x-1]=z;
        }
        
        priority_queue<node> q;
        q.push(node(a-1,0,0));
        vvd cost(m,vd((1<<n),MAX));
        cost[a-1][0]=0;
        while(!q.empty()){
            node cnode=q.top();q.pop();
            if(cost[cnode.index][cnode.ticket]<cnode.cost){
                continue;
            }
            REP(i,m){
                if(i!=cnode.index&&dist[cnode.index][i]!=NONE){
					REP(j,n){
						if(((1<<j)&cnode.ticket)==0){
							double newcost=cnode.cost+(double)dist[cnode.index][i]/tickets[j];
							if(cost[i][(1<<j)|cnode.ticket]>newcost){
								cost[i][(1<<j)|cnode.ticket]=newcost;
								q.push(node(i,(1<<j)|cnode.ticket,newcost));
							}
						}
					}
                }
            }
        }
		double ans=MAX;
		REP(i,1<<n){
			ans=min(ans,cost[b-1][i]);
		}
		if(ans>MAX-100){
			cout<<"Impossible"<<endl;
		}else{
			cout<<ans<<endl;
		}
    }
}

Measured memory_bytes: 2784
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    string s;
    cin >> n >> m >> s;
    vector<int> da(n), db(n);
    vector<vector<int>> e(n);
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u;
        --v;
        if (s[u] == 'A')
            ++da[v];
        else
            ++db[v];
        if (s[v] == 'A')
            ++da[u];
        else
            ++db[u];
        e[u].push_back(v);
        e[v].push_back(u);
    }
    int remain = n;
    queue<int> que;
    for (int i = 0; i < n; ++i)
        if (da[i] == 0 || db[i] == 0)
            que.push(i);
    while (!que.empty()) {
        int u = que.front();
        --remain;
        que.pop();
        for (int v : e[u]) {
            if (da[v] == 0 || db[v] == 0)
                continue;
            if (s[u] == 'A')
                --da[v];
            else
                --db[v];
            if (da[v] == 0 || db[v] == 0)
                que.push(v);
        }
    }
    if (remain == 0)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 12240
def solve(X, Y, Z, V, E, A):
    dp = [[0.0] * 6001 for _ in xrange(Y + max(V) + 1)]
    dp[0][0] = 1.0
    for i in xrange(Y):
        for j in xrange(5001):
            if dp[i][j] <= 0.0:
                continue
            for k in V:
                t = i + k
                if t > Y:
                    dp[Y][j] += dp[i][j]/X
                elif E[t] == 1:
                    dp[min(Y, t+A[t])][j] += dp[i][j]/X
                else:
                    dp[t][max(0, j+A[t])] += dp[i][j]/X

    s = 0
    for i in xrange(5001):
        if dp[Y][i] <= 0.0:
            continue
        s += i * dp[Y][i]
    print int(s)

if __name__ == "__main__":
    import sys

    while True:
        X, Y, Z = map(int, raw_input().split())
        if X | Y | Z == 0:
            sys.exit()
        V = map(int, raw_input().split())
        E = [0] * 100
        A = [0] * 100
        for _ in xrange(Z):
            n, e, a = map(int, raw_input().split())
            E[n] = e
            if e == 3:
                A[n] = -a
            else:
                A[n] = a
        solve(X, Y, Z, V, E, A)

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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

const int LIMIT = 200001;

double dp[22][LIMIT];

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N;
  cin >> N;
  vector<double> a(N);
  rep(i, N) cin >> a[i];

  fill(dp[0], dp[22], 1e10);
  reps(i, 1, LIMIT) dp[0][i] = fabs(a[0]-i)/a[0];
  rep(i, N-1) {
    reps(j, 1, LIMIT) {
      for(int k = 1; k*j < LIMIT; k++) {
	chmin(dp[i+1][k*j], max(dp[i][j], fabs(a[i+1]-k*j)/a[i+1]));
      }
    }
  }

  double ans = 1e10;
  reps(i, 1, LIMIT) chmin(ans, dp[N-1][i]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 37644
N, M = map(int, input().split())
kss = [list(map(int, input().split())) for _ in range(M)]
ps = list(map(int, input().split()))

answer = 0
for i in range(1 << N):
    for (_, *ss), p in zip(kss, ps):
        okay = True
        if sum([(i >> s-1) & 1 for s in ss]) % 2 != p:
            okay = False
            break
    if okay:
        answer += 1

print(answer)


Measured memory_bytes: 3064
<?php
//GCD（最大公約数）⇒ユークリッドの互除法
//LCM（最小公倍数）⇒ $a*$b/GCD（ダブルカウントの素因数を除去するイメージ）

$file_handle = fopen('php://stdin', "r");
//$file_handle = fopen('aoj0005_in.txt', "r");

while(1){
	$res = fscanf($file_handle, '%d %d', $a,$b);
	//終了条件
	if ($res==0) break;
	//スワップ
	if($a<$b){
		//$aの方が小さくなるように
		$tmp = $a;
		$a = $b;
		$b = $tmp;
	}
	//LCM用にデフォルト値を保存しておく
	$da = $a;
	$db = $b;
	//GCD。breakしたときの【$b】が最大公約数
	while(1){
		$r = $a % $b;
		if ($r==0){
			break;
		}
		$a = $b;
		$b = $r;
	}
	$gcd = $b;
	//LCM
	$lcm = $da*$db / $gcd;
	//出力
	echo $gcd.' '.$lcm.PHP_EOL;
}
fclose($file_handle);

Measured memory_bytes: 6592
N = int(input())
S = input()

wc = [0, 0]
ec = [S.count("E")]

lc = wc[-1] + ec[-1]
for s in S:
	wc += [wc[-1] + ("W" == s)]
	ec += [ec[-1] - ("E" == s)]
	#print(wc[-1], ec[-1])
	lc = min(lc, wc[-1] + ec[-1])

#print(wc[1:-1])
#print(ec[1:])
print(lc)


Measured memory_bytes: 27124
#include <bits/stdc++.h>
#define ll long long
#define fop(i,m,n) for(ll i=m;i<n;i++)
using namespace std;
int main(){
	ll n;
	cin >> n;
	vector<double> dp(1,1);
	fop(i,0,n){
		double x;
		cin >> x;
		vector<double> dpp(i+2);
		fop(j,0,i+1){
			dpp[j] += dp[j] * (1 - x);
			dpp[j+1] += dp[j] * x;
		}
		swap(dp,dpp);
	}
	double ans = 0;
	fop(i,0,n+1){
		if(i > n-i) ans += dp[i]; 
	}
	cout << fixed << setprecision(12) << ans;
}

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

int main(){
    const int INF = 1e9;
    int n, m;
    int cv[25];
    int dp[50010];
    cin >> n >> m;
    for(int i=0; i<m; i++) cin >> cv[i];
    for(int i=0; i<n+1; i++) dp[i] = INF;
    dp[0] = 0;

    for(int i=1; i<n+1; i++){
        for(int j=0; j<m; j++){
            if(i - cv[j] >= 0 && dp[i] > dp[i-cv[j]]){
                dp[i] = min(dp[i-cv[j]] + 1, dp[i]);
            }
        }
    }

    cout << dp[n] << endl;
}



Measured memory_bytes: 3296
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,c=1,n,j,p=0;
    cin>>n;
   /* string a;
    set<string>x;
    for(i=0; i<n; i++)
    {
        cin>>a;
        x.insert(a);
    }
    cout<<x.size()<<endl;*/
   vector<string>a;
   string s;
    for(i=0; i<n; i++)
    {
        cin>>s;
        a.push_back(s);

    }
    sort(a.begin(),a.end());
     for(i=0; i+1<n; i++)
    {
        if(a[i]!=a[i+1])
        {
            c++;
        }
    }
    cout<<c<<endl;
}


Measured memory_bytes: 11588
n,k,*a = map(int,open(0).read().split())
b = {}
for i in a:
  if i in b:
    b[i] += 1
  else:
    b[i] = 1
ans = 0
a = sorted(list(b.values()))
for i in range(max(0,len(a)-k)):
  ans += a[i]
print(ans)

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

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> A;
    int in;
    for (int i = 0; i < N; i++)
    {
        cin >> in;
        A.emplace_back(in);
    }
    
    int all = 1;
    for (int i = 0; i < N; i++)
    {
        all *= 3;
    }
    
    int odd = 1;
    for (int i = 0; i < N; i++)
    {
        if (A[i] % 2 == 0)
        {
            odd *= 2;
        }else
        {
            odd *= 1;
        }
        
    }
    
    cout << all - odd << endl;

    return 0;
}

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

using namespace std;
 
int main() {
    int A, B;
    cin >> A >> B;
    if(B == 1) cout << 0 << endl;
    else if(B <= A) cout << 1 << endl;
    else {
      int ans;
      ans = ((B-A)+(A-1)-1)/(A-1) +1;
      cout << ans << endl;
    }
}



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

///******************************** C o n t a i n e r ********************************///

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

///*********************************** C o n s t ***********************************///

const int       N=1e6+123;
const double    PI = acos(-1);
const ll        MOD=1000000007;                 ///1e9+7
ll dx[] = {+1, 0, -1, 0, +1, +1, -1, -1};       ///first 4 for adjacent
ll dy[] = {0, +1, 0, -1, +1, -1, +1, -1};
ll dx8[]= {+1, +1, -1, -1, +2, +2, -2, -2};    ///knights move
ll dy8[]= {+2, -2, +2, -2, +1, -1, +1, -1};

///********************************** M a r c o ***********************************///

#define pb push_back
#define MP make_pair
#define F first
#define S second
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define sz(x) x.size()
#define el <<'\n'
#define sp <<' '
#define print(a) {for(auto x:a)cout<<x<<" ";cout<<endl;}
#define mem(a,b) memset(a, b, sizeof(a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) (a)*(a)

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

///*********************************** F u n c t i o n ***********************************///

ll powmod(ll a,ll b){ a%=MOD;if(!a) return 0;ll pr=1;while(b>0){if(b&1){pr*=a;pr%=MOD;--b;}a*=a;a%=MOD;b/=2;}return pr;}
ll modinverse(ll a){return powmod(a,MOD-2);}
bool isPrime(ll n){ if(n<=1)return false;if(n<=3)return true;if(n%2==0 or n%3==0)return false;for(ll i=5;i*i<=n;i+=6){if(n%i==0 or n%(i+2)==0)return false;}return true;}
void seive(bool a[]){ll mx=sqrt(N),ii,jj;for(ii=3;ii<=mx;ii+=2)if(!a[ii])for(jj=ii*ii;jj<N;jj+=2*ii)a[jj]=true;}
void numofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]++; else a[jj]+=2;}}}
void sumofdiv(ll a[]){ll mx=sqrt(N),ii,jj;for(ii=1;ii<=mx;ii++){for(jj=ii*ii;jj<N;jj+=ii){if(jj==ii*ii) a[jj]+=ii; else a[jj]+=ii+jj/ii;}}}

///**************************************************** C o d e ****************************************************///
///-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=///
ll s,dp[2005],i,j;

void _case()
{
    cin>>s;
    dp[0]++;
    for(i=3;i<=s;i++){
        for(j=3;j<=s;j++){
            if(j<=i){
                dp[i]+=(dp[i-j])%MOD;
                dp[i]%=MOD;
            }
        }
    }
    cout<<dp[s] el;
}

main()
{
    fastio();
    _case();

}


///Thank you.


///Brainless_Loco Terminates Here!


Measured memory_bytes: 3660
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n - 1];

        int ans = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            b[i] = sc.nextInt();
            ans += b[i];
        }
        for (int i = 0; i < n - 1; i++) {
            c[i] = sc.nextInt();
        }

        for (int i = 0; i < n - 1; i++) {
            if (a[i + 1] == a[i] + 1) {
                ans += c[a[i] - 1];
            }
        }
        System.out.println(ans);

        sc.close();
    }

}


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

int main(){

    long long n, k; cin >> n >> k;
    long long q = n / k;
    long long r = n % k;
    vector<long long> v(k, q);
    for(long long i = 1; i <= r; i++) v[i]++;
    //for(long long i = 0; i < k; i++) cout << v[i] << " ";
    //cout << endl;

    long long ans = 0;
    for(long long a = 1; a <= n; a++){
        long long a_mod = a % k;
        long long b_mod = (k - a_mod) % k;
        long long num_b = v[b_mod];
        //cout << ">> " << b_mod << endl;
        long long c_mod = (k - b_mod) % k;
        //cout << a_mod << " " << b_mod << " " << c_mod << endl;
        if(a_mod + c_mod != 0 && a_mod + c_mod != k) continue;
        //cout << a << endl;
        long long num_c = v[c_mod];
        //cout << num_b << " " << num_c << endl;
        //cout << ans << endl;
        ans += num_b * num_c;
    }

    cout << ans << endl;
    return 0;
}

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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;

  int price;
  bool should_get_c = C * 2 < (A + B);
  if (should_get_c) {
    int rest = X - Y;
    if (rest < 0) rest = -rest;
    int c_to_get;
    bool should_still_get_c = 0;
    if (X < Y) {
      c_to_get = Y - rest;
      X = 0;
      Y = rest;
      should_still_get_c = C * 2 < B;
    } else {
      c_to_get = X - rest;
      X = rest;
      Y = 0;
      should_still_get_c = C * 2 < A;
    }
    c_to_get *= 2;
    if (should_still_get_c) {
      c_to_get += rest * 2;
      X = 0, Y =0;
    }
    price = C * c_to_get + A * X + B * Y;
  } else {
    price = A * X + B * Y;
  }
  cout << price << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}

struct P{double x; double y;};

// 2点間の距離
double dist(P p1, P p2){
	double dx = p1.x - p2.x;
	double dy = p1.y - p2.y;
	return sqrt(dx*dx + dy*dy);
}

void mainsolve(){

	ll n;
	cin >> n;
	vector<P> ps(n);
	rep(i,n){
		double x,y;
		cin >> x >> y;
		ps[i] = P{x,y};
	}

	// (x,y)を中心としたときの最遠点との距離
	auto f = [&](double x, double y){
		P center = P{x,y};
		double res = 0;
		rep(i,n){
			res = max(res, dist(center, ps[i]));
		}
		return res;
	};

	// fにおいてxを固定したときのfの最小値
	auto g = [&](double x){
		double l = 0;
		double r = 1000;
		rep(i,100){
			double p1 = (l*2+r)/3;
			double p2 = (l+r*2)/3;
			if(f(x,p1) > f(x,p2)) l = p1;
			else r = p2;
		}
		return f(x,l);
	};

	double l = 0;
	double r = 1000;
	rep(i,100){
		double p1 = (l*2+r)/3;
		double p2 = (l+r*2)/3;
		if(g(p1) > g(p2)) l = p1;
		else r = p2;
	}

	printf("%.10f\n", g(l));
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}

ll nCr(vll &fac,vll &finv,ll n,ll r){
	if(n<r||n<0||r<0) return 0 ;
	if(n==r||r==0) return 1 ;
	return fac.at(n)*finv.at(n-r)%mod*finv.at(r)%mod ;
}
ll nHr(vll &fac,vll &finv,ll n,ll r){return nCr(fac,finv,n+r-1,n-1) ;}

int main(){
	ll n,k ;
	cin >> n >> k ;
	vll fac(n*2,1),inv(n*2,1),finv(n*2,1) ;
	for(int i=2;i<fac.size();i++){
		fac.at(i) = fac.at(i-1)*i%mod ;
		inv.at(i) = mod-inv.at(mod%i)*(mod/i)%mod ;
		finv.at(i) = finv.at(i-1)*inv.at(i)%mod ;
	}
	ll ans = 1 ;
	for(int i=1;i<=min(n-1,k);i++){
		ans += nCr(fac,finv,n,i)*nHr(fac,finv,n-i,i)%mod ;
		ans %= mod ;
	}
	cout << ans << endl ;
}


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

bool is_prime(int n)
{
  for (int i = 2; i*i<=n; i++) {
    if (n%i == 0) {
      return false;
    }
  }
  return n != 1;
}

int main()
{
  int X;
  cin >> X;
  while(1) {
    if (is_prime(X)) {
      cout << X << endl;
      return 0;
    }
    X++;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#include<iomanip>//浮動小数点数を出力する制度の指定
//使い方　数値をnumとして　cout<<setprecision(n)<<num ;nは桁数
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end())
#define REV(a) reverse((a).begin(),(a).end())
using namespace std;
using ll =long long;
using db = double;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
/*覚えてないことメaモ
  数値型から文字列に変換　to_string(number);これは簡単
  文字列から数値型に変換　stoi(number)
  文字列からllに変換　stoll(number)
  __gcd(a,b)は最大公約数を取ってくれる、aとb
  の大きい方をNとしたとき、計算量は√N
 */
const int mod = 1e9 + 7;
//ここから書き始める
int main(){
	int a , b;
	cin >> a>> b;
	int ans = max(a-2*b,0);
	cout << ans << endl;


}



Measured memory_bytes: 256