akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)

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

    string s, t;
    cin >> s >> t;
    
    int rc = s.size() - t.size() + 1;
    vector<string> A;
    REP(i, rc){
        int i_i = i;
        bool f = true;
        REP(j, t.size()){
            if(s[i_i] == '?' or s[i_i] == t[j]);
            else{
                f = false;
                break;
            }
            i_i++;
        }
        if(f){ 
            string tmp = "";
            REP(j, s.size()){
                if(j == i){
                    tmp += t;
                    j += t.size() - 1;
                }else{
                    if(s[j] == '?') tmp += 'a';
                    else tmp += s[j];
                }
            }
            A.push_back(tmp);
        }
    }
    if(A.size()){
        sort(A.begin(), A.end());
        cout << A[0] << endl;
    }else cout << "UNRESTORABLE" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int ret = 0;
  rep(i,S.size()){
    if(S[i]=='+') ret++;
    if(S[i]=='-') ret--;
  }

  cout << ret << endl;
  
  return 0;
}



Measured memory_bytes: 256
A, B, C = map(int, input().split())

cnt = 0
if A == B == C and A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    print(-1)
else:
    while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
        a = A
        b = B
        c = C
        cnt += 1
        A = (b+c) // 2
        B = (c+a) // 2
        C = (a+b) // 2
    print(cnt)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


    class Program
{
   public static void Main(string[] args)
    {
        while(true){
            int t=int.Parse(Console.ReadLine());
            if(t==0)break;
            int n=int.Parse(Console.ReadLine());
            int sum=0;
            for(int i=0;i<n;++i){
               	
                string[] input = Console.ReadLine().Split(' ');
                int s=int.Parse(input[0]);
                int f=int.Parse(input[1]);
                sum+=f-s;
            }
            if(sum>=t){
                Console.WriteLine("OK");
            }else{
                Console.WriteLine(t-sum);
            }
        }
    }

}

Measured memory_bytes: 9364
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define loop(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
using ll = int64_t;

int main(){
    int n, k; cin >> n >> k;
    bool have[n];
    rep(i, n) have[i] = false;
    rep(i, k){
        int d; cin >> d;
        rep(j, d){
            int a; cin >> a;
            have[--a] = true;
        }
    }

    int ans = 0;
    rep(i, n) if(!have[i]) ans++;
    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;



int main() {
    int h, w;
    cin >> h >> w;
    vs s(h);
    rep(i, h) {
        cin >> s[i];
    }

    int now = 0;
    vvi board(h, vi(w));
    rep(i, h) {
        rep(j, w) {
            if(s[i][j] == '.') {
                ++now;
            } else {
                rep(k, now) {
                    board[i][j-1-k] = now;
                }
                now = 0;
            }
        }
        rep(k, now) {
            board[i][w-1-k] = now;
        }
        now = 0;
    }
    int ans = 0;
    rep(j, w) {
        rep(i, h) {
            if(s[i][j] == '.') {
                ++now;
            } else {
                rep(k, now) {
                    board[i-1-k][j] += now;
                    ans = max(ans, board[i-1-k][j]);
                }
                now = 0;
            }
        }
        rep(k, now) {
            board[h-1-k][j] += now;
            ans = max(ans, board[h-1-k][j]);
        } 
        now = 0;
    }

    cout << --ans << endl;
}

Measured memory_bytes: 20992
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int ans = (a - c) * (b - d);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        String a = sc.next();
        String b = sc.next();

        if (a.length() != b.length()) {
            if (a.length() > b.length())
                System.out.println("GREATER");
            else
                System.out.println("LESS");
            System.exit(0);
        }

        for (int i = 0; i < a.length(); i++) {
            if (a.charAt(i) != b.charAt(i)) {
                if (a.charAt(i) > b.charAt(i))
                    System.out.println("GREATER");
                else
                    System.out.println("LESS");
                System.exit(0);
            }
        }

        System.out.println("EQUAL");
        System.exit(0);
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>
#include<math.h>
#include<algorithm>
#include<limits.h>


using namespace std;


int log2(int num) {

	long long int soko = 1;
	int result = 0;
	
	while (pow(2, result) < num) {

		result++;
	}

	return result-1;
}



int main()
{



	int n, m;
	vector<int> a;
	vector<int> wkvec;

	int wkcount = 0;

	cin >> n >> m;

	int wk;
	int max = 0;
	for (int i = 0; i < n; i++) {
		cin >> wk;
		a.push_back(wk);

		if (max < wk) {
			max = wk;
		}
	}

	//０だけ例外処理
	if (max = 0) {
		cout << 0 << endl;
		return 0;
	}

//	int border = log2(max);
	int border = INT_MAX;
	bool endflg = false;
	
	while (true) {

		for (int i = 0; i < n; i++) {
			if (a[i] >= border) {
				wkvec.push_back(a[i]);
				a[i] = 0;
			}
		}
		border /= 2;

		sort(wkvec.begin(), wkvec.end(), greater<int>());

		for (int i = 0; i < wkvec.size(); i++) {
			wkvec[i] /= 2;
			wkcount++;

			if (wkcount == m) {
				endflg = true;
				break;
			}
		}
		if (endflg)break;

	}

	long long int sum = 0;
	for (int i = 0; i < wkvec.size(); i++) {
		sum += wkvec[i];
	}

	for (int i = 0; i < a.size(); i++) {
		sum += a[i];
	}

	cout << sum << endl;






	return 0;
}



Measured memory_bytes: 1400
//#include <stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
#define PI 3.14159265359;

class Hoge{
  public:
					long int i0;
	int A,B;
	int N0;
					string s0;
					int* iarray0;
					Hoge(int);
					void func0();
					void array0();
	void printarray0();
	~Hoge();
  private:
	
	void inputarray(int*,int);
	void inputarray2(int*,int*,int);
	void printarray(int*,int);
					};


Hoge::Hoge(int itemp){
	
	i0=itemp;
	//cout<<"i0="<<i0<<endl;
	
									}

void Hoge::func0(){
	//cout<<"N0?"<<endl;
	cin>>A>>B;
	cout<<A*B<<endl;
	//iarray0=new int[N0];
	//int N1=3;int N2=2;
	//int* iarray1=new int[N1];
	//int* iarray2=new int[N1];

	//inputarray(iarray0,N0);
	//printarray(iarray0,N0);
	//inputarray2(iarray1,iarray2,N1);
	
	//delete [] iarray1;
	//delete [] iarray2;
	
								}


void Hoge::array0(){

	cout<<"N0?";
	cin>>N0;
	
	
	for (int i0=0;i0<N0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray0[i0];
		
		
	}
}

void Hoge::inputarray(int* itemp,int itempn){
	
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
	}
}
void Hoge::inputarray2(int* itemp,int* itemp2,int itempn){
	
	int* iarray=itemp;
	int* iarray2=itemp2;
	int n0=itempn;
	
	for (int i0=0;i0<n0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
		cin>>iarray2[i0];
	}
}

void Hoge::printarray(int* itemp,int itempn){
	
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		cout<<"iarray["<<i0<<"]="<<iarray[i0]<<endl;
	
	}
}
	
	void Hoge::printarray0(){
							 
							 for (int i0=0;i0<N0;i0++){
			cout<<"iarray0["<<i0<<"]="<<iarray0[i0]<<endl;
			
							 
							 }
	
	
}
Hoge::~Hoge(){
	
	//delete [] iarray0;
							}
