akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cctype>
#include<utility>

using namespace std;
int main()
{
    int n,k,i,c1,a,b;
    scanf("%d %d",&n,&k);
    int  p[n],m=n;
    for(i=0; i<n; i++)
    {
        scanf("%d",&p[i]);
        if(m>p[i])
        {
            m=p[i];
            a=i;
        }
    }
    //if(k>=n)
      //  printf("1\n");
   // else
   // {
        c1=a/(k-1);
        b=c1*(k-1);
        c1+=(n-1-b)/(k-1);
        if((n-1-b)%(k-1))
            c1++;
        printf("%d\n",c1);
   // }
    return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int h = in.nextInt();
            int w = in.nextInt();

            String[] s = in.nextStringArray(h);

            boolean[][] b = new boolean[h][w];
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    b[i][j] = s[i].charAt(j) == '#';
                }
            }

            int[] dx = {1, 0, -1, 0};
            int[] dy = {0, 1, 0, -1};
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++) {
                    if (b[i][j]) {
                        boolean flg = true;
                        for (int k = 0; k < 4; k++) {
                            if (0 <= i + dy[k] && i + dy[k] < h && 0 <= j + dx[k] && j + dx[k] < w) {
                                if (b[i + dy[k]][j + dx[k]]) {
                                    flg = false;
                                    break;
                                }
                            }
                        }
                        if (flg) {
                            out.println("No");
                            return;
                        }
                    }
                }
            }

            out.println("Yes");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public String[] nextStringArray(int n) {
            String[] res = new String[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextString();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 23508
#include <iostream>

using namespace std;

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    double x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    double a = x2 - x1, b = y2 - y1, c = x4 - x3, d = y4 - y3;
    if (a * d - b * c == 0.0)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  set<int> ans;
  for (int i = 1; i < N + 1; i++){
     ans.insert(i);
  }
  
  for (int i = 0; i < K; i++){
    int d;
    cin >> d;
    vector<int> A(d);
    for (int j = 0; j < d; j++){
       cin >> A[j];
       ans.erase(A[j]);
    }
  }
    
  cout << ans.size() << endl;
}


Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main()
{
    int X, Y, Z;
    cin >> X >> Y >> Z;

    int tmp = X;
    X = Y;
    Y = tmp;

    tmp = X;
    X = Z;
    Z = tmp;

    cout << X << " " << Y << " " << Z;

    return 0;
}

Measured memory_bytes: 256
public class Main{
	public static void main(String[] args){
		//
		String input = new java.util.Scanner(System.in).nextLine();
		String[] words = input.split("\\s");
		int a = Integer.parseInt(words[0]);
		int b = Integer.parseInt(words[1]);
		if( a > b ){
			System.out.println("a > b");
		}else if( a < b ){
			System.out.println("a < b");
		}else if( a == b ){
			System.out.println("a == b");
		}
		//
	}
}

Measured memory_bytes: 26120
while True:
    h, w = map(int, input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for j in range(w):
            if i!=0 and i!=h-1 and j!=0 and j!=w-1 :
                print('.', end="")
            else:
                print('#', end="")
        print('')
    print('')



Measured memory_bytes: 7012
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
//const int MAX=1;

int main(){
	int N,A,B,C;
	cin>>N>>A>>B>>C;
	int l[8];
	rep(i,N)cin>>l[i];
	
	int ans=1e9;
	//全検。bit列で2マスずつ見て使うか判断
	rep(bit,1<<(2*N)){
		int u[8];
		rep(i,N){
			int a=(bit >> 2*i) & 1;
			int b=(bit >> (2*i+1)) & 1;
			u[i]=a+2*b;
		}
		int x=0, y=0, z=0;
		int cx=0, cy=0, cz=0; 
		rep(i,N){
			if(u[i]==1){x+=l[i];cx++;}
			if(u[i]==2){y+=l[i];cy++;}
			if(u[i]==3){z+=l[i];cz++;}
		}
		if(cx&&cy&&cz){
			int mp=(cx+cy+cz-3)*10+abs(x-A)+abs(y-B)+abs(z-C);
          	if(ans>mp){
            	ans=mp;
            }
		}
	}
	cout<<ans;
}

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

using namespace std;

#define fRead(x)  freopen(x,"r",stdin)
#define fWrite(x) freopen (x,"w",stdout)

#define LL long long
#define ULL unsigned long long
#define ff first
#define ss second
#define pb push_back
#define INF 2e16
#define PI acos(-1.0)
#define mk make_pair

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(a,min(b,min(c,d)))
#define max4(a,b,c,d) max(a,max(b,max(c,d)))
#define SQR(a) ((a)*(a))
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,b) for(int i=0;i<b;i++)
#define MEM(a,x) memset(a,x,sizeof(a))
#define ABS(x) ((x)<0?-(x):(x))

#define scanI(a) scanf("%d",&a)
#define scanI2(a,b) scanI(a) , scanI(b)
#define scanI3(a,b,c) scanI(a), scanI(b), scanI(c)
#define scanI4(a,b,c,d) scanI(a), scanI(b), scanI(c), scanI(d)

#define scanL(a) scanf("%I64d",&a)
#define scanL2(a,b) scanL(a) , scanL(b)
#define scanL3(a,b,c) scanL(a), scanL(b), scanL(c)
#define scanL4(a,b,c,d) scanL(a), scanL(b), scanL(c), scanL(d)

#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())

#define FastRead ios_base::sync_with_stdio(0);cin.tie(nullptr);

int main()
{
    int n , m;
    cin >> n >> m;
    if(n == m)cout << "Yes\n";
    else cout << "No\n";
}



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

public class Main {

	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader (System.in));
		String[] str = br.readLine().split(" ");
		
		int N = Integer.parseInt(str[0]);
		int K = Integer.parseInt(str[1]);
		int mul = K;
		
		for(int i=0; i<(N-1); i++){
			mul *= (K-1);
			
		}
		System.out.println(mul);
	}

}

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

