akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define pb push_back
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

signed main(){
	fast;
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	int dp[n];
	dp[0]=0;
	dp[1]=abs(h[0]-h[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1];
	return 0;
}



Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using int64 = long long;

map< int64, int64 > prime_factor(int64 n)
{
    map< int64, int64 > ret;
    for(int64 i = 2; i * i <= n; i++){
        while(n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if(n != 1) ret[n] = 1;
    return(ret);
}
int main(){
    ll n,p;
    cin >> n >> p;
    auto mp = prime_factor(p);
    ll ans = 1;
    for(auto x:mp){
        if(x.second>=n){
            rep(i,x.second/n){
                ans *= x.first;
            }
        }
    }
    cout << ans << endl;
}

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

const int MOD = 1e9 + 7;
const int MAX_N = 2010;

long long C[MAX_N][MAX_N];

void Combintation(){
    for (int i = 0; i < MAX_N; i++){
        C[i][0] = 1;
        C[i][i] = 1;
    }
    
    // C(n, m) = C(n - 1, m - 1) + C(n - 1, m)
    for (int i = 2; i < MAX_N; i++){
        for (int j = 1; j <= i; j++){
            C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % MOD;
        }
    }
}

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

    int n, k;
    cin >> n >> k;

    for (int i = 0; i < k; i++){
        cout << (C[n - k + 1][i + 1] * C[k - 1][i]) % MOD << '\n';
    }

    return 0;
}


Measured memory_bytes: 30336
from itertools import combinations
N, M, X = map(int, input().split())
books = []
for _ in range(N):
    books.append(list(map(int, input().split())))
P = []
for i in range(1, N+1):
    for item in list(combinations(books, i)):
        P.append(item)
ans = 10 ** 9 + 1
for items in P:
    price = 0
    chk = [0] * M
    for p in items:
        price += p[0]
        for i, item in enumerate(p[1:]):
            chk[i] += item
        if all(c >= X for c in chk):
            ans = min(ans, price)
            break
if ans == 10 ** 9 + 1:
    ans = -1
print(ans)

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

int main() {
  long a,b,n,ans=0;
  cin >> a >> b >> n;
  if(b>n) {
    ans=n*a/b;
  } else {
    ans=(b-1)*a/b;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main(){
    string s;
    cin >> s;
    if(s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
}

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

#define endl "\n"
#define INF (int) 9e18
#define HELL (int) (1e9 + 7)
#define int long long
#define double long double
#define uint unsigned long long
#define deb(x) cerr << #x << " => " << x << "\n"
#define deba(x) cerr << #x << "\n"; for (auto a : x) cerr << a << " "; cerr << "\n";
#define debm(x) cerr << #x << "\n"; for (auto a : x){for(auto b : a) cerr << b << " "; cerr << "\n";}
#define getMat(x, n, m, val) vector<vector<int>> x(n, vector<int> (m, val))
#define fastio ios_base :: sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define pout cout << fixed << setprecision(10)
int fastpow(int a, int b, int m) {
    int res = 1; a %= m; while (b > 0) { if (b & 1) res = (res * a) % m;
    a = (a * a) % m; b >>= 1; } return res;}
#define inv(a) fastpow(a, HELL - 2, HELL)
#define size(a) (int) a.size()

int32_t main() { fastio;
	int n; cin >> n;
	int sum = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 != 0 and i % 5 != 0) {
			sum += i;
		}
	}
	cout << sum << endl;
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string s;
	cin >> s;
	cout << s;
	if (s[s.length() - 1] == 's') {
		cout << "es" << endl;
	}
	else {
		cout << "s" << endl;
	}
	return 0;
}


Measured memory_bytes: 3616
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace Atcoder
{
    class aaaa
    {
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            char[] Schar = S.ToCharArray();

            Schar[3] = '8';

            Console.WriteLine(Schar);
        }
    }
}

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

int main()
{
    int k;
    string s;

    cin >> k >> s;

    if (s.length() <= k)
    {
        cout << s << endl;
    }
    else
    {
        cout << s.substr(0, k) << "..." << endl;
    }

    return 0;
}

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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL


int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int x,y;
	cin >> x >> y;
	if(x%y == 0) {
		cout << -1;
	} else {
		cout << x;
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

LL t[100005];

int main(){
	int n;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>t[i];
	}
	b=0,c=0;
	for(i=0;i<2;i++){
		a=0;
		for(j=0;j<n;j++){
			a+=t[j];
			if((i+j)%2==0){
				if(a>=0)b+=a+1,a=-1;
			}else if(a<=0)b+=-a+1,a=1;
		}
		swap(b,c);
	}
	if(b>c)b=c;
	cout<<b<<endl;
}

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

int main(){
    int flag;
    int ans=0;
    int a,b;
    cin >> a>>b;

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout << ans << endl;

    if(a*b%2==0)flag=0;
    else flag=1;

    if(flag==1)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int N = scanner.nextInt();
		int square = 0;
		int max = 1;

		for (int i = 1; i < N; i++) {
			square = i * i;
			if (square > N) {
				break;
			}
			max = square;
		}
		System.out.println(max);
	}

}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll a,b,c;
    cin>>a>>b>>c;
    if(a%2||b%2||c%2){cout<<0;return 0;}
    if(a==b&&b==c) cout<<-1;
    else{
        ll ans=0;
        while(!(a%2)&&!(b%2)&&!(c%2)){
            ll x=(a+b)/2,y=(b+c)/2,z=(c+a)/2;
            a=x,b=y,c=z;
            ans++;
        }
        cout<<ans;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int  k,n;
    cin >>k>>n;
    vector<int> vec(n);
    for (int i = 0; i < n; i++) {
        cin >> vec.at(i);
        
    }
    int Max=0;
    for(int i=1;i<n;i++){
        Max=max(Max,vec.at(i)-vec.at(i-1));
    }
    Max=max(Max,vec.at(0)+k-vec.at(n-1));

    cout << k-Max<<endl;
   
    
}

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

typedef long long ll;

const int N = 3e5 + 5, md = 1e9 + 7;

inline int add(int x, int y) {
    x += y;
    if(x >= md) x -= md;
    return x;
}

inline int mul(int x, int y) { return 1ll * x * y % md; }

ll a[N];
int n, ans;

int main() {
   
  
  cin>>n;
for(int i = 1; i <= n; i++)
	cin>>a[i];

 
 for(int j = 0; j < 60; j++) {
	 int cnt = 0;
        for(int i = 1; i <= n; i++)
		cnt += ((a[i]>>j)&1);
	ans = add (ans , mul((1LL << j) %md , mul(cnt,n-cnt)));
}

cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>
int main(void)
{
	int i,j,h,w;
	scanf("%d %d",&h,&w);
	while(h!=0 && w!=0) {
		for(i=1;i<=h;i++) {
			for(j=1;j<=w;j++) {
				printf("#");
			}
			printf("\n");
		}
		printf("\n");
	scanf("%d %d",&h,&w);
	}
	return 0;
}

Measured memory_bytes: 572
import Numeric
main = do
    str <- getLine
    let (a:b:_) = map read $ words str
    let (d,r) = quotRem a b
    let f = fromIntegral a / fromIntegral b
    putStr $ show d
    putChar ' '
    putStr $ show r
    putChar ' '
    putStr $ showFFloat Nothing f ""
    putChar '\n'

Measured memory_bytes: 4064
fun min(a: Long, b: Long, c: Long) = Math.min(a, Math.min(b, c))

fun max(a: Long, b: Long, c: Long) = Math.max(a, Math.max(b, c))

fun main(args: Array<String>) {
    val (h, w) = readLine()!!.split(' ').map(String::toLong)
    if (h % 3 == 0L || w % 3 == 0L) {
        println(0)
        return
    }
    val hhalf = h shr 1
    val d1 = (1 until w).map { x ->
        val wx = w - x
        val wxhalf = wx shr 1
        val s1 = x * h
        val s2 = wx * hhalf
        val s3 = wx * (h - hhalf)
        val s4 = wxhalf * h
        val s5 = (wx - wxhalf) * h
        Math.min(max(s1, s2, s3) - min(s1, s2, s3), max(s1, s4, s5) - min(s1, s4, s5))
    }.min()!!
    val whalf = w shr 1
    val d2 = (1 until h).map { y ->
        val hy = h - y
        val hyhalf = hy shr 1
        val s1 = y * w
        val s2 = hy * whalf
        val s3 = hy * (w - whalf)
        val s4 = hyhalf * w
        val s5 = (hy - hyhalf) * w
        Math.min(max(s1, s2, s3) - min(s1, s2, s3), max(s1, s4, s5) - min(s1, s4, s5))
    }.min()!!
    println(Math.min(d1, d2))
}


Measured memory_bytes: 38836
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int N;
  
  cin >> N;
 
  int X = N;
  int sum = 0;
  while (N > 0) {
      sum += N % 10;
      N /= 10;
  }
  
  if (X % sum == 0 )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<functional>
#include<queue>
#include <iomanip>
#include<map>
#include<limits>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<utility>
#include<complex>
#include<cstdlib>
#include<set>
#include<cctype>

#define DBG cerr << '!' << endl;
#define REP(i,n) for(int (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(int (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(int (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int i = 0;i < (n);i++)cerr << v[i] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(10)

using namespace std;

typedef long long ll;
typedef vector<int> iv;
typedef vector<iv> iiv;
typedef vector<string> sv;

int main()
{
	int a[2],b;
	cin >> a[0] >> a[1] >> b;
	
	int num = 0;
	for(int i = 0;i < 3700;i++)
	{
		REP(j,a[i%2])
		{
			num++;
			if(num%60 == b && i%2 == 0)
			{
				cout << num << endl;
				return 0;
			}
		}
	}
	cout << -1 << endl;
	
	
	return 0;
}

Measured memory_bytes: 3104
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < ll , ll >
#define F first
#define S second
#define int long long int
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define err(A) cout << #A << " = " << (A) << endl
using namespace std;
const int N=1e5+10,mod=1e9+7;
ll x[N];
int32_t main(){
    ll n,a,b;
    cin >> n >> a >> b;
    for (int i=0;i<n;i++){
        cin >> x[i];
    }
    ll ans=0;
    for (int i=0;i<n-1;i++){
        ans+=min(b,(x[i+1]-x[i])*a);
    }
    cout << ans;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#define type 26

int constant(int day)//1~26 順番
{
  return day%type+1;
}
int get_random()//1~26 ランダム
{
  return rand()%type+1;
}
int max(int s[][type+1],int day)//その日の最大の満足度選ぶ
{
  int m,max_score=0,i;
  for(i=1;i<=type;i++)
  {
    if(s[day][i]>max_score){
      max_score=s[day][i];
      m=i;
    }
  }
  return m;
}
void cal(int select,int c[type+1],int last[type+1],int s[][type+1],int day,int sum[])
{
  int i;
  sum[day]=sum[day-1]+s[day][select];
  for(i=1;i<=type;i++){
    sum[day]-=c[i]*(day-last[i]);
  }
}
void change(int c[type+1],int last[type+1],int s[][type+1],int sum[],int schedul[],int D)
//ランダムに変更
{
  int d,t,old,total=0,i,j;
  d=rand()%D+1;
  t=rand()%type+1;
  old=schedul[d];
  schedul[d]=t;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  if(total>sum[D]){
  //  printf("change\n");
    sum[D]=total;
  }
  else{
    schedul[d]=old;
  }
}
void cross(int c[type+1],int last[type+1],int s[][type+1],int sum[],int schedul[],int D)
//ランダムな２つ交換
{
  int a,b,old_a,old_b,flag=0,i,j,total=0;
  flag=rand()%2;
  a=rand()%D+1;
  if(flag==0){
    b=a+rand()%16+1;
    if(b>D) b=a-(rand()%16+1);
  }
  else{
    b=a-(rand()%16+1);
    if(b<1)   b=a+rand()%16+1;
  }
  old_a=schedul[a];
  old_b=schedul[b];
  schedul[a]=old_b;
  schedul[b]=old_a;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  if(total>sum[D]){
    sum[D]=total;
  }
  else
  {
    schedul[a]=old_a;
    schedul[b]=old_b;
  }
}
int main(void)
{
  int D,c[type+1],i,j;
  clock_t start,stop;
  start=clock();
  srand((unsigned int)time(NULL));
  scanf("%d",&D);//D=365
  int s[D+1][type+1],last[type+1],sum[D+1],schedul[D+1];
  for(i=0;i<=D;i++) sum[i]=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=type;i++) scanf("%d",&c[i]);
  for(i=1;i<D+1;i++){
    for(j=1;j<=type;j++) scanf("%d",&s[i][j]);
  }
  for(i=1;i<D+1;i++){
    int select;
    select=max(s,i);
    last[select]=i;
    schedul[i]=select;
    cal(select,c,last,s,i,sum);
    //printf("%d\n",sum[i]);
  }
  int count=0;
  stop=start;
  while((double)(stop - start) / CLOCKS_PER_SEC<1.988){
    int flag=rand()%2;
    if(flag==0) cross(c,last,s,sum,schedul,D);
    else change(c,last,s,sum,schedul,D);
    count++;
    stop=clock();
  }
/*
  printf("count:%d\n",count);
  printf("time:%f\n",(double)(stop - start) / CLOCKS_PER_SEC);
  printf("%d\n",sum[D]);
  printf("確認\n");
  int total=0;
  for(i=1;i<=type;i++) last[i]=0;
  for(i=1;i<=D;i++){
    total+=s[i][schedul[i]];
    last[schedul[i]]=i;
    for(j=1;j<=type;j++){
     total-=c[j]*(i-last[j]);
   }
  }
  printf("%d\n",total);
*/
  for(i=1;i<=D;i++) printf("%d\n",schedul[i]);
  return 0;
}


Measured memory_bytes: 1812
//  ____            _                  _                       _       _
// |  _ \ _   _ ___| |_    ___ _ __   | |_ ___ _ __ ___  _ __ | | __ _| |_ ___
// | |_) | | | / __| __|  / __| '_ \  | __/ _ \ '_ ` _ \| '_ \| |/ _` | __/ _ \
// |  _ <| |_| \__ \ |_  | (__| |_) | | ||  __/ | | | | | |_) | | (_| | ||  __/
// |_| \_\\__,_|___/\__|  \___| .__/___\__\___|_| |_| |_| .__/|_|\__,_|\__\___|
//                            |_| |_____|               |_|

//https://github.com/manta1130/Competitive_Programming_Template_Rust

#[macro_use]
mod input {

    use std;
    use std::io;

    const SPLIT_DELIMITER: char = ' ';

    #[macro_export]
    #[allow(unused_macros)]
    macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

    #[allow(dead_code)]
    pub fn input_line_str() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn p<T>(t: T)
    where
        T: std::fmt::Display,
    {
        println!("{}", t);
    }

    #[allow(dead_code)]
    pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<Vec<T>> = Vec::new();

        for _ in 0..line {
            let vec_line = input_vector();
            v.push(vec_line);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector<T>() -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v: Vec<T> = Vec::new();

        let s = input_line_str();
        let split_result = s.split(SPLIT_DELIMITER);
        for z in split_result {
            let buf = match z.parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    #[allow(dead_code)]
    pub fn input_vector_row<T>(n: usize) -> Vec<T>
    where
        T: std::str::FromStr,
    {
        let mut v = Vec::with_capacity(n);
        for _ in 0..n {
            let buf = match input_line_str().parse() {
                Ok(r) => r,
                Err(_) => panic!("Parse Error"),
            };
            v.push(buf);
        }
        v
    }

    pub trait ToCharVec {
        fn to_charvec(&self) -> Vec<char>;
    }

    impl ToCharVec for String {
        fn to_charvec(&self) -> Vec<char> {
            self.to_string().chars().collect::<Vec<_>>()
        }
    }
}

use input::*;
use std::collections::HashSet;
fn main() {
    let (n, r): (usize, usize);
    input!(n, r);
    if n >= 10 {
        println!("{}", r);
    } else {
        println!("{}", r + 100 * (10 - n));
    }
}


Measured memory_bytes: 4352
// Ballazt
//0a..brute force
//0b..greedy
//1..memorizatton of some sort	remember something cleverly
//2..sort
//3..binary search	keep check a particular solution
//4..dp				repeating strucutre,limited choices
//5..dfs/bfs		matrix with obstacles
//6..correlate to graph in some way		each state is a point
#include <bits/stdc++.h>
using namespace std;
#define ll unsigned long long int
#define endl "\n"


int main()

{
	ios::sync_with_stdio(0);
	cin.tie(0);

	int n;
	string s;
	cin>>n>>s;
	int count=0;

	for(int i=0;i<=n-3;i++)
	{
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
			count++;

	}

	cout<<count;
	



	
}

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

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a.begin(), a.end());
	
	vector<int> cand;
	for(int i=0; i<n-1; i++){
		if(a[i]==a[i+1]){
			cand.push_back(a[i]);
			i++;
		}
	}
	if((int)cand.size() < 2){
		cout << 0 << endl;
	}else{
		cout << (long long int)cand.back() * cand[cand.size()-2] << endl;
	}
	return 0;
}

Measured memory_bytes: 1024
import bisect
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    p = set(map(int, input().split()))
    num_list = set([i for i in range(-1, 102)])
    num_list = sorted(list(num_list ^ p))
    nummin = num_list[bisect.bisect_left(num_list, X)]
    nummax = num_list[bisect.bisect_right(num_list, X)]
    if nummin == nummax:
        nummin = num_list[bisect.bisect_left(num_list, X)-1]
    if X-nummin <= nummax-X:
        print(nummin)
    else:
        print(nummax)

Measured memory_bytes: 9120
#include<iostream>
#include<cstdio>
using namespace std;
int a,b,c,i;
int main(){
    scanf("%d%d%d",&a,&b,&c);
    for(i=1;i<b;i++)
    {
        if((a*i)%b==c){cout<<"YES"<<endl;return 0;}
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

const int mod = 1000000007;


int a[22][22];
ll dp[1<<22];
int n;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int main() {
  cin >> n;
  dp[0] = 1;
  rep(i,n){
    rep(j,n)cin >> a[i][j];
  }

  for(int s = 1; s<(1<<n);s++){
    //cout<<s<<" "<<__builtin_popcount(s)<<endl;
    int pos= __builtin_popcount(s)-1;
    rep(i,n){
      if(s&(1<<i) &&a[pos][i]){
        dp[s]+=dp[s^(1<<i)];
        dp[s]%=mod;
      }
    }
  }

  cout<<dp[(1<<n)-1]<<endl;
  return 0;
}

Measured memory_bytes: 20008
H, W = map(int, input().split())
grid = [list(str(input())) for _ in range(H)]

res = []
for h in range(H):
    for w in range(W):
        if grid[h][w] == "#":
            res.append(grid[h])
            break
    else:
        H -= 1

for w in range(W):
    for h in range(H):
        if res[h][w] == "#":
            break
    else:
        for i in range(H):
            res[i][w] = ""

for i in res:
    print("".join(i))

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;


int main(){
  map<string,int> data;
  string a,b;cin>>a>>b;
  cin>>data[a]>>data[b];
  string c; cin>>c;
  data[c]--;
  cout<<data[a]<<" "<<data[b]<<endl;
}

Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
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() {
	int n, k; cin >> n >> k;
    int cnt = 0;
    while(n != 0) {
        n /= k;
        ++cnt;
    }
    cout << cnt << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static Scanner scanner = new Scanner(System.in);

	public static void main(String[] args) {

		String s = input();
		String p = input();

		s += s;

		if (s.indexOf(p) != -1) {

			System.out.println("Yes");

		} else {

			System.out.println("No");

		}

		close();

	}

	public static String input() {

		return scanner.nextLine();

	}

	public static void close() {

		if (scanner != null) {

			scanner.close();

		}
	}
}

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

int main(){
  vector<int> res;
  while (true) {
    int a,b;
    char op;
    cin >> a >> op >> b;
    if (op == '?') {
      break;
    } else if(op == '+') {
      res.push_back(a+b);
    } else if(op == '-') {
      res.push_back(a-b);
    } else if(op == '*') {
      res.push_back(a*b);
    } else if(op == '/') {
      res.push_back(a/b);
    }
  }

  for (int i=0; i<res.size(); i++) {
    printf("%d\n", res[i]);  
  }

  return 0;
}



Measured memory_bytes: 3268
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

var abc [200][200]int

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	edges := make([]Edge, n)

	for i := 0; i < n-1; i++ {
		a := getNextInt(scanner) - 1
		b := getNextInt(scanner) - 1
		c := getNextInt64(scanner)
		edges[a].to = append(edges[a].to, b)
		edges[a].cost = append(edges[a].cost, c)
		edges[a].i++
		edges[b].to = append(edges[b].to, a)
		edges[b].cost = append(edges[b].cost, c)
		edges[b].i++
	}
	distance := make([]int64, n)
	color := make([]int, n)
	q := getNextInt(scanner)
	k := getNextInt(scanner) - 1

	queue := []int{k}
	color[k] = 1

	for len(queue) > 0 {
		p := queue[0]
		queue = queue[1:]
		edge := edges[p]
		for i := 0; i < edge.i; i++ {
			if color[edge.to[i]] != 0 {
				continue
			}
			color[edge.to[i]] = 1
			distance[edge.to[i]] = distance[p] + edge.cost[i]
			queue = append(queue, edge.to[i])
		}
	}

	for i := 0; i < q; i++ {
		x := getNextInt(scanner) - 1
		y := getNextInt(scanner) - 1

		fmt.Fprintln(writer, distance[x]+distance[y])
	}

	writer.Flush()
}

type Edge struct {
	i    int
	to   []int
	cost []int64
}


Measured memory_bytes: 20352
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <queue>
using namespace std;

void solve(){
  long long int n, k; cin >> n >> k;
  long long int x = n / k;
  long long int y = n - (x + 1) * k;
  long long int z = n % k;
  cout << min(abs(y), abs(z)) << endl;
  return;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String args[]){
    	Scanner s = new Scanner(System.in);
      	int N = s.nextInt();
      	int M = s.nextInt();
      	ArrayList<Integer> graph[] = new ArrayList[N];
      	for(int i=0;i<N;i++)
          	graph[i] = new ArrayList<Integer>();
      	for(int i=0;i<M;i++){
        	int a = s.nextInt()-1;
          	int b = s.nextInt()-1;	
          	graph[a].add(b);
        }
      	int ans = ans(graph,N);
      	System.out.println(ans);
    }
  	public static int ans(ArrayList<Integer> graph[], int N){
      	int ans[] = new int[N];
      	boolean[] visited = new boolean[N];
      	Arrays.fill(ans, -1);
      	int max = 0;
      	for(int i=0;i<N;i++){
        	if(!visited[i]){
            	max = Math.max(max, dfs(graph, i, N, ans, visited)-1);
            }
        }
      	return max;
    }
  	public static int dfs(ArrayList<Integer> graph[], int curr, int N,
                          int[] ans, boolean[] visited){
      	// System.out.println(curr+" "+ans[curr]);
    	if(ans[curr]!=-1){
        	return ans[curr]+1;
        }
      	visited[curr] = true;
      	int max = 0;
      	for(int i : graph[curr]){
          	if(!visited[i])
        		max = Math.max(max, dfs(graph, i, N, ans, visited));
        }
      	ans[curr] = max;
      	visited[curr] = false;
      	return max+1;
    }
}

Measured memory_bytes: 108668
#include <bits/stdc++.h>
using namespace std;
int dp[100000][3];

int solve(int n) {
	int d[100000][3];
	d[0][0] = dp[0][0];
	d[0][1] = dp[0][1];
	d[0][2] = dp[0][2];
	for (int i = 1; i < n; i++) {
		d[i][0] = dp[i][0] + max(d[i - 1][1], d[i - 1][2]);
		d[i][1] = dp[i][1] + max(d[i - 1][0], d[i - 1][2]);
		d[i][2] = dp[i][2] + max(d[i - 1][0], d[i - 1][1]);
	}
	return max(d[n - 1][0], max(d[n - 1][1], d[n - 1][2]));
}

int main() {


#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> dp[i][0];
		cin >> dp[i][1];
		cin >> dp[i][2];
	}
	cout << solve(n);

}

Measured memory_bytes: 5956
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];
  
  sort(all(A));
  
  mp::cpp_int ans = 1;
  
  rep(i, N) {
    ans *= A[i];
    if(ans > 1000000000000000000) {
      cout << -1 << endl;
      return 0;
    }
    if(ans == 0) {
      cout << 0 << endl;
      return 0;
    }
  }


  cout << ans << endl;

}

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

