akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch Repsept | diff Repsept.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address Repsept.cpp && ./a.out

/*

 8/2/2020

 5:04-5:26 give up
 8:50- skim solution tweets

 */

LL K;

void solve() {
  int res=-1;
  LL p10=1;
  REPE(i,K) {
    LL x=p10*7;
    x%=K;
    if(x==0) {
      res=i+1;
      break;
    }
    p10=p10*10+1;
    p10%=K;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;

  cin>>K;
  solve();

  return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define ll long long
#define pr pair <ll,ll> 
#define ff first
#define ss second
#define MP make_pair
#define PB push_back
#define pri 1000000007
#define mn 25
#define sz noofnodes +2
#define all(x) x.begin(),x.end()
using namespace std;

void masterstroke()
{   
	ll n,k;
	cin>>n>>k;
	if(k==1)cout<<0<<endl;
	else cout<<(n-k)<<endl;
	}


int main(){

	ll t=1;
	//cin>>t;
	for(ll i=0;i<t;i++)
	masterstroke();

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pi acos(-1)
typedef long long ll;
using namespace std;

int main()
{
    Fast;
    ll n,m,i,j,k,ans=0;
    string s;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        if(i%3!=0 && i%5!=0)
        {
            ans=ans+i;
        }
    }
    cout<<ans<<endl;
}


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

string S;
int K;

int main(void)
{
	cin >> K >> S;

	if (S.length() <= K)
	{
		cout << S;
	}
	else
	{
		for (int i = 0; i < K; i++)
		{
			cout << S[i];
		}
		cout << "...";
	}
}

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

int main(){
	int n, m;
	cin >> n >> m;
	int a[m], b[m];
	for(int i=0; i<m; i++) cin >> a[i] >> b[i];

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

	for(int i=0; i<m; i++){
		r[a[i]-1] += 1;
	}
	for(int i=0; i<m; i++){
		r[b[i]-1] += 1;
	}

	for(int i=0; i<n; i++) cout << r[i] << endl;

	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

//
// # Examples
//
// # integers
// input! { n: usize, m: usize, ... }
//
// # array
// input! { n: usize, v: [i32; n], }
//
// # matrix
// input! { n: usize, m: usize, mat: [[]] }
//
// # string
// input! { s: chars }
//
// 3 4
// ####
// #..#
// .#.#
//
// input!{
//     h: usize,
//     w: usize,
//     board: [chars; h],
// }

// https://practice.contest.atcoder.jp/tasks/practice_1
//fn main() {
//    input!{
//        a: usize, b: usize, c: usize,
//        foo: chars,
//    }
//    let s: String = foo.into_iter().collect();
//    println!("{} {}", a+b+c, s);
//}
fn main() {
    input!{
        n: usize, i: usize
    }
    println!("{}", n - i + 1);
}

Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
	int a,b;
	scanf("%d %d",&a,&b);
	if(a>=13)
		printf("%d\n",b);
	else if(a>=6 && a<=12)
		printf("%d\n",b/2);
	else
		printf("0\n");
	return 0;
}



Measured memory_bytes: 128
#include <algorithm>
#include <climits>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

#define MAX_N 100000

const int MAX = 100001;
const int MOD = 1000000007;

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

int ceil(int x, int y) { return (x % y == 0) ? x / y : x / y + 1; }

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }

int lcm(int x, int y) { return x / gcd(x, y) * y; }

int digit(ll a, ll b) {
  ll count = 1;
  while (a / b != 0) {
    a /= b;
    ++count;
  }
  return count;
}

ll power(ll a, ll b) {
  ll result = 1;
  for (ll i = 0; i < b; i++) result *= a;
  return result;
}

struct edge {
  int v, w, i;
};

vector<edge> graph[MAX_N];

void color(int v, int p, int pc, int ans[]) {
  int c = 1;
  for (edge e : graph[v]) {
    int w = e.w;
    if (w == p) continue;
    if (c != pc) {
      ans[e.i] = c;
    } else {
      ++c;
      ans[e.i] = c;
    }
    color(w, v, c, ans);
    ++c;
  }
}

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

  int n;
  cin >> n;
  int a[n - 1], b[n - 1];
  for (int i = 0; i < n - 1; i++) {
    cin >> a[i] >> b[i];
    --a[i];
    --b[i];
  }

  for (int i = 0; i < n - 1; i++) {
    graph[a[i]].push_back(edge{a[i], b[i], i});
    graph[b[i]].push_back(edge{b[i], a[i], i});
  }

  int k = 1;
  for (int v = 0; v < n; v++) {
    k = max(k, (int)graph[v].size());
  }

  int ans[n - 1];
  color(0, -1, 0, ans);

  string buf;
  buf += to_string(k) + "\n";
  for (int i = 0; i < n - 1; i++) {
    buf += to_string(ans[i]) + "\n";
  }

  cout << buf;

  return 0;
}


