akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <time.h>

#include <string>

const int MAX_N = 100050;
int N, x;

int ret[MAX_N * 2];

int main(int argc, char **argv) {
    std::cin >> N >> x;

    if (x == 1 || x == N * 2 - 1) {
        std::cout << "No" << std::endl;
        return 0;
    }

    if (x == N) {
        std::cout << "Yes" << std::endl;
        for (int i = 1; i <= N * 2 - 1; i++) {
            std::cout << i << std::endl;
        }
        return 0;
    }

    // 3 <= N 確定

    std::vector<int> res_val, res_pos;
    if (x < N) {
        ret[N] = 1;
        ret[N-1] = x;
        ret[N-2] = N * 2 - 1;
        ret[N+1] = N * 2 - 2;
        for (int i = 1; i <= N * 2 - 1; i++) {
            if (i != x && i != 1 && i < N * 2 - 2) {
                res_val.push_back(i);
            }
        }
    } else {
        ret[N] = N * 2 - 1;
        ret[N-1] = x;
        ret[N-2] = 1;
        ret[N+1] = 2;
        for (int i = 1; i <= N * 2 - 1; i++) {
            if (i != x && i != N * 2 - 1 && 2 < i) {
                res_val.push_back(i);
            }
        }
    }

    for (int i = 1; i <= N * 2 - 1; i++) {
        if (!(N - 2 <= i && i <= N + 1)) {
            res_pos.push_back(i);
        }
    }

    for (int i = 0; i < res_pos.size(); i++) {
        ret[res_pos[i]] = res_val[i];
    }

    std::cout << "Yes" << std::endl;
    for (int i = 1; i <= N * 2 - 1; i++) {
        std::cout << ret[i] << std::endl;
    }

    return 0;
}

Measured memory_bytes: 3956
import math
a, b = map(int, input().split())

x1 = a / 0.08
x2 = b / 0.1

ans = -1
zeinuki = int(min(x1,x2))
while zeinuki < max(x1,x2)+1:
  if math.floor(zeinuki * 0.08) == a and math.floor(zeinuki * 0.1) == b:
    ans = zeinuki
    break
  zeinuki += 1

print(int(ans))

Measured memory_bytes: 3064
n = gets.to_i
a = gets.split(' ').map(&:to_i)
cnt = 0

for i in 0..(n-1) do
  min_j = i
  for j in i..(n-1) do
    if a[j] < a[min_j] then
      min_j = j
    end
  end
  
  unless i == min_j then
    a[i], a[min_j] = a[min_j], a[i]
    cnt += 1
  end
end

puts a.join(' ')
puts cnt

Measured memory_bytes: 8632
l=list(input())
N=len(l)
Long=list()
for i in range(N):
  long=0
  for x in range(i,N):
    if l[x]=='A' or l[x]=='T' or l[x]=='C' or l[x]=='G':
      long+=1
    else:
      break
    Long.append(long)
if len(Long)==0:
  print('0')
else:
  print(max(Long))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define printYes() cout << "Yes" << endl;
#define printNo() cout << "No" << endl;
#define printVector(v) rep(i, v.size()) cout << v[i] << endl;

int main()
{
  int N;
  cin >> N;
  vector<long long> a(N);

  rep(i, N)
  {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ans = 0;
  rep(i, N)
  {
    int count = 0;
    while (a[i] % 2 == 0)
    {
      a[i] /= 2;
      count++;
    }
    ans += count;
  }

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

Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

public class Program
{
    public static void Main()
    {
        var nck = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var n = nck[0];
        var c = nck[1];
        var k = nck[2];

        var ts = Enumerable.Range(1, n)
            .Select(_ => int.Parse(Console.ReadLine()))
            .OrderBy(x => x)
            .ToArray();
        
        var demand = 1;
        var numPassengers = 1;
        var departureOn = ts.First() + k;
        foreach (var t in ts.Skip(1))
        {
            if (numPassengers >= c || departureOn < t)
            {
                ++demand;
                numPassengers = 0;
                departureOn = t + k;
            }
            ++numPassengers;
        }
        
        Console.WriteLine(demand.ToString());
    }
}


Measured memory_bytes: 20828
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    ll k;
    cin >> s >> k;
    int n = s.size();
    
    int flag1 = 0;  // 全て同じ文字かどうか
    rep(i, n) {
        if(s[i] != s[0]) {
            flag1 = 1;
        }
    }

    ll ans;
    if(!flag1) {
        ans = (n*k)/2LL;
    }
    else {  // 全て同じ文字ではないとき
        
        int now = 0;
        char t = s[0];
        ll cnt = 0;  // 1周期内で必要な操作回数
        rep(i, n) {

            if(i == n-1) {
                if(s[i] == t) {
                    now++;
                }
                cnt += now/2;
                break;
            }

            if(s[i] == t) {
                now++;
            }
            else {
                cnt += now/2;
                t = s[i];
                now = 1;
            }
        }

        if(s[0] != s[n-1]) {  // 先頭と末尾が異なる文字のとき
            ans = cnt*k;
        }
        else if(s[0] == s[n-1]) {  // 先頭と末尾が同じ文字のとき

            int mae = 0;
            rep(i, n) {
                if(s[i] != s[0]) {
                    break;
                }
                mae++;
            }

            int ushiro = 0;
            for(int i = n-1; i >= 0; i--) {
                if(s[i] != s[n-1]) {
                    break;
                }
                ushiro++;
            }

            cnt -= (mae/2 + ushiro/2);

            ll p = (mae + ushiro)/2;

            ans = mae/2 + cnt*k + p*(k-1) + ushiro/2;
        }
    }

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

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
    int n,sum=0,p,mx=0;
    cin >> n;
    while(n--){
        cin >> p;
        sum+=p;
        mx=max(mx,p);
    }
    sum-=mx/2;
    cout << sum;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(c) c.begin(),c.end()
#define init(c) memset(c,0,sizeof c)
#define S second
#define F first
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int N=20000005;
int n,k,x,t,a,b,m;
string s;
vi v;
int main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r" , stdin);
	#endif // ONLINE_JUDGE
	cin >> n >> a >> b;
	for(int i =a;i<=b;i++){
		if(i%n==0){
			cout <<"OK";
			return 0;
		}
	}
	cout << "NG";
	
	return 0;
}

Measured memory_bytes: 3636
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		public static long P = (long)1e9 + 7;
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			var a = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();

			var dic = new Dictionary<int, int>();
			for (int i = 0; i < n; i++) {
				if (dic.ContainsKey(a[i])) {
					dic[a[i]]++;
				} else {
					dic[a[i]] = 1;
				}
			}

			var keys = dic.Keys.OrderBy(x => x).ToArray();

			BigInteger ans = 1;
			int target = (n + 1) % 2;
			foreach (var k in keys) {
				if (k != target) {
					Console.WriteLine(0);
					return;
				}

				if (target == 0) {
					if (dic[k] != 1) {
						Console.WriteLine(0);
						return;
					}
				} else {
					if (dic[k] != 2) {
						Console.WriteLine(0);
						return;
					}

					ans *= 2;
				}

				target += 2;
			}

			Console.WriteLine(ans % P);
		}
	}
}