int cmp(const void *a,const void*b){
  return *(int*)b -*(int*)a;
}

int main(void){
  int N,H,i,ans=0,a_max=0,cnt=0;
  scanf("%d %d",&N,&H);
  int a[N],b[N];
  for(i=0;i<N;i++) scanf("%d %d",&a[i],&b[i]);
  for(i=0;i<N;i++) if(a_max<a[i]) a_max = a[i];
  
  qsort(b,N,sizeof(int),cmp);
  
  while(H>0){
    if(N<=cnt ||b[cnt]<=a_max) break;
    H-=b[cnt];
    cnt++;
  }
  if(H>0) cnt+=(H%a_max==0?H/a_max:H/a_max+1);
  printf("%d\n",cnt);
  return 0;
}

Measured memory_bytes: 1276
S = list(input())
S.pop(len(S) - 1)
count = 0
while True:
    if len(S) % 2 != 0:
        S.pop(len(S) - 1)
        continue
    mid = int(len(S) / 2)
    for i in range(mid):
        if S[i] == S[i + mid]:
            count += 1
    else:
        if count == mid:
            print(len(S))
            break
        else:
            count = 0
            S.pop(len(S) - 1)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <functional>
#include <utility>
#include <queue>
#include <vector>
#include <string>
#include <stack>
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;
typedef long long int ll;
const ll  MOD = 1000000007;
typedef pair<ll,ll> P;
const ll INF = 100100100100100100;

