akhauriyash/Code-Regression huggingface dataset:
void main()
{
    long[] tmp = rdRow;
    long n = tmp[0], m = tmp[1], k = tmp[2];

    foreach (i; 0 .. n+1)
    {
        foreach (j; 0 .. m+1)
        {
            long s = i * m + j * n - 2 * i * j;
            if (s == k)
            {
                "Yes".writeln;
                return;
            }
        }
    }

    "No".writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
// 入力マクロ
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

use std::cmp::{max, min};

fn main() {
    input! {
        n: usize,
        h: [i64; n]
    }

    let mut dp = vec![std::i64::MAX; n];
    dp[0] = 0;
    dp[1] = (h[1] - h[0]).abs();
    for i in 2..n {
        dp[i] = min(
            dp[i - 2] + (h[i] - h[i - 2]).abs(),
            dp[i - 1] + (h[i] - h[i - 1]).abs(),
        );
    }

    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 6396
/**********************************************
 * author : deepak nayan
 * file   : e:/Solutions/atcoder/abc154_a.cpp
 * time   : Sat May  2 19:02:12 2020
 * quest  : A - Remaining Balls
 *********************************************/
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if (s == u) {
    cout << a - 1 << " " << b << "\n";
  }
  else {
    cout << a << " " << b - 1 << "\n";
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	int a,b,c;
	cin>>a>>b>>c;
	
	int ans=3;
	if(a==b){ans--;}
	if(b==c){ans--;}
  if(a==c&&!(b==c)){ans--;}
	ce(ans)
	
}

Measured memory_bytes: 256
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VRSORT(v) sort(v.begin(), v.end(),greater<long long>());
#define ALL(X) (X).begin(),(X).end()
#define INF 99999999
#define M_PI 3.14159265358979323846
#define MOD 1000000007

#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

#ifdef __LOCAL
    #include <filesystem>
    namespace fs = std::filesystem;
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 0};
int dy[]={0, 1, 0, -1, 0};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
const int NIL = -1;
static mt19937 _g(time(nullptr));
 
std::string pad(int num){ char buffer[4]; std::snprintf(buffer, sizeof(buffer), "%03d", num); return buffer;}
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) os << "[" << el.first << " " << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) os << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N,M;
map<int,vector<int>> DIG;

void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path p = __FILE__;
        fs::path input,output;
        input = output = p.parent_path();
        input += string("/input/") + string(p.stem()) + string(".txt");
        output += string("/output/") + string(p.stem()) + string(".txt");
        freopen(input.c_str(), "r", stdin);
        freopen(output.c_str(), "w", stdout);
    #endif
    cin >> N >> M;
    for (int i = 0; i < M; i++)
    {
      int x,y;
      cin >> x >> y;
      x--;
      y--;
      DIG[x].push_back(y);
    }
}

vector<int> memo;
int bfs(int s){
  if(memo[s]!=0) return memo[s];
  int ans=0;
  for(auto g:DIG[s]) ans = max(ans,bfs(g)+1);
  return memo[s] = ans;
}

int solve(){
  // vector<int> dp(N,0);
  memo.assign(N,0);
  int ans=0;
  for (int i = 0; i < N; i++)
  {
    ans = max(ans,bfs(i));
  }
  cout << ans << endl; 
  return 0;
}

// この問題DPで解けるん？？！？！？！
int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 14976
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
using namespace std;

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

typedef long long ll;

int c[3][3];
string ans;

int Min(int a, int b, int c, int d, int e) {
  int r = min(a, b);
  r = min(r, c);
  r = min(r, d);
  r = min(r, e);
  return r;
}

string Ans() {
  REP(a0, 101) {
    int b0 = c[0][0] - a0;
    int a1 = c[1][0] - b0;
    int b1 = c[0][1] - a0;
    int a2 = c[2][0] - b0;
    int b2 = c[0][2] - a0;
    if (Min(b0, a1, b1, a2, b2) < 0) { continue; }

    if (c[1][1] == a1+b1 && c[1][2] == a1+b2 && c[2][1] == a2+b1 && c[2][2] == a2+b2) {
      return "Yes";
    } else {
      continue;
    }
  }
  return "No";
}