Measured memory_bytes: 10048
#include<bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false),cin.tie(0);
#define ll long long
#define inf 0x3f3f3f3f
const int N=2e5+5;
//set<string>b;
//set<string>::iterator it;
const ll mod=1e9+7;
ll a[N];
int main()
{
	IO;
	ll n,i,sum=0,ans=0;
	cin>>n;
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=1;i<n;i++) sum=(sum+a[i])%mod;
	for(i=0;i<n;i++)
	{
		ans=(ans+sum*a[i])%mod;
		sum=((sum-a[i+1])%mod+mod)%mod;
	}
	cout<<ans<<endl;
    return 0;
}

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

int main()
{
    int a, b, c;
    cin >> a;
    cin >> b;
    cin >> c;
    if ((a <= c & c <= b) | (b <= c & c <= a))
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
<?php
$n=trim(fgets(STDIN));
$h=explode(" ",trim(fgets(STDIN)));
$ans[0]=0;
$ans[1]=abs($h[1]-$h[0]);
$i=2;
while($i<$n){
  $ans[$i]=min($ans[$i-1]+abs($h[$i]-$h[$i-1]),
               $ans[$i-2]+abs($h[$i]-$h[$i-2]));
  ++$i;
}
echo $ans[$i-1];

Measured memory_bytes: 18932
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int n;
    cin>>n;
    long long int arr[n];
    for(long long int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    long long int xxor=0,ans;
    for(long long int i=0;i<n;i++)
    {
        xxor=xxor^arr[i];
    }
    for(long long int i=0;i<n;i++)
    {
        ans=xxor^arr[i];
        cout<<ans<<" ";
    }
    cout<<endl;
}

Measured memory_bytes: 5184
s = input()
len = len(s)
bit_len = 1 << (len - 1)
ans = 0

for b in range(bit_len):
    num= ord(s[0]) - ord('0')
    for i in range(len - 1):
        if (1 << i) & b != 0:
            ans += num
            num = 0
        num = num* 10 + ord(s[i+1]) - ord('0')
    ans += num

print(ans)


Measured memory_bytes: 2940
n,m=map(int,input().split())
a=list(map(int,input().split()))
d={}
for i in a:
  d[i]=d.get(i,0)+1

for _ in range(m):
    b,c=map(int,input().split())
    d[c]=d.get(c,0)+b
e=list(d.keys())
e.sort()
ans=f=0
for i in e[::-1]:
    if f+d[i]>=n:
        ans+=i*(n-f)
        break
    ans+=i*d[i]
    f+=d[i]
print(ans)

Measured memory_bytes: 32064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		int n = in.nextInt();
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = in.nextInt();
		}

		int max = -1;
		int[] dp = new int[n+1];
		for (int i = 0; i < n; i++) {
			dp[a[i]] = dp[a[i]-1] + 1;
			max = Math.max(max, dp[a[i]]);
		}

		System.out.println(n - max);

	}
}


Measured memory_bytes: 85556
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();

        if (N == M) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}

Measured memory_bytes: 23252
s = input()

ans0 = 0
ans1 = 0
for i, s_i in enumerate(s):
    if i % 2 == 0:
        if s_i == '0':
            ans1 += 1
        else:
            ans0 += 1
    else:
        if s_i == '0':
            ans0 += 1
        else:
            ans1 += 1
print(min(ans0, ans1))


Measured memory_bytes: 9172
/*************************************************************************
  >         File: A.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sat 15 Oct 2016 09:38:33 PM CST
*************************************************************************/
#include <bits/stdc++.h>

int main() {
  std::ios::sync_with_stdio(0);
  int n;
  std::cin >> n;
  using LL = long long;
  LL a = 0, b = 0;
  std::cin >> a >> b;
  for (int i = 0; i < n - 1; ++i) {
    int x, y;
    std::cin >> x >> y;
    LL k = std::max((a + x - 1) / x, (b + y - 1) / y);
    a = k * x, b = k * y;
  }
  std::cout << a + b << std::endl;

  return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val c = sc.nextInt()
    val k = sc.nextInt()
    val t = Array(n) { sc.nextInt() }
    t.sort()
    var ans = 0
    var dept = -1
    var count = 0
    for (i in 0 until n) {
        if (dept == -1) dept = t[i]
        if (dept + k < t[i]) {
            dept = t[i]
            ans++
            count = 1
        } else {
            count++
            if (count == c) {
                dept = -1
                ans++
                count = 0
            }
        }
    }
    if (count > 0) ans++
    println(ans)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


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

using namespace std;

void Solve(){
    double n;
    cin>>n;
    double res = n * n * n;
    res /= 27;
    cout<<fixed<<setprecision(10)<<res<<'\n';
}
int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int q = 1;
    //cin>>q;
    while(q--){
    	Solve();
    }
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m, x;
	cin >>n >>m >>x;
	
	vector<VL> dt(n, VL(m+1));
	rep(i, n) rep(j, m+1) cin >>dt[i][j];
	
	ll ans = 1LL<<60;
	rep(i, 1<<n){
		VL sm(m+1, 0);
		rep(j, n) if(i>>j &1){
			rep(k, m+1) sm[k] += dt[j][k];
		}
		bool ok=true;
		rep(k, m) if(sm[k+1] < x) ok=false;
		if(ok) ans = min(ans, sm[0]);
	}
	
	if(ans == 1LL<<60) ans =-1;
	cout <<ans <<"\n";
	return 0;
}


