akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int dx[4] = { 0, 1, 0, -1 }, dy[4] = { -1, 0, 1, 0 };

int H,W;
char s[55][55];
int dp[55][55];

int bfs(){
    queue<pair<int,int>> que;
    memset(dp, -1, sizeof(dp));
    que.push({0,0});
    dp[0][0] = 1;
    int x,y;
    while(!que.empty()){
        tie(x,y) = que.front();
        que.pop();

        if (x == W - 1 and y == H - 1) return dp[y][x];
        REP(i,4){
            int xi = x + dx[i];
            int yi = y + dy[i];
            if (0 <= xi && xi < W && 0 <= yi && yi < H){
                if(s[yi][xi] == '.' && dp[yi][xi] == -1){
                    dp[yi][xi] = dp[y][x] + 1;
                    que.push({xi,yi});
                }
            }
        }
    }
    return -1;
}

int main()
{
    cin >> H >> W;

    int b = 0;
    REP(i,H){
        REP(j,W){
            cin >> s[i][j];
            if(s[i][j] == '#'){
                b++;
            }
        }
    }
    
    int ans = bfs();
    if(ans != -1){
        cout << H*W-b - ans << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf);
    let mut s = buf.split_whitespace();
    let n: u8 = s.next().unwrap().parse().unwrap();
    let m: u8 = s.next().unwrap().parse().unwrap();

    let students: Vec<(i32, i32)> = (0..n).map(|_| {
       let x: i32 = s.next().unwrap().parse().unwrap();
       let y: i32 = s.next().unwrap().parse().unwrap();
       (x, y)
    }).collect();
    let checkpoints: Vec<(i32, i32)> = (0..m).map(|_| {
       let x: i32 = s.next().unwrap().parse().unwrap();
       let y: i32 = s.next().unwrap().parse().unwrap();
       (x, y)
    }).collect();

    for student in students {
        let dists = checkpoints.iter().enumerate().map(|(idx, cp)| {
          let dist = (student.0 - cp.0).abs() +
                     (student.1 - cp.1).abs();
          (dist, idx)
        });
        let cp_num = dists.min().unwrap().1 + 1;
        println!("{}", cp_num);
    }
}


Measured memory_bytes: 4352
/* while(!cin.eof()) */
 
#include<bits/stdc++.h>
using namespace std; 
#define int long long 
#define mod (int)(1e9+7)
#define MAXI (int)(1e15+100)
#define N 200005




// Driver code to test above functions
int32_t main()
{
    
     
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    int a, b;
    cin >> a >> b;
    cout << max(0LL, a-2*b);


    return 0;
    
} 

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

#define N 1000

int array[N];
int top;

void push(int);
int pop(void);

int main(){

  char in[N];
  int i=0;
  int a,b;
  int flag;

  while(1){

    flag =  scanf("%s",in);
    if(flag == EOF) break;
 
    if (in[0] == '+'){
      a = pop();
      b = pop();
      push(a+b);
    }
    else if(in[0] == '-'){
      b = pop();
      a = pop();
      push(a-b);
    }
    else if (in[0] == '*'){
      a = pop();
      b = pop();
      push(a*b);
    }
    else push(atoi(in));
  }
  
  printf("%d\n",pop());

  return 0;
}

int pop(){
  top--;
  return array[top+1];
}

void push(int x){
  array[++top] = x;
}



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

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

int main(){
    long long l,r;cin>>l>>r;

    vector<long long> targets;
    long long acc = 0;
    bool judge = false;
    for (long long i=l;i<r;i++){
        for (long long j=i+1;j<=r;j++){
            targets.push_back(((i % 2019) * (j % 2019)) % 2019);
            acc++;
            if (acc > 5000){
                judge = true;
                break;
            }
        }
        if (judge){
            break;
        }
    }
    sort(targets.begin(), targets.end());
    cout << targets[0] << endl;
    return 0;

}

Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    int d, e, f;
    d = a + b;
    e = b + c;
    f = a + c;
    int mini = min(d, e);
    mini = min(mini, f);

    cout << mini << '\n';

    return 0;
}


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

using namespace std;

#define INF 1e9
#define MAXN 2000005
#define MAXA 10005
#define MOD 1000000007
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int N;
vi A, C, ans;

void solve(){
    C.resize(MAXA, 0);
    ans.resize(N+1);

    rep(i, N){
        C[A[i]]++;
    }

    rep(i, MAXA-1) C[i+1] += C[i];

    // rep(i, 6) cout << C[i] << endl;

    for(int i = N-1; i >= 0; --i){
        int val = A[i];
        // cout << "A: " << val << endl;
        ans[C[val]] = val;
        C[val]--;
        // cout << "C: " << C[val] << endl;
    }

    for(int i = 1; i <= N; ++i) {
        cout << ans[i];
        if(i == N) cout << endl;
        else cout << " ";
    }
}

int main(){
    cin >> N;
    A.resize(N);

    rep(i, N) cin >> A[i];

    solve();
}



