akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

/***typededfs***/
typedef long long ll;
typedef long double ldb;

/***defines***/
#define M1 1000000007
#define M2 998244353
#define F first
#define S second
#define pb push_back
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forz(i,n) for(int i=0;i<(n);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define rforz(i,n) for(int i=(n-1);i>=0;i--)
#define rfore(i,a,b) for(int i=(a);i>=(b);i--)
#define test int T; cin>>T; while(T--)


int main(){ 
      FASTIO;
      int n;
      cin>>n;
      int h[n];
      forz(i,n)cin>>h[i];
      int dp[n+1]{};
      dp[1]=abs(h[1]-h[0]);
      //cout<<"dp["<<1<<"]= "<<dp[1]<<' ';
      fore(i,2,n-1){
            dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
            //cout<<"dp["<<i<<"]= "<<dp[i]<<' ';
      }
      cout<<dp[n-1];
}


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

int now[27];
int dp[100005] = {0};
int n;
string s, dummy;

int solve();

int main() {
  int i;
  cin >> n;
  for(i = 0; i < n; ++i) {
    cin >> dummy;
    s += dummy[0];
  }
  for(i = 0; i < 26; ++i) now[i] = -1000000000;
  cout << solve() << endl;
  return 0;
}

int solve() {
  int i, j, nown;
  for(i = 0; i < n; ++i) {
    nown = s[i] - 'a';
    now[nown] = max(now[nown], dp[i - 1]);
    if(i != 0) dp[i] = max(dp[i - 1], now[nown]);
    for(j = 0; j < 26; ++j) ++now[j];
  }
  return n - dp[n - 1];
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
int main(){
     long long a,b,c,d;
     cin>>a>>b>>c;
     d=min(a,c);
     a-=d;
     c-=d;
     b-=min(b,c);
     cout<<a<<" "<<b;
     return 0;
}


Measured memory_bytes: 256
using System;
using System.IO;

class Program{
    static void Main(string[] args){
        var S = Console.ReadLine();
        var answer = 0;
        var count = 0;
        for (var i = 0; i < S.Length; i++){
            var l = S[i];
            if (!(l == 'A' || l == 'C' || l == 'G' || l == 'T'))
            {
                if (answer < count) answer = count;
                count = 0;
                continue;}
            count++;}
        if (answer < count) answer = count;
        var writer = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(writer);
        Console.WriteLine(answer);
        Console.Out.Flush();}}

Measured memory_bytes: 25892
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int main() {
	int n, m;
	cin >> n >> m;
	vector<string> s;
	REP(i, n) {
		string a;
		cin >> a;
		s.push_back(a);
	}
	for (int i = 0;i < 2 * n;++i) {
		for (int q = 0;q < m;++q) {
			cout << s[i / 2][q];
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int[] min = new int[n-1];
		int max = scn.nextInt();;
		for(int i = 0;i<n-1;i++) {
			int x = scn.nextInt();
			if(max<x) {
				min[i]=max;
				max = x;
			}else {
				min[i]=x;
			}
		}
		int sum = 0;
		for(int x:min) {
			sum+=x;
		}
		if(max<sum) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int n;
void solve(){
  int i=0;
  for(;n/10>0;i++){
    int s=n,n_=0;
    for(int j=10;;j*=10){
      int u=s/j;
      if(u==0)break;
      int l=s%j;
      n_=max(n_,u*l);
    }
    n=n_;
  }
  cout<<i<<endl;
}

int main(){ _;
  int q;cin>>q;
  REP(i,q){
    cin>>n;
    solve();
  }
}

Measured memory_bytes: 1192
fun main(args: Array<String>) = println(run {
    fun List<Int>.accumulated(): List<Long> { var sum = 0L; return this.map { sum += it; sum } }
    val (n,x) = readLine()!!.split(" ").map { it.toInt() }
    val l = readLine()!!.split(" ").map { it.toInt() }

    1 + l.accumulated().count { it <= x }
})



Measured memory_bytes: 37744
anscnt = 0
n = int(input())
for i in range(1,n+1):
    if i%2==0:
        pass
    else:
        cnt = 0
        for j in range(1,i+1):
            if i%j == 0:
                cnt +=1
            if cnt ==8:
                anscnt +=1
                break
print(anscnt)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <numeric>
#include <utility>
#include <iomanip>

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    char a;
    cin >> a;
    if ('a' <= a && a <= 'z')
        cout << 'a' << endl;
    else
        cout << 'A' << endl;
}


Measured memory_bytes: 3040
#include <iostream>
#include <queue>
#include <algorithm>

int main(){
    using namespace std;

    int n, M[101][101] = {};
    cin >> n;
    for(int i = 0; i < n; ++i){
        int num, src;
        cin >> src >> num;
        for(int j = 0; j < num; ++j){
            int dest;
            cin >> dest;
            M[src][dest] = 1;
        }
    }
    int m;
    cin >> m;
    for(int i = 0; i < m; ++i){
        int src, dest, ttl, d[n + 1];
        fill(d, d + n + 1, -1);

        cin >> src >> dest >> ttl;
        d[src] = 1;
        queue<int> q;
        q.push(src);
        while(!q.empty()){
            int const u = q.front();
            q.pop();
            for(int v = 1; v < n + 1; ++v){
                if(M[u][v] == 1 && d[v] == -1){
                    d[v] = d[u] + 1;
                    q.push(v);
                }
            }
        }
        if(d[dest] == -1){
            cout << "NA";
        }else if(ttl - d[dest] >= 0){
            cout << d[dest];
        }else{
            cout << "NA";
        }
        cout << endl;
    }
}

Measured memory_bytes: 0
#include<stdio.h>
int main()
{
	long long int a, b, c, d;
	scanf("%lld %lld %lld %lld", &a, &b, &c, &d);
	long long int ans = b * d;
	if (ans < a * c)
		ans = a * c;
	if (ans < a * d)
		ans = a * d;
	if (ans < b * c)
		ans = b * c;
	printf("%lld", ans);
	return 0;
}

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

template<class t> void vin(vector<t>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    ll n, l, t;
    cin >> n >> l >> t;
    vector<ll> x(n), w(n);
    rep(i, n) cin >> x[i] >> w[i];
    vector<ll> tmp(n);
    rep(i, n) {
        if (w[i] == 1) tmp[i] = (x[i] + t) % l;
        else tmp[i] = ((x[i]-t)%l+l)%l;
    }
    sort(tmp.begin(), tmp.end());
    ll cur = 0;
    rep(i, n) {
        if (w[i] == 1) cur -= (t-(l-x[i])+l)/l;
        else cur += (t-(x[i]+1)+l)/l;
    }
    cur = (cur%n+n)%n;
    vector<ll> ans(n);
    rep(i, n) ans[(i+cur)%n] = tmp[i];
    rep(i, n) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 4352
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        // 整数の入力
        String s = sc.next();
      int flag=0;
      for(int i=0;i<3;i++){
        if(s.charAt(i)==s.charAt(i+1)) flag++;
      }
    
        System.out.println(flag==0?"Good":"Bad");
    }

}


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

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int x=max(a,max(b,c));
  int ans=(a+b+c-x)+x*pow(2,k);

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


Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws IOException
	{
		int n=nextInt();
		int m=nextInt();
		int a[]=new int[n+1];
		int freq[]=new int[n+1];
		for(int i=1;i<=n;i++)
		{
			a[i]=nextInt();
			freq[a[i]]++;
		}
		int covered[]=new int[n+1];
		for(int i=n;i>=1;i--)
		{
			if(freq[i]!=0)
				for(int j=0;j<freq[i] && i-j>=1;j++)
					covered[i-j]++;
		}
		int uncovered=0;
		for(int i=1;i<=n;i++)
			if(covered[i]==0)
				uncovered++;
		for(int i=1;i<=m;i++)
		{
			int x=nextInt();
			int y=nextInt();
			int l=a[x]-freq[a[x]]+1;
			if(l>=1 && covered[l]<=1)
				uncovered++;
			if(l>=1)
				covered[l]--;
			freq[a[x]]--;
			freq[y]++;
			l=y-freq[y]+1;
			if(l>=1 && covered[l]==0)
				uncovered--;
			if(l>=1)
				covered[l]++;
			a[x]=y;
			out.println(uncovered);
		}
	}

	 
	///////////////////////////////////////////////////////////

	public void run()throws IOException
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws IOException{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws IOException{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws IOException{
		return br.readLine();
	}
	int nextInt()throws IOException{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws IOException{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws IOException{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 74448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
ll ans[200000] = {};

int main()
{
ll n,q;
scanf("%ld %ld", &n, &q);
vector<vector<ll>> g(n);
rep(i, n-1)
{
    ll a,b;
    scanf("%ld %ld", &a, &b);
    g[a-1].push_back(b-1);
    g[b-1].push_back(a-1); //無向辺
}
ll po[n]={};
rep(i,q){
ll p , x ;
scanf("%ld %ld", &p, &x);
po[p-1]+=x;
}
stack<ll> s;
bool see[n]={};
s.push(0);
s.push(0);
ll now=0;
while(s.size()!=0){
  ll te=s.top();
  s.pop();
  if(!see[te]){
    see[te]=1;
    now+=po[te];
    ans[te]=now;
    for (auto p : g[te])
    {
      if (see[p])
          continue;
      s.push(p);
      s.push(p);
    }
  }
  else{
    now-=po[te];
  }
}
rep(i,n)
cout << ans[i] << " ";
cout << endl;
return 0;
}


Measured memory_bytes: 21232
W, H, x, y, r = map(int,input().split())

if (0 <= x <= W) and (0 <= y <= H):
    if (x+r <= W) and (x-r >= 0) and (y+r <= H) and (y-r >= 0):
        print('Yes')
    else:
        print('No')
else:
    print('No')



Measured memory_bytes: 5596
# ｎとｍの取得
data = input().split()
n = int(data[0]) #n == 人数
m = int(data[1]) #m == 数字の種類
ans = 0
#ｎ回データを取得してカウント

j = 1 #j == 好きな数字
i = 1 #i == 行数カウンタ
c = [0] * (m  *2)#c == ある数が含まれているかのカウンタ　0で初期化
    #データの取得

while i <= n:
    tmp = [int(s) for s in input().split()]
    td = tmp[1:] #td == 好きな番号
    tn = tmp[0]  #tn == 好きな番号の数
    
    # 数字が含まれているかの比較
    while j <= m: # jがすべての数字について実行
        
        if j in td: # jがｔｄに含まれるかの分岐
            j = int(j) #　ｊを数値に戻す
            
            c[j] += 1 # ｃのｊ番目の要素にカウント
        j = int(j) #if ではじかれたとき用にｊを数値に戻す
        j += 1# ｊをカウント
    j = 1    
    i += 1 # iをカウント

# 全てに含まれている数字の集計

for x in c:
    if x == n:
        ans += 1



print(ans)


Measured memory_bytes: 3064
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int t = sc.nextInt();
        List<Integer> a = new ArrayList<>();
        for (int i = 0; i < t; i++) {
            a.add(sc.nextInt());
        }
        Collections.sort(a);
        int cnt = 0;
        for (int i = 0; i < t - 1; i++) {
            cnt += a.get(i);
        }
        int ans = a.get(t - 1) - cnt - 1;
        if (ans <= 0) {
            System.out.println(0);
            return;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23124
// AOJ 0592
#include<cstdio>
#define rep(i,a) for( int i = 0; i != (a); ++i )

int main()
{
	int sum = 0;
	rep( i, 5 )
	{
		int a;
		scanf( "%d", &a );
		sum += a >= 40 ? a : 40;
	}

	printf( "%d\n", sum/5 );

	return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int a,b;
  cin >> a >> b;
  
  if(a>=1 && a<=9 && b>=1 && b<=9) cout << a*b << endl;
  else cout << -1 << endl;
 
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int a[100001];
	int i,m,k=0;
	m=n;
	for(i=0;m>0;i++)
	{
		a[i]=m%10;
		m/=10;
		k+=a[i];
	}
	if(n%k==0)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

Measured memory_bytes: 128
#![allow(unused_imports)]
use std::io;
use std::cmp::*;
use std::collections::*;
#[allow(dead_code)]
const M: i64 = 1e9 as i64 + 7;

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}
#[allow(dead_code)]
fn read<T>() -> T where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().trim().parse().unwrap()
}
#[allow(dead_code)]
fn readv<T>() -> Vec<T> where T: std::str::FromStr, T::Err : std::fmt::Debug {
    read_line().split(' ').map(|a| a.trim().parse().unwrap()).collect()
}

use std::time::Instant;
fn main() {
    let _ = read::<usize>();
    let aa = readv::<usize>();
    let bb = readv::<usize>();
    let x = aa.iter().fold(0, |acc, &a| acc ^ a);
    let (mut aa, bb): (Vec<_>, Vec<_>) = aa.iter().zip(bb.iter()).filter(|&(&a, &b)| a != b).unzip();
    let n = aa.len();
    aa.push(x);
    let mut nums = HashMap::with_capacity(n + 1);
    for &a in &aa {
        *nums.entry(a).or_insert(0) += 1;
    }
    // let mut nums: HashMap<_, i32> = aa.iter()
    //     .fold(HashMap::with_capacity(n + 1), |mut acc, &a| { *acc.entry(a).or_insert(0) += 1; acc });
    for &b in &bb {
        *nums.entry(b).or_insert(0) -= 1;
        if nums[&b] < 0 {
            println!("{}", -1);
            return;
        }
    }

    let mut dests = bb.iter().enumerate()
        .fold(HashMap::new(), |mut acc, (a, b)| { (acc.entry(b).or_insert(Vec::new())).push(a); acc });
    let mut q: VecDeque<_> = std::iter::once(n).collect();
    let mut rems: BTreeSet<_> = (0..n + 1).collect();
    let mut ans = n;
    #[cfg(local)] println!("{}: {:?}", "(aa, bb)", (&aa, &bb));
    while !rems.is_empty() {
        while let Some(s_idx) = q.pop_front() {
            if !rems.remove(&s_idx) { continue; }
            let s_num = aa[s_idx];
            // if let Some(destv) = dests.remove(&s_num) {
            //     for dest in destv {
            //         q.push_back(dest);
            //     }
            // }
            if let Some(destv) = dests.get_mut(&s_num) {
                for &dest in destv.iter() {
                    q.push_back(dest);
                }
                destv.clear();
            }
        }
        if let Some(&rem) = rems.iter().next() {
            q.push_back(rem);
            ans += 1;
        }
    }
    println!("{}", ans);
    std::process::exit(0);
}


Measured memory_bytes: 27576
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main () {
  int n;
  cin >> n;
  vll a(n);
  rep(i,n) cin >> a[i];
  ll sum = 0;
  ll mi = INFLL;
  int cnt = 0;
  rep(i,n) {
    if (a[i] < 0) cnt++;
    chmin(mi,abs(a[i]));
    sum += abs(a[i]);
  }
  if (cnt%2==0) cout << sum << endl;
  else cout << sum-2*mi << endl;
  return 0;
}

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

int a[111];
int n;

void bs(){
  bool flag = true;
  int cnt = 0;

  while(flag){
    flag = false;
    for(int j = n-1; j > 0; j--){
      if(a[j] < a[j-1]){
        cnt++;
        swap(a[j],a[j-1]);
        flag = true;
      }
    }
  }
  for(int i = 0; i < n; i++){
    if(i != n-1){
      cout << a[i] << " ";
    }else cout << a[i];
  }
  cout << endl;
  cout << cnt << endl;

}

int main(){


  cin >> n;

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

  bs();


}

Measured memory_bytes: 1160
var
  a,b,i:longint;
  ch:char;
begin
  readln(a,b);
  for i:=1 to a+b+1 do
  begin
    read(ch);
    if (i=a+1) and (ch<>'-') then begin writeln('No');exit;end
      else if (not (ch in ['0'..'9'])) and (i<>a+1) then begin writeln('No');exit;end;
  end;
  writeln('Yes');
end.

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

int main() {
    int a, b;
    string ans;
    cin >> a >> b;

    if (a <= 0 && 0 <= b) ans = "Zero";
    else if (0 < a && 0 < b) ans = "Positive";
    else if (a < 0 && b < 0) {
        if (abs(a - b) % 2 == 0) ans = "Negative";
        else ans = "Positive";
    }

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

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

int main() {
  int n; string s; cin>>n>>s; int c=0;
  rep(i, n-2) {
    if ((s[i] == 'A' && s[i+1] == 'B') && s[i+2] == 'C') c++;
  }
  cout<<c<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

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

	final long MOD = (long) (1e9 + 7);

	void run() {
		Scanner sc = new Scanner(System.in);
		char[] c = sc.next().toCharArray();
		int s = 0, t = c.length - 1;
		int ans = 0;
		while (s < t) {
			if (c[s] != c[t])
				++ans;
			++s;
			--t;
		}
		System.out.println(ans);
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

}


Measured memory_bytes: 21844
// #pragma comment(linker, "/STACK:1024000000,1024000000")
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <string>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <vector>
#include <fstream>
#include <list>
#include <iomanip>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define ms(s) memset(s, 0, sizeof(s))
const int inf = 0x3f3f3f3f;
#define LOCAL
const int maxn = 1e6 + 7;
int read(){
    int x = 0; int zf = 1; char ch = ' ';
    while (ch != '-' && (ch < '0' || ch > '9')) ch = getchar();
    if (ch == '-') zf = -1, ch = getchar();
    while (ch >= '0' && ch <= '9') x = x * 10 + ch - '0', ch = getchar(); return x * zf;
}

int main(int argc, char * argv[]) 
{
	int a, b;
	cin >> a >> b;
	if (a <= 9 && b <= 9){
		cout << a * b << endl;
	}
	else{
		cout << -1 << endl;
	}
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define file_se_input  freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define pp long long int
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned long long int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


bool check_prime(long long n)
{
	int flag = 0;
	for (long long i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
		{
			flag = 1;
			break;
		}
	}
	if (n == 1)
		return false;
	else if (flag == 0 || n == 2 || n == 3)
	{
		return true;
	}
	else
	{
		return false;
	}

}

int BE(int x, int n, int m) //function to calculate x raise to power n modulo m
{
	int result = 1;
	while (n > 0)
	{
		if (n % 2 == 1)
			result = result * x % m;
		x = x * x % m;
		n = n / 2;
	}
	return result;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n, q;
	cin >> n >> q;
	string s;
	cin >> s;
	int p[n] = {0};
	zip(i, 1, n)
	{
		if (s[i] == 'C' && s[i - 1] == 'A')
		{
			p[i] = p[i - 1] + 1;
		}
		else
		{
			p[i] = p[i - 1];
		}
	}
	int l, r;
	//zip(i, 0, n)  cout << p[i] << " ";  cout << en;

	zip(i, 0, q)
	{
		cin >> l >> r;
		cout << p[r - 1] - p[l - 1] << en;
	}



	return 0;
}



Measured memory_bytes: 1872
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

#define MAX_V 100000

struct edge { int to, cost; };

int V;//頂点数
vector<edge> G[MAX_V];//辺の張り方 : G[from].push_back((edge){to, cost});
int dist[MAX_V];
bool used[MAX_V];
bool no;

void DFS(int v, int d){
    if(used[v] == true){
        if(d != dist[v]){
            no = true;
        }
        return;
    }
    dist[v] = d;
    used[v] = true;
    REP(i,G[v].size()){
        DFS(G[v][i].to, d + G[v][i].cost);
    }
}

signed main(){
    int m;
    cin >> V >> m;
    int l,r,d;
    REP(i,m){
        cin >> l >> r >> d;
        l--;
        r--;
        G[l].push_back(edge{r, d});
        G[r].push_back(edge{l, -d});
    }
    REP(i,V){
        if(!used[i]){
            DFS(i, 0);
            if(no){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
using namespace std;
typedef long long unsigned int ll;

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    bool prime[55556] = {};
    priority_queue<int> p;
    fill( prime, prime+55555, true);
    for (int i = 2; i < 55556; i++ ){
        if( prime[i] ){
            p.push(i);
            for(int j = i*2; j < 55556; j+=i ){
                prime[j] = false;
            }
        }
    }

    int n;
    Scd(n);
    int cnt = 1;
    printf ("%d ", 2);
    p.pop();
    while( !p.empty()){
        if( p.top() % 10 == 3 ){
            printf ("%d", p.top());
            cnt++;
            if( cnt == n ) break;
            printf (" ");
        }
        p.pop();
    }

    return 0;
}



Measured memory_bytes: 384
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 998244353;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        while (N % a == 0) {
            ++ex;
            N /= a;
        }
        res.push_back({a, ex});
    }
    if (N != 1) res.push_back({N, 1});
    return res;
}

int main() {  
    ll n; cin >> n;
    vector<pll> prime = prime_factorize(n);

    int cnt = 0;
    for(auto p: prime){
        for(int i=1; ; i++){
            if(p.second < i) break;
            cnt++; p.second -= i;
        }
    }
    
    cout << cnt << ln;
}




Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,ans,flag=0;
    cin>>a>>b;
    ans=b*10;
    while(int(ans*0.08)!=a){
    	ans++;
    	if(ans>b*10+9){
    		flag=1;
    		break;
		}
	}
	if(flag==0){
		cout<<ans;
	}else {
		cout<<"-1";
	}
	
} 

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


int main()
{

    ll N, K, tmp1, tmp2;
    scanf("%ld %ld", &N, &K);

    // tmp1=0;
    // tmp2=0;
    // while(1){
    //     tmp1=N;
    //     N = llabs(N-K);
    //     if(N>tmp1) {
    //         N=tmp1;
    //         break;
    //     }
    // }

    tmp1=N%K;
    tmp2=llabs(tmp1-K);
    if(tmp2>tmp1) {
        printf("%ld", tmp1);
    } else {
        printf("%ld", tmp2);
    }


    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define INF 1e9
typedef long long llong;
using namespace std;

int main(){
	int n,q;
	cin>>n>>q;
	
	vector<char> s(n);
	cin>>s[0];
	vector<int> v;
	for(int i=1;i<n;++i){
		cin>>s[i];
		if(s[i]=='C'&&s[i-1]=='A') v.push_back(i);
	}
	
	
	REP(i,q){
		int l,r;
		cin>>l>>r;
		
		auto itr=lower_bound(ALL(v),l);
		auto itr2=upper_bound(ALL(v),r-1);
		
		cout<<itr2-itr<<endl;
	}
	
	return 0;
}

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

using namespace std;

#define REP(i, n) for(int i = 0; i < n; i++)

int main() {
    int ans = 0;

    REP(i, 5) {
        int a;
        cin >> a;
        ans += max(a, 40);
    }

    ans /= 5;
    cout << ans << endl;
    return 0;

}



Measured memory_bytes: 3068
from collections import defaultdict

n = int(input())
a = [tuple(map(int, input().split())) for _ in range(n)]

adj = defaultdict(list)
in_deg = defaultdict(int)
for u, row in enumerate(a, 1):
    for v1, v2 in zip(row, row[1:]):
        uu1, vv1 = min(u, v1), max(u, v1)
        uu2, vv2 = min(u, v2), max(u, v2)
        match1 = uu1 + vv1 * 1000
        match2 = uu2 + vv2 * 1000
        adj[match1].append(match2)
        in_deg[match1]
        in_deg[match2] += 1

now = [key for key, val in in_deg.items() if val == 0]
day = 0
while now:
    day += 1
    nxt = []
    for u in now:
        for v in adj[u]:
            in_deg[v] -= 1
            if in_deg[v] == 0:
                nxt.append(v)

    now = nxt

if max(in_deg.values()) > 0:
    day = -1

print(day)


Measured memory_bytes: 194680
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n;
  int ans = 0;
  cin >> n;
  vector<int> l(n);
  for (int i=0; i<n; i++) {
    cin >> l[i];
  }
  sort(l.begin(), l.end());
  for (int i=0; i<n; i++) {
    for (int j=0; j<i; j++) {
      for (int k=0; k<j; k++) {
        if (l[i]!=l[j] && l[j]!=l[k] && l[k] + l[j] > l[i]) ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3148
N, M = map(int, input().split())
PYlist = [tuple(map(int, input().split())) for _ in range(M)]
from copy import deepcopy
PYsorted = sorted(deepcopy(PYlist))


def zero_ume(num: int) -> str:
    return (6 - len(str(num))) * "0" + str(num)


now_ken = -1
ans_dict = {}
now_num = 0
for p, y in PYsorted:
    if p != now_ken:
        now_num = 0
        now_ken = p
    now_num += 1
    ans_dict[(p, y)] = zero_ume(p) + zero_ume(now_num)

for py in PYlist:
    print(ans_dict[py])


Measured memory_bytes: 38320
#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 ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set1;
typedef tree<string,null_type,less<string>,rb_tree_tag,tree_order_statistics_node_update> indexed_set2;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

int main() 
{
	ll n;
	cin>>n;
	ll arr[n+1] = {0};
	REP(i,0,n-1){
		ll x,y;
		cin>>x>>y;
		if(x > y) swap(x,y);
		if(x+1 <= n)
			arr[y] += x;
	}
	REP(i,1,n+1){
		arr[i] += arr[i-1];
	}
	ll sum = 0;
	REP(i,1,n+1){
		sum += (i*(i+1))/2;
		sum -= arr[i];
	}
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 5192
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
			StringBuilder answer = new StringBuilder();
			String lb = System.getProperty("line.separator");
			
			String str = input.readLine();
			while (!"-".equals(str)) {
				final int m = Integer.parseInt(input.readLine());
				for (int i = 0; i < m; i++) {
					final int h = Integer.parseInt(input.readLine());
					str = str.substring(h) + str.substring(0, h);
				}
				answer.append(str).append(lb);
				str = input.readLine();
			}
			
			input.close();
			System.out.print(answer.toString());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17044
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private const long INFINITY = 9223372036854775807;
    public static void Main()
    {
        Console.WriteLine(NextString().ToCharArray().Select(v => int.Parse(v.ToString())).Sum());
    }
}

public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


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

#define forn(i,n) for(int i=0;i<(int)(n);i++)
#define si(c) ((int)(c).size())
#define forsn(i,s,n) for(int i = (int)(s); i<((int)n); i++)
#define dforsn(i,s,n) for(int i = (int)(n)-1; i>=((int)s); i--)
#define all(c) (c).begin(), (c).end()
#define D(a) cerr << #a << "=" << a << endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

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

const int MOD = 1e9 + 7;
const int N = 15;

int n, out[1<<N][N], pot[N];
vi adj[N];

void add(int &x, int y) {
    x += y;
    if (x >= MOD) x -= MOD;
}

int memo[1<<N];
int go(int mask) {
    if (mask == 0) return 1;

    int &res = memo[mask];
    if (res != -1) return res;

    res = 0;
    for (int pick = mask; pick; pick = (pick-1)&mask) {
        if ((pick&3) == 3) continue;
   
        int nmask = mask - pick;
        int coef = 1;
        for (int m = nmask; m > 0; m &= (m-1)) {
            int last = __builtin_ctz(m);
            coef = ll(coef) * (pot[out[pick][last]]-1) % MOD; 
        }
        for (int m = pick; m > 0; m &= (m-1)) {
            int last = __builtin_ctz(m);
            coef = ll(coef) * pot[out[nmask][last]] % MOD;
        }
        add(res, go(nmask) * (ll)coef % MOD);
        
    }
    res %= MOD; if (res < 0) res += MOD;
    return res;
}

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

    pot[0] = 1;
    forsn(n,1,N) pot[n] = 2*pot[n-1] % MOD;


    int m; cin >> n >> m;
    while (m--) {
        int u,v; cin >> u >> v;
        u--; v--;
        adj[v].pb(u);
    }

    forsn(mask,1,1<<n) {
        int last = __builtin_ctz(mask);
        int nmask = mask - (1<<last);
        forn(u,n) out[mask][u] = out[nmask][u];
        for (int v : adj[last]) out[mask][v]++;
    }

    fill_n(memo, 1<<n, -1);
    cout << go((1<<n)-1) << endl;


    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>


using namespace std;

int solve(vector<int> _p, string *result){

	vector <int> cnt(5, 0);
	int max = 0;
	int cnt_pair = 0;

	for (int i = 0; i < 5; i++){
		for (int j = 0; j < 5; j++){
			if (_p[i] == _p[j]){
				cnt[i]++;
				if (cnt[i]>max) max = cnt[i];
			}
		}
	}

	if (max == 4){
		*result = "four card";
	}
	else if (max == 3){
		*result = "three card";
		for (int i = 0; i < 5; i++){
			if (cnt[i] == 2){
				*result = "full house";
				break;
			}
		}
	}
	else if (max == 2){
		*result = "one pair";
		for (int i = 0; i < 5; i++){
			if (cnt[i] == 2){
				cnt_pair++;
			}
		}
		if (cnt_pair == 4){
			*result = "two pair";
		}
	}
	else{
		*result = "straight";
		sort(_p.begin(), _p.end());

		if ((_p[0] + 1 == _p[1]) || (_p[0] == 1 && _p[1] == 10))
			;
		else
			*result = "null";

		for (int i = 1; i < 4; i++){
			if (_p[i]+1 != _p[i+1]){
				*result = "null";
				break;
			}
		}
	}

	//*result = "one pair";
	return 1;
}

int main(){

	int buf;
	char dummy;
	vector<int> p;
	string result;

	while (1){
		for (int i = 0; i < 4; i++){
			if (cin >> buf >> dummy);else return 0;
			p.push_back(buf);
		}
		cin >> buf;
		p.push_back(buf);


		solve(p, &result);
		
		cout << result << endl;

		p.clear();
	}

	return 0;
}

Measured memory_bytes: 1212
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main
{
  public static void main(String[] args) throws IOException
  {
    BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

    int counter = 0;

    while (input.ready())
    {
      String[] inputStr = input.readLine().split(" ");

      if (inputStr[0].equals("0") && inputStr[1].equals("0"))
      {
        break;
      }

      if (counter > 0)
      {
        System.out.println();
      }
      counter++;

      ArrayList<Integer> ansList = leapYearCount(Integer.parseInt(inputStr[0]),
          Integer.parseInt(inputStr[1]));

      if (ansList.size() == 0)
      {
        System.out.println("NA");
        continue;
      }

      for (Integer each : ansList)
      {
        System.out.println(each);
      }
    }

  }

  private static ArrayList<Integer> leapYearCount(int fromYear, int toYear)
  {
    ArrayList<Integer> yearList = new ArrayList<>();
    for (int i = fromYear; i <= toYear; i++)
    {
      if (isLeapYear(i))
      {
        yearList.add(i);
      }
    }
    return yearList;
  }

  private static boolean isLeapYear(int year)
  {
    if (year % 4 != 0)
    {
      return false;
    }

    if (year % 100 == 0 && year % 400 == 0)
    {
      return true;
    }

    if (year % 100 == 0)
    {
      return false;
    }

    return true;
  }
}

Measured memory_bytes: 25712
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll a,b,c;
    cin >>a>>b>>c;
    if(a==b && b==c){
        cout<<1<<endl;
    }else if(a==b||b==c||a==c){
        cout<<2<<endl;
    }else{
        cout<<3<<endl;
    }
   


    return 0;
    

}

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

using ll = long long;

const int INF = 1001001001;
const ll INF_LL = 1001001001001001001LL;

int main(void){
  int a,b,c; cin >> a >> b >> c;
  rep(i,b){
    if((i+1)*a%b==c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
  
  return 0;
}


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

//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
typedef long long ll;

int main(){
    int A, B, Q;
    ll x;
    
    cin >> A >> B >> Q;
    vector<ll> s(A,0),t(B,0);

    for (int i=0;i<A;++i){
        cin >> s[i];
    }
    for (int i=0;i<B;++i){
        cin >> t[i];
    }
    for (int i=0;i<Q;++i){
        cin >> x;
        auto its = lower_bound(s.begin(),s.end(),x);
        auto ds = distance(s.begin(),its);
        auto itt = lower_bound(t.begin(),t.end(),x);
        auto dt = distance(t.begin(),itt);

        vector<ll> s0,t0;
        if (ds>0) s0.push_back(s[ds-1]);
        if (dt>0) t0.push_back(t[dt-1]);
        if (ds<s.size()) s0.push_back(s[ds]);
        if (dt<t.size()) t0.push_back(t[dt]);

        ll res = 0;
        for (int i=0;i<s0.size();++i) {
            for (int j=0;j<t0.size();++j) {
                if (res>0) {
                    res = min(res,max({x,s0[i],t0[j]}) - min({x,s0[i],t0[j]}) + min(abs(max({x,s0[i],t0[j]})-x), x-min({x,s0[i],t0[j]})));
                }
                else res = max({x,s0[i],t0[j]}) - min({x,s0[i],t0[j]}) + min(abs(max({x,s0[i],t0[j]})-x), x-min({x,s0[i],t0[j]}));
                // cout << s0[0] << " " << t0[0] << endl;
            } 
        }
        
        cout << res << endl;
    }
}

Measured memory_bytes: 2944
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var ab = Console.ReadLine().Split(' ').Select(num => int.Parse(num)).ToArray();
            var result = ab[0] - ab[1] * 2;
            Console.WriteLine(result < 0 ? 0 : result);
        }
    }
}

Measured memory_bytes: 28268
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        double n = sc.nextDouble();
        System.out.println(2*n*Math.PI);
        

    }

}


Measured memory_bytes: 37436
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int x=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)==t.at(i)){x++;}
  }
  cout<<x<<endl;
}
  

Measured memory_bytes: 3592
#include <stdio.h>

int main() {
	int ccnt;
	char e;
	int list[4][13] = {0};
	int number;
	int i, j;

	scanf("%d" ,&ccnt);

	for (i = 0 ; i < ccnt * 2 ; i++) {
		scanf("%c %d", &e, &number);
		if (e == 'S') { 
			list[0][number - 1] = 1; 
		}
		if (e == 'H') { 
			list[1][number - 1] = 1;
		}
		if (e == 'C') { 
			list[2][number - 1] = 1;
		}
		if (e == 'D') { 
			list[3][number - 1] = 1;
		}
	}

	for (j = 0; j < 4; j++) {
		for (i = 0; i < 13; i++) {
			if (list[j][i] == 0) {
				if (j == 0) {
					printf("S ");
				}
				if (j == 1) {
					printf("H ");
				}
				if (j == 2) {
					printf("C ");
				}
				if (j == 3) {
					printf("D ");
				}
				printf("%d\n" ,i + 1);
			}
		}
	}

	return 0;
}


Measured memory_bytes: 2052
pen = input()


def search_auxiliariy(auxiliaries, pen=pen):
  
  for num in auxiliaries:
    if pen[-1] == num:
      return True
  return False


bons = ['3']
pons = ['0', '1', '6','8']
hons = ['2', '4', '5','7', '9']

if search_auxiliariy(bons):
  print('bon')
if search_auxiliariy(pons):
  print('pon')
if search_auxiliariy(hons):
  print('hon')

Measured memory_bytes: 8960
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
class ki {
public:
	VE conn;
	int cnt = 0;
};
void pre_pro(vector<ki> &vki,int idx,int par_idx) {
	if (vki[idx].conn.size() == 1) {
		vki[idx].conn.erase(vki[idx].conn.begin());
		return;
	}
	else {
		REP(i, vki[idx].conn.size()) {
			if (vki[idx].conn[i] == par_idx) {
				vki[idx].conn.erase(vki[idx].conn.begin()+i);
				break;
			}
		}
		REP(i, vki[idx].conn.size()) {
			pre_pro(vki, vki[idx].conn[i],idx);
		}
	}
	return;
}
void forward(vector<ki>& vki, int idx, int point) {
	vki[idx].cnt += point;
	REP(i, vki[idx].conn.size()) {
		forward(vki, vki[idx].conn[i], vki[idx].cnt);
	}
	return;
}
int main() {
	int node,act;
	cin >> node >> act;
	VEP bra(node-1);
	REP(i, node - 1) {
		cin >> bra[i].first >> bra[i].second;
	}
	vector<ki> nod(node);
	REP(i, node - 1) {
		int a = bra[i].first;
		int b = bra[i].second;
		nod[a - 1].conn.push_back(b - 1);
		nod[b - 1].conn.push_back(a - 1);
	}
	REP(i, nod[0].conn.size()) {
		pre_pro(nod, nod[0].conn[i], 0);
	}
	REP(i, act) {
		int index1;
		int point;
		cin >> index1 >> point;
		nod[index1 - 1].cnt += point;
	}
	forward(nod, 0, 0);
	REP(i, node) {
		cout << nod[i].cnt << " ";
	}

	cout << endl;
	return 0;
}


Measured memory_bytes: 25856
S=input()
array=[]
for i in range(len(S)):
    if S[i]=='B':
        if array==[]:
            array=[]
        else:
            array.pop(-1)
    else:
        array.append(S[i])
c=""
for i in range(len(array)):
    c+=array[i]
print(c)

Measured memory_bytes: 2940
function Main(input) {
    var n = input.split('\n')[0];
    var a = input.split('\n')[1];
    var extra = n % 500;
    if(a>=extra){
         console.log('Yes')
    }else{
        console.log('No')
    }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
using System;
using System.Text;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using E = System.Linq.Enumerable;
class Program
{
    static bool[,] cost;
    static int N;
    static long M;
    static long[] C;
    static void Main(string[] args)
    {

        //A = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        var N = long.Parse(Console.ReadLine());
        var A = new long[N];

        for (int i = 0; i < N; i++)
        {
            A[i] = long.Parse(Console.ReadLine());
        }


        long ans = 1;
        long count = 1;
        var dp = new long[N + 1];
        for (int i = 0; i < N; i++)
        {
            var tmp = A[i];
            if(dp[tmp-1] == 0)
            {
                dp[tmp] = 1;
            }
            else
            {
                dp[tmp] = dp[tmp-1] + 1;
            }
        }
        Console.WriteLine(N - dp.Max());
    }
}
















Measured memory_bytes: 38204
#include <iostream>
 
using namespace std;
 
int change(int price) {
  if (price % 1000 == 0) {
    return 0;
  }
  return 1000 - price % 1000; 
}

int main(int argc, char * argv[]) {
  int price;
  cin >> price;
  cout << change(price);
}

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

int N;
vector<int> A;

void input() {
    cin >> N;
    int a;
    for (int i=0; i<N; i++) {
        cin >> a;
        A.push_back(a);
    }
}

void solve() {
    reverse(A.begin(), A.end());

    for (int i=0; i<N; i++) {
        if (i != 0) cout << " ";
        cout << A.at(i);
    }
    cout << endl;
}

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


Measured memory_bytes: 3116
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  getline(cin, s);
  
  if (s=="AAA"){
      cout << "No" << endl;
  }
   else if (s=="BBB"){
       cout << "No" << endl;
   }
   
   else{
       cout << "Yes" << endl;
   };

}

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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	int n;
	cin>>n;
	cin>>s;
	int c=0;
	for(int i=0; i<n;)
	{
		if(s[i]=='A' and s[i+1]=='B' and s[i+2]=='C'){
			c++;
			i+=2;
		}
		else
			i++;	
	}
	cout<<c;
	
	
}

Measured memory_bytes: 256