akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

long long com(long long n,long long k){
	
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	string t="CODEFESTIVAL2016";
	int ans=0;
	for(int i=0;i<16;i++){
		if(s[i]!=t[i])ans++;
	}
	cout<<ans<<endl;
}

	


Measured memory_bytes: 256
import java.util.Scanner;

class Dice{
	public int Top;
	public int Front;
	public int Right;
	public int left;
	public int Back;
	public int Bottom;

	public Dice() {
		// TODO 自動生成されたコンストラクター・スタブ
	}
	public void W() {
		int Topch = Top;
		int leftch = left;
		Top = Right;
		Right = Bottom;
		left = Topch;
		Bottom = leftch;
	}
	public void E() {
		int Topch = Top;
		int Rightch = Right;
		Top = left;
		Right = Topch;
		left = Bottom;
		Bottom = Rightch;
	}

	public void S() {
		int Topch  =Top;
		int Frontch = Front;
		Top = Back;
		Front = Topch;
		Back = Bottom;
		Bottom = Frontch;
	}

	public void N() {
		int Topch = Top;
		int Backch = Back;
		Top = Front;
		Front = Bottom;
		Back = Topch;
		Bottom = Backch;
	}


}

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

		a.Top = sc.nextInt();
		a.Front = sc.nextInt();
		a.Right = sc.nextInt();
		a.left = sc.nextInt();
		a.Back = sc.nextInt();
		a.Bottom = sc.nextInt();
		int n = sc.nextInt();
		String str = "";
		int test1,test2;

		for(int i=0;i<n;i++){
			test1 = sc.nextInt();
			test2 = sc.nextInt();

			if(test1 == a.Front){
				str = str +"N";
			}else if(test1 == a.Right){
				str = str + "W";
			}else if(test1 == a.left){
				str = str + "E";
			}else if(test1 == a.Back){
				str = str + "S";
			}else if(test1 == a.Bottom){
				str = str + "NN";
			}

			char data[] = new char[str.length()];
			data = str.toCharArray();
			for(int j=0;j<str.length();j++) {
				switch(data[j]) {
				case 'W':
					a.W();
					break;
				case'S':
					a.S();
					break;
				case'N':
					a.N();
					break;
				case'E':
					a.E();
					break;
				default:
					break;
				}
			}
			str = "";
			if(test2 == a.Right){
				str = str + "WSE";
			}else if(test2 == a.left){
				str = str + "ESW";
			}else if(test2 == a.Back){
				str = str + "SSEE";
			}
			data = str.toCharArray();
			for(int j=0;j<str.length();j++) {
				switch(data[j]) {
				case 'W':
					a.W();
					break;
				case'S':
					a.S();
					break;
				case'N':
					a.N();
					break;
				case'E':
					a.E();
					break;
				default:
					break;
				}
			}
			System.out.println(a.Right);
			
			str = "";
		}



		sc.close();
	}
}



Measured memory_bytes: 26448
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    string s;cin >> s;
    ll ans = 0;
    ll mid = 0;
    ll p = s.size();
    for(int i = 0;i < p;i++){
        if(s[i] == 'A' || s[i] == 'G' || s[i] == 'C' || s[i] == 'T'){
            mid++;
            continue;
        }
        else{
            ans = max(ans, mid);
            mid = 0;
        }
    }
    ans = max(ans,mid);
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  long long ans = 1ll<<60;
  for(int i = 0; i <= x; i++){
  	long long now = i * a;
    now += 2 * (x - i) * c;
    long long canC = min((x - i), y);
    now += (y - canC) * b;
    ans = min(ans, now);
  }
  for(int i = 0; i <= y; i++){
  	long long now = i * b;
    now += 2 * (y - i) * c;
    long long canC = min((y - i), x);
    now += (x - canC) * a;
    ans = min(ans, now);
  }
  cout << ans << endl;
  return 0;
}


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