Measured memory_bytes: 18396
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a+b < c){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int ans=int.MaxValue;
		for(int i=0;i<s[0];i++){
			int[] q=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			if(ans>q[0]&&q[1]<=s[1]){ans=q[0];}
		}
		Console.WriteLine("{0}",ans!=int.MaxValue?ans.ToString():"TLE");
	}
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = ((int)(n)-1); i >= 0; i--)
#define all(x) (x).begin(),(x).end()
 
using namespace std;
using ll = long long;
 
struct edge { int to, cost; };
 
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> P;
 
const int INF = 1e9;
//const ll INF = 1e18;
const double EPS = 1e-10;
const int MOD = 1e9+7;
const double PI = acos(-1.0);

const int mx4[] = {0,1,0,-1};
const int my4[] = {1,0,-1,0};
const int mx8[] = {0,1,1,1,0,-1,-1,-1};
const int my8[] = {1,1,0,-1,-1,-1,0,1};

int main()
{
	int n;
	cin >> n;
	string s;
	cin >> s;
	int flag = 1;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '#') flag = 0;
	}
	if(flag || n == 1){
		cout << 0 << endl;
		return 0;
	}

	int w_cnt[s.size()+10] = {},b_cnt[s.size()+10] = {};
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '.') w_cnt[i]++;
		else b_cnt[i]++;
	}

	for(int i = s.size()-2; i >= 0; i--) w_cnt[i] += w_cnt[i+1];
	for(int i = 1; i < s.size(); i++) b_cnt[i] += b_cnt[i-1]; 

	int ma = b_cnt[n-1];
	for(int i = 0; i < s.size(); i++){
		if(s[i] == '#'){
			if(i == 0){
				ma = min(w_cnt[i+1],ma);
			}else if(i == s.size()-1){
				ma = min(b_cnt[i]-1,ma);
			}else{
				ma = min(b_cnt[i]-1+w_cnt[i+1],ma);
			}
		}
	}
	cout << ma << endl;
	return 0;
}

Measured memory_bytes: 2180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int r;
    cin >> r;
    cout << r * r << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

#ifdef DEBUG
    #define DPRINT(A)    print("%d", A);
#else
    #define DPRINT(A)
#endif


int main()
{
    int iPeople, iFoods;
    // 1行目
    if (scanf("%d %d", &iPeople, &iFoods) == 0)
    {
        return 0;
    }
    // printf("P: %d, F: %d", iPeople, iFoods);

    // 食べ物の上限は30
#define FOOD_LIMIT (30)
    int aiFoodResult[FOOD_LIMIT];
    // init 
    for (int j = 0; j < FOOD_LIMIT; j++)
    {
        aiFoodResult[j] = 1;
    }

    int i, j;
    for (i = 0; i < iPeople; i++)
    {
        int iFoodNum;
        // 一人の結果を集計するための一時変数
        int aiFoodResultTemp[FOOD_LIMIT] = {0};

        if (scanf("%d", &iFoodNum) == 0)
        {
            return 0;
        }
        // printf("Fnum: %d", iFoodNum);

        // 人の好きな食べ物の数ループ
        for (j = 0; j < iFoodNum; j++)
        {
            int iFoodId;
            if (scanf("%d", &iFoodId) == 0)
            {
                printf("error: %d", iFoodId);
                return 0;
            }
            // printf("fid: %d", iFoodId);
            aiFoodResultTemp[iFoodId - 1] = 1;
        }
        // 一人の結果をもとに全体を結果を生成
#ifdef DEBUG
        for (j = 0; j < FOOD_LIMIT; j++)
        {
            printf("%d", aiFoodResult[j]);
        }
        printf("\n");
#endif
        for (j = 0; j < FOOD_LIMIT; j++)
        {
            DPRINT(aiFoodResult[j]);
            aiFoodResult[j] = (aiFoodResult[j] & aiFoodResultTemp[j]);
            DPRINT(aiFoodResultTemp[j]);
        }
    }

    // 結果の出力
    int iResultNum = 0;
    for (j = 0; j < FOOD_LIMIT; j++)
    {
        if (aiFoodResult[j] == 1)
        {
            iResultNum++;
        }
    }

    printf("\n%d", iResultNum);

    return 0;
}

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

int main(void){
  char a[101], b[101];
  scanf("%s %s", a, b);
  int ans = 0;
  
  if(strlen(a) < strlen(b)) ans = -1;
  else if(strlen(a) > strlen(b)) ans = 1;
  else{
    for(int i = 0; i < strlen(a); i++){
      if(a[i] < b[i]){
        ans = -1;
        break;
      }else if(a[i] > b[i]){
        ans = 1;
        break;
      }
    }
  }
  if(ans == 0) printf("EQUAL\n");
  else if(ans < 0) printf("LESS\n");
  else printf("GREATER\n");
  return 0;
}

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

using namespace std;