Measured memory_bytes: 3636
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<stack>
#include<map>
#include<cstdint>
#include<unordered_map>
#include<boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < ( int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define vi vector<int>
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define Cin cin>>a;

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main(void){
	int R, G, B, N;
	cin >> R >> G >> B >> N;
	int count = 0;
	for (int r = 0; r * R <= N; r++) {
		for (int g = 0; g * G <= N; g++) {
			int tmp = N - r * R - g * G;
			if (tmp >= 0 && tmp % B == 0) {
				count++;
			}
		}
	}
	cout << count << endl;

}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;

class Myon
{
    static Scanner cin;
    public Myon() { }
    public static int Main()
    {
        //Console.SetOut(new Printer(Console.OpenStandardOutput()));
        cin = new Scanner();
        new Myon().calc();
        return 0;
    }


    public void calc()
    {
        int N = cin.nextInt();
        long x = cin.nextInt();
        long[] A = new long[N];
        for (int i = 0; i < N; i++)
        {
            A[i] = cin.nextInt();
        }
        long[] B = (long[])A.Clone();
        Array.Reverse(B);
        long ans = Math.Min(calc2(N, x, A), calc2(N, x, B));
        Console.WriteLine(ans);
    }

    long calc2(int N, long x, long[] A)
    {
        long ans = 0;

        for (int i = 1; i < N; i++)
        {
            long dec = A[i - 1] + A[i] - x;
            if (dec > 0)
            {
                ans += dec;
                long dec2 = Math.Min(dec, A[i]);
                A[i] -= dec2;
            }
        }
        return ans;
    }
}

class Printer : StreamWriter
{
    public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
    public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
    public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        while (i >= s.Length)
        {
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
        }
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}

Measured memory_bytes: 18640
import Data.List

main = do
    s <- reverse <$> getLine
    putStrLn $ if check s then "YES" else "NO"

check [] = True
check s | "maerd" `isPrefixOf` s = check (drop 5 s)
        | "remaerd" `isPrefixOf` s = check (drop 7 s)
        | "esare" `isPrefixOf` s = check (drop 5 s)
        | "resare" `isPrefixOf` s = check (drop 6 s)
        | otherwise = False

Measured memory_bytes: 7548
#include<bits/stdc++.h>
#define faster_io ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
using namespace std;
const ll N = 1e6 + 7, M = 1e5 + 7, mod = 998244353, inf = 1e18 + 7;
ll tc, n, m, q, a, b, c, d, i, j, k, ans;
//ll ar[N];
string s;
vector < ll > vec;

int main()
{
    faster_io;
    char ch;
    cin >> ch;
    cout << (char)(ch + 1) << endl;
}


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

using namespace std;

#define ll long long

const int N = 102, maxW = 100005;
ll dp[N][maxW];
int n, w[N], v[N];

ll cal(int x, int y) {
	if (y < 0) {
		return -2e18;
	}
	if (x == n) {
		return 0;
	}
	ll &ret = dp[x][y];
	if (ret > -2e18) {
		return ret;
	}
	ret = max(cal(x+1, y), cal(x+1, y - w[x]) + v[x]);
	return ret;
}

int main() {
	int W;
	scanf("%d %d", &n, &W);
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <= W; j++) {
			dp[i][j] = -2e18;
		}
	}
	for (int i = 0; i < n; i++) {
		scanf("%d %d", &w[i], &v[i]);
	}
	printf("%lld", cal(0, W));
	return 0;
}

/*
3 8
3 30
4 50
5 60
*/
/*
5 5
1 1000000000
1 1000000000
1 1000000000
1 1000000000
1 1000000000
*/
/*
6 15
6 5
5 6
6 4
6 6
3 5
7 2
*/


