akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    string s;
    cin >> s;

    if(s.length() == 1){
        cout << "YES" << endl;
        return 0;
    }

    int a[3] {};
    rep(i, s.length()){
        if(s[i] == 'a'){
            a[0]++;
        }
        else if(s[i] == 'b'){
            a[1]++;
        }
        else{
            a[2]++;
        }
    }
    
    sort(a, a+3);
    if((a[0]==a[1] && a[1] == a[2]) || (a[0]+1 == a[1] && a[1] == a[2]) || (a[0] == a[1] && a[1]+1 == a[2])){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>

int main(){
	int n;
	int* data;
	int* head;
	scanf("%d",&n);
	head=data=(int*)malloc(sizeof(int)*n);
	for(head--;n>0;n--){
		head++;
		if(n>1)
			scanf("%d ",head);
		else
			scanf("%d",head);
	}
	do{
		printf("%d",*head);
		if(head==data)
			printf("\n");
		else
			printf(" ");
	}while(data!=head--);
	free(data);
	return 0;
}

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

int main(){
  int n;
  cin >>n;
  int num[100100] = {0};
  int M = 0;
  rep(i,n){
    int a; cin >>a;
    a++;
    num[a-1]++; num[a]++;
    num[a+1]++;
    if(a+1>M) M = a+1;
  }
  int ans = 0;
  rep(i,M){
    if(num[i]>ans) ans = num[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
idx=X
cnt_left=0
cnt_right=0
cost_list=[0 for _ in range(N)]
for c in A:
    cost_list[c]=1
    
left=sum(cost_list[:idx])
right=sum(cost_list[idx:])
    
print(min(right,left))

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

#define ll long long

int main(){
    ll a, b;
    string ans;
    cin >> a >> b;
    if(a*b <= 0) ans = "Zero";
    else{
        if(a > 0) ans = "Positive";
        else if((b-a+1)%2 == 0) ans = "Positive";
        else ans = "Negative";
    }
    cout << ans << endl;
    return 0;
}

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

int main(){

	int a[10];
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4] >> a[5] >> a[6] >> a[7] >> a[8] >> a[9];
	int i,j;
	int hensuu;
	for(i=0;i<10;i++){
		for(j=0;j<9;j++){
			if(a[j+1]>a[j]){
				hensuu=a[j+1];
				a[j+1]=a[j];
				a[j]=hensuu;
			}
		}
	}
	cout << a[0] << "\n" << a[1] << "\n" << a[2] << endl;

    return 0;
}

Measured memory_bytes: 1164
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace D
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var NZW = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var N = NZW[0];
            var Y = NZW[2];
            var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();

            if (N == 1) Console.WriteLine(Math.Abs(A[0] - Y));
            else Console.WriteLine(Math.Max(Math.Abs(A[N - 1] - Y), Math.Abs(A[N - 2] - A[N - 1])));
        }
    }
}


Measured memory_bytes: 28772
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include <algorithm>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
int main() {
	int N; cin >> N;
	vector<int> P(N); rep(i, N) { cin >> P[i]; }
	int s = 200000, ans = 0;
	rep(i, N) {
		s = min(s, P[i]);
		if (s >= P[i]) {
			ans++;
		}
	}
	cout << ans << endl;

}




	
	


	


	


		






Measured memory_bytes: 1024
from collections import deque, defaultdict

grid_size = 3

def generate_next_state(q, visited, current_state, zero_pos, dx, dy):
	r = zero_pos // grid_size
	c = zero_pos % grid_size
	next_state = current_state[:]
	next_r = r + dx
	next_c = c + dy
	if next_r < 0 or next_r >= grid_size:
		return None
	if next_c < 0 or next_c >= grid_size:
		return None
	next_state[next_r * grid_size + next_c], next_state[r * grid_size + c] = next_state[r * grid_size + c], next_state[next_r * grid_size + next_c]
	if visited.get(tuple(next_state)) is not None:
		return None
	q.append(next_state)

def bfs(initial_state, goal):
	visited = defaultdict()
	q = deque()
	q.append(initial_state)
	step = 0
	while(len(q) > 0):
		node_count = len(q)
		while(node_count > 0):
			current_state = q.popleft()
			visited[tuple(current_state)] = True
			# print(current_state)
			node_count -= 1
			if current_state == goal:
				print(step)
				return 0
			zero_pos = current_state.index(0)
			generate_next_state(q, visited, current_state, zero_pos, 0, -1)
			generate_next_state(q, visited, current_state, zero_pos, 0, 1)
			generate_next_state(q, visited, current_state, zero_pos, -1, 0)
			generate_next_state(q, visited, current_state, zero_pos, 1, 0)


		step += 1

def init():
	initial_state = []
	goal = [1, 2, 3, 4, 5, 6, 7, 8, 0]
	for i in range(grid_size):
		input_list = input().rstrip().split()
		initial_state.extend([int(val) for val in input_list])
	return initial_state, goal

initial_state, goal = init()
bfs(initial_state, goal)




Measured memory_bytes: 51476
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb(t) push_back(t)
#define pt(num) cout << num << "\n"
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;


int main(void) {
    ll N, K;
    cin >> N >> K;
    
    if(K%2==0) {
        ll s=N/K;
        ll t=N/(K/2)-s;
        pt(s*s*s+t*t*t);
    }else {
        ll t=N/K;
        pt(t*t*t);
    }
    
    
    
    
}


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

int main(){
   unsigned long n;
   cin >> n;
   unsigned long sum = 0;
   for(unsigned long i = 1; i <= n; i++){
     if((i % 3 == 0) || (i % 5 == 0)){
     
     }else{
       sum += i;   
     }
   }
   cout << sum << endl;
}