int main() {
	int m, d;
	cin >> m >> d;

	int ans = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= d; j++) {
			int d1 = j % 10;
			int d10 = j / 10;

			if (d1 >= 2 && d10 >= 2 && d1 * d10 == i) {
				ans++;
			}
		}
	}

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


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int s[366][26];
int main() {

	int d;
	cin >> d;
	int c[26];
	int i, j, j2;
	for (i = 0; i < 26; i++) {
		cin >> c[i];
	}

	for (i = 0; i < d; i++) {
		for (j = 0; j < 26; j++) {
			cin >> s[i][j];
		}
	}
	int last[26];
	for (i = 0; i < 26; i++) {
		last[i] = 0;
	}
	int jmax, jindex, jindex2;
	for (i = 1; i <= d; i++) {

		jmax = 0;
		jindex = -1;
		jindex2 = -1;
		/*for (j = 0; j < 26; j++) {
			if (c[j] *(i - last[j]) > jmax) {
				jmax = c[j] *(i - last[j]);
				jindex = j;
			}
			else if (c[j] *(i - last[j]) == jmax) {
				if (s[i - 1][j] > s[i - 1][jindex]) {
					jindex = j;
				}
			}
		}*/
		for (j = 0; j < 26; j++) {
			for (j2 = 0; j2 < 26; j2++) {
				if (j != j2) {
					if (s[i - 1][j] + 8 * c[j] * (i - last[j]) + s[i][j2] + 8 * c[j2] * (i + 1 - last[j2]) > jmax) {
						jmax = s[i - 1][j] + 8 * c[j] * (i - last[j]) + s[i][j2] + 8 * c[j2] * (i + 1 - last[j2]);
						jindex = j;
						jindex2 = j2;
					}
				}
				else {
					if (s[i - 1][j] + 8 * c[j] * (i - last[j]) + s[i][j2] + 8 * c[j2] > jmax) {
						jmax = s[i - 1][j] + 8 * c[j] * (i - last[j]) + s[i][j2] + 8 * c[j2];
						jindex = j;
						jindex2 = j2;
					}
				}
			}
		}
		/*for (j = 0; j < 26; j++) {
			if (s[i - 1][j] + 15 * c[j] * (i - last[j]) >= jmax) {
				jmax = s[i - 1][j] + 15 * c[j] * (i - last[j]);
				jindex = j;
			}
		}*/
		last[jindex] = i;
		cout << jindex + 1 << endl;
		


	}
	return 0;


}

Measured memory_bytes: 3664
import java.util.Scanner;

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

		int x = sc.nextInt();

		System.out.println((x % 2 == 1 && 2 < x && x < 8) ? "YES" : "NO");

		sc.close();

	}
}



Measured memory_bytes: 23636
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n;
	cin >> n;
	int current = 1, answer = 0;
	while(n--)
	{
		int a;
		cin >> a;
		if(a == current) ++current;
		else ++answer;
	}
	cout << (current == 1 ? -1 : answer) << '\n';
}

Measured memory_bytes: 3592
#include <stdio.h>
#include <stdlib.h>
 
int main(){
  int i,j,N,minj,a,b;
  char tmp;
  char tmp2;
  int flag=0;
  scanf("%d",&N);
  
  char A[N][2];
  char B[N][2];
  char C[N][2];
  for(i=0;i<N;i++){
    scanf("%s",C[i]); 
    A[i][0]=C[i][0];
    A[i][1]=C[i][1];
    B[i][0]=C[i][0];
    B[i][1]=C[i][1];
 
  }
   
   for(i=0;i<N;i++){
    for(j=N-1;j>i;j--){
      if((int)A[j][1]<(int) A[j-1][1]){
    tmp=A[j][0];
    A[j][0]=A[j-1][0];
    A[j-1][0]=tmp;
    tmp2=A[j][1];
    A[j][1]=A[j-1][1];
    A[j-1][1]=tmp2;
      }
    }
    }
 
   for(i=0;i<N-1;i++)printf("%c%c ",A[i][0],A[i][1]);
   printf("%c%c\n",A[N-1][0],A[N-1][1]);
 
 
   for(i=0;i<N;i++){
     for(j=i+1;j<N;j++){
       for(a=0;a<N;a++){
     for(b=a+1;b<N;b++){
       if(C[i]==C[j] && C[i]==A[b] && C[j]==A[a]){
         flag=1;
       }
     }
       }
     }
   }
   if(flag==0)printf("Stable\n");
   else printf("Not stable\n");
 
   flag=0;
 
   for(i=0;i<N;i++){
     minj=i;
     for(j=i;j<N;j++){
       if((int)B[j][1]<(int)B[minj][1]){
     minj=j;
       }
     }
     tmp=B[i][0];
     B[i][0]=B[minj][0];
     B[minj][0]=tmp;
     tmp2=B[i][1];
     B[i][1]=B[minj][1];
     B[minj][1]=tmp2;
   }
 
 
   for(i=0;i<N-1;i++)printf("%c%c ",B[i][0],B[i][1]);
   printf("%c%c\n",B[N-1][0],B[N-1][1]);
 
   for(i=0;i<N;i++){
     for(j=i+1;j<N;j++){
       for(a=0;a<N;a++){
     for(b=a+1;b<N;b++){
       if(C[i][1]==C[j][1] && C[i][0]==B[b][0] && C[i][1]==B[b][1] && C[j][0]==B[a][0] && C[j][1]==B[a][1] ){
         flag=1;
       }
     }
       }
     }
   }
   if(flag==0)printf("Stable\n");
   else printf("Not stable\n");
 
 
 
   return 0;
}