ll N;
ll s[110];
ll sum = 0;
ll minnum = INF;

int main(){
  cin >> N;
  rep(i,N){
    cin >> s[i];
    sum += s[i];
    if(s[i] % 10 != 0 && s[i] < minnum){
      minnum = s[i];
    }
  }
  if(sum % 10 !=0){
    cout << sum << endl;
  }
  else{
    if(minnum == INF){
      cout << "0" << endl;
    }
    else{
      cout << sum-minnum << endl;
    }
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    int counter = 0;
    string s;
    cin >> s;
    for(int i = 0; i < 3; i++)
    {
        if(s[i] == '1') counter++;
    }
    cout << counter << endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<ll, int>;

#define INF 1e18

struct Edge {
  int to;
  ll cost;
  Edge(int to=0, ll cost=0) : to(to), cost(cost) {}
};

string rev(string s) {
  reverse(s.begin(), s.end());
  return s;
}

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> c(n);
  rep(i,n) cin >> s[i] >> c[i];
  rep(i,n) {
    s.push_back(rev(s[i]));
    c.push_back(c[i]);
  }
  int idcnt = 1;
  vector< vector<int> > id(n*2);
  rep(i,n*2) {
    int l = s[i].size();
    id[i].resize(l);
    rep(j,l) id[i][j] = idcnt++;
  }

  vector< vector<Edge> > G(idcnt);
  rep(i1,n*2) {
    int l1 = s[i1].size();
    rep(j,l1) {
      int v = id[i1][j];
      rep(i2,n*2) {
        if (i1/n==i2/n) continue;
        int l2 = s[i2].size();
        int w = min(l2,l1-j);
        if (s[i1].substr(j,w) != s[i2].substr(0,w)) continue;
        int u;
        if (l2 > w) u = id[i2][w];
        else if (l1-j > w) u = id[i1][j+w];
        else u = 0;
        G[v].emplace_back(u,c[i2]);
      }
    }
  }

  vector<ll> dist(idcnt,INF);
  priority_queue<P, vector<P>, greater<P>> q;
  auto push = [&] (int v, ll x) {
    if (dist[v] <= x) return;
    dist[v] = x;
    q.emplace(x,v);
  };

  rep(i,n) push(id[i][0],c[i]);
  while (!q.empty()) {
    int v;
    ll c;
    tie(c,v) = q.top(); q.pop();
    if (c != dist[v]) continue;
    for (auto e : G[v]) push(e.to,c+e.cost);
  }

  ll ans = dist[0];
  rep(i,n*2) {
    int l = s[i].size();
    rep(j,l) {
      string t = s[i].substr(j);
      if (t == rev(t)) ans = min(ans, dist[id[i][j]]);
    }
  }
  if (ans == INF) ans = -1;

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3724
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
int c[3][3];
int main(){
	rep(i, 3) rep(j, 3) cin>>c[i][j];
	rep(i, 101*101*101){
		bool ok = true;
		int i2 = i;
		vector<int> a(3);
		rep(j, 3){
			a[j] = c[0][j]-i2%101;
			if(a[j]<0||a[j]>100) ok = false;
		}
		i2 /= 101;
		rep(j, 3) if(a[j]!=c[1][j]-i2%101) ok = false;
		i2 /= 101;
		rep(j, 3) if(a[j]!=c[2][j]-i2%101) ok = false;
		if(ok){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;

	return 0;
}


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

string s;
vector<string> is7;

void dfs(int now, queue<int> que, string op) {
    if(que.empty()) {
        if(now == 7) is7.push_back(op);
        return;
    }
    
    int n = que.front(); que.pop();
    dfs(now + n, que, op + "+");
    dfs(now - n, que, op + "-");
}

int main() {
    cin >> s;
    queue<int> que;
    rep(i, s.size()) que.push(s.at(i) - '0');
    int n = que.front(); que.pop();
    dfs(n, que, "");
    string ans = "";
    rep(i, s.size()) {
        ans += s.at(i);
        if(i < 3) {
            ans += is7.at(0).at(i);
        }
    }
    ans += "=7";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>

#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

lint fib[50] = {0};

int main(){
    int n;
    cin >> n;
    fib[0] = 1;
    fib[1] = 1;
    REP(i, 2, n+1){
        fib[i] = fib[i-2] + fib[i-1];
    }
    cout << fib[n] << endl;
    return 0;
}


Measured memory_bytes: 3084
#include<stdio.h>

#define N 100000
 
typedef struct{
  int de;
  int pa;
  int ll;
  int sib;
}node;
  
node A[100000];
int n;
 
int depth(int now){
  int dep = 0; 
  while(1){
    if(A[now].pa == -1)return dep;
    else {
      now=A[now].pa;
      dep++;
    }
  }
}
 
void init(){
  int i;
  for(i=0;i<n;i++){
    A[i].pa=-1;
    A[i].ll=-1;
    A[i].sib=-1;
  }
  return;
}
 
int main(int argc,char *argv[]){
  int i,j,now,leaf,k;
   
  scanf("%d",&n);
  init();
  for(i=0;i<n;i++){
    scanf("%d",&now);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&leaf);
      if(j==0){
    A[now].ll=leaf;
    A[leaf].pa=now;
      }
      else {
    A[now].sib=leaf;
    A[leaf].pa=A[now].pa;
      }  
      now=leaf;
    }
  }
  for(i=0;i<n;i++){
    A[i].de=depth(i);
  }
  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,A[i].pa,A[i].de);
    if(A[i].pa==-1)printf("root, ");
    else if(A[i].ll==-1)printf("leaf, ");
    else printf("internal node, ");
    printf("[");
    for(j=A[i].ll;j!=-1;j=A[j].sib){
      if(j==A[i].ll)printf("%d",j);
      else printf(", %d",j);
    }
    printf("]\n");
  }
  return 0;
}

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

int main()
{
    long long a, b, k;
    cin >> a >> b >> k;
    a -= k;
    k=0;
    if (a<0)
    {
        k=-a;
        a = 0;
    }
    b -=k;
    if(b<0){
        b=0;
    }
    cout << a << ' ' << b << endl;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = (1ll << 31) - 1;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
//typedef pair<int, int> P;
//typedef pair<double, double> P;

//bool contain(set<P> &s, P a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
typedef priority_queue<long long, vector<long long>, greater<long long>> PQ_ASK;


void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

vector<pair<ll, int >> factorize(ll n) {
    vector<pair<ll, int >> res;

    for (ll i = 2; i * i <= n; i++) {
        if (n % i != 0) {
            continue;
        }
        res.emplace_back(i, 0);
        while (n % i == 0) {
            n /= i;
            res.back().second++;
        }
    }

    if (n != 1) res.emplace_back(n, 1);
    return res;

}

int main() {

    ll n;
    cin >> n;

    auto f = factorize(n);

    vector<ll> ans;
    for (auto l : f) {
        for (int i = 0; i < l.second; i++) {
            ans.push_back(l.first);
        }
    }

    cout << n << ':' << ' ';
    print_line(ans);

}



Measured memory_bytes: 3168
h, w, k = map(int, input().split())
cake = [list(input()) for i in range(h)]

res = [['.' for i in range(w)] for j in range(h)]

num = 1
f = 0
for i in range(h):
    if '#' not in cake[i]:
        continue
    for j in range(w):
        if cake[i][j] == '.':
            res[i][j] = num
        else:
            if f == 0:
                f = 1
                res[i][j] = num
            else:
                num += 1
                res [i][j] = num
    else:
        num += 1
        f = 0

for x in res:
    if '.' in x:
        continue
    else:
        tmp = x
        break

for i in range(h):
    if '.' in res[i]:
        res[i] = tmp
    tmp = res[i]

for x in res:
    print(*x)

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define pb            push_back
template<class T, class S> inline pair<T, S> mp(T x, S y){ return make_pair(x, y); }
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

static const int    INF = 1000000000;
static const ll     MOD = 1000000007LL;
static const double EPS = 1E-12;

int n;
string mes;
string s;

int main()
{
  cin >> n;

  while(n--){
    cin >> mes >> s;
    int m = s.size();
    reverse(ALL(mes));
    vrep(v, mes){
      if(*v == 'J'){
        char t = s[m - 1];
        rev(i, m-1) s[i + 1] = s[i];
        s[0] = t;
      }
      else if(*v == 'C'){
        char t = s[0];
        rep(i, m-1) s[i] = s[i + 1];
        s[m - 1] = t;
      }
      else if(*v == 'E'){
        string l = s.substr(0, m / 2);
        string r = s.substr((m + 1)/ 2, m - m / 2);
        if(m & 1) s = r + s[m / 2] + l;
        else s = r + l;
      }
      else if(*v == 'A'){
        reverse(ALL(s));
      }
      else if(*v == 'P'){
        vrep(w, s) if(*w >= '0' && *w <= '9'){
          *w -= 1;
          if(*w < '0') *w = '9';
        }
      }
      else if(*v == 'M'){
        vrep(w, s) if(*w >= '0' && *w <= '9'){
          *w += 1;
          if(*w > '9') *w = '0';
        }
      }
    }
    cout << s << endl;
  }

  return 0;
}

Measured memory_bytes: 1204
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
typedef long long ll;
#define INF 1e9


int main(){
    int n; cin >> n;
    vector<int> p(n), q(n);
    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];
    
    vector<int> v(n);
    rep(i,n) {
        v[i] = i+1;
    }
    
    
    int a = 0, b = 0;
    
    int num = 1;
    do {
        if(v == p) {
            a = num;
            
            break;
        }
        num++;
    } while (next_permutation(v.begin(), v.end()));

    num = 1;
    rep(i,n){
        v[i] = i+1;
    }
    
    do {
           if(v == q) {
               b = num;
              
               break;
           }
           num++;
       } while (next_permutation(v.begin(), v.end()));

    cout << abs(a-b) << endl;
    
    
}




Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <bitset>
#include <stack>
#include <set>
#include <cstdio>
using namespace std;

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<int,P> P2;
const int inf=1000000000;
int main() {
	string s;
	char a[]="abcdefghijklmnopqrstuvwxyz";
	cin>>s;
	int ls=s.length();
	for(int i=0;i<26;++i){
		int t=-6;
		for(int j=0;j<ls;++j){
			if(s[j]==a[i]){
				if(j-t<3){
					cout<<t+1<<" "<<j+1<<endl;
					return 0;
				}
				t=j;
			}
		}
	}
	cout<<"-1 -1"<<endl;
	return 0;
}


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

#define LLINF (1LL<<60)
typedef long long ll;

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template<typename T> inline T divrup(T a, T b) { if (a % b) return a/b+1; else return a/b;}

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)