int main(){
				int N=0;
				//cin>>N;
	Hoge* hoge=new Hoge(N);
	hoge->func0();
	
	return 0;
	delete hoge;
}//end of main

Measured memory_bytes: 3596
#include <stdio.h>

int main(void)
{
        int a, b;

        scanf("%d %d", &a, &b);

        if(a < b) printf("a < b\n");
        else if(a > b) printf("a > b\n");
        else if(a == b) printf("a == b\n");

        return 0;
}

Measured memory_bytes: 580
#include <iostream>
using namespace std;
 
int main() {
int a,b,i;
string s,sr,ss;
cin >> s >> sr;
cin>>a>>b;
cin >> ss;
if(ss==s)
cout << a-1 << " " << b;
if(ss==sr)
cout<<a<<" "<<b-1;
	return 0;
}


Measured memory_bytes: 3552
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, k := scanInt(), scanInt()
	c := make([]int, n+1)
	for i := 0; i < n; i++ {
		c[scanInt()]++
	}
	sort.Ints(c)

	b := 0
	for i := 0; i < k; i++ {
		b += c[n-i]
	}
	fmt.Fprintln(wr, n-b)

}


Measured memory_bytes: 4812
K = 33
L = K * 2
s = [['#' for j in range(L)] for i in range(K)]
t = [['.' for j in range(L)] for i in range(K)]

A, B = map(int, input().split())

def color(s, j0, i1, c):
    j = j0
    k = j0 * 2
    for i in range(1, i1):
        if L <= k:
            j += 1
            k = (j & 1) << 1
        s[j][k] = c
        k += 4

color(s, 0, A, '.')
color(t, 1, B, '#')

print(L, L)
f = lambda s : print('\n'.join((map(lambda s : ''.join(s), s))))
f(s)
f(t)


Measured memory_bytes: 9192
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const int MOD = 1e9 + 7;



int main() {
	int n, m;
	cin >> n >> m;
	vector< pair<int,int> > cities[101010];

	rep(i, 0, m) {
		int p, y;
		cin >> p >> y;
		cities[p].push_back({y,i});
	}


	pair<int, int> ans[101010];


	rep(i, 1, n+1) {
		sort(cities[i].begin(), cities[i].end());
		rep(j, 0, cities[i].size()) {
			ans[cities[i][j].second] = {i,j+1};
		}
	}

	rep(i, 0, m) {
		printf("%06d%06d\n",ans[i].first,ans[i].second);
	}






	


	return 0;
}


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

