akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  vector<vector<int>> a(H, vector<int>(W, 0));
  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      int a_ij;
      cin >> a_ij;
      a[i][j] = a_ij;
    }
  }

  int N = 0;
  vector<int> y, x, y_dash, x_dash;

  for (int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      if (a[i][j] % 2 != 0) {
        if (i != H - 1) {
          // not last row
          --a[i][j];
          ++a[i + 1][j];
          ++N;
          y.push_back(i + 1);
          x.push_back(j + 1);
          y_dash.push_back(i + 2);
          x_dash.push_back(j + 1);
        } else {
          // last row
          if (j != W - 1) {
            // not last column
            --a[i][j];
            ++a[i][j + 1];
            ++N;
            y.push_back(i + 1);
            x.push_back(j + 1);
            y_dash.push_back(i + 1);
            x_dash.push_back(j + 2);
          }
        }
      }
    }
  }

  cout << N << endl;
  for (int i = 0; i < N; ++i) {
    cout << y[i] << " " << x[i] << " " << y_dash[i] << " " << x_dash[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 5224
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n:i64 = read();
    let ans:String = if n == 0 {
        "0".to_string()
    } else {
        let mut n = n;
        let mut v = vec![];
        while n != 0 {
            if n % 2 == 0{
                v.push('0');
                n = n / -2;
            } else {
                v.push('1');
                n = (n-1) / -2;// n / 2 = 1 =>  (n -1 )/ 2= 0
            }
        }
        v.reverse();
        v.into_iter().collect::<String>()
    };
    println!("{}", ans);
}

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

int main() {
  double a, b, C;
  cin >> a >> b >> C;

  double area = (a * b * sin(C*M_PI/180)) / 2;
  double L = a + b + (sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(C*M_PI/180)));
  double height = b * sin(C*M_PI/180);

  printf("%.5f\n", area);
  printf("%.5f\n", L);
  printf("%.5f\n", height);

  return 0;
}



