akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<string,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<Pi,int> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

P2 d[101]={};

int main() {

	int n;
	string s[101];
	int p[101];

	cin>>n;
	rep(i,n){
		cin>>s[i]>>p[i];
		d[i].first.first=s[i];
		d[i].first.second=p[i];
		d[i].second=i+1;
	}
	sort(d,d+n);

	int f=0;
	rep(i,n){
		if(d[i].first.first==d[i+1].first.first){
			if(f==0)f=i+1;
		}else if(f>0){
			for(int j=i; j>=f-1; j--){
				cout<<d[j].second<<endl;
			}
			f=0;
		}else{
			cout<<d[i].second<<endl;
		}

	}

	return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
int n, s, r;
int main() {
	while(scanf("%d%d", &n, &s), n) {
		int a[102] = {0};
		for(int i = 0; i < n; i++) scanf("%d", &r), a[r]++;
		int ret = 0;
		for(int i = 1; i <= 100; i++) {
			for(int j = max(i, s - i + 1); j <= 100; j++) {
				ret += a[i] * a[j];
			}
		}
		for(int i = s / 2 + 1; i <= 100; i++) ret -= (a[i] * a[i] + a[i]) / 2;
		printf("%d\n", ret);
	}
}

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

int N;
std::vector<int> A;
std::vector<int> portfolio;
long long standard_sum;

int main() {
  std::cin >> N;
  A.assign(N, 0);
  portfolio.assign(N, 0);
  for (int i = 0; i < N; ++i) {
    std::cin >> A[i];
    ++portfolio[A[i]-1];
  }

  for (int i = 0; i < N; ++i) {
    standard_sum += (long long)portfolio[i] * (long long)(portfolio[i]-1)/2;
  }
  for (int k = 0; k < N; ++k) {
    long long out = 0;
    if (portfolio[A[k]-1] == 1) {
      out = standard_sum;
    } else {
      out = standard_sum - portfolio[A[k]-1] + 1;
    }
    std::cout << out << std::endl;
  }
}


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

int main(){
  int N, K;
  cin >> N >> K;
  int n, m;
  m = 0;
  for(int i = 0; i < N; i++){
    cin >> n;
    if(n > K / 2){
      m += K -n;
    }
    else {
      m += n;
    }
  }
  cout << m*2 << endl;
}
       
           


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// sort(cut.begin(),cut.end());

int main ()
{
    int N,M, C; cin>>N>>M>>C;
    int A[21][21];
    int B[21];

    for(int i=0;i<M;i++) cin>>B[i];

    for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
        cin>>A[i][j];
      }
    }

    int sum = 0;
    int cnt=0;
    for(int i=0;i<N;i++){
      for(int j=0;j<M;j++){
          sum += A[i][j] * B[j];

      }

      if((sum + C) > 0) cnt++;

      sum = 0;
    }

    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
const int inf = INT_MAX;

signed main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, k;
	cin>>n>>k;
	int a[n], c[n];

	for(int i=0; i<n; ++i)
	{
		cin>>a[i];
		c[i]=inf;
	}
	if(n==2){
		cout<<(int)abs(a[0]-a[1]);
		return 0;
	}
	c[0]=0;
	for(int curpos=0; curpos<=n-2; ++curpos)
	{
		for(int i =1; i<=k; ++i)
			if(curpos+i<=n-1)
				c[curpos+i] = min(c[curpos+i], c[curpos]+ (int)abs(a[curpos]-a[curpos+i]));
	}
	cout<<c[n-1];
	return 0;	
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    int a,b;cin>>a>>b;
    cout<<(((a*b)%2)?"Odd":"Even")<<endl;
}

Measured memory_bytes: 3560
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        int[] seats = new int[] {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
                0, 0};
        int[] groupMembers = new int[] {2, 5, 2, 2, 2};
        int[] eatTimes = new int[] {19, 39, 25, 36, 22, 42};

        int headGroup = -1;
        int pastMinutes = 0;
        List<Integer> waitTime = new ArrayList<Integer>();

        while (waitTime.size() <= 100) {
            // たべおわる
            for (int i = 0; i < seats.length; i++) {
                seats[i] = seats[i] == 0 ? 0 : seats[i] - 1;
            }

            // 来店
            if (headGroup == -1 && pastMinutes % 5 == 0) {
                headGroup = pastMinutes / 5;
            }

            // ちゃくせき
            while (headGroup != -1) {
                int needsSequencialSeats = groupMembers[headGroup % 5];
                int sequencialSeats = 0;
                int startIndex = -1;
                for (int i = 0; i < seats.length; i++) {
                    sequencialSeats = seats[i] == 0 ? sequencialSeats + 1 : 0;

                    if (sequencialSeats == needsSequencialSeats) {
                        startIndex = i - (needsSequencialSeats - 1);
                        break;
                    }
                }

                if (startIndex != -1) {
                    // すわれたみたい
                    waitTime.add(headGroup, pastMinutes - (headGroup * 5));
                    for (int i = startIndex; i < (startIndex + needsSequencialSeats); i++) {
                        seats[i] = eatTimes[headGroup % 6];
                    }

                    headGroup = (((headGroup + 1) * 5) <= pastMinutes) ? headGroup + 1
                            : -1;
                } else {
                    // すわれなかったみたい
                    break;
                }

            }

            pastMinutes++;

        }

        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            System.out.println(waitTime.get(sc.nextInt()));
        }

    }
}

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

const int MAX = 2e5 + 111;