int main(){
    int N;
    string s;
    int count = 0;
    cin >> N >> s;
    for(int i=0;i<N;i++){
        if(s[i]=='R')   count++;
    }
    if((N/2)<count){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

const int MAX=700000;
const int MOD=1000000007;

long long fac[MAX],finv[MAX],inv[MAX];

void com(){
	fac[0]=fac[1]=1;
	finv[0]=finv[1]=1;
	inv[1]=1;
	for(int i=2;i<MAX;i++){
		fac[i]=fac[i-1]*i%MOD;
		inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
		finv[i]=finv[i-1]*inv[i]%MOD;
	}
}

//二項計算 nCk
long long comb(long long n,long long k){
	if(n<k)return 0;
	if(n<0||k<0)return 0;
	return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int main(){
	com();
	long long  x,y;
	scanf("%lld%lld",&x,&y);
	if((x+y)%3!=0){
		printf("%d\n",0);
	}else{
		long long m,n;
		m=(2*y-x)/3;
		n=(2*x-y)/3;
		printf("%lld\n",comb(m+n,m));
	}
	return 0;
}

Measured memory_bytes: 16512
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n;
    cin>>n;
    vector<ll> a(n);
    vector<ll> b(n);
    rep(i,n){
        cin>>a[i]>>b[i];
    }
    ll pre=0;
    ll ans=0;
    for(ll i=n-1;i>=0;i--){
        a[i]+=pre;
        if(a[i]%b[i]!=0){
         if(a[i]>b[i]){
             ll u = a[i]/b[i] + 1;

             ll pl=b[i]*u-a[i];
             ans+=pl;
             pre+=pl;
         }else{
             ans+=b[i]-a[i];
             pre+=b[i]-a[i];
         }

        }
      //  cout<<ans<<endl;
    }
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <algorithm>

const double PI = acos(-1);

typedef long long int64;
int n;
double ans[105];
bool convex[105];
struct point
{
	int x, y, id;
	int64 dis2()
	{
		return (int64)x * x + (int64)y * y;
	}
} p[105];
int64 det(const point &a, const point &b)
{
	return (int64)a.x * b.y - (int64)b.x * a.y;
}
int64 dot(const point &a, const point &b)
{
	return (int64)a.x * b.x + (int64)a.y * b.y;
}
point operator-(const point &a, const point &b)
{
	return (point){a.x - b.x, a.y - b.y};
}

bool operator<(const point &a, const point &b)
{
	return det(a - p[1], b - p[1]) > 0 || (det(a - p[1], b - p[1]) == 0 && (a - p[1]).dis2() < (b - p[1]).dis2());
}

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d%d", &p[i].x, &p[i].y), p[i].id = i;
	if (n == 1)
		puts("1");
	else
	{
		for (int i = 2; i <= n; i++)
			if (p[i].x < p[1].x || (p[i].x == p[1].x && p[i].y < p[1].y))
				std::swap(p[1], p[i]);
		std::sort(p + 2, p + 1 + n);
		static point st[105];
		int top = 0;
		for (int i = 1; i <= n; i++)
		{
			while (top >= 2 && det(st[top - 1] - st[top], p[i] - st[top]) >= 0)
				top--;
			st[++top] = p[i];
		}
		if (top == 2)
			ans[st[1].id] = ans[st[2].id] = 0.5;
		else
		{
			st[0] = st[top];
			st[top + 1] = st[1];
			for (int i = 1; i <= top; i++)
			{
				point a = st[i] - st[i - 1], b = st[i + 1] - st[i];
				ans[st[i].id] = acos(dot(a, b) / sqrt(a.dis2()) / sqrt(b.dis2())) / (2 * PI);
			}
		}
		for (int i = 1; i <= n; i++)
			printf("%.20f\n", ans[i]);
	}
	return 0;
}

Measured memory_bytes: 128
// D - Road to Millionaire
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; cin>>N;
	int64_t yen = 1000;
	int now; cin>>now;
	for(int i=0; i<N-1; ++i){
		int nxt; cin>>nxt;
		yen += max(0L, yen/now * (nxt - now));
		now = nxt;
	}
	cout<< yen <<endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define ep emplace_back
#define st first
#define sc second

using namespace std;

const ll mod = 998244353;
const int e = 1e6 + 69;
const int base = 311;

// dung igt thay cho gt luc tinh giai thua
// 3
// cach tao hoan vi tu n so : n*(n+1)/2;

struct kien
{
    string s;
};
kien p[100+2];

bool lf(kien p, kien q)
{
    return p.s < q.s;
}

int main()
{
    int n, l;
    cin >> n >> l;
    for(int i=1; i<=n; i++)
    {
        cin >> p[i].s;
    }
    sort(p+1, p+n+1, lf);
    for(ll i=1; i<=n; i++) cout << p[i].s ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int n,l,i,p,ans=0;
  cin >> n >> l;
  if (l>=0) p=0;
  else if (-l<=n-1) p=-l;
  else p=n-1;
  for (i=0;i<n;i++) if (i!=p) ans+=l+i;
  cout << ans << endl;
  return 0;
}

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

int main(void)
{
    int a, b, c, x;
    cin >> a >> b >> c >> x;

    int count = 0;
    for (int i = 0; i <= a; i++)
    {
        for (int j = 0; j <= b; j++)
        {
            for (int k = 0; k <= c; k++)
            {
                if (x == 500 * i + 100 * j + 50 * k)
                {
                    count += 1;
                }
            }
        }
    }

    cout << count;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include <vector>
#include <cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;

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

const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  vll A(100);
  ll a,b,c;
  	ci(a>>b>>c);
  A[a-1]++;
  A[b-1]++;
  A[c-1]++;
  ll ans=0;
  FOR(i,0,100){
    if(A[i]>0) ans++;
  }
  co(ans)
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
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; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,-1,1,1,-1};
int dy[]={0,1,0,-1,-1,-1,1,1};




int main(){
    int n;cin >> n;
    vector<int> a(3*n);
    for (int i = 0; i < 3*n; i++) {
        cin >> a[i];
        a[i]--;
    }
    LL ans = 0;
    vector<vector<int>> dp(n, vector<int> (n, -INF));
    vector<int> dp_max(n, -INF);
    dp[a[0]][a[1]] = 0;
    dp[a[1]][a[0]] = 0;
    dp_max[a[0]] = 0;
    dp_max[a[1]] = 0;
    int mx = 0;
    for (int i = 0; i < n - 1; i++) {
        vector<int> v{a[i * 3 + 2], a[i * 3 + 3], a[i * 3 + 4]};
        sort(ALL(v));
        auto ndp_max = dp_max;
        int p = v[0], q = v[1], r = v[2];
        auto dp0 = dp[p], dp1 = dp[q], dp2 = dp[r];
        auto f = [&](int i,int j, int k){
            chmax(dp[i][j], k);
            chmax(dp[j][i], k);
            chmax(ndp_max[i], k);
            chmax(ndp_max[j], k);
        };
        if(v[0] == v[2]) {
            ans++;
            continue;
        }
        else if(v[0] == v[1]) {
            int p = v[0], q = v[2];
            auto dpp = dp[p];
            for (int k = 0; k < n; k++) {
                f(q, k, dp0[k] + 1);
            }
        }
        else if(v[1] == v[2]) {
            int p = v[2], q = v[0];
            for (int k = 0; k < n; k++) {
                f(q, k, dp2[k] + 1);
            }
        }
        for (int k = 0; k < n; k++) {
            f(p, k, dp_max[k]);
            f(q, k, dp_max[k]);
            f(r, k, dp_max[k]);
        }

        f(p, q, max(mx, dp2[r] + 1));
        f(q, r, max(mx, dp0[p] + 1));
        f(r, p, max(mx, dp1[q] + 1));

        dp_max = ndp_max;
        for (int j = 0; j < n; j++) {
            chmax(mx, dp_max[j]);
        }
    }
    int P = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            chmax(P, dp[i][j] + (i == j and i == a[3 * n - 1]));
        }
    }
    ans += P;
    cout << ans << endl;
    return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int>v(n);
	vector<int>cost(n);
	for(int i=0;i<n;i++){
		cin >> v[i];
	}
	for(int i=0;i<n;i++){
		cin >> cost[i];
	}
	int sum = 0;
	for(int i=0;i<n;i++){
		if((v[i]-cost[i])>0){
			sum = sum+v[i]-cost[i];
		}
	}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;
int n,t, ans = 0;
vector<int> a(200000);
int main(){
    cin >> n >> t;
    for (int i = 0; i < n;i++) {
        cin >> a[i];
    }
    for (int i = 0; i < n - 1;i++) {
        if (t > a[i + 1] - a[i]) {
            ans += a[i + 1] - a[i];
        }
        else
            ans += t;
    }
    ans += t;
    cout << ans << endl;
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {
	var n, a, b int
	fmt.Scan(&n, &a, &b)
	va := a
	vb := b
	for i := 0; i < 200; i++ {
		if va+1 == vb {
			va--
		} else {
			va++
		}
		if va < 1 {
			fmt.Println("Borys")
			return
		}
		if vb != n {
			vb++
		} else {
			if va == vb-1 {
				fmt.Println("Alice")
				return
			}
			vb--
		}
	}
	va = a
	vb = b
	for i := 0; i < 200; i++ {
		if va != 1 {
			va--
		} else {
			if vb == 2 {
				fmt.Println("Borys")
				return
			}
			va++
		}
		if va+1 != vb {
			vb--
		} else {
			if vb != n {
				vb++
			} else {
				fmt.Println("Alice")
				return
			}
		}
	}
	fmt.Println("Draw")
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using   namespace std;
int main(){
    long double r;
    cin>>r;
    
    long double cir=(double)2*(M_PI)*r;
    //float pi=float(22/7);
   // cout<<pi<<endl;
    cout<<fixed<<setprecision(20)<<cir;
    
    
    return 0;
}

Measured memory_bytes: 3768
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  int cnt=0;
  for(int j=0;j<n;j++){
    if(j%2==0) cnt+=a[j];
    else cnt-=a[j];
  }
  cout<<cnt;
}


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

int main()
{
	int64_t n, k;
	cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		int a_in;
		cin >> a_in;
		a.at(i) = a_in - 1;
	}

	vector<bool> seen(n, false);
	vector<int> syuuki = {0};
	seen.at(0) = true;
	int index = 0;
	int start = 0;
	int end = 0;
	while (true) {
		index = a.at(index);
		if (seen.at(index) == false) {
			seen.at(index) = true;
			syuuki.push_back(index);
		} else {
			start = index;
			int l = syuuki.size();
			end = syuuki.at(l - 1);
			break;
		}
	}

	int nn = syuuki.size();
	int64_t start_index;
	int64_t end_index = nn - 1;
	for (int i = 0; i < nn; i++) {
		if (syuuki.at(i) == start) {
			start_index = i;
		}
	}

	int64_t cnt = end_index - start_index + 1;
	int64_t amari = (k - start_index) % cnt;
	int ans;
	if (k > start_index) {
		ans = syuuki.at(start_index + amari) + 1;
	} else {
		ans = syuuki.at(k) + 1;
	}

	cout << ans << endl;

}


Measured memory_bytes: 5028
N = int(input())
txy = [list(map(int, input().split())) for i in range(N)]

for i in range(N):
    if i == 0:
        if txy[i][0] < abs(txy[i][1]) + abs(txy[i][2]) or txy[i][0]%2 != (txy[i][1] + txy[i][2])%2:
            print("No")
            exit()
    else:
        if txy[i][0] - txy[i-1][0] < abs(txy[i][1] - txy[i-1][1]) + abs(txy[i][2] - txy[i-1][2]) \
        or txy[i][0]%2 != (txy[i][1] + txy[i][2])%2:
            print("No")
            exit()

print("Yes")


Measured memory_bytes: 27300
import math
n,k = map(int,input().split())
num = 0
for i in range(1,n + 1):#サイコロの出た目
    if i >= k:
        num += 1 / n
    else:
        num += (1 / (n * (2 ** math.ceil(math.log(k / i,2)))))
print(num)

Measured memory_bytes: 9076
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define INF 1000000000
#define mod 1000000007
long modpow(long a,int p){
	if(p==0)return 1;
	if(p%2==0){
		int halfP=p/2;
		long half=modpow(a,halfP);
		
		return half*half%mod;
	}
	else{
		return a*modpow(a,p-1)%mod;
	}
}
long calcComb(int a,int b){
	if(b>a-b)return calcComb(a,a-b);
	long ansMul=1;
	long ansDiv=1;
	REP(i,b){
		ansMul*=(a-i);
		ansDiv*=(i+1);
		ansMul%=mod;
		ansDiv%=mod;
	}
	long ans=ansMul*modpow(ansDiv,mod-2)%mod;
	return ans;
}

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
	ll N,M;
	cin>>N>>M;

	
	int MNokori=M;
	long ans=1;
	for(int i=2;i*i<=MNokori;i++){
		if(MNokori%i==0){
			int cnt=0;
			while(MNokori%i==0){
				cnt++;MNokori/=i;
			}
			ans*=calcComb(N+cnt-1,N-1);
			ans%=mod;
		}
	}
	if(MNokori!=1){
		ans*=calcComb(N+1-1,N-1);
		ans%=mod;
	}
	
	cout<<ans<<endl;
	return 0;
}


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