Measured memory_bytes: 78336
#include <stdio.h>
#include <stdlib.h>
#include "time.h"
#include "unistd.h"
#include "string.h"
#include <math.h>
int ans;
int main(int argc, char* argv[]){
  long int a,b,c;
  scanf("%ld",&a);
  printf("ABC%d\n",a);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

// n以下の要素の中で最大の添え字を返す
// n < min(d) : -1
// max(d) < n : d.size() - 1
int Binary_search(ll n, vector<ll> & d) {
	auto tag = upper_bound(d.begin(), d.end(), n);
	return distance(d.begin(), tag) - 1;
}

int main(void) {
	int n, m, i, ans;
	ll k;
	cin >> n >> m >> k;
	vector<ll> a(n), b(m);
	rep(i, n)
		cin >> a[i];
	rep(i, m)
		cin >> b[i];
	rep(i, m - 1)
		b[i + 1] += b[i];
	ans = Binary_search(k, b);
	rep(i, n) {
		k -= a[i];
		if (k < 0)
			break;
		chmax(ans, i + 1 + Binary_search(k, b));
	}
	cout << ans + 1 << "\n";
	return 0;
}

Measured memory_bytes: 6424
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
#include <unordered_map>
using namespace std;

const unsigned long long BASE = 1e9 + 7;
#define SAFE 1e8

int main()
{
    int n, d;
    cin >> n >> d;
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        double x, y;
        cin >> x >> y;
        double dist = sqrt(x * x + y * y);
        if (dist <= d)
            count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3752
def main():
    input()
    H = [int(i) for i in input().split()]
    ans = 0
    prev = float('inf')
    cnt = -1
    for cur in H:
        if prev >= cur:
            cnt += 1
        else:
            if ans < cnt:
                ans = cnt
            cnt = 0
        prev = cur
    if ans < cnt:
        ans = cnt
    print(ans)
    return


main()


Measured memory_bytes: 14252
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
string s;
int ans[100005];
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  int sl = s.length();
  fill(ans, ans + sl, 0);

  REP(i, sl - 1) {
    if(s[i] == 'R' && s[i + 1] == 'L') {
      int rp = i;
      while(rp >= 0 && s[rp] == 'R') {
        if((i - rp) % 2 == 0) ans[i]++;
        else ans[i + 1]++;
        rp--;
      }
      int lp = i + 1;
      while(lp < sl && s[lp] == 'L') {
        if((lp - i - 1) % 2 == 0) ans[i + 1]++;
        else ans[i]++;
        lp++;
      }
    }
  }

  REP(i, sl) cout << ans[i] << endl;
}


Measured memory_bytes: 1104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n,k;
  cin >> n>> k;
  vector<ll> h(n+1);
  for(ll i=1;i<=n;i++){
    cin >> h.at(i);
  }
  ll dp[n+1];
  dp[1]=0;
  rep(i,n+1){
    dp[i]=0;
  }
  for(ll i=2;i<=n;i++){
    dp[i]=dp[i-1]+abs(h.at(i)-h.at(i-1));
    for(ll j=1;j<=k;j++){
      if(i-j>=1){
        dp[i]=min(dp[i],dp[i-j]+abs(h.at(i)-h.at(i-j)));
      }
    }
  }
  cout << dp[n];
}

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

class Main{
	
	public static void main(String[] args){

		int s[]=new int[3];
		int i,j;
		j = 0;
		Scanner sc = new Scanner(System.in);
		
		for(i=0;i<s.length;i++){
		s[i]= sc.nextInt();
		}
		
		Arrays.sort(s);
		
		System.out.println(s[0] + " " + s[1] + " " + s[2]);
		
		
	}

}

Measured memory_bytes: 26112
import System.Environment
import Data.Maybe
import Data.List
import Control.Exception

main :: IO ()
main = do
  isTest <- getEnv "TEST" `catch` (\(SomeException _) -> return "")
  if isTest == "1"
    then do
      testFile <- readFile "tests"
      putStrLn $ tests testFile
    else do
      input <- getContents
      putStrLn $ trim (solve (trim input))

--処理
solve :: String -> String
solve s = f list
 where
  (_:t:list) = fmap read (words s) :: [Int]
  f          = show . (t+) . sum . fmap (min t . uncurry (-)) . (zip =<< drop 1)

tests :: String -> String
tests text = case testParse text of
  Right bodys -> unlines (fmap (\(i, body) -> test i body) (zip [1 ..] bodys))
  Left  msg   -> "Test file parse error:" ++ msg

test :: Int -> (String, String) -> String
test n (input, outputRight)
  | output == outputRight
  = header ++ "Passed"
  | otherwise
  = header
    ++ "Faild\n"
    ++ "Right:"
    ++ show outputRight
    ++ "\nOutput:"
    ++ show output
 where
  header = "test" ++ show n ++ ":"
  output = trim $ solve input

testParse :: String -> Either String [(String, String)]
testParse s = case lines s of
  (sp1:sp2:bodys) -> testBodysParse sp1 sp2 bodys
  _               -> Left "testParse"

testBodysParse
  :: String -> String -> [String] -> Either String [(String, String)]
testBodysParse sp1 sp2 = (traverse . testBodyParse) sp2 . (split sp1)

testBodyParse :: String -> [String] -> Either String (String, String)
testBodyParse sp body = case fmap (trim . unlines) (split sp body) of
  [input, output] -> Right (input, output)
  _               -> Left "testBodyParse"

split :: Eq a => a -> [a] -> [[a]]
split spratar = foldr f [[]]
 where
  f x (p:ps) | x == spratar = [] : p : ps
             | otherwise    = (x : p) : ps
  f _ _ = undefined