int N;
int sum[100010] = {0};

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        int n;
        scanf("%d",&n);
        sum[n + 1]++;// 1
    }
    int ans = 0;
    for(int i = 1; i <= 100000; i++)
    {
        ans = max(ans,sum[i - 1] + sum[i] + sum[i + 1]);
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 640
A, B = map(int, input().split())
if A != 1 and B != 1 and A > B:
  	print("Alice")
elif  A != 1 and B != 1 and B > A:
    print("Bob")
elif A == B:
    print("Draw")
elif A == 1:
    print("Alice")
else:
    print("Bob")

Measured memory_bytes: 3060
package main

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

var rdr = bufio.NewReaderSize(os.Stdin, 10000)

func readLine() string {
	buf := make([]byte, 0, 10000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

type A [][]int

func (a A) Len() int           { return len(a) }
func (a A) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
func (a A) Less(i, j int) bool { return a[i][0] < a[j][0] }

func main() {
	nm := strings.Split(readLine(), " ")
	n, _ := strconv.Atoi(nm[0])
	m, _ := strconv.Atoi(nm[1])
	var ab [][]int
	for i := 0; i < n; i++ {
		abstr := strings.Split(readLine(), " ")
		a, _ := strconv.Atoi(abstr[0])
		b, _ := strconv.Atoi(abstr[1])
		ab = append(ab, []int{a, b})
	}
	sort.Sort(A(ab))
	var cost int
	for _, v := range ab {
		if m > v[1] {
			cost += v[0] * v[1]
			m -= v[1]
		} else {
			cost += v[0] * m
			break
		}
	}
	fmt.Println(cost)
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
void Main();

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i32 N;
    cin >> N;
    Vec<Vec<i32>> D(N);
    map<pair<i32, i32>, i32> e;
    for (i32 i = 0; i < N - 1; i++) {
        i32 a, b;
        cin >> a >> b;
        D[a - 1].push_back(b - 1);
        D[b - 1].push_back(a - 1);
        e.insert(make_pair(make_pair(a - 1, b - 1), i + 1));
        e.insert(make_pair(make_pair(b - 1, a - 1), i + 1));
    }
    queue<i32> q;
    Vec<bool> visited(N, false);
    q.push(0); visited[0] = true;
    Vec<i32> color(N, 0);
    Vec<i32> pre(N, 0);
    i32 max = 0;
    while (!q.empty()) {
        i32 current = q.front(); q.pop();
        i32 i;
        i32 c = 1;
        i32 e_color = 1;
        for (i = 0; i < D[current].size(); i++) {
            i32 next = D[current][i];
            if (visited[next]) continue;
            if (e_color == pre[current]) e_color++;
            color[e[make_pair(current, next)]] = e_color;
            pre[next] = e_color;
            q.push(next);
            visited[next] = true;
            e_color++;
        }
        if (i > max) max = i;
    }
    cout << max << endl;
    for (i32 i = 1; i < N; i++) {
        cout << color[i] << endl;
    }

}


Measured memory_bytes: 22268
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int n, k;
double p[maxn], sum[maxn];
int main() {
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i) {
		double x;
		scanf("%lf", &x);
		sum[i] = sum[i - 1] + x;
	}
	double ans = 0;
	for(int i = k; i <= n; ++i) {
		ans = max(ans, (sum[i] - sum[i - k] + k) / 2.0);
	}
	printf("%.10f\n", ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef set<int> si;
typedef pair<int,int> pii;
#define rep(i,a,b) for(int i=(a); i<(b); ++i)
#define per(i,a,b) for(int i=(b)-1; i>=(a); --i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int INF = 1000000007;
const int MOD = (int)1e9+7;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
int dy[4] = {-2, -1};
int dx[4] = {-1, -2};

string s;
string t;
set<ll> idx[26];

int main(void) {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("in.txt", "r", stdin);
	cin >> s >> t;
	rep(i,0,sz(s)) {
		idx[s[i]-'a'].insert(i);
	}
	ll p = 0;
	ll q = 0;
	rep(i,0,sz(t)) {
		set<ll>& cand = idx[t[i]-'a'];
		if(cand.empty()) {
			cout << -1 << endl;
			return 0;
		}
		auto it = cand.lower_bound(q);
		if(it == cand.end()) {
			p++;
			q = *(cand.begin())+1;
		} else {
			q = *it+1;
		}
	}
	cout << (ll)p*sz(s)+q << endl;
	return 0;
}


Measured memory_bytes: 5200
#include<stdio.h>

int heap[300];

int parent(int a)
{
	return a/2;
}
int left(int a)
{
	return 2*a;
}
int right(int a)
{
	return 2*a+1;
}

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

	for(i=1;i<=N;i++)
	{
		scanf("%d",&heap[i]);
	}
	for(i=1;i<=N;i++)
	{
		printf("node %d: key = %d, ",i,heap[i]);
		if(i!=1)
		{
			printf("parent key = %d, ",heap[parent(i)]);
		}
		re=left(i);
		if(re<=N)
		{
			printf("left key = %d, ",heap[re]);
		}
		re=right(i);
		if(re<=N)
		{
			printf("right key = %d, ",heap[re]);
		}
		printf("\n");
	}


	return 0;
}



Measured memory_bytes: 2108
#include<iostream>
using namespace std;
int c[10001],n,a[2000000],b[2000001],mx;
void countingsort(){
  for(int i=0;i<n;i++){
    b[c[a[i]]]=a[i];
    c[a[i]]--;
  }
}
int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i],c[a[i]]++,mx=max(mx,a[i]);
  for(int i=0;i<mx;i++)c[i+1]+=c[i];
  countingsort();
  for(int i=1;i<n;i++)cout<<b[i]<<" ";
  cout<<b[n]<<endl;
  return 0;
}

Measured memory_bytes: 16824
#include<iostream>
#include<vector>
#include <cassert>
#include<algorithm>
#include <tuple>
#include <utility>
#include<string>
#include <cmath>
#include <functional>
#define ll long long
using namespace std;

// index が条件を満たすかどうか
bool isOK(ll index, ll key, vector<ll> a) {
    if (a[index] >= key) return true;
    else return false;
}

// 汎用的な二分探索のテンプレ
int binary_search(ll key, vector<ll> a) {
    ll left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    ll right = (int)a.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()

    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1) {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key, a)) right = mid;
        else left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

char c[10][10];
char C[10][10];
char C2[10][10];

