akhauriyash/Code-Regression huggingface dataset:
import sys
x = []
y = []

for l in sys.stdin:
    xl, yl = map(int, l.split())
    if xl == 0 and yl == 0:
        break
    else:
        x.append(xl)
        y.append(yl)

cnt = 0

for le in x:
    if x[cnt] <= y[cnt]:
        print(x[cnt], y[cnt])
    else:
        print(y[cnt], x[cnt])
    cnt += 1


Measured memory_bytes: 6100
package main

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

func main() {
	n, x, t := readI(), readI(), readI()
	times := n / x
	if n%x != 0 {
		times++
	}
	fmt.Println(times * t)

}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


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

#define db(x) cout<<x<<'\n'
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define repi(i,n) for(int i=0;i<(n);++i)
//#define repA(i,a,n) for(int i=a;i<=(n);++i)
//#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define ll long long int
#define endl '\n'
#define lld long long double
#define vi vector<int> 
#define vl vector<ll> 
#define vb vector<bool> 
#define vvi vector<vector<int>  >
#define err(t) cout<<"Error : "<<t<<endl;
#define all(v) v.begin(),v.end()
#define mp make_pair
#define M 100000
#define MD 1000000007 //998244353
#define pb push_back
#define rep(i,a,b) for(ll i = a; i <= (b); i++)
#define pii pair<int,int>
#define pll pair<ll,ll> 
#define vec(a) vector<a >
#define se second
#define fi first
#define inf 0xffffffff
#define inchar getchar_unlocked
#define outchar(x) putchar_unlocked(x)
//template <typename T>
//using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll binpow(ll a,ll b){	if(a==0) return 0; if(b==0) return 1;ll ans=1;while(b>0){if(b&1) ans=ans*a; a=a*a; b=b>>1;}	return ans;}
template <typename T> 
T Min(T a,T b){ return a<b?a:b; }
template <typename T>
T Max(T a,T b){ return a>b?a:b; }

int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// int n;cin>>n;
	// string s;cin>>s;
	
	//ll n;cin>>n; vl a(n); repi(i,n) cin>>a[i];
	int n;cin>>n;
	int c=0;
	n%=1000;
	n=1000-n;
	if(n==1000) n=0;
	db(n);
	
	/*
	int test1;cin>>test1;while(test1--){ 
		
	 }
	 //*/
return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{   char c[]={'3','5','7'};
	 int n;
	 cin>>n;
	 queue<string>q;
	 q.push("3");
	 q.push("5");
	 q.push("7");
	 int on=3,nn=0,ans=0,flag=0;
	  while(1)
    {
    	for(int i=1;i<=on;i++)
    	{
    		 string t=q.front();
    		 q.pop();
    		 for(int j=0;j<3;j++)
    		 {
    		 	string tt=t+c[j];
    		
    		 	int num3=0,num5=0,num7=0;
    		 	for(int k=0;k<tt.length();k++)
    		 	{
    		 		if(tt[k]=='3')num3++;
    		 		else if(tt[k]=='5')num5++;
    		 		else if(tt[k]=='7')num7++;
    		 		
				 }
				 
    		 	stringstream ss;
    		 	int x;
    		 	ss<<tt;
    		 	ss>>x;
    		 	q.push(tt);
    		 	nn++;
    		 	if(x<=n){
    		 		if((num3&&num5&&num7))
    		 		ans++;
				 }
				 else
				 {
				 	flag=1;
				 	break;
				 }
			 }
			 if(flag)break;
		}
		if(flag)break;
		on=nn;
		nn=0;
	}
	printf("%d",ans);
 }

Measured memory_bytes: 1280
#include <stdio.h>

int main(void)
{
	unsigned int dp[30] = {-1};
	int n;
	int i;
	
	dp[0] = 1;
	dp[1] = 2;
	dp[2] = 4;
	dp[3] = 7;
	
	while (1){
		scanf("%d", &n);
		if (n == 0){
			break;
		}
		
		for (i = 3; i < n; i++){
			dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3];
		}
		
		printf("%d\n", (dp[n - 1] - 1) / 3650 + 1);
	}
	
	return (0);
}

Measured memory_bytes: 600
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=0 && 0<=b)
	{
		puts("Zero");
		return 0;
	}
	if(b<0)
	{
		int delta=abs(a-b);
		if(delta&1)
			puts("Positive");
		else 
			puts("Negative");
	}
	else
		puts("Positive");
	return 0;
}


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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;

#define endl '\n'
#define MAX

typedef long long ll;
typedef pair<int,int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int maxn = 1000 + 5;
const ll mod = 1e9 + 7;

ll dp[maxn][maxn];
char a[maxn][maxn];
int n, m;

ll solve(int x, int y){
	if(x > n || y > m)
		return 0;
	if(a[x][y] == '#')
		return 0;
	if(x == n && y == m)
		return 1;
	if(dp[x][y] != -1)
		return dp[x][y];
	ll ans = 0;
	ans += solve(x, y + 1);
	ans %= mod;
	ans += solve(x + 1, y);
	ans %= mod;
	return dp[x][y] = ans;
}

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

	cin >> n >> m;
	for(int i = 1; i <= n; i++)
		for(int j = 1; j <= m; j++)
			cin >> a[i][j];
	
	memset(dp, -1, sizeof(dp));
	cout << solve(1, 1) << endl;

	return 0;
}

