akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999999
#define MOD 10007
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> LV;

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


// int find_most_close(LV &v,llong x){
//     auto it = lower_bound(v.begin(),v.end(),x);
//     int idx = it -v.begin();
//     llong s = v[idx] -x;
//     if(idx==0){
//         return idx;
//     }
//     if(s > x - v[idx-1] ){
//         return idx-1;
//     }else{
//         return idx;
//     }
// }

 
int main() {
	llong A,B,Q;
    cin >> A >> B >> Q;
    LV s(A),t(B),x(Q);
    REP(i,A){
        scanf("%lld",&s[i]);
    }
    REP(i,B){
        scanf("%lld",&t[i]);
    }
    REP(i,Q){
        scanf("%lld",&x[i]);
    }

    REP(xi,Q){
        auto it = lower_bound(s.begin(),s.end(),x[xi]);
        int idx = it - s.begin();
        llong sr = s[idx];
        llong sl = (idx > 0) ? s[idx-1] : INF;

        it = lower_bound(t.begin(),t.end(),x[xi]);
        idx = it -t.begin();
        llong tr = t[idx];
        llong tl = (idx > 0) ? t[idx-1] : INF;
        llong cost = INF;
        LV sg{sl,sr};
        LV tg{tl,tr};
        // cout << "sg,tg" << sg[0] <<' '<< sg[1] << " " << tg[0] << " " << tg[1] << endl;
        REP(i,2){
            REP(j,2){
                llong fi = min(abs(x[xi]-tg[i]),abs(x[xi]-sg[j]));
                llong sec = abs( tg[i] - sg[j]  );
                cost = ((fi + sec) < cost) ? (fi + sec) : cost;
            }
        }
        cout << cost << endl;




       
        


    }


    


}


Measured memory_bytes: 3712
/*************************************************************\
~*********************ENJOY THE SILENCE***********************~
\*************************************************************/

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

/*******************Debugging defines*************************/

#define ok_dump() cerr<<"OK\n"
#define var_dump(x) cerr<<#x": "<<x<<'\n'
#define arr_dump(x, n) do{cerr<<#x"[]: ";\
     for(int _=0;_<n;++_) cerr<<x[_]<<" ";cerr<<'\n';}while(0)

/*************************************************************/

int Parent[500000], K[500000], T[500000];
vector<int> G[500000];
int dmax, n;

void DFS(int node) {
	if(G[node].empty()) {
		return;
	}

	int tot = 0;
	vector<int> V;

	for(auto vec : G[node]) {
		DFS(vec);
		V.push_back(K[vec]);
		tot += T[vec] + 1;
	}

	sort(V.begin(), V.end());
	while(V.size() && V.back() >= dmax)
		V.pop_back();

	T[node] = tot - V.size();
	if(V.size() == 0) K[node] = 0;
	else K[node] = V.back() + 1;
}


int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int p;
	cin >> n >> dmax;

	cin >> p;
	int ans = (p != 1);
	for(int i = 2; i <= n; ++i) {
		cin >> Parent[i];
		G[Parent[i]].push_back(i);
	}

	dmax -= 1;

	for(auto vec : G[1]) {
		DFS(vec);
		ans += T[vec];
	}

	//arr_dump(T, n + 1);
	//arr_dump(K, n + 1);

	cout << ans << endl;
}

/*************************************************************\
~*********************ENJOY THE SILENCE***********************~
\*************************************************************/


