akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<memory>
#include<cmath>
#include<stack>

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define pb push_back
#define DEBUG false

using namespace std;
 
typedef long long ll;
typedef pair<int,int> P;
const int mod=1e9+7,INF=1<<30;
const double EPS=1e-12,PI=3.1415926535897932384626;
const ll LINF=1LL<<60;
const int MAX_N=100005;

pair<ll,ll> ab[MAX_N];
ll a[MAX_N],b[MAX_N];

int main(){
  ll X,Y,Z,N;
  ll csum = 0; //最後に足す
  cin >> X >> Y >> Z ;
  N = X+Y+Z;
  rep(i,N){
    ll _a,_b,_c;
    scanf("%lld%lld%lld",&_a,&_b,&_c);
    ab[i].first = _a - _c;
    ab[i].second = _b - _c;
    csum += _c;
  }
  sort(ab,ab+N,[](pair<ll,ll> x,pair<ll,ll> y){
    return x.first-x.second<y.first-y.second;
  });
  priority_queue<ll,vector<ll>,greater<ll>> que;
  ll asum=0,bsum=0;
  rep(i,N){
    if(que.size()<Y){
      que.push(ab[i].second);
      bsum += ab[i].second;
      b[i] = bsum;
    }else{
      ll _in,_out;
      _in = ab[i].second;
      que.push(_in);
      _out = que.top();
      que.pop();
      bsum += (_in-_out);
      b[i] = bsum;
    }
  }
  que = priority_queue<ll,vector<ll>,greater<ll>>();
  for(int i=N-1;i>=0;i--){
    if(que.size()<X){
      que.push(ab[i].first);
      asum += ab[i].first;
      a[i]=asum;
    }else{
      ll _in,_out;
      _in = ab[i].first;
      que.push(_in);
      _out = que.top();
      que.pop();
      asum += (_in-_out);
      a[i] = asum;
    }
  }
  ll ans = -LINF;
  REP(i,Y-1,N-X){
    //cout << "i = " << i ;
    ans = max(ans,a[i+1]+b[i]);
    //cout << "  a:" << a[i] << " b:" << b[i] << endl;
  }
  cout << ans+csum << endl;
  return 0;
}

Measured memory_bytes: 4296
#include<bits/stdc++.h>
using namespace std; 
typedef long long ll;
#define pb push_back
#define fi first
#define se second
const ll mod = 1e9+7;
const int N = 1e5+6;
void solve(){
	int k,s; 
	cin>>k>>s; 
	int ans = 0;
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			int z = s-i-j;
			if(z>=0 and z<=k)ans++;
		}
	}
	cout<<ans<<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: 3556
#include <bits/stdc++.h>

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



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

	string a,b;
	cin >>a >>b;
	string s =a+b;
	ll nms = stoll(s);
	
	rep(i,200000){
		if(nms == i*i){
			puts("Yes"); return 0;
		}
	}
	puts("No");
	return 0;
	
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <unordered_map>
#include <climits>
#include <set>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>
#include <locale>
#include <random>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

using LL = long long;


int main() {

    int N, M;
    cin >> N >> M;

    vector<int> size(N, 1);
    vector<bool> red(N, false);
    red[0] = true;

    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        size[y]++;
        if (red[x]) red[y] = true;
        if (size[x] == 1) {
            size[x]--;
            red[x] = false;
        } else {
            size[x]--;
        }
    }

    int ans = count(red.begin(), red.end(), true);
    cout << ans << endl;

    return 0;
}



























Measured memory_bytes: 640
from collections import defaultdict
N = int(input())
word_count = defaultdict(int)
for _ in range(N): 
    word_count[input()] += 1
max_amount = sorted(word_count.items(), key=lambda x:x[1],  reverse=True)[0][1]
max_amount_words = sorted([k for k, v in word_count.items() if v == max_amount])
print('\n'.join(max_amount_words))

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