//////全探索したいときに開けよ////////
/*
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}
*/

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n;
  cin >> n;
  vector<pair<int64_t,int64_t>> a(n);
  rep(i,n) cin >> a.at(i).first >> a.at(i).second;
  vector<pair<int64_t,int64_t>> diffa;
  for(int i=0;i< n;i++){
    for(int j=i+1;j<n;j++){
      int64_t diffx = a.at(j).first - a.at(i).first;
      int64_t diffy = a.at(j).second - a.at(i).second;
      if(diffx > 0){
        diffa.push_back(pair<int64_t,int64_t>(diffx,diffy));
      }else if(diffx < 0){
        diffa.push_back(pair<int64_t,int64_t>(-diffx,-diffy));
      }else{
        diffa.push_back(pair<int64_t,int64_t>(0,abs(diffy)));
      }
    }
  }
  sort(diffa.begin(),diffa.end());
  int cnt = 1;
  int maxcnt = 1;
  rep(i,diffa.size()-1){
    //cout << diffa.at(i).first << diffa.at(i).second<<endl; 
    if(diffa.at(i) == diffa.at(i+1)){
      cnt++;
    }else{
      if(maxcnt < cnt){
        maxcnt = cnt;
      }
      cnt = 1;
    }
  }
  if(maxcnt < cnt){
     maxcnt = cnt;
  }
  if(n != 1){
    cout << n-maxcnt << endl;
  }else{
    cout << 1 << endl;
  }
     
}

Measured memory_bytes: 256
///
// File:  1165.cpp
// Author: ymiyamoto
//
// Created on Mon Nov 13 01:16:40 2017
//

#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

int32_t main()
{
  while (true) {
    uint32_t N;
    cin >> N;
    if (N == 0) break;

    vector<pair<int32_t, int32_t>> poss;
    poss.push_back({100, 100});
    for (uint32_t i = 1; i < N; i++) {
      int32_t n, d;
      cin >> n >> d;
      pair<int32_t, int32_t> pos = poss[n];
      if (d == 0) {
        poss.push_back({pos.first, pos.second - 1});
      } else if (d == 1) {
        poss.push_back({pos.first + 1, pos.second});
      } else if (d == 2) {
        poss.push_back({pos.first, pos.second + 1});
      } else if (d == 3) {
        poss.push_back({pos.first - 1, pos.second});
      }
    }

    int32_t min_height = INT32_MAX;
    int32_t max_height = 0;
    int32_t min_width = INT32_MAX;
    int32_t max_width = 0;
    for (auto pos = poss.begin(); pos < poss.end(); pos++) {
      min_height = min(min_height, pos->first);
      max_height = max(max_height, pos->first);
      min_width = min(min_width, pos->second);
      max_width = max(max_width, pos->second);
    }
    cout << 1 + max_width - min_width << " " << 1 + max_height - min_height << endl;
  }

  return 0;
}

Measured memory_bytes: 3024
hiki,hon = map(int,input().split())
turu = 0
kame = 0

for i in range(50):
    if hiki > 0 and hon >= 4:
        hon = hon - 4
        kame = kame + 1
        hiki = hiki - 1
    elif hon == 2 and hiki == 1:
        hiki = 0
        hon = 0
    else:
        break

hantei = hon % 2

