akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define Int long long
using namespace std;
struct t{int a,b,c,d;};

int main(){
  int h,w;
  int a[555][555];
  cin>>h>>w;
  for(int i=1;i<=h;i++)
	for(int j=1;j<=w;j++)
	  cin>>a[i][j];

  vector<t> tmp;
  
  for(int i=1;i<=h;i++){
	
	for(int j=1;j<=w-1;j++){
	  if(a[i][j]%2){
		tmp.push_back((t){i,j,i,j+1});
		a[i][j+1]++;
	  }
	}
	
	if(i==h)break;
	if(a[i][w]%2){
	  tmp.push_back((t){i,w,i+1,w});
	  a[i+1][w]++;
	}
	i++;

	for(int j=w;j>1;j--){
	  if(a[i][j]%2){
		tmp.push_back((t){i,j,i,j-1});
		a[i][j-1]++;
	  }
	}

	if(i==h)break;
	if(a[i][1]%2){
	  tmp.push_back((t){i,1,i+1,1});
	  a[i+1][1]++;
	}
	
  }
  cout<<tmp.size()<<endl;
  for(int i=0;i<tmp.size();i++){
	t k=tmp[i];
	cout<<k.a<<" "<<k.b<<" "<<k.c<<" "<<k.d<<endl;
  }
  return 0;
}


Measured memory_bytes: 5360
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;

int main()
{
    ll N,X,res;

    res = 0;
    string tmp;
    cin >> tmp;

    REP(i,4)
    {
        if(tmp[i] == '+')res++;
        else res--;
    }

    cout << res << endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	ios_base::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	for(int i = 0; i < n; ++i){ cin >> a[i]; }
	const int s = k - 1;
	cout << (n + s - 2) / s << endl;
	return 0;
}



Measured memory_bytes: 640
#include<iostream>
using namespace std;
int main(){
int a,b,c,n,s=0;
cin>>a>>b>>c>>n;
for(int i=0;i<=a;i++)
for(int j=0;j<=b;j++)
for(int k=0;k<=c;k++)
if(i*500+j*100+k*50==n)
s++;
cout<<s;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> V(N+1);
    for(int i=2; i<=N; i++) {
        int n;
        cin >> n;
        V[n]++;
    }

    for(int i=1; i< V.size(); i++) {
        cout << V[i] << endl;
    }
}

Measured memory_bytes: 4032
<?php

fscanf(STDIN, '%d', $N);
$line = trim(fgets(STDIN));
$arr = explode(' ', $line);
$bubble = bubbleSort($arr);
$select = selectionSort($arr);
echo implode(' ', $bubble), PHP_EOL, 'Stable', PHP_EOL;
$bool = count(array_diff_assoc($bubble, $select)) === 0;
echo implode(' ', $select), PHP_EOL, $bool ? 'Stable' : 'Not stable', PHP_EOL;

function bubbleSort($arr)
{
    for ($i = 0, $len = count($arr); $i < $len; $i++) {
        for ($j = $len - 1; $j > $i; $j--) {
            $tmp = $arr[$j];
            if ($arr[$j - 1][1] > $tmp[1]) {
                $arr[$j] = $arr[$j - 1];
                $arr[$j - 1] = $tmp;
            }
        }
    }

    return $arr;
}

function selectionSort($arr)
{
    for ($i = 0, $len = count($arr), $cnt = 0; $i < $len; $i++) {
        $key = $i;
        for ($j = $i; $j < $len; $j++) {
            if ($arr[$j][1] < $arr[$key][1]) {
                $key = $j;
            }
        }

        if ($key !== $i) {
            $tmp = $arr[$i];
            $arr[$i] = $arr[$key];
            $arr[$key] = $tmp;
            $cnt++;
        }
    }

    return $arr;
}

Measured memory_bytes: 6660
#include <bits/stdc++.h>
#define ll long long int
#define pr pair<ll, ll>
#define tp tuple<ll, ll, ll>
using namespace std;
long long int mod = 1e9 + 7;

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

    long double r;
    cin >> r;
    printf("%0.6Lf\n", (long double)(6.283185307179586232 * r));
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <array>

int main()
{
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  
  int N;
  std::cin>>N;
  
  uint64_t sum=0;
  std::array<int,100001> A{};
  for(int i=0;i!=N;i++)
  {
    int a;
    std::cin>>a;
    sum+=a;
    A[a]++;
  }
  
  int Q;
  std::cin>>Q;
  
  int B,C;
  for(int i=0;i!=Q;i++)
  {
    std::cin>>B>>C;
    
    sum=sum+(C-B)*A[B];
    
    A[C]=A[C]+A[B];
    A[B]=0;
    
    std::cout<<sum<<"\n";
  }
  
  std::cout<<std::endl;
  
  return 0;
}

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