Measured memory_bytes: 608
N,L = map(int,input().split())
S = []
for i in range(N):
    str = input()
    S.append(str)

value = ""
for i in range(N):
    for j in range(i+1,N):
        if S[i] > S[j]:
            value = S[i]
            S[i] = S[j]
            S[j] = value
result = ""
for i in range(N):
    result += S[i]
print(result)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define P pair<int,int>
#define PP pair<P,int>
#define F first
#define S second
#define f(i,n) for(int i=0;i<(n);i++)
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define mod (int)(1000000007)
#define pie 3.141592653589793238462643383279
#define Bpri priority_queue
#define Spri priority_queue<P,vector<P>,greater<P>>
using namespace std;
signed main(){
	int a,b;
	cin>>a>>b;
	if(b==1)cout<<0<<endl;
	else cout<<a-b<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
const int MAXN = 345678;
int p[MAXN];
int pos[MAXN];
int color[MAXN], bit[MAXN];

int query(int x) {
    int sum = 0;
    while (x >= 1) {
        sum += bit[x];
        x -= (x & (-x));
    }
    return sum;
}

void update(int x, int val, int N) {
    while (x <= N) {
        bit[x] += val;
        x += (x & (-x));
    }
}

void NO() {
    puts("No");
    exit(0);
}

int main() {
    int N;
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) {
        scanf("%d", &p[i]);
        pos[p[i]] = i;
    }
    for (int R = N; R >= 1; R--) {
        if (color[R]) {
            if (pos[R] == R) continue;
            NO();
        }
        int offs = query(pos[R]);
        int L = pos[R] - offs * 2;
        //printf("R = %d offs = %d L = %d\n", R, offs, L);
        if ((L % 2) != (R % 2)) NO();
        if (offs && L != R) NO();
        if (L == R) continue;
        update(pos[R], 1, N);

        for (int i = L + 1; i < R; i += 2) {
            if (color[i]) break;
            color[i] = 1;
        }
    }
    puts("Yes");
    return 0;
}


Measured memory_bytes: 5248
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
# stdin = open("sample.txt")


MOD = 1000000007
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr
    
def main():
    N = int(stdin.readline().rstrip())
    S = stdin.readline().rstrip()
    r = S.count("R")
    Sr = S[0:r]
    w_Sr = Sr.count("W")
    print(w_Sr)
    
main()

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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int main() {
    int a, b, k, cnt = 0;
    cin >> a >> b >> k;
    for (int i = min(a, b); i >= 0; --i) {
        if (a % i == 0 && b % i == 0) {
            cnt++;
            if (cnt == k) {
                cout << i << endl;
                break;
            }
        }
    }

    return 0;
}

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

#define ll long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define vi vector<int>
using namespace std;
int mod = 1'000'000'000 + 7;

void COME_LET_THE_GAMES_BEGIN() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << setprecision(20);
}

char x[3][110];
char H[] = {'A', 'B', 'C'};

char solve(vector<int> v = {0, 0, 0}, int t = 0) {
    char c = x[t][v[t]];
    if (c == '\0') {
        return H[t];
    }
    v[t]++;
    return solve(v, (c == 'a') ? 0 : (c == 'b') ? 1 : 2);
}