trimHead :: String -> String
trimHead = dropWhile (\s -> isJust (elemIndex s [' ', '\t', '\n', '\r']))

trim :: String -> String
trim = reverse . trimHead . reverse . trimHead

Measured memory_bytes: 140668
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	int a, b;
	cin >> a >> b;
	
	int n = 1;
	int ans = 0;
	while( n < b ){
		n--;
		n += a;
		ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1e9 + 7;
const ll inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

double n;

int main()
{
    while (cin >> n)
    {
        if (n == 0)
            return 0;
        vector<double> v;
        double sum = 0;
        for (int i = 0; i < n; i++)
        {
            double k;
            cin >> k;
            v.push_back(k);
            sum += k;
        }
        sum /= n;
        int ans = 0;
        for (int i = 0; i < n; i++)
        {
            if (v[i] <= sum)
                ans++;
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3388
#include<iostream>
#include<stdio.h>
#include<vector>//s1.erase(n)=文字列s1の、n文字目以降削除
#include<algorithm>//辞書順=next_permutation
#include<set>
#include<string>//char 小文字のほうが32大きい
#include<sstream>
#include<string.h>
#include<complex>
#include<time.h>
#include<random>
#include<cmath>
#include<math.h>
#include<queue>
#include<time.h>
#include<iomanip>
#include<locale>
#include<utility>//swap=数値交換
#define rt "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rop(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n-1;0<=i;i--)
#define drop(i,n) for(int i=n;0<i;i--)
#define yes(ans) if(ans)cout<<"yes"<<rt;else cout<<"no"<<rt;
#define Yes(ans) if(ans)cout<<"Yes"<<rt;else cout<<"No"<<rt;
#define YES(ans) if(ans)cout<<"YES"<<rt;else cout<<"NO"<<rt;
#define sec(a,b,ans) if(ans)cout<<a<<rt;else cout<<b<<rt;
#define vcin(s,n) rep(i,n)cin>>s[i];//vcin(配列名),(繰り返し回数)
#define sort(s) sort(s.begin(),s.end())//標準=昇順
#define reve(s) reverse(s.begin(),s.end())
#define asas int ans=0
#define llcncn llint cnt=0
#define llasas llint ans=0
#define str string
#define please return
#define AC 0
#define ic_a int a;cin>>a;
#define ic_b int b;cin>>b;
#define ic_s string s;cin>>s;
#define Rapid_pleaseAC_fast cin.tie(0);ios::sync_with_stdio(false)
#define Pi 3.1415926535897932384626
#define nine 1000000000

using namespace std;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<double> vdou;
typedef long long int llint;
typedef pair<int, int> pint;
typedef pair<llint, llint> pllint;
typedef vector<llint> vllint;
typedef vector<pint> vpint;
typedef vector<pair<llint, llint>> vpllint;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
typedef vector<vector<llint>> vvllint;
typedef vector<vector<string>> vvstr;
typedef vector<vector<bool>> vvbool;
typedef vector<vector<pint>> vvpint;
typedef vector<bool> vbool;

long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
	return a * b / GCD(a, b);
}

unsigned GetDigit(unsigned num) {
	return std::to_string(num).length();
}

int tow(int n) {//2のn乗
	if (n == 0)return 1;
	int x = tow(n / 2);
	x *= x;
	if (n % 2 == 1)x *= 2;
	return x;//@domino
}

/*

 (char)toupper(a[n])=文字列のn文字目を大文字で出力

  pow(a,b)=aのb乗

  */


int main(void) {
	Rapid_pleaseAC_fast;

	int n, k;
	cin >> n >> k;
	vint l(n);
	vcin(l, n);
	sort(l); reve(l);
	int ans = 0;
	rep(i, k) {
		ans += l[i];
	}
	cout << ans << rt;

	please AC;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main(){
  ll a,b;
  cin>>a>>b;
  ll ans=max({a+a-1,a+b,b+b-1});
  cout<<ans<<endl;

}


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

using namespace std;
using ll = long long;


int n;
vector<int> A;
int cnt[200000];


void solve()
{
    for (int i = 0; i < n; i++)
    {   
        cnt[i] = 0;
    }
    for(auto &e : A){
        cnt[e - 1]++;
    } 
    for(int i = 0; i < n; i++) cout << cnt[i] << endl; 
    
}

int main()
{
    cin >> n;
    for(int i = 0; i < n - 1; i++){
        int a;
        cin >> a;
        A.push_back(a);
    } 
    solve();


    return EXIT_SUCCESS;
}

Measured memory_bytes: 4816
#約数
def make_divisors(n): #約数をリストで返す
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N,M = (int(i) for i in input().split())
M_div =make_divisors(M)
div_rev =M_div[::-1]

#M=約数✖（相手）⇒相手＝n(n+1)/2 以上なら成り立つ
for i in range(len(M_div)):
    if N <= M_div[i]:
        print(div_rev[i])

        break 

Measured memory_bytes: 9360
#include <stdio.h>
#include <math.h>
 
int main(void){
 
  double a,b,c,S,L,h,x;
 
  scanf("%lf %lf %lf",&a,&b,&c);
  
  c = c * 3.14159265 / 180;
 
  S = (a * b) * 0.5 * sin(c);
 
  x = (a * a) + (b * b) - 2 * a * b * cos(c);
  L = a + b + sqrt(x);
 
  h = b * sin(c);
 
  printf("%f\n",S);
  printf("%f\n",L);
  printf("%f\n",h);
  return 0;
}

Measured memory_bytes: 672
#include <bits/stdc++.h>
//#define DEBUG
#define REP(i, nn ) for(int i = 0 ; i < (int) nn; i++)
#define deb(x) std::cerr << #x << " " << x << endl;
#define debl(x) std::cerr << #x << " " << x << " ";
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
//const ll LINF = 1001002003004005006ll;
//const int INF = 1001001001;
template<typename... T>
void read(T& ... a){
    ((cin >> a),...);
}
template<typename... T>
void write(T... a){
    ((cout << a << "\n"),...);
}

template<typename... T>
void write_space(T... a){
    ((cout << a << " "),...);
}
constexpr int MOD = 1e9 + 7;
constexpr int mxN = 100;
constexpr int mxK = 1e5;

ll dp[mxN][mxK + 1];

void solve(){
    int n, k;
    read(n,k);
    vi a(n);
    REP(i,n) cin >> a[i];
    for(int i = 0 ; i <= a[0]; i++){
        dp[0][i] = 1;
    }
    for(int i = 1 ; i < n ; i++){
        for(int j = 0 ; j <= k ; j++){
            if( j == 0){
                dp[i][j] = 1;
                continue;
            }
            dp[i][j] = dp[i-1][j] + dp[i][j-1];
            if(j-1 >= a[i]){
                dp[i][j] = (dp[i][j] + MOD - dp[i-1][j - 1 - a[i]]) % MOD;
                
            }
            if(dp[i][j] >= MOD){
                dp[i][j] = dp[i][j] % MOD;
            }
            
        }
    }
    cout << dp[n-1][k] << endl; 
}

int main()
{
    //making data IO Fast
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    /****************************/
    solve();
    return 0;
}



Measured memory_bytes: 81692
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Tarek
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CModuloSummation solver = new CModuloSummation();
        solver.solve(1, in, out);
        out.close();
    }

    static class CModuloSummation {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int sum = 0;
            for (int i = 0; i < n; i++) {
                sum += in.nextInt() - 1;
            }
            out.println(sum);
        }

    }
}



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

template <class T> using V = vector<T>;

using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;


#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;


ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}


ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}


ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/