for i in range(50):
    if hiki == 0 or kame == 0 or hantei == 1:
        break
    elif hiki > 0 and kame > 0 and hantei == 0:
        hiki = hiki - 1
        kame = kame - 1

if hiki == 0 and hon == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
void solve(){
    
}
int main() {
  int sum=0;
  int k;
  cin>>k;
  for(int i=1;i<=k;i++){
    for(int j=1;j<=k;j++){
      for(int l=1;l<=k;l++){
        int p=__gcd(i,j);
        sum+=(__gcd(p,l));
      }
    }
  }
  cout<<sum;
  return 0;
}

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

int main()
{
    vector<int> prime;
    vector<bool> is_prime(100010, true);

    for (int i = 0; i < 2; i++)
    {
        is_prime[i] = false;
    }
    
    for (int i = 2; i <= 100000; i++)
    {
        if(is_prime[i])
        {
            for (int j = i * 2; j <= 100000; j += i)
            {
                is_prime[j] = false;
            }
            prime.push_back(i);
        }
    }
    
    vector<int> like2017(100010, 0);
    for (int i = 0; i < (int)prime.size(); i++)
    {
        if(is_prime[(prime[i] + 1) / 2])
        {
            like2017[prime[i]] = 1;
        }
    }
    vector<int> sumlike2017(100010, 0);
    for (int i = 0; i < 100010; i++)
    {
        sumlike2017[i + 1] = sumlike2017[i] + like2017[i + 1];
        //cout << sumlike2017[i] << " ";
    }
    
    int q;
    cin >> q;
    while (q--)
    {
        int l, r;
        cin >> l >> r;

        cout << sumlike2017[r] - sumlike2017[l - 1] << endl;
    }
    
}

Measured memory_bytes: 3900
#include <bits/stdc++.h> 
using namespace std;
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=1e5+2;

int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int a,b,c;
      cin>>a>>b>>c;
      if(a+b+c>=22) cout<<"bust\n";
      else cout<<"win";
}
// I never lose. I either win or I learn

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll MOD = 1'000'000'007;

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;cin>>n;
    int res = 0;
    for (int i = 1; i <= n; i+=2)
    {
        int cnt = 0;
        for (int j = 1; j <= i; j++)
        {
            if (i % j == 0)
            {
                cnt++;
            }
        }
        res += (cnt == 8);
    }
    cout <<res<<endl;
    
    return 0;
}


Measured memory_bytes: 3640
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <vector>
namespace fastIO{
#define getchar() my_getchar()
#define putchar(x) my_putchar(x)
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;
	char buf[IN_BUF], *ps = buf, *pt = buf;
	inline char my_getchar() {
		return ps == pt && (pt = (ps = buf) + fread(buf, 1, IN_BUF, stdin), ps == pt) ? EOF : *ps++;
	}
	template<typename T> inline bool read(T &x){
		char op = 0, ch = getchar();
		for (x = 0; !isdigit(ch) && ch != EOF; ch = getchar()) if (ch == '-') op ^= 1;
		if (ch == EOF) return false;
		for (; isdigit(ch); ch = getchar()) x = x * 10 + (ch ^ '0');
		if (ch != '.') return op ? x = -x : 0, true; else ch = getchar();
		T t = 1;
		for (; isdigit(ch); ch = getchar()) t /= 10, x += (ch ^ '0') * t;
		return op ? x = -x : 0, true;
	}
	inline int reads(char *s){
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar()) ;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) s[n++] = ch;
		return s[n] = '\0', n;
	}
	char pbuf[OUT_BUF], *pp = pbuf;
	struct _flusher{ ~_flusher(){ fwrite(pbuf, 1, pp - pbuf, stdout); } } OutputFlusher;
	inline void my_putchar(char x){
		pp == pbuf + OUT_BUF ? fwrite(pbuf, 1, OUT_BUF, stdout), pp = pbuf : 0, *pp++ = x;
	}
	template<typename T> inline void print_(T x){
		if (x == 0) return putchar('0'), void(0);
		std::vector<int> num;
		for (x < 0 ? putchar('-'), x = -x : 0; x; x /= 10) num.push_back(x % 10);
		while (!num.empty()) putchar(num.back() ^ '0'), num.pop_back();
	}
	template<typename T> inline void print(T x, char ch = '\n'){
		print_(x), putchar(ch);
	}
	inline void prints_(const char *s, int n = -1){
		if (n == -1) n = strlen(s);
		for (register int i = 0; i < n; ++i) putchar(s[i]);
	}
	inline void prints(const char *s, int n = -1, char ch = '\n'){
		prints_(s, n), putchar(ch);
	}
	template<typename T> inline void printd_(T x, int n){
		if (x < 0) x = -x, putchar('-');
		long long a, b;
		for (register int i = 0; i < n; ++i) x *= 10;
		x = (long long)(x + 0.5);
		for (register int i = 0; i < n; ++i) x /= 10;
		a = x, x -= a;
		for (register int i = 0; i < n; ++i) x *= 10;
		b = x;
		print_(a);
		if (n) putchar('.'); else return;
		std::vector<int> num(n);
		for (register int i = 0; i < n; ++i) num[i] = b % 10, b /= 10;
		while (!num.empty()) putchar(num.back() ^ '0'), num.pop_back();
	}
	template<typename T> inline void printd(T x, int n, char ch = '\n'){
		printd_(x, n), putchar(ch);
	}
}
using namespace fastIO;
char s[5];
void solve(){
	reads(s);
	if (s[0] == s[1] && s[1] == s[2]) prints("No");
	else prints("Yes");
}
int main(){
#ifdef AT_HOME
	freopen("test.in", "r", stdin);
	freopen("test.out", "w", stdout);
#endif
	int T = 1;
	// read(T);
	while (T--) solve();
}

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