int main() {
  REP(i, 3) { REP(j, 3) { cin >> c[i][j]; } }

  ans = Ans();

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


Measured memory_bytes: 256
import copy

def Many_Medians(n , xl):

    ans = []
    left = n // 2
    right = n // 2 - 1
    sort_xl = sorted(xl)

    for x in xl:
        if x < sort_xl[left]:
            ans.append(sort_xl[left])
        else:
            ans.append(sort_xl[right])

    return ans

def main():
    n = int(input())
    xl = list(map(int , input().split()))
    ans = Many_Medians(n, xl)
    for i in range(n):
        print(ans[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 100600
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_MOD			1000000007								// 除数(10の9乗+7)

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 和 - 取得
int
fGetModSum(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	int liSum = piVal1 + piVal2;
	if (liSum >= 0) {
		return liSum % D_MOD;
	}
	else {
		return liSum + D_MOD;
	}
}

// 積 - 取得
int
fGetModMulti(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	return (int)((long long)piVal1 * (long long)piVal2 % D_MOD);
}

// べき乗 - 取得
int
fGetModPower(
	int piBase					// <I> 基数
	, int piIdx					// <I> 指数
)
{
	// 基数
	if (piBase == 0) {
		return 0;
	}

	// 平方リスト - 作成
	int li1Val[100];
	li1Val[0] = piBase;
	int liCnt = 1;
	int liIdx = 1;
	while (piIdx > liIdx) {
		li1Val[liCnt] = fGetModMulti(li1Val[liCnt - 1], li1Val[liCnt - 1]);
		liCnt++;
		liIdx += liIdx;
	}

	// べき乗 - 取得
	int liVal = 1;
	while (piIdx > 0) {
		if (piIdx >= liIdx) {
			piIdx -= liIdx;
			liVal = fGetModMulti(liVal, li1Val[liCnt - 1]);
		}
		liCnt--;
		liIdx /= 2;
	}

	return liVal;
}

// 実行メイン
int
fMain(
)
{
	char lc1Buf[1024];

	// 配列数 - 取得
	int liN;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &liN);

	// 全パターン
	int liSum = fGetModPower(10, liN);

	// 0なし(9なし)
	int liCnt = fGetModPower(9, liN);
	liSum = fGetModSum(liSum, -liCnt);
	liSum = fGetModSum(liSum, -liCnt);

	// 0,9なし
	liCnt = fGetModPower(8, liN);
	liSum = fGetModSum(liSum, liCnt);

	return liSum;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

#define ll long long
#define N 100010
int n;
ll s[N];
int used[N];

int main() {
	while (scanf("%d", &n) != EOF) {
		for (int i = 0; i < n; ++i) {
			scanf("%lld", s + i);
		}
		memset(used, 0, sizeof used); 
		ll res = 0;
		for (int C = 1; C <= n; ++C) {
			ll tmp = 0; 
			for (int k = 1; 1ll * k * C < n; ++k) { 	
				int a = k * C;
				int b = n - 1 - k * C;
				int A = b, B = b - C;
				if (A <= 0 || B <= 0) break;
				if (a < 0 || a >= n || b < 0 || b >= n || a == b) break; 
				if (used[a] == C || used[b] == C) {
					break;
				}
				used[a] = C;
				used[b] = C;
				tmp += s[a];
				tmp += s[b];
				res = max(res, tmp);
			}
		}
		printf("%lld\n", res);
	}
	return 0;
}


Measured memory_bytes: 1408
from collections import deque
n = int(input())
v = {i:[] for i in range(n)}
for i in range(n):
    u = list(map(int, input().split()))
    for j in range(2, 2+u[1]):
        v[u[0]-1].append(u[j]-1)

global cnt1 
cnt1 = 0
visited = [False for _ in range(n)]
f = [0 for _ in range(n)]
l = [0 for _ in range(n)]
def DFS(now, visited):
    global cnt1
    cnt1 += 1
    f[now] = cnt1
    visited[now] = True
    for nv in v[now]:
        if visited[nv]:
            continue
        DFS(nv, visited)
    cnt1 += 1
    l[now] = cnt1

for value in range(n):
    if not visited[value]:
        DFS(value, visited)
    
for i in range(n):
    print(i+1, f[i], l[i])


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

int main()
{
	string s;
	cin >> s;
	vector<int> a(26);
	for(char c: s) a[c-'a']++;
	
	for(int i: a) {
		if(i % 2) {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}


Measured memory_bytes: 3604
n = int(input())
hort = [[0] * 9 for i in range(9)]
#hort[i][j] := i~j
for i in range(1, n + 1):
    temp = str(i)
    if temp[0] == '0' or temp[-1] == '0':continue 
    hort[int(temp[0]) - 1][int(temp[-1]) - 1] += 1

res = 0
for i in range(9):
    for j in range(9):
        if i != j:
            temp = hort[i][j] * hort[j][i] * 2
        else:
            temp = hort[i][j] * (hort[i][j] - 1) + hort[i][j]
            #print(temp, i, j)
        hort[i][j] = 0
        res += temp

print(res)

Measured memory_bytes: 9256
function Main(input) {
    input = input.split("\n");
    var line = input[0].split(" ");
    var num = parseInt(line[0]);
    var signals = [];
    signals[0] = 0;
    var ans = -1;
    for(var i = 0; i < num;i++){
        signals[i+1] = parseInt(input[i+1]);
    }
    var current = 1;
    var count = 1
    while(1){
        current = signals[current];
        if(current === 2){
            ans = count;
            break;
        }
        count++;
        if(count>100001){
            break;
        }
    }
//    console.dir(signals);
    console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

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

  ll ans = 1e18;
  for (ll i = 1; i * i <= n; i++)
  {
    if (n % i != 0)
    {
      continue;
    }
    ll j = n / i;
    ans = min(ans, i + j - 2);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> d[5];
    string str = "MARCH";
    rep(i, 0, n){
        string s;
        cin >> s;
        if(str.find(s[0]) != string::npos){
            int it = str.find(s[0]);
            d[it].push_back(s);
        }
    }
    int ans = 0;
    rep(i, 0, 5){
        rep(j, i + 1, 5){
            rep(k, j + 1, 5){
                ans += d[i].size() * d[j].size() * d[k].size();
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5748
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main(){
    ll n, X[5];
    cin >> n;
    REP(i,5) cin >> X[i];

    ll mi = 1e18;
    REP(i, 5) mi = min(mi, X[i]);
    if(n%mi==0) cout << (n/mi)-1+5 << endl;
    else cout << (n/mi+1)-1+5 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    int N; 
    ll T;
    cin >> N >> T;
    vel t(N); rep(i,N) cin >> t[i];

    ll time = T;
    rep(i,N-1) {
        if(t[i+1] - t[i] <= T) time += t[i+1] - t[i];
        else time += T;
    }
    cout << time << endl;
    return 0;
}

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



int main(){
	bool cards[4][13];
	for (int j = 0; j < 13; j++){
		for (int i = 0; i < 4; i++){
			cards[i][j] = false;
		}
	}
	int n;
	char a;
	int b;
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a >> b;
		switch (a)
		{
		case 'S':
			cards[0][b - 1] = true;
			break;
		case 'H':
			cards[1][b - 1] = true;
			break;
		case 'C':
			cards[2][b - 1] = true;
			break;
		case 'D':
			cards[3][b - 1] = true;
			break;
		default:
			break;
		}
	}

	for (int i = 0; i < 4; i++){
		for (int j = 0; j < 13; j++){
			if (cards[i][j] == false){
				switch (i)
				{
				case 0:
					cout << "S " << j + 1 << endl;
					break;
				case 1:
					cout << "H " << j + 1 << endl;
					break;
				case 2:
					cout << "C " << j + 1 << endl;
					break;
				case 3:
					cout << "D " << j + 1 << endl;
					break;
				default:
					break;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1160
int main() {     

int i, j = 0, seisu[10000], max = -10000000, min = 10000000, num;     

long int sum = 0;     

scanf("%d", &i);       

while(j != i)     

{         

scanf("%d", &seisu[j]);           

j++;     

}       

j = 0;       

for(j=0; j<i; j++)     

{         

num = seisu[j];           

if(max < num)         

{             

max = num;         

}                  

if(min > num)         

{             

min = num;         

}           

sum = sum + num;     

}       

printf("%d %d %ld\n", min, max, sum);       

return 0; 

}

Measured memory_bytes: 640
#include <stdio.h>

void output(int A[], int N) {
	int i;
	for ( i = 0; i < N; i++ ) {
		if (i > 0) printf(" ");
		printf("%d", A[i]);
	}
	printf("\n");
}

int InsertionSort(int A[], int N) {
	int i, j;
	int esc;
	
	for ( i = 1; i < N; i++ ) {
		j = i - 1;
		esc = A[i];
		
		while ( j >= 0 && A[j] > esc ) {
			A[j + 1] = A[j];
			j--;
		}
		
		A[j + 1] = esc;
		output(A, N);
	}
	
}

int main(void) {
	int N;
	int A[100];
	int i;
	
	scanf("%d", &N);
	
	for ( i = 0; i < N; i++ ) {
		scanf("%d", &A[i]);
	}

	output(A, N);
	InsertionSort(A, N);

	return 0;
}

Measured memory_bytes: 604
#include<stdio.h>
int gcd(int x,int y){
  	int r;
	while ((r = x % y) != 0) {
		x = y;
		y = r;
	}
	return y;
}
int main(){
  int n;
  scanf("%d",&n);
  int a[100000];
  for(int i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int ans=a[0];
  for(int i=0;i<n;i++){
    ans=gcd(ans,a[i]);
  }
  printf("%d",ans);
}

Measured memory_bytes: 512
// Problem : B - Magic 2
// Contest : AtCoder - M-SOLUTIONS Programming Contest 2020
// URL : https://atcoder.jp/contests/m-solutions2020/tasks/m_solutions2020_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// Delete the dynamically allocated memory

#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define pr              pair<long long,long long>
#define mp(a,b)         make_pair(a,b)
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define fill(a,b)       memset(a, b, sizeof(a))
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)
ll power(ll base, ll exp) {
    ll res=1;
    while(exp>0) {
       if(exp%2==1) res=(res*base);
       base=(base*base);
       exp/=2;
    }
    return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	ll cnt=0;
	while(b<=a){
		b=2*b;
		cnt++;
	}
	while(c<=b){
		c=2*c;
		cnt++;
	}
	if(cnt<=k){
		cout<<"Yes"<<"\n";
	}else{
		cout<<"No"<<"\n";
	}
	return 0;
	}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

  
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<pii>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define re(n) for (int i = 0; i < n; ++i)
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define eb emplace_back

//OutPut
#define ps(x) cout << x << endl;
#define ps_end(x) {ps(x); return;}


const int md = 998244353; //998244353 ;
const int dir[4][2] = {{-1,0}, {1, 0}, {0, -1}, {0, 1}};
template<class T> bool ckmin(T& a, const T& b) { 
  return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
  return a < b ? a = b, 1 : 0; }
ll pw(auto x, auto y) {  ll s = 1; while(y) { if (y & 1) s = s * x % md; x= 1LL * x * x % md; y /= 2; } return s;}

const int maxn = 1e6 + 10;

int n, m, nq, nk;
string str;

void task() {
  cin >> n;
  cin >> nk;
  vi l(nk), r(nk);
  vector<long long> sum(nk);
  re(nk) cin >> l[i] >> r[i];
  vector<ll>  dp(n + 1);
  dp[1] = 1;
  for (int i = 2; i <= n; ++i) {
    for (int j = 0; j < nk; ++j) {
      if (i - l[j] >= 1) sum[j] += dp[i - l[j]], sum[j] %= md;
      if (i - r[j] - 1 >= 1) sum[j] -= dp[i - r[j] - 1], sum[j] %= md;
    }
    for (int j = 0; j < nk; ++j) {
      dp[i] += sum[j];
      dp[i] %= md;
    }
  } 
  dp[n] = (dp[n] %md + md) % md;
  cout << dp[n] << endl;
  //Read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  int T = 1;
 // cin >> T;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
  * write down
*/


Measured memory_bytes: 4808
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define loop(i,n) for(int i = 0 ; i < n; i++)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
 
int main() {
  
  FAST;

  int n,a,b,c;
  cin >> n;

  int dp[3][n];

  cin >> a >> b >> c;
  dp[0][0] = a;
  dp[1][0] = b;
  dp[2][0] = c;


  for(int i=1;i<n;++i) {
    cin >> a >> b >> c;
    dp[0][i] = max(dp[1][i-1],dp[2][i-1]) + a;
    dp[1][i] = max(dp[0][i-1],dp[2][i-1]) + b;
    dp[2][i] = max(dp[0][i-1],dp[1][i-1]) + c;
  }
  cout << max(max(dp[0][n-1],dp[1][n-1]),dp[2][n-1]) << endl;
  return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
string k;
ll n,d;
const ll mod=1e9+7;
ll memo[100001][2][101];
ll go(ll pos,ll par,ll val){
    if(pos==n){
        if(val%d==0) return 1;
        return 0;
    }
    if(memo[pos][par][val]!=-1) return memo[pos][par][val];
    ll ans=0;
    if(par==0){
        for(ll i=0;i<10;i++){
            ans+=go(pos+1,par,(val+i)%d);
            ans%=mod;
        }
    }
    else{
        ans+=go(pos+1,par,(val+k[pos]-'0'+d)%d);
        ans%=mod;
        for(ll i=0;i<k[pos]-'0';i++){
            ans+=go(pos+1,0,(val+i)%d);
            ans%=mod;
        }
    }
    return memo[pos][par][val]=ans;
}

int main(){

    cin>>k>>d;
    memset(memo,-1,sizeof(memo));
    n=k.size();
    ll ans=(go(0,1,0)-1+mod)%mod;
    cout<<ans;

}

Measured memory_bytes: 158848
import java.util.Scanner;
 
public class Main{
    public static void main(String[] args){
        Scanner s = new Scanner(System.in);
        int h,w,i,j;
        while(true){
            h = s.nextInt();
            w = s.nextInt();
            if(h==0&&w==0)break;
            for(i=1;i<=h;i++){
                for(j=1;j<=w;j++){
                    if(i==1||i==h||j==1||j==w)System.out.print("#");
                    else System.out.print(".");
                }
                System.out.println();
        }
        System.out.println();
    }
    }
}


Measured memory_bytes: 33544
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
	ll x,d;
}a[200005];
const ll mod=998244353;
ll tree[1000000];
bool cmp(struct node a1,struct node a2)
{
	return a1.x<a2.x;
}
void build(ll k,ll l,ll r,ll wei,ll val)
{
	ll m=(l+r)/2;
	if(l==wei&&wei==r)
	{
		tree[k]=val;
	}
	else if(l<=wei&&wei<=r)
	{
		build(k*2+1,l,m,wei,val);
		build(k*2+2,m+1,r,wei,val);
		tree[k]=max(tree[k*2+1],tree[k*2+2]);
	}
}
ll cal(ll k,ll l,ll r,ll l1,ll r1)
{
	ll m=(l+r)/2;
	if(l1<=l&&r<=r1)
	{
		return tree[k];
	}
	else if(r<l1||r1<l)
	{
		return -10000000000;
	}
	else
	{
		return max(cal(k*2+1,l,m,l1,r1),cal(k*2+2,m+1,r,l1,r1));
	}
}
ll bi(ll l,ll r,ll val)
{	
	ll m=(l+r)/2;
	if(l==r)
	{
		return m;
	}
	else if(a[m].x>=val)
	{
		return bi(l,m,val);
	}
	else
	{
		return bi(m+1,r,val);
	}
}
ll cov[200005]={0};
ll dp[200005]={0};
int main(void)
{
	ll n;
	scanf("%lld",&n);
	for(ll i=0;i<=n*4;i++)
	{
		tree[i]=-1000000000;
	}
	for(ll i=0;i<n;i++)
	{
		scanf("%lld%lld",&a[i].x,&a[i].d);
	}
	sort(a,a+n,cmp);
	build(0,0,n-1,n-1,n-1);
	for(ll i=n-2;i>=0;i--)
	{
		ll wei=bi(0,n-1,a[i].x+a[i].d);
		if(a[wei].x>=a[i].x+a[i].d)
		{
			wei--;
		}
		if(wei==i)
		{
			build(0,0,n-1,i,i);
		}
		else
		{
			ll wei2=cal(0,0,n-1,i+1,wei);
			build(0,0,n-1,i,wei2);
		}
	}
	for(ll i=0;i<n;i++)
	{
		cov[i]=cal(0,0,n-1,i,i);
	}
	dp[n-1]=2;
	for(ll i=n-2;i>=0;i--)
	{
		if(cov[i]==n-1)
		{
			dp[i]=dp[i+1]+1;
			dp[i]%=mod;
		}
		else
		{
			dp[i]=dp[i+1]+dp[cov[i]+1];
			dp[i]%=mod;
		}
	}
	printf("%lld",dp[0]);
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    vector<int> b(n);
    rep(i,n+1) cin >> a.at(i);
    rep(i,n) cin >> b.at(i);
    ll total = 0;
    rep(i,n+1) total += a.at(i);
    rep(i,n){
        if(a.at(i) >= b.at(i)){
            a.at(i) -= b.at(i);
            b.at(i) = 0;
        }else{
            b.at(i) -= a.at(i);
            a.at(i) = 0;
            a.at(i+1) = max(a.at(i+1) - b.at(i),0);
        }
    }
    ll remain = 0;
    rep(i,n+1) remain += a.at(i);
    cout << total - remain << endl;
}

Measured memory_bytes: 4060
import sys
sys.setrecursionlimit(100000)

N,M=map(int,input().split())
edges=[[] for _ in range(N)]
for _ in range(M):
    A,B=map(int,input().split())
    edges[A-1].append(B-1)
    edges[B-1].append(A-1)

visited=[False]*N
path=[]

def dfs(curr):
    visited[curr] = True
    path.append(curr)
    for dst in edges[curr]:
        if not visited[dst]:
            dfs(dst)
            return

dfs(0)
path=path[1:][::-1]
dfs(0)

print(len(path))
print(" ".join([str(v+1) for v in path]))


Measured memory_bytes: 134816
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    
    String ss = sc.next();
    int count = 0;
    
    for (int i = 0; i <= 2; i++) {
      if (ss.charAt(i) == '1') {
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 35588
def main():

    N = str(input())
    #print(N[-1])

    if N[-1] == "2" or N[-1] == "4" or N[-1] == "5" or N[-1] == "7" or N[-1] == "9" :
        print("hon")
    elif N[-1] == "0" or N[-1] == "1" or N[-1] == "6" or N[-1] == "8" :
        print("pon")
    else :
        print("bon")



if __name__ == '__main__':
    main()


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

int func(int n,int*a,int*b,int *c)
{
    int dp[3][n];
    dp[0][0]=a[0] , dp[1][0]=b[0] , dp[2][0]=c[0];

    for(int i=1;i<n;i++)
    {
        dp[0][i] = max(dp[1][i-1],dp[2][i-1])+a[i];
        dp[1][i] = max(dp[0][i-1],dp[2][i-1])+b[i];
        dp[2][i] = max(dp[0][i-1],dp[1][i-1])+c[i];
    }
    return max(dp[0][n-1],max(dp[1][n-1],dp[2][n-1]));
}

int main() {
    int n; cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
    cout<<func(n,a,b,c);
}


Measured memory_bytes: 5472
#include<bits/stdc++.h>
using namespace std;
int main(){
 int a,b,c;
 cin>>a>>b>>c;
 int count=0;
 if(a==b&&b==c&&a==c&&a%2==0&&b%2==0&&c%2==0) cout<<-1<<endl;
 else {
 while(a%2==0&&b%2==0&&c%2==0){
   int m=a,n=b;
   a=b/2+c/2;
   b=m/2+c/2;
   c=m/2+n/2;
   count++;
 }
 cout<<count<<endl;
 }
}

Measured memory_bytes: 3672
#include <iostream>
#include <cctype>
#include <string>
using namespace std;
int main(void){
    // Here your code !
 
   string s;
   getline(cin,s);
    for(int i=0;s[i];i++){
    if(isupper(s[i]))
       s[i]=tolower(s[i]);
    else if(islower(s[i]))
       s[i]=toupper(s[i]);
}

cout<<s<<endl;
return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
#define Imax 1e9+5
#define LLmax 1e18
#define Imin -1e9-5
#define LLmin -1e18
string day [] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
vector <string> v;
bool sortByFirst(const pair<int,int>&a,const pair<int,int>&b){
    return a.first>b.first;
}
void dfs (string str, string t = "", int cnt = 0) {
    if (cnt == 2) {
        v.push_back (t);
        return;
    } else {
        for (int i = 0; i <str.size (); i ++) {
            dfs (str, t + str [i], cnt + 1);
        }
    }
}
int main () {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    while(cin>>n){
        for(int i=1;i<=9;i++){
            if(n%i==0 && (n/i)<=9){
                cout<<"Yes"<<endl;
                exit(0);
            }
        }
    cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
input_list = list(map(int,input().split()))
l = input_list[0]
r = input_list[1]
if r-l >= 2018:
    r = 2018
    l = 0
    ans = 2019
    for i in range(l, r + 1):
        for j in range(i + 1, r + 1):
            temp = (i * j) % 2019
            if temp < ans:
                ans = temp
    print(ans)
else:
    if l%2019 < r%2019: # またがないパターン
        l = l%2019
        r = r%2019
        ans = 2019
        for i in range(l,r+1):
            for j in range(i+1,r+1):
                temp = (i * j)%2019
                if temp < ans:
                    ans = temp
        print(ans)
    else:
        print(0)

Measured memory_bytes: 40780
def count(m):
    return len(list(filter(lambda x: x >= m-1, e)))


N = int(input())
# N!の素因数分解を行う
e = [0] * (N+1)  # 0~Nを何個ずつ素因数としてもつかのテーブル

for i in range(2, N+1):
    cur = i
    for j in range(2, i+1):
        while cur % j == 0:
            e[j] += 1
            cur //= j

ans = 0
ans += count(75)
ans += count(25) * (count(3) - 1)
ans += count(15) * (count(5) - 1)
ans += (count(5) * (count(5)-1) * (count(3) - 2)) // 2
print(ans)


Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
#define PI 3.14159265
int main(void){
    int a,b,c;
    double S, L, h;
   scanf("%d %d %d", &a, &b, &c);
   S = 0.5*a*b*sin(c*PI/180);
   L = a + b + sqrt(a*a + b*b - 2*a*b*cos(c*PI/180));
   h = (2*S)/a;
   printf("%lf\n", S);
   printf("%lf\n", L);
   printf("%lf\n", h);
   return 0;
   
}



Measured memory_bytes: 2044
import java.util.Scanner

object Main {
  def main(args: Array[String]) {
    val result = solve(new Scanner(System.in))
    if (result.length > 0) println(result)
  }

  def solve(in: String): String = solve(new Scanner(in))

  def solve(sc: Scanner): String = {
    val b = sc.next

    if (b == "A") "T"
    else if (b == "C") "G"
    else if (b == "G") "C" else "A"
  }
}


Measured memory_bytes: 25912
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt(),b=stdIn.nextInt(),c=stdIn.nextInt(),d=stdIn.nextInt(),e,f,g;
		if(b>a) e=b-a;
		else e=a-b;
		if(c>b) f=c-b;
		else f=b-c;
		if(c>a) g=c-a;
		else g=a-c;
		System.out.print(e<=d&&f<=d||g<=d?"Yes":"No");
	}
}

Measured memory_bytes: 22100
#include<iostream>
#include<string>
#include<algorithm> 
using namespace std;
int main(){
  int a,b,c,x,sum=0;
  cin>>a>>b>>c>>x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k == x) sum++;
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using ll = long long;
using P = pair<int, int>;
using MATRIX = vector< vector<ll> >;

int main() {
  int N;
  int a[100000];
  cin >> N;
  rep(i, N) {
    cin >> a[i];
  }
  sort(a, a+N);
  int ans = a[(N+1) / 2] - a[(N-1) / 2];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4012
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);

void solve(){
    string s; cin >> s;
    int cnt = 0;
    vector<int> a(s.size(), 0);
    REP(i, s.size()-1){
        if(s[i] == 'R') cnt++;
        if(s[i] == 'R' && s[i+1] != 'R'){
            a[i] = cnt;
            cnt = 0;
        }
    }
    for(int i=s.size()-1; i>=1; i--){
        if(s[i] == 'L') cnt++;
        if(s[i] == 'L' && s[i-1] != 'L'){
            a[i] = cnt;
            cnt = 0;
        }
    }

    REP(i, s.size()){
        if(s[i] == 'R' && s[i+1] == 'L'){
            int R = a[i], L = a[i+1];
            a[i] = ceil(R/2.0) + floor(L/2.0);
            a[i+1] = floor(R/2.0) + ceil(L/2.0);
        }
    }

    REP(i, s.size()){
        cout << a[i];
        if(i != s.size()-1){
            cout << " ";
        }
        else{
            cout << endl;
        }
    }
}

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

Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
#define int int64_t
int f(int b,int n){
  if(n<b){
    return n;
  }else{
    return f(b,n/b)+n%b;
  }
}
main(){
  int n,s;
  cin>>n>>s;
  if(s==n){
    cout<<(n+1)<<endl;
    return 0;
  }
  {
    vector<int>xs;
    for(int b=2;b<=sqrt(n);++b){
      if(f(b,n)==s){
        xs.push_back(b);
      }
    }
    if(xs.size()>=1){
      cout<<*min_element(xs.begin(),xs.end())<<endl;
      return 0;
    }
  }
  if(n<s){
    cout<<-1<<endl;
    return 0;
  }
  {
    vector<int>xs;
    for(int p=1;p<sqrt(n);++p){
      if((n-s)%p)continue;
      const int b=(n-s)/p+1;
      if(f(b,n)==s){
        xs.push_back(b);
      }
    }
    if(xs.size()>=1){
      cout<<*min_element(xs.begin(),xs.end())<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> v2l;
typedef vector<bool> vb;
typedef vector<vb> v2b;

const ll AMAX = 1e13;

int dfs(vi e[], int a[], int x, int p, v2l &dp1, v2b &dp2) {
    int sz = 1;
    dp1[x] = {a[x]};
    dp2[x] = {a[x] > 0};

    for (int y : e[x]) {
        if (y == p) {
            continue;
        }

        int ysz = dfs(e, a, y, x, dp1, dp2);
        dp1[x].resize(sz + ysz, AMAX);
        dp2[x].resize(sz + ysz, false);

        for (int i = sz - 1; i >= 0; i--) {
            for (int j = ysz - 1; j >= 0; j--) {
                if (j > 0) {
                    dp1[x][i+j] = min(dp1[x][i+j], dp1[x][i] + dp1[y][j]);
                    dp2[x][i+j] = dp2[x][i+j] || dp2[x][i] && dp2[y][j];
                }
                if (dp1[y][j] < 0 || dp2[y][j]) {
                    dp1[x][i+j+1] = min(dp1[x][i+j+1], dp1[x][i]);
                    dp2[x][i+j+1] = dp2[x][i+j+1] || dp2[x][i];
                }
            }
            dp1[x][i] = min(AMAX, dp1[x][i] + dp1[y][0]);
            dp2[x][i] = dp2[x][i] && dp2[y][0];
        }

        sz += ysz;
    }

    return sz;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vi e[n];
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        cin >> u >> v;
        u--, v--;
        e[u].push_back(v);
        e[v].push_back(u);
    }

    v2l dp1(n);
    v2b dp2(n);
    dfs(e, a, 0, -1, dp1, dp2);

    for (int i = 0; i < n; i++) {
        if (dp1[0][i] < 0 || dp2[0][i]) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 84608
import math

A, B, H, M = map(int, input().split())

harg = (math.pi * 2 / 12) * (H + M / 60.)
marg = (math.pi * 2 / 60) * M

hx = A * math.cos(harg)
hy = A * math.sin(harg)

mx = B * math.cos(marg)
my = B * math.sin(marg)

print(math.sqrt((hx - mx) ** 2 + (hy - my) ** 2))


Measured memory_bytes: 62560
from collections import Counter
s = input()
n = len(s)
count = dict(Counter(s))
flag = False

if n ==1:
    flag = True
elif n <= 3:
    if max(count.values())!=2:
        flag = True
elif n==4:
    if max(count.values())<=2:
        flag = True
else:
    if "a" in count:
        if "b" in count:
            if "c" in count:
                if count["a"]==count["b"] or count["b"]==count["c"] or count["c"]==count["a"]:
                    dev = max(count.values())-min(count.values())
                    if dev <= 1:
                        flag = True
            
            
print('YES' if flag==True else 'NO')

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

ll solve() {
    ll N, K;
    cin >> N >> K;
    vector<int> P(N);
    vector<ll> C(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> P[i];
        P[i]--;
    }
    for ( int i = 0; i < N; i++ ) cin >> C[i];

    vector<int> gp(N,-1);
    vector<vector<ll>> cc;
    int i = 0;
    for ( int j = 0; j < N; j++ ) {
        if ( gp[j] >= 0 ) continue;
        cc.push_back(vector<ll>());
        int cur = j;
        ll cs = 0;
        cc[i].push_back(cs);
        while ( gp[cur] < 0 ) {
            gp[cur] = i;
            cur = P[cur];
            cs += C[cur];
            cc[i].push_back(cs);
        }
        i++;
    }
    vector<ll> sz(cc.size()), bk(cc.size());
    for ( int i = 0; i < cc.size(); i++ ) {
        sz[i] = cc[i].size() - 1;
        bk[i] = cc[i].back();
        for ( int j = 1; j <= sz[i]; j++ ) {
            cc[i].push_back(bk[i] + cc[i][j]);
        }
    }
    ll ans = -1e10;
    for ( int i = 0; i < cc.size(); i++ ) {
        ll k = K;
        ll kd = k % sz[i], kc = k / sz[i];
        if ( kc > 0 ) {
            ll tm = -1e10;
            for ( int j = 0; j < sz[i]; j++ ) {
                for ( int h = kd+1; h <= sz[i]; h++ ) {
                    ll t = cc[i][j+h] - cc[i][j];
                    tm = max(tm, t);
                }
            }
            if ( bk[i] > 0 ) {
                ans = max(ans, tm + (kc-1)*bk[i]);
            } else {
                ans = max(ans, tm);
            }
        }
        {
            ll tm = -1e10;
            for ( int j = 0; j < sz[i]; j++ ) {
                for ( int h = 1; h <= kd; h++ ) {
                    ll t = cc[i][j+h] - cc[i][j];
                    tm = max(tm, t);
                }
            }
            if ( bk[i] > 0 ) {
                ans = max(ans, tm + kc*bk[i]);
            } else {
                ans = max(ans, tm);
            }
        }
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

int main()
{
  int n;
  cin>>n;
  vector<int>a(n);
  int  count=0,ans=0;
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
    if(i==0)continue;
    if(a[i]<=a[i-1])
    {
      count++;
      ans=max(ans,count);
    }
    else 
    {
      count=0;
    }
  }
  cout<<ans<<endl;
  
  return 0;
}
  

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

int main() {
    int a,b;
    cin >> a >> b;
    if (a<=b) {
        for (int i=0; i<b; i++) {
            cout << a;
        }
        cout << endl;
    }
    else {
        for (int i=0; i<a; i++) {
            cout << b;
        }
        cout << endl;
    }
}

Measured memory_bytes: 3504
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

#define rep(i, o) for (int i = 0; i < (o); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define NUM 1e5

typedef long long ll;
typedef unsigned long long ull;

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

const ll MOD = 1000000007;

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

    set<ll> a;
    map<int, int> a_b;
    rep(i, n) {
        int c, b; cin >> c >> b;
        a.insert(c);
        a_b[c] += b; 
    }

    ll sum = 0; ll ans = 0; auto itr = a.begin();
    do {
        sum += a_b[*itr];
        ans = *itr; itr++;
    }
    while (k > sum);

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

Measured memory_bytes: 9392
#include <stdio.h>
int main(void)
{
    int a, b, ans=0;
    scanf("%d%d", &a, &b);

    for(int i=0;i<2;i++){
        if(a>b){
            ans=ans+a;
            a--;
        }
        else{
            ans=ans+b;
            b--;
        }
    }

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

    return 0;
}


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

using namespace std;

int main (void) {
    int N, M;
    cin >> N >> M;
    /* 各スイッチが繋がっている電球を示すビット列 */
    vector<int> sw(N, 0);
    int k, s;
    for ( int bulb=0; bulb<M; bulb++ ) {
        cin >> k;
        for ( int i=0; i<k; i++ ) {
            cin >> s;
            s--;    /* 0 index に */
            sw[s] |= (1 << bulb);
        }
    }
    /* p のビットが 1 のとき奇数個のスイッチが押されたらその電球が ON */
    int p = 0, tmp_p;
    for ( int bulb=0; bulb<M; bulb++ ) {
        cin >> tmp_p;
        p |= (tmp_p << bulb);
    }

    /* すべてのスイッチのパターンを網羅 */
    int ans = 0;
    int bulb_st;
    for ( int sw_st=0; sw_st<(1<<N); sw_st++ ) {
        bulb_st = 0;
        for ( int i=0; i<N; i++ ) {
            /* スイッチが ON の状態ならそのスイッチが繋がっている電球の状態を反転させる */
            if ( sw_st & (1 << i) ) {
                bulb_st ^= sw[i];
            }
        }
        if ( bulb_st == p )
            ans++;
    }

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


Measured memory_bytes: 256
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *					# alpha = ascii_lowercase
from random import *
from sys import stdin
from itertools import *
from collections import Counter			# z = dict(Counter(l))

def maxHappiness(A,B,C,n):
	dp = [0,0,0]
	for i in range(3):
		dp[i] = [0]*n
	dp[0][0] = A[0]
	dp[1][0] = B[0]
	dp[2][0] = C[0]
	for i in range(1,n):
		dp[0][i] = A[i] + max(dp[1][i-1], dp[2][i-1])
		dp[1][i] = B[i] + max(dp[2][i-1], dp[0][i-1])
		dp[2][i] = C[i] + max(dp[0][i-1], dp[1][i-1])
	ans = max(dp[0][-1],dp[1][-1],dp[2][-1])
	return ans


A,B,C = [],[],[]
T = int(input())
for _ in range(T):
	a,b,c = list(map(int, stdin.readline().rstrip().split()))
	A.append(a)
	B.append(b)
	C.append(c)

ans = maxHappiness(A,B,C,T)
print(ans)

Measured memory_bytes: 27936
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <climits>
#include <cstdio>
#include <iomanip>
#include <utility>
#include <unordered_map>

using namespace std;
typedef long long int ll;

#define SP(x) setprecision((int)x)
#define ALL(v) v.begin(),v.end()

int main(int argc, char const *argv[])
{
    ll n;
    cin >> n;
    vector<ll> v(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    ll ans = 0;
    for (ll i = 0; i < n - 1; i++)
    {
        if (v[i] == i + 1)
        {
            ll temp = v[i];
            v[i] = v[i + 1];
            v[i + 1] = temp;
            ans++;
        }
    }
    if (v[n - 1] == n)
    {
        ll temp = v[n - 1];
        v[n - 1] = v[n - 2];
        v[n - 2] = temp;
        ans++;
    }
    cout << ans << endl;
}


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

#define ll long long
#define pb push_back
#define fi first
#define se second

/** Dateloper */

using namespace std;

const int mod = 1e9+7;
const int maxn = 1000 * 1000 + 10;

int main()
{
    ll k,x;
    cin>>k>>x;
    if(k*500>=x)
        cout<<"Yes";
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 256