signed main() {
  ll x,a,b;
  	ci(x>>a>>b);
  
  if(rM(abs(x-a),abs(x-b))==abs(x-a)) co('A')
  else co('B')
}
  


Measured memory_bytes: 256
def yaku(n):
    A = []
    for i in range(1,int(n**0.5)+1):
        if n%i==0:
            A.append(i)
            A.append(n//i)
    return len(A)
N = int(input())
cnt = 0
for i in range(1,N+1,2):
    if yaku(i)==8:
        cnt += 1
print(cnt)

Measured memory_bytes: 38384
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//227
	string a,b;
	cin>>a>>b;
	string tem="";
	REP(i,0,(int)a.length()-(int)b.length()) {
		bool h = true;
		REP(j,0,(int)b.length()-1) {
			if(b[j]!=a[i+j]&&a[i+j]!='?') {
				h=0;
				break;
			}
		}
		if(h) {
			tem = a;
			REP(j,0,(int)b.length()-1) {
				tem[i+j]=b[j];
			}
			REP(j,0,(int)a.length()-1){
				if(tem[j]=='?')tem[j]='a';
			}
		}
	}
	if(tem!=""){
		cout<<tem;
	} else
	cout<<"UNRESTORABLE";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3624
import java.util.*;

public class Main {
	//0155 start
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			String [] s = sc.nextLine().split(" ");
			LinkedList<Double> stack = new LinkedList<Double>();
			for(int i = 0 ; i <s.length; i++){
				char c = s[i].charAt(0);
				if(Character.isDigit(c) || (c == '-' && s[i].length() > 1)){
					double res = Integer.parseInt(s[i]);
					stack.addLast(res);
				}
				else{
					double b = stack.removeLast();
					double a = stack.removeLast();
					if(c == '+'){
						double res = a + b;
						stack.addLast(res);
					}
					else if(c == '-'){
						double res = a - b;
						stack.addLast(res);
					}
					else if(c =='*'){
						double res = a * b;
						stack.addLast(res);
					}
					else if(c == '/'){
						double res = a / b;
						stack.addLast(res);
					}
				}
			}
			System.out.printf("%.6f\n",stack.removeLast());
		}
	}
	public static void main(String [] args){
		new Main().doit();
	}
}

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

