akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s == "SUN") {
        cout << 7;
        return 0;
    }
    if (s == "MON") {
        cout << 6;
        return 0;
    }
    if (s == "TUE") {
        cout << 5;
        return 0;
    }
    if (s == "WED") {
        cout << 4;
        return 0;
    }
    if (s == "THU") {
        cout << 3;
        return 0;
    }
    if (s == "FRI") {
        cout << 2;
        return 0;
    }
    if (s == "SAT") {
        cout << 1;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int d[30][100004];
int n[200004];
int main( void )
{
  ios::sync_with_stdio(false);
  int N, C, s, t, c;
  cin >> N >> C;
  for( int i=0; i<N; i++ ){
    cin >> s >> t >> c;
    d[c-1][s]++;
    d[c-1][t]--;
  }
  for( int i=0; i<C; i++ ){
    for( int j=0; j<=100000; j++ ){
      if( d[i][j] == 1 ){
        n[j*2-1]++;
      } else if( d[i][j] == -1 ){
        n[j*2]--;
      }
    }
  }
  int ret = 0;
  int r = 0;
  for( int i=0; i<=200000; i++ ){
    r += n[i];
    ret = max( ret, r );
  }
  cout << ret << endl;
}

Measured memory_bytes: 12800
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const ll MOD=1000000007;
const ll MAX_N=500010;
const ll INF=999999999999;

int main(){
    int n,m,x;
    cin>>n>>m>>x;
    int ans1=0;
    int ans2=0;
    for(int i=0;i<m;i++){
        int a;
        cin>>a;
        if(a<x){
            ans1++;
        }else{
            ans2++;
        }
    }
    cout<<min(ans1,ans2)<<endl;
}

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

using namespace std;

void fast();

/*
*
* Watch out! Another Buggy Code From Muhammad_Mamdouh, Happy Coding;
*
*/

int main()
{
    fast();
    int n, x, t; cin >> n >> x >> t;

    int total = 0;
    while (n > 0)
    {
        total += t;
        n -= x;
    }

    cout << total;

    return 0;
}

void fast()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <algorithm>

using namespace std;

int main(){
	int n,max_num = -1000001,min_num = 1000001,tmp;
	long long int sum = 0;
	scanf("%d",&n);
	for(int i = 0; i < n; i++){
		scanf("%d",&tmp);
		sum += tmp;
		max_num = max(max_num,tmp);
		min_num = min(min_num,tmp);
	}
	printf("%d %d %lld\n",min_num,max_num,sum);
}

Measured memory_bytes: 1032
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=((ll)n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=((ll)a);i<((ll)n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,p;
    cin>>a>>p;
    puta((a*3+p)/2);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  for(int i = 0;i < b+2;i++){
    cout << "#";
  }
  cout << endl;
  for(int i = 0;i < a;i++){
    string c;
    cin >> c;
    cout << "#" << c << "#" <<endl;
  }
  for(int i = 0;i < b+2;i++){
    cout << "#";
  }
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{int n,s=0;
 int a[200];
 cin>>n;
 for(int i=0;i<2*n;i++)
    cin>>a[i];
 sort(a,a+2*n);
 for(int i=0;i<2*n;i+=2)
    s+=a[i];
 cout<<s<<endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main 
{
	public static void main(String[] args) 
	{
		primeCalc();
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext())
		{
			int ans = 0;
			int n = stdIn.nextInt();
			for(int i = 0; i <= n; ++i)
			{
				if(isPrime[i])
				{
					++ans;
				}
			}
			System.out.println(ans);
		}
	}
	
	static List<Integer> list = new ArrayList<Integer>();
	static final int DATA_NUM = 1000001;
	static boolean[] isPrime = new boolean[DATA_NUM];
	static void primeCalc()
	{
		for(int i = 0; i < DATA_NUM; ++i)
		{
			isPrime[i] = true;
		}
		isPrime[0] = isPrime[1] = false;
		for(int i = 2; i < DATA_NUM; ++i)
		{
			if(isPrime[i])
			{
				list.add(i);
				for(int j = 2 * i; j < DATA_NUM; j += i)
				{
					isPrime[j] = false;
				}
			}
		}
	}
}

Measured memory_bytes: 24860
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int l = sc.nextInt();
		int eat = 0;
		if(l < 0){
			if(-l < n-1){
				eat = -l;
			}else{
				eat = n-1;
			}
		}
		int ans = -(eat + l);
		for(int i = 0; i < n; i++){
			ans += i + l;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
S=input()

if S[0]=='A' :
    if 'C' in S[2:-1]:
        if S.count('C')==1:
            bl = True
            for s in S[1:]:
                if s<'a' and s !='C':
                    bl = False
            if bl:
                print('AC')
                exit(0)                
print('WA')
    

                
                
                
    

    


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#include<algorithm>
#include<set>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stack>
using namespace std;
typedef long long int ll;
const int MOD=1e9+7;
// power function with a^b 
ll power(ll a, ll b){
    ll ans=1;
    while(b>0){
        if(b%2!=0)
        ans=ans*a;

        b/=2;
        a=a*a;
    }
    return ans;
}
// power function with modulo i.e (a^b)%mod
ll powermod(ll a,ll b, ll mod){
    ll ans=1;
    a=a%mod;
    if(a==0) return 0;
    while(b>0){
        if(b%2!=0)
        ans=(ans*a)%mod;

        b/=2;
        a=(a*a)%mod;
    }
    return ans;
}
ll fact(ll n){
    ll ans=1;
    for(int i=n; i>=1; i--){
        ans*=i;
    }
    return ans;
}
int solve(){
    ll n;
    cin>>n;
    ll k;
    cin>>k;
    ll height[n];
    for(int i=0; i<n; i++){
        cin>>height[i];
    }
    ll dp[n];
    memset(dp,63,sizeof(dp));
    dp[0]=0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<=i+k; j++){
            if(j<n)
            dp[j]=min(dp[j],dp[i]+abs(height[i]-height[j]));
        }
    }
    return dp[n-1];
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

   // ll tc;
   // cin >> tc;
    //for (int t = 1; t <= tc; t++) {
        // cout << "Case #" << t  << ": ";
        ll ans=solve();
        cout<<ans<<"\n";
    //}
}


Measured memory_bytes: 5096
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(), (a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(), (a).end())
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> a(m),b(m);
    map<int,int> p;
    rep(i,m){
        cin>>a[i]>>b[i];
        if(a[i]==1){
            p[b[i]]++;
        }
    }
    bool ans = false;
    rep(i,m){
        if(b[i]==n){
            if(p[a[i]]>=1){
                ans = true;
                break;
            }
        }
    }
    if(ans){
        cout<<"POSSIBLE"<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
}

Measured memory_bytes: 11136
package main

import(
    "fmt"
)



func main() {
    var x,y int
    fmt.Scan(&x,&y)
    if x+y>=10{
        fmt.Println("error")
    } else {
        fmt.Println(x+y)
    }
}





func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}


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

int main(){
    int a,b;
    cin >> a >> b;
    int n;
    if(b / 10 == 0){
        a = a * 10;
    }else if(b / 100 == 0){
        a = a * 100;
    }else{
        a = a * 1000;
    }
    n = a + b;
    for(int i=0; i!=100000; i++){
        if(n == i * i){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}



Measured memory_bytes: 256
a,b,c,x,y = map(int, input().split())
mix_price = min(a+b,c*2)
if a >= 2 * c and b >= 2 * c:
  print(2 * c * max(x,y))
elif a >= 2 * c and x >= y:
  print(x * 2 * c)
elif a >= 2 * c and x < y:
  print(x * 2 * c + (y - x) * b)
elif b >= 2 * c and x <= y:
  print(y * 2 * c)
elif b >= 2 * c and x > y:
  print(y * 2 * c + (x - y) * a)
elif a + b >= 2 * c and x >= y:
  print(y * mix_price + (x - y) * a)
elif a + b >= 2 * c and x < y:
  print(x * mix_price + (y - x) * b)
else:
  print(x * a + y * b)

Measured memory_bytes: 3064
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

# 始点を決めて適当に道を選んでいくと，
# 行き詰まった点は今まで通った頂点としか繋がっていない
# 2回これを繰り返して，終点どうしを結べばok

def edges_to_pt(s,t,n,directed=False):
    pt = [[] for _ in range(n)]
    for i in range(len(s)):
        pt[s[i]-1].append(t[i]-1)
        if not directed:
            pt[t[i]-1].append(s[i]-1)
    return pt

N,M = LI()
A,B = LIR(M,2)

pt = edges_to_pt(A,B,N)

s = 0
path1 = [s]
visited = [False]*N
visited[s] = True
S = [s]
while S:
    v = S.pop()
    for u in pt[v]:
        if not visited[u]:
            visited[u] = True
            path1.append(u)
            S.append(u)
            break

s = 0
path2 = []
S = [s]
while S:
    v = S.pop()
    for u in pt[v]:
        if not visited[u]:
            visited[u] = True
            path2.append(u)
            S.append(u)
            break

path = list(reversed(path2))+path1
path = list(map(lambda x:x+1,path))

print(len(path))
print(*path)

Measured memory_bytes: 84316
#include<bits/stdc++.h>
using namespace std;
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define pa pair<int,int>
#define mod 1000000007
#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define cl(x) memset(x,0,sizeof x)
#ifdef Devil_Gary
#define bug(x) cout<<(#x)<<" "<<(x)<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define bug(x)
#define debug(...)
#endif
const int INF = 0x7fffffff;
const int N=1e5+5;
/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int read(){
    int x=0,rev=0,ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')rev=1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+ch-'0';ch=getchar();}
    return rev?-x:x;
}
int cnt;
double x[5],y[5],tmp[5],ans,angle1,angle2; 
double calc(int a,int b){
	return (double)sqrt((x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b])); 
}
double calc2(double a,double b,double c){
	double d=(b*b+c*c-a*a)/(2*b*c); 
	return acos(d);
}
int main(){
#ifdef Devil_Gary
	freopen("in.txt","r",stdin);
#endif
	for(int i=1;i<=3;i++) x[i]=read(),y[i]=read();
	for(int i=1;i<=3;i++){
		for(int j=i+1;j<=3;j++){
			tmp[++cnt]=calc(i,j);
		}
	}
	sort(tmp+1,tmp+cnt+1);
	angle1=calc2(tmp[1],tmp[2],tmp[3])/2,angle2=calc2(tmp[2],tmp[1],tmp[3])/2;
	ans=tmp[3]/(2+1/tan(angle1)+1/tan(angle2));
	printf("%.12lf",ans);
}



Measured memory_bytes: 512
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		int N = GetInt();
		long X = GetLong();

		long[] numP = new long[N+1];
		long[] numTotal = new long[N+1];
		numP[0] = 1L;
		numTotal[0] = 1L;
		for(int i = 1; i <= N; i++)
		{
			numP[i] = 1L + 2L * numP[i-1];
			numTotal[i] = 3L + 2L * numTotal[i-1];
		}

		Solver solver = new Solver(numP, numTotal);
		Console.WriteLine(solver.eat(N, X));		
	}
}