Measured memory_bytes: 3572
n = int(input())
a = list(map(int,input().split()))

b_l = []
for i in range(0,len(a)):
    b_l.append(a[i] - (i+1))
b_l.sort()
b = b_l[n//2]
ans = 0
for i in range(0,len(a)):
    ans += abs(a[i] - (i+1+b))
print(ans)

Measured memory_bytes: 26708
def solve(s):
    return min(solve_partial(s), solve_partial(s[::-1]))


def solve_partial(s):
    n = len(s)
    cs = [int(c) for c in s]
    res = 0
    for i in range(n - 1):
        if cs[i] == cs[i + 1]:
            cs[i + 1] = int(not cs[i])
            res += 1
    return res


def main():
    s = input()
    res = solve(s)
    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3956
#include<stdio.h>

int n;
int array[50];

int solve(int i,int m){
  int res;
  if(m == 0){
    return 1;
  }
  if(i >= n){
    return 0;
  }
  //総当たりする再帰関数
  res = solve(i+1,m)|| solve(i + 1,m-array[i]);
  return res;
  
}
int main(){
  int q,m,i;

  scanf("%d",&n);
  for(i = 0;i<n;i++){
    scanf("%d",&array[i]);
  }

  scanf("%d",&q);
  for(i = 0;i< q;i++){
    scanf("%d",&m);
  
    if(solve(0,m)){
      printf("yes\n");
    }
    else{
      printf("no\n");
    }
  }
  return 0;
 
  
}



Measured memory_bytes: 2108
head="MARCH"
cnt=[0]*5
n=int(input())
# 頭文字MARCHで始まった人がそれぞれ何人か調べる
for i in range(n):
    s=input()
    for j in range(5):
        if s[0]==head[j]:
            cnt[j]+=1
# 全探索で足し合わせる
ret=0
for i in range(5):
    for j in range(i):
        for k in range(j):
            ret+=cnt[i]*cnt[j]*cnt[k]
print(ret)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){
			
			String[] strs = {
				"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT",
			};
			
			final String S = sc.next();
			for(int i = 0; i < strs.length; i++) {
				if(S.equals(strs[i])) {
					System.out.println(strs.length - i);
					return;
				}
			}
			
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}
		

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 21204
n = int(input())
x = range(n)
P =[]
s = 0
for i in x:P += [[int(i) for i in input().split()]]
P+=[P[0]]
for i in x:s += P[i][0]*P[i+1][1] - P[i][1]*P[i+1][0]
print(s*0.5)

Measured memory_bytes: 7716
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int sum = 100000;
		for(int i = 0; i < n; ++i)
		{
			sum *= 1.05;
			int remainder = sum % 1000;
			if(remainder > 0)
			{
				sum = sum - remainder + 1000;
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 17148
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cout << *it << " = " << a << endl;
	err(++it, args...);
}
 
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
 
#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e4 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
    readb(n, k);
    cout << min((n % k), k - (n % k));
}









Measured memory_bytes: 256
D = gets.to_i
C = gets.chomp.split.map(&:to_i)
s = D.times.map{gets.split.map(&:to_i)}
c = Array.new(26, 0)
t = []

(0..D-1).each do |i|

  (0..25).each do |l|
    c[l] += C[l]
  end
ans = 0
boder = s[i][0]+4*c[0]

  (1..25).each do |e|
    if s[i][e]+4*c[e] >= boder
      ans = e
      boder = s[i][e]+4*c[e]
    end
  end
c[ans] = 0
puts ans+1
end


  



Measured memory_bytes: 14336
n, k = map(int, input().split())
bunshi = 1
a = 1
bunbo = 0
while a < k:
    a *= 2
    bunbo += 1
for i in range(2, n + 1):
    count = 0
    while i < k:
        i *= 2
        count += 1
    bunshi += 2 ** (bunbo - count)
print(bunshi / ((2 ** bunbo) * n))

Measured memory_bytes: 3060
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 100010
int cnt[2][MAXN],n,mx[2],p[2],mn[2];
int a[MAXN],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		cnt[i&1][a[i]]++;
	}
	for(int i=1;i<=100000;i++)
	{
		if(cnt[0][i]>=mx[0])
		{
			mn[0]=mx[0];mx[0]=cnt[0][i],p[0]=i;
		}
		else if(cnt[0][i]>mn[0]) mn[0]=cnt[0][i];
		
		if(cnt[1][i]>=mx[1])
		{
			mn[1]=mx[1];mx[1]=cnt[1][i],p[1]=i;
		}
		else if(cnt[1][i]>mn[1]) mn[1]=cnt[1][i];
	}
	if(p[0]!=p[1])
		ans=n-mx[0]-mx[1];
	else ans=n-max(mx[0]+mn[1],mx[1]+mn[0]);
	printf("%d\n",ans);
}

Measured memory_bytes: 1280
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#include<cstdio>
#define curr(P,i) P[(i)%P.size()]
#define next(P,i) P[(i+1)%P.size()]
#define prev(P,i) P[(i+P.size()-1)%P.size()]


using namespace std;

typedef double Real;

Real EPS = 1e-8;
const Real PI = acos(-1);

int sgn(Real a, Real b=0){return a<b-EPS?-1:a>b+EPS?1:0;}
Real sqr(Real a){return sqrt(max(a,(Real)0));}

struct Point{  
  Real add(Real a, Real b){
    if(abs(a+b) < EPS*(abs(a)+abs(b)))return 0;
    return a+b;
  }

  Real x, y;
  Point(){}
  Point(Real x,Real y) : x(x) , y(y){}