int main() {
  int N, M;
  cin >> N >> M;
  int a = 0;
  for(int i = 0; i < N; i++) {
    a += i;
  }
    for(int i = 0; i < M; i++) {
    a += i;
  }
  cout << a << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	M = pow2(N);
	vector< int > A(M + 1);
	rep(i, M) cin >> A[i];
	A[M] = -1;
	vector< vector< pii > > dp(N + 1, vector< pii >(M, pii(M, M)));
	rep(b, M) dp[0][b] = pii(b, M);
	rep(i, N) rep(b, M) {
		set< int > s;
		s.insert(dp[i][b].first);
		s.insert(dp[i][b].second);
		if (b & (1 << i)) {
			int b2 = b - (1 << i);
			s.insert(dp[i][b2].first);
			s.insert(dp[i][b2].second);
		}
		for (auto it = s.begin(); it != s.end(); it++) {
			int a = A[*it];
			if (A[dp[i + 1][b].second] < a)
				dp[i + 1][b].second = *it;
			if (A[dp[i + 1][b].first] < a)
				swap(dp[i + 1][b].first, dp[i + 1][b].second);
		}
	}
	int ans = 0;
	for (int b = 1; b < M; b++) {
		chmax(ans, A[dp[N][b].first] + A[dp[N][b].second]);
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

#define int ll

#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)

ll read(){
	ll x;
	scanf("%lld",&x);
	return x;
}

void print(ll x){
	printf("%lld\n",x);
}

using vi=vector<int>;
#define PB push_back
#define ALL(x) x.begin(),x.end()

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

template<class T>
T Sq(T t){
	return t*t;
}

using Pos=complex<double>;

double Tri2(Pos a,Pos b,Pos c){
	////;<<a<<" "<<b<<" "<<c<<endl;
	b-=a;
	c-=a;
	return b.real()*c.imag()-b.imag()*c.real();
}

vector<double> Waf(vector<Pos> ps){
	int n=ps.size();
	vector<double> ans(n,0);
	REP(i,n){
		ps.PB(ps[i]);
	}
	REP(i,n){
		Pos a=ps[i],b=ps[i+1],c=(b-a)*Pos(0.5,0.5*sqrt(3))+a;
		//;<<c<<endl;
		int lw=0,up=n-1;
		while(up-lw>1){
			const int mid=(lw+up)/2;
			//;<<"w "<<mid<<" "<<Tri2(b,c,ps[i+1+mid])<<endl;
			if(Tri2(b,c,ps[i+1+mid])>=0)
				up=mid;
			else
				lw=mid;
		}
		up--;
		lw=0;
		//;<<i<<" "<<lw<<" "<<up<<endl;
		while(1){
			int m1=(lw*2+up)/3,m2=(lw+up*2)/3;
			if(m1==m2)break;
			double s1=Tri2(c,b,ps[i+1+m1]);
			double s2=Tri2(c,b,ps[i+1+m2]);
			if(s1>=s2){
				if(up==m2)
					break;
				up=m2;
			}else{
				if(lw==m1)
					break;
				lw=m1;
			}
		}
		double len=abs(a-b);
		FOR(j,lw,up+1){
			Pos d=ps[i+1+j];
			double s=Tri2(c,b,d)/len;
			//;<<i<<" "<<j<<" "<<s<<endl;
			chmax(ans[i],s*2/sqrt(3));
		}
		//;<<i<<" "<<ans[i]<<endl;
	}
	return ans;
}

signed main(){
	int n=read();
	vector<Pos> ps(n);
	REP(i,n){
		int x=read(),y=read();
		ps[i]=Pos(x,y);
	}
	vector<double> waf=Waf(ps);
	reverse(ps.begin()+1,ps.end());
	for(auto&p:ps){
		p=Pos(-p.real(),p.imag());
	}
	vector<double> relka=Waf(ps);
	reverse(ALL(relka));
	reverse(ps.begin()+1,ps.end());
	for(auto&p:ps){
		p=Pos(-p.real(),p.imag());
	}
	
	double ans=1e19;
	REP(i,n){
		double len=abs(ps[i]-ps[(i+1)%n]);
		chmin(ans,len+waf[i]+relka[i]);
	}
	cout<<fixed<<setprecision(20)<<ans<<endl;
}



Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mod 1000000007
int main(){
	int h,w;
	cin>>h>>w;
	vector<vector<char> > a(h,vector<char>(w,0));
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	vector<vector<lli> > dp(h,vector<lli>(w,0));
	dp[0][0]=1;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(i==0&&j==0)
				continue;
			if(a[i][j]=='#'){
				dp[i][j]=0;
			}
			else{
				dp[i][j]=((i-1>=0?dp[i-1][j]:0)+(j-1>=0?dp[i][j-1]:0))%mod;
			}
		}
	}
	cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 9088
#include <stdio.h>
#define INFTY 100000000;
int a[100][100],d[100],n;

int main(){
int i,j,k,u,c,v;
	
	scanf("%d",&n);
	
	for(i=0;i<100;i++){
		for(j=0;j<100;j++){
			a[i][j]=INFTY;
		}
		a[i][i]=0;
	}
	
	for(i=0;i<n;i++){
		scanf("%d %d",&u,&k);
		for(j=0;j<k;j++){
			scanf("%d %d",&v,&c);
			a[u][v]=c;
		}
	}
	
	for(k=0;k<n;k++){
		for(i=0;i<n;i++){
	    for(j=0;j<n;j++){
	    	if(a[i][j]>=(a[i][k]+a[k][j])) a[i][j]=a[i][k]+a[k][j];
	    }
    }
  }

  for(i = 0 ; i < n ; i++){
    printf("%d %d\n" ,i ,a[0][i]);
  }

	return 0;
}



Measured memory_bytes: 2088
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try{
		Scanner sc = new Scanner(System.in);

		int h = sc.nextInt();
		int w = sc.nextInt();
		int[][] mass = new int[h][w];
		String line = sc.nextLine();

		for (int i = 0; i < h; i++) {
			line = sc.nextLine();
			for (int x = 0; x < w; x++) {
				if (line.charAt(x) == '#') {
					mass[i][x] = 1;
				}else{
					mass[i][x] = 0;
				}
			}
		}
		String ans = "Yes";

		for (int i = 0; i < h; i++) {
			for (int x = 0; x < w; x++) {
				if(mass[i][x] == 1){
				boolean yes = false;

				// 左のマス
				if (x != 0) {
					if (mass[i][x - 1] == 1)
						yes = true;
				}
				// 右のマス
				if (x != w - 1) {
					if (mass[i][x + 1] == 1)
						yes = true;
				}

				// 上のマス
				if (i != 0) {
					if (mass[i - 1][x] == 1)
						yes = true;
				}

				// 下のマス
				if (i != h - 1) {
					if (mass[i + 1][x] == 1)
						yes = true;
				}

				if (!yes) {
					ans = "No";
				}

				}
			}
		}

		System.out.println(ans);
		}catch(Exception e){
			e.printStackTrace();
		}

	}
}