using namespace std;

int a[26];

int main()
{
    string s; cin>>s;
    for(int i=0;i<s.length();i++)
    {
        a[s[i]-'a']++;
    }
    for(int i=0;i<26;i++)
    {
        if(a[i]%2!=0)
        {
            cout<<"No"; return 0;
        }
    }
    cout<<"Yes";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ps push_back
using namespace std;
const long long inf=9999999999999;
long long dp[52][2502];
struct nex{
    int x,cost,tim;
};
struct node{
    int x, s, t;
    bool operator<(const node& a)const{
        return t>a.t;
    }
};
priority_queue<node>que;
vector<nex>edg[52];
int c[52],d[52];
int book[52][2502];
int main()
{
    int u, v, a, b, s, n, m, i, j, k;
    cin>>n>>m>>s;
    s=min(2500, s);
    nex tmp;
    int ma=0;
    while(m--)
    {
        scanf("%d%d%d%d", &u,&v,&a,&b);
        ma=max(a,ma);
        tmp.x=v,tmp.cost=a,tmp.tim=b;
        edg[u].ps(tmp);
        tmp.x=u;
        edg[v].ps(tmp);
    }
    ma*=n;
    for(int i=1; i<=n; i++)scanf("%d%d", &c[i], &d[i]);
    for(i=0; i<=n; i++)
    {
        for(j=0; j<=2500; j++)
        {
            dp[i][j]=inf;
        }
    }
    dp[1][s]=0;
    node top;
    top.x=1;top.t=0;top.s=s;
    que.push(top);
//    top.x=2;top.t=1;top.s=s;
//    que.push(top);
//    printf("%d\n",que.top().x);
    while(!que.empty())
    {
        top=que.top();
        que.pop();
        int now=top.x, coin=top.s;
//        if(coin<10)printf("now%d coin%d %d\n", now, coin, dp[now][coin]);
        int nc=min(ma, coin+c[now]);
//        if(book[now][coin])continue;
//        book[now][coin]=1;
        if(dp[now][nc]>dp[now][coin]+d[now])
        {
            dp[now][nc]=dp[now][coin]+d[now];
//            if(book[now][nc])printf("%d %d %d\n", now, nc);
//            if(book[now][nc]==0){
            top.x=now,top.s=nc;
            top.t=dp[top.x][top.s];
            que.push(top);
//            }
        }
//        if(i<10)printf("nc%d %d\n", nc, dp[now][nc]);
        nex tmp;
        for(k=0; k<edg[now].size(); k++)
        {
            tmp=edg[now][k];
            j=coin;
//            if(i<10)printf("%d %d\n%d %d\n", now, tmp.x,j-tmp.cost, dp[tmp.x][j-tmp.cost]);


            if(j-tmp.cost>=0 && dp[now][j]+tmp.tim<dp[tmp.x][j-tmp.cost])
            {

                dp[tmp.x][j-tmp.cost]=dp[now][j]+tmp.tim;
//                if(book[tmp.x][j-tmp.cost]==0){
                    top.x=tmp.x;
                    top.s=j-tmp.cost;
                    top.t=dp[top.x][top.s];
                    que.push(top);
//                }
            }
        }

    }
    for(i=2; i<=n; i++)
    {
        long long mi=inf;
        for(j=0; j<=2500; j++)
        {
            mi=min(mi,dp[i][j]);
        }
        printf("%lld\n", mi);
    }
    return 0;
}


Measured memory_bytes: 10556
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1e+9

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

    int N;
    cin >> N;
    vector<ll> A(N), B(N), C(N);
    rep(i, N) { cin >> A[i]; }

    rep(i, N) { cin >> B[i]; }

    rep(i, N) { cin >> C[i]; }

    sort(all(A)), sort(all(B)), sort(all(C));

    ll ans = 0;
    rep(i, N) {
        ll b = B[i];
        ll left = lower_bound(all(A), b) - A.begin();
        ll right = C.end() - upper_bound(all(C), b);
        ans += left * right;
    }

    cout << ans << endl;
}