int N, C, s, t, c, mx, v[35][100005];

int main() {
    cin >> N >> C;
    while (N--) {
        cin >> s >> t >> c;
        for (int i = s; i <= t; i++) {
            v[c][i] = 1;
        }
    }

    for (int i = 1; i <= 100000; i++) {
        s = 0;
        for (int j = 1; j <= C; j++) {
            s += v[j][i];
        }
        mx = max(mx, s);
    }

    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 12160
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<stdio.h>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<set>
#include<math.h>
#include<stack>
#include<sstream>
#include<queue>
#include<list>
#include<iomanip>
#include<bitset>
#include<limits.h>
#include <bits/stdc++.h>
#define MOD  1000000007
#define BIG  1000000005
#define ii pair<int,int>
#define iii pair<int,pair<int,int> >
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define pi pair<int,int>;
typedef long long ll;
using namespace std;


int main()
{
    //freopen("input.txt", "r", stdin);

     int a , b ,c;
     cin >> a >> b>>c  ;
    int k ;
    cin >> k ;
    ll res = max( max(a,b) , c) ;

     cout << res*pow(2,k)+ a + b + c - res << endl ;
            return 0 ;

}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int main(void)
{
	int a,s,d,f,g,h,i,j;
	scanf("%d",&f);
	for(i=0;i<f;i++){
		scanf("%d %d %d",&a,&s,&d);
		if(a*a==s*s+d*d||d*d==s*s+a*a||s*s==d*d+a*a)
			printf("YES\n");
		else
			printf("NO\n");
	}
	return 0;
}

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

/* short names and const
using ll = long long;
using vll = vector<long long>;
using df = vector<vll>;
df data(n, vll(m));
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
*/

/* Boost!
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/range/algorithm.hpp> // boost::sort(arr)
using boost::algorithm::split; // split(result, s, boost::is_any_of(","));
using boost::algorithm::join; // string s = join(arr, "");
using boost::algorithm::replace_all; // replace_all(s, "AtCoder", "A");
*/

/* print(arr)
template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}
*/

/* fast cin and precise cout
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  getline(cin, s);
  cout << fixed << setprecision(15);
*/

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
}