Measured memory_bytes: 24064
#include <bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int n, k;
	cin >> n >> k;
	map<int, int> mp;
	for(int i = 0; i < n; i++) {
		int x;
		cin >> x;
		mp[x]++;
	}
	vector<int> a;
	for(auto &i : mp) {
		a.push_back(i.second);
	}
	sort(a.rbegin(), a.rend());
	long long ans = 0;
	for(int i = k; i < a.size(); i++) {
		ans += a[i];
	}
	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 10744
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
int a[100005];int n;
int search(int x)
{
	while(a[x+1]==a[x]) x++;
	if(a[x+1]-a[x]>0)
	{
		while(a[x+1]>=a[x]&&x+1<=n) x++;
	}
	else
	{
		while(a[x+1]<=a[x]&&x+1<=n) x++;
	}
	return x;
}
int main()
{
	int i;
	scanf("%d",&n);
	for(i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	int j=1,h=0;
	while(j<=n)
	{
		j=search(j)+1;
		h++;
	}
	cout<<h<<endl;
}

Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

import static java.lang.Integer.parseInt;

/**
 * Pasta
 * JOI 11th, Pre 4
 */
public class Main {

	static final int MOD = 10000;
	static int N;
	static int[] plan;
	static int[][][] memo;

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		line = br.readLine();

		N = parseInt(line.substring(0, line.indexOf(' ')));
		int K = parseInt(line.substring(line.indexOf(' ') + 1));

		plan = new int[N + 1];

		for (int i = 0; i < K; i++) {
			line = br.readLine();
			int A, B;
			A = parseInt(line.substring(0, line.indexOf(' ')));
			B = parseInt(line.substring(line.indexOf(' ') + 1));
			plan[A] = B;
		}

		memo = new int[N + 1][4][3];

		for (int i = 0; i <= N; i++) {
			for (int j = 0; j <= 3; j++) {
				Arrays.fill(memo[i][j], -1);
			}
		}

		int count = solve(0, 0, 0);

		System.out.println(count);

	}

	//d ??\????????£?¶? s ?????????????????? p ????£??????????
	static int solve(int d, int p, int s) {

		if (d == N) return 1;

		if (memo[d][p][s] != -1) return memo[d][p][s];

		int ret = 0;

		if (plan[d + 1] != 0) {
			if (p == plan[d + 1]) {
				if (s == 1) ret = solve(d + 1, plan[d + 1], 2);
			} else {
				ret = solve(d + 1, plan[d + 1], 1);
			}
		} else {
			for (int _p = 1; _p <= 3; _p++) {
				if (_p == p) {
					if (s == 1) ret += solve(d + 1, _p, 2);
				} else {
					ret += solve(d + 1, _p, 1);
				}
			}
		}

		memo[d][p][s] = ret % MOD;

		return memo[d][p][s];
	}
}

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

int main() {
  int a,b,x;
  cin>>a>>b>>x;
  if(a+b<x){
    cout<<"NO"<<endl;
  }
  else if(a>x){
    cout<<"NO"<<endl;
  }
  else{
    cout<<"YES"<<endl;
  }
  
}

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

using namespace std;

using ll = long long;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main () {
  cin.tie(0);
  cout << fixed << setprecision(10);

  int a, p; cin >> a >> p;
  cout << (a * 3 + p) / 2 << endl;
}


Measured memory_bytes: 256
const input=require('fs').readFileSync('/dev/stdin','utf8').split(/[\s]/);const tn=():number=>{const a=input[0];input.shift();return Number(a)};const tnn=(n:number):number[]=>{const a=[];for(let i=0;i<n;i++){a.push(tn())}return a};const ts=():string=>{const a=input[0];input.shift();return String(a)};const tss=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(ts())}return a};const tc=():string=>{let a=input[0].split('');const b=a[0];a.shift();if(a.length>0){input[0]=a.join('')}else{input.shift()}return String(b)};const tcc=(n:number):string[]=>{const a=[];for(let i=0;i<n;i++){a.push(tc())}return a};const to=(...arg)=>{console.log(...arg)};const abs=(a)=>{return Math.abs(a)};const min=(...a)=>{return Math.min(...a)};const max=(...a)=>{return Math.max(...a)};const floor=(a)=>{return Math.floor(a)};const asc=(ar:number[])=>{return ar.sort((a,b)=>{return a-b})};const desc=(ar:number[])=>{return ar.sort((a,b)=>{return b-a})};const sw=(a,arr:any[],op:'=='|'>='|'>'|'<='|'<'='==')=>{for(let i=0;i<arr.length;i+=2){if(eval(a+op+arr[i]))return arr[i+1];}return arr[arr.length-1]};const near=(n:number,arr:number[]):number=>{let ne=arr[0],ni=0;for(let i=1;i<arr.length;i++){if(Math.abs(n-ne)>Math.abs(n-arr[i])){ne=arr[i];ni=i}}return ni};
const main=()=>{
  let [n,t,a]=tnn(3)
  let h=tnn(n)
  let arr=[]
  for(let i=0;i<n;i++){
    arr.push(t-h[i]*0.006)
  }
  to(near(a,arr)+1)
}
main()


Measured memory_bytes: 7500
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Main {
	static int free=0;
	static int[] cl=new int[8];
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		Arrays.fill(cl, 0);
		for(int i=0; i<N; i++) {
			int rate=sc.nextInt();
			if(rate>=3200) {
				free++;
			}
			else {
				cl[rate/400]++;
			}
		}
		int notjiyu=0;
		for(int i=0; i<8; i++) {
			if(cl[i]>0) {
				notjiyu++;
			}
		}
		if(notjiyu>0) {
			pl(notjiyu+" "+(notjiyu+free));
		}
		else if(notjiyu==0) {
			pl(1+" "+free);
		}

	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
}


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