int main() {
    COME_LET_THE_GAMES_BEGIN();
    cin >> x[0] >> x[1] >> x[2];
    cout << solve() << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define PRECISION(x) cout << fixed << setprecision(x)
#define FAST_IO ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define ALLR(X) (X).rbegin(), (X).rend()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second

using namespace std;
 
template<class T> void max_self(T & a, const T & b) { if(a < b) a = b; }
template<class T> void min_self(T & a, const T & b) { if(a > b) a = b; }
typedef long long LL;
const int INF = 1e9 + 7;
const double PI = acos(-1.0);
const double EPS = (1e-9);


int main(){
  FAST_IO

  int N; cin >> N;
  if(N < 1000) cout << "ABC\n";
  else cout << "ABD\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

//update 2019/12/13

public class Main{

  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {

    int a = nextInt();
    int b = nextInt();

    int c = a+b;

    if(c==3){
      System.out.println("3");
    }
    else if(c==4){
      System.out.println("2");
    }
    else{
      System.out.println("1");
    }

/*
    for(int i=0;i<n;i++){
      System.out.println("a["+i+"]="+a[i]);
    }
*/

  }

  static String next(){
    return sc.next();
  }

  static int nextInt(){
    return Integer.parseInt(sc.next());
  }

  static long nextLong(){
    return Long.parseLong(sc.next());
  }

  static double nextDouble(){
    return Double.parseDouble(sc.next());
  }

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char aaa){
    return aaa - 48;
  }

  public static int maxInt(int[] a,int lng){
    int max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static int minInt(int[] a,int lng){
    int min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

  public static long maxLong(long[] a,int lng){
    long max=a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }

  public static long minLong(long[] a,int lng){
    long min=a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }

}


Measured memory_bytes: 21844
/*ex3_2
  moriai ryo 19B30920*/

#include <stdio.h>

int main(void){
  int pencil;
  scanf("%d",&pencil);
  int digit_1=pencil%10;/*一桁目 = mod10*/
  if(digit_1==3){
    printf("bon\n");
  }
  else if(digit_1==0 || digit_1==1 || digit_1==6 || digit_1==8){
    printf("pon\n");
  }
  else{
    printf("hon\n");
  }
  return 0;
}


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

using ll = long long;

int main() {
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  sort(a.rbegin(), a.rend());
  
  ll x = 0, y = 0;
  for(int i = 1; i < n; i++){
    if(a.at(i - 1) == a.at(i)){
      if(x == 0){
        x = a.at(i);
        i++;
      }
      else if(y == 0){
        y = a.at(i);
        break;
      }
    }
  }
  
  cout << x * y << endl;
}

Measured memory_bytes: 1024
while 1:
        n=int(input())
        if not n:break
        vote={"":0}
        cnt=0
        for c in input().split(" "):
            cnt+=1
            if c in vote:vote[c]+=1
            else:vote[c]=1
            v=sorted(vote.items(), key=lambda x: x[1])
            if v[-1][-1]>v[-2][-1]+n-cnt:
                print(*[v[-1][-2],cnt])
                break
            elif n==cnt:print("TIE")


Measured memory_bytes: 5624
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <algorithm>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef list<ll> listl;
typedef string str;

#define min(A, B) min(static_cast<ll>(A), static_cast<ll>(B))
#define max(A, B) max(static_cast<ll>(A), static_cast<ll>(B))

void in(ll& I)
{
	cin >> I;
}

void in(vl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(listl& I)
{
	for (auto& i : I)
	{
		cin >> i;
	}
}

void in(str& s)
{
	cin >> s;
}

void out(ll& O)
{
	cout << O;
}

void out(ll O)
{
	cout << O;
}

void out(vl& O)
{
	for (auto& o : O)
	{
		cout << o;
	}
}

ll Get(ll Max, ll N, ll K, ll A)
{
	if (N*A >= K)
	{
		return A * Max;
	}
	else
	{
		return Get(Max, N, K, A * 2);
	}
}

int main()
{
	ll N;
	in(N);

	ll K;
	in(K);

	ll M = 0;

	vl A(N);

	for (int i = 1; i <= N; i++)
	{
		A[i - 1] = Get(N, i, K, 1);
	}

	for (auto& a : A)
	{
		M += A[0] / a;
	}

	double D = 1.0*M / A[0];

	printf("%0.12lf", D);

	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int t[n], x[n], y[n];
    for (int i = 0; i < n; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }
    int t0 = 0, x0 = 0, y0 = 0, t1, x1, y1;
    for (int i = 0; i < n; i++) {
        t1 = t[i], x1 = x[i], y1 = y[i];
        if ((t1 - t0) < abs(x1 - x0) + abs(y1 - y0)
            || (abs(x1 - x0) + abs(y1 - y0) - (t1 - t0)) % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
        t0 = t1, x0 = x1, y0 = y1;
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1408
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
//#define inf 10000000000000001ll
//#define fi first
//#define se second
typedef long long ll;
using namespace std;
int a[201][201];
vector<int>g[201];
int used[201];
void dfs(int v){
    for (auto to:g[v]){
        if (used[to]==used[v]){
            cout<<-1;
            exit(0);
        }
        if (!used[to]){
            used[to]=used[v]%2+1;
            dfs(to);
        }
    }
}
int d[201][201];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;cin>>n;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            char c;cin>>c;
            a[i][j]=(c=='1');
        }
    }

    for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) d[i][j]=100000001;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            if (a[i][j]) {
                d[i][j]=1;
                g[i].push_back(j);
            }
        }
    }
    used[1]=1;
    dfs(1);
    for (int i=1;i<=n;i++) d[i][i]=0;


    for (int k=1;k<=n;k++){
        for (int i=1;i<=n;i++){
            for (int j=1;j<=n;j++){
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
            }
        }
    }
    int maxx=0;
    for (int i=1;i<=n;i++){
        for (int j=1;j<=n;j++){
            maxx=max(maxx,d[i][j]);
        }
    }
    cout<<maxx+1;
    return 0;
}


Measured memory_bytes: 1280
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
long long n,A,B,a[55],dp[55][3030],ans;
int main()
{
	cin>>n>>A;
	B=A;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	dp[0][0]=1;
	for(int i=0;i<n;i++)
	{
		for(int cnt=n;cnt>=0;cnt--)
		{
			for(int j=2626;j>=0;j--)
			{
				if(!dp[cnt][j])
				{
					continue;
				}
				dp[cnt+1][j+a[i]]+=dp[cnt][j];
			}
		}
	}
	for(int i=1;i<=n;i++)
	{
		ans+=dp[i][i*A];
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(void)
{
	int n;
	cin >> n;


	set<int> st;

	for (int i = 0; i < n; i++) {
		int m;
		cin >> m;
		st.insert(m);
	}

	cout << st.size() << endl;
	return 0;
}


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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------

//def function, class
//------------------------------------------
class MyClass         // 中身が空のクラス宣言
{
};
//main
//------------------------------------------
signed main(){
  int N;
  cin >> N;
  VI H(N);
  REP(i ,N) cin >> H.at(i);

  int ans=0;
  REP(i, N){
    int count=0;
    REP(j, i){
      if(H.at(i)>=H.at(j)) count++;
    }
    if(count==i) ans++;
  }

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
a,b,x = map(int,input().split())

import math

menseki = x/a
if menseki >= (a*b)/2:
    amari = a*b -menseki
    tan = amari * 2 / (a**2)
    
else:
    tan_90_theta = menseki * 2 / (b**2)
    tan = 1 / tan_90_theta
theta = math.degrees(math.atan(tan))
print(theta)

Measured memory_bytes: 38512
using System;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var  _ = Console.ReadLine().Split();
            var a = int.Parse(_[0]);
            var b = int.Parse(_[1]);
            var h = int.Parse(_[2]);
            var m = int.Parse(_[3]);

            var k = ((360 / 12 * h) + (0.5 * m)) - (360 / 60 * m);
            k = Math.Min(k, 360 - k);

            var x = (a * a) + (b * b) - ((2 * a * b) * Math.Cos(k * (Math.PI / 180)));
            Console.WriteLine(string.Format("{0:f20}",Math.Sqrt(x)));
        }
    }
}


Measured memory_bytes: 27824
A, B, C, K =map(int, input().split())

ans = 0

if A <= K:
    ans = ans + A
    K = K-A
    if B <= K:
        K = K-B
        if C >= K:
            ans = ans - K
            print(ans)
    else:
        print(ans)
else:
    print(K)

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

int main()
{
  uint64_t a, b;
  cin >> a >> b;
  if (a < b)
  {
    uint64_t tmp = a;
    a = b;
    b = tmp;
  }
  uint64_t r = a % b, x = a * b;
  while (r != 0)
  {
    a = b;
    b = r;
    r = a % b;
  }
  cout << x / b << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int big = 0;
		if(x >= y) {
			big = x;
		}else {
			big = y;
		}
		int abs = Math.abs(x - y);
		int sum = 0;
		
		if(a + b >= 2 * c) {
			sum = (big - abs) * (2 * c);
			if(big == x && a >= (2 * c)) {
				sum += (abs * (2 * c));
			}else if(big == x && a < (2 * c)) {
				sum += (abs * a);
			}else if(big == y && b >= (2 * c)) {
				sum += (abs * (2 * c));
			}else if(big == y && b < (2 * c)) {
				sum += (abs * b);
			}
		}else {
			sum = (big - abs) * (a + b);
			if(big == x && a >= (2 * c)) {
				sum += (abs * (2 * c));
			}else if(big == x && a < (2 * c)) {
				sum += (abs * a);
			}else if(big == y && b >= (2 * c)) {
				sum += (abs * (2 * c));
			}else if(big == y && b < (2 * c)) {
				sum += (abs * b);
			}
		}
		System.out.println(sum);
	}
}