public class Solver
{
	private long[] m_numP;
	private long[] m_numTotal;

	public Solver(long[] numP, long[] numTotal)
	{
		m_numP = numP;
		m_numTotal = numTotal;
	}

	public long eat(int level, long length)
	{
		if(length == 1L)
		{
			return (level == 0) ? 1 : 0;
		}
		else if(length < 1L + m_numTotal[level - 1])
		{
			return eat(level - 1, length - 1L);
		}
		else if(length == 1L + m_numTotal[level - 1])
		{
			return m_numP[level - 1L];
		}
		else if(length == 2L + m_numTotal[level - 1])
		{
			return m_numP[level - 1] + 1L;
		}
		else if(length < 3L + 2 * m_numTotal[level - 1])
		{
			return m_numP[level - 1] + 1L + eat(level - 1, length - 2L - m_numTotal[level - 1]);
		}
		else
		{
			return m_numP[level];
		}
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;

	int a[N+5];
	for(int i = 0;i<N;++i){
		cin >> a[i];
	}

	int Alice = 0,Bob = 0;

	sort(a, a+N, greater<int>());
	for(int j = 0;j < N;++j){
		if(j % 2 == 0) Alice += a[j];
		else Bob += a[j];
	}

	cout << Alice - Bob << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,d;
	cin>>n>>d;
	int k= d*2+1;
	int c = n/k;
	if(k*c<n)
	{
		cout<<c+1<<endl;
	} 
	else
	{
	 	cout<<c<<endl;
	}
	return 0;
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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 solve(long long N, std::vector<std::string> S) {
    map<string, int> counter;
    int c = 0;
    for(int i = 0 ; i < S.size() ; i++){
        c = max(c, ++counter[S[i]]);
    }
    for( auto i : counter ){
        if( i.second == c ){
            cout << i.first << endl;
        }
    }
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<std::string> S(N);
  for (int i = 0; i < N; i++) {
    std::cin >> S[i];
  }
  solve(N, std::move(S));
  return 0;
}


Measured memory_bytes: 26752
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>
 
using namespace std;


 
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) r.begin(),r.end()
#define fi first
#define se second
#define println(X) cout<<X<<endl;
#define DBG(X) cout<<#X<<" : "<<X<<endl;
 

 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;



const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-7;


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

int d[110][110][4];
int used[110][110];

int x, y, nx, ny, c;

int main(){
	int h, w, t;
	while(cin>>w>>h){
		//cout<<h<<" "<<w<<endl;
		if(h == 0 && w == 0) break;
		for(int i = 0; i < 110; i++){
			for(int j = 0; j < 110; j++){
				for(int k = 0; k < 4; k++){
					d[i][j][k] = 1;
				}
				used[i][j] = 0;
			}
		}
		for(int i = 0; i < 2 * h -1; i++){
			if(i % 2 == 0){
				for(int j = 0; j < w-1; j++){
					cin>>t;
					if(t == 0){
						d[i/2+1][j+1][2] = 0;
						d[i/2+1][j+2][0] = 0;
					}
				}
			}
			else{
				for(int j = 0; j < w; j++){
					cin>>t;
					if(t == 0){
						d[i/2+1][j+1][3] = 0;
						d[i/2+2][j+1][1] = 0;
					}
				}
			}
		}
		// for(int i = 1; i <= h; i++){
		// 	for(int j = 1; j <= w; j++){
		// 		cout<<" "<<d[i][j][1];
		// 	}
		// 	cout<<endl;
		// }
		queue<pair<int, pii> > q;
		pair<int, pii> p(mp(0,mp(1,1)));
		used[1][1] = 1;
		q.push(p);
		int ans = -1;
		while(!q.empty()){
			p = q.front(); q.pop();
			c = p.fi;
			x = p.se.se; y = p.se.fi;
			//cout<<x<<" "<<y<<" "<<c<<endl;
			for(int i = 0; i < 4; i++){
				nx = x + dx[i];
				ny = y + dy[i];
				if(d[y][x][i]==1 || used[ny][nx] == 1) continue;
				if(nx == w && ny == h){
					ans = c + 1;
					while(!q.empty()) q.pop();
					break;
				}
				q.push(mp(c+1, mp(ny, nx)));
				used[ny][nx] = 1;
			}
		}
		cout<<ans+1<<endl;
	}
}

Measured memory_bytes: 1452
/*
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
*/
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long INF = 1000000000000;
int pow3(int x){
  int ans = 1;
  for (int i = 0; i < x; i++){
    ans *= 3;
  }
  return ans;
}
int main(){
  int N;
  cin >> N;
  vector<int> X(N), Y(N);
  vector<long long> P(N);
  for (int i = 0; i < N; i++){
    cin >> X[i] >> Y[i] >> P[i];
  }
  vector<pair<int, int>> xs;
  xs.reserve(N + 1);
  for (int i = 0; i < N; i++){
    xs.emplace_back(X[i], i);
  }
  xs.emplace_back(0, N);
  sort(xs.begin(), xs.end());
  vector<pair<int, int>> ys;
  ys.reserve(N + 1);
  for (int i = 0; i < N; i++){
    ys.emplace_back(Y[i], i);
  }
  ys.emplace_back(0, N);
  sort(ys.begin(), ys.end());
  vector<long long> ans(N + 1, INF);
  vector<int> H, V;
  H.reserve(N + 2);
  V.reserve(N + 2);
  vector<int> a(N + 1, 0);
  vector<int> d(N, 1000000);
  int u = pow3(N);
  int cnt, tmp, A, B;
  for (int i = 0; i < u; i++){
    cnt = 0;
    tmp = i;
    for (int j = 0; j < N; j++){
      if ((a[j] = tmp % 3) > 0){
        cnt++;
      }
      tmp /= 3;
    }
    a[N] = 1;
    H.clear();
    H.emplace_back(-1000000);
    for (auto P : ys){
      if (a[P.second] == 1){
        H.emplace_back(P.first);
      }
    }
    H.emplace_back(1000000);
    a[N] = 2;
    V.clear();
    V.emplace_back(-1000000);
    for (auto P : xs){
      if (a[P.second] == 2){
        V.emplace_back(P.first);
      }
    }
    V.emplace_back(1000000);
    A = 0;
    int tmp1 = H.size() - 1;
    for (auto p : ys){
      if (p.second == N){
        continue;
      }
      while (A < tmp1){
        if (H[A + 1] < p.first){
          A++;
        } else {
          break;
        }
      }
      d[p.second] = min(p.first - H[A], H[A + 1] - p.first);
    }
    B = 0;
    int tmp2 = V.size() - 1;
    for (auto p : xs){
      if (p.second == N){
        continue;
      }
      while (B < tmp2){
        if (V[B + 1] < p.first){
          B++;
        } else {
          break;
        }
      }
      d[p.second] = min(d[p.second], min(p.first - V[B], V[B + 1] - p.first));
    }
    long long S = 0;
    for (int i = 0; i < N; i++){
      S += d[i] * P[i];
    }
    ans[cnt] = min(ans[cnt], S);
  }
  for (int i = 0; i <= N; i++){
    cout << ans[i] << "\n";
  }
}

Measured memory_bytes: 3152
import sys
sys.setrecursionlimit(10**6)
def main():
    class unionfind():
        def __init__(self,n):
            self.par = [i for i in range(n)]
            self.size = [1 for i in range(n)]
            self.rank = [0 for i in range(n)]
 