using namespace std;
#define int long long
const int MOD = 1000000007;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int T[2];
    int A[2];
    int B[2];
    cin >> T[0] >> T[1];
    cin >> A[0] >> B[0];
    cin >> A[1] >> B[1];
    int X[2];
    int Y[2];
    for (int i = 0; i < 2; i++) {
        X[i] = T[0] * A[i];
        Y[i] = X[i] + T[1] * B[i];
    }
    if (X[0] > X[1]) {
        swap(X[0], X[1]);
        swap(Y[0], Y[1]);
    }
    if (Y[0] < Y[1]) {
        cout << 0 << endl;
    } else if (Y[0] == Y[1]) {
        cout << "infinity" << endl;
    } else {
        int a = Y[0] - Y[1];
        int b = X[1] - X[0];
        //cerr << b << " " << a << endl;
        int res = 2 * (b / a);
        if (b % a != 0) res++;
        cout << res << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x, y, s;
  while(cin >> x >> y >> s, x || y || s){
    int ret = 0;
    for(int i = 1; i < s; i++){
      for(int j = s - i; j >= i; j--){
        int a = i * (100 + x) / 100;
        int b = j * (100 + x) / 100;
        if(a + b != s) continue;
        ret = max( ret, i * (100 + y) / 100 + j * (100 + y) / 100); 
      }
    }
    cout << ret << endl;
  }

}

Measured memory_bytes: 1160
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect, bisect_left, bisect_right

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
A = LIST()

A.sort(reverse=True)
ans = A[0]
cnt = 1

for x in A[1:]:
    if cnt == N - 1:
        break
    if cnt == N - 2:
        ans += x
        cnt += 1
        # 奇数の場合
    else:
        ans += 2 * x
        cnt += 2
print(ans)

Measured memory_bytes: 33476
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b,c,d; cin >> a>>b;
	if (b >= a)cout << a;
	else cout << a - 1;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAXN 85
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,a[MAXN];
ll dp[MAXN];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    dp[0]=1000;
    for(int i=1;i<=n;i++)
    {
        dp[i]=dp[i-1];
        for(int j=1;j<i;j++)
        {
            if(a[j]<a[i])
            {
                ll cnt=dp[j]/a[j];
                dp[i]=max(dp[i],dp[j]+cnt*(a[i]-a[j]));
            }
        }
    }
    printf("%lld\n",dp[n]);
}

Measured memory_bytes: 3820
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i <= (n); i++)
#define show(a, n) rep(i,n) {cout<<a[i]<<' ';} cout<<endl;

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<long long, long long> pll;

const int INF = 1 << 30;
const long long INFL = 1LL << 62;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100010;

int main() {
	char c;
	cin >> c;
	bool vowel = c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o';
	cout << (vowel ? "vowel" : "consonant") << endl;
}


Measured memory_bytes: 256
/*
 Author:Alokit Kumar
   */
  #include<bits/stdc++.h>
  using namespace std;
  #define int long long 
  int32_t main()
  {
   int n,i,j,k,l;
   cin>>n;
   int a[n+1];
   for(i=1;i<=n;i++) cin>>a[i];
   int dp[n+1];dp[n]=0;
   for(i=n-1;i>=1;i--)
   {
     if(a[i]>=a[i+1])
      dp[i]=dp[i+1]+1;
     else
      dp[i]=0;
   }
   int min1=0;
   for(i=1;i<=n;i++)
    min1=max(min1,dp[i]);
    cout<<min1;
  }

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<char> > c(2 * h, vector<char>(2 * w));
    for (int i = 0; i < h; i++)
	{
        for (int j = 0; j < w; j++)
		{
            cin >> c[i][j];
        }
    }
    vector<vector<int> > l(2 * h, vector<int>(2 * w));
    vector<vector<int> > r(2 * h, vector<int>(2 * w));
    vector<vector<int> > d(2 * h, vector<int>(2 * w));
    vector<vector<int> > u(2 * h, vector<int>(2 * w));
    for (int i = 0; i < h; i++)
	{
        for (int j = 0; j < w; j++)
		{
            if (c[i][j] == '#') l[i][j] = 0;
            else if (j == 0) l[i][j] = 1;
            else l[i][j] = l[i][j-1] + 1;
        }
    }
    for (int i = 0; i < h; i++)
	{
        for (int j = w-1; j >= 0; j--)
		{
            if (c[i][j] == '#') r[i][j] = 0;
            else if (j == w-1) r[i][j] = 1;
            else r[i][j] = r[i][j+1] + 1;
        }
    }
    for (int j = 0; j < w; j++)
	{
        for (int i = 0; i < h; i++)
		{
            if (c[i][j] == '#') u[i][j] = 0;
            else if (i == 0) u[i][j] = 1;
            else u[i][j] = u[i-1][j] + 1;
        }
    }
    for (int j = 0; j < w; j++)
	{
        for (int i = h-1; i >= 0; i--)
		{
            if (c[i][j] == '#') d[i][j] = 0;
            else if (i == h-1) d[i][j] = 1;
            else d[i][j] = d[i+1][j] + 1;
        }
    }
    int max_c = 0;
    for (int i = 0; i < h; i++)
	{
        for (int j = 0; j < w; j++)
		{
            max_c = max(max_c, l[i][j] + r[i][j] +\
			 d[i][j] + u[i][j] - 3);
        }
    }
    cout << max_c;
}