  Point operator + (Point p){return Point(add(x,p.x), add(y,p.y));}
  Point operator - (Point p){return Point(add(x,-p.x), add(y,-p.y));}
  Point operator * (Real d){return Point(x*d,y*d);}
  Point operator / (Real d){return Point(x/d,y/d);}
  bool operator == (Point p){return !sgn(dist(p));}
  bool operator < (Point p){return (p.x!=x)?p.x<x:p.y<y;}
  Real norm(){return sqr(x*x+y*y);}
  Real dist(Point a){return (*this-a).norm();}
  Real dot(Point a){return x*a.x+y*a.y;}
  Real cross(Point a){return x*a.y-y*a.x;}
  //点pを中心に角度r(radius)だけ半時計回りに回転する
  Point rotate(Real r,Point p = Point(0,0)){
    Real ta=cos(r)*(x-p.x)-sin(r)*(y-p.y)+p.x;
    Real tb=sin(r)*(x-p.x)+cos(r)*(y-p.y)+p.y;
    return Point(ta,tb);
  }
  Real arg(){
    if(sgn(x)>0)return atan(y/x);
    if(sgn(x)<0)return atan(y/x)+PI;
    if(sgn(y)>0)return PI/2;
    if(sgn(y)<0)return 3*PI/2;
    return 0;
  }
};

//a -> b -> c
int ccw(Point a, Point b, Point c) {
  b = b-a; c = c-a;

  if (b.cross(c) > 0)   return +1;       // counter clockwise
  if (b.cross(c) < 0)   return -1;       // clockwise
  if (b.dot(c) < 0)     return +2;       // c--a--b on line
  if (b.norm() < c.norm()) return -2;    // a--b--c on line
  return 0;                              // a--c--b on line
}

struct Polygon{
  vector<Point>v;
  
  Polygon(){}
  Polygon(int n){v.resize(n);}
  
  bool isConvex() {
    for (int i=0; i<v.size();i++){
      if (ccw(prev(v,i),curr(v,i),next(v,i))==-1)return false;
    }
    return true;
  }

  Real area(){
    Real area=0;
    for(int i=0;i<v.size();i++)
      area+=(curr(v,i).x-next(v,i).x)*(curr(v,i).y+next(v,i).y);
    return abs(area)/2.0;
  }
};

int main(void){

  int n;
  cin >> n;
  Polygon p(n);

  for(int i=0;i<n;i++)
    cin >> p.v[i].x >> p.v[i].y;

  printf("%.1f",p.area());
  cout << endl;

  return 0;
}

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


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

    if(N == 1){
        cout << 1 << endl;
        return 0;
    }
    
    int ans = 0;
    FOR(i, 1, N){
        while(i < N and S[i-1] == S[i]) ++i;
        ++ans;
    }
    if(N >= 2 and S[N-1] != S[N-2]) ++ans;
    cout << ans << endl;
    
    return 0;
}

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