Measured memory_bytes: 23892
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb emplace_back
#define fi first
#define se second
#define gg return puts("NO"),0;
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef pair<int,int> pi;
const int N=25,L=(1<<18)+5;
int low[L],hig[L],r[L],val[L];
vector<pi>vc[L];int n,lim;
priority_queue<pi,vector<pi>,greater<pi> >q;
int main(){
	scanf("%d",&n),lim=(1<<n);
	fp(i,0,lim-1){
		scanf("%d",&val[i]),--val[i];
		r[i]=(r[i>>1]>>1)|((i&1)<<(n-1));
	}
	fd(i,lim-1,0){
		hig[i]=(~val[i]?val[i]:lim-1);
		fp(k,0,n-1)if(i>>k&1^1)cmin(hig[i],hig[i|(1<<k)]);
	}
	fp(i,0,lim-1){
		if(~val[i])low[i]=val[i];
		fp(k,0,n-1)if(i>>k&1)cmax(low[i],low[i^(1<<k)]);
	}
	fp(i,0,lim-1){
		if(low[i]>hig[i])gg;
		vc[low[i]].pb(pi(hig[i],i));
	}
	fp(i,0,lim-1){
		for(auto v:vc[i])q.push(v);
		if(q.empty()||q.top().fi<i)gg;
		val[q.top().se]=i,q.pop();
	}
	puts("YES");
	fp(i,0,lim-1)printf("%d ",val[r[i]]+1);
	return 0;
}

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