Measured memory_bytes: 3372
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n,m; cin >> n>>m;
  vi h(n);
  vi good(n,true);
  rep(i,n) cin >> h[i];
  rep(i,m) {
    int a,b; cin >> a>>b;
    a--;b--;
    if (h[a] > h[b]) {
      good[b] = false;
    } 
    if (h[a] < h[b]) {
      good[a] = false;
    }
    if (h[a] == h[b]) {
      good[a] = good[b] = false;
    }
  }
  int ans = 0;
  rep(i,n) {
    if (good[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std ;
#define int long long
#define fi first
#define se second
#define pb push_back
#define pii pair<int, int>
#define mod 1000000007

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int d,t,s ;
int arr[500005] ;
string str ;

void solve()
{
    cin >> d >> t >> s ;
    if(s*t>=d)
        cout << "Yes" ;
    else
        cout << "No" ;
}
int32_t main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int tt = 1;
	//cin >> tt ;
	while(tt--)
	{
	     solve() ;
	}
}


Measured memory_bytes: 3640
// AOJ 1368: Quality of Check Digits
// 2017.11.3 bal4u@uu

#include <stdio.h>
#include <stdlib.h>

int t[10][10];
int n[5];

int cd(int len)
{
	int i, k;
	for (k = i = 0; i < len; i++) k = t[k][n[i]];
	return k;
}

int check()
{
	int i, j, k;
	for (i = 0; i < 5; i++) for (j = 0; j < 10; j++) if (j != n[i]) {
		k = n[i], n[i] = j;
		if (!cd(5)) return 1;
		n[i] = k;
	}
	for (i = 0; i < 4; i++) if (n[i] != n[i+1]) {
		j = n[i], k = n[i+1];
		n[i] = k, n[i+1] = j;
		if (!cd(5)) return 1;
		n[i] = j, n[i+1] = k;
	}
	return 0;
}

int main()
{
	int i, j, k, ans;
	char b[5];

	for (i = 0; i < 10; i++) for (j = 0; j < 10; j++) scanf("%s", b), t[i][j] = *b & 0xf;

	ans = 0;
	for (i = 0; i < 10000; i++) {
		for (k = i, j = 3; j >= 0; j--) n[j] = k % 10, k /= 10;
		n[4] = cd(4);
		ans += check();
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1848
use std::io::*;
use std::str::FromStr;
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}
fn main(){
    let t:f64=read();
    let x:f64=read();
    println!("{}",t/x);
}

Measured memory_bytes: 2176
#include<iostream>
#include<algorithm>
#include<cstdint>
#include<cstring>
using namespace std;

const int MAX = 100000;

/**
 * 転倒数を求めます。<br>
 * 計算量はO(NlogN)です。
 * @param a 転倒数を求める数列(ソートされてしまうので注意)
 * @param l 数列の左端
 * @param r 数列の右端(こっちは含めない)
 * @return 転倒数
 */
int64_t invNum(int *a, int l, int r) {
	int64_t ret = 0;
	int n = r - l, m = l + (n >> 1);
	if (n <= 1) return ret;
	ret += invNum(a, l, m); // マージソートの分解部分
	ret += invNum(a, m, r);
	int *tmp = new int[n];
	for (int i = 0, j = m;i < n;++ i) { // マージソートの結合部分
		if (a[l] <= a[j]) {
			tmp[i] = a[l];
			++ l;
			if (l >= m) {
				memcpy(tmp + i + 1, a + j, sizeof(int) * (n - i - 1));
				break;
			}
		} else { // 結合時に順番をひっくり返す場所→転倒場所
			tmp[i] = a[j];
			ret += m - l; // 転倒した数を移動させる距離
			++ j;
			if (j >= r) {
				memcpy(tmp + i + 1, a + l, sizeof(int) * (n - i - 1));
				break;
			}
		}
	}
	memcpy(a + r - n, tmp, sizeof(int) * n);
	return ret;
}

bool check(int x, int *a, int N) {
	int *b = new int[N + 1];
	b[0] = 0;
	for (int i = 0;i < N;++ i) b[i + 1] = b[i] + (a[i] < x ? -1 : 1); // 累積和
	return invNum(b, 0, N + 1) <= (int64_t)N * (N + 1) >> 2;
}

int binarySearch(int *a, int N) {
	int min = 0, max = N;
	int b[MAX];
	memcpy(b, a, sizeof(int) * N);
	sort(b, b+N);
	for (int mid = max >> 1;max - min > 1;mid = min + (max - min >> 1)) { // 二分探索
		if (check(b[mid], a, N)) min = mid;
		else max = mid;
	}
	return b[min];
}
int main() {
	int N, a[MAX];
	cin >> N;
	for (int i = 0;i < N;++ i) cin >> a[i];
	cout << binarySearch(a, N);
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり
また、コンテスト後に https://31536000.hatenablog.com/ で解説していると思うので、良かったら読んでねー

解説AC
*/

Measured memory_bytes: 149504
n=int(input())
h=list(map(int,input().split()))

if n==1:
    print('Yes')

else:
    c=0
    for i in range(n):
        if c<h[i]:
            h[i]-=1
            c=h[i]
        elif c==h[i]:
            c=h[i]
        else:
            print('No')
            break
    else:
        print('Yes')



Measured memory_bytes: 14396
n = int(input())
p = list(map(int, input().split()))
ans = 0
for i in range(n-2):
	if p[i] < p[i+1] and p[i+1] < p[i+2]:
		ans += 1
	elif p[i+2] < p[i+1] and p[i+1] < p[i]:
		ans += 1
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
const int MX=200010;
int N, M, k, x;
int arr[MX];
int main()
{
    cin>>N;
    ll sa=0, sb=0;
    for(int i=0;i<N;i++) cin>>arr[i];
    sort(arr, arr+N);
    bool a=0;
    for(int i=N-1;i>=0;i--)
    {
        if(!a) sa+=arr[i];
        else sb+=arr[i];
        a=!a;
    }
    cout<<sa-sb;
    return 0;
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_1_D
#include <iostream>
using namespace std;
int main(){
  int S;
  cin >> S;
  int sec = S % 60;
  int hour = S / 3600;
  int minute = (S - hour* 3600 - sec) / 60;
  cout << hour << ":" << minute << ":" << sec << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;

//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;

//少数点表示
//cout << std::fixed << std::setprecision(14) << 値

int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
    int a,b;
    cin >> a >> b;
    bool flag = false;
    rep1(i,1,4){
        if((a*b*i)%2 != 0) flag = true;
    }
    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

int main()
{
  string s;
  cin>>s;
  int sum=0;
  for(int i=0;i<s.length();i++)
    sum+=s[i]-'0';
  if(sum%9)
    cout<<"No";
  else
    cout<<"Yes";
  return 0;
}

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

#define ll   long long int
#define rep(i,n)    for(int i=0;i<(int)n;i++)
#define show(s)     cout<<s<<endl

int main() {

    string S;
    cin >> S;

    int count = 0;
    int mx = 0;

    int N = S.size();

    rep(i,N){
        if(S[i]=='A' || S[i]=='C' || S[i]=='G' || S[i]=='T'){
            count++;
        }else{
            mx = max(mx,count);
            count = 0;
        }
    }

    mx = max(mx,count);
    show(mx);

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main(void) {
	int i, N, c = 0;
	int* x;
	scanf("%d", &N);
	x =(int*) malloc(N*sizeof(int));
	if (x == NULL)
	{
		puts("Failed");
		return 1;
	}
	
	for (i = 0; i < N; i++) {
		scanf("%d", &x[i]);
	}
	for (i = 0; i < N; i++)
	{
		if (x[i] % 2 == 0)
		{
			c--;
			if (x[i] % 3 == 0 || x[i] % 5 == 0)
				c++;
		}
	}
	if (c == 0)printf("APPROVED");
	else printf("DENIED");
	return 0;
}

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

int main() {
	int N;
	cin >> N;
	
	vector<int> dp(3);

	while (N--) {
		int ai, bi, ci;
		cin >> ai >> bi >> ci;
		dp = {ai + max(dp[1], dp[2]),
			  bi + max(dp[0], dp[2]),
			  ci + max(dp[0], dp[1])};
	}

	cout << *max_element(dp.begin(), dp.end()) << endl;
}


Measured memory_bytes: 256
from collections import deque


n, m = map(int, input().split())
rels = [None] + [[] for _ in range(n)]
for _ in range(m):
    l, r, d = map(int, input().split())
    rels[l].append((r, d))
    rels[r].append((l, -d))

x = [None] + [None] * n
i = 0
while i < n:
    i += 1
    if x[i] is not None:
        continue

    q = deque()
    x[i] = 0
    q.append(i)
    while q:
        x1 = q.popleft()
        for x2, d in rels[x1]:
            if x[x1] is not None and x[x2] is not None:
                if x[x2] - x[x1] != d:
                    print('No')
                    exit()
                continue
            if x[x1] is not None and x[x2] is None:
                x[x2] = x[x1] + d
                q.append(x2)
            elif x[x1] is None and x[x2] is not None:
                x[x1] = x[x2] - d
                q.append(x1)

print('Yes')

Measured memory_bytes: 66804
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
template <class T> int size(const T &x) { return x.size(); }
const int INF = 2147483647;
#define rep(i,a,b) for (__typeof(a) i=(a); i<(b); ++i)
#define iter(it,c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)

int main() {
    int n;
    cin >> n;
    vi arr;
    rep(i,0,2*n) {
        int x;
        cin >> x;
        arr.push_back(x);
    }
    sort(arr.begin(), arr.end());
    ll res = 0;
    for (int i = 0; i < 2*n; i += 2) {
        res += arr[i];
    }
    cout << res << endl;
    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    char s[n];

    for (size_t i = 0; i < n; i++)
    {
        cin >> s[i];
        if (s[i] == 'Y')
        {
            cout << "Four" << endl;
            break;
        }
        else if (i == (n - 1))
        {
            cout << "Three" << endl;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n;
  while(cin>>n){
    vector<int> A(2001),B(2001);
    REP(i,1001)REP(j,1001)A[i+j]++;
    REP(i,1001)REP(j,1001)B[i+j]++;
    int ans=0;
    REP(i,2001)if(n-i>=0&&n-i<=2000)ans+=A[i]*B[n-i];
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3124
#include <stdio.h>

int BinarySearch(int *,int,int);  

int main(){
  int s[100001],n,q,el,cnt=0,i;

  scanf("%d",&n);

  for(i=0;i<n;i++) scanf("%d",&s[i]);

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&el);
    cnt+=BinarySearch(s,el,n);

  }

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

  return 0;
}

int BinarySearch(int *a,int el,int n){
  int right,left,mid;

  left=0;
  right=n;



  while(right>left){
    mid=(right+left)/2;
    
    if(a[mid]==el) return 1;

    if(el<a[mid]) right=mid;
    else left=mid+1;
  }

  return 0;
}

  



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

using namespace std;

int main() {
    int n;
    cin >> n;
    string nstr = to_string(n);
    int fx = 0;
    for(auto e : nstr)
    {
        fx += e - '0';
    }
    if(n % fx == 0)
    {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main() {
	int A, B; string S; cin >> A >> B >> S;
	bool flag=true;
	for(int i=0; i<A+B+1; ++i){
	    if((i==A)^(S[i]=='-')){
	        flag=false;
	        break;
	    }
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


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

using namespace std;

long long R, C, K;
vector<long long> r, c, v;
vector<vector<long long>> items;

long long dp(long long currR, long long currC, long long tookItemNbSameRow, vector<vector<vector<long long>>>& memo) {
    if (memo[currR][currC][tookItemNbSameRow] >= 0) {
        return memo[currR][currC][tookItemNbSameRow];
    }
    long long ret = 0LL;
    if (items[currR][currC] > 0) {
        long long skipToR = (currR == R - 1) ? 0LL : dp(currR + 1, currC, 0, memo);
        long long skipToC = (currC == C - 1) ? 0LL : dp(currR, currC + 1, tookItemNbSameRow, memo);
        long long retTemp = max(skipToR, skipToC);
        if (tookItemNbSameRow < 3) {
            long long tookToR = (currR == R - 1) ? 0LL : dp(currR + 1, currC, 0, memo);
            long long tookToC = (currC == C - 1) ? 0LL : dp(currR, currC + 1, tookItemNbSameRow + 1, memo);
            retTemp = max(retTemp, items[currR][currC] + max(tookToR, tookToC));
        }
        ret = retTemp;
    }
    else {
        long long skipToR = (currR == R - 1) ? 0LL : dp(currR + 1, currC, 0, memo);
        long long skipToC = (currC == C - 1) ? 0LL : dp(currR, currC + 1, tookItemNbSameRow, memo);
        long long retTemp = max(skipToR, skipToC);
        ret = retTemp;
    }
    memo[currR][currC][tookItemNbSameRow] = ret;
    return ret;
}

void Main() {
    cin >> R >> C >> K;
    r = vector<long long>(K, 0LL);
    c = vector<long long>(K, 0LL);;
    v = vector<long long>(K, 0LL);
    items = vector<vector<long long>>(R, vector<long long>(C, 0LL));
    for (long long i = 0; i < K; ++i) {
        cin >> r[i] >> c[i] >> v[i];
        --r[i];
        --c[i];
        items[r[i]][c[i]] = v[i];
    }

    vector<vector<vector<long long>>> memo(R, vector<vector<long long>>(C, vector<long long>(4, -1LL)));
    long long ans = dp(0, 0, 0, memo);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 711644
/**
 *  http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0015
 */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>

#define MAX_DIGITS 80
#define MAX_INPUTS 101

int             add(const char *n1, const char *n2, char **a);
char           *stralloc(const size_t length);

int
main()
{
    int             n, i;
    char            n1[MAX_INPUTS];
    char            n2[MAX_INPUTS];
    char           *r;

    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s", n1);
        scanf("%s", n2);

        if (add(n1, n2, &r)) {
            printf("overflow\n");
            continue;
        }

        printf("%s\n", r);
        free(r);
    }

    return 0;
}

int
add(const char *n1, const char *n2, char **a)
{
    int             l1, l2, lr;
    int             c = 0;
    int             d;
    int             i;
    char           *r;
    char           *n;

    l1 = strlen(n1);
    l2 = strlen(n2);
    if (l1 > MAX_DIGITS || l2 > MAX_DIGITS) {
        return ERANGE;
    }
    lr = l1 > l2 ? l1 : l2;

    r = stralloc(lr + 1);
    while (lr >= 0) {
        d = c + (l1-- > 0 ? n1[l1] - '0' : 0) + (l2-- > 0 ? n2[l2] - '0' : 0);
        c = d / 10;
        r[lr--] = d % 10 + '0';
    }
    i = r[0] == '0' ? 1 : 0;
    if (strlen(r + i) > MAX_DIGITS) {
        free(r);
        return EOVERFLOW;
    }
    if (i != 0) {
        n = r;
        r = stralloc(strlen(n + i));
        strcpy(r, n + i);
        free(n);
    }
    *a = r;
    return 0;
}

char           *
stralloc(const size_t length)
{
    return (char *)calloc(length + 1, sizeof(char));
}

Measured memory_bytes: 1736
n = int(input())
t, a = map(int,input().split())
h_a = (t - a) / 0.006
h = list(map(int,input().split()))
m = 10**5
j = -1

for i in range(len(h)):
    h[i] = h[i] - h_a
    if h[i] < 0:
        h[i] = -h[i]
    if m > h[i]:
        m = h[i]
        j = i

print(j+1)


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

string S;

int main(void)
{
    int min=100000000;

    cin >> S;

    for(int i=0;i<S.size()-2;i++)
    {
        if(min>abs((int)(S[i]-'0')*100+(int)(S[i+1]-'0')*10+(int)(S[i+2]-'0')-753))
        {
            min=abs((int)(S[i]-'0')*100+(int)(S[i+1]-'0')*10+(int)(S[i+2]-'0')-753);
        }
    }

    cout << min << endl;

    return 0;
}

Measured memory_bytes: 256
maisu=int(input())
mochihuda=[]
hikaku=[]

for i in range(maisu):
    huda=list(map(str,input().split()))
    huda[1]=int(huda[1])
    mochihuda.append(huda)

for i in range(1,5):
    for j in range(1,14):
        if i==1:
            hikaku=['S',j]
        elif i==2:
            hikaku=['H',j]
        elif i==3:
            hikaku=['C',j]
        elif i==4:
            hikaku=['D',j]

        if hikaku not in mochihuda:
            print(str(hikaku[0])+" "+str(hikaku[1]))

        hikaku=[]



Measured memory_bytes: 5600
import java.util.*;
import java.io.*;

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt();
		int x[] = fs.nextIntArray(n);
		Arrays.sort(x);
		int min = 10000000;
		for(int i=0;i<=100;i++) {
			int tmp = 0;
			for(int j=0;j<n;j++) {
				int d = (x[j]-i)*(x[j]-i);
				tmp += d;
			}
			min = Math.min(min, tmp);
		}
		System.out.println(min);
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

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

using namespace std;


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

	int n;
	long double ans;
	cin >> n;
	if (n % 2 == 0) ans = 0.5;
	else ans = (n / 2 + 1) * 1.0 / n;

	cout << setprecision(10) << fixed << ans << "\n";
	
	return 0;
}


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

int main(){
  int n,k,ans=0;
  string RL;
  cin>>n>>k;
  cin>>RL;
  for(int i=0;i<n;i++){
    if(RL[i]==RL[i+1]) ans++;
  }
  cout<<min(ans+(k*2),n-1);
} 

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  string s;
  int k;
  cin >> k >> s;

  if(s.size() <= k){
    print(s);
  } else {
    rep(i, k){
      cout << s[i];
    }
    cout << "..." << endl;
  }

}


Measured memory_bytes: 3056
#include "bits/stdc++.h"
using namespace std;

class UnionFind {
private:
	long long Size;
	vector<long long> Parent, Rank;
public:
	UnionFind(long long N) : Size(N) {
		Parent.resize(N);
		Rank.resize(N);
		for (int i = 0; i < N; i++) {
			Parent[i] = i;
			Rank[i] = 0;
		}
	}
	long long Root(long long N) {
		if (N == Parent[N]) {
			Rank[N] = 0;
			return N;
		}
		Rank[N] = 1;
		return Parent[N] = Root(Parent[N]);
	}
	bool Same(long long A, long long B) {
		return Root(A) == Root(B);
	}
	void Merge(long long A, long long B) {
		long long RA = Root(A), RB = Root(B);
		if (Rank[RA] < Rank[RB]) {
			Parent[RA] = RB;
			Rank[RA]++;
		}
		else {
			Parent[RB] = Root(RA);
			Rank[RB]++;
		}
	}
};

int main() {
	long long N, M, Q;
	vector<long long> A, B, C;
	bool check = true;
	cin >> N >> M >> Q;
	A.resize(Q), B.resize(Q), C.resize(Q);
	UnionFind UF(N);
	for (int i = 0; i < Q; i++) {
		cin >> A[i] >> B[i] >> C[i];
		if (C[i] == 1) check = false;
	}
	if (check) {
		if (M == N - 1) cout << "Yes" << endl;
		else cout << "No" << endl;
		return 0;
	}
	if (M == N - 1) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < Q; i++) {
		if (C[i] == 0) UF.Merge(A[i], B[i]);
	}
	for (int i = 0; i < Q; i++) {
		if (C[i] == 1) {
			if (UF.Same(A[i], B[i])) {
				cout << "No" << endl;
				return 0;
			}
		}
	}
	vector<long long> Roots(N);
	for (int i = 0; i < N; i++) {
		Roots[i] = UF.Root(i);
	}
	sort(Roots.begin(), Roots.end());
	Roots.erase(unique(Roots.begin(), Roots.end()), Roots.end());
	long long P = Roots.size();
	if (P <= 2) cout << "No" << endl;
	else if (N - P + P * (P - 1) / 2 < M) cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 4992
N = int(input())
K = int(input())
X = list(map(int, input().split()))
ans = 0
for i in range(N):
    if X[i]<= abs(X[i]-K):
        ans += 2*X[i]
    else:
        ans += 2*abs(X[i]-K)
print(ans)
        

Measured memory_bytes: 38256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
#define pint pair<int,int>
#define vi(v) rep(i,v.size())cin >> v[i]
#define vc(v) rep(i,v.size())cout << v[i] << endl
#define ni(n) cin >> n
#define nc(n) cout << n << endl
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  ll a,b;
  cin >> a >> b;
  if(a <= 0 && 0 <= b)cout << "Zero" << endl;
  else if(0 < a)cout << "Positive" << endl;
  else{
    ll c = abs(a - b) + 1;
    if(c % 2)cout << "Negative" << endl;
    else cout << "Positive" << endl;
  }
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}


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

using namespace std;

typedef long long ll;

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

	int n, k;
	cin >> n >> k;

	vector<double> p(n);
	rep(i, n) cin >> p[i];

	double ans = 0.0;

	double tmp = 0.0;
	rep(i, k){
		tmp += (p[i] + 1.0) / 2.0;
	}

	ans = max(ans, tmp);
	for(int i = k; i < n; i++){
		tmp += (p[i] + 1.0) / 2.0;
		tmp -= (p[i-k] + 1.0) / 2.0;
		ans = max(ans, tmp);
	}

	cout << fixed << setprecision(10);
	cout << ans << endl;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val list: List<String> = readLine()!!.split(" ").map { it.toString() }
    var weightList = mutableListOf<Int>()
    for (i in (0..list[0].toInt()-1))
    {
        weightList.add(readLine()!!.toInt())
    }
    var trackCnt=  list[1].toInt()
    if (trackCnt == 1)
    {
        println(weightList.sum().toString())
        return
    }
    var mid = Math.ceil((weightList.sum().toDouble() / trackCnt.toDouble())).toInt()
    if (mid < weightList.max()!!)
    {
        mid = weightList.max()!!
    }
    //println(weightList.sum())
    var cnt:Int
    var w:Int
    val weightTotal = weightList.sum()
    //最適weight探索
    for (j in (mid..weightTotal-1)) {
        //println("j"+j.toString())
        w = j
        cnt = 0
        for (i in (0..weightList.count() - 1)) {
            if (w >= weightList[i]) {
                w = w - weightList[i]
                //println("weight:"+w.toString())
                if (w==0)
                {
                    cnt++
                    //println("cnt:"+cnt.toString())
                    w = j
                }
            } else {
                cnt++
                //println("cnt:"+cnt.toString())
                w = j - weightList[i]
                //println("weight:"+w.toString())
            }
            if (cnt > trackCnt)
            {
                //println(j.toString()+"break")
                break
            }
            else if((trackCnt!= cnt) && ((weightTotal - (cnt * j)) / (trackCnt - cnt)) > j)
            {
                break
            }
        }
        if (w!=j)
        {
            cnt++
        }
        if (cnt <= trackCnt) {
            println(j)
            break
        }
    }
}



Measured memory_bytes: 43732
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io
    
    int n;
    cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    ll sub=0;
    ll r=0, g=0, b=0;

    rep(i,n) {
        if(s[i]=='R') r++;
        else if(s[i]=='G') g++;
        else b++;
    }
    ans=r*g*b;

    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            if(s[i]==s[j]) continue;
            int k=j*2-i;
            if(k>=n || s[k]==s[i]||s[k]==s[j]) continue;
            sub++;
        }
    }
    
    cout<<ans-sub<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include<stdio.h>
int main(){
	int S,h,m,s;
	scanf("%d",&S);
	h=S/3600;
	m=S%3600/60;
	s=S-(h*3600+m*60);
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

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

int main()
{
  ll a,b;
  ll arr[4];
  memset(arr,0,sizeof(arr));
  cin>>a>>b;
  arr[a]++;arr[b]++;
  int i;
  for( i=1;i<4;i++)
  {
    if(arr[i]==0)
      break;
  }
  cout<<i<<"\n";
  return 0;
}

Measured memory_bytes: 256
using System;

namespace AtCoder2
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] x = Console.ReadLine().Split(' ');
            int A = int.Parse(x[0]);
            int B = int.Parse(x[1]);
            int C = int.Parse(x[2]);

            if (A >= B && B>=C)
            {
                Console.WriteLine(A * 10 + B + C);
            }
            else if (B >= A && A >= C)
            {
                Console.WriteLine(B * 10 + A + C);
            }
            else if (C >= A && A >= B)
            {
                Console.WriteLine(C * 10 + A + B);
            }
            else if (A >= C && C >= B)
            {
                Console.WriteLine(A * 10 + C + B);
            }
            else if (B >= C && C >= A)
            {
                Console.WriteLine(B * 10 + C + A);
            }
            else
            {
                Console.WriteLine(C * 10 + B + A);
            }
       }
    }
}   

Measured memory_bytes: 13140
N = int(input())
alist = list(map(int, input().split()))
import numpy as np
Sum_a = 0
Sum_j_list = np.cumsum(alist)
for i in range(N-1):
  Sum_j = int((Sum_j_list[N-1] - Sum_j_list[i]) % int(1e9+7))
  Sum_a += (alist[i] * Sum_j) % int(1e9+7)
print(int(Sum_a % int(1e9+7)))

Measured memory_bytes: 37828
import copy

h, w, z = map(int, input().split())
table = [['.' for j in range(w)] for i in range(h)]
ans = 0

for i in range(h):
    column = str(input())
    for j in range(w):
        table[i][j] = column[j]

tmp = h + w

for i in range(2**tmp):
    table_tmp = copy.deepcopy(table)
    count = 0

    for j in range(h):
        if (i >> j) & 1:
            for k in range(w):
                table_tmp[j][k] = 'x'

    for l in range(w):
        if (i >> (h + l)) & 1:
            for m in range(h):
                table_tmp[m][l] = 'x'

    for p in range(h):
        for q in range(w):
            if table_tmp[p][q] == '#':
                count += 1

    if count == z:
        ans += 1

print(ans)


Measured memory_bytes: 9348
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int n;cin>>n;
    if(n<1000)cout<<"ABC"<<endl;
    else cout<<"ABD"<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N;
    cin >> N;
    vector<int> A(N),B(N);
    rep(i,N){
        cin >> A[i];
        B[i] = A[i];
    }
    sort(B.begin(),B.end());
    map<int,int> odd,even;
    rep(i,N){
        if(i%2==0){
            even[B[i]]++;
        }else{
            odd[B[i]]++;
        }
    }
    ll cnt = 0;
    rep(i,N){
        // cout << "i:" << i << " A[i]:" << A[i] << " odd:" << odd[A[i]] << " even:" << even[A[i]] << endl;
        if(i%2==0&&even[A[i]]!=0){
            cnt++;
            even[A[i]]--;
        }else if(i%2==1&&odd[A[i]]!=0){
            cnt++;
            odd[A[i]]--;
        }
    }
    cout << (N - cnt)/2 << endl;
    return 0;
}

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

namespace patch {
  template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
}
int main() {

  int n;
  cin >> n;

  int a_4,a_7;
  a_4 = n/4;
  a_7 = n/7;
  for(int i=0; i<n/4+1; i++) {
    for(int j=0; j<n/7+1; j++) {
      if(4*i+7*j == n) {
	cout << "Yes" << endl;
	return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define MOD 1000000007
long long int power(long long int s, long long int t)
{
	long long int ans = 1;
	long long int k = s;
	while(t)
	{
		if(t%2==1) ans*=k, ans%=MOD;
		t/=2;
		k*=k, k%=MOD;
	}
	return ans;
}
int main()
{
	int a;
	scanf("%d",&a);
	long long int s1 = power(10,a);
	long long int s2 = power(9,a);
	long long int s3 = power(8,a);
	printf("%lld",(s1+2*(MOD-s2)+s3)%MOD);
}

Measured memory_bytes: 1736
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	static int r,c,a1,a2,b2,b1;
	static int[] v1={0,0,0,1,1,1,2,2,2};
	static int[] v2={0,1,2,0,1,2,0,1,2};
	public static void main(String[] args) {
		Scanner cin=new Scanner(System.in);
		r=cin.nextInt();
		c=cin.nextInt();
		a1=cin.nextInt();
		a2=cin.nextInt();
		b1=cin.nextInt();
		b2=cin.nextInt();
		int[][] goals=new int[9][2];
		for(int i=0;i<9;i++){
			v1[i]=v1[i]*r;
			v2[i]=v2[i]*c;
		}
		for(int i=0;i<9;i++){
			goals[i][0]=b1+v1[i];
			goals[i][1]=b2+v2[i];
		}
		for(int i=0;i<9;i++){
//			System.out.println(goals[i][0]+" "+goals[i][1]);
		}
		
		a1=a1+r;
		a2=a2+c;
		int min=1<<30,x=0,y=0,cnt=0;;
		for(int i=0;i<9;i++){
			int dis=Math.abs(goals[i][0]-a1)+Math.abs(goals[i][1]-a2);
			if(min>dis){
				x=Math.abs(goals[i][0]-a1);
				y=Math.abs(goals[i][1]-a2);
				cnt=1;
				min=dis;
			}
			else if(min==dis){
				cnt++;
			}
		}
//		System.out.println(x+" "+y+" "+cnt);
		BigInteger bg=BigInteger.ONE;
		for(int i=1;i<=x+y;i++){
			bg=bg.multiply(new BigInteger(""+i));
		}
//		System.out.println(bg);
		for(int i=1;i<=x;i++){
			bg=bg.divide(new BigInteger(""+i));
		}
		for(int i=1;i<=y;i++){
			bg=bg.divide(new BigInteger(""+i));
		}
		bg=bg.multiply(new BigInteger(""+cnt));
			
		System.out.println(bg.remainder(new BigInteger("100000007")));
	}

}

Measured memory_bytes: 23036
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define bitrep(X,N) for(ll X = 0; X < (1 << (N)); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 


using namespace std;


int main(){

    int n,co;
    cin >> n >> co;

    int d[501][501] = {};
    int c[501][501] = {};

    int tmp;

    rep(i,co){
        rep(j,co){
            cin >> tmp;
            d[i + 1][j + 1] = tmp;
        }
    }

    rep(i,n){
        rep(j,n){
            cin >> tmp;
            c[i + 1][j + 1] = tmp;
        }
    }

    vector<vector<int>> color;
    vector<vector<pair<int,int>>> cost;
    vector<int> tmpv;
    vector<pair<int,int>> tmpv2;

    rep(i,co + 1){
        tmpv.pback(0);
    }

    rep(i,3){
        color.pback(tmpv);
        cost.pback(tmpv2);
    }

    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= n; j++){
            int mod = (i + j) % 3;
            color[mod][c[i][j]]++;
        }
    }

    rep(k, 3){
        for(int i = 1; i <= co; i++){
            int tmpcost = 0;

            for(int j = 1; j <= co; j++){
                tmpcost += color[k][j] * d[j][i];
            }

            cost[k].pback(mpair(tmpcost,i));
        }
        sort(ALL(cost[k]));
    }

    int ans = INT_MAX;

    rep(i,3){
        int color0 = cost[0][i].second;
        rep(j,3){
            int color1 = cost[1][j].second;
            if(color0 == color1) continue;
            rep(k,3){
                int color2 = cost[2][k].second;
                if(color0 == color2 || color1 == color2) continue;
                int tmpcost = cost[0][i].first + cost[1][j].first + cost[2][k].first;

                ans = min(ans,tmpcost);
            
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2176
#!/usr/bin/ruby
while(m,a,b=gets.split.map(&:to_i))[0]!=0
	p m.times.map{gets.to_i}.each_cons(2).with_index(1).map{|(x,y),i|[x-y,i]}.drop(a-1).take(b-a+1).max[1]
end

Measured memory_bytes: 8884
#include<bits/stdc++.h>
using namespace std;
int main()
{
// #ifndef ONLINE_JUDGE
// 	freopen("input", "r", stdin);
// 	freopen("output", "w", stdout);
// #endif

	int n;	cin >> n;
	map<string, int> m = {{"AC", 0}, {"WA", 0}, {"TLE", 0}, {"RE", 0}};
	string s;

	while (n--)
	{
		cin >> s;
		m[s]++;
	}

	cout << "AC x " << m["AC"] << endl;
	cout << "WA x " << m["WA"] << endl;
	cout << "TLE x " << m["TLE"] << endl;
	cout << "RE x " << m["RE"] << endl;

	// for (auto i : m)
	// cout << i.first << " x " << i.second << endl;

}

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

const int INF = 1e9;

int main() {
    int N, K, Q;
    cin >> N >> K >> Q;
    vector<int> A(N + 2);
    rep(i, N) cin >> A[i + 1];
    int ans = INF;
    auto solve = [&](int x) -> int {
        priority_queue<int, vector<int>, greater<int>> que;
        vector<int> P;
        rep(i, N + 2) if(A[i] < x) P.push_back(i);
        rep(i, P.size() - 1) {
            priority_queue<int, vector<int>, greater<int>> tmp;
            for(int j = P[i] + 1; j < P[i + 1]; ++j) tmp.push(A[j]);
            while(tmp.size() >= K) que.push(tmp.top()), tmp.pop();
        }
        int mx = 0;
        rep(i, Q) {
            if(que.empty()) return INF;
            mx = que.top(); que.pop();
        }
        return mx - x;
    };
    for(int i = 1; i < N + 1; ++i) ans = min(ans, solve(A[i]));
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3676
#include<iostream>
using namespace std;
int main()
{
int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<=a)
    cout<<k;
  else if(k>a&&k<=b)
    cout<<a;
  else
    cout<<a-(k-a-b);
  return 0;
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	int n;

	string s;

	cin>>n>>s;

	vi sum_e(n+1, 0), sum_w(n+1, 0);

	rep(i, n){
		if(s[i]=='E'){
			sum_e[i+1]=sum_e[i]+1;
			sum_w[i+1]=sum_w[i];
		}else{
			sum_e[i+1]=sum_e[i];
			sum_w[i+1]=sum_w[i]+1;
		}
	}

	int min=1e9;
	rep(i, n){
		int temp=sum_w[i]+sum_e[n]-sum_e[i+1];
		if(min>temp) min=temp;
	}
	cout<<min<<endl;
}


Measured memory_bytes: 3076
// https://beta.atcoder.jp/contests/abc114

#define SUBMIT

#include <bits/stdc++.h>
using namespace std;

int main() {
    string s;
    cin >> s;
    auto ans = INT_MAX;
    for (int i = 0; i < s.length() - 2; ++i) ans = min(ans, abs(753 - stoi(s.substr(i, 3))));
    cout << ans << endl;
    return 0;
}

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

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

  int ans = 0;
  int move = 0;
  for ( int i = 1; i < n; i++ ) {
    if ( h[i] <= h[i-1] ) {
      move++;
    } else {
      ans = max(ans, move);
      move = 0;
    }
  }
  ans = max(ans, move);

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


Measured memory_bytes: 3996
n, k = gets.split.map(&:to_i)
xy = n.times.map {gets.split.map(&:to_i)}.sort_by{|x,y| x}

ans = 10 ** 20
0.upto(n-k) do |i|
    (i+k-1).upto(n-1) do |j|
        a = xy[i..j].map{|x,y| y}.sort
        s = 0.upto(j - i + 1 - k).map do |w|
            a[w + k - 1] - a[w]
        end.min * (xy[j][0] - xy[i][0])
        ans = s if ans > s
    end
end

p ans

Measured memory_bytes: 14436
#include <bits/stdc++.h>
#define int long long int
#define MAX 1000007
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isPrime(int n)  
{  
    // Corner cases  
    if (n <= 1)  return false;  
    if (n <= 3)  return true;  
    
    // This is checked so that we can skip   
    // middle five numbers in below loop  
    if (n%2 == 0 || n%3 == 0) return false;  
    
    for (int i=5; i*i<=n; i=i+6)  
        if (n%i == 0 || n%(i+2) == 0)  
           return false;  
    
    return true;  
}  
  
// Function to return the smallest 
// prime number greater than N 
int nextPrime(int N) 
{ 
  
    // Base case 
    if (N <= 1) 
        return 2; 
  
    int prime = N; 
    bool found = false; 
  
    // Loop continuously until isPrime returns 
    // true for a number greater than n 
    while (!found) { 
  
        if (isPrime(prime)) { 
            found = true; 
            break;
        }
        else
        prime++;
    } 
  
    return prime; 
}
void solve() {
 	int n;
 	cin >> n;
 	cout << nextPrime(n);
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n,m;
    cin>>n>>m;
    if(n%2==1){
        int a=(n-1)/2;
        int b=a+1;
        rep(i,m){
            cout<<a<<" "<<b<<endl;
            a--;
            b++;
        }
        return 0;
    }
    else{
        int a=n/2-1;
        int b=a+1;
        rep(i,m){
            if((b-a)*2<n){
                cout<<a<<" "<<b<<endl;
            }
            else{
                cout<<a<<" "<<b+1<<endl;
            }
            a--;
            b++;
        }
        return 0;
    }
}


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

int main(void){
  int a,b,c,d;
  char str[100],*p;
  
  fgets(str,sizeof(str),stdin);
  p=strtok(str," \n");
  a=atoi(p);
  p=strtok(NULL," \n");
  b=atoi(p);
  p=strtok(NULL," \n");
  c=atoi(p);
  p=strtok(NULL," \n");
  d=atoi(p);
  
  if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d) ){
   printf("Yes\n"); 
  }else{
   printf("No\n"); 
  }
  
 return 0; 
}

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

using namespace std;

const int N = 3e5 + 5;

vector<pair<int, int> > v;

pair<int, int > h;

int a, b, c, x, y, n, cless;

long long sum;

int main()
{
	scanf("%d %d %d %d %d", &x, &y, &a, &b, &c);
	for(int i = 0 ; i < a; ++i)
	{
		scanf("%d", &h.first);
		h.second = 1;
		v.push_back({h.first, h.second});
	}
	for(int i = 0 ; i < b; ++i)
	{
		scanf("%d", &h.first);
		h.second = 2;
		v.push_back({h.first, h.second});
	}
	for(int i = 0 ; i < c; ++i)
	{
		scanf("%d", &h.first);
		h.second = 3;
		v.push_back({h.first, h.second});
	}
	sort(v.begin(), v.end());
	for(int i = v.size() - 1 ; i >= 0; --i)
	{
		if(cless - (x + y) == 0)	break;
		if(x < 1 && v[i].second == 1)	continue;
		else if(y < 1 && v[i].second == 2)	continue;
		sum += v[i].first;
		if(v[i].second == 1) --x;
		else if(v[i].second == 2) --y;
		else	++cless;
	}
	printf("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 6512
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k = sc.nextInt();
		int ans = -1;
		if(k % 7 == 0) {
			k /= 7;
		}
		int l = 9 * k;
		int ama = 10 % l;
		for(int i = 1; i < 10000000; i++) {
			if(ama == 1) {
				ans = i;
				break;
			}
			ama = (ama*10) % l;
			
		}
		System.out.println(ans);
	}
}



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

int main() {
  
  int A, B;
  cin >> A >> B;
  
  if ((A+B)%2==0) {
    cout << (A+B)/2 << endl;
  }
  else {
    cout << "IMPOSSIBLE" << endl;
  }
return 0;
}

Measured memory_bytes: 3644
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define owo(i,a, b) for(int i=(a);i<(b); ++i)
#define uwu(i,a, b) for(int i=(a)-1; i>=(b); --i)
#define senpai push_back
#define ttgl pair<int, int>
#define ayaya cout<<"ayaya~"<<endl
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<ttgl, null_type,less<ttgl>, rb_tree_tag,tree_order_statistics_node_update>*/
 
using ll = long long;
using ld = long double;
const ll MOD = 1000000007;
const ll root = 62;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll binpow(ll a,ll b){ll res=1;while(b){if(b&1)res=(res*a)%MOD;a=(a*a)%MOD;b>>=1;}return res;}
ll modInv(ll a){return binpow(a, MOD-2);}
const double PI = acos(-1);
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int NINF = 0xc0c0c0c0;
const ll INFLL = 0x3f3f3f3f3f3f3f3f;
const ll NINFLL = 0xc0c0c0c0c0c0c0c0;
const int mxN = 200001;
ll f[mxN];
ll psum[mxN];
ll arr[mxN];
ll n, x;
ll ans = INFLL;
int main() {
    //freopen("file.in", "r", stdin);
    //freopen("file.out", "w", stdout);
    mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
    cin.tie(0)->sync_with_stdio(0);
    cin>>n>>x;
    owo(i, 1, n+1) {
        cin>>arr[i];
    }
    f[0] = 5;
    f[1] = 5;
    owo(i, 2, mxN) {
        f[i] = f[i-1] + 2;
    }
    owo(i, 1, n+1) {
        psum[i] = psum[i-1] + arr[i];
    }
    owo(i, 1, n+1) {
        ll type;
        int cnt = 0;
        int lst = n;
        ll curr = i*x;
        for(int cnt = 0; lst>0; cnt++) {
            int nxt = max(lst-i, 0);
            ll add = (psum[lst]-psum[nxt])*f[cnt];
            if(__builtin_add_overflow(curr, add, &type)) curr = INFLL;
            else curr = curr+add;
            lst = nxt;
        }
        ans = min(ans, curr);
    }
    ans = ans  +  n*x;
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 8288