        def root(self,x):
            if self.par[x] == x:
                return x
            else:
                self.par[x] = self.root(self.par[x])
                return self.par[x]
 
        def same(self,x,y):
            return self.root(x) == self.root(y)
 
        def unite(self,x,y):
            x = self.root(x)
            y = self.root(y)
            if x==y:return
            else:
                if self.rank[x] < self.rank[y]:
                     x,y = y,x
                if self.rank[x] == self.rank[y]:
                    self.rank[x]+=1
                self.par[y] = x
                self.size[x] +=self.size[y]
        def get_size(self,x):
            x = self.root(x)
            return self.size[x]
 
    
    input = sys.stdin.readline
    n,m,k = map(int,input().split())
    uff = unionfind(n)
    fr = [0 for i in range(n)]
 
 
    for i in range(m):
        a,b = map(int,input().split())
        uff.unite(a-1,b-1)
        fr[a-1]+=1
        fr[b-1]+=1
 
 
    ans = [uff.get_size(i) -fr[i]-1 for i in range(n)]
 
    for i in range(k):
        c,d = map(int,input().split())
        if uff.same(c-1,d-1):
            ans[c-1] -=1
            ans[d-1] -=1
    print(*ans)
if __name__=="__main__":
    main()

Measured memory_bytes: 84400
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<queue>
#include<deque>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000001
using namespace std;
typedef long long ll;

int d,g;
int p[20],c[20];

int main(){
  std::cin >> d >> g;
  rep(i,1,d+1){
    std::cin >> p[i] >> c[i];
  }
  int res = MAX;
  rep(i,0,(1<<d)){
    int score = 0;int tmp = 0;
    rep(j,1,d+1){
      if(i&(1<<(j-1))){
        score += 100*p[j]*j+c[j];
        tmp += p[j];
      }
    }
    // std::cout << score << '\n';
    if(score>=g)res = min(tmp, res);
    else{
      per(j,1,d+1){
        if(score >= g)break;
        if(!(i&(1<<(j-1)))){
          int hoge = p[j];
          while(hoge){
            score += 100*j;
            tmp += 1;
            if(score >= g)break;
            hoge -= 1;
          }
        }
      }
      res = min(tmp, res);
    }
  }
  std::cout << res << '\n';
}


Measured memory_bytes: 256
using System;
using System.Linq;

namespace _0123
{
    class Program
    {
        static void Main(string[] args)
        { string kyu = "NA";
            while (true)
            {
                string str = Console.ReadLine();
                if (str == null) { break; }
                kyu = "NA";
                float[] a1 = str.Split().Select(float.Parse).ToArray();
                float a = a1[0],b=a1[1];
                if (a < 35.5 && b < 71) { kyu = "AAA"; }
                else if (a < 37.5 && b < 77) { kyu = "AA"; }
                else if (a < 40 && b < 83) { kyu = "A"; }
                else if (a < 43 && b < 89) { kyu = "B"; }
                else if (a < 50 && b < 105) { kyu = "C"; }
                else if (a < 55 && b < 116) { kyu = "D"; }
                else if (a < 70 && b < 148) { kyu = "E"; }
                Console.WriteLine(kyu);
            }
        }
    }
}

Measured memory_bytes: 9680
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; ++i) {
			for (int j = i + 1; j < n; j++) {
				++count;
			}
		}
		for (int i = 0; i < m; i++) {
			for (int j = i + 1; j < m; j++) {
				++count;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
long long a,b,c,k;
int main()
{
	cin>>a>>b>>c>>k;
	if(k<=a) cout<<k;
	else if(k<=a+b) cout<<a;
	else cout<<a-(k-a-b);
	return 0;
}

Measured memory_bytes: 3596
n = int(input())
S = list(map(int, input().split()))
q = int(input())
T = list(map(int, input().split()))

def binary_search(A, x):
    right = len(A)
    center = right // 2
    left = 0
    pre_center = -1
    result = False
    while left < right:
        if x < A[center]:
            right = center
            center = (right + left) // 2
        elif x > A[center]:
            left = center + 1
            center = (right + left) // 2
        else:
            result = True
            break


    return result
cnt = 0
for i in T:
    if binary_search(S, i):
        cnt += 1

print(cnt)


Measured memory_bytes: 16708
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long int
#define lu unsigned long long int
#define pi pair<ll, ll>
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define mk make_pair
#define ve vector
#define lr(n) for (ll i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define be begin
#define sz(a) (ll)(a.size())
#define INF 1e18
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

// ll gcd(ll a, ll b){
// 	return b == 0 ? a : gcd(b, a % b);
// }

// ll mod = 1e9+7;

// ll mult(ll x, ll y){
//     ll rem=1;
//     while(y){
//         if(y&1){
//             rem=(rem*x)%mod;
//         }
//         x=(x*x)%mod;
//         y>>=1;
//     }
//     return rem;
// }


void solve(ll T){
	ll n,x,t;
	cin>>n>>x>>t;
	ll k=n/x, r=n%x;
	if(r) k++;
	cout << k*t << "\n";
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	// std::cout << std::unitbuf;
	ll T=1;
	// cin>>T;
	for(ll t=1;t<=T;t++){
		solve(t);
	}
	return 0;
}


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

int main(){
    ll n;
    cin >> n;
    ll count=0;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin >> a[i];
        if(a[i]<0) count++;
    }
    if(count%2==0){
        ll res=0;
        for(ll i=0;i<n;i++){
            res+=abs(a[i]);
        }
        cout << res << endl;
    }
    else{
        ll res=0;
        ll mmin=1e10;
        for(ll i=0;i<n;i++){
            mmin=min(mmin,abs(a[i]));
            res+=abs(a[i]);
        }
        res-=mmin*2;
        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 4372
#include<iostream>
#include<cmath>

using namespace std;

int N ,A ,B;
int h[100000];
int deltaAB;
int max_h;


bool defeatable(int x){
	int y = x;
	for(int i = 0 ; i < N ;i++){
		if( h[i] - B * x  > 0){
			y -= ceil((h[i]-B * x + 0.0)/deltaAB);
//			cout <<ceil((h[i]-B* x + 0.0)/deltaAB)<<endl;
		if(y <0) {
			return false;
		}
		}

	}
	return true;
}


int main(){
	cin >>N >> A >>B;
	max_h = 0;
	for(int i = 0 ;i < N;i++){
		cin >> h[i];
		if(max_h < h[i])max_h = h[i];
	}
	deltaAB = A-B;
	int lb =0;
	int ub = max_h / B +2 ;
	int a ;	
	while(ub - lb >1){
		a = floor((ub + lb )/2);
//		cout << "ub=" <<ub <<"lb" <<lb <<endl;
		if(defeatable(a)){
//			cout << "ub=" << a <<endl; 
			ub = a;
		}else{
//			cout << "lb=" << a <<endl; 
			lb = a;
		}
		}
//if(defeatable(3))cout <<"true"<<endl;
//	else cout << "false" << endl;
	cout <<ub << endl;
return 0;	
}


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

typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define each(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); ++itr)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second

int C,D,W,X;
int E[15][30],F[15][30];

int dp[31][51][6];
int dfs(int day, int cost, int x)
{
    if(dp[day][cost][x]>=0) return dp[day][cost][x];
    if(day==D) return 0;

    int ret=0;

    // ??????????????????
    ret=max(ret,dfs(day+1,cost,x));

    rep(place,C)
    {
        if(E[place][day]==0) continue;

        // 1????????????
        if(cost+F[place][day]<=W) ret=max(ret,dfs(day+1,cost+F[place][day],x)+E[place][day]);

        // ?????°????????????
        if(x==X) continue;

        int tcost=cost+F[place][day];
        int tE=E[place][day];
        int now=place-1;
        while(now>=0)
        {
            if(E[now][day]==0) break;
            if(tcost+F[now][day]>W) break;

            tcost+=F[now][day];
            tE+=E[now][day];
            ret=max(ret,dfs(day+1,tcost,x+1)+tE);

            --now;
        }

        tcost=cost+F[place][day];
        tE=E[place][day];
        now=place+1;
        while(now<C)
        {
            if(E[now][day]==0) break;
            if(tcost+F[now][day]>W) break;

            tcost+=F[now][day];
            tE+=E[now][day];
            ret=max(ret,dfs(day+1,tcost,x+1)+tE);
            ++now;
        }
    }

    dp[day][cost][x]=ret;
    return ret;
}

int main()
{
    while(scanf(" %d %d %d %d",&C,&D,&W,&X),C)
    {
        rep(i,C)rep(j,D) scanf(" %d", &E[i][j]);
        rep(i,C)rep(j,D) scanf(" %d", &F[i][j]);
        memset(dp,-1,sizeof(dp));
        printf("%d\n", dfs(0,0,0));
    }
    return 0;
}

Measured memory_bytes: 3232
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a=nxt(),b=nxt();
    int cur=1;
    int test=0;
    while(cur<b)
    {
        cur--;
        cur+=a;
        test++;
    }
    cout<<test<<endl;
    
    
    return 0;   
}


 
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;

int main()
{
    uint x, y;

    while (true) {
        cin >> x >> y;

        if (!x && !y) {
            break;
        }

        if (x > y) {
            swap(x, y);
        }

        printf("%d %d\n", x, y);
    }
}



Measured memory_bytes: 3120
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }
template<typename V> void printVec(V v) {ll i=0;for(auto x : v){std::cout << " [" << i++ << "] " << x;} print();}

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

  ll N;
  std::cin >> N;
  std::vector< ll > vh(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> vh[i];
  }

  ll ans = 0LL;
  for (ll i = 0; i < N; i++) {
    bool judge = true;
    for (ll j = 0; j < i; j++) {
      if (vh[i] < vh[j]) {
	judge = false;
      }
    }
    if (judge) ans++;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

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

int main() {
  LL N; cin >> N;
  vector<LL> A(N); cin >> A;

  LL cnt = 0;
  LL x = 0;
  for (int i = 0; i < N; ++i) {
    if (x > A[i]) {
      cnt += x - A[i];
    } else {
      x = A[i];
    }
  }
  cout << cnt << endl;
}


Measured memory_bytes: 4724
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    int n;

    cin >> n;

    int a[n];
    int sum = 0, average=0, cost=0;

    for (int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    average = round((double)sum/n);

    for (int i=0; i<n; i++) {
        cost += (a[i]-average)*(a[i]-average);
    }

    cout << cost << endl;

    return 0;
}


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

using namespace std;

typedef pair<int,int> pii;
typedef pair<int,pii> piii;
int n, m;
map<pii,int> lab;
vector<int> lis[400100];
vector<int> num[100100];
pii arr[400100];
int visit[100100], dist[400100];
int icnt, INF = 987654321;
int push(int x, int y) {
	if (lab.find(pii(x,y))==lab.end()) {
		lab[pii(x,y)] = icnt;
		num[x].push_back(icnt);
		arr[icnt] = pii(x,y);
		icnt++; return icnt-1;
	}
	num[x].push_back(lab[pii(x,y)]);
	return lab[pii(x,y)];
}
int main() {
	int i, t;

	scanf("%d%d",&n,&m);
	for (i=0;i<m;i++) {
		int a, b, c;
		scanf("%d%d%d",&a,&b,&c); --a; --b;
		int p = push(a,c), q = push(b,c);
		lis[p].push_back(q);
		lis[q].push_back(p);
	}
	int st = push(0,0);
	for (i=0;i<icnt;i++) dist[i] = INF;
	dist[st] = 0;
	queue<pii> p, q;
	q.push(pii(0,st));
	while(1) {
		bool flag = 0;
		while(!q.empty()) {
			pii tmp = q.front();
			q.pop();
			int here = arr[tmp.second].first, d = tmp.first;
			if (visit[here]>=2) continue;
			for (auto &there : num[here]) {
				if (dist[there]>d+1) {
					flag = 1;
					dist[there]=d+1;
					p.push(pii(d+1,there));
				}
			}
			visit[here] = 2;
		}
		while(!p.empty()) {
			pii tmp = p.front();
			p.pop();
			int here = tmp.second, d = tmp.first;
			for (auto &there : lis[here]) {
				if (dist[there]>d) {
					dist[there]=d;
					p.push(pii(d,there));
					q.push(pii(d,there));
					flag = 1;
				}
			}
		}
		if (!flag) break;
	}
	int mini = INF;
	for (auto &v : num[n-1]) {
		mini = min(mini,dist[v]);
	}
	printf("%d\n",(mini>=n+10)?-1:mini);

    return 0;
}


Measured memory_bytes: 59512
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <set>
#include <map>
using namespace std;
typedef long long int lli;
const lli mod = 1e9 +7;
const lli inf = 1e18;
typedef pair<lli, lli> pll;

int main(){
    int n,d;
    cin >> n >> d;
    vector<vector<int> > v(n, vector<int>(d));
    for(int i=0; i<n; i++){
        for(int j=0; j<d; j++){
            cin >> v[i][j];
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            int sum = 0;
            for(int k=0; k<d; k++){
                sum += (v[i][k] -v[j][k]) *(v[i][k] -v[j][k]);
            }
            if(sum == (int)sqrt(sum)*(int)sqrt(sum)){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
#define MARK 4
#define RANK 13
#define CHECK 1	
int main(void)
{
	int n,rank,a,i,k;
	char mark;
	int card[4]={0};
	char mk[4]={'S','H','C','D'};
	cin >> n;
	for(i=0; i<n; i++){
		cin >> mark >> rank;
		if(mark == 'S'){
			a=1;
			a <<= rank;
			card[0] += a;
		}else if(mark == 'H'){
			a=1;
			a <<= rank;
			card[1] += a;
		}else if(mark == 'C'){
			a=1;
			a <<= rank;
			card[2] += a;
		}else if(mark == 'D'){
			a=1; 
			a <<= rank;
			card[3] += a;
		}
	}
	for(i=0; i<MARK; i++){
		for(k=1; k<=RANK; k++){
			card[i] >>= 1;
			if((card[i] & CHECK) == 0){
				cout << mk[i] << " " << k << endl;
			}
		}
	}
	return 0;
}

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

#define MAX 2000000
#define INFTY (1<<30)

int H,A[MAX+1];

void maxHeapify(int);
int extract(void);
void increaseKey(int,int);
void insert(int key);

int main() {

  int key;
  char com[8];

  while(1) {
    scanf("%s",com);

    if(com[0] == 'e' && com[1] == 'n') break;

    if(com[0] == 'i') {
      scanf("%d",&key);
      insert(key);
    } else {
      printf("%d\n",extract());
    }
  }

  return 0;

}

void maxHeapify(int i) {

  int l,r,largest;
  int a;
  l = 2*i;
  r = 2*i+1;
  
  if(l<=H && A[l]>A[i]) largest = l;
  else largest = i;
  if(r<=H && A[r]>A[largest]) largest = r;
  
  if(largest != i) {
    a = A[i]; A[i] = A[largest]; A[largest] = a;
    maxHeapify(largest);
  }
}

int extract() {
  
  int maxv;

  if(H<1) return -INFTY;
  maxv = A[1];
  A[1] = A[H--];
  maxHeapify(1);
  return maxv;

}

void increaseKey(int i,int key) {

  int a;

  if(key<A[i]) return;
  A[i] = key;
  while(i>1 && A[i/2] < A[i]) {
    a = A[i]; A[i] = A[i/2]; A[i/2] = a;
    i = i/2;
  }

}

void insert(int key) {

  H++;
  A[H] = -INFTY;
  increaseKey(H,key);
  
}


Measured memory_bytes: 5608
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<string>
#include<algorithm>
using namespace std;
int main(){
  vector<int> a(6);
  for(int i=0; i<6; i++) cin >> a[i];
  cout << (a[4]-a[0]<=a[5] ? "Yay!" : ":(") << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    char s[6];
    
    scanf("%s",s);
    if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
    {
        printf("Bad\n");
    }
    else
    {
        printf("Good\n");
    }
    
    return 0;
}


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

int main(){
    int k,a,b,flag=0;
    cin >> k;
    cin >> a >> b;
    for(int i=a;i<=b;i++){
        if (i%k == 0) {
            cout << "OK" << endl;
            flag = 1;
            break;
        }
    }
    if(flag==0) {
        cout << "NG" << endl;
    }

    return 0;
}

Measured memory_bytes: 3624
s = input()
t = input()
c = []

for j in range(len(s)-len(t)+1):
    counter = 0
    for i in range(len(t)):
        if(s[i+j] == t[i]):
#            print("i,j=",i,j)
            counter += 1

#    print(counter)
    c.append(counter)

print(len(t)-max(c))

Measured memory_bytes: 9052
A, B, C, D = map(int, input().split())
n = 1
while A > 0 and C > 0:
  if n % 2 == 1:
    C = C - B
    ans = "Yes"
    n = n + 1
  else:
    A = A - D
    ans = "No"
    n = n + 1
    
print(ans)

Measured memory_bytes: 9148
from fractions import gcd

A, B, C, D = map(int, input().split())
l = C * D // gcd(C, D)
x = (A - 1) - (A - 1) // C - (A - 1) // D + (A - 1) // l
y = B - B // C - B // D + B // l
print(y - x)

Measured memory_bytes: 5048
#include <stdio.h>
#define MAX 500005
  
int T[MAX]; 
int hs;
 
void maxHeapify(int);
void buildMaxHeap();
int left(int);
int right(int);
  
int main()
{
  int i;
   
  scanf("%d", &hs); 
  for(i=1; i<=hs; i++){
    scanf("%d", &T[i]);
  }
   
  buildMaxHeap();
  
  for(i=1; i<=hs; i++){   
    printf(" %d", T[i]);
  }
  
  printf("\n");
  
  return 0;
}
 
 
void buildMaxHeap()
{
  int i;
 
  for(i= hs/2; i>=1; i--){
    maxHeapify(i);
  }
}
 
 
void maxHeapify(int i)
{
  int largest=0, temp, l, r;
 
  l = left(i);
  r = right(i);
   
  if((hs >= l) && (T[l] > T[i])){
    largest = l;
  }
  else{
    largest = i;
  }
    
  if((hs >= r) && (T[r] > T[largest])){
    largest = r;
  }
 
  if (largest != i){
    temp = T[i];
    T[i] = T[largest];
    T[largest] = temp;
    maxHeapify(largest);
  } 
 
}
 
  
int left(int i)
{
  return (2*i);
}
  
int right(int i)
{
  return (2*i + 1);
}



Measured memory_bytes: 3648
#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cstring>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

#define SIZE(x) (int((x).size()))
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
#define repd(i,r,l) for (int i=(r); i>=(l); i--)
#define rept(i,c) for (typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)

#ifndef ONLINE_JUDGE
#define debug(x) { cerr<<#x<<" = "<<(x)<<endl; }
#else
#define debug(x) {}
#endif

#define maxn 310
#define INF 1000000000

char g[maxn][maxn];
int sa[maxn][maxn][maxn], dp[maxn][maxn];

void su(int &a, int b) { a=min(a,b); }

void lemon()
{
	int n,m; scanf("%d%d",&n,&m);
	rep(i,1,n) scanf("%s",g[i]+1);
	rep(dif,-(n-1),n-1)
		rep(s,1,n)
		{
			int t=s+dif;
			if (t<1 || t>n) continue;
			rep(col,1,m-1)
				sa[col][s][t]=sa[col][s-1][t-1]+(g[s][col]==g[t][col+1]?1:0);
		}
		
	//dp[i][j][k]
	//col i has j blocks left and i+1 has k
	int ans=0;
	rep(i,1,m-1)
	{
		rep(j,0,n) rep(k,0,n) dp[j][k]=INF;
		dp[n][n]=0;
		repd(j,n,0)
			repd(k,n,0)
				if (dp[j][k]!=INF)
				{
					if (j)
						su(dp[j-1][k],dp[j][k]+sa[i][j][k]);
					if (k) 
						su(dp[j][k-1], dp[j][k]+sa[i][j][k]);
				}
		ans+=dp[0][0];
	}
	printf("%d\n",ans);
}

int main()
{
	ios::sync_with_stdio(true);
	#ifndef ONLINE_JUDGE
	//	freopen("D.in","r",stdin);
	#endif
	lemon();
	return 0;
}



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

int main()
{
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    int ans=0;
    int min=INT_MAX;
    if(a%10!=0)
   {
       if(a%10<min)
       min=a%10;
        a/=10;
    a++;
    a*=10;
   }
    if(b%10!=0)
   {
       if(b%10<min)
       min=b%10;
       b/=10;
    b++;
    b*=10;
   }
    if(c%10!=0)
   {
       if(c%10<min)
       min=c%10;
         c/=10;
    c++;
    c*=10;
   }
      if(d%10!=0)
   {
       if(d%10<min)
       min=d%10;
      d/=10;
    d++;
    d*=10;
   }
      if(e%10!=0)
   {
       if(e%10<min)
       min=e%10;
        e/=10;
    e++;
    e*=10;
   }
   ans=(a+b+c+d+e);
 if(min==INT_MAX)
    cout<<ans;
    else
    cout<<ans-(10-min);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
char s[N];
int main()
{
    scanf("%s",s+1);
    int n=strlen(s+1);
    int ans=0;
    int l=1,r=n;
    while(l<=r)
    {
        if(s[l++]!=s[r--]) ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  while(1){
    int N,K;
    int flg=0,i,j,S[100],B;
    scanf("%d %d",&N,&K);
    if( N==0 && K==0 ) break;

    for(i=0 ; i<K ; i++) scanf("%d",&S[i]);

    for(i=0 ; i<N ; i++){
      for(j=0 ; j<K ; j++){
	scanf("%d",&B);
	S[j]-=B;
	if(S[j]<0)flg=1;
      }
    }
    switch(flg){
    case 0:
      printf("Yes\n");
      break;
    case 1:
      printf("No\n");
      break;
    }
  }
  return 0;
}

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

using namespace std;

#define FOR(i, x, y) for(int i = (x); i < (y); ++i)
#define REP(i, x, y) for(int i = (x); i <= (y); ++i)
#define PB push_back
#define MP make_pair
#define PH push
#define fst first
#define snd second
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair<int, int> pii;

const int maxn = 2005;
const int p[10][3] = {{0, 1, 2}, {0, 1, 3}, {0, 1, 4}, {0, 2, 3}, {0, 2, 4}, {0, 3, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}};
const int q[10][3] = {{3, 4}, {2, 4}, {2, 3}, {1, 4}, {1, 3}, {1, 2}, {0, 4}, {0, 3}, {0, 2}, {0, 1}};

inline void umax(int &x, int y){ x = max(x, y); }

class Upd{
public:
	int x, y, v;
	Upd(int x_, int y_, int v_): x(x_), y(y_), v(v_){}
};

int n, dlt, mx, ans; 
int a[maxn * 3], cmx[maxn];
int dp[maxn][maxn];
vector<Upd> upd;

inline void p2p(int x, int y, int z){
	upd.PB(Upd(x, y, max(mx, dp[z][z] + 1)));
	return;
}

inline void r2r(int x, int z){
	FOR(k, 0, n){
		upd.PB(Upd(k, z, dp[x][k] + 1));
	}
	return;
}

inline void r2p(int z){
	FOR(k, 0, n){
		upd.PB(Upd(k, z, cmx[k]));
	}
	return;
}

inline void update(Upd u){
	int x = u.x, y = u.y, v = u.v;
	int res = max(dp[x][y], v);
	dp[x][y] = dp[y][x] = res;
	umax(cmx[x], res);
	umax(cmx[y], res);
	umax(mx, res);
	return;
}

inline void init(){
	dp[a[0]][a[1]] = dp[a[1]][a[0]] = 0;
	cmx[a[0]] = cmx[a[1]] = mx = 0;
	return;
}

inline void print(){
	FOR(i, 0, n){
		FOR(j, 0, n)
			printf("%d ", dp[i][j] + dlt);
		puts("");
	}
	return;
}

int main(){	
	scanf("%d", &n);
	FOR(i, 0, n * 3)
		scanf("%d", a + i), --a[i];
	
	if(n == 1){
		printf("%d\n", a[0] == a[1] && a[1] == a[2]);
		return 0;
	}	
	
	mx = -0x3f3f3f3f;
	FOR(i, 0, n) FOR(j, 0, n)
		dp[i][j] = -0x3f3f3f3f;
	FOR(i, 0, n)
		cmx[i] = -0x3f3f3f3f;
	init();
	
	REP(i, 0, n - 2){
		
		int x = a[i * 3 + 2], y = a[3 * i + 3], z = a[3 * i + 4];
		if(x == y && y == z){
			++dlt;
			continue;
		}
		upd.clear();
		
		p2p(x, y, z);
		p2p(x, z, y);
		p2p(y, z, x);
		
		if(x == y)
			r2r(x, z);
		if(x == z)
			r2r(x, y);
		if(y == z)
			r2r(y, x);
		r2p(x);
		r2p(y);
		r2p(z);
		
		FOR(j, 0, upd.size()){
			update(upd[j]);
		}
	}
	
	FOR(i, 0, n) FOR(j, 0, n){
		umax(ans, dp[i][j] + dlt + (i == j && i == a[3 * n - 1]));
	}
	
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 19652
n = int(input())
a = input()
b = input()
c = input()
count = 0 
for i in range(n):
    if a[i] == b[i]:
        if b[i] != c[i]:
            count += 1
    else:
        if a[i] == c[i] or b[i] == c[i]:
            count += 1
        else:
            count += 2
print(count)

Measured memory_bytes: 3064
K = gets.to_i
N = (K==1) ? 1 : (K+3)/4*2

grid = Array.new(N){Array.new(N)}
N.times do |i|
    N.times do |j|
        grid[i][j] = (i+j) % N + (j%2) * N
        grid[i][j] -= N if grid[i][j] >= K
    end
end

puts N
grid.each do |row|
    puts row.map{|a| a+1}.join(' ')
end

Measured memory_bytes: 4860