Measured memory_bytes: 31816
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

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

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

long long com(long long n,long long k){
	
}
long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}

class Point{
public:
	long long x;
	long long y;
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string a,b;
	cin>>a>>b;
	if(a.length()>b.length()){
		cout<<"GREATER"<<endl;
		return 0;
	}
	if(a.length()<b.length()){
		cout<<"LESS"<<endl;
		return 0;
	}
	long long i=0;
	if(a==b){
		cout<<"EQUAL"<<endl;
		return 0;
	}
		if(a<b){
			cout<<"LESS"<<endl;
			return 0;
		}
		if(a>b){
			cout<<"GREATER"<<endl;
			return 0;
		}
	
}


Measured memory_bytes: 256
/***

    Muhammad Imdad-Ul-Haque Rakib(Attari)
    CSE'19
    Chittagong,Bangladesh

***/

#include<bits/stdc++.h>

/**Definitions**/

#define   ld             long double
#define   ll             long long
#define   boost_         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define   pb             push_back
#define   ppb            pop_back
#define   ull            unsigned long long
#define   over           return 0
#define   scan(i,n,a)    for(i=0;i<n;i++) cin>>a[i]
#define   MP             make_pair
#define   spc            " "

using namespace std;

/** Predefined Functions **/

int gcd(int x,int y){
    if(x==0) return y;
    else return gcd(y%x,x);
}
bool sortbysec(const pair<int,int>&a, const pair<int,int>&b){ return (a.second<b.second); }
bool sortbysecinrev(const pair<int,int>&a, const pair<int,int>&b){ return (a.second>b.second); }
bool sortbysize(string &s1,string &s2){ return s1.size() < s2.size(); }
bool sortinrev(const pair<int,int> &a, const pair<int,int> &b){ return (a.first > b.first); }


int main(){

    boost_;

    int n;
    cin>>n;
    cout<<n+n*n+n*n*n<<endl;
    over;
}


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

#define vi vector<int>
#define pii pair<int, int>
#define vp vector<pii>

int main() {

    int N;
    cin >> N;

    vp A;
    int a;
    for (int i = 0; i < N; i++) {
        cin >> a;
        A.push_back(make_pair(-a, i));
    }

    set<pii> s;
    for (int i = 0; i < N; i++) {
        auto itr = s.upper_bound(A[i]);
        if (itr != s.end()) {
            s.erase(itr);
        }
        s.insert(A[i]);
    }

    cout << s.size() << endl;

    return 0;
}


Measured memory_bytes: 5748
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;
const int maxn=1e5;
const int maxm=2e5;
int n,m,flag,tot;
ll c,p,d,ans;
int pre[maxm*2+8],now[maxn+8],son[maxm*2+8];
bool vis[maxn+8],color[maxn+8];

int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}

void add(int u,int v)
{
    pre[++tot]=now[u];
    now[u]=tot;
    son[tot]=v;
}

void dfs(int x)
{
    vis[x]=1;
    for (int p=now[x];p;p=pre[p])
	{
	    int child=son[p];
	    if (!vis[child])
		{
		    color[child]=color[x]^1;
		    dfs(child);
		}
	    else
		    if (color[child]^color[x]^1) c-=flag,d+=flag,flag=0;
	}
}