int main() {
#ifdef LOCAL
    freopen("xxx.in", "r", stdin);
    freopen("xxx.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; j <= m; ++j) {
            if (k == i * j + (n - i) * (m - j)) {
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, modinv, bitSearch, bitList, dfs, bfs, dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = 0;
vl flag, color; vll path; vl D; ll C;
//***********//
vl bitList(ll n, ll k, ll f) {
	vl bitList(k);
	for (ll i = 0; i < k; i++) {
		bitList[i] = f % n;
		f /= n;
	}
	return bitList;
}
int main() {
	cin >> N >> K;
	vl A(N);
	vl sum(N + 1);
	sum[0] = 0;
	for (i = 0; i < N; i++) {
		cin >> A[i];
		sum[i + 1] = sum[i] + A[i];
	}
	vl P;
	for (i = 0; i < N; i++) {
		for (j = i+1; j <= N; j++) {
			P.push_back(sum[j] - sum[i]);
		}
	}
	ll L = P.size();
	for (k = 40; k >= 1; k--) {
		ll pre = pow(2, k - 1);
		ll C = 0;
		for (i = 0; i < L; i++) {
			ll Q = (ans + pre) & P[i];
			if (Q == ans + pre) C++;
		}
		if (C >= K) ans += pre;
	}
	cout << ans;
}

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

#define M 5070721
#define NIL (-1)
#define L 14
typedef long long ll;
char H[M][L];
 
int getChar(char ch) {
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}
 
ll getKey(char str[]) {
  ll sum = 0, p = 1;
  int len = strlen(str);
  for(int i = 0; i < len; i++) {
    sum += p * (getChar(str[i]));
    p *= 5;
  }
  return sum;
}
 
int h1(int key){
  return key % M;
}
 
int h2(int key){
  return 1 + (key % (M-1));
}
 
int find(char str[]){
  ll key, i, h;
  key = getKey(str);
  for(i = 0; ; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      return 0;
    }
  }
  return 0;
}
 
int insert(char str[]) {
  ll key, h;
  key = getKey(str);
  for(ll i = 0;; i++) {
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) {
      return 1;
    } else if(strlen(H[h]) == 0) {
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(void){
  int N;
  char str[L], com[9];
  for(int i = 0; i < M; i++) {
    H[i][0]='\0';
  }

  scanf("%d", &N);
  for(int i=0; i < N; i++){
    scanf("%s %s", com, str);
    if(com[0] == 'i') {
      insert(str);
    }else{
      if(find(str)) {
        printf("yes\n");
      }else{
        printf("no\n");
      }
    }
  }
  return 0;
}



Measured memory_bytes: 72080
#include <iostream>
using namespace std;
double myabs(double a) {
    if (a < 0) return -1 * a;
    return (double)a;
}
 
int main()
{
    int n, t, a;
    cin >> n >> t >> a;
    int h[n];
    for (int i = 0; i < n; i++) cin >> h[i];
    double diff = 0xffff;
    int p = -1;
 
    for (int i = 0; i < n; i++) {
        double temp = t - h[i] * 0.006;
        if (diff > myabs(a - temp)) {
            diff = myabs(a - temp);
            p = i + 1;
        }
    }
    cout << p << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <map>

using namespace std;

int main()
{
    string input;
    map<char, int> alpha;

    alpha['A'] = 0;
    alpha['I'] = 1;
    alpha['V'] = 5;
    alpha['X'] = 10;
    alpha['L'] = 50;
    alpha['C'] = 100;
    alpha['D'] = 500;
    alpha['M'] = 1000;

    while (cin >> input) {
        long long ans = 0;
        
        input += 'A';

        for (int i = 0; i < input.size(); ) {
            if (alpha[input[i]] >= alpha[input[i + 1]]) {
                ans += alpha[input[i]];
                i++;
            }
            else {
                ans += (alpha[input[i + 1]] - alpha[input[i]]);
                i += 2;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>


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

const double EPS =1e-9;
const long INF =999999999;
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979

int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(){
	int H,W;
	string st;

	cin>>H>>W;

	REP(i,W+2) printf("#"); 
	puts("");
	REP(i,H){
		cin>>st;
		cout<<"#"<<st<<"#"<<endl;
	}
	REP(i,W+2) printf("#"); 
	puts("");

	return 0;
}



Measured memory_bytes: 256
s=input()
l = set()
check = set(['A','G','C','T'])
for i in range(len(s)):
  for j in range(i+1,len(s)+1):
    #print(s[i:j])
    if len(set(s[i:j]) | check) == 4:
      l.add(j-i)
if len(l) == 0:
  print(0)
else:
  print(max(l))

Measured memory_bytes: 8988
n = int(input())
rest = []
for i in range(n):
  s_, p_ = input().split()
  p_ = int(p_)
  rest.append([s_, p_, i+1])

rest.sort(key=lambda x:x[1], reverse=True)
rest.sort(key=lambda x:x[0])

for i in range(n):
  print(rest[i][2])

Measured memory_bytes: 3060
#include<stdio.h>
int prime[250000];
int main(void){
    int i,j,input,ans;
    for(i=0;i<250000;i++){
        prime[i]=1;
    }
    prime[0]=0;
    prime[1]=0;
    for(i=2;i<250000;i++){
        if(prime[i]==1){
            for(j=i+i;j<250000;j+=i){
                prime[j]=0;
            }
        }
    }
    while(1){
        scanf("%d",&input);
        if(input==0){
            break;
        }
        ans=0;
        for(i=input+1;i<=input*2;i++){
            ans+=prime[i];
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2752
#include<bits/stdc++.h>
#define L long long
#define pb push_back
#define pi pair<int,int>
#define pii pair<pair<int,int>,int>
#define aa first
#define bb second
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
#define SZ 666666
typedef long long ll;
int fst[SZ],nxt[SZ],vb[SZ],cap[SZ],ff[SZ],M=1,N=0;
#define add ad_dl
void _ad_dl(int a,int b,int c) {++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;cap[M]=c;}
void ad_dl(int a,int b,int c)
{_ad_dl(a,b,c); _ad_dl(b,a,0);}
int S,T,q[SZ],d[SZ];
bool bfs()
{
    memset(d,-1,4*(N+1));
    d[T]=0; q[1]=T; int h=1,t=2;
    while(h!=t)
    {
        int cur=q[h++];
        for(int e=fst[cur];e;e=nxt[e])
        {
            int b=vb[e];
            if(d[b]==-1&&cap[e^1])
            {
                d[b]=d[cur]+1, q[t++]=b;
                if(b==S) return 1; //???? 
            }
        }
    }
    return d[S]!=-1;
}
int dfs(int x,int f)
{
    if(f<=0) return 0;
    if(x==T) return f;
    int ca=0;
    for(int& e=fst[x];e;e=nxt[e]) //????? 
    {
        int b=vb[e];
        if(d[b]+1!=d[x]) continue;
        int w=dfs(b,(cap[e]<f-ca)?cap[e]:(f-ca));
        cap[e]-=w; cap[e^1]+=w; ca+=w;
        if(ca==f) break;
    }
    if(!ca) d[x]=-1; //????? 
    return ca;
}
#define inf 2e9+3
int dinic()
{
    int ans=0;
    memcpy(ff,fst,4*(N+1));
    while(bfs())
    {
        //?????
        ans+=dfs(S,inf);
        memcpy(fst,ff,4*(N+1));
    }
    return ans;
}
int n,m,x[110],f[210],p;
bool a[10000010];
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	  scanf("%d",&x[i]);
	sort(x+1,x+n+1);
	for(i=2;i<=n;i++)
	  if(x[i-1]+1!=x[i])
	    {
		 f[++m]=x[i-1]+1;
		 f[++m]=x[i];
		}
	f[++m]=x[1];
	f[++m]=x[n]+1;
	a[1]=1;
	for(i=2;i<=10000000;i++)
	  if(!a[i])
	    for(j=i+i;j<=10000000;j+=i)
	      a[j]=1;
	a[2]=1;
	N=m+2;
	S=m+2;
	T=m+1;
	for(i=1;i<=m;i++)
	  if(f[i]&1)
	    add(m+2,i,1);
	  else
	    add(i,m+1,1);
	for(i=1;i<=m;i++)
	  for(j=1;j<=m;j++)
	    if(i!=j && f[i]&1 && !a[abs(f[i]-f[j])])
	      add(i,j,1);
	p=k=dinic();
	for(i=1,j=-k;i<=m;i++)
	  if(f[i]&1)
	    j++;
	p+=j/2*2;
	if(j&1)
	  p+=3;
	for(i=1,j=-k;i<=m;i++)
	  if(!(f[i]&1))
	    j++;
	p+=j/2*2;
	printf("%d\n",p);
	return 0;
}


Measured memory_bytes: 22784
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func getNextUint64(scanner *bufio.Scanner) uint64 {
	i, _ := strconv.ParseUint(getNextString(scanner), 10, 64)
	return i
}

func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	id := ID{}
	id.init(n)

	aa := make([][]int, n)
	for i := 0; i < n; i++ {
		aa[i] = make([]int, n-1)
	}

	vv := make([][]int, id.i)
	for i := 0; i < id.i; i++ {
		vv[i] = make([]int, 0)
	}
	deg := make([]int, id.i)

	for y := 0; y < n; y++ {
		for x := 0; x < n-1; x++ {
			u := getNextInt(scanner) - 1
			aa[y][x] = u
			if x == 0 {
				continue
			}
			prev := id.get(y, aa[y][x-1])
			next := id.get(y, u)
			vv[prev] = append(vv[prev], next)
			deg[next]++
		}
	}
	q := make([]int, 0)
	for i := 0; i < id.i; i++ {
		if deg[i] == 0 {
			q = append(q, i)
		}
	}
	visited := make([]int, id.i)

	day := 0
	for len(q) > 0 {
		day++
		l := len(q)
		for i := 0; i < l; i++ {
			p := q[i]
			visited[p] = 1
			for _, v := range vv[p] {
				deg[v]--
				if deg[v] == 0 {
					q = append(q, v)
				}
			}
		}
		q = q[l:]
	}
	for i := 0; i < id.i; i++ {
		if visited[i] == 0 {
			day = -1
			break
		}
	}

	fmt.Fprintln(writer, day)
	writer.Flush()
}

// ID ...
type ID struct {
	table [][]int
	i     int
}

func (id *ID) init(n int) {
	id.table = make([][]int, n)
	for y := 0; y < n; y++ {
		id.table[y] = make([]int, n)
	}

	i := 0
	for y := 0; y < n; y++ {
		for x := y + 1; x < n; x++ {
			id.table[y][x] = i
			id.table[x][y] = i
			i++
		}
	}
	id.i = i
}

func (id *ID) get(i, j int) int {
	return id.table[i][j]
}


Measured memory_bytes: 63872
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define LINF 1e18
#define INF 1e9
using namespace std;

int main(){
    
    ll n,sum = 0;
    cin >> n;
    ll x[n] ={};
    rep(i,0,n){
        cin >> x[i];
        sum += x[i];
    }
    ll ave = round((double)sum / (double)n),ans = 0;
    rep(i,0,n){
        ans += (ave-x[i])*(ave-x[i]);
    }
    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 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 SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
#define fi first
#define se second
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define yn(x, ok, ng) cout << ((x)?(ok):(ng)) << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
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;}
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);

ll X;
cin >> X;

for(ll a = -1000; a <= 1000; a++) {
    for(ll b = -1000; b <= 1000; b++) {
        if(a*a*a*a*a - b*b*b*b*b == X) {
            cout << a << ' ' << b << endl;
            return 0;
        }
    }
}


return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

int main(){
	while(1){
		char n[9];
		int index, c[3] = {0};
		double min = 1000, d;
	
		scanf(" %s", n);
		if(strcmp(n, "0") == 0) break;
		
		for(int i=0; i<3; i++){
			if(n[2*i+1] <= '9') c[i] += 16*(n[2*i+1]-'0');
			else c[i] += 16*(n[2*i+1]-'a'+10);
			
			if(n[2*i+2] <= '9') c[i] += n[2*i+2]-'0';
			else c[i] += n[2*i+2]-'a'+10;
		}
		
		/*for(int i=0; i<3; i++)
			printf("%d ", c[i]);*/
		
		for(int i=0; i<8; i++){
			int p;
			if(i%4==0 || i%4==1) p=0;
			else p=1;
		
			d=sqrt( pow(c[0]-(i/4)*255, 2) + pow(c[1]-p*255, 2) + pow(c[2]-(i%2)*255, 2) );
			if(min > d){
				min = d;
				index = i;
			}
		}
		
		if(index==0) printf("black\n");
		else if(index==1) printf("blue\n");
		else if(index==2) printf("lime\n");
		else if(index==3) printf("aqua\n");
		else if(index==4) printf("red\n");
		else if(index==5) printf("fuchsia\n");
		else if(index==6) printf("yellow\n");
		else if(index==7) printf("white\n");

	}

	return 0;
}

Measured memory_bytes: 1108
#include <stdio.h>

int main(void)
{
    int N, t;
    int x[1001], h[1001];
    double max;
    double t2;
    int i;
    
    scanf("%d%d", &N, &t);
    for (i = 0; i < N; i++){
        scanf("%d%d", &x[i], &h[i]);
    }
    
    max = (double)h[0] / (double)x[0];
    for (i = 1; i < N; i++){
        if (t > x[i]){
            t2 = (double)h[i] / (double)x[i];
            if (max < t2){
                max = t2;
            }
        }
    }
    
    printf("%lf\n", max * t);
    
    return (0);
}



Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n, k;
    cin>>n>>k; long long arr[n];
    for(int i=0; i<n; i++)
        cin>>arr[i];
    long long dp[n];
    dp[0] = 0; dp[1] = abs(arr[1]-arr[0]);
    for(int i=2; i<n; i++){
        dp[i] = 100000000000000000;
        for(int j=1; j<=k && i-j>=0; j++)
            dp[i] = min(dp[i], abs(arr[i]-arr[i-j])+dp[i-j]);
    }
    cout<<dp[n-1];
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define rep(i,s,e) for(int i=s;i<e;i++)
#define endl '\n'
int main(){
    int n,a,b;cin>>n>>a>>b;
    int res=0;
    for(int i=1;i<=n;i++){
        int sum=0;
        int tmp=i;
        while (tmp>0)
        {
            sum+=tmp%10;
            tmp/=10;
        }
        if(a<=sum && sum<=b)res+=i;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<vector>
#include<cmath>
#include<numeric>
#include<ctime>
#include<locale>
//freopen("std.in","r",stdin);freopen("stdout.out","w",stdout);
using namespace std;
vector<long >g[200010];
queue<long >q;
int main()
{
    long n,m;
    long a,b;
    cin>>n>>m;
    for(long i=0;i<m;i++)
    {
        scanf("%ld%ld",&a,&b);
        g[a].push_back(b);
        g[b].push_back(a);
    }
    {
        q.push(1);
        for(long i=0,li=g[1].size();i<li;i++)
        {
            for(long j=0,lj=g[g[1][i]].size();j<lj;j++)
            {
                if(g[g[1][i]][j]==n)
                {
                    printf("POSSIBLE\n");
                    return 0;
                }
            }
        }
    }
    printf("IMPOSSIBLE\n");
    return 0;
}


Measured memory_bytes: 12776
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <string>
#include <limits>
#include <algorithm>
#include <map>
#include <sstream>
#include <unordered_map>
#include <set>

using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
static ull tenq = 1000000000;
static ull mod = tenq + 7;

using namespace std;

int main()
{
  ll N;
  cin >> N;

  ll res = 1;
  for (auto i = 2; i <= N; i++) {
    bool isprime = true;
    for (auto j = 2; j * j <= i; j++) {
      if (i % j == 0) {
        isprime = false;
        break;
      }
    }
    if (!isprime) continue;

    ll num_soinsu = 0;
    for (auto j = i; j <= N; j *= i) {
      num_soinsu += N / j;
    }
//    cout << "i=" << i << " num_soinsu=" << num_soinsu << endl;
    res = (res * (num_soinsu + 1)) % mod;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
n,x=map(int,input().split())
a=list(map(int,input().split()))
if n==1:
    print(abs(a[0]-x))
    exit()
def gcd(m,n):
    x,y=max(m,n),min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
b=[]
for i in range(n):
    b.append(abs(a[i]-x))
c=gcd(b[0],b[1])
for i in range(n-2):
    c=gcd(c,b[i+2])
print(c)

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

const int MAXN=1e5+5;
const int INF=0x3f3f3f3f;

using namespace std;

int a[MAXN];
int cmp(int a,int b)
{
    return a>b;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&a[i]);
    }
    int t=0;
    sort(a+1,a+n+1,cmp);
    for(; a[t]>=t; t++);
    t--;
    int flag=0;
    if((a[t]-t)%2==0)
    {
        int j;
        for( j=0; a[j+t]>=t; j++);
        if((j-1)%2==0)
        {
            flag=1;
        }
    }
    printf(!flag?"First\n":"Second\n");
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N - 1);
  for(int i = 0; i < N - 1; i++) {
    cin >> B.at(i);
  }
  for(int i = 1; i < N - 1; i++) {
    A.at(i) = min(B.at(i - 1), B.at(i));
  }
  A.at(0) = B.at(0);
  A.at(N - 1) = B.at(N - 2);
  int S = 0;
  for(int i = 0; i < N; i++) {
    S += A.at(i);
  }
  cout << S << endl;
}

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

ll solve() {
    ll N;
    cin >> N;
    vector<int> C(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> C[i];
        C[i]--;
    }
    vector<vector<int>> G(N);
    int a, b;
    for ( int i = 0; i < N-1; i++ ) {
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    vector<ll> nv(N); // number of vertex of subtree(v)
    vector<int> pa(N); // 親頂点
    function<ll(int,int)> dfs1 = [&](int v, int p) {
        ll a = 1;
        for ( int u : G[v] ) {
            if ( u == p ) continue;
            a += dfs1(u,v);
        }
        nv[v] = a;
        pa[v] = p;
        return a;
    };
    dfs1(0,-1);

    vector<ll> vc_r(N, N); // vc_r[c]:0を根として色cと重ならない部分木の頂点数
    vector<ll> vc_v(nv); // vc_v[i]:頂点iの親で区切ったときの部分木の頂点数
    vector<int> pac(N,-1); // pac[c]:親の色がcである頂点のうち最も近い祖先
    function<void(int,int)> dfs2 = [&](int v, int p) {
        int vpc = pac[C[v]];
        if ( vpc < 0 ) {
            vc_r[C[v]] -= nv[v];
        } else {
            vc_v[vpc] -= nv[v];
        }
        for ( int u : G[v] ) {
            if ( u == p ) continue;
            pac[C[v]] = u;
            dfs2(u, v);
            pac[C[v]] = vpc;
        }
    };
    dfs2(0,-1);

    vector<ll> cmpl(N); // cmpl[c]:色cを通らないパスの数
    for ( int c = 0; c < N; c++ ) {
        cmpl[c] += vc_r[c] * (vc_r[c]+1) / 2;
    }
    for ( int v = 1; v < N; v++ ) {
        int p = pa[v];
        cmpl[C[p]] += vc_v[v] * (vc_v[v]+1) / 2;
    }

    for ( int c = 0; c < N; c++ ) {
        ll ans = N * (N+1) / 2 - cmpl[c];
        cout << ans << "\n";
    }    
    return 0;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 41372
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <deque>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000007;
int main(){
	int n;
	cin >> n;
	map<string,bool> mp;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		mp[s] = true;
	}

	cout << mp.size() << endl;
}


Measured memory_bytes: 19180
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define MOD2 998244353
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
#define trace(x) cerr<<#x<<": "<<x<<'\n';
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
#define T int
#define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>
auto clk=clock();
 
ll mexp(ll a, ll b, ll m){
    ll ans=1;
    a%=m;
    while(b){
        if(b&1) ans=ans*a%m;
        b>>=1;
        a=a*a%m;
    }
    return ans;
}

const int N = 200005;

ll fac[N], inv[N];

ll nCr(ll n, ll r){
    return (((fac[n] * inv[n-r]) % MOD) * inv[r]) % MOD;
}

void pre(){
    fac[0] = 1;
    inv[0] = 1;
    FOR(i,1,N-1){
        fac[i] = (fac[i-1] * i) % MOD;
        inv[i] = mexp(fac[i], MOD - 2, MOD);
    }
}

int main(){
    IOS
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    pre();
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    ll ans = 0;
    FOR(i,b,w-1){
        int y1 = h - a - 1, x1 = i;
        int y2 = a - 1, x2 = w - i - 1;
        ll p = (nCr(x1 + y1, x1) * nCr(x2 + y2, x2)) % MOD;
        ans = (ans + p) % MOD;
    }
  cout << ans << '\n';

    cerr<<endl<<endl<<"Time: "<<fixed<<setprecision(12)<<(long double)(clock()-clk)/CLOCKS_PER_SEC<<" ms"<<endl<<endl;
 
    return 0;
}

Measured memory_bytes: 3456
#include <iostream>
#include <stdio.h>
#include <math.h>

using namespace std;

void solve()
{
	double q;
	while(cin >> q, q != -1)
	{
		double x1 = q / 2;
		while(true)
		{
			if(fabs(x1 * x1 * x1 - q) < 0.00001 * q)
			{
				printf("%.6f\n", x1);
				break;
			}
			x1 = x1 - (x1 * x1 * x1 - q) / (3 * x1 * x1);
		}
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1236
#include <iostream>
#include<vector>
#include<queue>
using namespace std;
void dij(int s,vector<vector<pair<long long,int>>> a,vector<long long>& d,int n){
	priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>>> q;
	q.push(pair<long long,int>(0,s));
	vector<int> vl(n,1);
	d[s]=0;
	while(q.size()){
		pair<long long,int> temp=q.top();
		q.pop();
//		cout<<temp.second<<' '<<temp.first<<endl;
		if(vl[temp.second]){
			vl[temp.second]=0;
			d[temp.second]=temp.first;
			while(a[temp.second].size()){
				pair<long long,int> tonext=a[temp.second].back();
				a[temp.second].pop_back();
				if(vl[tonext.second]){
						q.push(pair<long long,int>(temp.first+tonext.first,tonext.second));
				}
			}
		}
	}


}


int main() {
	int n,m,s,t;cin>>n>>m>>s>>t;
	int u[m],v[m];
	long long a[m],b[m];
	vector<long long> y(n),su(n);
	vector<vector<pair<long long,int>>> vy(n),vsu(n);
	for(int i=0;i<m;i++){
		cin>>u[i]>>v[i]>>a[i]>>b[i];
		u[i]--;
		v[i]--;
		vy[u[i]].push_back(pair<long long,int>(a[i],v[i]));
		vsu[u[i]].push_back(pair<long long,int>(b[i],v[i]));
		vy[v[i]].push_back(pair<long long,int>(a[i],u[i]));
		vsu[v[i]].push_back(pair<long long,int>(b[i],u[i]));
	}
	dij(s-1,vy,y,n);
	dij(t-1,vsu,su,n);
//	for(int i=0;i<n;i++){
//		cout<<y[i]<<' ';
//	}
//	cout<<endl;
//	for(int i=0;i<n;i++){
//		cout<<su[i]<<' ';
//	}
//	cout<<endl;
	long long max=1;
	for(int i=0;i<15;i++){
		max*=10;
	}
	long long ans[n];
	for(int i=0;i<n;i++){
		ans[i]=max-y[i]-su[i];
	}
	for(int i=n-1;i>=0;i--){
		if(ans[i]<ans[i+1]){
			ans[i]=ans[i+1];
		}
	}
	for(int i=0;i<n;i++){
		cout<<ans[i]<<endl;
	}

	return 0;
}

Measured memory_bytes: 27832
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <cstring>
#include <complex>
#include <ctime>
#include <cstdlib>

using namespace std;

inline int to_int(string s) {int v; istringstream sin(s); sin >> v; return v;}
template<class T> inline string to_str(T x) {ostringstream sout; sout << x; return sout.str();}

typedef long long ll;

struct cards{
	int num, card;
};

bool straight( vector<int> card )
{
	sort(card.begin(), card.end());
	int st = card[0];
	bool straight1 = true, straight2 = true;
	for(int i = 1; i < 5; i++)
	{
		st++;
		if(st != card[i])
		{
			straight1 = false;
			break;
		}
	}

	for(int i = 0; i < 5; i++)
	{
		if(card[i] == 1) card[i] = 14;
	}

	sort(card.begin(), card.end());
	st = card[0];
	for(int i = 1; i < 5; i++)
	{
		st++;
		if(st != card[i])
		{
			straight2 = false;
			break;
		}
	}

	return (straight1 || straight2);
}

int main()
{
	vector<int> card(5);
	vector<int> num;
	// num, card
	while(scanf("%d,%d,%d,%d,%d", &card[0], &card[1], &card[2], &card[3], &card[4]) != EOF)
	{
		num.clear();

		if(straight(card))
		{
			cout << "straight" << endl;
			continue;
		}

		sort(card.begin(), card.end());
		int cnt = 1;
		for(int i = 0; i < 5; i++)
		{
			if(card[i] == card[i+1])
			{
				cnt++;
			}
			else
			{
				num.push_back(cnt);

				cnt = 1;
			}
		}

		if(num.size() == 2)
		{
			if( num[0] == 4 || num[1] == 4)
			{
				cout << "four card" << endl;
			}
			if( num[0] == 3 && num[1] == 2 || num[0] == 2 && num[1] == 3)
			{
				cout << "full house" << endl;
			}
		}
		else if(num.size() == 3)
		{
			if( num[0] == 3 || num[1] == 3 || num[2] == 3)
			{
				cout << "three card" << endl;
			}

			else if( num[0] == 2 && num[1] == 2 || num[0] == 2 && num[2] == 2 || num[1] == 2 && num[2] == 2)
			{
				cout << "two pair" << endl;
			}
		}
		else if(num.size() == 4)
		{
			cout << "one pair" << endl;
		}
		else if(num.size() == 5)
		{
			cout << "null" << endl;
		}
	}
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int N;
    cin >> N;
    cout << N/2 + N%2 << endl;
    return 0;
}



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

int main() {
int n;
long long a;
long long minValue = 1000000;
long long maxValue = -1000000;
long long sum=0;

cin>>n;
for(int i=0; i<n; i++){
cin>>a;
if(a<minValue) minValue=a;
if(a>maxValue) maxValue=a;
sum+= a;
}
cout<< minValue <<" "<<maxValue <<" "<< sum << endl;
	// your code goes here
	return 0;
}

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

int main(){
  long A, B;
  cin >> A >> B;
  int ad = A%4;
  int bd = B%4;
  long ansA = 0;
  long ansB = B;
  for(int i=1; i<=ad; i++){
    ansA ^= A-i;
  }
  for(int i=1; i<=bd; i++){
    ansB ^= B-i;
  }
  long ans = ansA^ansB;
  cout << ans << endl;
  return 0;
}

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

using ll = int64_t;
#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)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(), x.end()

using pi = pair<int, int>;
using vi = vector<int>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}

template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  REP(i, (int)v.size()) {
    if (i) os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

ll read() {
  ll i;
  scanf("%" SCNd64, &i);
  return i;
}

void printSpace() { printf(" "); }

void printEoln() { printf("\n"); }

void print(ll x, int suc = 1) {
  printf("%" PRId64, x);
  if (suc == 1) printEoln();
  if (suc == 2) printSpace();
}

string readString() {
  static char buf[3341000];
  scanf("%s", buf);
  return string(buf);
}

char *readCharArray() {
  static char buf[3341000];
  static int bufUsed = 0;
  char *ret = buf + bufUsed;
  scanf("%s", ret);
  bufUsed += strlen(ret) + 1;
  return ret;
}

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

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

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

signed main() {
  int A, P, ans;
  cin >> A >> P;
  ans = (3 * A + P) / 2;
  print(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int l;      cin >> l;
    string op;  cin >> op;
    int r;      cin >> r;
    if     (op == "+")  cout << l + r << endl;
    else  /*op == "-"*/ cout << l - r << endl;
}

Measured memory_bytes: 256
N = int(input())
h = [0] + [int(i) for i in input().split()] + [0]

ans = 0
cur = 0
while h.count(0) != len(h):
    for i in range(N+2):
        if h[i] == 0:
            if cur > 0:
                ans += 1
            cur = 0
        elif h[i] > 0:
            h[i] -= 1
            cur += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define m 1000000007
ll mod(ll a,ll b)
{
    return max(a,b)-min(b,a);
}
int main() {
    ll h,v;
    cin>>h>>v;
    char a[h+1][v+1];
    ll ans[h+1][v+1];
    for(int i=1;i<h+1;i++)
    {
        for(int j=1;j<v+1;j++)
        {
            cin>>a[i][j];
            ans[i][j]=0;
        }
    }
    ans[1][1]=1;

    for(int i=2;i<=v;i++)
        if(a[1][i]=='.')
            ans[1][i]=ans[1][i-1];

    for(int i=2;i<=h;i++)
        if(a[i][1]=='.')
            ans[i][1]=ans[i-1][1];

    for(int i=2;i<h+1;i++)
    {
        for(int j=2;j<v+1;j++)
        {
            if(a[i][j]=='.')
                ans[i][j]=(ans[i-1][j]+ans[i][j-1])%m;
        }
    }
    cout<<ans[h][v]<<endl;
	return 0;
}

Measured memory_bytes: 9088
n = STDIN.gets.to_i
s = STDIN.gets.split[0...n].map(&:to_i)

q = STDIN.gets.to_i
t = STDIN.gets.split[0...q].map(&:to_i)

count = 0
t.each do |te|
	s[n] = te # 番兵を利用, rubyでは多分意味ない
	i = 0
	i += 1 until s[i] == te
	count += 1 unless i == n
end
p count

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

#define ll long long int
#define all(x) (x).begin(), (x).end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define pb push_back
#define mp make_pair
#define inputv(a) forall(i,0,a.size()) cin>>a[i]
#define outputv(a) for(auto i:a) cout<<i<<" ";br;
#define fs first
#define sec second
#define lb lower_bound
#define ub upper_bound
#define minv(a) *min_element(all(a))
#define maxv(a) *max_element(all(a))
#define br cout<<"\n"
using namespace std;


int dr[]={1,-1,0,0};
int dc[]={0,0,1,-1};
ll mod=1000000007;
ll po(ll x,ll n){
    ll res = 1;
    while(n>0){
        if(n%2==1)
            res = ((res)*(x));
        x = (x*x);
        n = n/2;
    }
    return res;
}
ll ceil(ll x,ll y)
{
    if(x%y==0)
        return x/y;
    else
        return(x/y)+1;
}
ll binomialCoeff(int n, int k)
{
    ll res = 1;
    if (k > n - k)
        k = n - k;

    for (int i = 0; i < k; ++i) {
        res *= (n - i);
        res /= (i + 1);
    }

    return res;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    rep(i,0,n) cin>>a[i];
    ll ans=1000;
    for(ll i=1;i<n;i++)
    {
        if(a[i]>a[i-1])
        {
            ll tmp=ans/a[i-1];
            ll rem=ans%a[i-1];
            ans=tmp*a[i]+rem;
        }
    }
    cout<<ans;

	return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	int p[50];
	int p1[50];
	int count = 0;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> p[i];
		p1[i] = p[i];
	}

	sort(p, p + n);
	
	for (int i = 0; i < n; i++){
		if (p[i] != p1[i]) count++;
		if (count == 3)  break;
	}

	if (count < 3)	cout << "YES" << endl;
	else   cout << "NO" << endl;

	return 0;
}

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

int main(){
    using namespace std;
    unsigned long N;
    cin >> N;
    vector<unsigned long> A(N);
    copy_n(istream_iterator<unsigned long>(cin), N, A.begin());
    unsigned long st{0}, nd{0};
    for(const auto& i : A){
        if(st < i){
            swap(nd, st);
            st = i;
        }else if(nd < i){
            nd = i;
        }
    }
    for(const auto& i : A)cout << (i == st ? nd : st) << endl;
}

Measured memory_bytes: 3200
n = int(input())
l = [] 
for i in range(n):
	list = [" "] * n
	a = int(input())
	for j in range(a):
		data = input().split(" ")
		x = int(data[0])
		y = data[1]
		list[x-1] = y
	l.append(list)
m = 0
for i in range(2**n):
	s = bin(i)
	s = s[2:]
	s = s.zfill(n)
	ll = []
	th = [" "] * n
	for j in range(n):
		if int(s[j]) == 1:
			ll.append(l[j])
			th[j] = "1"
		elif int(s[j]) == 0:
			th[j] = "0" 
	te = 0
	for j in range(n):
		for k in range(len(ll)):
			if ll[k][j] == "1" or ll[k][j] == "0":
				if ll[k][j] != th[j]:
					te = 1
	if te == 0:
		f = len(ll)
		if f > m:
			m = f
print(m)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;

int main(){
int n,k,q;cin>>n>>k>>q;
map <int,int> m;
for(int i=0;i<n;i++)m[i]=0;
for(int i=0;i<q;i++){
    int b;cin>>b;m[b-1]++;
}

for(auto it=m.begin();it!=m.end();it++){
    if(q-it->second>=k)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}
}

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  string str;
  cin >> str;

  ll ans = INF;

  for (ll i = 0; i < str.length() - 2; i++) {
    string s = str.substr(i, 3);
    ll v = stoll(s);
    v = abs(753 - v);

    ans = min(ans, v);
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int abc = 1200, arc = 2800;
	int r;

	scanf("%d", &r);

	if (r < abc)
	{
		printf("ABC");
	}
	else if (r < arc)
	{
		printf("ARC");
	}
	else
	{
		printf("AGC");
	}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
int main(){
  int n,m;cin>>n>>m;
  long long  costs[100000]={};
  map<int,int> mp;
  for(int i=0;i<n;++i){
	cin>>costs[i];
	int a;cin>>a;
	if(mp.find(costs[i])!=mp.end()){mp[costs[i]]+=a;costs[i]=1.0e+9;}
	else mp[costs[i]]=a;
  }
  sort(costs,costs+n);
  long long total=0;
  for(int i=0;i<n;++i){
	if(m>mp[costs[i]]){
	  m-=mp[costs[i]];
	  total+=mp[costs[i]]*costs[i];
	}
	else{
	  total+=costs[i]*m;
	  break;
	}
	  
  }
  cout<<total<<endl;
}


Measured memory_bytes: 5760
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
typedef long long ll;
const int MAXN = 1e5+5;
const int INF = 0x3f3f3f3f;
int dp[MAXN],a[MAXN];

int main(){
	int N,K;
	memset(dp,INF,sizeof(dp));
	cin>>N>>K;
	for(int i=0;i<N;++i){
		cin>>a[i];
	}
	dp[0]=0;
	for(int i=0;i<N;++i){
		for(int j=1;j<=K&&j+i<N;++j){
			dp[j+i]=min(dp[i+j],dp[i]+abs(a[i]-a[i+j]));
		}
	}
	cout<<dp[N-1]<<endl;
	return 0;
}																				


Measured memory_bytes: 1024
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N,K=get_i
R,S,P=get_i
T=get_nsp
group=array(K)
T.each_with_index do|t,i|
    group[i%K]=[] if group[i%K].nil?
    group[i%K].push(t)
end

def DP(n,t)
    dp=Array.new(n+1){Array.new(3){0}}
    n.times do|i|
        case t[i]
        when "r" then
            dp[i+1][0]=max(dp[i][1],dp[i][2])
            dp[i+1][1]=max(dp[i][0],dp[i][2])
            dp[i+1][2]=max(dp[i][0],dp[i][1])+P
        when "s" then
            dp[i+1][0]=max(dp[i][1],dp[i][2])+R
            dp[i+1][1]=max(dp[i][0],dp[i][2])
            dp[i+1][2]=max(dp[i][0],dp[i][1])
        when "p" then
            dp[i+1][0]=max(dp[i][1],dp[i][2])
            dp[i+1][1]=max(dp[i][0],dp[i][2])+S
            dp[i+1][2]=max(dp[i][0],dp[i][1])
        end
    end
    return dp[n].max
end
ans=0
group.each do|g|
  ans+=DP(g.size,g)
end
puts ans

Measured memory_bytes: 17788
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<int> a(n),b(n),c(n-1);
    rep(i,n) cin>>a[i], --a[i];
    rep(i,n) cin>>b[i];
    rep(i,n-1) cin>>c[i];

    int ans = 0;
    rep(i,n) {
        ans += b[a[i]];
        if (i != n-1 && a[i+1] == a[i]+1) ans += c[a[i]];
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
using namespace std;
int max(int a,int b)
{
    if (a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
int main()
{
    int n=0;
    cin>>n;
    int a[n];
    for(int i=0;i!=n;i++)
    {
        cin>>a[i];
    }
    int max=a[0];
    int sum=0;
    for(int i=1;i!=n;i++)
    {
        if(a[i]>max)
        {
            sum+=max;
            max=a[i];
        }
        else
        {
            sum+=a[i];
        }
    }
    if(max>=sum)
    {
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
}



Measured memory_bytes: 3632