int main(){
    ll H,W,K,ans=0;
    cin >> H >> W >> K; 
    for(int i=0; i < H; i++){
        for(int j=0; j < W; j++){
            cin >> c[i][j];
            C[i][j] = c[i][j];
            C2[i][j] = c[i][j];
        }
    }

    for (int bit = 0; bit < (1<<H); ++bit) {
        vector<int> S;
        for (int i = 0; i < H; ++i) {
            if (bit & (1<<i)) S.push_back(i);
        }
        // 縦を全通り
        for (int i = 0; i < (int)S.size(); ++i) {
            for(int j=0; j < W; j++){
                C[S[i]][j] = '.';
                C2[S[i]][j] = C[S[i]][j];
            }
        }
        for (int bit2 = 0; bit2 < (1<<W); ++bit2) {
            vector<int> S2;
            for (int i = 0; i < W; ++i) {
                if (bit2 & (1<<i)) S2.push_back(i);
            }
            // 横を全通り
            for (int i = 0; i < (int)S2.size(); ++i) {
                for(int j=0; j < H; j++){
                    C[j][S2[i]] = '.';
                }
            }
            // 初期化と正解
            int tmp = 0;
            for(int i=0; i < H; i++){
                for(int j=0; j < W; j++){
                    if(C[i][j] == '#') tmp++;
                    C[i][j] = C2[i][j];
                }
            }
            if(tmp == K){
                ans++;
                // cout << bit << ": {";
                // for (int i = 0; i < (int)S.size(); ++i) {
                //     cout << S[i] << " ";
                // }
                // cout << "}" << endl;
                // cout << bit2 << ": {";
                // for (int i = 0; i < (int)S2.size(); ++i) {
                //     cout << S2[i] << " ";
                // }
                // cout << "}" << endl;
                // cout << endl;
            }
        }
        // 初期化
        for(int i=0; i < H; i++){
                for(int j=0; j < W; j++){
                    C[i][j] = c[i][j];
                    C2[i][j] = c[i][j];
                }
            }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,m,i,j,k,w[52]={0},r[52]={0},b[52]={0},MIN,sum;
	char s[51][51];
	scanf("%d %d",&n,&m);
	for(i=0;i<n;i++){
		scanf("%s",s[i]);
		for(j=0;j<m;j++){
			if(s[i][j]=='W'){
				r[i]++;
				b[i]++;
			}
			if(s[i][j]=='R'){
				w[i]++;
				b[i]++;
			}
			if(s[i][j]=='B'){
				w[i]++;
				r[i]++;
			}
		}
	}
	MIN=2600;
	for(i=0;i<n-2;i++){
		for(j=i+1;j<n-1;j++){
			sum=0;
			for(k=0;k<=i;k++){
				sum+=w[k];
			}
			for(k=i+1;k<=j;k++){
				sum+=b[k];
			}
			for(k=j+1;k<n;k++){
				sum+=r[k];
			}
			MIN=min(MIN,sum);
		}
	}
	printf("%d\n",MIN);
	return 0;
}


Measured memory_bytes: 2696
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long int>
#define vC  vector<char>
#define FastIO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

/*ll gcd(ll a, ll b)
{
    if (a == 0)
        return b;
    return gcd(b % a, a);
}*/
int main()
{
    int n,i;
    cin>>n;
    vi a(n),m(n);
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    m[0]=0;
    m[1]=abs(a[1]-a[0]);
    for(i=2;i<n;i++)
    {
        m[i]=min(abs(a[i]-a[i-1])+m[i-1],abs(a[i]-a[i-2])+m[i-2]);
    }
    cout<<m[n-1];
    return 0;

}


Measured memory_bytes: 1024
#include<stdio.h>
 
int main(){
  int x1,y1,x2,y2;
  scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
  int x=x2-x1, y=y2-y1;
  printf("%d %d %d %d\n",x2-y,y2+x,x1-y,y1+x);
  return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:
const int limit = 5010;
const int inf = 1 << 20;
vector<int> tree[limit];

int x[limit],y[limit];
int dp[limit][limit];


void dfs(int v,int cnt){
	
	if(tree[v].size()==0){
		dp[v][x[v]]=0;
		dp[v][0]=x[v];
		return;
	}

	dp[v][0] = 0;

	int nxt[limit];

	for(auto &v2:tree[v]){
		dfs(v2,v);	
		rep(i,limit) nxt[i] = inf;

		rep(i,limit){
			if(dp[v][i]==inf) continue;
			if(i+x[v2]<limit) chmin(nxt[i+x[v2]],dp[v][i]+y[v2]);
			if(i+y[v2]<limit) chmin(nxt[i+y[v2]],dp[v][i]+x[v2]);
		}

		rep(i,limit) dp[v][i]=nxt[i];
	}

	y[v]=inf;
	rep(i,x[v]+1) chmin(y[v],dp[v][i]);
	return ;
}


int main(void){
	int n;
	cin >> n;

	rep(v,1,n){
		int p;
		cin >> p;
		tree[p-1].push_back(v);
	}

	rep(i,n) cin >> x[i];

	
	rep(i,n)rep(j,limit+1) dp[i][j]=inf;

	dfs(0,-1);

	bool ok = false;
	rep(i,x[0]+1) if(dp[0][i]!=inf) ok = true;

	if(ok)
		puts("POSSIBLE");
	else
		puts("IMPOSSIBLE");

	return 0;
}

Measured memory_bytes: 29312
#include <iostream>
#include <vector>
#include <cstdlib>
using namespace std;
typedef long long ll;

int main(){
  int N;
  cin >> N;
  vector<ll> a(N);
  for(int i = 0;i < N;i++)cin >> a[i];

  vector<ll> sums(N);
  sums[0] = a[0];
  for(int i = 1;i < N;i++)sums[i] = sums[i-1] + a[i];

  ll sum_all = sums[N-1];

  ll ans = 1e15;

  for(int i = 0;i < N - 1;i++){
    ll left = sum_all - sums[i];
    ll abs_ = max(left - sums[i],sums[i] - left);
    ans = min(abs_,ans);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3328
#include<stdio.h>
int main(){
	int HP,damage;
	scanf("%d %d", &HP, &damage);
	if((HP%damage==0)&&(HP>damage)) printf("%d\n", HP/damage);
	else if((HP%damage!=0)&&(HP>damage)) printf("%d\n", HP/damage+1);
	else if(damage<=damage) printf("1\n");
	return 0;
}

Measured memory_bytes: 1704
#include<bits/stdc++.h>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std; 
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long int ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template<class T> void chmax(T & a, const T & b) { a = max(a, b); }
template<class T> void chmin(T & a, const T & b) { a = min(a, b); }
////////////////////////////////////////////////////////////////////

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);  
  cout.tie(NULL);
  int n;
  cin>>n;
  int h=0;
  h+=(int)(n/500)*1000;
  n-=(n/500)*500;
  h+=(int)(n/5)*5;
  cout<<h<<"\n";
  return 0;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n;
	cin >> n;
	map<string, int> mp;
	rep(i, n) {
		string a;
		cin >> a;
		mp[a]++;
	}
	int m;
	cin >> m;
	rep(i, m) {
		string b;
		cin >> b;
		mp[b]--;
	}
	int ma = 0;
	for (auto m : mp) {
		chmax(ma, m.second);
	}
	out(ma);

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
bool check(vector<int> &s, int N)
{
    int p = 0;
    for (int i = 0; i < N; i++) {
        p += s[i];
        if (p < 0) {
            return 0;
        }
    }
    return (p == 0);
}
  
int main()
{
    int N;
    string str;
    cin >> N;
    vector<int> s(N);
    for (int i = 0; i < N; i++) {
        cin >> str;
        if (str == "A") {
            s[i] = +1;
        } else {
            s[i] = -1;
        }
    }
    cout << (check(s, N) ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
using namespace std;

int main() {
  int N,M;
  cin>>N>>M;
  
  vector<int> b(M+1);
  
  for(int i=0;i<N;++i){
    int K;
    cin>>K;
    vector<int> a(K);
    for(int j=0;j<K;++j){
      cin>>a[j];
      ++b[a[j]];
    }
  }
  
  int ans=0;
  for(int i=1;i<=M;++i){
    if(b[i]==N)
      ++ans;
  }
  
  cout<<ans<<endl;
  
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e3+7;
ll xx[maxn],yy[maxn],zz[maxn];
int main()
{
	int x,y,z,k;cin>>x>>y>>z>>k;
	for(int i=0;i<x;i++) scanf("%lld",&xx[i]);
	for(int i=0;i<y;i++) scanf("%lld",&yy[i]);
	for(int i=0;i<z;i++) scanf("%lld",&zz[i]);
	//cout<<1<<endl;
	vector<ll> v,v1;
	for(int i=0;i<x;i++)
	for(int j=0;j<y;j++) v.push_back(-xx[i]-yy[j]);//,cout<<(xx[i]+yy[j])<<endl;
	sort(v.begin(),v.end());//cout<<v[0]<<endl<<endl;
	for(int i=0;i<min(k,x*y);i++)
	for(int j=0;j<z;j++)
	{
		v1.push_back(v[i]-zz[j]);
	}
	int t=min(k,x*y*z);
	sort(v1.begin(),v1.end());
	for(int i=0;i<t;i++)
	{
		cout<<-v1[i]<<endl;
	}
 } 

Measured memory_bytes: 43364
import  heapq

ans = 0
n, m = map(int, input().split())

memo = [[] for _ in range(10**5)]
for _ in range(n):
    a, b = map(int, input().split())
    memo[a-1].append(-b)

pq = []

for i in range(m):
    for j in memo[i]:
        heapq.heappush(pq,j)
    if len(pq):
        ans += -heapq.heappop(pq)

print(ans)

Measured memory_bytes: 17856
#include <iostream>
#include <cstdlib>
#include <vector>

using namespace std;

int main() {
  int n, m;
  vector<int> costs;
  vector<int> votes;
  cin >> n >> m;

  for( int i = 0; i < n; i++ ) {
    int c;
    cin >> c;
    costs.push_back( c );
    votes.push_back( 0 );
  }
  
  for( int j = 0; j < m; j++ ) {
    int t;
    cin >> t;
    for( int i = 0; i < n; i++ ) {
      if( costs[ i ] <= t ) { 
        votes[ i ]++;
        break;
      }
    }
  }
  
  int maxidx = 0;
  for( int i = 1; i < n; i++ ) {
    if( votes[ i ] > votes[ maxidx ] ) {
      maxidx = i;
    }
  }

  cout << maxidx + 1 << endl;

  return EXIT_SUCCESS;
}

Measured memory_bytes: 1228
#include<iostream>
#include<cmath>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<string>
using namespace std;
#define ll long long
#define ull unsigned long long
#define l long
#define xx 1000000007
#define max 1000
int main()
{ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n,k;
cin>>n>>k;
int a[n];
for(int i=1;i<=n;i++)cin>>a[i];
//for(int i=1;i<=n;i++)cout<<a[i]<<" ";
int sum[n];
sum[1]=0;


//cout<<sum[2]<<" "<<sum[3]<<" ";
for(int i=2;i<=n;i++)
{int curr_min=sum[i-1]+abs(a[i]-a[i-1]);
	
	for(int j=i-2;j>=1&&j>=i-k;j--)
	{
		curr_min=min(curr_min,sum[j]+abs(a[i]-a[j]));
	}

sum[i]=curr_min;
//cout<<sum[i]<<" ";
}cout<<sum[n];

}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;
typedef pair<int, int> i_i;

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define REP(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
const ll mod = 1e9+7;
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; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

int B[5001][26];
int lower[200001];
int upper[200001];
int ketamod[200001];
int cnt[10001];
int main() {
    int N, P;
    string S;
    cin >> N >> P;
    cin >> S;
    reverse(ALL(S));
    ll ans = 0;
    if (P == 2 || P == 5){
        rep(i, N){
            if ((S[i] - '0') % P == 0){
                ans += N - i;
            }
        }
        cout << ans;
        return 0;
    }
    
    int num = 0;
    lower[0] = 0;
    cnt[0]++;
    rep(i, N){
        if (i == 0){
            ketamod[i] = 1;
        } else {
            ketamod[i] = (ketamod[i - 1] * 10)%P;
        }
        lower[i + 1] = (lower[i] + (S[i] - '0') *  ketamod[i])%P;
        
        ans += cnt[lower[i + 1]];
        
        cnt[lower[i + 1]]++;
        //cout << i << " lower: " << lower[i] << endl;
        
    }
    cout << ans;
    return 0;
    //cout << N << " lower: " << lower[N] << endl;
    upper[N - 1] = lower[N];
    
    //rep(i, P)
    //    cout << "cnt[" << i << "]" << cnt[i] << endl;
    
    //cout << N - 1<< " upper: " << upper[N - 1] << endl;
    //cout << "ans = " << cnt[upper[N - 1]] << endl;
    cnt[lower[N]]--;
    
    ans += cnt[upper[N - 1]];
    cnt[lower[N - 1]]--;
    for (int i = N - 1; i >= 1; i--){
        int tmp = ((S[i] - '0')* ketamod[i])%P;
        upper[i - 1] = (upper[i] + P - tmp)%P;
        // upper[i] = (upper[i + 1] + P - S[i + 1] * ketamod[i + 1])%P;
        //cout << i << " upper: " << upper[i] << endl;
        ans += cnt[upper[i - 1]];
        cnt[lower[i - 1]]--;
        
        //cout << "ans = " << cnt[upper[i]] << endl;
        
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 2180
from collections import deque, Counter as cnt
from collections import defaultdict as dd
from operator import itemgetter as ig
from bisect import bisect_right as bsr
from math import factorial, ceil, floor
import sys
sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def nlist(n, v):
    if not n:
        return [] if type(v) is list else v
    return [nlist(n[1:], v) for _ in range(n[0])]


# エントリーポイント
def main():
    N, M = input(int, int)
    print(N * (N - 1) // 2 + M * (M - 1) // 2)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vec_input(v) for(auto it=v.begin();it!=v.end();it++){cin>>*it;}
#define vec_debug(v) for(auto it=v.begin();it!=v.end();it++){cerr<<*it<<" ";}cerr<<endl;
#define yn(ans) cout<<(ans?"Yes":"No")<<endl
#define YN(ans) cout<<(ans?"YES":"NO")<<endl
using namespace std;
using ll = long long;
template <typename T>T digitsum(T n);
template <typename T>bool isPrime(T n);
template <typename T>vector<pair<T, T>> prime_factor(T n);
long long int intpow(long long int,long long int);
template <typename T>T intlog(T);
long long int combination(long long int,long long int);
long long int series_sum(long long int);

int main(){
    ll ans,i,x;
    for(i=1;i<=5;i++){
        cin>>x;
        if(x==0)ans=i;
    }
    cout<<ans<<endl;
}

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

int main() {
  
  int X=0, A=0, B=0;
  
  cin >> X >> A >> B;
  
  int cul = X - A;
  int rest = cul % B;
  
  cout << rest << endl;
  
  return 0;
  
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> p(n),x(m),y(m);
  rep(i,n){
    cin >> p[i];
    p[i]--;
  }
  vector<int> uf(n);
  rep(i,n)uf[i] = INF;
  rep(i,m){
    cin >> x[i] >> y[i];
    x[i]--;y[i]--;
    int rootx = x[i], rooty = y[i], stepx = 0, stepy = 0;
    while(uf[rootx]!=rootx && uf[rootx] != INF){
      stepx++;
      rootx = uf[rootx];
    }
    while(uf[rooty]!=rooty && uf[rooty] != INF){
      stepy++;
      rooty = uf[rooty];
    }
    if(rootx != rooty || (uf[rootx]==INF && uf[rooty]==INF)){
      if(uf[rooty]==INF && uf[rootx]==INF){
        uf[x[i]] = x[i];
        uf[y[i]] = x[i];
      }else if(uf[rooty]!=INF && uf[rootx]==INF){
        uf[x[i]] = rooty;
      }else if(uf[rootx]!=INF && uf[rooty]==INF){
        uf[y[i]] = rootx;
      }else{
        if(stepx>stepy)uf[rooty] = rootx;
        else uf[rootx] = rooty;
      }
    }
  }
  int ans = 0;
  rep(i,n){
    if(p[i]==i){
      ans++;
      continue;
    }
    if(uf[i]==INF || uf[p[i]]==INF)continue;
    int pi = p[i];
    while(uf[pi] != pi)pi = uf[pi];
    int ii = i;
    while(uf[ii] != ii)ii = uf[ii];
    if(pi == ii)ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4808
// "7 3"
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  var splitInput = input.split(" ");

  var a = parseInt(splitInput[0], 10);
  var b = parseInt(splitInput[1], 10);

  if (a % b !== 0) {
    console.log(1);
  } else {
    console.log(0);
  }
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const long long INF = 1LL << 60;

int main() {
    int N, cnt = 1; cin >> N;
    int m = 1000000;
    for (int i = 0; i < N; i++) {
        int x; cin >> x;
        if (x < m) {
            m = x;
            if (i == 0) continue;
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#define DEBUG(x) std::cout << '>' << #x << ':' << x << '\n';
#define PRINTVEC(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i] << ' '; std::cout << '\n';
#define PRINTPAIR(x) for (int i = 0; i < (int)x.size(); i++) std::cout << x[i].first << ' ' << x[i].second << '\n'; std::cout << '\n';
#define PRINTSET(x) for (auto it = x.begin(); it != x.end(); it++) { std::cout << *it << ' '; } std::cout << '\n';
#define io std::ios_base::sync_with_stdio(false);std::cin.tie(NULL);   
const int INF = 1<<29;
typedef long long ll;
using namespace std;


int main()
{
	io;
    #ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);  
    #endif

    int m,n,x;
    cin >> n >> m;
    int sum = 0;
    for (int i = 0; i < m; i++) {
        cin >> x ;
        sum += x;
    }
    cout << (n < sum ? -1 : n - sum);

    #ifndef ONLINE_JUDGE   
    //std::cout << '\n' << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    #endif
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<sstream>
#include<fstream>
#include<algorithm>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<cctype>
#include<vector>
#include<string>
#include<cmath>
#include<ctime>
#include<stack>
#include<queue>
#include<map>
#include<set>
#define mem(a,b) memset(a,b,sizeof(a))
#define random(a,b) (rand()%(b-a+1)+a)
#define ll long long
#define ull unsigned long long
#define e 2.71828182
#define Pi acos(-1.0)
#define ls(rt) (rt<<1)
#define rs(rt) (rt<<1|1)
#define lowbit(x) (x&(-x))
using namespace std;
int read()
{
	int s=1,x=0;
	char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') s=-1;ch=getchar();}
	while(isdigit(ch)) {x=10*x+ch-'0';ch=getchar();}
	return x*s;
}
int main()
{
	int n=read();
	if(n%2==0) cout<<"0.5000000000";
	else	printf("%.10f",double(n/2+1)/double(n));
}


Measured memory_bytes: 256
from collections import deque

INF = float("inf")

H, W, K = map(int, input().split())
A = [list(input()) for _ in range(H)]

Si, Sj = (0, 0)
for i, a in enumerate(A):
    if "S" in a:
        Si, Sj = (i, a.index("S"))
        A[Si][Sj] = "c"
        break

distance = INF

Q = deque([(0, Si, Sj)])
while Q:
    cnt, i, j = Q.popleft()

    distance = min(distance, i, j, H - i - 1, W - j - 1)
    if distance == 0:
        break

    if cnt >= K:
        continue

    for ni, nj in ((i + 1, j), (i, j + 1), (i - 1, j), (i, j - 1)):
        if 0 <= ni < H and 0 <= nj < W and A[ni][nj] == ".":
            A[ni][nj] = "c"
            Q.append((cnt + 1, ni, nj))

print(-(-distance // K) + 1)


Measured memory_bytes: 9204
N = gets.to_i
array = gets.split.map(&:to_i).sort.reverse

if N % 2 == 1 then
  array.push(0)
end
  
sli = array.each_slice(2).to_a
ali = sli.map{|i| i[0] }
bob = sli.map{|i| i[1] }
  
ans = ali.inject(:+) - bob.inject(:+)
  
p ans

Measured memory_bytes: 3836
import java.util.Scanner;

class Main
{
    public static void main(String args[])
    {
        Scanner scan = new Scanner(System.in);
        
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        
        if(a<b&&b<c){
        System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


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

main () {
  //どう見ても2以上の数字は無限大に発散するため、
  //先頭から1がいくつあるかが勝負になる。
  char s[101];
  ll k;
  scanf("%s %lld", s, &k);

  int i = 0;
  while(s[i] == '1') i++;

  if ((i >= k) || (s[i] == '\0')) {
    printf("1\n");
  }
  else {
    printf("%d\n", (int)(s[i]-'0'));
  }

  return 0;
}


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

struct NODE {
	char body[11];
	int  time;
	int  hash;
	struct NODE *next;
};

struct NODE *head;
struct NODE *tail;

int node_num = 0;

int change_worm(char *worm);	
void add_node(char *worm, int time);
int calc_hash(char *worm);
int change_color(struct NODE *node);
int check_body(char *worm);
int check_hash(int hash);
void free_node(void);

int main(void)
{
	char worm[11];
	int time;

	
	while (1){
		scanf("%s", worm);
		
		if (worm[0] == '0'){
			break;
		}
		time = change_worm(worm);
		if (time == -1){
			printf("NA\n");
		}
		else {
			printf("%d\n", time);
		}
		node_num = 0;
		
		free_node();
	}
	return (0);
}

int change_worm(char *worm)	
{
	struct NODE *node;
	int time;
	
	add_node(worm, 0);
	
	node = head;
	
	while (node != NULL){
//		printf("-->%d %s\n", node->time, node->body);
		time = change_color(node);
		if (time >= 0){
			return (time);
		}
		node = node->next;
	}
	return (-1);
}

void add_node(char *worm, int time)
{
	struct NODE *node;
	int hash;
	int i;
	
	node = malloc(sizeof(struct NODE));
	
	strcpy(node->body, worm);
	node->time = time;
	node->hash = calc_hash(node->body);
	node->next = NULL;
	
	if (head == NULL){
		head = tail = node;
	}
	else {
		tail->next = node;
		tail = node;
	}
//printf("<%d>\n", ++node_num);
//	printf("[%d  %s]\n", time, worm);
}
	
int calc_hash(char *worm)
{
	int hash;
	int i;
	
	hash = 0;
	i = 0;
	while (worm[i] != '\0'){
		hash *= 3;
		switch (worm[i]){
		  case 'r':
		    break;
			
		  case 'g':
		    hash++;
			break;
			
		  case 'b':
			hash += 2;
			break;
		}
		i++;
	}
	
	return (hash);
}

int change_color(struct NODE *node)
{
	int i;
	char new_worm[11];
	int hash;
	
	if (check_body(node->body) == 1){
		return (node->time);
	}

	i = 0;
	while (node->body[i + 1] != '\0'){
		if (node->body[i] != node->body[i + 1]){
			strcpy(new_worm, node->body);
			if (new_worm[i] != 'r' && new_worm[i + 1] != 'r'){
				new_worm[i] = new_worm[i + 1] = 'r';
			}
			else if (new_worm[i] != 'g' && new_worm[i + 1] != 'g'){
				new_worm[i] = new_worm[i + 1] = 'g';
			}
			else if (new_worm[i] != 'b' && new_worm[i + 1] != 'b'){
				new_worm[i] = new_worm[i + 1] = 'b';
			}
			
			if (check_body(new_worm) == 1){
				return (node->time + 1);
			}
			
			if (check_hash(calc_hash(new_worm)) == 1){
				add_node(new_worm, node->time + 1);
			}
		}
		i++;
	}
	
	return (-1);
}

int check_body(char *worm)
{
	int i;
	char first;
	
	first = worm[0];
	i = 1;
	while (worm[i] != '\0'){
		if (worm[i] != first){
			return (0);
		}
		i++;
	}
	
	return (1);
}

int check_hash(int hash)
{
	struct NODE *node;
	
	node = head;
	
	while (node != NULL){
		if (node->hash == hash){
//			printf("<<found>>\n");
			return (0);
		}
		node = node->next;
	}
	return (1);
}

void free_node(void)
{
	struct NODE *node;
	struct NODE *del_node;
	
	node = head;
	
	while (node->next != NULL){
		del_node = node;
		node = node->next;
		free(del_node);
	}
	head = tail = NULL;
}
		
		

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

Measured memory_bytes: 592
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    char op;
    while(true){
        cin>>a>>op>>b;
        if(op=='?'){
            break;
        }
        if(op=='+'){
            cout<<(a+b)<<endl;
        }
        if(op=='-'){
            cout<<(a-b)<<endl;
        }
        if(op=='*'){
            cout<<(a*b)<<endl;
        }
        if(op=='/'){
            cout<<(a/b)<<endl;
        }
    }
}



Measured memory_bytes: 3100
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;
int n;
int a[110];
int ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",a+i);
	for(int i=2;i<=n;i++)
	{
		if(a[i]==a[i-1])
		{
			ans++;
			i++;
		}
	}
	printf("%d",ans);
	return 0;
} 

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

int main(){
    int A[101][101],r,c; 
    cin >> r >> c;
    for (int i = 0; i < r; i++){
        for (int j = 0; j < c; j++){
            cin >> A[i][j];
        }
    }
    for (int i = 0; i <= r; i++){A[i][c] = 0;
    for (int j = 0; j <= c; j++){A[r][j] = 0;
        }
    }
    A[r][c] = 0;

    for (int i = 0;i < r;i++){
        for (int j = 0; j < c; j++){
            A[i][c] += A[i][j];
            A[r][j] += A[i][j];
            A[r][c] += A[i][j];
        }
    }

    for (int i = 0; i <= r; i++){
        for (int j = 0;j <= c;j++){
            if(j)cout << " ";
            cout << A[i][j];
        }
        cout << endl;
    }
return 0;
}


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

int main(){
  ios::sync_with_stdio(0),cin.tie(0);
  int n,x;
  cin>>n>>x;
  int m=2*n-1;
  if(x==1||x==m){
    cout<<"No\n";
    return 0;
  }
  cout<<"Yes\n";
  for(int i=0;i<m;++i){
    cout<<(m-n+x+i)%m+1<<' ';
  }
}


Measured memory_bytes: 1536
import sys
sys.setrecursionlimit(200000)

n = int(input())
edge = [[[] for i in range(2)] for j in range(n)]
dp = [-1] * n
for i in range(n - 1):
    a, b, c = map(int, input().split())
    edge[a - 1][0].append(b - 1)
    edge[a - 1][1].append(c)
    edge[b - 1][0].append(a - 1)
    edge[b - 1][1].append(c)


def distance(x, prev, d):
    dp[x] = d
    for i, j in zip(edge[x][0], edge[x][1]):
        if i == prev:
            continue
        if dp[i] != -1:
            continue
        distance(i, x, d + j)
    return

q, k = map(int, input().split())
k -= 1

ans = []
distance(k, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    ans.append(dp[x - 1] + dp[y - 1])

for i in range(q):
    print(ans[i])

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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

int x, a, b;

int main() {
    cin >> x >> a >> b;
    if (abs(x-a) > abs(x-b)) cout << "B" << endl;
    else cout << "A" << endl;
}

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

#define MAX_N 1000

using namespace std;

int n, k;

int c[MAX_N + 1];

int main()
{
    cin >> k;

    if(k <= 500)
    {
        cout << k << "\n";
        for(int i = 1; i <= k; i ++)
        {
            for(int j = 1; j <= k; j ++)
                cout << j << " ";
            cout << "\n";
        }

        return 0;
    }

    int n = ((k >> 2) << 1);
    if((n << 1) < k)
        n += 2;

    for(int i = 0; i < (n << 1); i ++)
        c[i] = i;

    int last = (n << 1) - 1;
    while(last >= 0 && last + 1 > k)
    {
        c[last] -= n;
        last --;
    }

    cout << n << "\n";
    for(int i = 0; i < n; i ++)
    {
        for(int j = 0; j < n; j ++)
        {
            if((i & 1) == 0)
                cout << c[(i + j) % n] + 1 << " ";

            else
                cout << c[n + (i + j) % n] + 1 << " ";
        }

        cout << "\n";
    }

    return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>

void main(){
  int N;

  scanf("%d",&N);

  int i, a[N],cnt=0;

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

  /* for(i = 0; i < N; i++)
    printf("%d ",a[i]);
    printf("\n");*/

  for(i = 0; i < N-1; i++){
    if(a[i] == a[i+1]){
      cnt++;
      i++;
    }
  }
  printf("%d\n",cnt);
}

Measured memory_bytes: 128
S = input()

check = True
for i, s in enumerate(S):
  if (i+1)%2 == 0:
    if not(s == "L" or s == "U" or s == "D"):
      check = False
  else:
    if not(s == "R" or s == "U" or s == "D"):
      check = False

if check:
  print("Yes")
else:
  print("No")

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

void Main()
{
    int n, d, x;
    cin >> n >> d >> x;
    vint a(n);
    rep(i, n) cin >> a[i];

    int ans = x;
    rep(i, n)
    {
        int day = 1;
        while (day <= d)
        {
            ++ans;
            day += a[i];
        }
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut vec: Vec<u32> = Vec::new();
    for _ in 0..3 {
        vec.push(read());
    }
    vec.sort();
    println!("{} {} {}", vec[0], vec[1], vec[2])
}



Measured memory_bytes: 5020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
    int A, B;
    cin >> A >> B;
    int AB = A*B;
    if(AB%2==1)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#define INF 1000000000;

using namespace std;
typedef pair<int, int> P;

const int MAX_N=1<<18;

int m, dato[2*MAX_N-1], date[2*MAX_N-1];

void init(int m_){
	m=1;
	while(m<m_) m*=2;
	for(int i=0; i<2*m-1; i++){
		dato[i]=INF;
		date[i]=INF;
	}
}

void update1(int k, int a){
	k+=m-1;
	dato[k]=a;
	while(k>0){
		k=(k-1)/2;
		dato[k]=min(dato[k*2+1], dato[k*2+2]);
	}
}

void update0(int k, int a){
	k+=m-1;
	date[k]=a;
	while(k>0){
		k=(k-1)/2;
		date[k]=min(date[k*2+1], date[k*2+2]);
	}
}

int query1(int a, int b, int k, int l, int r){
	if(r<=a || b<=l) return INF;
	if(a<=l && r<=b){
		return dato[k];
	}else{
		int vl=query1(a, b, k*2+1, l, (l+r)/2);
		int vr=query1(a, b, k*2+2, (l+r)/2, r);
		return min(vl, vr);
	}
}

int query0(int a, int b, int k, int l, int r){
	if(r<=a || b<=l) return INF;
	if(a<=l && r<=b){
		return date[k];
	}else{
		int vl=query0(a, b, k*2+1, l, (l+r)/2);
		int vr=query0(a, b, k*2+2, (l+r)/2, r);
		return min(vl, vr);
	}
}

int main()
{
	int n;
	scanf("%d", &n);
	int p;
	int p1[200001];
	init(n/2+1);
	for(int i=1; i<=n; i++){
		scanf("%d", &p);
		p1[p]=i;
		if(i%2==1){
			update1((i+1)/2, p);
		}else{
			update0(i/2, p);
		}
	}
	vector<int> ans;
	map<int, P> mp;
	mp[query1(1, n/2+1, 0, 0, m)]=P(1, n+1);

	for(int i=0; i<n/2; i++){
		auto itr=mp.begin();
		int m0=itr->first;
		ans.push_back(m0);
		P p0=itr->second;
		int x1=p0.first;
		int x2=p0.second;
		mp.erase(itr);
		if(p1[m0]%2==0){
			int m1=query1((p1[m0]+2)/2, (x2+2)/2, 0, 0, m);
          
			ans.push_back(m1);
			if(p1[m0]-x1>1){
				mp[query0(x1/2, p1[m0]/2, 0, 0, m)]=P(x1, p1[m0]);
			}
			if(p1[m1]-p1[m0]>1){
				mp[query1((p1[m0]+2)/2, (p1[m1]+1)/2, 0, 0, m)]=P(p1[m0]+1, p1[m1]);
			}
			if(x2-p1[m1]>1){
				mp[query0((p1[m1]+1)/2, x2/2, 0, 0, m)]=P(p1[m1]+1, x2);
			}
          
		}else{
			int m1=query0((p1[m0]+1)/2, (x2+1)/2, 0, 1, m);
			ans.push_back(m1);
			if(p1[m0]-x1>1){
				mp[query1((x1+1)/2, (p1[m0]+1)/2, 0, 1, m)]=P(x1, p1[m0]);
			}
			if(p1[m1]-p1[m0]>1){
				mp[query0((p1[m0]+1)/2, (p1[m1]+1)/2, 0, 1, m)]=P(p1[m0]+1, p1[m1]);
			}
			if(x2-p1[m1]>1){
				mp[query1((p1[m1]+2)/2, (x2+1)/2, 0, 1, m)]=P(p1[m1]+1, x2);
			}
          
		}
	}
	for(int i=0; i<n; i++){
		printf("%d ", ans[i]);
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 8692