Measured memory_bytes: 9216
/**
SXR0aXAkI0JwbXptI3FhI3Z3I293bCNqY2IjUG0jMCNicG0jVHFkcXZvLyNCcG0jQW10bjBhY2phcWFicXZvLyNNYm16dml0MSNWdyNhdGN1am16I2tpdiNhbXF9bSNQcXUjVnd6I0F0bW14MSNQcWEjaXptI2l0dCNicHF2b2EjUXYjYnBtI3BtaWRtdmEjaXZsI3d2I21pemJwMSNFcHcjcWEjYnBtem0ja2l2I3F2Ym16a21sbSNRdiNQcWEjeHptYW12a20jbXtrbXhiI0lhI3BtI3htenVxYmJtYnBHI1BtI3N2d2VtYnAjRXBpYiMraXh4bWl6bWJwI2J3I1BxYSNrem1pYmN6bWEjSWEsI0ptbnd6bSN3eiNJbmJteiN3eiNKbXBxdmwjYnBtdTEjVnd6I2FwaXR0I2JwbXwja3d1eGlhYSNJY29wYiN3biNwcWEjc3Z3ZXRtbG9tI017a214YiNpYSNQbSNlcXR0bWJwMSNQcWEjYnB6d3ZtI2x3YnAjbXtibXZsI1dkbXojYnBtI3BtaWRtdmEjSXZsI3d2I21pemJwLyNpdmwjUG0jbm1tdG1icCNWdyNuaWJxb2NtI3F2I29jaXpscXZvI0l2bCN4em1hbXpkcXZvI2JwbXUvI053eiNQbSNxYSNicG0jVXdhYiNQcW9wMSNCcG0jQWN4em11bSMrcXYjb3R3enwsMQ==
*/
#include <cstring>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cassert>

#define F first
#define S second
#define endl '\n'
#define deb(x) cout<<#x<<' '<<x<<endl;
#define pb push_back

const long long MAXN = 1e6 + 1;
using namespace std;

typedef long long ll;
typedef pair<int, int> pii;


long long readInt() {
    bool minus1 = false;
    long long result = 0;
    char ch;
    ch = getchar();
    while (true) {
        if (ch == '-') break;
        if (ch >= '0' && ch <= '9') break;
        ch = getchar();
    }
    if (ch == '-') minus1 = true; else result = ch-'0';
    while (true) {
        ch = getchar();
        if (ch < '0' || ch > '9') break;
        result = result*10 + (ch - '0');
    }
    if (minus1)
        return -result;
    else
        return result;
}

#define int __int64_t

main() {
	#ifdef IZI_KATKA
	assert(freopen("input", "r", stdin));
    assert(freopen("output", "w", stdout));
    #endif
    int n = readInt();
    int k = 100;
    vector <int> ans;
    for (int i = 1; i <= k; i++) {
        ans.pb(i);
    }
    int l = 1, r = k;
    while (n) {
        if (!(n & 1)) {
            n--;
            ans.pb(r--);
        }
        ans.pb(l++);
        --n;
        n >>= 1;
    }
    cout << ans.size() << endl;
    for (int i : ans) {
        cout << i << ' ';
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define ff                  first
#define ss                  second
#define int                 long long
#define pb                  push_back
#define mp                  make_pair
#define pii                 pair<int,int>
#define vi                  vector<int>
#define vvi				    vector< vi > 
#define vpii                vector< pair<int,int> > 
#define mii                 map<int,int>
#define pqb                 priority_queue<int>
#define pqs                 priority_queue<int,vi,greater<int> >
#define loop(i,a,b)		    for(int i=a;i<b;i++)
#define LOOP(i,a,b)		    for(int i=a;i<=b;i++)
#define looprev(i,a,b)		for(int i=a;i>=b;i--)
#define rloop(it,c)         for(auto& it : c)
#define sz(a)			    a.size()
#define all(c) 			    c.begin(),c.end()
#define tr(c,i) 		    for(auto i = c.begin(); i != c.end(); i++)
#define present(c,x) 	    (c.find(x) != c.end())
#define cpresent(c,x) 	    (find(all(c),x) != c.end())
#define spresent(s,x)       (s.find(x) != s.npos)           //use 'x' while passing to parameters  ||  we can also use cpresent(c,x)
#define setbits(x)          __builtin_popcountll(x)
#define zrobits(x)          __builtin_ctzll(x)
#define SETINT(a,x)         memset(a, x, sizeof(a))
#define SETCHAR(str,x)      memset(str, x, sizeof(str)      //use 'x' while passing to parameters  
#define mod                 1000000007
#define inf                 1e18
#define ps(x,y)             fixed<<setprecision(y)<<x
#define w(x)                int x; cin>>x; while(x--)
mt19937                     rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

 
int raise(int a,int n,int m = mod)
{
    if(n == 0)return 1;
    if(n == 1)return a;
    int x = 1;
    x *= raise(a,n/2,m);
    x %= m;
    x *= x;
    x %= m;
    if(n%2)x*= a;
    x %= m;
    return x;
}
 
int floor1(int n,int k)
{
    if(n%k == 0 || n >= 0)return n/k;
    return (n/k)-1;
}
 
int ceil1(int n,int k)
{
    return floor1(n+k-1,k);
}
 
 
void Gur27()
{
    ios::sync_with_stdio(0); cin.tie(0); 

}

int dp[100005];

int frog1rec(int h[],int N,int n)
{
    
    if(N==2)
        return abs(h[1]-h[0]);
    if(dp[N]!=-1)
        return dp[N];
    else 
    
    return dp[N]=min(abs(h[n-1]-h[n-2])+frog1rec(h,N-1,n-1),abs(h[n-1]-h[n-3])+frog1rec(h,N-2,n-2));

}
int frog1tpdn(int *h,int N,int n)
{
    LOOP(i,3,N)
    {
        dp[i]=min(abs(h[i-1]-h[i-2])+dp[i-1],abs(h[i-1]-h[i-3])+dp[i-2]);
    }
    return dp[N];
}
 
int32_t main()
{
    Gur27();
    int n;
    cin>>n;
    int a[n];
    SETINT(dp,-1);
    dp[0]=0;
    dp[1]=0;
    
    loop(i,0,n)
        cin>>a[i];
    dp[2]=abs(a[1]-a[0]);
    
    cout<<frog1tpdn(a,n,n);
    
    return 0;
}


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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);

    int n;
    long long nxt = 0, cnt = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if(a < nxt)
            cnt += nxt - a;
        else
            nxt = a;
    }
    cout << cnt << endl;
}


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