Measured memory_bytes: 22612
#include <iostream>
#include <algorithm>

using namespace std;


int main()
{
    int n;
    int H[100];
    int ans=0;
    int maxH=-1;
    
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> H[i];
        if(maxH<=H[i]){
            maxH=H[i];
            ans++;
        }
    }

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

Measured memory_bytes: 256
import sys


def input():
    return sys.stdin.readline()[:-1]


def main():
    n, a, b, c, d = map(int, input().split())
    a -= 1
    b -= 1
    c -= 1
    d -= 1
    s = input()

    if "##" in s[a:c] or "##" in s[b:d]:
        print("No")
        sys.exit()

    if c < d:
        print("Yes")
        sys.exit()

    if d < c:
        for i in range(b, d+1):
            if "." == s[i-1] == s[i] == s[i+1]:
                print("Yes")
                sys.exit()
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 40944
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    set<string> st;
    rep(i, N) {
        string S; cin >> S;
        st.insert(S);
    }
    cout << st.size() << endl;

    return 0;
}


Measured memory_bytes: 19216
//Be Name Khorgraph, Besmellah Rahmane Rahim, In The Name Of God;
//#include<bits/stweight++.h>
#include<iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include<bitset>
#include<list>
#include<cassert>
#include<numeric>
#include <stdio.h>
#include <string.h>
#include<iomanip>
#include<unordered_map>
#include<unordered_set>
#include <iostream>
#include <fstream>


using namespace std;

const int N = 2e5 + 5;
int a[N];
int n;

int main()
{
	cin >> n;
	for (int i = 0; i < n - 1; i++)
	{
		int tmp;
		cin >> tmp;
		a[tmp - 1]++;
	}
	for (int i = 0; i < n; i++)
	{
		cout << a[i] << endl;
	}
	


}




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

int main() {
  int n;
  cin >> n;
  vector<int> xs(n);

  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }

  int ret = 101*101*101;
  for (int i = 0; i <= 100; i++) {
    int f = 0;
    for (int x = 0; x < n; x++) {
      f += (xs[x] - i) * (xs[x] - i);
    }
    ret = min(f, ret);
  }

  cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define lp(i, n) for(int i = 0; i < n; i++)
#define int long long

int32_t main() {
ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
        int n; cin >> n;
        string str; cin >> str;
        if (n & 1) cout << "No";
        else {
                bool b = 1;
                lp(i, n/2) {
                        if (str[i] != str[n/2 + i]) b = 0;
                }
                cout << (b?"Yes":"No");
        }
return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a;
    cin>>a;
    long long b=(a-1)/11;
    if((a-1)%11<=5){
        cout<<b*2+1<<endl;
    }
    else{
        cout<<b*2+2<<endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int Alice = in.nextInt();
		int Bob = in.nextInt();
		System.out.println(Alice == Bob ? "Draw" : Alice == 1 ? "Alice" : Bob == 1 ? "Bob" : Alice > Bob ? "Alice" : "Bob");
	}
	
}


Measured memory_bytes: 9680
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
using namespace std;
 
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
 
const ll INF=1e9+7;