signed main() {
  int D, T, S;
  cin >> D >> T >> S;

  if (D <= T * S) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep2(i,m,n) for (int i = (int)(m); i < (int)(n); i++)
#define rep(i,n) rep2(i,0,n)
#define all(x) (x).begin(), (x).end()
#define sz size()
#define pb push_back
#define bg begin()
#define ed end()
#define fi first()
#define se second()
using namespace std;
using ll = long long;
using vint = vector<int>;
using pint = pair<int,int>;
using vpint = vector<pint>;
template <typename T>
T sq(T x){
  return x * x;
}
ll mod = 1e9 + 7;

signed main (){
char c[2];
  rep(i,2)
    cin >> c[i];

  rep(i,2){
    if(c[i]=='9'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No"  << endl;
  return 0;
}


Measured memory_bytes: 3512
/*
Author-> Codie_1(Akash)
*/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(n) for(int i=0;i<n;i++)
#define repi(n) for(int i=0;i<n;i++)
#define repj(n) for(int j=0;j<n;j++)
#define repp(n) for(int i=0;i<=n;i++)
#define repab(a,b) for(int i=a;i<b;i++)
#define w(t) int t; cin>>t; while(t--)
#define endl '\n'
#define pi pair<int, int> p
#define pis pair<int, string> p
#define ff first
#define ss second
#define pb push_back
#define mk make_pair
#define vi vector<int> v
#define vl vector<long long> v;
typedef long long ll;

 

int main()
{
	char ch;
	cin>>ch;
	int i=(int)ch+1;
	cout<<(char)i;
	return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
int main(void){
    int n;
    int a[100000+5];
    scanf("%d", &n);
    for(int i=1; i<=n; i++){
        int n;
        scanf("%d", &n);
        a[n]=i;
    }
    for(int i=1; i<=n; i++){
        printf("%d", a[i]);
        if(i!=n)printf(" ");
    }
}


Measured memory_bytes: 2076
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>

#define rep(a,i,n) for(int i = (a) ; i< (n);i++)
#define ic(n) int (n); cin>>(n);
#define SORT(a) sort((a).begin(),(a).end());
#define che(a,string) cout<<string<<":"<<(a)<<endl;
#define ch(a,string) cout<<string<<":"<<(a)<<" ";
using namespace std;



typedef pair<int,int> P;




int main(){

  ic(n);ic(m);	vector<tuple<long long,long long,long long>> M(m);
  rep(0,i,m){
	ic(where);ic(when);
	M[i] = make_tuple(where,when,i+1);;
  }
  long long a, b ;
  long long c;
  SORT(M);
  vector<pair<long long,long long>> A(m);
  long long x,y;
  long long count = 1;
  long long p=0;
  rep(0,i,m){
	tie(x,y,a) =M[i];
	if(x==p){
	  count++;
	}
	else if(x!=p){
	  count=1;
	  p=x;
	}
	x*=pow(10,6);
	c = x+count;
	A[i] = make_pair(a,c);
  }
  SORT(A);
  rep(0,i,m){
	long long id;
	tie(ignore,id) = A[i];
	printf("%012lld\n",id);
  }
}

Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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



int main(int argc, const char * argv[]) {
    
    
    
    
    int n; cin >> n;
    vector<double> value(n);
    rep(i,n) cin >> value[i];
    
    sort(value.begin(), value.end());
    
    double Ans = (value[0] + value[1])/2;
    
    for (int i = 2; i < n; i++) Ans = (Ans + value[i])/2;
    
    cout << Ans << endl;
    
    return 0;
    
    

    
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int n;
  scanf("%d",&n);
  for(int i=9;i>=1;i--){
	if(n%i==0){
      if(n/i>=1&&n/i<=9){
        printf("Yes");
        return 0;
      }
    }
  }
  printf("No");
  return 0;
}

Measured memory_bytes: 128
def shift_l(str)
  str[1..-1] + str[0]
end

def cycle(str)
  str.size.pred.times.reduce([str]) { |a| a << shift_l(a.last) }
end

s = gets.strip
t = gets.strip
b = cycle(s).any? { |str| str == t }
puts b ? 'Yes' : 'No'


Measured memory_bytes: 1788
n = int(input())
ans = 0
for i in range(1, int(n**0.5) + 1):
    if n % i == 0:
        j = n // i
        # print(i, j)
        if j < i-1:
            ans += i-i
            # print("p", i-1)
        if i < j-1:
            ans += j-1
            # print("p", j-1)

print(ans)

Measured memory_bytes: 40172
#include<bits/stdc++.h>
using namespace std;
constexpr int mod = 1e9 +7;
constexpr int MAXNe6 = 1e6 + 7;
#pragma region 
inline long long read()
{
	char c = getchar();long long flag = 1, ans = 0;
	while(c < '0' || c > '9'){if(c == '-')flag = -1; c = getchar();}
	while(c >= '0' && c <= '9'){ans = ans * 10 + c - '0'; c = getchar();}
	return (ans * flag);
}
#pragma endregion
// C'est la vie
int main() {
    long long h = read();
    int deepth = floor(log2(h)) + 1;
    long long ans = pow(2, deepth) - 1;
    cout << ans << endl;
    #ifndef ONLINE_JUDGE
    system("pause");
    #endif
}

Measured memory_bytes: 512
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;


signed main(){

	int A, B, K;
	cin >> A >> B >> K;

	int k = 0;
	int i;
	for ( i = 100; i >= 1; i--){
		if (A%i == 0 && B%i == 0){
			k++;
			if (k == K) break;
		}
	}
	cout << i << endl;


	return 0;
}

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

int main()
{
	string s,t,ans="";
	bool found=false;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	for(int i=0;i<=n-m;i++)
	{
		string ss=s;
		bool ok=true;
		for(int j=0;j<m;j++)
		{
			if(ss[i+j]=='?')
				ss[i+j]=t[j];
			else if(ss[i+j]!=t[j])
			{
				ok=false;
				break;
			}
		}
		if(ok)
		{
			for(int j=0;j<n;j++)
				if(ss[j]=='?')
					ss[j]='a';
			if(found)
			{
				if(ss<ans)
					ans=ss;
			}
			else
			{
				ans=ss;
				found=true;
			}
		}		
	}
	if(found)
		cout<<ans;
	else
		cout<<"UNRESTORABLE";
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<cmath>
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=j;i<=k;i++)

using namespace std;

typedef pair<int,int> pii;

int main(){
	int n,d,m,s[100002],k[10000];
	for(;;){
		scanf("%d",&d);
		if(d==0)break;
		scanf("%d%d",&n,&m);
		s[0]=0;
		rep(i,n-1)scanf("%d",s+i+1);
		rep(i,m)scanf("%d",k+i);
		sort(s,s+n);
		s[n]=d;
		s[n+1]=d+1;
		sort(k,k+m);
		int cnt=0,p=0,t=2000000000,temp;
		rep(i,m){
			temp=t;
			for(;p<n+2;p++){
				int x=abs(k[i]-s[p]);
				if(temp>x)temp=x;
				if(temp!=x){
					cnt += temp;
					p--;
					break;
				}
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

Measured memory_bytes: 1472
# -*- coding: utf-8 -*-
N,A,B,C,D = map(int,input().split())

pencilsX = 0
ansX = 0
while True:
    pencilsX += A
    ansX += B
    if pencilsX >= N:
        break

pencilsY = 0
ansY = 0
while True:
    pencilsY += C
    ansY += D
    if pencilsY >= N:
        break

print(min(ansX, ansY))



Measured memory_bytes: 5600
import java.util.*;
class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  int k=sc.nextInt();
  int a[]=new int[n];
  for(int i=0;i<n;i++){
    a[i]=sc.nextInt();
    if(i>=k){
    	System.out.println((a[i]>a[i-k])?"Yes":"No");
    }
  }
}

}

Measured memory_bytes: 60700
#include<cstdio>
#include<stack>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
	char s[200001];
	scanf("%s",s);
	int l = strlen(s);
	int cnt = 0;
	stack<char> st;
	for(int i=0;i<l;i++){
		if(s[i]=='S') st.push('S');
		else{
			if(!st.empty()&&st.top()=='S'){
				st.pop();
				cnt++;
			}else{
				st.push('T');
			}
		}
	}
	printf("%d\n",l-2*cnt);
}


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

// macros
#define overload_rep(_1, _2 ,_3 ,name, ...) name
#define re_p(i, n) for(int i = 0; i < (n); ++i)
#define r_ep(i, x, y) for(int i = (x); i <= (y); ++i)
#define rep(...) overload_rep(__VA_ARGS__, r_ep, re_p)(__VA_ARGS__)
#define all(a) a.begin(), a.end()
#ifndef STOP_DEBUG
#define debug(...)\
    do { cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_cerr(__VA_ARGS__); cerr << noboolalpha; } while (0)
#else
#define debug(...)
#endif

// functions
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
void debug_cerr(){ cerr << '\n'; }
template<class Head, class... Tail>
void debug_cerr(Head head, Tail... tail){
    cerr << ' ' << head;
    debug_cerr(tail...);
}

// cin/cout setup
struct IoSetup{
    IoSetup(){
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

// AtCoder Beginner Contest 143
int main(){

    int a, b;
    cin >> a >> b;
    cout << max(0, a - 2 * b) << endl;

}

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

int main(){
	ll q,ans=0;cin>>q;
	priority_queue<ll> s;
	priority_queue<ll,vector<ll>,greater<>> l;
	for(ll _=0;_<q;++_){
		ll t;cin>>t;
		if(t==1){
			ll a,b;cin>>a>>b;
			ans+=b;
			s.push(a);l.push(a);
			ll x=s.top();s.pop();
			ll y=l.top();l.pop();
			if(x>y){
				ans+=x-y;
				swap(x,y);
			}
			s.push(x);
			l.push(y);
		}
		else{
			cout<<s.top()<<" "<<ans<<endl;
		}
	}
}


Measured memory_bytes: 4588
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 10000000000000000
#define MOD 1000000007
using namespace std;




int main(){
    int N,M;
    cin >> N >> M;
    
    int p[N];
    for(int i=0; i<N; i++){
        cin >> p[i];
        p[i]--;
    }
    
    pair<int, int> xy[M];
    for(int i=0; i<M; i++){
        cin >> xy[i].first >> xy[i].second;
        xy[i].first--;
        xy[i].second--;
        if(xy[i].second<xy[i].first){
            swap(xy[i].first,xy[i].second);
        }
    }
    
    sort(xy,xy+M);
    
    int group[N];
    for(int i=0; i<N; i++){
        group[i]=-1;
    }
 

    
    queue<int> q[N];
    for(int i=0; i<M; i++){
        q[xy[i].first].push(xy[i].second);
        q[xy[i].second].push(xy[i].first);
    }
    
    int checked[N]={};
    

    
    for(int i=0; i<N; i++){
        if(checked[i]==1){continue;}
        
        if(group[i]==-1){
            group[i]=i;
        }
        
        checked[i]=1;
        
        
        queue<int> q_tansaku;
        while(!q[i].empty()){
            q_tansaku.push(q[i].front());
            q[i].pop();
        }
        
        while(!q_tansaku.empty()){
            if(checked[q_tansaku.front()]){
                q_tansaku.pop();
            }else{
                group[q_tansaku.front()]=i;
                checked[q_tansaku.front()]=1;
                while(!q[q_tansaku.front()].empty()){
                    q_tansaku.push(q[q_tansaku.front()].front());
                    q[q_tansaku.front()].pop();
                }
                q_tansaku.pop();
            }
            
        }
        
    }
    
    
    
    
    int ans=0;
    for(int i=0; i<N; i++){
        if(group[p[i]]==group[i]){
            ans++;
        }
     //   cout<<group[i]<<endl;
    }
    
    
    
    cout<<ans<<endl;
    
    return 0;
}




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

int main(){
  string s;
  cin >> s;
  int p;
  p = 0;
  if(s[0] == 'o') p += 100;
  if(s[1] == 'o') p += 100;
  if(s[2] == 'o') p += 100;
  cout << 700 + p << endl;
} 


 
 
    

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a,b,max,i;
scanf("%d",&a);
  b=0;
  max=0;
int l[a];
  for(i=0;i<a;++i)
  {
  scanf("%d",&l[i]);
  b=b+l[i];
  if(l[i]>max) max=l[i];
  }
  
  if(max*2<b) printf("Yes");
  else printf("No");

return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		Long H = sc.nextLong();
		Long W = sc.nextLong();
		if (H%3==0||W%3==0) {
			System.out.println(0);
			return ;
		}
		long min = H>W?W:H;
		for (int i=1;i<W;i++) {
			long A = H*i;
			long B = (W-i)*(H/2);
			long C = (W-i)*(H/2+H%2);
			long temp = Math.abs(A-B);
			if (C-B>temp) {
				temp = C-B;
			}
			if (Math.abs(A-C)>temp) {
				temp = Math.abs(A-C);
			}
			if (min>temp) {
				min = temp;
			}
		}
		for (int i=1;i<H;i++) {
			long A = W*i;
			long B = (H-i)*(W/2);
			long C = (H-i)*(W/2+W%2);
			long temp = Math.abs(A-B);
			if (C-B>temp) {
				temp = C-B;
			}
			if (Math.abs(A-C)>temp) {
				temp = Math.abs(A-C);
			}
			if (min>temp) {
				min = temp;
			}
		}
		System.out.println(min);
	}
}

Measured memory_bytes: 23892
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<list>
#include<set>
using namespace std;
int gcd(int a, int b) {
	int c = a % b;
	while (c != 0) {
		a = b;
		b = c;
		c = a % b;
	}
	return b;
}
struct UnionFind {
	vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

	UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
		for (int i = 0; i < N; i++) par[i] = i;
	}

	int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
		if (par[x] == x) return x;
		return par[x] = root(par[x]);
	}

	void unite(int x, int y) { // xとyの木を併合
		int rx = root(x); //xの根をrx
		int ry = root(y); //yの根をry
		if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
		par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
	}

	bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
		int rx = root(x);
		int ry = root(y);
		return rx == ry;
	}
};
typedef long long ll;

const ll M = 1000000007;

vector<ll> fac(300001); //n!(mod M)
vector<ll> ifac(300001); //k!^{M-2} (mod M)
//a,bの範囲的にこれだけ配列を用意していけば十分

ll mpow(ll x, ll n) { //x^n(mod M) ←普通にpow(x,n)では溢れてしまうため，随時mod計算
	ll ans = 1;
	while (n != 0) {
		if (n & 1) ans = ans * x % M;
		x = x * x % M;
		n = n >> 1;
	}
	return ans;
}

ll comb(ll a, ll b) { //aCbをmod計算
	if (a == 0 && b == 0)return 1;
	if (a < b || a < 0)return 0;
	ll tmp = ifac[a - b] * ifac[b] % M;
	return tmp * fac[a] % M;
}
int main() {
	int n, i, j, k, ans = 0,flag;
	char s[333][333];
	cin >> n;
	for (i = 0; i < n; i++)
		cin >> s[i];
	for (k = 0; k < n; k++) {
		flag = 1;
		for (i = 0; i < n; i++)
			for (j = 0; j < n; j++)
				if (s[i][(j+k)%n] != s[j][(i + k) % n])
					flag = 0;
		if (flag == 1)
			ans += n;
	}
	cout << ans << endl;
}


Measured memory_bytes: 5120
#include <iostream>
#include <fstream>

#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
using namespace std;

using ll = long long;
using pii = pair<int, int>;

#define pb push_back
#define mp make_pair

#define NMAX 200100

char s[NMAX];

int main()
{
    ios::sync_with_stdio(false), cin.tie(0);
    // cout.setf(ios::fixed), cout.precision(20);

#ifdef LOCAL
    ifstream cin("input.txt");
#endif

    int n;
    cin >> n;
    cin >> (s + 1);

    int st = 1, dr = n, cost = 0;
    while (st < dr) {
        if (s[st] == 'R') {
            st++;
            continue;
        }
        if (s[dr] == 'W') {
            dr--;
            continue;
        }
        cost++;
        st++;
        dr--;
    }
    cout << cost << '\n';
    return 0;
}

Measured memory_bytes: 3392
// D - RGB Triplets
#include <bits/stdc++.h>
using namespace std;
long long ng,r,g,b;

int main(){
	int N; string S; cin>>N>>S;
	for(int i=0; i<N; i++){
		if(S[i]=='R') r++; else if(S[i]=='G') g++; else b++;
		for(int j=i+1,k=i+2; k<N; k+=2,j++)
			if((S[i]^S[j]^S[k]) == ('R'^'G'^'B')) ng++;
	}
	cout<< r*g*b - ng <<endl;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
#define ii pair<int,int>
#define ll long long

using namespace std;

int main(){
    priority_queue<int>pq;
    int n,m;
    cin>>n>>m;
    for(int i =0;i<n;i++){
        int x;cin>>x;
        pq.push(x);
    }
    while(m--){
        int x = pq.top();
        pq.pop();
        pq.push(x/2);
    }
    ll ans = 0;
    while(n--){
        ans += pq.top();
        pq.pop();
    }
    cout<<ans;
}
/*
 * 1 3 5 9
 * 1 3 4 5
 * 1 2 3 4
 * 1 2 2 3
 */

Measured memory_bytes: 892
using System;

namespace ABC_055_A_Csharp_ver
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int n = 0;
            if (N < 15)
            {
                Console.WriteLine(N * 800);
            }
            else if (N >= 15 && N < 30)
            {
                Console.WriteLine(N * 800 - 200);
            }
            else if (N >= 30 && N < 45)
            {
                Console.WriteLine(N * 800 - 400);
            }
            else if (N >= 45 && N < 60)
            {
                Console.WriteLine(N * 800 - 600);
            }
            else if (N >= 60 && N < 75)
            {
                Console.WriteLine(N * 800 - 800);
            }
            else if (N >= 75 && N < 90)
            {
                Console.WriteLine(N * 800 - 1000);
            }
            else if (N >= 90)
            {
                Console.WriteLine(N * 800 - 1200);
            }
            Console.ReadKey();
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

struct Cake{
    int w;
    int d;
    int cnt;
    Cake(int w, int d, int cnt) : w(w), d(d), cnt(cnt) {}
    bool operator< (const Cake& a) const{
        return (cnt == a.cnt ? w*d < a.w*a.d : cnt < a.cnt);
    }
};

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

    while(1){
        int n, w, d;
        cin >> n >> w >> d;
        if(!n && !w && !d) break;
        vector<Cake> cake;
        cake.pb(Cake(w, d, 0));
        REP(i, n){
            int p, s;
            cin >> p >> s;
            p--;
            Cake now = cake[p];
            cake[p].cnt = INF;
            now.cnt = i;
            Cake next = now;
            s %= (now.w + now.d);
            if(s <= now.w){
                now.w = s;
                next.w = next.w-s;
            }else{
                now.d = s - now.w;
                next.d = next.w + next.d - s;
            }
            cake.pb(now);
            cake.pb(next);
            sort(all(cake));
        }
        vector<int> ans;
        REP(i, cake.size()) if(cake[i].cnt != INF) ans.pb(cake[i].d * cake[i].w);
        sort(all(ans));
        REP(i, n+1) cout << ans[i] << " \n"[i == n];
    }
}



Measured memory_bytes: 3044
N = int(input())
S = input()

colors = ['R', 'G', 'B']
thirds = {'RG': 'B', 'GR': 'B', 'BR': 'G', 'RB': 'G', 'BG': 'R', 'GB': 'R'}
accs = {color: [] for color in colors}
nums = {color: 0 for color in colors}
sums = {color: len([s for s in S if s == color]) for color in colors}
for i in range(N):
    nums[S[i]] += 1
    for color in colors:
        accs[color].append(sums[color] - nums[color])
        
res = 0
for i in range(N-2):
    first = S[i]
    for j in range(i+1, N-1):
        second = S[j]
        if first == second:
            continue
        third = thirds[first+second]
        res += accs[third][j]
        if 2 *j - i < N and S[2*j - i] == third:
            res -= 1
                
print(res)

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

template<typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

const long long mod = 998244353;
int main() {
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; cin >> n;
	vector<int> a(n); cin >> a;
	map<int, int> m;
	for (int x : a) m[x]++;
	if (m[0] != 1 || a[0] != 0) {
		cout << "0\n";
		return 0;
	}
	int mx = *max_element(a.begin(), a.end());
	long long ans = 1;
	for (int i = 1; i <= mx; i++) {
		long long res = 1;
		for (int j = 0; j < m[i]; j++) {
			res *= m[i - 1];
			res %= mod;
		}
		ans *= res;
		ans %= mod;
	}
	cout << ans << '\n';
}


Measured memory_bytes: 8308
import sys
input = sys.stdin.readline

def main():
    N, A, B = map(int, input().split())
    v = sorted(list(map(int, input().split())), reverse=True)

    kai = [1] * (N+1)

    for i in range(1, N+1):
        kai[i] = i * kai[i-1]

    ans1 = sum(v[:A]) / A

    dic = {}
    for t in v:
        if t in dic:
            dic[t] += 1
        else:
            dic[t] = 1
    
    dic = sorted(dic.items(), reverse=True)
    # print(dic)
    tmp = 0
    for i in range(N):
        tmp += dic[i][1]
        if tmp >= A:
            ind = i
            must = A - (tmp - dic[i][1])
            max_ = min(B, tmp) - (tmp - dic[i][1])
            break
    n = dic[ind][1]
    if ind == 0:
        ans2 = 0
        # nCA ~ nCmax_
        for i in range(A, max_+1):
            ans2 += (kai[n] // kai[n - i]) // kai[i]
    else:
        # nCmust
        ans2 = (kai[n] // kai[n - must]) // kai[must]
    
    print(ans1)
    print(ans2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
a=int(input())
b=[list(map(int,input().split())) for i in range(a)]

n=[]
for i in b:
    if i[0]==i[1]:
        n.append(1)
        continue
    n.append(0)
for i in range(a-2):
    if n[i]==1 and n[i+1]==1 and n[i+2]==1:
        print('Yes')
        exit()
print('No')

Measured memory_bytes: 9132
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

typedef long long ll;

int main() {
    int N;
    ll S;
    ll Min = 1000000;
    cin >> N;
    vector<int>a(N);

    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }

    for (int i = -100; i <= 100; i++) {
        S = 0;
        for (int k = 0; k < N; k++) {
            S += pow((a[k]-i), 2);    
        }
        if (Min > S) {
            Min = S;
        }
    }

    cout << Min << endl;
}


Measured memory_bytes: 256
# include <iostream>

struct heya {
	int n;
	int operator =(int x) {
		n = x;
		return n;
	}
	heya() {
		n = 0;
	}
};

struct kai {
	heya h[10];
};

struct tatemono {
	kai k[3];
};



int main() {
	int n;
	std::cin >> n;
	tatemono t[4];

	for (int i = 0; i < n; i++) {
		int b, f, r, v;
		std::cin >> b >> f >> r >> v;
		t[b - 1].k[f - 1].h[r-1].n += v;
	}

	for (int tate = 0; tate < 4; tate++) {
		for (int kai = 0; kai < 3; kai++) {
			for (int he = 0; he < 10; he++) {
				std::cout << " "<<  t[tate].k[kai].h[he].n;
			}		
			std::cout << std::endl;
		}
		if( tate != 3)
			std::cout << "####################" << std::endl;
	}

	return 0;
}

Measured memory_bytes: 3076
N, M, X, Y = map(int, input().split())
x_list = sorted([int(i) for i in input().split()])
y_list = sorted([int(i) for i in input().split()])

x = x_list[-1]
y = y_list[0]
if x < y and any([X < z <= Y for z in range(x+1, y+1)]):
    print('No War')
else:
    print('War')


Measured memory_bytes: 3060
S = input()


if (S.count("W") != 0 and S.count("E") != 0) and (S.count("N") == 0 and S.count("S") == 0):
    print("Yes")
elif (S.count("N") != 0 and S.count("S") != 0) and (S.count("W") == 0 and S.count("E") == 0):
    print("Yes")
elif S.count("N") != 0 and S.count("S") != 0 and S.count("W") != 0 and S.count("E") != 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 2e9+7
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int mxN=100100;

int main () {
    ios::sync_with_stdio(false); cin.tie(0);
    ll n,k; cin>>n>>k;
    if(n%k==0) cout<<"0"<<endl;
    else {
        cout<<min(n%k,k-(n%k))<<endl;
    }
}



Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
#include<functional>
#include<queue>
#define INF 999999

using namespace std;

int bind(int a[], int k)
{
	int i = 1;
	int j = 0;
	int b=0;
	while (j < k) {
		b += a[j] * i;
		if(a[j]<10)i *= 10;
		else i *= 100;
		j++;
	}
	return b;
}

int main()
{
	int p = 0;
	int b[5];
	while (1) {
		int n, k;
		cin >> n >> k;
		if (n == 0 && k == 0) {
			break;
		}

		vector<int> card;
		for (int i = 0; i < n; i++) {
			int a;
			cin >> a;
			card.push_back(a);
		}

		set<int> s;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				for (int l = 0; l < n; l++) {
					for (int m = 0; m < n; m++) {
						if (i != j&&i != l&&i != m&&j != l&&j != m&&l != m) {
							int b[4] = { card[i],card[j],card[l],card[m] };
							int c = bind(b, k);
							s.insert(c);
						}
					}
				}
			}
		}
		b[p] = s.size();
		p++;
	}
	for (int i = 0; i < p; i++) {
		cout << b[i] << endl;
	}
	return 0;

}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> p(m);
  vector<string> s(m);
  int ans=0;
  vector<int> cnt(n+1);
  int pen=0;
  for(int i=0;i<m;i++){
    cin >> p.at(i) >> s.at(i);
  }
  vector<int> a(n+1);
  for(int i=0;i<m;i++){
    if(s.at(i)=="AC"){
        a.at(p.at(i))=1;
    }else if(s.at(i)=="WA"&&a.at(p.at(i))==0){
        cnt.at(p.at(i))+=1;
    }
  }
  for(int i=0;i<n+1;i++){
    ans+=a.at(i);
  }
  for(int i=0;i<n+1;i++){
    if(a.at(i)==1){
     pen+=cnt.at(i);
    }
  }
  cout << ans << " " << pen << endl;
}

Measured memory_bytes: 6912
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

int main(){
  ll a,b,c;
  cin >> a >> b >> c;
  cout << a * b / 2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <list>
#include <cmath>
#include <cassert>
#include <deque>
#include <iostream>
#include <vector>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>

using namespace std;

typedef int64_t ll;
typedef long double ld;
typedef pair<int, int> pii;

const int SZ = 1000000 + 100;

ll n, k;

int solve() {
    ll ans;
    cin >> n >> k;
    if (n >= 10) {
        ans = k;
    } else {
        ans = k + 1000 - 100 * n;
    }
    cout << ans << endl;

    return 0;
}

int main() {
    ios_base::sync_with_stdio(false);

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

    solve();

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;
struct Edge {
	ll to;
 	ll cost;
 };
using Graph = vector<vector<Edge>>;

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(a) (a).begin(), (a).end()
/***** define constant start *******/
const ll MOD = 1000000007;
const double PI = 2.0 * asin(1.0);
const ll INF = 1L<<60;
string abc = "abcdefghijklmnopqrstuvwxyz";
string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const ll MAX = 10000000;
/****** define constant end ********/
/****** define variable start ******/
ll n, m, s, t;
vl u, v, a, b;
/******* define variable end *******/
typedef pair<ll, ll> P;
vector<ll> d1;
void dijkstra(Graph G, ll s){
	std::priority_queue<P, std::vector<P>, std::greater<P>> que;
	for(int i = 0; i < n; i++) d1[i] = INF;
	d1[s] = 0;
	que.push(P(0, s));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d1[v] < p.first) continue;
		for(int i = 0; i < G[v].size(); i++){
			Edge e = G[v][i];
			if(d1[e.to] > d1[v] + e.cost){
				d1[e.to] = d1[v] + e.cost;
				que.push(P(d1[e.to], e.to));
			}
		}
	}
}
vector<ll> d2;
void dijkstra2(Graph G2, ll s){
	std::priority_queue<P, std::vector<P>, std::greater<P>> que;
	for(int i = 0; i < n; i++) d2[i] = INF;
	d2[s] = 0;
	que.push(P(0, s));

	while(!que.empty()){
		P p = que.top(); que.pop();
		int v = p.second;
		if(d2[v] < p.first) continue;
		for(int i = 0; i < G2[v].size(); i++){
			Edge e = G2[v][i];
			if(d2[e.to] > d2[v] + e.cost){
				d2[e.to] = d2[v] + e.cost;
				que.push(P(d2[e.to], e.to));
			}
		}
	}
}
int solve() {
	cin >> n >> m >> s >> t;
	Graph G(n);
	Graph G2(n);
	u.resize(m);
	v.resize(m);
	a.resize(m);
	b.resize(m);
	vector<ll> ans(n+1);
	REP(i, m){
		cin >> u[i] >> v[i] >> a[i] >> b[i];
		Edge e = { v[i] - 1, a[i] };
		Edge e2 = { u[i] - 1, a[i] };
		G[u[i]-1].push_back(e);
		G[v[i]-1].push_back(e2);
		Edge e5 = { v[i] - 1, b[i] };
		Edge e6 = { u[i] - 1, b[i] };
		G2[u[i]-1].push_back(e5);
		G2[v[i]-1].push_back(e6);
	}
	d1.resize(n);
	d2.resize(n);
	dijkstra(G, s-1);
	dijkstra2(G2,t-1);
	REP(i, n+1){
		ans[i] = INF;
	}
	for(ll i = n-1; i >= 0; i--){
		ans[i] = min(ans[i+1], d1[i]+d2[i]);
	}
	REP(i, n){
		cout << 1000000000000000 - ans[i] << endl;
	}
	return 0;
}

int main() {
	//clock_t start = clock();
	cout << std::fixed << std::setprecision(10);
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int end_solve = solve();
	/*
	clock_t end = clock();
	const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC *
	1000.0; printf("time %lf[ms]\n", time);
	*/

	return end_solve;
}


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

int main(){
  int N;
  scanf("%d", &N);
  double ans = 0;
  rep(i, N){
    double x;
    string u;
    cin >> x >> u;
    if(u == "JPY"){
      ans += x;
    }else{
      ans += x * 380000;
    }
  }
  printf("%.9lf\n", ans);
  return 0;
}


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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  ll K; scanf("%lld", &K);
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; ++i) {
    scanf("%d %d", &A[i].first, &A[i].second);
  }
  sort(A.begin(), A.end());
  ll cnt = 0;
  int ans = -1;
  for (int i = 0; i < N; ++i) {
    if (cnt + A[i].second < K) { cnt += A[i].second; }
    else {
      ans = A[i].first;
      break;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 1024