int main()
{
	map<string, int> words;
	string str;
	while (cin >> str)
	{
		if (words.count(str))
		{
			words[str]++;
		}
		else
		{
			words[str] = 1;
		}
	}

	int Max = 0;
	string mode;
	string longest;
	for (auto i : words)
	{
		if (Max < i.second)
		{
			Max = i.second;
			mode = i.first;
		}
		if (longest.size() < i.first.size())
		{
			longest = i.first;
		}
	}
	cout << mode << ' ' << longest << endl;

	return 0;
}

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

int main(){
	int n, x;
	cin >> n >> x;
	vector<int> vc(n);
	for (int i=0;i<n;i++){
		cin >> vc.at(i);
	}
	int d =0,
	ans = 1;
	for (int i=0;i<n;i++){
		d += vc.at(i);
		if (d>x){
			break;
		}
		ans++;				
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
typedef struct node{
  int key;
  struct node *r,*l,*par;
}Node;

Node *root,*NIL;

Node* find(Node *u,int k){
  while(u!=NIL&&k!=u->key){
    if(k<u->key)u=u->l;
    else u=u->r;
  }
  return u;
}

void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;

  z=(Node *)malloc(sizeof(Node));
  z->key=k;
  z->l=NIL;
  z->r=NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->l;
    }
    else{
      x=x->r;
    }
  }

  z->par=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key<y->key){
      y->l=z;
    }
    else{
      y->r=z;
    }
  }
}

void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(Node *u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  int n,i,a;
  char ary[10];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%s",ary);
    if(strncmp(ary,"f",1)==0){
      scanf("%d",&a);
      Node *v=find(root,a);
      if(v!=NIL)printf("yes\n");
      else printf("no\n");
    }
    else if(strcmp(ary,"insert")==0){
      scanf("%d",&a);
      insert(a);
    }
    else if(strcmp(ary,"print")==0){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}




Measured memory_bytes: 20480
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
//#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;



int main(){
	
	int a,b;
	cin>>a>>b;
	if(a==1)a=14;
	if(b==1)b=14;
	if(a>b)cout<<"Alice"<<endl;
	else if(a==b)cout<<"Draw"<<endl;
	else if(a<b)cout<<"Bob"<<endl;
	
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

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

		List<Integer> listCardLankS = new ArrayList<Integer>();
		List<Integer> listCardLankH = new ArrayList<Integer>();
		List<Integer> listCardLankC = new ArrayList<Integer>();
		List<Integer> listCardLankD = new ArrayList<Integer>();

		List<String> listEgaraS = new ArrayList<String>();
		List<String> listEgaraH = new ArrayList<String>();
		List<String> listEgaraC = new ArrayList<String>();
		List<String> listEgaraD = new ArrayList<String>();

		for(int i = 1; i < 14; i++) {
			listCardLankS.add(i);
			listCardLankH.add(i);
			listCardLankC.add(i);
			listCardLankD.add(i);

			listEgaraS.add("S");
			listEgaraH.add("H");
			listEgaraC.add("C");
			listEgaraD.add("D");
		}

		for(int i = 0; i < A; i++) {
			String strA = sc.next();
			int intA = sc.nextInt();

		//	System.out.println("?????? : "+strA);
		//	System.out.println("????????? : "+intA);
			if(listEgaraS.contains(strA) && listCardLankS.contains(intA)) {
		//		System.out.println("?????????????????????????????£?????????");
				listEgaraS.remove(strA);
				listCardLankS.remove((Integer)intA);
			}
			if(listEgaraH.contains(strA) && listCardLankH.contains(intA)) {
		//		System.out.println("?????????????????????????????£?????????");
				listEgaraH.remove(strA);
				listCardLankH.remove((Integer)intA);
			}
			if(listEgaraC.contains(strA) && listCardLankC.contains(intA)) {
		//		System.out.println("?????????????????????????????£?????????");
				listEgaraC.remove(strA);
				listCardLankC.remove((Integer)intA);
			}
			if(listEgaraD.contains(strA) && listCardLankD.contains(intA)) {
		//		System.out.println("?????????????????????????????£?????????");
				listEgaraD.remove(strA);
				listCardLankD.remove((Integer)intA);
			}

		}

		for(int j : listCardLankS) {
			System.out.println("S "+j);
		}
		for(int j : listCardLankH) {
			System.out.println("H "+j);
		}
		for(int j : listCardLankC) {
			System.out.println("C "+j);
		}
		for(int j : listCardLankD) {
			System.out.println("D "+j);
		}
	}
}

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