int main(void){
  int i;
  int K;
  char S[100];
  
  scanf("%d",&K);
  scanf("%s",S);
  
  if(strlen(S)<=K){
    printf("%s\n",S);
  }else{
    for(i=0;i<K;i++){
      printf("%c",S[i]);
    }
    printf("...\n");
  }
  return(0);
}

Measured memory_bytes: 1664
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Contest
{
	class Program
	{
		static void Main()
		{
			int N = int.Parse(Console.ReadLine());
			int[] s = new int[N];
			for (int i = 0; i < N; i++)
			{
				s[i] = int.Parse(Console.ReadLine());
			}
			if (s.Sum() % 10 > 0)
			{
				Console.WriteLine(s.Sum());
			}
			else if (s.Any(item => item % 10 > 0))
			{
				Console.WriteLine(s.Sum() - s.Where(item => item % 10 > 0).Min());
			}
			else
			{
				Console.WriteLine(0);
			}
#if DEBUG
			Console.ReadKey();
#endif
		}
	}
}

Measured memory_bytes: 13396
// Original: https://github.com/tanakh/competitive-rs
    #[allow(unused_macros)]
    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)*}
        };
    }
     
    #[allow(unused_macros)]
    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)*}
        };
     
        ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
            let mut $var = read_value!($next, $t);
            input_inner!{$next $($r)*}
        };
    }
     
    #[allow(unused_macros)]
    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, bytes) => {
            read_value!($next, String).into_bytes()
        };
     
        ($next:expr, usize1) => {
            read_value!($next, usize) - 1
        };
     
        ($next:expr, $t:ty) => {
            $next().parse::<$t>().expect("Parse error")
        };
    }
     
    #[allow(unused_imports)]
    use std::cmp::{max, min};
    #[allow(unused_imports)]
    use std::collections::HashMap;
     
    fn main() {
        input!(s: String);
        let vs = vec![
        "AKIHABARA",
        "KIHABARA",
        "AKIHBARA",
        "KIHBARA",
        "AKIHABRA",
        "KIHABRA",
        "AKIHBRA",
        "KIHBRA",
        "AKIHABAR",
        "KIHABAR",
        "AKIHBAR",
        "KIHBAR",
        "AKIHABR",
        "KIHABR",
        "AKIHBR",
        "KIHBR",
        ];

        
        let s: &str = &s;
        let ok = if vs.contains(&s) { true } else { false };
        
        println!("{}", if ok { "YES" } else { "NO" });
    }

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<iostream>
using namespace std;
long long int lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
using ll =long long int;
#define ci(a) cin>>a
#define co(a) cout<<a<<endl
#define gcd(a,b) __gcd(a,b)
#define vec vector<ll>
#define For(i,a,b) for(int i=a;i<b;i++)
#define rFor(i,a,b) for(int i=a;i>b;i--)
#define sort(a,b) sort(a.begin(),b.end())
#define reverse(a,b) reverse(a.begin(),b.end())
//gcd 最大公約数
//lcm 最小公倍数
//double 少数（変数）
//string 文字列（変数）
//sqrt 平方根
//ceil 天井関数
//floor 床関数
//abs 絶対値
//pow 累乗
//cbrt  立方根
//hypot 平方和の平方根
//(string-'0') 文字列を数字に変換
//vector<vector<int>> data(a,vector<b>(b)) a×b行列
//for(int i=0;i<a;i++)
//for(int j=0;j<b;j++)
//cin>>data.at(i).at(j)  a×b行列の入力
//floor(log10(a)+1) aの10進法での桁数
//ceil(log10(a)) aの10進法での桁数