string S;

long long recurse(int i, string n, long long t){
	if(i < S.length()){
		long long ret = 0;
		if(n.size() > 0) ret += recurse(i + 1, S.substr(i, 1), t + stoll(n));
		ret += recurse(i + 1, n + S.substr(i, 1), t);
		return ret;
	}else if(n.length() > 0) return t + stoll(n);
	else return t;
}

int main(){		
	getline(cin, S);
	printf("%lld\n", recurse(1, S.substr(0, 1), 0));
	return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
		Stack<Integer> s = new Stack<Integer>();
		while(in.hasNextInt()){
			int t=in.nextInt();
			if(t==0){
				System.out.println(s.pop());
			}else{
				s.push(t);
			}
		}
		while(!s.empty())System.out.println(s.pop());
	}
}

Measured memory_bytes: 12000
#include<stdio.h>
#define MAX 500001

void buildMaxHeap(void);
void maxHeapify(int);

int a[MAX];
int h;

int main(){
  int i;

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

  buildMaxHeap();

  for(i=1;i<=h;i++){
    printf(" %d", a[i]);
  }
  printf("\n");
  
  return 0;
}

void buildMaxHeap(){
  int i;
  for(i=h/2;i>=1;i--){
    maxHeapify(i);
  }
}

void maxHeapify(int i){
  int l, r; //lは左の子のノード番号, rは右の子のノード番号
  int largest; //自分と左の子と右の子でkeyが最大のノードの番号
  int v;
  
  l = 2 * i;
  r = 2 * i + 1;

  //keyが最大のノードを選ぶ
  if(l <= h && a[l] > a[i]) largest = l;
  else largest = i;
  if(r <= h && a[r] > a[largest]) largest = r;

  //iのこの方が大きい時a[i]とa[largest]を交換
  if(largest != i){
    v = a[i];
    a[i] = a[largest];
    a[largest] = v;
    maxHeapify(largest);
  }
}



Measured memory_bytes: 3680
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define trace(x) cerr<<#x<<" : "<<x<<endl;
#define ssd ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>




int main()
{
	ssd
	#define task "TASK"
	 //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
    string ch;
    cin>>ch;
    int sum=(int)(ch[0]-'0');
    for(ll i=1;i<ch.length();i++)
    {
        sum+=(ch[i]-'0');
        sum=sum%9;
    }


    if(sum%9==0)
    {

        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

	return 0;
}


Measured memory_bytes: 3736
n, q = map(int, input().split())
stack = [[] for _ in range(n)]

for _ in range(q):
    query = list(map(int, input().split()))
    if query[0] == 0:
        stack[query[1]].append(query[2])
    elif query[0] == 1:
        if stack[query[1]] == []:
            pass
        else:
            print(stack[query[1]][-1])
    elif query[0] == 2:
        if stack[query[1]] == []:
            pass
        else:
            stack[query[1]].pop(-1)



Measured memory_bytes: 13700
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>
 
using namespace std;
 
vector<int> used;
 
vector<vector<int>> g;
 
void dfs(int cur, int ch, vector<int> &h) {
    h[cur] = ch;
    used[cur] = 1;
    for (auto t : g[cur]) {
        if (!used[t]) {
            dfs(t, ch + 1, h);
        }
    }
}
 
int mys(int len) {
    return len - 1;
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
   
    int n;
    int a, b;
    cin >> n >> a >> b;
    a--;
    b--;
    used.resize(n);
    g.resize(n);
    for (int i = 0; i + 1 < n; i++) {
        int u, v;
        cin >> u >> v;
        u--;
        v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<int> ha(n);
    vector<int> hb(n);
    dfs(a, 0, ha);
    fill(used.begin(), used.end(), 0);
    dfs(b, 0, hb);
    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (hb[i] > ha[i]) {
            ans = max(ans, ha[i] + mys(hb[i] - ha[i]));
        }
    }
    cout << ans << endl;
}

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

#define M 1046527
#define L 15


struct Node {
    char value[L];
    Node* next;
};

Node* nil;
Node* H[M];

long long getKey(char* str) {
    long long result = 0;
    for (int i = 0; i < strlen(str); ++i) {
        int j = 0;
        switch (str[i]) {
            case 'A':
                j = 1;
                break;
            case 'C':
                j = 2;
                break;
            case 'G':
                j = 3;
                break;
            case 'T':
                j = 4;
                break;
        }
        result += j * pow(5, i);
    }
    return result % M;
}

bool find(char* str) {
    int i = 0;
    long long key = getKey(str);
    Node* cur = H[key];
    while (cur != nil) {
        if (strcmp(cur->value, str) == 0) return true;
        cur = cur->next;
    }
    return false;
}

void insert(char* str) {
    int i = 0;
    long long key = getKey(str);
    Node* cur = H[key];
    Node* node = (Node *)malloc(sizeof(Node));
    strcpy(node->value, str);
    node->next = cur;
    H[key] = node;
    return;
}

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < M; ++i) { H[i] = nil; }

    for (int i = 0; i < n; ++i) {
        char command[7];
        char c[L];
        scanf("%s %s", command, c);
        if (command[0] == 'i') insert(c);
        if (command[0] == 'f') {
            if (find(c)) {
                printf("yes\n");
            }
            else {
                printf("no\n");
            }
        }
    }
    return 0;
}

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