int main() {
  int a, b;
  cin >> a >> b;
  cout << b * 2 - a;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int count = 0;
		if(b != 1) {
			count = 1;
		}
		int sum = a;
		while(b > sum) {
			sum += a-1;
			count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 23764
def main():
    n, c = map(int, input().split())
    xv = [list(map(int, input().split())) for _ in range(n)]
    v, left_max, right_max = 0, 0, 0
    gl = [None]*n
    gr = [None]*n
    _2oas = [None]*(n+1)
    _2obs = [None]*(n+1)
    _2oas[0], _2obs[0] = 0, 0
    ans = 0
    for i, (xi, vi) in enumerate(xv):
        v += vi
        left = v - xi
        if left_max < left:
            left_max = left
        gl[i] = left_max
        _2oas[i+1] = v - 2*xi
    v = 0
    for i, (xi, vi) in enumerate(xv[::-1]):
        v += vi
        right = v - c + xi
        if right_max < right:
            right_max = right
        gr[i] = right_max
        _2obs[i+1] = v - 2*(c - xi)
    for i in range(1, n+1):
        oa = gl[-i]
        _2ob = _2obs[i-1]
        ob = gr[-i]
        _2oa = _2oas[i-1]
        if ans < _2oa+ob:
            ans = _2oa+ob
        if ans < _2ob+oa:
            ans = _2ob+oa
    print(ans)
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 71512
#include <stdio.h>
int main(void){
  int s,m,h;
  scanf("%d",&s);
  h=s/3600;
  m=(s-h*3600)/60;
  s=s-h*3600-m*60;
  printf("%d:%d:%d\n",h,m,s);
  
  return 0;
}

Measured memory_bytes: 1852
#include <stdio.h>

int main(void){
  int i,n = 0;
  char w[11], t[1001];
  scanf("%s", w);
  do{
    scanf("%s",t);
    if(!strcmp(t,"END_OF_TEXT")) break;
      for(i=0;t[i]!='\0';i++)
        if(t[i]<91) t[i] += 32;
    if( !strcmp(w,t) ) n++;
  }

  while(1);
  printf("%d\n",n);
  return 0;
}


Measured memory_bytes: 2048
while True:
    n = int(input())
    if n == 0: break
    ans = 0
    f = input().split()
    for i in range(len(f) - 1):
        if f[i] == "lu" and f[i+1] == "ru" \
                or f[i] == "ru" and f[i+1] == "lu" \
                or f[i] == "ld" and f[i+1] == "rd" \
                or f[i] == "rd" and f[i+1] == "ld":
                    ans += 1
    print(ans)

Measured memory_bytes: 6720
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

long long gcd(long long a, long long b) {
    if(a < b) gcd(b, a);
    long long r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main() {
    
    long x,y;
    cin >> x >> y;
    cout << gcd(x,y) << endl;


}


Measured memory_bytes: 3120
import java.util.*;

class SortingThreeNumbers {
    public static void main(String...args) {
        final Scanner sc = new Scanner(System.in);
        final int[] nums = new int[3];
        for (int i = 0; i < 3; i++) {
            nums[i] = sc.nextInt();
        }
        Arrays.sort(nums);
        System.out.println(nums[0] + " " + nums[1] + " " + nums[2]);
    }
}
public class Main {
    public static void main(String... args) {
        SortingThreeNumbers.main();
    }
}

Measured memory_bytes: 17168
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define SWAP(type, x, y) do { type tmp = x; x = y; y = tmp; } while (0)

#define MOD 1000000007 

//昇順
int asc(const void* a, const void* b){
    return *(int*)a-*(int*)b;
}

int main(void){
    int N;
    scanf("%d",&N);

    //A[0]~A[N-1]に格納する
    int* A;
    NEW(A,N);
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    qsort(A,N,sizeof(int),asc);

    int ans=0;
    int tmp=A[0];
    int cnt=0;
    for(int i=0;i<N;i++){
        if(A[i]==tmp) cnt++;
        else{
            if(cnt<tmp) ans+=cnt;
            else ans+=(cnt-tmp);

            tmp=A[i];
            cnt=1;
        }
    }
    if(cnt<tmp) ans+=cnt;
    else ans+=(cnt-tmp);
    printf("%d\n",ans);

    return 0;
}

Measured memory_bytes: 892
#include<bits//stdc++.h>
using namespace std;
int n,l;
int main()
{
	cin >> n >> l;
	int sum = (n * (n - 1)) / 2 + n * l;
	int t = n + l-1;
	if (l > 0 && t > 0)
	{
		cout << sum - min(l,t) << endl;
	}
	else if (l < 0 && t < 0)
	{
		cout <<sum - max(l, t) << endl;
	}
	else cout << sum << endl;
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-06-27 15:37:37 +0900
# LastModified: 2020-06-27 15:43:18 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    if n<=k:
        print(0)
        return
    h.sort()
#    print(h)
    print(sum(h[:n-k]))



if __name__ == "__main__":
    main()


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

int arr[101];
int result[101];

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


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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




int main(){
    int N; cin >> N;
    VI A(N), P(N), Q(N);
    REP(i, N){
        A[i] = i+1;
        cin >> P[i];
    }
    REP(i, N) cin >> Q[i];
    int a = 0, b = 0, i = 1;
    do{
        if(A == P) a = i;
        if(A == Q) b = i;
        ++i;
        if(a && b) break;
    }while(next_permutation(ALL(A)));
    cout << abs(a - b) << endl;
    return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
x = 0
t = True
while t:
    for i in range(n):
        if a[i] % 2 == 1:
            t = False
        else:
            a[i] /= 2
    if t == True:
        x += 1
print(x)

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

int main() {
    int n,tmp,h; cin>>n;
    tmp = n;
    h = 0;
    while(tmp>0){
        h+=tmp%10;
        tmp/=10;
    }
    if(n%h==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n,d,r;
	cin>>n>>d>>r;
	while(n--){
		int a;
		cin>>a;
		r+=1+(d-1)/a;
	}
	cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 256
f=lambda:map(int,input().split())
N,K=f()
r,s,p=f()
T=list(input())
F=[0]*N
res=0
for i in range(N):
    if F[i]==1:
        continue
    if i+K<N:
        if T[i]==T[i+K]:
            F[i+K]=1
    if T[i]=='s':
        res+=r
    elif T[i]=='p':
        res+=s
    else:
        res+=p
print(res)

Measured memory_bytes: 78624
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n,a,b;
	cin >> n >> a >> b;

	cout << min(a,b) << " " << (a+b>n ? (a+b)-n : 0) << '\n';
	return 0;
}



Measured memory_bytes: 256
using System;
public class MainClass
{
	public static void Main(string[] args)
	{
		string line = Console.ReadLine();
		string[] inputs = line.Split(' ');
		int n = int.Parse(inputs[0]);
		int m = int.Parse(inputs[1]);
		int[] mArray = new int[m+1];
		int result = 0;
		for(int i = 0; i < n; i++)
		{
			string l = Console.ReadLine();
			string[] t = l.Split(' ');
			int k = int.Parse(t[0]);
			for(int j = 1; j < k+1; j++)
			{
				int foodNo = int.Parse(t[j]);
				mArray[foodNo]++;
				if(i == n - 1 && mArray[foodNo] == n)
				{
					//LastKai
					result++;
				}
			}
		}
		Console.WriteLine(result);
	}
}

Measured memory_bytes: 11092
#coing:utf-8


def distance(a,b):

    dst = pow(a,2) + pow(b,2)

    return dst

def isTriangle(lines):

    idxList = [[0,1,2],[1,0,2],[2,0,1]]
    flag = False
    for i in idxList:
        if not flag and pow(lines[i[0]],2) == distance(lines[i[1]], lines[i[2]]):
            flag = True

    return flag

if __name__ == '__main__':

    num = int(input())

    results = []

    for i in range(num):
        lines = [int(item) for item in input().split(" ")]
        results.append(isTriangle(lines))

    for r in results:
        if r:
            print("YES")
        else :
            print("NO")

Measured memory_bytes: 7600
#include <stdio.h>

int main() {
  int i, number_of_towns, number_of_roads, town_a, town_b;
  scanf("%d %d", &number_of_towns, &number_of_roads);
  int road_counter[50] = {};
  for(i = 0; i < number_of_roads; i++) {
    scanf("%d %d", &town_a, &town_b);
    road_counter[town_a-1]++;
    road_counter[town_b-1]++;
  }
  for(i = 0; i < number_of_towns; i++) {
    printf("%d\n", road_counter[i]);
  }
  return 0;
}


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

const int INF = 1e9;

int main() {
  int n;
  cin>>n;
  int k = -1;
  for (int i=1; i<=sqrt(2*n); i++) {
    if (i * (i + 1) == 2 * n) {
      k = i;
      break;
    }
  }
  if (k == -1) {
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;

  int ans[k+1][k];
  int s = 1;
  for (int i=0; i<k+1; i++) {
    for (int j=i; j<k; j++) {
      ans[i][j] = s + (j - i);
    }
    for (int j=i+1; j<k+1; j++) {
      ans[j][i] = s + (j - i - 1);
    }
    s += k - i;
  }
  cout<<k+1<<endl;
  for (int i=0; i<k+1; i++) {
    cout<<k<<" ";
    cout<<ans[i][0];
    for (int j=1; j<k; j++) {
      cout<<" "<<ans[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 2176
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
    public void main(Scanner sc) {
        List<Integer> primeList = createPrime(100000);
        int like2017[] = new int[50001];
        for (int prime : primeList) {
            int tmp = (prime + 1) / 2;
            if (prime % 2 == 1 && primeList.contains(tmp)) {
                like2017[tmp] = 1;
            }
        }

        int sum = 0;
        for (int i = 0; i <= 50000; i++) {
            sum += like2017[i];
            like2017[i] = sum;
        }

        int q = sc.nextInt();
        for (int i = 0; i < q; i++) {
            int l = sc.nextInt();
            int r = sc.nextInt();

            System.out.println(like2017[(r + 1) / 2] - like2017[(l - 1) / 2]);
        }
    }

    private List<Integer> createPrime(int n) {
        List<Integer> primeList = new ArrayList<>(Arrays.asList(2, 3, 5, 7));

        for (int i = 9; i <= n; i += 2) {
            boolean flag = true;
            for (long prime : primeList) {
                if (prime * prime > i) {
                    break;
                }
                if (i % prime == 0) {
                    flag = false;
                    break;
                }
            }
            if (flag) {
                primeList.add(i);
            }
        }

        return primeList;
    }

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


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

int partition_out(vector <int> &A, int q){
    int n = A.size();
    for (int i=0; i<n; i++){
		if (i==q) cout << "[" << A[i] << "]";
		else cout << A[i];
		if (i!= n-1) cout<<" ";
        else cout<<endl;
    }
    return 0;
}

int partition(vector <int> &A, int p, int r){
	int x = A[r];
	int i = p;
	for (int j=p; j<r; j++){
		if (A[j]<=x){
			swap(A[j], A[i]);
			i++;
		}
	}
	swap(A[i], A[r]);
	return i;
}


int main(void){
	int n, p,q,r;
	cin >> n;
	vector <int> A(n,0);
	for (int i=0; i<n; i++)
		cin >> A[i];
	q = partition(A, 0, n-1);
	partition_out(A, q);
	return 0;
}

Measured memory_bytes: 1532
while True:
	try:
		n = eval(input())
		is_prime = [True for _ in range(n+1)]
		is_prime[1] = False
		for i in range(2,int((n+1)/2)):
			if is_prime[i]:
				for j in range(i*2,n+1,i):
					is_prime[j] = False
		is_prime_rev = list(is_prime)
		is_prime_rev.reverse()
		count = 0
		for i in range(1,n+1):
			count = count + (1 if is_prime[i] and is_prime_rev[i-1] else 0)
		print(count)
	except EOFError:
		break

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

#define ll long long int

int main(){
  string a[3]={"Sunny","Cloudy","Rainy"};
  string x;
  cin >> x;
  if(x=="Sunny"){
    cout<<"Cloudy"<<endl;
  }
  else if(x=="Cloudy"){
    cout<<"Rainy"<<endl;
  }
  else{
    cout<<"Sunny"<<endl;
  }
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
  int i,n,x;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    x=i;
    if((x%3)==0 )printf(" %d",i);
    else
      while(x){
        if( x%10==3){
          printf(" %d",i);
          break;
        }
        x=x/10;
      }
  }
    printf("\n");

  return 0;
}

Measured memory_bytes: 2676
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl



int main() {
    int Q;  cin >> Q;
    vector<int> l(Q);
    vector<int> r(Q);
    rep(i, Q)  cin >> l[i] >> r[i];

    int N = int(pow(10, 5));
    vector<int> prime;
    for (int i=2; i<N; i++) {
        if (i % 2 == 0) continue;
        bool flag = true;
        for (int j=2; j<sqrt(i)+1; j++) {
            if (i % j == 0) {
                flag = false;
            }
        }
        if (flag) {
            prime.push_back(i);
        }
    }

    vector<int> prime2;
    for (int i=2; i<N; i++) {
        if (i % 2 == 0) continue;
        bool flag = true;
        for (int j=2; j<sqrt(i); j++) {
            if ((i+1)/2 % j == 0) {
                flag = false;
            }
        }
        if (flag) {
            prime2.push_back(i);
        }
    }

    vector<int> primeA;
    rep(i, max(prime.size(), prime2.size())) {
        rep(j, min(prime.size(), prime2.size())) {
            if (prime[i] == prime2[j]) {
                primeA.push_back(prime[i]);
            }
        }
    }

    vector<int> row;
    rep(i, N) {
        bool flag = false;
        rep(j, primeA.size()) {
            if (i == primeA[j]) {
                flag = true;
            }
        }
        if (flag) row.push_back(1);
        else row.push_back(0);
    }

    vector<int> sum(N, 0);
    rep(i, N) {
        if (row[i]) sum[i+1] = sum[i] + 1;
        else sum[i+1] = sum[i];
    }

    rep(i, Q) {
        print(sum[r[i]+1] - sum[l[i]]);
    }


}

Measured memory_bytes: 2424
#include <iostream>
#include <iomanip>

using namespace std;

int a, b, answer;
char op;

int main(){
	
	while (true){

		cin >> a >> op >> b;

		if (op == '?') { 
			break; 
		}
		else if (op == '+'){
			answer = a + b;
		}
		else if (op == '-'){
			answer = a - b;
		}
		else if (op == '*'){
			answer = a * b;
		}
		else if (op == '/'){
			answer = a / b;
		}

		cout << answer << endl;

	}
	return 0;
}






Measured memory_bytes: 3048