int main() {
  ll n,a,b,c,d,e;
  ci(n>>a>>b>>c>>d>>e);
  ll A=0,B=0,C=0,D=0,E=0;
  ll an=0,ans=0;
  for(int i=1;i<20;i++){
    E+=min(D,e);
    D+=min(C,d)-min(D,e);
    C+=min(B,c)-min(C,d);
    B+=min(A,b)-min(B,c);
    A+=a-min(A,b);
    if(E>0){
      an=i;
      ans=E;
      break;
    }
  }
  if(n%ans==0)
    an--;
  co(an+n/ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main(){
  int n;
  cin >> n;
  vector<pair<ll,ll>> k;
  set<ll> x,y;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    //if(x.count(a)||y.count(b))continue;
    k.push_back(make_pair(a,b));
    x.insert(a);
    y.insert(b);
  }
  sort(k.begin(),k.end());
  n=k.size();
  priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>> p;
  rep(i,n){
    if(i!=0){
      p.push(make_tuple(k[i].first-k[i-1].first,i-1,i));
    }
    if(i!=n-1){
      p.push(make_tuple(k[i+1].first-k[i].first,i,i+1));
    }
  }
  vector<pair<ll,ll>> o(n);
  rep(i,n)o[i]=make_pair(k[i].second,i);
  sort(o.begin(),o.end());
  rep(i,n){
    if(i!=0){
      p.push(make_tuple(o[i].first-o[i-1].first,o[i-1].second,o[i].second));
    }
    if(i!=n-1){
      p.push(make_tuple(o[i+1].first-o[i].first,o[i].second,o[i+1].second));
    }
  }
  UnionFind u(n);
  ll ans=0;
  while(p.size()!=0){
    tuple<ll,ll,ll> m=p.top();
    p.pop();
    ll aa,bb,cc;
    tie(aa,bb,cc)=m;
    //cout << aa << " " << bb << " " << cc << " " << ans << endl;
    if(u.findSet(bb,cc))continue;
    else{
      u.unionSet(bb,cc);
      ans+=aa;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 28188
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;cin>>n;
    string s;cin>>s;
    int ans=0;
    for(int i=0;i<n;i++){
        int same=0;
        int num[1000] = {0};
        for(int j=0;j<i;j++){
            if(num[s[j]]==0){
                num[s[j]]++;
            }
        }
        for(int j=i;j<n;j++){
            if(num[s[j]]==1){
                same++;
                num[s[j]]++;
            }
        }
        ans=max(ans,same);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
s_list = list()
c_list = list()
for _ in range(M):
    s, c = input().split()
    s_list.append(s)
    c_list.append(c)

out = '-1'
exists = True

num = 'd' * N

for index in range(len(s_list)):
    if num[int(s_list[index]) - 1] == 'd' or num[int(s_list[index]) - 1] == c_list[index]:
        # num[int(s_list[index])] = c_list[index]
        num_tmp = num[:int(s_list[index]) - 1]
        num_tmp += c_list[index] + num[int(s_list[index]):]
        num = num_tmp

    else:
        exists = False
        break

if num[0] == '0' and N > 1:  # 0から始まる2桁以上を排除
    exists = False

if exists:
    out = num.replace('d', '0')
    if out[0] == '0' and N > 1:  # '00'→'10'等
        out = '1' + out[1:]

print(out)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
//struct nya{ nya(){ cin.tie(0); ios::sync_with_stdio(false); } }nyan;


void solve(long long A, long long B, long long K){
	if (K<=A) cout << A-K << " " << B << "\n";
	else if (K<=A+B) cout << 0 << " " << B-(K-A) << "\n";
	else cout << 0 << " " << 0 << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long K;
    scanf("%lld",&K);
    solve(A, B, K);
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i]
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion




int32_t main() {
    make(int, k, a, b);
    a = (((a - 1) / k) + 1) * k;
    cout << (a <= b ? "OK\n" : "NG\n");

    return 0;
}

Measured memory_bytes: 3612
from bisect import bisect_left
S = input()
T = input()
Ns = len(S)
S = S + S
ABC = [[] for _ in range(26)]
for i, s in enumerate(S):
    s = ord(s) - 97
    ABC[s].append(i)
ans = 0
l_s = 0
for t in T:
    t = ord(t) - 97
    abc = ABC[t]
    l = bisect_left(abc, l_s)
    if l == len(abc):
        print(-1)
        exit()
    l_s = abc[l]
    l_s += 1
    #print(l_s)
    if l_s >= Ns:
        ans += Ns
        l_s -= Ns
print(ans + l_s)


Measured memory_bytes: 13812
#include<iostream>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define pb(x) push_back(x)
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
#define lcm(a,b) (a*b)/gcd(a,b)
#define bits(x) __builtin_popcountll(x)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int32_t main()
{
	double n,d;
	cin>>n>>d;
	int c=0;
	while(n--)
	{
		int x,y;
		cin>>x>>y;
		double ans=sqrt(x*x+y*y);
		if(ans<=d)
		 c++;
	}
	cout<<c;
}


Measured memory_bytes: 3780
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<math.h>
using namespace std;
typedef long long ll;
typedef pair<int,ll> P;
#define N (1000000000+7)
#define INF (ll)1e16
typedef long long ll;
 
ll sum[200010];
vector<int>graph[200010];
 
void dfs(int vertex,int root){
    for(int i=0;i<(int)graph[vertex].size();i++){
        int now=(int)graph[vertex][i];
        if(now!=root){
            sum[now]=sum[now]+sum[vertex];
            dfs(now,vertex);
        }
    }
}
 
int main(void){
    int n,q,a,b,p,x;
    cin>>n>>q;
    for(int i=1;i<=n-1;i++){
        cin>>a>>b;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    for(int i=0;i<q;i++){
        cin>>p>>x;
        sum[p]+=x;
    }
    dfs(1,1);
    for(int i=1;i<=n;i++){
        if(i==n)cout<<sum[n]<<endl;
        else cout<<sum[i]<<" ";
    }
    return 0;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int n,t,a;
  scanf("%d%d%d",&n,&t,&a);
  int h[1000];
  int i;
  for(i=0;i<n;i++) scanf("%d",h+i);
  int index=0;
  for(i=1;i<n;i++){
    if(ABS(1000*t-6*h[i]-1000*a)<ABS(1000*t-6*h[index]-1000*a)) index=i;
  }
  printf("%d\n",index+1);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 128
package main
import (
	"fmt"
	"math"
)
func main() {
	var x int
	fmt.Scanf("%d", &x)
	a, b := findPair(x)
	fmt.Printf("%d %d\n", a, b)
}

func findPair(x int) (int,int) {
	for i := 1; i <= int(math.Pow(float64(x), 0.5)) + 1; i ++ {
		if x % i == 0 {
			a, b := getAnswer(i, x / i)
			if a != -100000 && b != -100000 {
				return a, b
			}
		}
	} 
	return 0, 0 // invalid state
}

func getAnswer(i, j int) (int, int) {
	x, y := i, j
	if x > y {
		x, y = y, x
	}
	for a := -1000; a < 1000; a ++ {
		for b := -1000; b < 1000; b ++ {
			if i == a - b && j == a*a*a*a + b*b*b*b + a*a*a*b + a*b*b*b + a*a*b*b {
				return a, b
			}
		}
	}
	return -100000, -100000
}

Measured memory_bytes: 1852
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD = int(1e9)+7; 
using namespace std;
using pii = pair<lol, lol>;
typedef vector<int> vit;

//最大公約数
lol gcd(lol x, lol y){ return (y != 0 ? gcd(y, x % y) : x); }
//最小公倍数
lol lcm(lol x, lol y){ return ((x * y) / gcd(max(x, y), min(x, y))); }

signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  lol n, k;
  cin >> n >> k;
  lol a[n + 5];
  reps(i, n){
    cin >> a[i];
  }
  lol high = 1e9, low = 0;
  while(high > low + 1){
    lol mid = (high + low) / 2, sum = 0;
    reps(i, n){
      sum += (a[i] - 1) / mid;
    }
    //cout << mid << " " << sum << '\n';
    if(sum <= k){
      high = mid;
    } else {
      low = mid;
    }
  }
  cout << high << '\n';
  return 0;
}


Measured memory_bytes: 5156
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << 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; }

ll dp[1000001];
int main(){
  ll k, n;
  cin >> k >> n;
  vi a(n);
  rep(i,n){
    cin >> a[i];
  }
  fill(dp, dp + 1000000, 0);
  dp[0] = 0;
  rep(i,n){
    if(i==0){
      dp[0] = a[0] + k - a[n - 1];
    }
    else{
      dp[i] = a[i] - a[i - 1];
    }
  }
  rep(i,n){
    dp[0] = max(dp[0], dp[i]);
  }
  print(k - dp[0]);
}

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

int main(){
    int n,m;
    cin >> n >> m;
    int a[m], b[m];
    int ans[n] = {0};
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        ans[a[i] - 1]++;
        ans[b[i] - 1]++;
    }
    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

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

#define ll long long
#define ar array

int n, a[200000];

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

	cin >> n;
	for (int i=0; i<n; ++i)
		cin >> a[i];
	sort(a, a+n, greater<int>());
	ll ans=0;
	for (int i=1; i<n; ++i)
		ans+=a[i/2];
	cout << ans;
	return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/


Measured memory_bytes: 4372
package main

import (
	"fmt"
)

func main() {
	var n int
	var s string
	fmt.Scan(&n, &s)
	
	max := 0
	cnt := 0
	for i := 0; i < n; i++ {
		if s[i] == 'I' {
			cnt++
		}
		if s[i] == 'D' {
			cnt--
		}
		if max < cnt {
			max = cnt
		}
	}
	fmt.Println(max)
}

Measured memory_bytes: 1764
import java.util.LinkedList;
import java.util.Scanner;
public class Main
{
	public static void main(String arg[])
	{
		Scanner in =new Scanner(System.in);
		while(in.hasNext())
		{
			int n=in.nextInt();
			int s=in.nextInt();
			if((n|s)==0)
				return;
			LinkedList<Integer> L=new LinkedList<Integer>();
			LinkedList<Integer> tmp=new LinkedList<Integer>();
			for(int i=1;i<=n;i++)
				L.add(i);
			while(s-->0)
			{
				int p=in.nextInt();
				int c=in.nextInt();
				for(int i=0;i<c;i++)
					tmp.add(L.get(n-p-i));
				for(int i=0;i<c;i++)
					L.remove(n-p-i);
				for(int i=c-1;i>=0;i--)
				{
					L.add(tmp.get(i));
					tmp.remove(i);
				}
			}
			System.out.println(L.getLast());
		}
	}
}

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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, t, x, y, nx, ny, nt, d;

signed main() {
	cin >> n;
	rep(i,n) {
		cin >> t >> x >> y;
		d = abs(x-nx) + abs(y-ny);
		if (d<=t-nt && (t-nt-d)%2==0) nx = x, ny = y, nt = t;
		else {
			cout << "No" << ln;
			return 0;
		}
	}
	cout << "Yes" << ln;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define REP1(j,n) for(int j=0;j<(int)n;++j)
#define REPD(i,n) for(int i=n;i>=0;--i)
#define REPD1(j,n) for(int j=n;j=>0;--j)
#define REPS(i,n) for(int i=1;i<=(int)n;++i)
#define REPS1(j,n) for(int j=1;j<=(int)n;++j)
#define rep(i,a,n) for(int i=a;i<=(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	if (n > k)
		cout << k * x + (n - k)*y << endl;
	else
		cout << n * x << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define ll long long 
# define skorost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 

using namespace std ;
 
ll z , o , ans ;

ll N = 1e4 + 15820 ;

int main(){ skorost ;

	deque<char>a,b,c;

	string sa , sb , sc ;

	cin >> sa >> sb >> sc ;

	for( int i = 0 ; i < ( int ) sa.size() ; i ++ ){

		a.push_back(sa[i]);

	}
	for( int i = 0 ; i < ( int ) sb.size() ; i ++ ){

		b.push_back(sb[i]);

	}
	for( int i = 0 ; i < ( int ) sc.size() ; i ++ ){

		c.push_back(sc[i]);

	}

	int u = 0 ;

	while( true ){

		if( u == 0 ){

			if( a.size() > 0 ){

				u = a[0] - 'a' ;

				a.pop_front();

			}else{

				cout << 'A' << endl ;

				return 0 ;

			}

		}

		if( u == 1 ){

			if( b.size() > 0 ){

				u = b[0] - 'a' ;

				b.pop_front() ;

			}else{

				cout << 'B' << endl ;

				return 0 ;

			}

		}

		if( u == 2 ){

			if( c.size() > 0 ){

				u = c[0] - 'a' ;

				c.pop_front() ;

			}else{

				cout << 'C' << endl ;

				return 0 ;

			}

		}

	}

}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int x;
  int count = 0;

  scanf("%d", &x);

  while (x >= 500){
    x -= 500;
    count += 1000;
  }

  while (x >= 5){
    x -= 5;
    count += 5;
  }

  printf("%d",count);

  return 0;
}

Measured memory_bytes: 128
# Node??????????????¨????????????
# delete???????????§????????????????????????(parent)??????????????????
class Node
  attr_accessor :value,:left,:right,:parent

  def initialize (value,parent)
    @value = value
    @parent = parent
    @left = nil
    @right = nil
  end

  def insert (value)
    if value < @value
      if @left.nil?
        @left = Node.new(value,self)
      else
        @left.insert(value)
      end
    else
      if @right.nil?
        @right = Node.new(value,self)
      else
        @right.insert(value)
      end
    end
  end

  def find(value)
    if value==@value
      print "yes\n"
    elsif value < @value
      if @left.nil?
        print "no\n"
      else
        @left.find(value)
      end
    else
      if @right.nil?
        print "no\n"
      else
        @right.find(value)
      end
    end
  end

  def delete(value)
    if value == @value
      if @left.nil? or @right.nil?
        update_tree
      else
       # ????????¨?????¨??????????°?????????????????????????????????§????????£?????????
        @value = @right.get_new_value
      end
    elsif value < @value
      @left.delete(value)
    else
      @right.delete(value)
    end
  end

# ??\??????????????????(????????¨?????¨??§????°???????????????????????????????
  def get_new_value
    unless @left.nil?
      return @left.get_new_value
    else
      update_tree
      return @value
    end
  end
 
# ??????????????????????????¨?????????????????????
  def update_tree 
     #p "value: #{@value}"
     #p "@parent.value: #{@parent.value}"
    if @left.nil? and @right.nil?
      new_child = nil
    elsif @left.nil?
      new_child = @right
    elsif @right.nil?
      new_child =  @left
    else
      # ???????????\??£???????????°???
      p "oops"
    end

    new_child.parent = @parent unless new_child.nil?

    if @value < @parent.value
      @parent.left  = new_child
       #p "parent left: #{@parent.left}"
    else
      @parent.right = new_child
       #p "parent right: #{@parent.right}"
    end
  end
  
  def print_inorder
    @left.print_inorder unless @left.nil?
    print " #{value}"
    @right.print_inorder unless @right.nil?
  end
  
  def print_preorder
    print " #{value}"
    @left.print_preorder unless @left.nil?
    @right.print_preorder unless @right.nil?
  end
end

# Input??????????????????
CMD=0
VAL=1

# ???????????????????????????
num_of_cmd = STDIN.gets()
inputs = STDIN.read().split("\n").map{ |input| input.split(' ') }

root=nil
inputs.each do |input|
  if input[CMD] == 'insert'
    if root.nil?
      root = Node.new(input[VAL].to_i,nil)
    else
      root.insert(input[VAL].to_i)
    end
  elsif input[CMD] == 'find'
    root.find(input[VAL].to_i)
  elsif input[CMD] == 'delete'
    root.delete(input[VAL].to_i)
  else
    root.print_inorder unless root.nil?
    print "\n"
    root.print_preorder unless root.nil?
    print "\n"
  end
end

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

#define pb(a) push_back(a)
#define vi vector<int>
#define loop(i, n) for(int i=1;i<=n;i++)
#define loop0(i, n) for(int i=0;i<n;i++)
#define in(i) scanf("%d", &i);
#define out(i) printf("%d", i)

int n, ans, m, u, v, visited[100001], dp[100001];
vi adjacencyList[100001];
void dfs(int i)
{
  visited[i]=1;
  for(int elem:adjacencyList[i])
  {
    if(!visited[elem])
      dfs(elem);
    dp[i]=max(dp[elem]+1, dp[i]);
    ans=max(ans, dp[i]);
  }
}
void solve(int i)
{
  for(int i=1;i<=n;i++)
    if(!visited[i])
      dfs(i);
}
int main()
{
  in(n);
  in(m);
  loop(i, m)
  {
    in(u);
    in(v);
    adjacencyList[u].pb(v);
  }
  solve(1);
  sort(begin(dp), end(dp));
  cout<<ans<<"\n";
}



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

int main(void) {
  string s;
  cin >> s;
  if (s[0] == '7' || s[1] == '7' || s[2] == '7')
    	cout << "Yes\n";
  else 
    	cout << "No\n";
  return 0;
}

Measured memory_bytes: 3620
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1187&lang=jp
AC
"""
import sys
from sys import stdin
input = stdin.readline


class Team(object):
    def __init__(self, id):
        self.id = id
        self.correct = 0        #  ??£?§£??°
        self.time = 0           #  ????????????
        self.penalty = 0        #  ??????????????£
        self.status = {}        #  ?????£?§£?????¶??? key: ????????????, value: ????????£????????°

    def judge(self, m, p, j):
        if j == 0:
            self.correct += 1
            self.time += m      #  ?????????????????£?§£??¨?????£??????????????????????????????????¨?????????????????????????????????????????????§????????????
            self.penalty += 20 * self.status.pop(p, 0)
        else:
            if p in self.status:
                self.status[p] += 1
            else:
                self.status[p] = 1


def calc_result(scores):
    # ???????????????????????¢????????§?????????????????£?§£??°?????????????????????????????????????????§???????????????????????????
    result = []                 #  ??????????????¨??????[??£?§£??°*(-1), ????????????, ???????????????*(-1)] ??????????????§?¨??????????
    for i, s in enumerate(scores[1:], start=1):
        if s is not None:
            result.append([-s.correct, s.time+s.penalty, s.id*-1]) #  sort()??????????????????????????£????????????????????????????????£?§£??°??¨??????????????????-1???????????????
        else:
            result.append([0, 0, -i])
    result.sort()
    return result


def main(args):
    # M, T, P, R = 300, 10, 8, 5,
    # data = [[50, 5, 2, 1,], [70, 5, 2, 0], [75, 1, 1, 0], [100, 3, 1, 0], [150, 3, 2, 0]]

    while True:
        M, T, P, R = map(int, input().split())
        if M == 0 and T == 0 and P == 0 and R == 0:
            break
        data = [[int(i) for i in input().split()]  for x in range(R)]

        scores = [None] * (T+1)
        for d in data:
            m, t, p, j = d
            if scores[t] == None:
                team = Team(t)
                scores[t] = team
            scores[t].judge(m, p, j)

        # ???????????????
        result = calc_result(scores)

        # ?????????????????????????????????
        prev_correct = result[0][0]
        prev_time = result[0][1]
        final_output = str(result[0][2]*-1)
        for r in result[1:]:
            if r[0] == prev_correct and r[1] == prev_time:
                final_output += '='
                final_output += str(r[2]*-1)
            else:
                final_output += ','
                final_output += str(r[2]*-1)
                prev_correct = r[0]
                prev_time = r[1]
        print(final_output)


if __name__ == '__main__':
    main(sys.argv[1:])

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

using namespace std;

int n;
long long int cnt[20010];

int main()
{
	scanf("%d",&n);
	for(int x=1;x<=100;x++)
	{
		for(int y=1;y<=100;y++)
		{
			for(int z=1;z<=100;z++)
			{
				int sum=(x+y)*(x+y)+(y+z)*(y+z)+(x+z)*(x+z);
				if(sum>2*n)
				    break;
				else
				{
					if(sum%2==0)
					cnt[sum/2]++;
				}
				    
			}
		}
	}
	for(int i=1;i<=n;i++)
	    printf("%lld\n",cnt[i]);
	return 0;
} 

Measured memory_bytes: 3792
N = int(input())
h = list(map(int, input().split()))

"""
    dp[i]: カエルが足場 i にたどり着くまでの最小コスト
    i の一つ前は、 i-1 or i-2 にいる. dp[0] = 0.
"""

dp = [0] * N
dp[1] = abs(h[1] - h[0])
for i in range(2, N):
    dp[i] = min(dp[i - 2] + abs(h[i] - h[i - 2]), dp[i - 1] + abs(h[i] - h[i - 1]))

print(dp[N - 1])


Measured memory_bytes: 13980
import java.util.Scanner;
public class Main {
    public static void main(String[] at){
        Scanner scanner = new Scanner(System.in);
        int mon = scanner.nextInt();
        String[] hate = new String [scanner.nextInt()];
        for (int i = 0; i < hate.length; i++){
            hate[i] = scanner.next();
        }
        String money = Integer.toString(mon);
        int result = mon;
        boolean ok = true;
        while (ok){
            for (int i = 0; i < hate.length; i++){
                if (money.matches(".*" + hate[i] + ".*")){
                    result++;
                    money = Integer.toString(result);
                    break;
                } else if (i == hate.length-1){
                    ok = false;
                }
            }
        }

        System.out.println(result);


    }
}


Measured memory_bytes: 45936
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef pair<int, int>pii;
vector<pii>pat[100000];
bool flag[100000];
int d[100000];
void dfs(int node, int t)
{
	if (flag[node])
	{
		if (d[node] != t)
		{
			printf("No\n");
			exit(0);
		}
		return;
	}
	flag[node] = true;
	d[node] = t;
	for (int i = 0; i < pat[node].size(); i++)dfs(pat[node][i].first, t + pat[node][i].second);
}
int main()
{
	int num, way;
	scanf("%d%d", &num, &way);
	for (int i = 0; i < way; i++)
	{
		int za, zb, zc;
		scanf("%d%d%d", &za, &zb, &zc);
		za--, zb--;
		pat[za].push_back(make_pair(zb, zc));
		pat[zb].push_back(make_pair(za, -zc));
	}
	for (int i = 0; i < num; i++)
	{
		if (!flag[i])dfs(i, 0);
	}
	printf("Yes\n");
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cerr << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cerr<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 500010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = (1 << 30) - 1;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
mt19937 rng; //use it by rng() % mod, shuffle(all(vec), rng)
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
int P[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) cin >> P[i];
	sort(P, P + N);

	double res = P[0];
	rep(i, 1, N) {
		res = (res + P[i]) / 2.0;
	}
	cout << res << "\n";
}

uint32_t rd() {
	uint32_t res;
#ifdef __MINGW32__
	asm volatile("rdrand %0" :"=a"(res) ::"cc");
#else
	res = std::random_device()();
#endif
	return res;
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
    cerr << fixed;
	cerr.precision(6);
	rng.seed(rd());
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
	if(!freopen("in.txt", "rt", stdin)) return 1;
#endif	
	solve();
    cerr << "Time: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int A, B;
    int ans = 0;
    int sum = 1;
    cin >> A >> B;
    
    int up_A = A - 1;
    
    while(sum < B){
        ans++;
        sum += up_A;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    long x;
    cin >> x;
    long amari = x%100;
    int judge = amari/5;
    if(amari%5!=0) judge++;
    if((x/100)>=judge) cout << 1 << endl;
    else cout << 0 << endl;
}

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

using namespace std;

int main() {
  int N;
  
  cin >> N;
  
  vector<int> l;
  
  for (int i = 0; i < N; i++) {
    int v;
    
    cin >> v;
    
    l.push_back(v);
  }
  
  sort(l.begin(), l.end());
  
  long long sum = 0, tmp = 1;
  
  sum += l[0] + l[1];
  
  for (int i = 2; i < N; i++) {
    tmp *= 2;
    sum += tmp * l[i];
  }
  
  cout << (double)sum / (2.0 * tmp) << endl;
  
  return 0;
}

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

int main() {
  int n, k;
  cin >> n >> k;
  int count = 0;
  int res = n;
  for (int i=0; i<10000; i++) {
    ++count;
    res /= k;
    if (res == 0) break;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
s = gets.strip
y = s.slice(0, 2).to_i
m = s.slice(2, 2).to_i

ym = y >= 1 && y <= 12
mm = m >= 1 && m <= 12

if ym && mm
  puts "AMBIGUOUS"
elsif ym
  puts "MMYY"
elsif mm
  puts "YYMM"
else
  puts "NA"
end


Measured memory_bytes: 1788
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}

int main() {

    string S;
    cin >> S;

    int ans = INT_MAX;

    for (int i = 0; i < S.size() - 2; i++) {
        string s = S.substr(i, 3);
        ans = min(ans, abs(stoi(s) - 753));
    }

    cout << ans << endl;

    return 0;
}





























































Measured memory_bytes: 256
s=int(input())
x1=0
y1=0
x3=1
x2=10**9
if s==10**18:
  y3=10**9
  y2=0
else:
  y3=s//(10**9)+1
  y2=10**9-s%(10**9)
a=[x1,y1,x2,y2,x3,y3]
a=map(str,a)
print((' ').join(a))

Measured memory_bytes: 61920