Measured memory_bytes: 5532
# -*- coding: utf-8 -*-
s = int(input())

a = [s]
for i in range(1000001):
    #print(i)
    if a[i] % 2 == 0:
        a.append(a[i] // 2)
    else:
        a.append(3 * a[i] + 1)
#print(a)
i = 0
flag = True
while flag:
    for j in range(i):
        if a[i] == a[j]:
            ans = i + 1
            flag = False
            break
    i += 1
print(ans)


Measured memory_bytes: 11028
def read_input():
    s = input()
    cs = [c for c in s]

    return cs


def submit():
    cs = read_input()

    for c1,c2 in zip(cs, cs[1:]):
        if c1 == c2:
            print('Bad')
            return

    print('Good')
    return


if __name__ == '__main__':
    submit()


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main() {
  int a;
  int b;
  int c;
  cin >> a;
  b = a / 10;
  c = a - b * 10;
  if(c == 2 || c == 4 || c == 5 || c == 7 || c == 9){
    cout << "hon" << endl;
  }else if(c == 0 || c == 6 || c == 1 || c == 8){
    cout << "pon" << endl;
  }else if(c == 3){
    cout << "bon" << endl;
  }
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
int main()
{
	ll x;
	cin>>x;
	if(x<=599)
		cout<<8<<"\n";
	else if(x<=799)
		cout<<7<<"\n";
	else if(x<=999)
		cout<<6<<"\n";
	else if(x<=1199)
		cout<<5<<"\n";
	else if(x<=1399)
		cout<<4<<"\n";
	else if(x<=1599)
		cout<<3<<"\n";
	else if(x<=1799)
		cout<<2<<"\n";
	else if(x<=1999)
		cout<<1<<"\n";
		
	return 0;
}

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

using namespace std;

int getvalue(char c){
  if(c == 'I'){
	  return 1;
	}else if(c == 'V'){
	  return 5;
	}else if(c == 'X'){
	  return 10;
	}else if(c == 'L'){
	  return 50;
	}else if(c == 'C'){
	  return 100;
	}else if(c == 'D'){
	  return 500;
	}else if(c == 'M'){
	  return 1000;
	}
  return -1;
}

int parseStr(string str){
  int ret=0;
  int now;
  int next;

  for(int i=0;i<str.size();i++){
	now = getvalue(str[i]);
	if(i != str.size() - 1){
	  next = getvalue(str[i+1]);
	}else{
	  next = -1;
	}
	
	if(now >= next){
	  ret += now;
	}else{
	  ret += next - now;
	  i++;
	}
  }
  return ret;
}

int main(void){
  string tmp;

  while(cin >> tmp){
	cout << parseStr(tmp) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
int n;
int ans;

void dfs(long long int a,int b,int c,int d){
  if(a > n) return ;
  if(b && c && d) ans ++;
  dfs(a * 10 + 3, b + 1, c, d);
  dfs(a * 10 + 5, b, c + 1, d);
  dfs(a * 10 + 7, b, c, d + 1);
}

int main()
{
  cin>>n;
  ans = 0;
  dfs((long long int)0, 0, 0, 0);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    A = Scanner.map_int()
    minus = sum([a < 0 for a in A])
    ans = sum([abs(a) for a in A])
    if minus % 2 == 1:
        ans -= min([abs(a) for a in A]) * 2
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 86636
#include<stdio.h>
int main(){
  int a,i,j,n,q,S[1000000],T[50000],c1=0,c2=0;
  int left=0,mid,right,value;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  scanf("%d",&q);
  for(j=0;j<q;j++){
    scanf("%d",&T[j]);
  }
  for(a=0;a<q;a++){
    left=0;
    right=n;
    while(left<=right){
      // value=(left+right) % 2;                                                
      //if(value==0){                                                           
      //mid = (left+right) / 2;}                                                
      //else if(value!=0){                                                      
      mid = (left+right)/2;
      if(S[mid] == T[a]){
        c1++;
        c2++;
        break;
        if(c2>=2){
          c1--;
        }
      }
      else if (S[mid] < T[a]){
        left = mid + 1;
      }
      else{
        right = mid - 1;
      }
    }
  }
  printf("%d\n",c1);
  return 0;
}



Measured memory_bytes: 2444
//ABC 144 B(全探索)



import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		sc.close();

		for(int i=1 ; i<=9 ; i++) {
			for(int j=1; j<=9 ; j++) {
				if(n == i * j) {
					System.out.println("Yes");
					return;
				}
			}
		}

		System.out.println("No");



	}

}


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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef pair<ii, int> ri3;
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
#define SZ(x) (int)(x).size()
#define ALL(x) begin(x), end(x) 
#define REP(i, n) for (int i = 0; i < n; ++i) 
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define RFOR(i, a, b) for (int i = a; i >= b; --i)

const int MX_N = 3005;
const int MX_T = 3005;

int N, T;
ii d[MX_N];
int res[MX_N][MX_T];

int dp(int i, int x) {
    if (i == N || x >= T) return 0;
    if (~res[i][x]) return res[i][x];
    return res[i][x] = max(dp(i+1,x), dp(i+1,x+d[i].fi)+d[i].sc);
}

int main() {
    //freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> N >> T;
    FOR(i,0,N-1){
        int A, B; cin >> A >> B;
        d[i] = ii(A,B);
    }
    sort(d,d+N);
    memset(res,-1,sizeof res);
    cout << dp(0,0) << '\n';
}



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

using namespace std;

long long int N, K, ans = 0;

int main() {
	cin >> N >> K;
	for (int i = K + 1; i <= N; i++) {
		if (N%i == 0) {
			ans += N / i*(i - K);
		}
		else {
			ans += N / i*(i - K) + N%i - min(N%i, max((long long int)0, K - 1));
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
count = 0
for i in range(1, n - 1):
    if p[i - 1] < p[i] < p[i + 1]:
        count += 1
    elif p[i + 1] < p[i] < p[i - 1]:
        count += 1
print(count)


Measured memory_bytes: 2940
import numpy as np

H,W,K = map(int,input().split())
lst = []
for i in range(H):
    s = input()
    lst = np.append(lst,[*s])
lst = lst.reshape(H,W)
#print(lst)  

ans = 0
for h in range(1 << H):
    for w in range(1 << W):
        tmp = lst.copy()
        for hh in range(H):
            for ww in range(W):
                if ((h >> hh) & 1) == 1:
                    tmp[-1-hh,:] = "!"
                if ((w >> ww) & 1) == 1:
                    tmp[:,-1-ww] = "!"    
        #print(tmp)    
        if np.count_nonzero(tmp == "#") == K:
            ans += 1
        #print(ans)    
print(ans)         



Measured memory_bytes: 27052
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define endl "\n"
#define rep(i, a, n) for (int i = a; i < n; ++i)
#define all(x) (x).begin(), (x).end()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x = x2 - x1;
    int y = y2 - y1;
    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;
    return 0;
}


Measured memory_bytes: 3648
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<cstring>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
#include<time.h>
#include<cassert>
#include<functional>
#include<numeric>
#include <tuple>

using namespace std;
using ll = long long;
using ld = long double;
#define int long long
#define all(a) (a).begin(),(a).end()
#define EPS (1e-13)
#define fs first
#define sc second
#define xx first
#define yy second.first
#define zz second.second
#define H pair<int, int>
#define P pair<int, pair<int, int>>
#define Q(i,j,k) mkp(i,mkp(j,k))
#define rep(i,n) for(int (i) = 0 ; (i) < (n) ; (i)++)
#define rng(i,s,n) for(int (i) = (s) ; (i) < (n) ; (i)++)
#define req(i,n) for(int (i) = (n) - 1 ; (i) >= 0 ; (i)--)
#define mkp make_pair
#define mem0(x) memset(x,0,sizeof(x))
#define vec vector
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define crdcomp(b) sort(all((b)));(b).erase(unique(all((b))),(b).end())
#define ssp(i,n) (i==n-1?"\n":" ")
#define ctoi(c) (int)(c-'A')
#define itoc(c) (char)(c+'A')
#define pb push_back
#define cauto const auto&
#define itn int
#define pri_que priority_queue
#define pp(x,y) pb(H{x,y})
#define ppp(x,y,z) pb(Q(x,y,z))
const int mod = 1e9 + 7;
const int Mod = 998244353;
const ll inf = 3 * 1e18;
const int Inf = 15 * 1e8;
template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T & a, const T & b) { if (b < a) { a = b; return 1; } return 0; }
ll read() { ll u, k = scanf(" %lld", &u); return u; }
string reads() { string s; cin >> s; return s; }
ll gcd(ll i, ll j) { return j ? gcd(j, i % j) : i; }
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
ll bitcount(ll x) {
	int sum = 0; for (int i = 0; i < 60; i++)if ((1ll << i) & x) sum++;
	return sum;}
const int fn_ = 600000;
ll fact_[fn_], comp_[fn_];
ll comb(ll x, ll y, ll Mod = mod) {
	if (!fact_[0]) {
		fact_[0] = 1; comp_[0] = 1;
		for (int i = 1; i < fn_; i++) {
			fact_[i] = fact_[i - 1] * i % Mod;
			comp_[i] = mod_pow(fact_[i], Mod - 2, Mod);
		}
	}
	if (x < y) return 0;
	return fact_[x] * comp_[x - y] % Mod * comp_[y] % Mod;
}
//---------------------------------------------------------------
string l;
int dp[200000][2];
//最初の桁、触れているか
signed main() {
	cin >> l;
	dp[0][1] = 2;
	dp[0][0] = 1;
	rng(i, 1, l.size()) {
		if (l[i] == '0') {
			dp[i][1] = dp[i - 1][1];
			dp[i][0] = dp[i - 1][0] * 3;
		}
		else {
			dp[i][1] = dp[i - 1][1] * 2;
			dp[i][0] = dp[i - 1][1] + dp[i - 1][0] * 3;
		}
		dp[i][0] %= mod; dp[i][1] %= mod;
	}
	cout << (dp[l.size() - 1][0] + dp[l.size() - 1][1]) % mod << endl;
}

Measured memory_bytes: 4096
package main

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

func main() {
	N := getStdinInt()
	A := getStdinIntArr()

	var ans float64 = 0
	for i := 0; i < N; i++ {
		ans += 1.0 / (float64)(A[i])
	}

	fmt.Printf("%f\n", 1.0/ans)
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinIntU64() uint64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return uint64(rtn)
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func getStdinIntArrU64() []uint64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]uint64, len(list))
	for idx, val := range list {
		r, _ := strconv.ParseInt(val, 10, 64)
		rtn[idx] = uint64(r)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


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

int main(){
	string week[7] = {"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"};
	int month[12] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int m,d,cnt,mc;

	while( cin >> m >> d ){
		if(m==0) break;

		mc = 1;
		cnt = 3;
		while(1){
			for(int i=1 ; i <= month[mc-1] ; i++, cnt++){
				if(m==mc && d==i) break;
			}
			if(m==mc) break;
			mc++;
		}
		cout << week[cnt%7] << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>
#include <algorithm> 
#include <math.h>
using namespace std;
int a[100001],l[100001],r[100001];
int ab(int x){
	return x>0?x:-x; 
}
int main(){
  int n,i,j,k,m;
  scanf("%d",&n);
  for(i=1;i<=n;i++)scanf("%d",&a[i]);
  l[1]=ab(a[1]);
  r[n]=ab(a[n]);
  for(i=2;i<=n;i++){
l[i]=l[i-1]+ab(a[i]-a[i-1]);

  }
  for(i=n-1;i>=1;i--){
r[i]=r[i+1]+ab(a[i]-a[i+1]);

  }
  for(i=1;i<n;i++){
  	printf("%d\n",l[i-1]+ab(a[i+1]-a[i-1])+r[i+1]);
  }
  printf("%d",l[n-1]+ab(a[n-1]));
  return 0;
}

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

int top, S[1000];
void push(int x) {
	S[++top] = x;
}
int pop(){
	top--;
	return S[top + 1];
}
int main(){
	int a, b;
	top = 0;
	char s[100];
	while(scanf("%s", s) != EOF){
		if(s[0] == '+'){
			a = pop();
			b = pop();
			push(a + b);
		}
		else if(s[0] == '-'){
			b = pop();
			a = pop();
			push(a - b);
		}
		else if(s[0] == '*'){
			a = pop();
			b = pop();
			push(a * b);
		}
		else{
			push(atoi(s));
		}
	}
	printf("%d\n", pop());
	return 0;
}



Measured memory_bytes: 2044
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;

typedef unsigned long long ull;

const int MAX=4001;

vector<int> r, g;
map<int,bool> B_pos;

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    string s;
    while(cin>>n>>s){
        for(int i=0;i<n;i++){
            if(s[i]=='R')r.push_back(i);
            if(s[i]=='G')g.push_back(i);
            if(s[i]=='B')B_pos[i]=true;
        }
        ull result=r.size()*g.size()*B_pos.size();
        for(auto x:r){
            for(auto y:g){
                if(B_pos[2*x-y])result--;
                if(B_pos[2*y-x])result--;
                if((x+y)%2==0 && B_pos[(x+y)/2])result--;
            }
        }
        cout<<result<<endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  int x = 0;
  int k = 1;
  vector<int> a(N);
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  for(int j = 0; j < N ; j++){
    k = a[k-1];
    x++;
    if(k == 2){
      cout << x << endl;
      break;
    }
    else if(j == N-1){
      cout << "-1" << endl;
    }
  }
}
  


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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define all(c) begin(c),end(c)

template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


const int INF = 1 << 29;

auto solve() {
    int N;
    cin>>N;
    vi A(N);
    for (auto &&e: A) cin >> e;

    vll pows(32);
    pows[0] = 1;
    FOR(i, 1, 32) {
        pows[i] = pows[i - 1] * 2;
    }
    reverse(all(pows));

    sort(all(A));
    reverse(all(A));

    map<int, int> nums;
    for (auto &&e: A) nums[e]++;

    int res = 0;
    for (auto &&e: A) {
        if (nums[e] > 0) {
            nums[e]--;
            for (auto &&p: pows) {
                ll u = p - e;
                if (u > 0 && nums[u] > 0) {
                    res++;
                    nums[u]--;
                    break;
                }
            }
        }
    }

    return res;
}


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

    cout << solve() << endl;
//    solve();
    return 0;
}


Measured memory_bytes: 39168
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;

int main(){
    int n;
    cin >> n;
    string name;
    map<string, int> vote;

    for(int i = 0; i < n; i++){
        cin >> name;
        if(vote.count(name)) vote[name]++;
        else vote[name] = 1;
    }

    int maxv = 0;
    for(auto x : vote)
        maxv = max(maxv, x.second);

    for(auto it = vote.begin(); it != vote.end(); it++)
        if(it->second == maxv) cout << it->first << endl;

    return 0;
}

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

int main()
{
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++)
        cin>>a[i];
    ll ph=0;
    ll ans=0;
    for(int i=0;i<n;i++)
    {
        if(a[i]>=ph)
            ph=a[i];
        else
        {
            ans+=(ph-a[i]);
        }
        
    }
    cout<<ans<<endl;
}

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

int D;
long long G;
vector<long long> p, c;

int main() {
  cin >> D >> G;
  p.resize(D); c.resize(D);
  for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];

  long long res = 1<<29;
  for (int bit = 0; bit < (1<<D); ++bit) {
	long long sum = 0;
	long long num = 0;
	for (int i = 0; i < D; ++i) {
	  if (bit & (1<<i)) sum += c[i] + p[i] * 100 * (i+1), num += p[i];
	}
	if (sum >= G) res = min(res, num);
	else {
	  for (int i = D-1; i >= 0; --i) {
		if (bit & (1<<i)) continue;
		for (int j = 0; j < p[i]; ++j) {
		  if (sum >= G) break;
		  sum += 100 * (i+1);
		  ++num;
		}
	  }
	  res = min(res, num);
	}
  }
  cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int ac = 0,wa = 0,tle = 0,re = 0;
    for (int i = 0; i < n; i++) {
        string temp;
        cin >> temp;
        if(temp == "AC") {
            ac++;
            continue;
        }
        if(temp == "WA") {
            wa++;
            continue;
        }
        if(temp == "TLE") {
            tle++;
            continue;
        }
        if(temp == "RE") {
            re++;
            continue;
        }
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
    return 0;
}


Measured memory_bytes: 3660
// ConsoleApplication2.cpp : コンソール アプリケーションのエントリ ポイントを定義します。
//

#include <iostream>
#include <string>

using namespace std;
int main()
{
	string A;
	cin >> A;
	if ("YAKI" == A.substr(0, 4)) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
    return 0;
}



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

using namespace std;

int main(){
    int N;
    while(cin >> N){
        int cnt[7] = {0};
        string in;
        vector<int> a(N),b(N);
        for(int i = 0 ; i < N ; i++){
            cin >> in;
            a[i] = in[0]-'0';
            b[i] = in[1]-'0';
            cnt[a[i]]++;
            cnt[b[i]]++;
        }
        if(N == 1){
            cout << "Yes" << endl;
            continue;
        }
        bool check = false;
        for(int i = 0 ; i < N ; i++){
            if(a[i] == b[i]){
                if(cnt[a[i]] == 2){
                    check = true;
                    break;
                }
            }
        }
        if(check){
            cout << "No" << endl;
            continue;
        }
        int odd = 0,even = 0;
        for(int i = 0 ; i < 7 ; i++){
            if(cnt[i]&1) odd++;
            else even++;
        }
        cout << ((even == 7 || odd == 2) ? "Yes" : "No") << endl;
    }
    return 0;
}

Measured memory_bytes: 1196