using namespace std;

#define ll long long 
#define Fastest ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"

int main()
{
    int a;
    string s;
    
    cin >> a >> s;
    
    if(a < 3200)
    {
		cout << "red\n";
	}
	else cout << s << endl;
    	
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int N, K;
const int MOD = 10000;

int order[100], dp[100][3][3];//[day][today][yesterday]

int main() {
	cin >> N >> K;
	for (int i = 0; i < K; i++) {
		int a, b;
		cin >> a >> b;
		order[a - 1] = b;
	}
	if (!order[0]) {
		dp[0][0][1] = 1;
		dp[0][1][0] = 1;
		dp[0][2][0] = 1;
	}
	else
		if (order[0] - 1)dp[0][order[0] - 1][0] = 1;
		else dp[0][order[0] - 1][1] = 1;
	for (int i = 0; i < N - 1; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (!order[i]) {
					for (int l = 0; l < 3; l++) {
						if (order[i + 1] - 1 == l || !order[i + 1]) {
							if (j != k) dp[i + 1][l][j] += dp[i][j][k], dp[i + 1][l][j] %= MOD;
							else {
								if (j != l)dp[i + 1][l][j] += dp[i][j][k],dp[i + 1][l][j] %= MOD;
							}
						}
					}
				}
				else {
					for (int l = 0; l < 3; l++) {
						if (order[i + 1] - 1 == l || !order[i + 1]) {
							if (j != k) dp[i + 1][l][j] += dp[i][j][k], dp[i + 1][l][j] %= MOD;
							else {
								if (j != l)dp[i + 1][l][j] += dp[i][j][k], dp[i + 1][l][j] %= MOD;
							}
						}
					}
				}
			}
		}
	}
	int ans = 0;
	for (int i = 0; i < 3; i++) for (int j = 0; j < 3; j++)ans += dp[N - 1][i][j];
	cout << ans % MOD<< endl;
	return 0;
}

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<bool>> vvbool;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	//==================================

	int H, W;
	cin >> H >> W;

	vstring A(H);
	for (int i = 0; i < H; i++) {
		cin >> A[i];
	}

	vvint Grid(H);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			Grid[i].emplace_back(int(A[i][j] == '#'));
		}
	}


	int nowH = 0;
	int nowW = 0;

	while (nowH != H-1 || nowW != W-1) {

		if (nowH + 1 < H && Grid[nowH + 1][nowW] == 1) {
			nowH++;
		}
		else if (nowW + 1 < W && Grid[nowH][nowW] == 1) {
			nowW++;
		}
		else {
			cout << "Impossible";
			return 0;
		}


	}

	int sum = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			sum += Grid[i][j];
		}
	}

	if (sum != H + W-1) {
		cout << "Impossible";
		return 0;
	}

	cout << "Possible";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAX 10005
#define INF 99999999
#define EPS 1e-9
#define pb push_back
#define mp make_pair
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
using namespace std;
 typedef  int ll;
 typedef pair<int,int> ii;
 typedef vector<ii> vii;
 typedef vector <ll > vi;

int fun(int end,int p[])
{
  int x=end,sum=1;
  while(p[x]!=-1)
    sum++,x=p[x];
  return sum;
}

int main()
{
//  freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
 // ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int x,a,b;
  cin>>x>>a>>b;
  if(b-a<=0)
    cout<<"delicious"<<endl;
  else if(b-a<=x)
    cout<<"safe"<<endl;
  else
    cout<<"dangerous"<<endl;

 return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<pair<int,long>> a(N);
  for(int i=0;i<N;i++){
    int p,q;
    cin >> p >> q;
    a[i].first=q;
    a[i].second=p;
  }
  sort(a.begin(),a.end());
  bool ans=true;
  if(a[0].first<a[0].second)ans=false;
  for(int i=1;i<N && ans;i++){
    a[i].second+=a[i-1].second;
    if(a[i].first<a[i].second)ans=false;
  }
  if(ans)cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b){
    int n =a+b;
    int cnt=0;
    while(n){
      n/=10;
      cnt++;
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 2964
A,B,C,K = map(int,input().split())
import sys

ans = 0

ans = A
K = K - A

if K < 0:
  ans = ans + K
  print(ans)
  sys.exit(0)

if K > 0:
  K = K - B

if K > 0:
  ans = ans - K

print(ans)

Measured memory_bytes: 9196
n = int(input())
a = list(map(int,input().split()))

b = [0]*n
for i in range(n):
  b[i] = a[i] - (i+1)  

bs = sorted(b)  
if n%2 ==1:
  median = bs[n//2] 
else:
  median = (bs[n//2 -1]+bs[(n//2)])//2
  
ans = 0
for i in range(n):
  ans+= abs(a[i] -(median + i+1))
  
print(ans)    

Measured memory_bytes: 26180