//C++14 (GCC 5.4.1)
int main() {
    string S;
    char a,b;
    cin >>S;
    
    //-----------------------------------
    bool is=false;
    if(S[0]==S[1]){
        a=S[0];
        is=(a!=S[2] && S[2]==S[3]);
    }else{
        a=S[0];
        b=S[1];
        is = (a==S[2] && b== S[3])||(a==S[3]&& b==S[2]);
    }
    cout << ((is) ? "Yes" : "No") <<endl;
    return (0);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define ll long long
int main()
{
    ll n,i,j,k,l,m;
    cin>>n;
    k=0;
    l=INT_MIN;
    for(i=0;i<n;i++)
    {
        cin>>j;
        k+=j;
        if(j>l){l=j;}
    }
    k-=l;
    k+=(l/2);
    cout<<k<<endl;
    return 0;
}


Measured memory_bytes: 256
def main():
  n = int(input())
  ac=0
  wa=0
  tle=0
  re=0
  for i in range(0,n):
    s = input()
    if s=='AC':
      ac+=1
    elif s=='WA':
      wa+=1
    elif s=='TLE':
      tle+=1
    else:
      re+=1
  print('AC x',ac)
  print('WA x',wa)
  print('TLE x',tle)
  print('RE x',re)

main()

Measured memory_bytes: 9220