int main()
{
    n=read(),m=read();
    for (int i=1;i<=m;i++)
	{
	    int u=read(),v=read();
	    add(u,v);
	    add(v,u);
	}
    for (int i=1;i<=n;i++)
	if (!now[i]) p++;
	else if (!vis[i]) flag=1,c++,dfs(i);
    ans=p*n+p*(n-p)+d*d+c*(d+c)*2;
    printf("%lld\n",ans);
    return 0;
}
    


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

int main() {

	int a = 0, b = 0, c = 0, p = 0;
	int ans = 0;

	cin >> a >> b >> c >> p;

	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if (500 * i + 100 * j + 50 * k == p) {
					ans += 1;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main() {
  string s, t;
  int ans=0;
  cin >> s >> t;
  int n=s.length();
  for(int i=0;i<n;i++) if(s[i] != t[i]) ans ++;
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n,count,ans;
  cin>>n;
  ans=2*(n/11);
  count=n%11;
  if(0<count && count<7){
    ans+=1;
  }else if(7<=count){
    ans+=2;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
/*######################################################
#########~~~~~####~~~~###~~##~~##~~##~~##~~##~~#########
#########~~##~~##~~##~~##~~~#~~##~~~#~~##~~##~~#########
#~~~~~~##~~~~~###~~~~~~##~~#~~~##~~#~~~##~~##~~##~~~~~~#
#########~~######~~##~~##~~##~~##~~##~~##~~##~~#########
#########~~######~~##~~##~~##~~##~~##~~###~~~~##########
######################################################*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#pragma GCC optimize("O3")
#define rtn return
#define endl '\n'
#define F first
#define S second
#define mt make_tuple
#define pb push_back
#define int long long
#define sz(x) (int) x.size()
#define value_at find_by_order
#define index_of order_of_key
#define fill(a, v) memset(a,v,sizeof(a))
#define copy(a, b) memcpy(b,a,sizeof(a))
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define rep(i, n) for(int i=0;i<(int)n;++i)
#define per(i, n) for(int i=(int)n-1;i>=0;--i)
#define rep1(i, n) for(int i=1;i<=(int)n;++i)
#define per1(i, n) for(int i=(int)n;i>=1;--i)
#define loop(i, begin, end) for(int i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " = " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " = " << arg1 << " |";
  __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef string str;
typedef long double db;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef vector<str> vstr;
typedef vector<db> vdb;

template<class T, class V> void remin(T &a, V b) { a > b ? a = b : a = a; }
template<class T, class V> void remax(T &a, V b) { a < b ? a = b : a = a; }
template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


const int INF = 1e18;
const db EPS = 1e-15;
const int MOD = 1e9 + 7;
const int N = 1e5 + 7;

int n, k;

int32_t main() {
  FAST_IO;
  cin >> n >> k;
  int ans = 0;
  for (int i = k; i <= n + 1; i++) {
    int L = i * (i - 1) / 2;
    int R = n * i - L;
		ans += R - L + 1;
  }
  cout << ans % MOD << '\n';
  rtn 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	string S;
	cin >> S;
	int len;
	len = S.length();
	if(len == 2){
		for(int i = 0;i<len-1;i++){
			cout << S[i];	
		}cout << S[len - 1] << endl;
	}
	if(len == 3){
		for(int i = 2;i>0;i--){
			cout << S[i];
		}cout << S[0] << endl;
	}
	return 0;
}

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

int main() {
    int n, q;
    cin >> n;
    
    int s[n];
    rep(i, n){
        cin >> s[i];
    }
    
    cin >> q;
    int t[q];
    rep(i, q){
        cin >> t[i];
    }
    
    int res = 0;
    rep(i, q){
        int r_min = 0;
        int r_max = n-1;
        int e = t[i];
        
        while(true){
            if(r_min > r_max) break;
            int idx = (r_min + r_max)/2;
            if(e != s[idx]){
                if(e > s[idx]){
                    r_min = idx + 1;
                }else{
                    r_max = idx - 1;
                }
            }else{
                ++res;
                break;
            }
        }
    }
    
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3604
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    let c=read::<i32>();
    println!("{}",if a==b{c}else if a==c{b}else{a})
}

Measured memory_bytes: 4352
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"5
IIDID"# => r#"2"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        s: chars,
    }
    // DP練習
    let mut v = vec![0; n + 1];

    for i in 0..n {
        v[i + 1] = v[i] + if s[i] == 'I' { 1  } else { -1 };
    }
    // デバッグコード
    // println!("{:?} {}", v, v.iter().max().unwrap());

    v.iter().max().unwrap().to_string()
}

Measured memory_bytes: 4352
import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

void main() {
    int n, m;

    scan(n, m);

    auto visited = new bool[](n);
    auto adj = new int[][](n, 0);
    auto rank = new int[](n);
    auto indeg = new int[](n);

    foreach (i ; 0 .. m) {
        int si, ti;
        scan(si, ti);
        adj[si] ~= ti;
        indeg[ti]++;
    }

    int num = 0;

    void bfs(int s) {
        auto q = Queue!(int)(n + 1);

        q.push(s);
        rank[num++] = s;
        visited[s] = true;

        while (!q.empty) {
            int v = q.front;
            q.pop;

            foreach (u ; adj[v]) {
                indeg[u]--;

                if (indeg[u] == 0 && !visited[u]) {
                    q.push(u);
                    rank[num++] = u;
                    visited[u] = true;
                }
            }
        }
    }

    foreach (i ; 0 .. n) {
        if (!visited[i] && indeg[i] == 0) bfs(i);
    }

    writefln("%(%s\n%)", rank);
}

struct Queue(T) {
    private {
        int N, head, tail;
        T[] data;
    }

    this(int n) {
        N = n + 1;
        data = new T[](N);
    }

    bool empty() {
        return head == tail;
    }

    bool full() {
        return (tail + 1) % N == head;
    }

    T front() {
        return data[head];
    }

    void push(T x) {
        assert(!full);
        data[tail++] = x;
        tail %= N;
    }

    void pop() {
        assert(!empty);
        head = (head + 1) % N;
    }

    void clear() {
        head = tail = 0;
    }
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 10948
#include<algorithm>
#include<cstdio>
using namespace std;

const int A = 1e9 + 7;
int h, w, k;
long dp[100][8][2];
int c[7];

int main() {
    scanf("%d %d %d", &h, &w, &k);
    
    for (int i = 0, j = 0, cnt = 0; i < 64; i++) {
        int x = i;
        do {
            if (x & 1 && (x >> 1) & 1) break;
            x >>= 1;
            if (x == 0) cnt++;
        } while (x > 0);
        if (i == (1 << j) - 1) c[j++] = cnt;
    }

    dp[0][0][0] = 1;    
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (i == 0) break;
            dp[i][j][0] = (dp[i - 1][j][0] * c[max(0, j - 1)] * c[max(0, w - j - 2)] + dp[i - 1][j][1]) % A;
        }
        for (int j = 0; j < w; j++) {
            if (j > 0) dp[i][j][1] = dp[i][j - 1][0] * c[max(0, j - 2)] * c[max(0, w - j - 2)];
            if (j < w - 1) dp[i][j][1] += dp[i][j + 1][0] * c[max(0, j - 1)] * c[max(0, w - j - 3)];
            dp[i][j][1] %= A;
        }
    }

    printf("%ld\n", (dp[h - 1][k - 1][0] * c[max(0, k - 2)] * c[max(0, w - k - 1)] + dp[h - 1][k - 1][1]) % A);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
list_w = list()
for i in range(n):
    list_w.append(input())
a = 0
i = 0
while i <= n-2:
    x = list_w[i]
    y = list_w[i+1]
    if x[-1] != y[0]:
        a += 1
        break
    if i > 0:
        for j in range(i):
            if x == list_w[j - 1]:
                a += 1
                break
    i += 1
if a == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3188
#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 ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ld double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
/*
    vec1.size();
    str1.length();
    vec1.pop_back;
*/
typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll, ll> pll;
typedef vector<pll> vplll;
#define rep(i,l,r) for (ll i = l; i < r; ++i)
#define reprev(i,l,r) for (ll i = r; i >= l; --i)
ll mod = 1e9+7;
ll expo_mod(ll x, ll y, ll p) 
{ 
    ll res = 1;
    x = x % p; 
    if (x == 0) 
        return 0; 
    while (y > 0) 
    {
        if (y%2==1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll gcd(ll a,ll b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n+1];
    rep(i,0,n)
    {
        cin>>arr[i];
    }
    ll cost[n+1];
    cost[0]=0;
    cost[1]=abs(arr[0]-arr[1]);
    rep(i,2,n)
    {
        cost[i]=min(cost[i-1]+abs(arr[i]-arr[i-1]),cost[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<cost[n-1]<<"\n";
    return 0;
}

Measured memory_bytes: 1792
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;

import java.util.*;

public class Main {
    long MOD = (long) 1e9 + 7;

    InputStream in;
    OutputStream out;

    public Main() {
        this(System.in, System.out);
    }

    public Main(InputStream in, OutputStream out) {
        this.in = in;
        this.out = out;
    }

    void run() {
        Scanner sc = new Scanner(this.in);
        PrintWriter out = new PrintWriter(this.out);

        // write your code
        int n = sc.nextInt(), m = sc.nextInt();
        int[] s = new int[n], t = new int[m];
        for (int i = 0; i < n; i++) {
            s[i] = sc.nextInt();
        }
        for (int i = 0; i < m; i++) {
            t[i] = sc.nextInt();
        }

        long[][] dp = new long[n + 1][m + 1];
        long[][] sum = new long[n + 1][m + 1];
        long ans = 0;

        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if (s[i] == t[j]) {
                    dp[i + 1][j + 1] = (sum[i][j] + 1) % MOD;
                }
                sum[i + 1][j + 1] = (MOD + sum[i][j + 1] + sum[i + 1][j] - sum[i][j] + dp[i + 1][j + 1]) % MOD;
//                debug(i, j);
//                debug(dp[i + 1]);
//                debug(sum[i + 1]);
            }
        }

        out.println((sum[n][m] + 1) % MOD);

        out.flush();
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }
}

Measured memory_bytes: 127532
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n, m;

vector<vector<int>> adj;

const int MAXN = 100005;
int color[MAXN];

bool bipartite;

void dfs(int u, int c) {
    color[u] = c;

    for (auto v : adj[u]) {
        if (color[v] == -1) {
            dfs(v, 1-c);
        }
        else if (color[v] == color[u]) {
            bipartite = false;
        }
    }
}

int main() {
    GI(n);
    GI(m);

    adj.resize(n+1);

    FORN(i, m) {
        int a, b;
        GI(a);
        GI(b);

        adj[a].PB(b);
        adj[b].PB(a);
    }

    memset(color, -1, sizeof color);

    bipartite = true;
    dfs(1, 0);

    if (!bipartite) {
        printf("%lld\n", 1LL*n*(n-1)/2 - m);
    }
    else {
        int cnt0 = 0;
        int cnt1 = 0;

        FOR1(i, n) {
            if (color[i] == 0) cnt0++;
            else cnt1++;
        }

        printf("%lld\n", 1LL*cnt0*cnt1 - m);
    }

    return 0;
}

Measured memory_bytes: 6784
def get_val(x):
    left = x
    while True:
        tmp = left // 10
        if tmp == 0:
            break
        left = tmp
    return left, x % 10


N = int(input())

counter = dict()
for x in range(1, N+1):
    key = get_val(x)
    if key not in counter:
        counter[key] = 0
    counter[key] += 1

res = 0
for i in range(1, N+1):
    left, right = get_val(i)
    if right == 0:
        continue
    if (right, left) in counter:
        res += counter.get((right, left))

print(res)


Measured memory_bytes: 42204
#include<stdio.h>

int main(){
	int H,W;
	scanf("%d%d",&H,&W);
	int N;
	scanf("%d",&N);
	int a[N];
	int sum[N+1];
	sum[0]=0;
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
		sum[i+1]=sum[i]+a[i];
	}
	int ans[H][W];
	int count=0;
	int color=1;
	for(count=0;count<H*W;count++){
		int h,w;
		h=count/W;
		w=count%W;
		if(h%2!=0)w=W-w-1;
		if(count<sum[color])ans[h][w]=color;
		else{
			color++;
			ans[h][w]=color;
		}
	}
	
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			printf("%d",ans[i][j]);
			if(j<W-1)printf(" ");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#define rep(index,num) for(int index=0;index<num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
typedef long long ll;
using namespace std;
typedef pair<int,int> pint;
const ll INF = 10000000000000000;
int main(){
	int N,A[200000];
	ll Asum[200001];
	ll absmin=INF;
	int lcut=1,rcut=3;
	scan(N);
	Asum[0]=0;
	rep(i,N){
		scan(A[i]);
		Asum[i+1]=Asum[i]+A[i];
	}
	for(int mcut=2;mcut<=N-2;mcut++){
		ll lmax=INF,lmin=-1,rmax=INF,rmin=-1;
		for(;lcut<mcut;lcut++){
			if(abs((Asum[mcut]-Asum[lcut])-(Asum[lcut]-Asum[0]))<abs((Asum[mcut]-Asum[lcut+1])-(Asum[lcut+1]-Asum[0]))||lcut==mcut-1){
				lmax=max(Asum[mcut]-Asum[lcut],Asum[lcut]-Asum[0]);
				lmin=min(Asum[mcut]-Asum[lcut],Asum[lcut]-Asum[0]);
				break;
			}
		}
		if(rcut<=mcut) rcut=mcut+1;
		for(;rcut<N;rcut++){
			if(abs((Asum[N]-Asum[rcut])-(Asum[rcut]-Asum[mcut]))<abs((Asum[N]-Asum[rcut+1])-(Asum[rcut+1]-Asum[mcut]))||rcut==N-1){
				rmax=max(Asum[N]-Asum[rcut],Asum[rcut]-Asum[mcut]);
				rmin=min(Asum[N]-Asum[rcut],Asum[rcut]-Asum[mcut]);
				break;
			}
		}
		absmin=min(absmin,abs(max(lmax,rmax)-min(lmin,rmin)));
		//printf("lcut:%d mcut:%d rcut:%d lmax:%lld lmin:%lld rmax:%lld rmin:%lld absmin:%lld\n",lcut,mcut,rcut,lmax,lmin,rmax,rmin,absmin);
	}
	prin(absmin);
	return 0;
}


Measured memory_bytes: 2560
var answer : Long=0
tailrec fun divider(get:Long) {
    var newget= get
    answer+=1
    if(newget == 1L){
        return
    }
    else{
        if(newget % 2L == 1L)  newget-= 1L
        divider(newget/2)
    }
}
fun kakeru(get:Long): Long {
    var retunnumber :Long=1
    for (i in 0 until get ){
        retunnumber *= 2
    }
    return retunnumber
}
fun main(args: Array<String>) {
    val HP: Long? = readLine()?.toLong()
    if (HP != null) {
        divider(HP)
    }
    var num : Long=0
    for (i in 0 until answer){
        num+= kakeru(i)
    }
    println(num)
}

Measured memory_bytes: 33780
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm> 
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include  <ctime>
#include <iomanip>
using namespace std;

#define ll                    long long int
#define ull                   unsigned long long int
#define loop(i,a,b)           for(int i=(int)a;i<(int)b;++i)
#define rloop(i,a,b)          for(int i=(int)a;i<=(int)b;++i)
#define loopl(i,a,b)          for(ll i=(ll)a;i<(ll)b;++i)
#define loopr(i,a,b)          for(int i=(int)a;i>=(int)b;--i)
#define count_1(n)            __builtin_popcountll(n)
#define pb                    push_back
#define eb                    emplace_back
#define ab(a)                 (a<0)?(-1*a):a
#define pc                    putchar
#define gc                    getchar
#define mset(a,b,c)           loop(i,0,b) a[i]=c
#define mp                    make_pair
#define itoc(c)               ((char)(((int)'0')+c))
#define all(p)                p.begin(),p.end()
#define max(x,y)              ((x>y)?x:y)
#define min(x,y)              ((x<y)?x:y)
#define mid(s,e)              (s+(e-s)/2)
#define vi                    vector<int>
#define vvi                   vector<vector<int>>
const ll MOD = 998244353;

ll modpow(ll a, ll b, ll mod) { ll res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a; res%=mod; a = a * a; a%=mod; }return res; }
//ll p(ll a, ll b) { ll res = 1; for (; b; b >>= 1) { if (b & 1)res = res * a;a = a * a; }return res; }

struct Matrix {
    ll** mat;
    ll n, m;
    Matrix(int a, int b) {
        n = a;
        m = b;
        mat = new ll*[a];
        loop(i, 0, a) {
            mat[i] = new ll[b]; loop(j, 0, b) mat[i][j] = 0;
        }
    }
    Matrix operator *(Matrix op) {
        Matrix ans(n, op.m);
        loop(i, 0, n) {
            loop(j, 0, op.m) {
                loop(k, 0, m) { ans.mat[i][j] += mat[i][k] * op.mat[k][j]; }
            }
        }
        return ans;
    }
    void operator %(int d) {
        loop(i, 0, n) { loop(j, 0, n) mat[i][j] %= d; }
    }
    Matrix exp(ll b) {
        Matrix ans(n, m);
        Matrix a(n, m);
        loop(i, 0, n) { loop(j, 0, m) a.mat[i][j] = mat[i][j]; }
        loop(i, 0, n) { ans.mat[i][i] = 1; }
        for (; b; b >>= 1) { if (b & 1)ans = ans * a; a = a * a; ans % MOD; a % MOD; }
        return ans;
    }
};


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    /* code */
    ll n, k; cin >> n >> k;
    vector<ll> l(k), r(k);
    loop(i,0,k) cin >> l[i] >> r[i];
    vector<ll> poss(n+1);
    loop(i,0,k) {
        loop(j,l[i],r[i]+1) poss[j] = 1;
    }
    vector<ll> dp(n); dp[0] = 1;
    vector<ll> hold(k);
    loop(i,1,n) {
        loop(j,0,k) {
            if(i-l[j]>=0) hold[j]+=dp[i-l[j]]; hold[j]%=MOD;
            if(i-r[j]-1>=0) hold[j]-=dp[i-r[j]-1]; hold[j]+=MOD; hold[j]%=MOD;
            dp[i] += hold[j]; dp[i] %= MOD;
        }
    }
    cout << dp[n-1] << "\n";
    /* end code */
}

Measured memory_bytes: 6348
#include <iostream>
#include <array>
#include <algorithm>
   
int main(){
    std::array<u_int, 10> heights;
      
    for (u_int i = 0; i < 10; ++i){
        std::cin >> heights[i];
    }
      
    std::sort(heights.begin(), heights.end(), std::greater<u_int>());
      
    for (u_int i = 0; i < 3; ++i){
        std::cout << heights[i] << std::endl;
    }
     
    return 0;
}

Measured memory_bytes: 3052
def main():
    N, K = (int(i) for i in input().split())
    ans = 0
    if K == 0:
        return print(N**2)
    for a in range(1, N+1):
        r = N % a
        p = (N - r) // a
        ans += p * max(0, a - K)
        ans += max(0, r - K + 1)
    print(ans)


if __name__ == '__main__':
    main()


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

namespace _0049_Blood_Groups
{
    class Program
    {
        static void Main(string[] args)
        {
            string str;
            int countA = 0;
            int countB = 0;
            int countO = 0;
            int countAB = 0;
            while ((str = Console.ReadLine()) != null)
            {
                string[] input = str.Split(',');
                if (input[1] == "A")
                {
                    countA++;
                }
                else if (input[1] == "B")
                {
                    countB++;
                }
                else if (input[1] == "AB")
                {
                    countAB++;
                }
                else if (input[1] == "O")
                {
                    countO++;
                }
            }
            Console.WriteLine(countA);
            Console.WriteLine(countB);
            Console.WriteLine(countAB);
            Console.WriteLine(countO);
        }
    }
}



Measured memory_bytes: 15872
N=int(input())
S=input()
#初めて出てきたときのインデックスをめも
lmemo=[-1]*10
rmemo=[-1]*10
for i in range(N-2):
    ls=int(S[i])
    rs=int(S[-(i+1)])
    if lmemo[ls]==-1:
        lmemo[ls]=i
    if rmemo[rs]==-1:
        rmemo[rs]=N-(i+1)
ans=0
#print(lmemo,rmemo)
for l in lmemo:
    for r in rmemo:
        if l+1<r and l>=0 and r>=0:
            ans+=len(set(S[l+1:r]))


print(ans)


Measured memory_bytes: 67676
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

void pr(int ans){
    cout1(ans)
    exit(0);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b,c;
    cin>>a>>b>>c;
    
    if(a==b&&b==c){
        if(a%2) pr(0);
        else pr(-1);
    }
    
    
    ll cnt=0,sum=a+b+c;
    while(a%2==0&&b%2==0&&c%2==0){
        ll na=(sum-a)/2;
        ll nb=(sum-b)/2;
        ll nc=(sum-c)/2;
        a=na;
        b=nb;
        c=nc;
        cnt++;
    }
    cout1(cnt)
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
      
      //入力
     int N = sc.nextInt();
     //九九リストを用意する
     List<Integer> kukulist = new ArrayList<>();
    
     //リストに九九を追加していく
     for(int i=1; i<=9; i++){
         for(int j=1; j<=9; j++){
            kukulist.add(i*j);
            }
     }
     //九九で表せる数字かどうか
     System.out.println(kukulist.contains(N) ? "Yes":"No");
   }
}

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

//#pragma GCC optimize("O3,Ofast,no-stack-protector,unroll-loops,fast-math")

//#define int long long
typedef pair <int, int> pii;

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	long double l;
	cin >> l;
	cout << setprecision(10) << l * l * l / 27;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;
typedef pair<ll, int> P;

const ll mod = 1000000007LL;

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

    int n, m;
    cin >> n >> m;
    vector <ll> A, B;
    for (int i = 0; i < n; i++) {
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(A.begin(), A.end(), greater<ll>());

    for (int i = 0; i < m; i++) {
        ll b;
        cin >> b;
        B.push_back(b);
    }
    sort(B.begin(), B.end(), greater<ll>());

    int a = 0, b = 0;
    ll ret = 1;
    for (int k = n * m; k > 0; k--) {
        //cout << A[a] << " " << B[b] << " " << ret << endl;
        if (a < n && b < m && A[a] == k && B[b] == k) {
            a++; b++;
        } else if (a < n && A[a] == k) {
            ret = ret * b % mod;
            a++;
        } else if (b < m && B[b] == k) {
            ret = ret * a % mod;
            b++;
        } else {
            ret = ret * (a * b - (n * m) + k) % mod;
        }
    }

    cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 256
// Problem : B - Distance 
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#define _CRT_SECURE_NO_WARNINGS
#include <queue>
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
double gdist(double x1,double y1,double x2,double y2)
{
	double dx = x1 - x2,dy = y1 - y2;
	return sqrt(dx * dx + dy * dy);
}
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n,d;cin >> n >> d;
	int res = 0;
	for(int i = 0;i < n;++i)
	{
		double x,y;cin >> x >> y;
		if(gdist(x,y,0,0) <= d)	++res;
	}
	cout << res;
    return 0;
}


Measured memory_bytes: 3188
import random
import time

t1=time.time()
d=int(input())
c=input()
cl=[int(n) for n in c.split()]
sl=list()
for i in range(d):
    s=input()
    sl=sl+[int(n) for n in s.split()]
tl=list()
for i in range(d):
    tl.append(random.randint(1,26))
sat=0
for i in range(d):
    sat+=sl[i*26+tl[i]-1]

def decr(tl,cl):
    dec=0
    for i in range(26):
        last=[a for a, x in enumerate(tl) if x==i+1]
        if last==list():
            dec+=(d*(d+1)/2)*cl[i]
        else:
            for v in range(len(last)):
                if v!=len(last)-1:    
                    dec+=cl[i]*(last[v+1]-last[v]-1)*(last[v+1]-last[v])/2
                else:
                    dec+=cl[i]*(d-last[v]-1)*(d-last[v])/2
            dec+=cl[i]*(last[0])*(last[0]+1)/2
    return(int(dec))

oldscore=sat
oldans=oldscore-decr(tl,cl)
oldtl=[int(x) for x in tl]
t2=time.time()
while t2-t1<1.85:
    if round(t2)/2==0:
        d1=random.randint(1,d)
        d2=random.randint(1,d)
        q1=tl[d2-1]
        q2=tl[d1-1]
        cha=sl[(d1-1)*26+q1-1]-sl[(d1-1)*26+tl[d1-1]-1]+sl[(d2-1)*26+q2-1]-sl[(d2-1)*26+tl[d2-1]-1]
        tl[d2-1]=q1
        tl[d1-1]=q2
        newscore=oldscore+cha
        newans=newscore-decr(tl,cl)
    else:
        da=random.randint(1,d)
        q=random.randint(1,26)
        cha=sl[(da-1)*26+q-1]-sl[(da-1)*26+tl[da-1]-1]
        tl[da-1]=q
        newscore=oldscore+cha
        newans=newscore-decr(tl,cl)
    r=0
    if newans<oldans:
        if (t2-t1)/1.85<random.random():
            r=1
    if r==1:
        tl=[int(x) for x in oldtl]
    else:
        oldans=newans
        oldtl=[int(x) for x in tl]
        oldscore=newscore
    t2=time.time()
for i in range(d):
    print(tl[i])

        

Measured memory_bytes: 90772
#include <bits/stdc++.h>
using namespace std;
// types
typedef long long ll; 
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
// IO
#define fo(i, n) for (int i = 0; i < n; i++)
#define fo1(i, n) for (int i = 1; i <= n; i++)
#define sc(n) scanf("%d", &n) 
#define sca(a, n) fo(i, n) sc(a[i])
#define pd(a) printf("%d ", a)
#define pld(a) printf("%d\n", a)
#define pda(a, n) fo(i, n) pd(a[i])
#define pl printf("\n")
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b) 
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
// math
const ll mod = 1e9+7;
template<typename T> T gcf(T a, T b) {return (b == 0) ? a : gcf(b, a%b);} 
template<typename T> T lcm(T a, T b) {return (a*b)/gcf(a, b);}
template<typename T> T sumTo(T x) {return x * (x+1) / 2;}
template<typename T> T sumSquaresTo(T x) {return x * (x+1) * (2*x+1) / 6;}
template<typename T> T ceilDiv(T n, T d) {return (n+d-1)/d;}

void solve() {
    int n, k; cin >> n >> k;
    int ans = 0;
    while (n) {
        ans++;
        n /= k;
    }
    cout << ans;
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
w,h,x,y,r = gets.split(' ').map(&:to_i)
w = w - 2*r
h = h - 2*r
x = x - r
y = y - r

if w >= x && h >= y && w >= 0 && h >= 0 && x >= 0 && y >= 0 && r >= 0 then puts "Yes" 
else puts "No"
end

Measured memory_bytes: 8680
//Sasayego! Sasayego! Shinzou wo Sasageyo!

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bitset>
#include <ctime>
#define debug(x)  cerr << #x << " = " << x << endl
#define lid (id << 1)
#define rid (lid ^ 1)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 3e3 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int a[maxN], arumin[maxN];
vector <int> G[maxN];

int LEVI(int v, int p = 0){
	for (int u : G[v]){
		if (u == p)
			continue;
		int b = LEVI(u, v);
		if (a[v] > a[u])
			arumin[v] |= !b;
	}
	return arumin[v];
}

int main(){
	time_t START = clock();
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++)
		scanf("%d", a + i);
	for (int i = 1; i < n; i++){
		int u, v; scanf("%d%d", &u, &v);
		G[u].push_back(v);
		G[v].push_back(u);
	}
	for (int i = 1; i <= n; i++){
		memset(arumin, 0, sizeof arumin);
		if (LEVI(i))
			printf("%d ", i);
	}
	printf("\n");
	time_t FINISH = clock();
	cerr << "Execution time: " << (ld)(FINISH - START) / CLOCKS_PER_SEC * 1000.0 << " milliseconds.\n";
	return 0;
}
 



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

int main()
{
  int n;
  int plc = 1;
  ll k;
  ll cnt = 0;
  cin >> n >> k;
  vector<int> trans(n + 1, -1);
  vector<int> pass(n + 1, -1);
  pass[1] = 0;
  for (int i = 1; i <= n; i++) {
    cin >> trans[i];
  }
  while (k > 0) {
    plc = trans[plc];
    k--;
    cnt++;
    if (pass[plc] != -1) {
      int period = cnt - pass[plc];
      k %= period;
      rep(i, k) {
        plc = trans[plc];
      }
      cout << plc << endl;
      return 0;
    }
    pass[plc] = cnt;
  }
  cout << plc << endl;

  return 0;
}


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

int main(){
  int a,b;

  scanf("%d %d", &a, &b);

  if(a > 9 || b > 9) printf("-1\n");

  else printf("%d\n", a*b);

  return 0;
}

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

#define lli long long int
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define INF 1000000007
#define endl "\n"
#define max(aa, bb) (aa > bb ? aa : bb)
#define min(aa, bb) (aa < bb ? aa : bb)

int main(){
    lli n, x, sum=0;
    cin>>n>>x;
    vector<lli> w(n), val(n);
    for (lli i = 0; i < n; i++){
        cin>>w[i]>>val[i];
        sum+=val[i];
    }
    vector<lli> dp(sum+1, INF);
    dp[0]=0;
    for (lli i = 0; i < n; i++){
        for (lli tmp = sum-val[i]; tmp >=0; tmp--){
            dp[tmp+val[i]]=min(dp[tmp+val[i]], dp[tmp]+w[i]);
        }
    }
    lli cvp=0;
    for (lli i = 0; i <= sum; i++){
        if(dp[i]<=x) cvp=max(cvp, i);
    }
    cout<<cvp;
}

Measured memory_bytes: 3992
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, c, ans;
	cin >> a >> b >> c;
	ans = min(a + b, min(b + c, c + a));
	cout << ans << "\n";

	return 0;
}


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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  else if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
using System;

public class hello
{
	public static void Main()
	{
		var n = int.Parse(Console.ReadLine().Trim());
		string[] s = Console.ReadLine().Trim().Split(' ');
		var ans = getTF(s[0], s[1]);
		if (n == 2) { Console.WriteLine(ans); goto end; }
		for (int i = 2; i < n; i++)
			ans = getTF(ans, s[i]);
		Console.WriteLine(ans);
	end:;
	}
	static string getTF ( string a, string b)
	{
		if (a == "T" && b == "T") return "T";
		else if (a == "T" && b == "F") return "F";
		else if (a == "F" && b == "T") return "T";
		else return "T";
	}
}



Measured memory_bytes: 21856