using namespace std;

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)
#define SCANFD(x) scanf("%d",&x)

int main(){
  int powers[10] = {1,2,4,8,16,32,64,128,256,512};
  int N,M;
  vector<vector <int> > svv;
  vector<int> sv,kv;
  int k,s,res=0,count,lights,limit;
  int p[10];

  scanf ("%d %d",&N,&M);  
  
  REPI (M)
  {
    scanf ("%d", &k);
    kv.push_back (k);
    sv = vector<int> ();
    REPJ (k)
    {
      scanf ("%d",&s);
      sv.push_back (s-1);
    }
    svv.push_back (sv);
  }

  REPI (M)
  {
    scanf ("%d", &p[i]);
  }

  limit = pow(2,N);
  for (int state = 0; state < limit; state++)
  {
    lights = 0;
    REPI (M)
    {
      count = 0;      
      REPJ (kv[i])
      {
        if (state & powers[svv[i][j]])
          count++;
      }
      if (count%2 == p[i])
        lights++;
    }
    if (lights == M)
      res++;
  }

  printf ("%d\n",res);
  return 0;
}


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

int main () {
    string s, t;
    cin >> s >> t;

    int minCh = t.size() + 5;
    for (unsigned i = 0; i <= s.size() - t.size(); ++i) {
        int counter = 0;
        for (unsigned j = 0; j < t.size(); ++j)
            if (s[i+j] != t[j])
                ++counter;
        if (counter < minCh)
            minCh = counter;
    }

    cout << minCh;
}


Measured memory_bytes: 3620
inp = input()
inp_list = inp.split()
for i in range(1, len(inp_list)+1):
  inp_list[i-1] = int(inp_list[i-1])
for j in range(1, len(inp_list)):
  for k in range(1, len(inp_list)):
    if inp_list[k-1] > inp_list[k]:
        tmp = inp_list[k-1]
        inp_list[k-1] = inp_list[k]
        inp_list[k] = tmp
print('%d %d %d' %(inp_list[0], inp_list[1], inp_list[2]))


Measured memory_bytes: 5600
//package  com.company;


import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int prev=-1;
        long ans=0;//1000000*1000000*1000000;
        for(int i=0;i<N;++i){
            int a=sc.nextInt();
            if(prev>a){
                ans+=prev-a;
            }else{
                prev=a;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 48492
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;


int main(){
    string s; cin >> s;
    stack<char> st;
    int ans = 0;
    rep(i, s.length()){
        if(st.empty()){
            st.push(s[i]);
        }else{
            int t = st.top();
            if(t != s[i]){
                st.pop();
                ans += 2;
            }
            else st.push(s[i]);
        }
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 3848
import math
a, b, C = map(int, input().split())
S = a*b*math.sin(C*math.pi/180)/2
L = a+b+(a**2+b**2-2*a*b*math.cos(C*math.pi/180))**0.5
h = 2*S/a
print(S)
print(L)
print(h)



Measured memory_bytes: 5720
// Author : Mahmoud Tarek

#include <bits/stdc++.h>
#define all(v) v.begin(),v.end()
using namespace std ;

int main(){

 int n , m ;
 string st ;
 cin >> n ;
 unordered_map < string , int > mp , mp2 ;
 for( int i = 0 ; i < n ; i++ ){
    cin >> st ;
    mp[ st ]++ ;
 }
 cin >> m ;
 int mx = 0 ;
 for( int o = 0 ; o < m ; o++ ){
     cin >> st ;
     mp2[ st ]++ ;
 }

 for( auto i : mp ){
     mx = max( i.second - mp2[ i.first ] , mx ) ;
 }

 cout << mx ;

 return 0 ;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  vector<int> a(n), b(n);
  ll as = 0, bs = 0;
  REP(i,n){
    cin >> a[i];
    as += a[i];
  }
  REP(i,n){ 
    cin >> b[i];
    bs += b[i];
  }
  ll total = bs-as;
  
  ll one = 0, two = 0;
  REP(i,n){
    if(a[i]<b[i]){
      two += (b[i]-a[i]+1)/2;
    }else if(a[i]>b[i]){
      one += a[i]-b[i];
    }
  }
  if(max(one,two)<=total) cout << "Yes\n";
  else cout << "No\n";
  return 0;
}


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


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	for(int i=1;i<10;i++){
		for(int j=1;j<10;j++){
			cout<<i<<"x"<<j<<"="<<i*j<<"\n";
		}
	}
	return 0;
}

Measured memory_bytes: 1160