int main(){
    ll n,a,b;
    cin >> n >> a >> b;
    ll nn =n;
    ll cnt  =0;
    ll j = n/(a+b);

    if((a+b) >= n && n > a) cout << a;
    else if(n < a) cout << n;
    else if(a == 0) cout << '0';
    else{
        cnt += a*j;
        n -= (a+b) * j;
        
            n -= a;
            cnt += a;
            if(n <= 0){    
                cout << cnt + n;
                
            }
            else{
                n-=b;
                if(n <= 0){
                    cout << cnt;
                    

                }
            }
        
    }

    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<stack>
#include<ctime>
#include<cmath>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>
#define LL long long
#define INF 0x3f3f3f3f
using namespace std;      
int read(){      
    int f=1,x=0;char s=getchar();         
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}        
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}      
    return f*x; 
}
#define MAXN 100
int L[2*MAXN+5];
int main(){
	int n=read(),ans=0;
	for(int i=1;i<=2*n;i++)
		L[i]=read();
	sort(L+1,L+2*n+1);
	for(int i=1;i<=2*n;i+=2)
		ans+=L[i];
	printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
import java.security.KeyStore.TrustedCertificateEntry
import java.util
import java.util.regex.Pattern
import java.util.{ArrayList, Collections, Comparator, List => JList}

import scala.math._
import scala.collection.mutable
import scala.collection.mutable.{ArrayBuffer, ListBuffer}
import scala.util.{Failure, Success, Try}

object Main{
  val LINE_SEPARATOR = "\n"
  def main(args: Array[String]): Unit = {
    if (sys.env.getOrElse("TEST", "")=="1"){
      println(test());
    }else{
      val input=io.Source.stdin.getLines().mkString(LINE_SEPARATOR);
      println(solve(input).trim());
    }
  }

  def init (nRows: Int, nCols: Int, default: Int) = Array.tabulate(nRows,nCols)( (x,y) =>  default)

  def sortIgnoreCase1(list: JList[String]): JList[String] = {
    val r = new ArrayList[String](list)
    Collections.sort(r, new Comparator[String] {
      override def compare(o1: String, o2: String): Int = o1.compareToIgnoreCase(o2)
    })
    r
  }

  def solve(input: String): String = {
    val a = input.split(" ").head.toInt
    val b = input.split(" ").tail.head.toInt

    ceil((b - 1d)/(a-1d)).toInt.toString
  }

  def divisors(n: Long): Vector[Long] = {
    val halfList = (1 to sqrt(n).toInt).toVector.filter(_ % n == 0).map(_.toLong)
    val reversedList = if (sqrt(n).floor == sqrt(n)) halfList.reverse.tail.map(n/_) else halfList.reverse.map(n/_)
    halfList ++ reversedList
  }

  def gcd(m: Long, n: Long): Long = n match {
    case 0 => m
    case _ => gcd(n, m % n)
  }
  def lcm(a: Long, b: Long): Long = a * b / gcd(a, b)

  val tests=List(
    """4 10""".stripMargin -> """3
                                |""".stripMargin,
    """8 9""".stripMargin -> """2
                               |""".stripMargin,
    """8 8""".stripMargin -> """1"""
  )

  def test():String= {
    return tests.map{case (i,o)=>(i.trim(),o.trim())}
      .zipWithIndex.map{
      case ((input,outputExpect),i)=>{
        val output=solve(input).trim();
        s"test${i+1}:"+(if(output==outputExpect){
          "Passed"
        }else{
          s"Failed\nexpect:\n${outputExpect}\noutput:\n${output}"
        })
      }}
      .mkString("\n");
  }
}

Measured memory_bytes: 25544
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <queue>
#include <iostream>
#include <cmath>

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
typedef long long ll;
using namespace std;


void solve(long long N){
    REP(i, 1000) { 
        if(1000*i >= N) { 
            cout << 1000*i - N << endl;
            return;
        }
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 3744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int,int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    int N = sz(s);

    int ans = 0;
    rep(i, N-1)
    {
        if(s[i+1] -s[i])
            ans++;

    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include <math.h>
using namespace std;

int main()
{
    int N;
    cin >> N;
    int ans = N;
    string S;
    cin >> S;
    for(int i = 1; i < N; i++)
    {
        if(S.at(i)==S.at(i - 1)) ans--;
    }
    cout << ans << endl;
    return 0;
}
 

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(long long i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

  
int main() {
string S;
cin >> S;

if(S.at(0) == S.at(2)){
  yes;
}else no;

}


Measured memory_bytes: 256
<?php
$n = trim(fgets(STDIN));

$line = explode(" ", trim(fgets(STDIN)));

function kumiawase($zentai,$nukitorisu){
  $zentaisu=count($zentai);
  if($zentaisu<$nukitorisu){
    return;
  }elseif($nukitorisu==1){
    for($i=0;$i<$zentaisu;$i++){
      $arrs[$i]=array($zentai[$i]);
    }
  }elseif($nukitorisu>1){
    $j=0;
    for($i=0;$i<$zentaisu-$nukitorisu+1;$i++){
      $ts=kumiawase(array_slice($zentai,$i+1),$nukitorisu-1);
      foreach($ts as $t){
        array_unshift($t,$zentai[$i]);
        $arrs[$j]=$t;
        $j++;
      }
    }
  }
  return $arrs;
}


$array = kumiawase($line,2);
$num = 0;
foreach($array as $k=>$v){
    $num += $v[0] * $v[1];
}

echo $num;

?>

Measured memory_bytes: 4856
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.lang.Math.*;
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        String a = in.next();
        String x = in.next();
        String c = in.next();
        System.out.println("A"+x.charAt(0)+"C");
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <limits>
#include <algorithm>

int abs(int x)
{
    if (x < 0) {
        return -x;
    } else {
        return x;
    }
}

int solve(int n, int k, const std::vector<int>& h)
{
    std::vector<int> dp;
    dp.resize(n);
    std::fill(dp.begin() + 1, dp.end(), std::numeric_limits<int>::max());

    for (int i = 1; i < n; i++) {
        for (int j = std::max(i - k, 0); j < i; j++) {
            dp[i] = std::min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }

    return dp[n - 1];
}

int main()
{
    int n, k;
    std::vector<int> h;

    std::cin >> n >> k;
    h.resize(n);

    for (size_t i = 0; i < h.size(); i++) {
        std::cin >> h[i];
    }

    std::cout << solve(n, k, h) << std::endl;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main(){
    string a;
    cin>>a;
    int ar[300];
    memset(ar,0,sizeof(ar));
    for(int i=0;i<a.size();i++){
        ar[(int)a[i]]++;
    }
    int c1=0,c2=0;
    for(int i='a';i<='z';i++){
        if(ar[i]%2!=0) c2++;
    }
    if(c2!=0) cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 10000005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

LL ans[MAX];
void pre() {
	ans[1] = 1;
	for(int i=2;i*i<MAX;i++) {
		for(int j=i*i;j<MAX;j+=i) {
			int q = j/i;
			ans[j]++;
			if(q != i) ans[j]++;
		}
	}
	
	for(int i=2;i<MAX;i++) {
		ans[i]+=2;
		ans[i] = i * ans[i];
		ans[i] += ans[i-1];
	}
}
void solve() {
	int n;
	in(n);
	cout<<ans[n]<<en;
}

int main() {
	int t = 1;
	pre();
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 81880
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;

const int mxn = 100005;
int n, k, h[mxn];
int ff[mxn];

void solution()
{
  ff[n] = 0;
  for(int i = n - 1; i > 0; i--)
  {
    ff[i] = INT_MAX;
    for(int j = 1; j <= k and i + j <= n; j++)
    {
      ff[i] = min(ff[i], abs(h[i] - h[i + j]) + ff[i + j]);
    }
  }
}

int main()
{
  scanf("%d %d", &n, &k);
  for(int i = 1; i <= n; i++) 
  { 
    scanf("%d", h + i);
  }
  solution();
  printf("%d\n", ff[1]);
  return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)
#define REPIT(i,x) for(auto i{(x).begin()}; i != (x).end(); i++) 

#define PB push_back
#define MP make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef double dbl;
typedef vector<bool> Vb;
typedef vector<char> Vc;
typedef vector<double> Vd;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<string> Vs;
typedef vector<vector<int>> VVi;
typedef vector<vector<ll>> VVl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }
inline void YES() { cout << "YES" << endl; } inline void Yes() { cout << "Yes" << endl; }
inline void NO() { cout << "NO" << endl; } inline void No() { cout << "No" << endl; }

const int inf = 1 << 30;
const ll linf = 1LL << 60;
const int MOD = 1000000007;


void debug(ll ans, ll n)
{
	ll tmp = 0;
	while (n)
	{
		tmp += n % ans;
		n /= ans;
	}

	cout << "debug result : " << tmp << endl;;
}

int main()
{
	ll n, s;
	cin >> n >> s;

	if (s > n) { cout << -1 << endl; return 0; }
	if (s == n) { cout << n + 1 << endl; return 0; }

	ll lim = (ll)ceil(sqrt(n));

	for (ll b = 2; b <= lim; ++b)
	{
		ll chk = 0;
		ll tmpn = n;
		ll tmpb = b;
		while (tmpn)
		{
			chk += tmpn % tmpb;
			tmpn /= tmpb;
		}

		if (chk == s) { cout << b << endl; return 0; }
	}

	ll ans = linf;
	for (ll p = min(lim, s); p >= 1; --p)
	{
		ll q = s - p;
		ll b = (n - q) / p;

		if (b * p + q == n && p < b && q < b)
		{
			chmin(ans, b);
//			cout << b << " " << p << " " << q << endl; return 0;
		}

	}
	if (ans == linf)
		cout << -1 << endl;
	else
		cout << ans << endl;
}


Measured memory_bytes: 256
while true

  m, f, r = gets.split.map(&:to_i)
  if [m, f, r] == [-1, -1, -1]
    break
  elsif m == -1 || f == -1 || m + f < 30
    puts "F"
  elsif m + f >= 80
    puts "A"
  elsif m + f >= 65
    puts "B"
  elsif m + f >= 50 || m + f >= 30 && r >= 50
    puts "C"
  else
    puts "D"
  end
end



Measured memory_bytes: 6872
#include <bits/stdc++.h>
using namespace std;
 
const int N = 202;
int g[N][N];
int dfs(int w, int b){
    if(g[w][b]>=0) return g[w][b];
 
    vector<bool> ap(N);
    if(w>0) ap[dfs(w-1,b)] = true;
    for(int i=1; i<=min(w,b); ++i) ap[dfs(w,b-i)] = true;
    if(b>0) ap[dfs(w+1,b-1)] = true;
 
    int ret = 0;
    while(ap[ret]) ++ret;
    return g[w][b] = ret;
}
 
int main(){
    memset(g,-1,sizeof(g));
    int n;
    cin >>n;
    int a = 0;
    while(n--){
        int w,b;
        cin >>w >>b;
        a ^= dfs(w,b);
    }
    cout << !a << endl;
    return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N=805;

int n, m, k, ans=1e9;
char a[N][N];
int vis[N][N], dist[N][N], ways[N][N];
int dx[4]={-1, +1, 0, 0};
int dy[4]={0, 0, +1, -1};

void bfs(int x, int y, int n, int m)
{
	queue<pair<int, int> > q;
	q.push({x, y});
	ways[x][y]=1;
	vis[x][y]=1;
	dist[x][y]=0;
	while(!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		if(a[x][y]=='#')
			continue;
		for(int dir=0;dir<4;dir++)
		{
			int nx=x+dx[dir];
			int ny=y+dy[dir];
			if(nx<1 || ny<1 || nx>n || ny>m)
				continue;
			if(!vis[nx][ny])
			{
				dist[nx][ny]=dist[x][y]+1;
				vis[nx][ny]=1;
				q.push({nx, ny});
			}
		}
	}
}

int get(int x, int y)
{
	return min({x-1, n-x, y-1, m-y});
}

int32_t main()
{
	IOS;
	int sx, sy;
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='S')
				sx=i, sy=j;
		}
	bfs(sx, sy, n, m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			if(vis[i][j] && dist[i][j]<=k && a[i][j]!='#')
				ans=min(ans, 1 + (get(i, j)+k-1)/k);
	cout<<ans;
	return 0;
}


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

int main(){
    int n;
    int tmp;
    cin >> n;
    tmp = n;

    int s = 0;
    while(tmp > 0){
        s += tmp % 10;
        tmp /= 10;
    }

    if(n % s == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF          1e9
#define INFLL        1e18
#define EPS          1e-9
#define MOD          1000000007
#define REP(i,n)     for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)    for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)    for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)   for(ll i=(n);i>0;--i)
#define REPC(i,obj)  for(auto i:obj)
#define ALL(obj)     (obj).begin(),(obj).end()
#define SETP(n)      cout<<fixed<<setprecision(n)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll n = in();
	REP(i, n) {
		if (in<char>() == 'Y') {
			cout << "Four" << endl;
			return 0;
		}
	}
	cout << "Three" << endl;
}

Measured memory_bytes: 256
S = input()
length = len(S)
if length % 2 == 0:
    length = int(length / 2)
    S_half_1 = S[:length]
    S_half_2 = S[(length):]
    S_half_2 = S_half_2[::-1]
else:
    length = int(length // 2)
    S_half_1 = S[:length]
    S_half_2 = S[(length + 1) :]
    S_half_2 = S_half_2[::-1]

ans = 0
for i in range(length):
    if S_half_1[i] != S_half_2[i]:
        ans += 1
print(ans)


Measured memory_bytes: 8968
//Aleksander Łukasiewicz
#include<bits/stdc++.h>
using namespace std;

#define x first
#define y second
#define pb push_back
#define mp make_pair

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

const int INF = 1000000009;

const int MAXN = 1000;

int A[MAXN + 3];

int main(){
    int n, m;
    scanf("%d %d", &n, &m);
    int sum = 0;
    for(int i=0; i<n; i++){
        scanf("%d", &A[i]);
        sum += A[i];
    }
    sort(A, A+n, greater<int>());
    int k = A[m-1];
    puts((4*m*k >= sum) ? "Yes" : "No");
    
return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 10**9
    if A + B < 2 * C:#C=0
        ans = A*X + B*Y
    else:#C>1
        #Aを2*Cで補うときの利益 > Bを2*Cで補うときの利益
        if (A-2*C)*X + B*max(Y-X, 0) > (B-2*C)*Y + A*max(X-Y, 0):
            #A=0
            ans = 2*C*X + max(Y-X, 0)*B
        else:#B=0
            ans = 2*C*Y + max(X-Y, 0)*A
        if 2*C < A and 2*C < B:
            ans = min(ans, 2*C*max(X,Y))
    print(ans)

def main():
    A, B, C, X, Y = map(int, input().split())
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
        return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
        return readInts()[0];
}
auto readLongs() {
        return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
        return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

long angle2(long h, long m) {
    auto tmp = abs(60*h+m - 12*m);
    return min(tmp, 720-tmp);
}

void main(){
    auto n = readLong();
    foreach(i; iota(n)) {
        long h, m;
        readf("%d:%d\n", &h, &m);
        long a2 = angle2(h, m);
        if(a2 < 60) {
            writeln("alert");
            continue;
        }
        if(a2 >= 180) {
            writeln("safe");
            continue;
        }
        writeln("warning");
    }
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = n-1; i >= 0; i--) {
        cout << a[i];
        if (i != 0) cout << " ";
    }
    cout << endl;
}


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

#define ll long long int

using namespace std;

#define M 1000000007

int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> A(n);
    for (auto & a : A) cin >> a;

    sort(A.begin(), A.end(), [](auto const & left, auto const & right) { return abs(left) > abs(right); });

    ll nNeg = 0;
    ll nPos = 0;
    ll nZor = 0;
    for (auto a : A) {
        if (a < 0) ++nNeg;
        if (a > 0) ++nPos;
        if (a == 0) ++nZor;
    }

    ll res = 0L;
    if (k > nPos + nNeg) {
        // 0 を選ぶ必要がある
        res = 0L;
    } else if ((nPos == 0 && (k%2 == 1)) || (n == k && (nNeg%2 == 1))) {
        if (nZor != 0) {
            res = 0L;
        } else {
            res = 1L;
            sort(A.begin(), A.end(), greater<ll>());
            for (ll i = 0; i < k; ++i) {
                res *= abs(A[i]);
                res %= M;
            }
            res = -res;
        }
    } else {
        ll nNeg = 0;
        ll nPos = 0;
        for (ll i = 0; i < k; ++i) {
            if (A[i] < 0) {
                ++nNeg;
            }
            if (A[i] > 0) {
                ++nPos;
            }
        }
        if ((nNeg%2)==0) {
            res = 1L;
            for (ll i = 0; i<k;++i) {
                res *= abs(A[i]);
                res %= M;
            }
        } else {
            vector<ll> B(n);
            vector<ll> C(n);
            copy(A.begin(), A.end(), B.begin());
            sort(B.begin(), B.end(), greater<ll>());
            copy(A.begin(), A.end(), C.begin());
            sort(C.begin(), C.end());
            if (nPos > 0 && nNeg > 0) {
                if (B[nPos-1] * B[nPos] > C[nNeg-1]*C[nNeg]) {
                    ++nPos;
                    --nNeg;
                } else {
                    --nPos;
                    ++nNeg;
                }
            } else if (nPos == 0) {
                ++nPos;
                --nNeg;
            } else {
                --nPos;
                ++nNeg;
            }
            res = 1L;
            for (ll i = 0; i < nPos; ++i) {
                res *= B[i];
                res %= M;
            }
            for (ll i = 0; i < nNeg; ++i) {
                res *= abs(C[i]);
                res %= M;
            }
        }
    }
    res = (res + M) % M;
    cout << res << endl;
}


Measured memory_bytes: 7956
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    string s; cin >> s;
    int count = 0;
    int ans = 0;
    for(int i = 0;i < s.length();i++){
        if(s.substr(i,1)=="A"||s.substr(i,1)=="T"||s.substr(i,1)=="G"||s.substr(i,1)=="C"){
            count++;
        }else{
            if(count > ans){
                ans = count;
            }
            count = 0;
        }
    }
    cout << max({ans,count}) << endl;
}

Measured memory_bytes: 256
s=input()
s1=int(s[0:2])
s2=int(s[2:4])
s1MM=False
s2MM=False
if 1<=s1 and 12>=s1:
  s1MM=True
if 1<=s2 and 12>=s2:
  s2MM=True

if s1MM and s2MM:
  print("AMBIGUOUS")
elif s1MM:
  print("MMYY")
elif s2MM:
  print("YYMM")
else:
  print("NA")

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
// now

struct UnionFind {
    vector<int> d;
    UnionFind(int n=0) : d(n,-1){}
    int Find (int x){//根の番号を探す
        if(d[x] < 0) return x;
        return d[x] = Find(d[x]);
    }
    bool unite (int x, int y){
        x = Find(x); y = Find(y);
        if(x == y ) return false;
        if(d[x] < d[y]){
            swap(x,y);
        }
        d[x] += d[y];
        d[y] = x;
        return true;
    } 

    bool same(int x, int y){
        return Find(x) == Find(y);
    }
    int size(int x) {
        return (-d[Find(x)]);
    }
};


ll nCr (ll n, ll r){
    ll ans = 1;
    for(ll i = n ; i > n-r ; i --){
        ans *= i;
    }
    for(ll i = 1 ; i<= r; i ++){
        ans /= i;
    }
    return ans ;
}

int nPr (int n,int r){
    int ans = 1;
    for(int i = n ; i > n-r ; i --){
        ans *= i;
    }
    return ans ;
}
 ll modd = 1e9+ 7;
ll wa (ll n,ll mi, ll ma){
    ll ans  = n * (mi+ma) /2;
    return ans;
}
ll kw(ll k,ll n){
    
    ll ans  =0;
    ll mi,ma;
    mi= wa(k,0,k-1);
    
    ma = wa(k,n-k+1,n);
    
    return (ma-mi +1)%modd;
}

int main(){
    ll n,k;
    cin >> n >> k;

    ll sum = 0;
   

    for(ll i = k;i <= n ; i++){
        ll tmp = kw(i,n);
        sum += tmp%modd;
        sum %= modd;
    }

    cout << sum+1 <<endl;
}





Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll n, m;
    cin >> n >> m;
    vector<ll> a(m);
    ll s = 0;
    for(int i=0;i<m;++i) {
        cin >> a[i];
        s += a[i];   
    }

    if(s > n) {
        cout << -1 << "\n";
    } else {
        cout << n-s << "\n";
    }
}


Measured memory_bytes: 3692
#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<int> a(N);
  int mod = 1;
  int ans = 0;
  rep(i, N)
  {
    cin >> a[i];
    ans += a[i] - 1;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    

    int a, b, c;
    cin >> a >> b >> c;
    
    int result =  (c - (a - b)) < 0 ? 0 : (c - (a - b));
    cout << result << endl;

    return 0;

}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

int gcd( int a, int b ) {
	return b ? gcd( b, a%b ) : a;
}

int main() {
	ios_base::sync_with_stdio( false );

	int N;
	cin >> N;

	int ans;
	cin >> ans;

	for( int i = 1; i < N; ++i ) {
		int x;
		cin >> x;

		ans = gcd( ans, x );
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int  n = sc.nextInt();
		
		long arr[] = new long[n];
		
		for(int i=0; i<n; i++) {
			arr[i] = sc.nextLong();
		}
		
		long total = 0;
		long largest = arr[0];
		for(int i=1; i<n; i++) {
			
			if(arr[i] <= largest) {
				total += largest - arr[i];
			}else if(arr[i] > largest) {
				largest = arr[i];
			}
		}
		
		System.out.println(total);
		sc.close();
	}

}


Measured memory_bytes: 60784
t = list(input())
for i, c in enumerate(t):
    if c == "?":
        if i == 0 or i == len(t) - 1:
            t[i] = "D"
        else:
            if t[i - 1] == "P":
                t[i] = "D"
            elif t[i + 1] == "D":
                t[i] = "P"
            else:
                t[i] = "D"
print("".join(t))


Measured memory_bytes: 82716
#include<iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n,k;
llong T[MAX];

int check(llong P){
    int i=0;
    for( int j=0; j<k; j++){
        llong s=0;
        while(s+T[i]<=P){
            s += T[i];
            i++;
            if(i==n) return n;
        }
    }
    return i;
}

int solve(){
    llong left =0;
    llong right = 100000 * 10000;
    llong mid;
    while( right - left > 1){
        mid = (left + right)/2;
        int v = check(mid); 
        if( v>=n)right=mid;
        else left = mid;
    }
    return right;
}

 int main(){
    cin >> n >> k;
    for( int i=0; i<n; i++) cin >> T[i];
    llong ans = solve();
    cout << ans << endl;
    
}


Measured memory_bytes: 3880
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1l<<60;

int main(int argc, char **argv)
{
	ll N; cin >> N;
	ll mi, ma;
	cin >> mi >> ma;
	std::cout << max(0ll, (ma*(N-1)+mi) - (mi*(N-1)+ma) + 1) << std::endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
#include <cmath>

using namespace std;

int solve(int N, int L) {
    // N個のりんごの味の総和
    int nTaste = 0;
    for (int i = 1; i <= N; i++) {
        nTaste += (L + i - 1);
    }

    // N-1個のりんごの味の総和と絶対値の差を計算
    int minDiff = INT_MAX;
    int ans;
    for (int i = 1; i <= N; i++) {
        int n1Taste = nTaste - (L + i -1);
        int diffTaste = abs(nTaste - n1Taste);
        if (minDiff > diffTaste) {
            minDiff = diffTaste;
            ans = n1Taste;
        }
    }
    printf("%d\n", ans);
}

int main() {
    int N, L;
    scanf("%d", &N);
    scanf("%d", &L);

    solve(N, L);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using namespace std;

using P = pair<int, int>;

#define MAX_N 400000
#define INF 400000

// 各点への最短経路 dijkstra
long d[MAX_N];  //頂点kから各点への距離
vector<P> G[MAX_N]; //隣接行列
int n, m; 
void dijkstra(int k) { //Gは隣接行列 G[i][j].firstが距離, secondが向かう頂点名, kはスタートする頂点
    fill(d, d+3*n+1, INF); d[k] = 0;
    priority_queue< P, vector<P>, greater<P> > que;
    que.push(P(0, k));
    while (!que.empty()) {
        P p = que.top(); que.pop();
        int now = p.second;
        if (d[now] < p.first) continue;
        for (auto g:G[now]) {
            int to = g.second;
            long newd = g.first + d[now];
            if (d[to] > newd) {
                d[to] = newd;
                que.push(P(d[to], to));
            }
        }
    }
}

int main() {
    cin >> n >> m;
    for (int i=0; i<m; i++) {
        int u, v;
        cin >> u >> v;
        G[u].push_back({1, v+n});
        G[u+n].push_back({1, v+2*n});
        G[u+2*n].push_back({1, v});
    }
    int s, t;
    cin >> s >> t;
    dijkstra(s);
    cout << (d[2*n+t] < INF ? d[t]/3 : -1) << '\n';
    return 0;
}


Measured memory_bytes: 21888
from bisect import bisect_left,bisect_right
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
a.sort()
c.sort()
ans=0

for i in range(n):
    a_idx=bisect_left(a,b[i])
    c_idx=bisect_right(c,b[i])
    ans+=a_idx*(n-c_idx)
print(ans)


Measured memory_bytes: 23232
import java.util.Scanner;

public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		
		Integer array[] = new Integer[3];
		// 初期化
		for(int i = 0; i < 3; i++) {
			array[i] = -1;
		}
		
		for(int i = 0; i < m; i++) {
			int s = scan.nextInt() - 1;
			int c = scan.nextInt();
			// Nが2桁or3桁で1桁目が0は存在しない
			if(n != 1 && s == 0 && c == 0) {
				System.out.println(-1);
				return;			
			}
			// 既に入力済みかつ違う数値は存在しない
			if(array[s] != -1 && array[s] != c) {
				System.out.println(-1);
				return;			
			}
			// s桁目の初めての入力
			if(array[s] == -1) {
				array[s] = c;
			}
		}

		// 入力されていない桁に最小値を設定
		for(int i = 0; i < 3; i++) {
			// Nが2桁or3桁の1桁目が未入力
			if(n != 1 && i == 0 && array[i] == -1) {
				array[i] = 1;
			}
			if(array[i] == -1){
				array[i] = 0;
			}
		}
		int num = 0;
		for(int i = 0;i < n;i++) {
	    	if(i != 0) {
	    		num = num*10;
	        }
	    	num = num + array[i];
	    }
		System.out.println(num);
		return;
		
	}
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define INF (1LL<<31)-1
//#define MOD 998244353
#define MOD 1000000007

int main(){
    int n;
    scanf("%d",&n);
    vector<string> s(n);
    rep(i,0,n)cin>>s[i];
    sort(s.begin(),s.end());
    s.erase(unique(s.begin(),s.end()),s.end());
    cout<<s.size()<<"\n";
}

Measured memory_bytes: 9516
#include<stdio.h>
int main()
{
    int n,a,i,min=1000000,max=-1000000;
    long int sum=0;
    scanf("%d",&n);
    for(i=1;i<=n;i++)
    {
        scanf("%d",&a);
        sum=sum+a;
        if(a<min)
            min=a;
        else
            min=min;
        if(a>max)
            max=a;
        else
            max=max;
    }
    printf("%d %d %ld\n",min,max,sum);
    return 0;
}



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

#define MAX 305
#define ld long double

ld dp[MAX][MAX][MAX];

void setup() {
    for (int i = 0; i < MAX; ++i)
    for (int j = 0; j < MAX; ++j)
    for (int k = 0; k < MAX; ++k)
        dp[i][j][k] = -1;
    dp[0][0][0] = 0;
}

ld run(int one, int two, int three, int n) {
    if (one < 0 || two < 0 || three < 0)
        return 0;
    if (dp[one][two][three] != -1)
        return dp[one][two][three];
    ld sum = one + two + three;
    ld total = (ld) n / (sum);
    total += ((ld) one / sum) * run(one - 1, two, three, n);
    total += ((ld) two / sum) * run(one + 1, two - 1, three, n);
    total += ((ld) three / sum) * run(one, two + 1, three - 1, n);
    dp[one][two][three] = total;
    return total;
}

signed main(int argc, char const *argv[])
{
    setup();
    int n, a;
    cin >> n;
    int one = 0, two = 0, three = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a;
        if (a == 1) one++;
        else if (a == 2) two++;
        else three++;
    }

    cout << fixed << setprecision(12) << run(one, two, three, n) << endl;
    return 0;
}

Measured memory_bytes: 443648
N, K = map(int, input().split())
li = list(map(int, input().split()))

x = -1
for i in range(len(li)):
	if li[i] >= 0:
		x = i
		break

if x == -1:
	print(li[-K] * -1)

elif not x :
	print(li[K-1])

else:
	score = float("inf")
	for i in range(K):
		if i == K-1:
			try:
				score = min(li[x+i], score)
			except:
				pass
			try:
				if x-i-1 >= 0:
					score = min(li[x-i-1] * -1, score)
			except:
				pass
		else:
			try:
				if x-(K-1-i) >= 0:
					score = min(li[x+i] * 2 + li[x-(K-1-i)] * -1, score)
			except:
				pass
			try:
				if x-i-1 >= 0:
					score = min(li[x-i-1] * -2 + li[x+K-2-i], score)
			except:
				pass
	print(score)

Measured memory_bytes: 14456
number_of_cards = int(input())
suits_of_cards = [input().split(" ") for i in range(number_of_cards)]

spade = []
heart = []
club = []
diamond = []

for j in range(0, number_of_cards):
    suits_of_cards[j][1] = int(suits_of_cards[j][1])

for k in suits_of_cards:
    if "S" in k:
        spade.append(k)
    elif "H" in k:
        heart.append(k)
    elif "C" in k:
        club.append(k)
    else:
        diamond.append(k)

for l in range(1, 14):
    if ['S', l] not in spade:
        print("S", l)
for l2 in range(1, 14):
    if ['H', l2] not in heart:
        print("H", l2)
for l3 in range(1, 14):
    if ['C', l3] not in club:
        print("C", l3)
for l4 in range(1,14):
    if ['D', l4] not in diamond:
        print("D", l4)


Measured memory_bytes: 5624
#include<iostream>
#include<vector>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<complex>
using namespace::std;
typedef complex<double> P;


double cross(P a, P b){
  return a.real()*b.imag() - a.imag()*b.real();
}

double dot(P a, P b){
  return a.real()*b.real() + a.imag()*b.real();
}

int ccw(P a, P b, P c){
  b -= a; c -= a;
  if(cross(b, c) > 0) return 1;
  if(cross(b, c) < 0) return -1;
  if(dot(b, c) < 0) return 2;
  if(norm(b) < norm(c)) return -2;
  return 0;
}

int main(){

  int r1, r2, r3;
  float x1, x2, x3, xp, y1, y2, y3, yp;

  for(;;){
    if(scanf("%f %f %f %f %f %f %f %f", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp) == EOF){
      break;
    }
  P p1 = P(x1, y1);
  P p2 = P(x2, y2);
  P p3 = P(x3, y3);
  P p4 = P(xp, yp);

  r1 = ccw(p1, p2, p4);
  r2 = ccw(p2, p3, p4);
  r3 = ccw(p3, p1, p4);

  if((r1 == -1) && (r2 == -1) && (r3 == -1)){
    printf("YES\n");
  }else if ((r1 == 1) && (r2 == 1) && (r3 == 1)){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  }
  return 0;
}

Measured memory_bytes: 1208
import operator
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


class UnionFind:
    def __init__(self, n):
        self.n = n
        self.parents = list(range(n))
        self.ranks = [0 for _ in range(n)]

    def get_root(self, x):
        if self.parents[x] == x:
            return x
        self.parents[x] = self.get_root(self.parents[x])
        return self.parents[x]

    def merge(self, x, y):
        x = self.get_root(x)
        y = self.get_root(y)
        if x != y:
            if self.ranks[x] < self.ranks[y]:
                self.parents[x] = y
            else:
                self.parents[y] = x
                if self.ranks[x] == self.ranks[y]:
                    self.ranks[x] += 1


def kruskal(n_nodes, edges):
    edges.sort(key=operator.itemgetter(2))
    res = []
    uf = UnionFind(n_nodes)
    for e in edges:
        if uf.get_root(e[0]) != uf.get_root(e[1]):
            res.append(e)
            uf.merge(e[0], e[1])
    return res


n = ri()
ls = rils(n)
ls = list(enumerate(ls))

edges = []
ls.sort(key=lambda x: x[1][0])
for (i, (x0, y0)), (j, (x1, y1)) in zip(ls, ls[1:]):
    edges.append((i, j, min(abs(x0 - x1), abs(y0 - y1))))

ls.sort(key=lambda x: x[1][1])
for (i, (x0, y0)), (j, (x1, y1)) in zip(ls, ls[1:]):
    edges.append((i, j, min(abs(x0 - x1), abs(y0 - y1))))

res = kruskal(n, edges)
print(sum(x[2] for x in res))

Measured memory_bytes: 65408
#include<stdio.h>

int main(void)
{
   int n,x;
   double s;

   scanf("%df",&n);

   if(n%2==0) printf("0.5000000000\n");

   else if(n%2!=0) {
   s=(n/2+1)/(double)n;
   printf("%.10lf\n",s);
   }

   return 0;
}


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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n;
    cin >> n;
    ll mae = 0;
    ll ans = 0;
    rep(i,n){
        ll a;
        cin >> a;
        if(mae < a) mae = a;
        else{
            ans += mae - a;
        }
    }
    cout << ans << endl;

    return 0;
}

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

using namespace std;
#define int long long
#define all(a) (a).begin(), (a).end()
#define ms(a,v) memset(a, v, sizeof(a))
#define sz(v) ((int)(v).size())
#define mp make_pair
#define pb push_back
#define prev biiiiirl_sai_de_casa_comi_pra_caralho
#define next trapezio_descendente
#define index eh_ele_que_nos_vai_buscar
#define left aqui_eh_37_anos_porra
#define R32 ({int32_t x; scanf("%d", &x); x;})
#define RL ({long long x; scanf("%lld", &x); x;})
#define RC ({char x; scanf(" %c", &x); x;})
#define RI RL
#define ff first
#define ss second
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef long long ll;

inline int sig(int x){
    return x > 0 ? 1 : (x < 0)*-1;
}

int32_t main(){
    int n = RI;

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

    int cnt = 1;
    int last = 0;
    for(int i = 1; i < n; i++){
        if(last*sig(a[i]-a[i-1]) < 0){
            last = 0;
            cnt++;
        } else {
            if(sig(a[i]-a[i-1]))
                last = sig(a[i]-a[i-1]);
        }
    }

    cout << cnt << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void){

  char str[128] = {0};

  scanf("%s",str);

  int i;

  for(i = 0; i < 128; i++){

    char tmp;
    tmp = str[i];
    if(tmp == 0)
      break;

  }

  printf("%c%d%c\n",str[0],i - 2,str[i - 1]);
  return 0;
}

Measured memory_bytes: 128
from sys import stdin
from sys import setrecursionlimit
from collections import Counter, deque, defaultdict
from bisect import bisect_left
setrecursionlimit(1000000)

INF = int(1e10)
MOD = int(1e9 + 7)

def input():
    return stdin.readline()[:-1]


def main():
    from builtins import int, map
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    if N < sum(A):
        print(-1)
    else:
        print(N - sum(A))
   
if __name__ == '__main__':
    main()

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

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

using namespace std;


int main()
{
	string s;
	int a[3] = {1,0,0};

	while(cin >> s)
	{
		int d = s[0] - 'A';
		int d2 = s[2] - 'A';
		swap(a[d],a[d2]);
	}

	rep(i,3)
	{
		if(a[i] == 1)
		{
			cout << (char)(i + 'A') << endl;
		}
	}
	return 0;
}

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

int A,B,X,n;
int main(){
	cin>>A>>B>>X;
	n=X-A;
	if(n>=0) {
		if(B-n>=0) {
			cout<<"YES"<<endl;
		} else if(B-n<0) {
			cout<<"NO"<<endl;
		}
	} else {
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int main() {
  cout << fixed << setprecision(10);
  int n,m;
  cin >> n >> m;
  map<int,int> mp;
  rep(i,m){
    int a;
    cin >> a;
    mp[a]++;
  }
  vector<int> dp(100100,0);
  dp[0]=1;
  if(!mp[1]){
    dp[1]=1;
  }
  for(int i=2; i<=n; i++){
    if(!mp[i]){
      dp[i]=(dp[i-1]+dp[i-2])%MOD;
    }
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 5376
#include <iostream>

using namespace std;
int main() {
  int N, M, K;
  cin >> N >> M >> K;

  for (auto i = 0; i <= N; ++i) {
    for (auto j = 0; j <= M; ++j) {
      if (K == i * M + j * N - 2 * i * j) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}


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

int main(){
 int N;
  cin>>N;
  int A[N];
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  int sum=0;
  for(int i=0;i<N;i++){
    if(A[i]!=i+1){
      sum++;
    }
  }
  if(sum<=2){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3572