Measured memory_bytes: 266624
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pii B[100005];

int main()
{
	int N, M;
	cin >> N >> M;
	REP(i, M)
	{
		cin >> B[i].first >> B[i].second;
	}
	sort(B, B + M, [](pii a, pii b) {return a.second < b.second; });
	int last = -1;
	int sum = 0;
	REP(i, M)
	{
		if (B[i].first <= last)continue;
		sum++;
		last = B[i].second - 1;
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 1152
#include "vector"
#include "string"
#include "set"
#include "map"
#include "sstream"
#include "algorithm"
#include "cmath"
#include "cassert"
#include "iostream"
#include "numeric"
#include "fstream"
#include "queue"
#include <functional>
#include <climits>
#include <cstring>
#include <ctime>
#include <list>
#include <iomanip>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <complex>
#include <limits>
#include <random>
#include <array>

#define int64 long long int

const int64 M = 1e9 + 7;

void MultL(int64 &a, int64 b) {
    a = (a * b) % M;
}
void AddL(int64 &a, int64 b) {
    a = (a + (b + M)) % M;
}

int64 Mult(int64 a, int64 b) {
    return (a * b) % M;
}
int64 Add(int64 a, int64 b) {
    return (a + (b + M)) % M;
}

using namespace std;

vector<int64> fen;
int64 fen_sum(int r) {
    int64 result = 0;
    for (; r >= 0; r = (r & (r + 1)) - 1) {
        result += fen[r];
    }
    return result;
}
void fen_inc(int i, int64 delta) {
    for (; i < fen.size(); i = (i | (i + 1))) {
        fen[i] += delta;
    }
}
void fen_init(size_t n) {
    fen.assign(n, 0);
}
void fen_init(const vector<int64> &data) {
    fen_init(data.size());
    for (int i = 0; i < data.size(); i++) {
        fen_inc(i, data[i]);
    }
}


int64 gcd (int64 a, int64 b) {
    int64 r;
    while (b != 0){
        r = a % b;
        a = b;
        b = r;
    }
    return a;
}


int main() {

    int n;
    cin >> n;
    vector<int> data(n);
    for (int i = 0; i < n; ++i) cin >> data[i];
    unordered_map<int, int> count1;
    unordered_map<int, int> count2;
    for (int i = 0; i < n; ++i) {
        if (i & 1) {
            ++count1[data[i]];
        }
        else {
            ++count2[data[i]];
        }
    }
    int ma1 = 0;
    int i1 = -1;
    int ma2 = 0;
    int i2 = 0;
    for (auto p : count1) {
        if (p.second > ma1) {
            ma1 = p.second;
            i1 = p.first;
        }
    }
    for (auto p : count1) {
        if (p.first != i1 && p.second > ma2) {
            ma2 = p.second;
            i2 = p.first;
        }
    }

    int ma3 = 0;
    int i3 = -1;
    int ma4 = 0;
    int i4 = 0;
    for (auto p : count2) {
        if (p.second > ma3) {
            ma3 = p.second;
            i3 = p.first;
        }
    }
    for (auto p : count2) {
        if (p.first != i3 && p.second > ma4) {
            ma4 = p.second;
            i4 = p.first;
        }
    }

    if (i1 != i3) {
        cout << n - ma1 - ma3 << endl;
    }
    else {
        cout << n - max(ma1 + ma4, ma3 + ma2) << endl;
    }


    return 0;
}

Measured memory_bytes: 4760
N, M = map(int, input().split())
lst = [input().split() for _ in range(M)]
pe = [0] * N #結果的なWA数
wa = [0] * N #現在のWA数（ACしたら-1）

for l in lst:
    if l[1] == "WA" and wa[int(l[0])-1] != -1:
        #未ACでWA
        wa[int(l[0])-1] += 1
    if l[1] == "AC" and wa[int(l[0])-1] != -1:
        #はじめてAC
        pe[int(l[0])-1] = wa[int(l[0])-1]
        wa[int(l[0])-1] = -1

ans = []
ans.append(str(wa.count(-1)))
ans.append(str(sum(pe)))
print(" ".join(ans))

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

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

  int l=a+b;
  int r=c+d;

  if(l>r){
    cout<<"Left";
  }else if(l==r){
    cout<<"Balanced";
  }else{
    cout<<"Right";
  }

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

int n, k;
ll a[5010];
bool dp[5010][5010];
bool check(int x) {
	dp[0][0] = true;
	REP(i, k) dp[0][i+1]=false;
	REP(i, n) {
		if(i != x) {
			REP(j, k+1) {
				if(j>=a[i]) dp[i+1][j] = (dp[i][j]||dp[i][j-a[i]]);
				else dp[i+1][j] = dp[i][j];
			}
		} else {
			REP(j, k+1) dp[i+1][j] = dp[i][j];
		}
	}
	bool ret = false;
	if(k<a[x]) return true;
	FOR(i, k-a[x], k) ret |= dp[n][i];
	return ret;
}
signed main(void)
{
	cin >> n >> k;
	REP(i, n) cin >> a[i];
	sort(a, a+n);

	int high = n, low = 0;
	while(high-low>1) {
		int mid = (high+low)/2;
		if(check(mid)) {
			high = mid;
		} else {
			low = mid;
		}
	}
	if(check(0)) cout << 0 << endl;
	else cout << high << endl;

	return 0;
}


Measured memory_bytes: 24704
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break

    dataset = []
    for a in range(1, n + 1):
        for b in range(a + 1, n + 1):
            for c in range(b + 1, n + 1):
                dataset.append([a,b,c])

    count = 0
    for data in dataset:
        if sum(data) == x:
            count += 1

    print(count)

Measured memory_bytes: 25476
///
// File:  2321.cpp
// Author: ymiyamoto
//
// Created on Fri Dec 29 10:09:56 2017
//

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

using namespace std;

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

    vector<uint64_t> sats(N + 1, 0);
    vector<uint32_t> dates(N + 1, 0);
    for (uint32_t i = 1; i <= N; i++) {
      uint64_t M, L;
      cin >> M >> L;
      uint32_t date = 0;
      for (uint32_t j = 0; j < M; j++) {
        uint32_t S, E;
        cin >> S >> E;
        for (uint32_t k = S - 6; k < E - 6; k++) {
          date |= 1 << k;
        }
      }
      sats[i] = L;
      dates[i] = date;
    }

    vector<vector<uint64_t>> dp(N + 1, vector<uint64_t>(1 << 16, 0));
    for (uint32_t i = 1; i <= N; i++) {
      for (uint32_t j = 0; j < (1 << 16); j++) {
        dp[i][j] = dp[i - 1][j];
      }
      for (uint32_t j = 0; j < (1 << 16); j++) {
        if ((j & dates[i]) == 0) {
          dp[i][j | dates[i]] = max(dp[i][j | dates[i]], dp[i - 1][j] + sats[i]);
        }
      }
    }

    uint64_t max_val = 0;
    for (auto d : dp[N]) {
      max_val = max(max_val, d);
    }
    cout << max_val << endl;
  }

  return 0;
}