int main(){
    ll n,c;
    cin >> n >> c;
    vector<ll> xr(n);
    vector<ll> xl(n);
    vector<ll> vr(n);
    vector<ll> vl(n);
    rep(i,n){
        cin >> xr[i] >> vr[i];
    }
    rep(i,n){
        xl[i]=c-xr[n-1-i];
        vl[i]=vr[n-1-i];
    }
    vector<ll> r(n);
    vector<ll> l(n);
    ll sumr=0;
    rep(i,n){
        if(i){
            sumr-=(xr[i]-xr[i-1]);
            sumr+=vr[i];
        }
        else{
            sumr-=xr[i];
            sumr+=vr[i];
        }
        r[i]=sumr;
    }
    ll suml=0;
    rep(i,n){
        if(i){
            suml-=(xl[i]-xl[i-1]);
            suml+=vl[i];
        }
        else{
            suml-=xl[i];
            suml+=vl[i];
        }
        l[i]=suml;
    }
    vector<ll> ar(n);
    vector<ll> al(n);
    ll curr_r=r[0];
    rep(i,n){
        curr_r=max(r[i],curr_r);
        ar[i]=curr_r;
    }
    ll curr_l=l[0];
    rep(i,n){
        curr_l=max(l[i],curr_l);
        al[i]=curr_l;
    }
    ll ans=0;
    rep(i,n){
        if(n-i-1>=1){
            ans=max(ans,r[i]+al[n-i-2]-xr[i]);
            ans=max(ans,l[i]+ar[n-i-2]-xl[i]);
        }
        ans=max(ans,r[i]);
        ans=max(ans,l[i]);
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define INF 1000000000000000000LL
using namespace std;
typedef long long ll;
map<ll, ll> score;
ll T, N, A, B, C, D;
 
ll calc(ll N) {
  if(N==0) return 0;
  if(N==1) return D;
  if(N==2) return min(2LL*D, D + A);
  if(score[N]) return score[N];
  
  ll ret  = INF;
  if(N  <= INF / D) {
    ret = N*D;
  }
  
  ret = min(ret, 1LL*(N%2) * D + A + calc (N/2));
  if(N%2) {
    ret = min(ret, 1LL*(2 - N%2) * D + A + calc (N/2 + 1));
  }
  
  ret = min(ret, 1LL* (N%3) * D + B + calc (N/3));
  if(N%3) {
    ret = min(ret, 1LL*(3 - N%3) * D + B + calc (N/3+1));
  }
  
  ret = min(ret, 1LL*(N%5) * D + C + calc (N/5));
  if(N%5) {
    ret = min(ret, 1LL* (5 - N%5) * D + C + calc (N/5+1));
  }
  score[N] = ret;
  //cout<<N<<" "<<score[N]<<endl;
  return ret;
} 
 
int main() {
  cin>>T;
  while(T--) {
    score.clear();
    cin>>N>>A>>B>>C>>D;
    cout<<calc(N)<<endl;
  }
  return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxn = 1e5 + 10;

int vec[maxn];

string s[] = {"Adrian", "Bruno", "Goran"};
int ans[3];

int main() {
    int n, m;
    set<int> s;
    scanf("%d", &n);
    while(n--) {
        scanf("%d", &m);
        if(s.count(m)) s.erase(m);
        else s.insert(m);
    }
    printf("%d\n", s.size());
}

Measured memory_bytes: 4864
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <random>
#include <queue>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b;cin >> a >> b;
	cout << a*b << endl;
}


Measured memory_bytes: 3208
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <array>
#include <cassert>
#include <utility>
#include <vector>
#include <atcoder/maxflow>

template <class InputIterator>
std::ostream& range_output(std::ostream& os_arg, InputIterator first_arg, InputIterator last_arg){ if(first_arg != last_arg){ do{ os_arg << *(first_arg++); if(first_arg == last_arg) break; os_arg << ' '; } while(true); }  return os_arg; }
template <class Tp> std::ostream& operator << (std::ostream& os_arg, const std::vector<Tp>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class Tp, std::size_t Size> std::ostream& operator << (std::ostream& os_arg, const std::array<Tp, Size>& arr_arg){ return range_output(os_arg, arr_arg.cbegin(), arr_arg.cend()); }
template <class S, class T> std::ostream& operator << (std::ostream& os_arg, const std::pair<S, T>& pair_arg){ return os_arg << '(' << pair_arg.first << ", " << pair_arg.second << ')'; }

#ifndef ONLINE_JUDGE
    template <typename Head> void dump_out(Head head_arg){ std::cerr << head_arg << '\n'; }
    template <typename Head, typename... Tail>
    void dump_out(Head head_arg, Tail... tail_args){ std::cerr << head_arg << ", "; dump_out(tail_args...); }
    #define dump(...) do { std::cerr << "[in line " << __LINE__ << "] " << #__VA_ARGS__ << " : "; dump_out(__VA_ARGS__); } while(false)
#else
    #define dump(...) (void(0))
#endif


char S[100][110];
char R[100][110];

int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    std::cout << std::fixed << std::setprecision(16);
    int n, m; std::cin >> n >> m;
    for(int i = 0; i < n; ++i) std::cin >> S[i];
    auto change = [&](int x, int y){ return x * m + y; };
    const int N = n * m;
    atcoder::mf_graph<int> flow(N + 2);
    for(int i = 0; i < n; ++i) for(int j = 0; j < m; ++j) if(S[i][j] == '.'){
        if((i + j) % 2) flow.add_edge(change(i, j), N + 1, 1);
        else flow.add_edge(N, change(i, j), 1);
    }
    for(int i = 0; i < n; ++i) for(int j = 0; j + 1 < m; ++j) if(S[i][j] == '.' and S[i][j + 1] == '.'){
        if((i + j) % 2) flow.add_edge(change(i, j + 1), change(i, j), 1);
        else flow.add_edge(change(i, j), change(i, j + 1), 1);
    }
    for(int i = 0; i + 1 < n; ++i) for(int j = 0; j < m; ++j) if(S[i][j] == '.' and S[i + 1][j] == '.'){
        if((i + j) % 2) flow.add_edge(change(i + 1, j), change(i, j), 1);
        else flow.add_edge(change(i, j), change(i + 1, j), 1);
    }

    std::cout << flow.flow(N, N + 1) << '\n';
    const auto v = flow.edges();
    for(const auto& e : v){
        if(e.from == N or e.to == N + 1 or e.flow == 0) continue;
        std::pair<int, int> c1(e.from / m, e.from % m);
        std::pair<int, int> c2(e.to / m, e.to % m);
        if(c1 > c2) std::swap(c1, c2);
        if(c1.first == c2.first){ S[c1.first][c1.second] = '>'; S[c2.first][c2.second] = '<'; }
        else { S[c1.first][c1.second] = 'v'; S[c2.first][c2.second] = '^'; }
    }
    for(int i = 0; i < n; ++i) std::cout << S[i] << '\n';
    
    
    return 0;
}

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

int main() {
  int n;
  int cost = 1e+9;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  int ans = 0;
  for (int i = -100; i <= 100; i++) {
    int sum = 0;
    for (int j = 0; j < n; j++) {
      sum += (a.at(j) - i) * (a.at(j) - i);
    }
    if (sum < cost) {
      cost = sum;
      ans = i;
    }
    if (sum == 0) {
      cout << 0;
      return 0;
    }
  }
  cout << cost;
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=get_nsp
if (n[0]==n[1] and n[1]==n[2]) or (n[1]==n[2] and n[2]==n[3])
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 3836
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        String correct = "CODEFESTIVAL2016";
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        String S = scan.next();
        char[] c = correct.toCharArray();
        char[] d = S.toCharArray();
        int answer = 0;
        for (int i = 0; i < c.length; i++) {
            if (c[i] != d[i]) {
                answer += 1;
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 23508
#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)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -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 main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  ll n;
  cin >> n;
  vector<ll> t(n), a(n);
  rep(i, n) cin >> t[i];
  rep(i, n) cin >> a[i];

  vector<ll> minth(n), maxth(n);
  minth[0] = t[0], maxth[0] = t[0];
  FOR(i, 1, n) {
    minth[i] = (t[i - 1] == t[i] ? 1 : t[i]);
    maxth[i] = t[i];
  }
  vector<ll> minah(n), maxah(n);
  minah[n - 1] = a[n - 1], maxah[n - 1] = a[n - 1];
  repr(i, n - 2) {
    minah[i] = (a[i] == a[i + 1] ? 1 : a[i]);
    maxah[i] = a[i];
  }

  ll ans = 1;
  rep(i, n) {
    ll minh = max(minth[i], minah[i]), maxh = min(maxth[i], maxah[i]);
    if (maxh - minh + 1 <= 0) {
      cout << 0 << '\n';
      return 0;
    }
    ans = ans * (maxh - minh + 1) % mod;
  }
  cout << ans << '\n';




  
  return 0;
}

Measured memory_bytes: 4992
(defun greedy-takahashi (a b n)
  (let ((t1 (max (- a n) 0))
        (t2 b))
    (if (= t1 0)
        (setf t2 (max (+ t2 (- a n)) 0)))
    (format t "~A ~A ~%" t1 t2)))

(greedy-takahashi (read) (read) (read))

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int

int main(){
int n,m;
cin>>n>>m;
ll h[n];
rep(i,n){
  cin>>h[i];
}
int a[m],b[m];
rep(i,m){
  cin>>a[i]>>b[i];
}
bool Q[n];
rep(i,n){
    Q[i]=true;
}
rep(i,m){
if(h[a[i]-1]>h[b[i]-1]){
  Q[b[i]-1]=false;
}else if(h[a[i]-1]<h[b[i]-1]){
  Q[a[i]-1]=false;
}else
{ Q[b[i]-1]=false;
   Q[a[i]-1]=false;
}
}
int ans=0;
rep(i,n){
  if(Q[i]){
    ans++;
  }
 //cout<<Q[i]<<endl;
}
cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 5280
# include <bits/stdc++.h>
#define INF 1e9
using namespace std;

int main(){

  int A, B;
  cin >> A >> B;
  if(A > B){
    cout << 2*A-1 << endl;
  } else if (A < B){
    cout << 2*B-1 << endl;
  } else {
    cout << A + B << endl;
  }
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	set<string>s;
	for(int i=0; i<n; i++){
		string str;
		cin>>str;
		s.insert(str);
	}
	cout<<s.size();
	return 0;
}

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

int main(){
    int N,sum;
    cin >> N;
    vector<int> B(N-1);
    for(int i = 0;i < N - 1;i++){
        cin >> B.at(i);
    }
    sum += B[0] + B[N-2];

    for(int i = 0;i < N - 2; i++){
        sum += min({B[i],B[i+1]});
    }

    cout << sum << endl;
}


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

int main() {
    int N,C;
    cin >> N >> C;
    vector<int> s(N), t(N),c(N);
    for(int i=0; i<N; ++i) cin >> s[i] >> t[i] >> c[i];

    int tt[200001];
    int ch[200001] = {};
    for(int i=1; i<=C; ++i) {
        for(int j=0; j<=200000; ++j) tt[j] = 0;
        for(int j=0; j<N; ++j) {
            if(c[j] == i) {
                ++tt[2*s[j]-1];
                --tt[2*t[j]];
            }
        }
        for(int j=1; j<=200000; ++j) {
            tt[j] += tt[j-1];
            if(tt[j]) ++ch[j];
        }
    }

    int ans = 0;
    for(int j=0; j<=200000; ++j) ans = max(ans, ch[j]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2944
main(){int s[9000],n,m,t,f,i;while(scanf("%d%d",&n,&m),i=0,t=f=1,n)while(++i<=n+m)if(scanf("%d",&s[i]),i>n)if(t+=s[t+=s[i]],t>=n&f==1)printf("%d\n",i-n,f=0);}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
 
int N;
int x[10], y[10];
 
double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}
 
void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double ans = 0.0;
    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) ans += dist(i, j) * 2 / N;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return;
}
 
int main() {
    solve();
    return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  set<int>S = {1, 2, 3};
  S.erase(a);
  S.erase(b);
  if(S.count(1))cout << 1;
  else if(S.count(2))cout << 2;
  else cout << 3;
  return 0;
}
  

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

int main(){
    int N;
    cin>>N;
    int num2=0;
    if(N/1000==2)num2++;
    if(N/100%10==2)num2++;
    if(N/10%10==2)num2++;
    if(N%10==2)num2++;
    cout<<num2<<endl;
    return 0;
}

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

void dfs(int N,vector<vector<int>> ed,stack<pair<int,vector<int>>> s,int &ans){
  if(s.empty()==false){
    int ve=s.top().first;vector<int> arc=s.top().second;
    arc[ve]=1;s.pop();
    bool b=true;
    for(int i=0; i<N; i++){
      if(arc[i]==0){
        b=false;break;
      }
    }
    if(b) ans++;
    else{
      for(int i=0; i<ed[ve].size(); i++){
        if(arc[ed[ve][i]]==0){
          s.push(make_pair(ed[ve][i],arc));dfs(N,ed,s,ans);
        }
      }
    }
  }
}

int main(){
  int N,M;cin >> N >> M;
  vector<vector<int>> ed(N);
  for(int i=0;i<M;i++){
    int a,b;cin >> a >> b;
    ed[a-1].push_back(b-1);ed[b-1].push_back(a-1);
  }
  int ans=0;
  vector<int> arc(N,0);
  stack<pair<int,vector<int>>> s;s.push(make_pair(0,arc));
  dfs(N,ed,s,ans);
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
m = n % 10

if m == 2:
  print('hon')
elif m == 4:
  print('hon')
elif m == 5:
  print('hon')
elif m == 7:
  print('hon')
elif m == 9:
  print('hon')
elif m == 0:
  print('pon')
elif m == 1:
  print('pon')
elif m == 6:
  print('pon')
elif m == 8:
  print('pon')
elif m == 3:
  print('bon')

Measured memory_bytes: 9204
#!/usr/bin/env python
from __future__ import division, print_function
from sys import stdin, exit, maxsize


def main(readline=stdin.readline):
    value = -1
    number = maxsize
    for _ in range(int(readline())):
        a, v = (int(s) for s in readline().split())
        if v > value or v == value and a < number:
            number = a
            value = v
    print(number, value)
    exit()


main()

Measured memory_bytes: 4232
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(H, A):
    return math.ceil(H / A)


def main():
    H, A = read_int_n()
    print(slv(H, A))


if __name__ == '__main__':
    main()


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

const int N_MAX = 10010;
vector<vector<int>> tree(N_MAX);
vector<int> res(N_MAX);
queue<int> q;
priority_queue<int> pq;

int main() {
    ll h, w; cin >> h >> w;
    if(h%3==0 || w%3==0) {
        cout << 0 << endl;
        return 0;
    }
    ll res = min(h, w);
    for(ll i = 1ll; i < h; i++) {
        ll a = min(i, h-i);
        ll b = max(i, h-i);
        ll x = a * w;
        ll y = b * (w/2 + w%2);
        ll z = b * (w/2);
        ll temp = max({x, y, z}) - min({x, y, z});
        chmin(res, temp);
    }
    for(ll i = 1ll; i < w; i++){
        ll a = min(i, w-i);
        ll b = max(i, w-i);
        ll x = a * h;
        ll y = b * (h/2 + h%2);
        ll z = b * (h/2);
        ll temp = max({x, y, z}) - min({x, y, z});
        chmin(res, temp);
    }
    cout << res << endl;
    return 0;
}

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

using ll = int_fast64_t;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define repr(i,n) for(int i{n};i-->0;)

signed main(){

  int n,m;
  cin>>n>>m;
  vector<int> a(m),b(m),c(m);
  rep(i,m){
    cin>>a[i]>>b[i];
    rep(j,b[i]){
      int cij;
      cin>>cij;
      cij--;
      c[i] |= 1<<cij;
    }
  }

  vector dp(1<<12+1,1<<28);
  dp[0] = 0;
  rep(i,1<<12){
    rep(j,m){
      dp[i|c[j]] = min(dp[i|c[j]],dp[i]+a[j]);
    }
  }
  int ans = dp[(1<<n)-1];
  cout<<(ans>=1<<28?-1:ans)<<endl;


}

Measured memory_bytes: 3608
/*input
1
1

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  string str1, str2;
  cin >> str1 >> str2;

  int n = str1.size(), m = str2.size();

  int ans = m;

  for (int i = 0; i <= n - m; i++) {
    string str = str1.substr(i, m);
    int cur = 0;
    for (int j = 0; j < m; j++)
      cur += (str[j] != str2[j]);
    ans = min(ans, cur);
  }  
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>
#include<algorithm>
#include <map>
#include <list>
#include <stack>
#include <queue>
#include <vector>
#include <iostream>
#include <functional>
#include <time.h>
using namespace std;
clock_t fi, endtime;
const int r_c = 0;
const int r_t = 1;
const int MAX_V = 100000;
const int MAX_d = 100000;
const int MAX_E = 500000;
long long int INF = 10000 * 50000;

int n, m, a, b, c, t;
int k, p, q, r;
long long int wf[MAX_V];

struct edge { int from, to, ct; };
edge edg[MAX_E];

int main()
{
	int cou = 0;
	scanf("%d %d %d", &n, &m, &r);
	for (int i = 0; i < m; ++i) {
		scanf("%d %d %d", &a, &b, &c);
		edg[i].from = a; edg[i].to = b; edg[i].ct = c;
	}
	for (int i = 0; i < n; ++i) {
		wf[i] = INF;
	}
	wf[r] = 0;
	while (1) {
		bool bo = false;
		for (int i = 0; i < m; ++i) {
			edge e = edg[i];
			if (wf[e.from] != INF && wf[e.to] > wf[e.from] + e.ct) {
				wf[e.to] = wf[e.from] + e.ct;
				bo = true;
			}
		}
		if (!bo) break;
		++cou;
		if (cou > n) break;
	}
	if (cou > n) printf("NEGATIVE CYCLE\n");
	else {
		for (int i = 0; i < n; ++i) {
			if (wf[i] == INF) printf("INF\n");
			else printf("%lld\n", wf[i]);
		}
	}
}

Measured memory_bytes: 3220
#include<stdio.h>
#include<iostream>

using namespace std;
int main(){
  int N;
  int A[100000];
  int ans[100000];
  cin >> N;
  for(int i=0; i< N; i++){
    int n;
    cin >> n;
    ans[n-1]=i+1;
  }
  for(int i=0; i<N-1; i++){
    cout << ans[i] << " ";
  }
  cout << ans[N-1] << endl;
}

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

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for(int i = (int)(n - 1); i >= 0; --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)
#define BIT(x, i) (((x) >> (i)) & 1)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vc> vvc;
typedef vector<vll> vvll;

int main() {
  int h, w = 5;
  while(cin >> h, h) {
    vvi field(h + 1, vi(w));
    REP(y, h) REP(x, w){
      cin >> field[y][x];
    }
    REP(x, w){
      field[h][x] = x + 1;
    }

    int res = 0;
    bool update = true;
    while(update) {
      update = false;
      // erase
      REP(y, h) {
        auto &ln = field[y];
        auto c = ln.begin() + 2;
        auto l = c;
        auto r = c;
        while(l != ln.begin() && *(l - 1) == *c) l--;
        while(r != ln.end() && *(r + 1) == *c)  r++;
        if (++r - l >= 3) {
          res += (r - l) * *c;
          fill(l, r, 0);
        }
      }

      // drop
      REP(x, w) {
        RREP(y, h - 1) {
          if (!field[y + 1][x] && field[y][x]) {
            swap(field[y + 1][x], field[y][x]);
            update = true;
            y += 2;
          }
        }
      }
    }

    cout << res << endl;

  }
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define int long long
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    int n, ans;
    string s;
    cin>>n>>s;
    int rc = 0, gc = 0, bc = 0;

    for (int i = 0; i < n; i++) {
        if (s[i] == 'R') rc++;
        if (s[i] == 'G') gc++;
        if (s[i] == 'B') bc++;
    }

    ans = rc * gc * bc;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if ((i + j) % 2 == 0) {
                if (
                    s[i] != s[j] &&
                    s[j] != s[(i + j) / 2] &&
                    s[i] != s[(i + j) / 2]
                ) ans--;
            }
        }
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 3636
#include <iostream> 
#include <vector>
#include <cmath>
#include <string>
#include <sstream>
#include <algorithm>
#include <queue>
#include <stack>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <iomanip>
#include <cctype>
#include <climits>
#include <deque>

using namespace std;

using ii = pair<int, int>;
using iic = pair<ii, char>;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;

using ll = long long int;

#define mp(a,b) make_pair(a,b)

const int MOD = 1000 * 1000 * 1000 + 7;

bool res() {
	deque<char> str;
	string s;
	cin >> s;
	if (!cin) return false;
	//for (int i = 0; i < s.size(); ++i) str.push_back(s[i]);


	int q;
	
	cin >> q;
	vector<iic> consultas(q);
	for (int i = 0; i < q; ++i) {
		cin >> consultas[i].first.first;
		if (consultas[i].first.first == 2) {
			cin >> consultas[i].first.second;
			cin >> consultas[i].second;
		}
	}

	bool inv = false;
	deque<char> ini, fin;

	for (int i = 0; i < q; ++i) {
		if (consultas[i].first.first == 1) {
			inv = !inv;
		}
		else {
			if (consultas[i].first.second == 1) {
				if (!inv) {
					ini.push_front(consultas[i].second);
				}
				else {
					fin.push_back(consultas[i].second);
				}
			}
			else {
				if (!inv) {
					fin.push_back(consultas[i].second);
				}
				else {
					ini.push_front(consultas[i].second);
				}
			}
		}
	}

	if (!inv) {
		for (int i = 0; i < ini.size(); ++i) cout << ini[i];
		cout << s;
		for (int i = 0; i < fin.size(); ++i) cout << fin[i];
		cout << '\n';
	}
	else {
		for (int i = fin.size() - 1; i >= 0; --i) cout << fin[i];
		reverse(s.begin(), s.end());
		cout << s;
		for (int i = ini.size() - 1; i >= 0; --i) cout << ini[i];
		cout << '\n';
	}
	

	return true;
}

int main() {
	while (res()) {}
	return 0;
}

Measured memory_bytes: 3200
n = int(input())
a = {}

for i in range(n):
  a[i + 1] = int(input())

b = a[1]
k = 1
if b == 2:
  ans = k
else:
  f = 0
  for i in range(n):
    b = a[b]
    k += 1
    if b == 2:
      ans = k
      f = 1
      break
    else:
      next
  if f == 0:
    ans = -1
print(ans)

Measured memory_bytes: 17892
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long n;
  cin>>n;
  if(n%10==2||n%10==4||n%10==5||n%10==7||n%10==9)
    cout<<"hon"<<endl;
  else if(n%10==3)
    cout<<"bon"<<endl;
  else
    cout<<"pon"<<endl;
}

Measured memory_bytes: 3548
#include <iostream>
#include <cstdlib>
#include <vector>
#include <stack>
#include <cstdio>
#include <cstring>
using namespace std;

int main(){

    stack<int> a;
    char b[100];
    
    while( cin >> b ){
        if(b[0]=='+'){
            int x = a.top();
            a.pop();
            int y = a.top();
            a.pop();
            int z = x + y;
            a.push(z);
        }
        else if(b[0]=='-'){
            int x = a.top();
            a.pop();
            int y = a.top();
            a.pop();
            int z = y - x;
            a.push(z);
        }
        else if(b[0]=='*'){
            int x = a.top();
            a.pop();
            int y = a.top();
            a.pop();
            int z = x * y;
            a.push(z);
        }
        else{
            int i = atoi(b);
            a.push(i);
        }
    }
    
    printf("%d\n",a.top());

    return 0;
}



Measured memory_bytes: 3240
#include <iostream>
#include <set>
#include <deque>
#include<string>
#include<algorithm>

using namespace std;

int main()
{
    int n, a, arr[2000005] = {};
    cin >> n;
    for (int i = 0; i < n - 1; i++)
    {
        cin >> a;
        arr[a]++;
    }
    for (int i = 1; i <= n; i++)
        cout << arr[i] << endl;
    return 0;
}

Measured memory_bytes: 11456
#include <iostream>
#include <string>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(void){
    int N;
    string S;
    cin >> N >> S;
    int ans = 0;
    int score = 0;
    rep(i,N){
        if(S[i] == 'I'){
            score++;
        }
        else{
            score--;
        }
        ans = max(score,ans);
    }
    cout << ans;
}


Measured memory_bytes: 3136
a,b,k = (int(i) for i in input().split())

def is_odd(num):
    if num % 2 == 0:
        return False
    else:
        return True

def proc(a,b):
    if is_odd(a):
        a=a-1
    a=a/2
    b+=a
    return a,b

is_a = True
for i in range(k):
    if is_a:
        a,b=proc(a,b)
        is_a=False
    else:
       b,a=proc(b,a)
       is_a=True


a,b=int(a),int(b)
print(a,b)

Measured memory_bytes: 3064
int main(void)
{
	int H=1,W=1,i,j;
	while((H!=0)||(W!=0))
	{
		scanf("%d %d",&H,&W);

		for(j=0;j<H;j++)
		{
			if (j % 2 == 0)
			{

				for (i = 0; i < W; i++)
				{
					if (i % 2 == 0)
					{
						printf("#");
					}
					else
					{
						printf(".");
					}
				}
				printf("\n");
			}
			if (j % 2 == 1)
			{

				for (i = 0; i < W; i++)
				{
					if (i % 2 == 0)
					{
						printf(".");
					}
					else
					{
						printf("#");
					}
				}
				printf("\n");
			}
		}
		if ((H != 0) || (W != 0))
		{
			printf("\n");
		}


	}
	return 0;
}


Measured memory_bytes: 2064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n],k=0,l=999999999;
  for(int i=0;i<n;i++){
    cin >> a[i];
    k+=a[i];
    if(l>a[i]&&a[i]%10!=0)l=a[i];
  }
  if(l==999999999)l=k;
  if(k%10==0)k-=l;
  cout << k;
}


Measured memory_bytes: 256
// #include<iostream>
// #include<vector>
// #include<algorithm>
// #include<map>
// #include<cstring>
// #include<math.h>
// #include<bitset>
// #include<queue>
// #include<set>
// #include<iomanip>
// #include<math.h>
// #include<assert.h>
// #include<string>
// #include<cstdlib>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr ll INF = 1LL << 40;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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;
}
// ----------------------------------------------------------------------------

int main(){
  int N,M;
  cin >> N >> M;
  vector<bool> solve(N+1,false);
  vector<int> cnt(N+1,0);
  for(int i=0; i<M; i++){
    int p;
    string S;
    cin >> p >> S;
    if(solve[p]) continue;
    if(S == "AC"){
      solve[p] = true;
    }else{
      cnt[p]++;
    }
  }
  int AC=0,WA=0;
  for(int i=1; i<=N; i++){
    if(solve[i]){
      AC++;
      WA += cnt[i];
    }
  }
  cout << AC << " " << WA << endl;
 return 0;
}


Measured memory_bytes: 640