Measured memory_bytes: 55116
n = int(input())

ans = 0
for i in range(1, n+1):
    if i % 3 == 0 and i % 5 == 0:
        pass
    elif i % 3 == 0:
        pass
    elif i % 5 == 0:
        pass
    else:
        ans += i
print(ans)

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

bool HasSuffix(const string& s, const string& t) {
  if (s.size() < t.size()) return false;
  for (int i = 0; i < t.size(); i++) {
    if (s[s.size() - 1 - i] != t[t.size() - 1 - i]) return false;
  }
  return true;
}

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

  string s;
  cin >> s;
  vector<string> words({"dream", "dreamer", "erase", "eraser"});
  while (true) {
    bool b = false;
    for (const auto& word: words) {
      if (HasSuffix(s, word)) {
        // cout << s << " " << word << endl;
        for (int i = 0; i < word.size(); i++) {
          s.pop_back();
        }
        b = true;
        break;
      }
    }
    if (!b) break;
  }

  if (s.empty()) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for (int i = 
#define REVERSE(x) reverse(ALL(x))
#define SORT(x) sort(ALL(x))
#define RSORT(x) sort(ALL(x), greater<>())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SIZE(x) ll((x).size())
#define gcd __gcd
const int INF = 1001001001;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
template <typename T = int> inline T in(){
  T x; cin >> x; return x;}
template <typename T> inline void print(const T& x){
  cout << x << "\n";}
inline int lcm(int a, int b){
  return a / gcd(a, b) * b;}
bool is_prime(int n){
  if (n < 2) return false;
  FOR(i, 2, (int)(sqrt(n) + 1)){
    if (n % i == 0) return false;
  }
  return true;
}
signed main(){
  int x = in();
  while(true){
    if ( is_prime(x) ) {
      print(x);
      break;
    }
    else {
      ++x;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
typedef long long ll; 
using namespace std;
ll h,cnt,ans=1;
ll f(ll a){
    ll p=1;
    for(int i=0;i<=a;i++)
    {
        p*=2;
    }
    p-=2;
    return p;
}
int main(){
    cin>>h;
    if(h==1){
        cout<<ans<<endl;
        return 0;
    }
    else {
        while(1){
            if(h!=1){
                h/=2;
                cnt++;
            }
            else{
                ans+=f(cnt);
                break;
            }
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int mod = 1e9 + 7;
const int maxn = 1e5 + 10;
int fac[maxn];
int  inv[maxn];
int a[maxn];
int  n;
int  add;
int  fin[maxn];
int  id;
long long pow_mod(long long x)
{
    long long res = 1;
    long long n=mod-2;
    while (n)
    {
        if (n & 1)
            res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
int C(int x, int y)
{
    return ((1ll * fac[x] * inv[y] )% mod * inv[x - y] )% mod;
}
void init()
{
    fac[0] = 1;
    fac[1] = 1;
    for (int i = 2; i <= n; i ++)
        fac[i] = (1ll * fac[i - 1] * i) % mod;
    inv[n] = pow_mod(fac[n]);
    for (int i = n - 1; i >= 0; i --)
        inv[i] = 1ll * inv[i + 1] * (i + 1) % mod;
}
void findd()
{
    for (int i = 1; i <= n; i ++)
    {
        if (fin[a[i]]!=0)
        {
            add = i;
            id = a[i];
            return;
        }
        fin[a[i]] = i;
    }
}
int main()
{
    scanf("%d",&n);
    n++;
    for (int i = 1; i <= n; i ++)
        scanf("%d",&a[i]);
        init();
        findd();
    int com=n-add+fin[id]-1;
    for (int i = 1; i <= n; ++i)
    {
        int ans = C(n, i);
        if (i - 1 <= com)
            ans -= C(com, i - 1);
        printf("%d\n",(ans+mod)%mod);
    }
    return 0;
}


Measured memory_bytes: 2816
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;
use num::*;
use num::integer::Roots;

fn main() {
    input! {
    a:String,
    b:String,
    c:String,
    }
    let a=a.chars().collect_vec();
    let b=b.chars().collect_vec();
    let c=c.chars().collect_vec();
    let mut d=0;
    let mut aa=0;
    let mut bb=0;
    let mut cc=0;
    for _ in 0.. {
        if d==0 {
            if a.len()-aa==0 {println!("A");exit(0)}
            if a[aa]=='a' {d=0}
            if a[aa]=='b' {d=1}
            if a[aa]=='c' {d=2}
            aa+=1;
        }
        if d==1 {
            if b.len()-bb==0 {println!("B");exit(0)}
            if b[bb]=='a' {d=0}
            if b[bb]=='b' {d=1}
            if b[bb]=='c' {d=2}
            bb+=1;
        }
        if d==2 {
            if c.len()-cc==0 {println!("C");exit(0)}
            if c[cc]=='a' {d=0}
            if c[cc]=='b' {d=1}
            if c[cc]=='c' {d=2}
            cc+=1;
        }
    }
}

Measured memory_bytes: 2120
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);

	int n;
	int js[];

	void run() {
		while (true) {
			n = sc.nextInt();
			if (n == 0)
				break;
			js = new int[n - 1];
			int sum = 0;
			for (int i = 0; i < n; i++) {
				sum += sc.nextInt();
			}
			for (int i = 0; i < n - 1; i++) {
				sum += js[i] = sc.nextInt();
			}
			Arrays.sort(js);

			long max = sum;
			long jsum = 0;
			for (int i = 0; i < n - 1; i++) {
				jsum += js[i];
				max = Math.max(max, (i + 2) * (sum - jsum));
			}
			System.out.println(max);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 158908
//R<3S
#include <bits/stdc++.h>
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define vecmax(v) max_element(all(v))
#define vecmin(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(x) for(auto i : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);}
#define inset(data,n) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);}
#define ll long long
#define int long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vl vector<ll>
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define mll map<ll,ll>
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


using namespace std;

void solve()
  {

	string s;
	cin>>s;
	if(s=="ABC")cout<<"ARC";
	else cout<<"ABC";

  }



signed main()
{
   FAST
   int t;
   t=1;
   //cin>>t;
   while(t--)
    {
        solve();
    }


   return 0;
}


Measured memory_bytes: 3648
a, b, c, x, y = gets.chomp.split.map(&:to_i)

def main(a, b, c, x, y)
  count_ab = ([x, y].max)*2
  min_price = Float::INFINITY
  (0..count_ab).reverse_each do |c_ab|
    c_a = [x - c_ab.div(2), 0].max
    c_b = [y - c_ab.div(2), 0].max
    price = c_a * a + c_b * b + c_ab * c
    min_price = price if price < min_price
  end
  return min_price
end

puts main(a, b, c, x, y)

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

public class MainClass
{
	public const long Giri = 1000000007;
	public const long DpInf = 99999999999999;
	
	public static void Main(string[] args)
	{
		var s = Console.ReadLine();
		var q = Console.ReadLine().ToInt();
		
		var t = new LinkedList<string>();
		for(int i = 0; i < s.Length; i++)
		{
			t.AddLast(s[i].ToString());
		}
		
		bool normal = true;
		
		for(int i = 0; i < q; i++)
		{
			var p = Input();
			var que = p[0].ToInt();
			if(que == 1)
			{
				normal = !normal;
			}
			else if(que == 2)
			{
				if(p[1].ToInt() == 1)
				{
					if(normal) t.AddFirst(p[2]);
					else t.AddLast(p[2]);
				}
				else
				{
					if(!normal) t.AddFirst(p[2]);
					else t.AddLast(p[2]);
				}
			}
		}
		if(normal)
		{
			Console.WriteLine(string.Join("", t.ToArray()));
		}
		else
		{
			string[] ary = t.ToArray();
			Array.Reverse(ary);
			Console.WriteLine(string.Join("", ary));
		}
	}
	
	static long GCD(long a, long b)
	{
		var v = new[] { a, b };
		while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
		return v[0];
	}
	public static string[] Input() { return Console.ReadLine().Split(); }
}

public static class Smarter
{
	public static int ToInt(this string str) { return int.Parse(str); }
	public static long ToLong(this string str) { return long.Parse(str); }
	public static int[] ToInt(this string[] str, int offset = 0)
	{
		var r = new int[str.Length];
		for(int i = 0; i < str.Length; i++) r[i] = str[i].ToInt() + offset;
		return r;
	}
}


Measured memory_bytes: 40488
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

template<typename T> void cinpb(vector<T>& x) { T n; cin >> n; x.push_back(n); }
ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


// 

int main()
{
	int a, b;
	cin >> a >> b;

	if ( (a * b) % 2 == 0 )
		cout << "No" << endl;
	else
		cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 768
use std::io::{self, BufRead, Write};
use std::collections::BinaryHeap;
use std::ops::Div;

fn solve<R, W>(reader: R, mut writer: W)
where
    R: BufRead,
    W: Write,
{
    let mut lines = reader.lines();
    let line1 = lines.next().unwrap().unwrap();
    let mut splited1 = line1.trim().split_whitespace();
    let _: i32 = splited1.next().unwrap().parse().unwrap();
    let m: i32 = splited1.next().unwrap().parse().unwrap();
    let line2 = lines.next().unwrap().unwrap();
    let mut splited2 = line2.trim().split_whitespace();
    let mut goods = splited2
        .map(|s| s.parse().unwrap())
        .collect::<BinaryHeap<u64>>();

    for _ in 0..m {
        let max = goods.pop().unwrap();
        goods.push(max.div(2));
    }

    let ans: u64 = goods.iter().sum();
    writeln!(&mut writer, "{}", ans).unwrap();
}

fn main() {
    let stdio = io::stdin();
    let input = stdio.lock();

    let output = io::stdout();

    solve(input, output);
}

#[cfg(test)]
mod tests {
    use super::*;

    const TESTS: &'static [(&'static [u8], &'static [u8])] = &[
        (
            br"3 3
2 13 8", br"9
",
        ),
        (
            br"4 4
1 9 3 5", br"6
",
        ),
        (
            br"1 100000
1000000000", br"0
",
        ),
        (
            br"10 1
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000", br"9500000000
",
        ),
    ];

    #[test]
    fn test_d() {
        for &(input, expected) in TESTS {
            let mut output = Vec::new();
            solve(input, &mut output);
            let expected_str = String::from_utf8(expected.to_vec()).unwrap();
            let output_str = String::from_utf8(output).unwrap();
            assert_eq!(expected_str, output_str);
        }
    }
}


Measured memory_bytes: 8444
x1,y1,x2,y2 = map(int, input().split())
xsabun = abs(x2 - x1)
ysabun = abs(y2 -y1)
if x1 < x2 :
    if y1 < y2:
        x3 = x2 - ysabun
        y3 = y2 + xsabun
        x4 = x1 - ysabun
        y4 = y1 + xsabun
    else:
        x3 = x2 + ysabun
        y3 = y2 + xsabun
        x4 = x1 + ysabun
        y4 = y1 + xsabun
else:
    if y1 < y2:
        x3 = x2 - ysabun
        y3 = y2 - xsabun
        x4 = x1 - ysabun
        y4 = y1 - xsabun
    else:
        x3 = x2 + ysabun
        y3 = y2 - xsabun
        x4 = x1 + ysabun
        y4 = y1 - xsabun

print("{0} {1} {2} {3}".format(x3,y3,x4,y4))  

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j;
  for(int testcase = 0;testcase >= 0;testcase++){
    string s; cin >> s;
    string res;
    int cnt = 0;
    per(i, s.size()){
      if(s[i] == 'B')++cnt;
      else{
        if(cnt){
          --cnt;
        }else{
          res += s[i];
        }
      }
    }

    reverse(all(res));
    pri(res);

/*/

//*/ break;
  }
  return 0;
}


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

int main() {
	int a,b,k;
	cin >> a >> b >> k;
	int count = 0;
	for(int i=a;i>0;i--){
		if((a%i==0)&&(b%i==0)){
			count ++;
			if(count == k){
				cout << i << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int func(string s,char X){
  for(int i=0;i<s.size();i++){
    if(X==s.at(i)){
      return 1;
    }
  }
  return 0;
}
int main(){
  string s;
  cin>>s;
  int N=func(s,'N'),W=func(s,'W'),S=func(s,'S'),E=func(s,'E');
  if(N!=S || W!=E)
    cout<<"No";
  else
    cout<<"Yes";
}

Measured memory_bytes: 3624
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll a, b, c;
  cin >> a >> b >> c;
  Pr(b*c>=a);
}


Measured memory_bytes: 3688
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
const int N=100005;

int n,h[N];
int dp[N];

int main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n;
	for (int i=1;i<=n;++i) cin>>h[i];
	dp[2]=abs(h[1]-h[2]);
	for (int i=3;i<=n;++i)
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n]<<'\n';
}

Measured memory_bytes: 1024
import 'dart:convert';
import 'dart:io';
import 'dart:async';

Future main() async {
  var n = int.parse(stdin.readLineSync());
  // readLineSync()を複数行の入力に対して使用すると非常に遅いため、非同期に入力を受ける
  var lines =
      stdin.transform(utf8.decoder).transform(LineSplitter()); // ここ大事（複数行入力）

  List<int> txy = [];
  bool possible = true;
  List<int> prev = [0, 0, 0];
  int diff = 0;
  int dis = 0;
  int count = 0;
  // 非同期に入力しているので。
  await for (var line in lines) {
    txy = line.split(" ").map((x) => int.parse(x)).toList();
    diff = (txy[0] - prev[0]);
    dis = ((txy[1] - prev[1]).abs() + (txy[2] - prev[2]).abs());
    if (diff < dis || diff % 2 != dis % 2) {
      possible = false;
      break;
    }
    prev = [txy[0], txy[1], txy[2]];
    count++;
    possible = true;
    if (count >= n) break;
  }

  if (possible == true) {
    print("Yes");
  } else {
    print("No");
  }
}

Measured memory_bytes: 20656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

ll i,j,k;


int main(){
   ll a,b;
   cin>>a>>b;
   cout<<(a+b)%24<<endl;

   
}

Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
B=[]
for i in range (N):
    if A[i]%2==0:
        B.append(A[i])

x=len(B)
hantei=0
for i in range(x):
    if B[i]%3==0:
        hantei=hantei+1
    elif B[i]%5==0:
        hantei=hantei+1
    else:
        pass

if hantei>=x:
    print('APPROVED')
else:
    print('DENIED')

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod (int)1000000007
#define pb push_back
#define endl "\n"
#define all(a) a.begin(),a.end()
#define mx(a) *max_element(all(a))
#define mn(a) *min_element(all(a))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repo(i,b) for(int i=(int)0;i<b;i++)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

signed solve(){
	int n;
	cin>>n;
	int a[n]={0};
	rep(i,0,n) cin>>a[i];
	int dp[n]={0};
	dp[0]=0,dp[1]=abs(a[0]-a[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(abs(a[i]-a[i-1])+dp[i-1],abs(a[i]-a[i-2])+dp[i-2]);
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

signed main(){
	fast;
	int tests=1;
	// cin>>tests;
	while(tests--){
		solve();
	}
}

Measured memory_bytes: 5196
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
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<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;
int a[100010];
signed main()
{
    int h, n;
    int cnt = 0;
    cin >> h >> n;
    REP(i, n){
        cin >> a[i];
        cnt += a[i];
    }
    if(cnt>=h)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1024
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let s_sub:String = read();
    let s = s_sub.replace("2017","2018");
    println!("{}",s);
}


Measured memory_bytes: 4352