akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int(i)=0;i<(n);i++)
#define MAX_N 200001
int par[MAX_N]; //親
int rnk[MAX_N]; //木の深さ
int siz[MAX_N]; //木の深さ
int ans=0;

//n要素で初期化
void init(int n){
    REP(i,n){
        par[i]=i;
        rnk[i]=0;
        siz[i]=1;
    }
}

//木の根を求める
int find(int x){
    if(par[x]==x){
        return x;
    }else{
        return par[x]=find(par[x]);
    }
}

//xとyの属する集合を併合
void unite(int x,int y){
    x=find(x);
    y=find(y);
    if(x==y) return;

    if(rnk[x]<rnk[y]){
        par[x]=y;
        siz[y]+=siz[x];
        ans=max(ans,siz[y]);
    }else{
        par[y]=x;
        siz[x]+=siz[y];
        if(rnk[x]==rnk[y]) rnk[x]++;
        ans=max(ans,siz[x]);
    }
}

//xとyが同じ集合に属するか否か
bool same(int x, int y){
    return find(x)==find(y);
}

int main(){
  int n,m;cin>>n>>m;
  if(!m){
    cout<<1;
    return 0;
  }
  init(n);
  REP(i,m){
    int a,b;cin>>a>>b;
    unite(a,b);
  }

  cout<<ans;
}

Measured memory_bytes: 5936
import sys
import itertools
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N,M,Q = map(int, readline().split())
A = np.array(list(itertools.combinations_with_replacement(range(1,M+1), N)))

score = np.zeros(len(A), int)
m = map(int, read().split())
for a,b,c,d in zip(m,m,m,m):
    score += (A[:,b-1] - A[:,a-1] == c) * d
print(score.max())

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

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

using namespace std;

const int MOD = 100000;
int dp[2][(1<<20)],H,W;
bool CONTINUE[1<<20];
char G[20][20];
/*
dp[(x,y) & 1][column][Is the left is J?] := the number % 10^5
 */

inline void compute(int other){

  dp[0][0] = 1;

  rep(y,H)rep(x,W) {
    int phase = ( x + y * W ) & 1;
    rep(i,(1<<W)) dp[!phase][i] = 0;
    rep(bitmask,(1<<W)){     

      int nbitmask = bitmask;

      if( G[y][x] == 'O' ) goto O;
      if( G[y][x] == 'I' ) goto I;

      // put J
      if( x-1 >= 0 ) nbitmask &= ~(1<<(x-1));
      if( x+1 != W ) nbitmask |= (1<<x);
      ( dp[!phase][nbitmask] += ( dp[phase][bitmask] ) ) %= MOD;
      if( G[y][x] == 'J' ) goto Skip;

    O:;
      // put O
      nbitmask = bitmask;
      nbitmask &= ~(1<<x);
      ( dp[!phase][nbitmask] += dp[phase][bitmask] ) %= MOD;
      if( G[y][x] == 'O' ) goto Skip;

    I:;
      // put I
      nbitmask = bitmask;
      nbitmask &= ~(1<<x);
      if( x-1 >= 0 ) nbitmask &= ~(1<<(x-1));
      if( !( ( bitmask>>x ) & 1 ) ) {
        ( dp[!phase][nbitmask] += dp[phase][bitmask] ) %= MOD;
      }
      
    Skip:;
      
    }
  }

  int sum = 0;
  rep(i,(1<<W)) ( sum += dp[(H*W)&1][i] ) %= MOD;

  int total = 1;
  rep(i,other) ( total *= 3 ) %= MOD;
  cout << ( total - sum + MOD ) % MOD << endl;
}

int main(){

  scanf("%d %d",&H,&W);
  int other = 0;
  rep(i,H)rep(j,W){
    cin >> G[i][j];
    other += (G[i][j]=='?');
  }
  compute(other);
  return 0;
}

Measured memory_bytes: 9420
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
using ll = int64_t;
using ull = uint64_t;
using ld = long double;
using uint = uint32_t;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/

signed main() {
	EmiliaMyWife

	ll ans = 0;
	int n;
	cin >> n;
	for(int i = 0, a, mx = 0; i < n; i++) {
		cin >> a;
		if(mx)
			ans += max(0, mx - a);
		mx = max(mx, a);
	}
	cout << ans << '\n';

	return 0;
}


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

int main() {
  int n;
  cin >> n;
  
  vector<int> d(n);
  for (int i = 0; i < n; i++) {
    cin >> d.at(i);
  }
  
  sort(d.begin(), d.end());
  
  int x = 0, a = 0;
  
  for (int i = 0; i < n; i++) {
    if (d.at(i) > x) {
      x = d.at(i);
      a++;
    }
  }
  
  cout << a << endl;
}


Measured memory_bytes: 256
let partition a p r =
  let x = a.(r) in
  let swap i j = let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
  in
  let rec doit i j =
    if j >= r then i
    else begin
      if a.(j) <= x then (swap (i + 1) j; doit (i + 1) (j + 1))
      else doit i (j + 1)
    end
  in
  let i = doit (p - 1) p in
  swap (i + 1) r;
  i + 1

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%d " (fun e -> e)) in
  let k = partition a 0 (n - 1) in
  Array.iteri (fun i e ->
    Printf.printf (if i = 0 then "%d" else if i = k then " [%d]" else " %d") e) a;
  print_newline ()

Measured memory_bytes: 5260
a,b,c = gets.chomp.split.map(&:to_i)

smaller = c - a - b <= 0 ? true : false
if smaller
  puts 'No'
  exit
end

if 4 * a * b < (c - a - b) * (c - a - b)
  puts 'Yes'
else
  puts 'No'
end



Measured memory_bytes: 1916
#include <bits/stdc++.h>
// #include "ane.cpp"

const int INF  = 1e9;
const long long INFLL = 1e18;
const int NMAX = 100005;
const int MMAX = 100005;
const int KMAX = 1005;
const int MOD  = 1e9 + 7;
using namespace std;

// comment to disable debug functions
#define DEBUG

// frequently used macros

#if __cplusplus >= 201103L
#define ALL(v) begin(v),end(v)
#define SORT(v) sort(begin(v), end(v))
#define FIND(v,x) find(begin(v), end(v), (x))
#else
#define ALL(v) (v).begin(),(v).end()
#define SORT(v) sort(v.begin(), v.end())
#define FIND(v,x) find(v.begin(), v.end(), (x))
#endif

#define MEMNEXT(from, to) do{ memmove((to), (from), sizeof(from)); \
memset((from), 0, sizeof(from)); } while(0)
#ifdef DEBUG
#define DUMP(x) do{ std::cerr << (#x) << ": " << x << std::endl; }while(0)
#else
#define DUMP(x) do{}while(0)
#endif

// frequent used aliases
typedef long long ll;
typedef pair<int, int> p;
typedef pair<ll, int> lp;
typedef pair<ll, ll> llp;
typedef vector<int> vec;
typedef vector<ll> vecll;
typedef vector<vec> mat;
typedef vector<vecll> matll;

// frequently used constants
static const int di[] = {-1, 0, 1, -1, 1, -1, 0, 1};
static const int dj[] = {-1, -1, -1, 0, 0, 1, 1, 1};

// frequently used structs
struct edge{
  int to,cost;
};

// printf for debug
#ifndef DEBUG
void debug(const char* format, ...){}
#else
void debug(const char* format, ...){
  va_list arg;
  va_start(arg, format);
  vprintf(format, arg);
  va_end(arg);
}
#endif

// dump vector
#ifdef DEBUG
#define DUMPV(v, c) do{       \
  printf("%s: ", #v);         \
  for (int i = 0; i < (c); ++i) \
  {                           \
  cout << (v)[i] << " ";      \
  }                           \
  cout << endl;               \
} while(0)
#else
#define DUMPV(v,c)
#endif

// std::fill of multi dimensions
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
  std::fill( (T*)array, (T*)(array+N), val );
}

// binary search
ll BSearch(ll _begin, ll _end, bool (*f)(int)){
  ll mid;
  while(_end - _begin > 1LL) {
  mid = (_begin + _end) / 2LL;
  if(f(mid)) {
    debug("BSearch: f(%d) == true\n", mid);
    _end = mid;
  }
  else
  {
    debug("BSearch: f(%d) == false\n", mid);
    _begin = mid;
  }
  }
  return _end;
}


ll N,M,K,A,B,C,D,E;
int dp[NMAX] = {};

string S;
vec v;

ll ans = {};

void solve(){
  // main algorithm
  ans = ((1900 * M) + 100 * (N - M)) * pow(2, M);
}
void debug(){
  // output debug information

}
void answer(){
  // output answer
  cout << ans << endl;
}
int main(int argc, char const *argv[])
{
  // operate inputs

  // Fill(dp, -1);
  cin >> N >> M;
  solve();
  #ifdef DEBUG
  debug();
  #endif
  answer();

  return 0;
}

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

    cin>>p>>q>>r;

    if(p<=q&&r<=q)cout<<p+r<<endl;
    else if(q<=p&&r<=p)cout<<q+r<<endl;
    else cout<<p+q<<endl;
 
    return 0;
}

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

int find(string str, string word) {
    int count = 0;
    for(string::size_type pos = 0; (pos = str.find(word, pos)) != string::npos;
        pos += word.size()) {
        ++count;
    }
    return count;
}

int main() {
    string t;
    cin >> t;
    for(int i = 0; i < t.length(); i++)
        if(t[i] == '?')
            t[i] = 'D';
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3700
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAX = 100001;
const ll INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b){ if(a<b) {a=b; return true;} return false;}

int N;
ll DP[MAX][3];
int abc[MAX][3];

int main(){
    cin >> N;
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++) DP[i][j] = 0;
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<3; j++) cin >> abc[i+1][j];
    }
    for(int i=0; i<3; i++) DP[0][i] = 0;

    for(int i=1; i<N+1; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<3; k++){
                if(j == k) continue;
                chmax(DP[i][j], DP[i-1][k]+abc[i][j]);
            }
        }
    }
    cout << max({DP[N][0], DP[N][1], DP[N][2]}) << endl;
}

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

using namespace std;
using ll=long long;

int main()
{
    int n;cin >>n;
    int a[n];bool b[n];
    for(int i=0;i<n;i++){
        int k;cin >>k;
        k--;a[i]=k;
        b[i]=true;
    }
    int ans=0;
    for(int i=0;i<n;i++){
        if(b[i]&&a[a[i]]==i){
                ans++;
                b[a[i]]=false;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
fib (-1) = 0
fib 0 = 1
fib 1 = 1
fib 2 = 2
fib 3 = 3
fib 4 = 5
fib 5 = 8
fib 6 = 13
fib 7 = 21
fib _ = 0
-- fib n = (fib (n - 1)) + (fib (n - 2))
-- fib n = [1, 1, 2, 3, 5, 8, 13, 21] !! n

solve h w k =
    let
        solve' 0 m = m
        solve' h m =
            solve' (h - 1)
            ( [0] ++ [
                sum
                    [ (m !! i) * (fib (i - 1)) * (fib (w - i))
                    , (m !! (i - 1)) * (fib (i - 2)) * (fib (w - i))
                    , (m !! (i + 1)) * (fib (i - 1)) * (fib (w - i - 1))
                    ] `mod` (10 ^ 9 + 7 :: Int)
            | i <- [1..w] ] ++ [0] )
    in
        (solve' h [ if x == k then 1 else 0 | x <- [0..w+1] ]) !! 1

main = do
    [h, w, k] <- map read . words <$> getLine :: IO [Int]
    print $ solve h w k

Measured memory_bytes: 636
#include <cstdio>
#include <cstdint>
#include <algorithm>
#include <vector>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<std::vector<int>> a(N, std::vector<int>(3));
  for (size_t i = 0; i < N; ++i)
    for (size_t j = 0; j < 3; ++j)
      scanf("%d", &a[i][j]);

  std::vector<int> res(N);
  for (int k = 0; k < 3; ++k) {
    for (size_t i = 0; i < N; ++i) {
      bool dupe = false;
      for (size_t j = 0; j < N; ++j) {
        if (j == i) continue;
        if (a[i][k] == a[j][k]) {
          dupe = true;
          break;
        }
      }
      if (!dupe)
        res[i] += a[i][k];
    }
  }
  for (size_t i = 0; i < N; ++i)
    printf("%d\n", res[i]);
}



Measured memory_bytes: 2656
//include
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath> 
#include <iomanip>
#include <math.h>
#include <utility>
#include <functional>
//using
using namespace std;
using vi = vector <int>;
using vs = vector <string>;
using vc = vector <char>;
using ll= long long;
using vvl = vector<vector<ll> >;
using vd = vector <double>;
//define
//#define int long long
#define rep(i,n) for(int i=0; i<n; i++)
#define print(n) cout<<n<<endl;
#define sortp(d) sort(d.begin(),d.end()) //1234
#define sortm(d) sort(d.rbegin(),d.rend()) //4321
//グローバル変数宣言
 ll a=0,b=0,c=0,e=0,n=0,k=0;


int main(){
   cin>>n;
   vd v(n);
   rep(i,n)cin>>v[i];
   sortm(v);
   rep(i,n-1){
      v[n-i-2]=(v[n-i-1]+v[n-i-2])/2;
   }
   print(v[0]);
}


Measured memory_bytes: 3832
import numpy as np
n,d = tuple(map(int,input().split()))

x = [np.array(tuple(map(int,input().split()))) for _ in [0]*n]

ans = 0
for i in range(n):
  for j in range(i+1,n):
    if np.linalg.norm(x[i]-x[j]).is_integer():
      ans+=1
print(ans)


Measured memory_bytes: 12500
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr ll INF = 3000000000000000000;

int main() {
    vector<vector<char>> C(2, vector<char>(3));
    REP(i, 2) REP(j, 3) cin >> C[i][j];
    if (C[0][0] == C[1][2] && C[0][1] == C[1][1] && C[0][2] == C[1][0]) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}


Measured memory_bytes: 3612
//#typedef int ll
// include
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <tuple>
// namespace
using namespace std;
// typedef
typedef long long ll;
typedef long double ld;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pint;
// const
const int inf = 1e9;
const int mod = ((int)1e9 + 7);
// loop
#define rep(i, n) for(int i = 0, i##_mx = n; i < i##_mx; i++)
#define brep(i, b, e) for(int i = b; i < e; i++)
#define erep(i, b, e) for(int i = b; i <= e; i++)
#define rrep(i, b, e) for(int i = b; i >= e; i--)
// STL
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
// function
int gcd(int a, int b){return b ? gcd(b, a % b) : a;}
void prime(vint& v, int n){brep(i, 2, n){bool fg = false; for(auto e : v){if(i % e == 0){fg = true;}} if(fg){continue;} v.pb(i);}}
void in(vint& v){for(auto& i : v){cin >> i;}}
void in(vll& v){for(auto& i : v){cin >> i;}}

signed main(){
    int n, l;
    cin >> n >> l;
    
    int ans = 0;
    bool flag = false;
    for(int i = 1; i <= n; i++){
        ans += l + i - 1;
        if(l + i - 1 == 0){
            flag = true;
        }
    }
    
    if(flag){
        cout << ans << endl;
    }else{
        if(l > 0){
            cout << ans - min(abs(l), abs(l + n - 1)) << endl;
        }else{
            cout << ans + min(abs(l), abs(l + n - 1)) << endl;
        }
    }
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  for (;;){
    int h, w; cin >> h >> w;
    if (w == 0) return 0;
    for (int i = 0; i < h; i++){
      for (int j = 0; j < w; j++){
        cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
}


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,x,t;
	cin>>n>>x>>t;
	int c=n/x;
	if(n%x==0)
	{
		cout<<c*t<<endl;
	}
	else
	{
		cout<<(c+1)*t<<endl;
	}
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vd = vector<double>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;

const int N = 1000000;

int main() {
  int s;
  cin >> s;
  
  set<int> st;
  int x = s;
  while (st.count(x)==0) {
    st.insert(x);
    if(x%2 == 0) {
      x /= 2;
    }
    else {
      x = x*3+1;
    }
  }
  
  cout << st.size()+1 << endl;
}

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

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

    int k;
    cin >> k;
    cin.ignore(numeric_limits<streamsize>::max(), '\n');
    string s;
    getline(cin, s);
    int n = s.size();
    if (n <= k) {
        cout << s << '\n';
    } else {
        for (int i = 0; i < k; ++i) {
            cout << s[i];
        }
        cout << "...\n";
    }

    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define rep(i,n) for(int i=0;i<n;i++)
#define For(i,a,b) for(int i=a;i<b;i++)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define mp make_pair
#define bit(n) (1LL<<(n))
#define F first
#define S second
#define debug(x) cerr << x << endl
#define Complex complex<double>
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

/*
テストケース全てに目を通す
テストケースが2個以下だったらなんかある
N最小のコーナーケースがないか調べる
制約をしっかりと確認する（1からNまでの順列、全て異なる値などの制約も含め）
制約のn*mとn,mを読み違えない
操作の逆順を考える
オーバーフローしないか確かめる
Codeforcesではscanfを使う
modの引き算には+modをする
エラー出力は消す
エラー出力を消せ！！！！！
数値の区切り位置を誤読しない
cout << fixed;
cout << setprecision(n) << ans;
 */

int main() {
    int n,m;
    cin >> n >> m;
    if(n==m)cout << "Yes";
    else cout << "No";



    
}

/*
*/



Measured memory_bytes: 256
#if 0
set???????????´?????\??£???????????§??????????????????????´????????????????set?????¨????????????
#endif

#include <string>
#include <set>
#include <iostream>
#include <algorithm>
using namespace std;

int main(){
	int n;
	string t, t1, t2, r1, r2; //??\???(??????),????????????,????????????,???????????¢,???????????¢
	typedef set<string> SET; //????????´?????\??£???????????§??????????????????????´?
	cin>>n;
	for(int k=0;k<n;++k){
		cin>>t;
		SET T;
		for(int i=0;i<t.length();++i){
				t1="";
				t2="";
			for(int j=0;j<=i;++j){ //??????????????????
				t1+=t[j];
			}
			for(int j=0;j<t.length()-1-i;j++){
				t2+=t[t.length()-1-j]; //??????
			}
			r1=t1;
			reverse(r1.begin(),r1.end()); //?????¢
			r2=t2;
			reverse(r2.begin(),r2.end()); //?????¢
			T.insert(t1+t2);
			T.insert(t2+t1);
			T.insert(t1+r2);
			T.insert(r2+t1);
			T.insert(t2+r1);
			T.insert(r1+t2);
			T.insert(r1+r2);
			T.insert(r2+r1);
			//result[i]=T.size();
			}
		cout << T.size() << endl;
	//for(int i=0;i<n;++i)
	}
	return 0;
}

Measured memory_bytes: 3144
n = int(input())
an = list(map(int, input().split()))
bn = list(map(int, input().split()))



bsum = sum(bn)
for i in range(n):
    diff = an[i] - bn[i]
    if diff <= 0:
        diff = bn[i] - an[i]
        an[i] = 0
        bn[i] = diff
    else:
        an[i] = diff
        bn[i] = 0
    
    diff2 = an[i+1] - bn[i]
    if diff2 <= 0:
        diff2 = bn[i] - an[i+1]
        an[i+1] = 0
        bn[i] = diff2
    else:
        an[i+1] = diff2
        bn[i] = 0
ans = bsum - sum(bn)
print(ans)

Measured memory_bytes: 19004
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws IOException {

		Scanner scan = new Scanner(System.in);

		String t = scan.next();
		String p = scan.next();

		StFind f = new StFind(t, p, false);

		scan.close();
		System.exit(0);
	}
}

class StFind {
	boolean debug;

	public StFind(String t, String p, boolean d) {
		debug = d;
		createCharPt(p);
		createMatchPt(p);
		StringBuilder sb = new StringBuilder();

		int x = 0;
		for (int st = 0; st < t.length() - p.length() + 1;) {
			if ((x = isBaEqual(t, p, st)) == p.length())
				// System.out.println(st);
				sb.append(st + "\n");
			// st += Math.max(sft[t.charAt(st + p.length() - 1)], msft[x]);
			st += msft[x];
		}
		System.out.print(sb);
	}

	int[] msft;

	private void createMatchPt(String p) {
		msft = new int[p.length() + 1];
		msft[0] = p.length();

		for (int sft = p.length(); sft > 0; sft--) {
			for (int m = 1; m < msft.length; m++) {
				if (m > p.length() - sft) {
					msft[m] = sft;
					continue;
				}
				if (p.charAt(p.length() - m) != p.charAt(p.length() - m - sft)) {
					msft[m - 1] = sft;
					break;
				} else if (m == p.length() - sft)
					msft[m] = sft;
			}
		}

		if (debug)
			for (int i = 0; i < msft.length; i++)
				System.out.println("--- " + i + " : " + msft[i]);
	}

	int[] sft = new int[Character.MAX_CODE_POINT];

	private void createCharPt(String p) {
		for (int i = 0; i < sft.length; i++)
			sft[i] = p.length();

		for (int i = 1; i < p.length(); i++) {
			char c = p.charAt(p.length() - i - 1);
			if (sft[c] == p.length())
				sft[c] = i;
		}

		if (debug)
			for (int i = 0; i < sft.length; i++)
				if (('a' <= i && i <= 'z') || ('A' <= i && i <= 'Z') || ('0' <= i && i <= '9'))
					System.out.println("-- " + (char) i + " : " + sft[i]);
	}

	private boolean isEqual(String t, String p, int st) {
		for (int i = 0; i < p.length(); i++)
			if (t.charAt(i + st) != p.charAt(i))
				return false;
		return true;

	}

	int stPre = 0;
	int retPre = 0;

	private int isBaEqual(String t, String p, int st) {
		int clen = p.length();
		if (st >= stPre + p.length() - retPre && st < stPre + p.length())
			clen -= stPre + p.length() - st;
		for (int i = 0; i < clen; i++)
			if (t.charAt(p.length() - 1 - i + st) != p.charAt(p.length() - 1 - i)) {
				stPre = st;
				retPre = i;
				return i;
			}
		stPre = st;
		retPre = p.length();
		return p.length();
	}

}

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

using namespace std;

int main() {
  int N, Y;
  cin >> N >> Y;
  Y /= 1000;
  for (int i = 0; i <= N; i++) {
    for (int j = 0; i + j <= N; j++) {
      int k = N - i - j;
      if (i * 10 + j * 5 + k * 1 == Y) {
        cout << i << " " << j << " " << k << endl;
        return 0;
      }
    }
  }
  cout << "-1 -1 -1" << endl;

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		while(true){
			int t = stdIn.nextInt();
			if(t==0) return;
			int n = stdIn.nextInt();
			int sum = 0;
			for(int i=0;i<n;i++){
				sum+=(-1*(stdIn.nextInt()-stdIn.nextInt()));
			}
			if(sum>=t){
				System.out.println("OK");
			}
			else{
				System.out.println(t-sum);
			}
		}
	}
}

Measured memory_bytes: 23544
# solution

import io
import sys
import math

nim, mike = map(int, input().split())

if mike==0:
    print(nim*nim)
    exit()

b = mike+1

counter = 0

while b<=nim:
    counter += (nim//b)*(b-mike)+max(nim%b-mike+1, 0)
    b += 1

print(counter)

Measured memory_bytes: 3060
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(dead_code)]
struct Scanner<'a> {
    cin: StdinLock<'a>,
}
#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn input<T: FromStr>(&mut self) -> T {
        self.read().unwrap()
    }
}

fn ok(chs: Vec<char>) -> bool {
    for ch in chs {
        match ch {
            'A' | 'C' |'G' | 'T' => {continue},
            _  =>{return false}
        }
    }
    true
}
fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin);

    let s: String = sc.input();
    let chs: Vec<char> = s.chars().collect();

    let mut ans = 0;
    for i in 0..chs.len() {
        for j in i..chs.len() + 1 {
            if ok(chs[i..j].to_vec()) {
                ans = std::cmp::max(ans, j - i);
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;
const int M = 11;

int n;
int m;
int K[M];
int p[M];
int s[M][M];

int main(){
    scanf("%d%d" , &n , &m);
    for(int i = 1; i <= m; i++){
        int x;
        scanf("%d" , &x);
        K[i] = x;
        for(int j = 1; j <= x; j++){
            scanf("%d" , &s[i][j]);
        }
    }
    for(int i = 1; i <= m; i++){
        scanf("%d" , &p[i]);
    }
    int ways = 0;
    for(int mask = 0; mask < (1 << n); mask++){
        // we will switch on this mask "switches"
        int ison = 0;
        for(int i = 1; i <= m; i++){
            int switchesonme = 0;
            for(int j = 1; j <= K[i]; j++){
                if(mask & (1 << (s[i][j]-1)))
                    switchesonme++;
            }
            if(p[i] == switchesonme % 2)
                ison++;
        }
        if(ison == m)
            ways++;
    }
    printf("%d\n" , ways);
}

Measured memory_bytes: 256
import sys
import math

max = 10**9+7
n,m = map(int,input().split())
ans = 0

if n+1 < m or m+1 < n:
    print(0)
    sys.exit()

if n == m:
    ans = ((math.factorial(n))*(math.factorial(m)))*2
else:
    ans = (math.factorial(n))*(math.factorial(m))

print(ans%max)

Measured memory_bytes: 55152
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

template<typename T>
string to_string(const vector<T>& vc, int w) {
	if(vc.empty()) return "";
	if(w + 1 == vc.size()) return to_string(vc[w]);
	return to_string(vc[w]) + "," + to_string(vc, w + 1);
}

template<typename T>
string to_string(const vector<T>& vc) {
	return "{" + to_string(vc, 0) + "}";
}

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20, bs = 29;

ll frm(ll x, ll y, ll z) {
	return x * x + y * y + z * z + (x * y + x * z + y * z);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	int n;
	cin >> n;
	vector<int> arr(n + 1);
	for(int u = 1; frm(u, 1, 1) <= n; u++)
		for(int i = 1; frm(u, i, 1) <= n; i++)
			for(int j = 1; frm(u, i, j) <= n; j++)
				arr[frm(u, i, j)]++;
	for(int i = 1; i <= n; i++) cout << arr[i] << '\n';
}



Measured memory_bytes: 3600
# -*- coding: utf-8 -*-
"""
Bitset I - Bit Flag
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP2_10_C&lang=jp

"""
class Bit:
    def __init__(self):
        self.data = 0

    def process(self, op, arg):
        funcs = (self.test, self.set, self.clear, self.flip, self.all, self.any, self.none, self.count, self.val)
        funcs[int(op)](arg)

    def test(self, arg):
        print(int(bool(self.data & 1 << int(arg))))

    def set(self, arg):
        self.data |= 1 << int(arg)

    def clear(self, arg):
        self.data &= ~(1 << int(arg))

    def flip(self, arg):
        self.data ^= 1 << int(arg)

    def all(self, arg):
        print(int(bin(self.data).count('1') == 64))

    def any(self, arg):
        print(int(self.data != 0))

    def none(self, arg):
        print(int(self.data == 0))

    def count(self, arg):
        print(bin(self.data).count('1'))

    def val(self, arg):
        print(self.data)

b = Bit()
for _ in range(int(input())):
    op, arg = (input() + ' 1').split()[:2]
    b.process(op, arg)



Measured memory_bytes: 5644
def read():
    A = list()
    for i in range(3):
        a = list(map(int, input().strip().split()))
        A.append(a)
    N = int(input().strip())
    B = list()
    for i in range(N):
        b = int(input().strip())
        B.append(b)
    return A, N, B

def solve(A, N, B):
    lines = [
        [(0, 0), (0, 1), (0, 2)],
        [(1, 0), (1, 1), (1, 2)],
        [(2, 0), (2, 1), (2, 2)],
        [(0, 0), (1, 0), (2, 0)],
        [(0, 1), (1, 1), (2, 1)],
        [(0, 2), (1, 2), (2, 2)],
        [(0, 0), (1, 1), (2, 2)],
        [(0, 2), (1, 1), (2, 0)]
    ]
    C = [[False for j in range(3)] for i in range(3)]
    for b in B:
        for i in range(3):
            for j in range(3):
                if A[i][j] == b:
                    C[i][j] = True
    for line in lines:
        is_bingo = True
        for r, c in line:
            if not C[r][c]:
                is_bingo = False
        if is_bingo:
            return 'Yes'
    return 'No'


if __name__ == '__main__':
    inputs = read()
    print("{}".format(solve(*inputs)))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97 '0'=0x30=48
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;

long long fact(int x){//x! 階乗
  long long ans=1;
  for (int i=1;i<=x;i++){
    ans *= i;
    if(ans>mod)ans%=mod;
  }
  return ans;
}
//桁数指定　cout << fixed << setprecision(2)
int main() {
  int i;
  int n;
  cin>>n;
  i=1;
  cout<<fact(n);
}

Measured memory_bytes: 256
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.util.*;
 
public class Main {
    Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        new Main();
    }
 
    public Main() {
        while(true){
            int n = in.nextInt();
            if(n==0)break;
            new AOJ1107().doIt(n);
        }
    }
     
    class AOJ1107{
    	double EPS = 1.0e-8;
    	int comp(double x,double y){
    		if(Math.abs(x-y)<EPS)return 0;
    		if(x<y)return -1;
    		return 1;
    	}
    	
        void doIt(int n){
            Point2D[] p = new Point2D[n];
            for(int i=0;i<n;i++)p[i] = new Point2D.Double(in.nextDouble(), in.nextDouble());
            boolean[] used = new boolean[n];
            double result = 0;
            Point2D before = new Point2D.Double(0,-1);
            Point2D now = new Point2D.Double(0,0);
            int visit = 0;
            while(visit!=n){
                double max = Integer.MIN_VALUE;
                double len = Double.MAX_VALUE;
                int index = -1;
                for(int i=0;i<n;i++)if(!used[i]){
                    //内積
                    double ccw = dot(sub(now, before),sub(p[i],now));
                    double res = now.distance(p[i]);
//                  System.out.println(sub(now, before));
//                  System.out.println(sub(p[i], now));
                    ccw /= sub(now,before).distance(0,0);
                    ccw /= sub(p[i],now).distance(0,0);
//                  System.out.println("CCW " + ccw+" "+i+" "+p[i]);
                    int diff = comp(max, ccw);
                    if((diff<0)||(diff==0&&res<len)){
                        max = ccw;
                        index = i;
                        len = res;
                    }
                }
 
//              System.out.println(sub(now, before));
//              System.out.println(sub(p[index], now));
                used[index] = true;
//              System.out.println("CCW "+index+" "+p[index]);
                result += p[index].distance(now);
                before = now;
                now = p[index];
                visit++;
            }
            System.out.printf("%.1f\n",result);
        }
        double dot(Point2D p1,Point2D p2){
            return p1.getX()*p2.getX()+p1.getY()*p2.getY();
        }
        Point2D sub(Point2D p1,Point2D p2){
            return new Point2D.Double(p1.getX()-p2.getX(),p1.getY()-p2.getY());
        }
    }
}

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

int main(){
  int N;
  cin>>N;
  vector<int> X(N),Y(N);
  for(int i=0;i<N;i++){
    cin>>X.at(i);
    Y.at(i)=X.at(i);
  }
  sort(Y.begin(),Y.end());
  int center1=Y.at(N/2-1);
  int center2=Y.at(N/2);
  for(int i=0;i<N;i++){
    if(X.at(i)>=Y.at(N/2)){
      cout<<center1<<endl;
    }else{
      cout<<center2<<endl;
    }
  }

}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int N;
vector<long long> x(100), y(100), h(100);

bool is_ans(int Cx, int Cy, int H)
{
    rep (i, 0, N) {
        if (h[i] != max(0ll, H - abs(x[i] - Cx) - abs(y[i] - Cy)))
            return false;
    }
    return true;
}

int main()
{
    cin >> N;
    rep (i, 0, N) cin >> x[i] >> y[i] >> h[i];

    rrep (Cx, 0, 100) {
        rrep (Cy, 0, 100) {
            rep (i, 0, N) {
                int H = h[i] + abs(Cx - x[i]) + abs(Cy - y[i]);
                if (is_ans(Cx, Cy, H)) {
                    cout << Cx << " " << Cy << " " << H << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n, a, ans = 0;
  scanf("%d", &n);
  for(int i = 1; i <= n; i++){
    cin >> a;
    if(i % 2 && a % 2) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3728
# -*- coding: utf-8 -*-
# input
n = int(input())

t0 = x0 = y0 = 0
for i in range(n):
    t, x, y = map(int, input().split())
    dt = t - t0
    dm = abs(x - x0) + abs(y - y0)
    if dt < dm or dt % 2 != dm %2:
        print('No')
        exit()

    t0 = t
    x0 = x
    y0 = y

print('Yes')


Measured memory_bytes: 3060
n, m, x = map(int, input().split())

c = [0] * n
a = [[0] * m for _ in range(n)]

for i in range(n):
    tmp = list(map(int, input().split()))
    c[i] = tmp[0]
    a[i] = tmp[1:]

INF = 10 ** 9
ans = INF

for i in range(1 << n):
    cost = 0
    under = [0] * m
    for j in range(n):
        if not i >> j & 1: continue
        cost += c[j]
        for k in range(m):
            under[k] += a[j][k]
    ok = True
    for k in range(m):
        if under[k] < x: ok = False
    if ok:
        ans = min(ans, cost)

if ans == INF: print("-1")
else: print(ans)

Measured memory_bytes: 74020
#include <iostream>
#include <string>
#include <cmath>
#include <fstream>
#include <chrono>
#include <iomanip>
#include <vector>
#include <utility>
#include <time.h>
#include <set>
#include <unordered_set>
#include <list>
#include <iterator>
#include <time.h>
#include <chrono>
#include <deque>
#include <cstdio>
#include <sstream>
#include <algorithm>
#include <stack>
#include <queue>
#include <climits>
#include <tuple>
#include <map>
using namespace std;

#define ll long long
#define ldb long double

ll mod(ll a, ll b)
{
	return (b + (a % b)) % b;
}

ll subMod(ll a, ll b, ll M)
{
	return mod((mod(a, M) - mod(b, M)), M);
}

ll dayofweek(ll d, ll m, ll y)
{
	static ll t[] = { 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4 };
	y -= m < 3;
	return (y + y / 4 - y / 100 +
		y / 400 + t[m - 1] + d) % 7;
}

void test()
{

}

void solve()
{
	ll n;
	cin >> n;
	map<string, int> Map;

	ll Max = 0;

	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		Map[s]++;

		if (Map[s] > Max)
		{
			Max = Map[s];
		}
	}

	for (auto it = Map.begin(); it != Map.end(); it++)
	{
		if (it->second == Max)
		{
			cout << it->first << "\n";
		}
	}
}

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

	//test();

	solve();

	return 0;
}

Measured memory_bytes: 23808
#include<bits/stdc++.h>
using namespace std;
void godie(){
	puts("Impossible");
	exit(0);
}
const int maxn=110;
int n,a[maxn],s[maxn];
int main(){
	scanf("%d",&n);
	int d=0;
	for(int i=1;i<=n;++i)scanf("%d",&a[i]),d=max(a[i],d),s[a[i]]++;
	if(d&1){
		for(int i=d-d/2;i<=d;++i){
			s[i]-=2;if(s[i]<0)godie();
		}
		for(int i=d-d/2;i;--i)if(s[i])godie();
	}
	else {
		if(!s[d/2])godie();
		--s[d/2];
		for(int i=d/2+1;i<=d;++i){
			s[i]-=2;if(s[i]<0)godie();
		}
		for(int i=d/2;i;--i)if(s[i])godie();
	}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
import math
def  results(a,b):
    return ((a+b-1)//b)
 
n=int(input())
t,a=map(int,input().split())
for i in range(1,n):
    ti,ai=map(int,input().split())
    if ti<=t or ai<=a:
        k=max(results(t,ti),results(a,ai))
        t=k*ti
        a=k*ai
    else:
        t=ti
        a=ai
    #print(t,a)
print(t+a)

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()


using namespace std;

int main()
{
	pair<pair<string, int>, int> p[200];
	int N;
	cin >> N;
	REP(i, N)
	{
		string tmps;
		int  tmpi;

		cin >> tmps >> tmpi;

		p[i] = make_pair(make_pair(tmps, -tmpi), i+1);
	}

	sort(p, p+N);

	REP(i, N) cout << p[i].second << endl;

	return 0;
}


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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int A;
string S;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>A>>S;
	if(A>=3200) cout<<S<<endl;
	else cout<<"red"<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


class Mod:
    def __init__(self, m):
        self.m = m
    
    def add(self, a, b):
        return (a + b ) % self.m

    def sub(self, a, b):
        return (a - b) % self.m
    
    def mul(self, a, b):
        return ((a % self.m) * (b % self.m)) % self.m

    def div(self, a, b):
        return self.mul(a, self.pow(b, self.m-2))

    def pow(self, x, y):
        if y == 0: 
            return 1
        elif y == 1: 
            return x % self.m
        elif y % 2 == 0: 
            return self.pow(x, y//2)**2 % self.m
        else: 
            return self.pow(x, y//2)**2 * x % self.m



@mt
def slv(N, S):

    ans = 0
    CC = Counter()
    for c in S:
        CC[c] += 1
    
    m = Mod(10**9+7)

    cs = tuple(CC.values())
    @lru_cache(maxsize=None)
    def f(v):
        if not v:
            return 1
        
        c = v[0]
        v = v[1:]
        return m.add(m.mul(c, f(v)), f(v))
    return f(cs) - 1


def main():
    N = read_int()
    S = read_str()
    print(slv(N, S))


if __name__ == '__main__':
    main()


Measured memory_bytes: 6840
N = int(input())
S = input()
hdg = S[1:N].count('E')
hdg_chgd = hdg
hdg_chg_nrs =[]
for i in range(1,N):
    if S[i] == 'E':
        hdg_chgd -= 1
    if S[i-1] == 'W':
        hdg_chgd += 1
    hdg_chg_nrs.append(hdg_chgd)
hdg_chgd_f = min(hdg_chg_nrs)
print(min(hdg, hdg_chgd_f))


Measured memory_bytes: 15552
<?php
fscanf( STDIN, "%d", $count );

for($i=0;$i<$count;$i++){

fscanf( STDIN, "%d %d %d", $a, $b, $c );

if( $b < $a ) list( $b, $a ) = [ $a, $b ];#a,b??§?????§???b
if( $c < $b ) list( $c, $b ) = [ $b, $c ];#a,b,c??§?????§???c

$answer = ( $a * $a + $b * $b == $c * $c ) ? 'YES' : 'NO';

printf("%s\n",$answer);
}

Measured memory_bytes: 14924
def func(n,s=''):
    while True:
        if n == 1:
            break
        elif n == 0:
            break
        div = -(-n//-2)
        mod = n - (-2)*div
        n = div
        s = str(mod) + s
    return '1' + s

if __name__ == '__main__':
    n = int(input())
    if n == 1:
        print(1)
        exit()
    elif n == 0:
        print(0)
        exit()
    print(func(n))

Measured memory_bytes: 3060
import fractions

a, b = map(int, input().split())
count = 0


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


c = make_divisors(a)
d = make_divisors(b)
e = []
for i in c:
    if i in d:
        e.append(i)

e.pop(0)
e.sort()

gcd_list = [1]
for i in e:
    count = 0
    for j in gcd_list:
        if fractions.gcd(i, j) != 1:
            break
        else:
            count += 1
        if count == len(gcd_list):
            gcd_list.append(i)

print(len(gcd_list))


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

void main(){
  char S[100], T[100];
  scanf("%s%s",S ,T );
  
  for(int i=0; i<strlen(S); i++){
    if(S[i]==T[i])
      continue;
    else{
      printf("No\n");
      return 0;
    }
  }
  printf("Yes\n");
  return 0;
}

Measured memory_bytes: 1652
<?php
    fscanf(STDIN,"%d %d",$N,$M);

    

    function kaijyo($n){
        $sum=0;
        for($i=1;$i<=$n;$i++){
            $sum += $i;
        }
        return $sum;
    }


    $N_patern = $N*($N-1)/2;

    $M_patern = $M*($M-1)/2;

    
    echo $N_patern+$M_patern."\n";
    
    

Measured memory_bytes: 4604
#include <stack>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cmath>
#include <array>
#include <iomanip>
#include <string>
using namespace std;
int gcd(int a, int b)
{
   if (a%b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a%b));
   }
}
int mod = 1000000000 + 7;
int main(){
    //std::stack<int> stack;
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    const double PI = 3.141592653589;
    double ans;
    double kakuM = m * 6.0;
    double kakuH = h * 30.0 + m * 0.5;
    double kaku = kakuM - kakuH;
    double rad = kaku * PI / 180;
    ans = sqrt(a*a + b*b - 2*a*b*cos(rad));
    cout << std::setprecision(12) << ans << endl;
    return 0;
}





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

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

    int ans = 0;
    for(int i = 0; i < n; i++) {
        bool divisible = true;
        while(divisible) {
            if(a[i] % 2 == 0) {
                ans++;
                a[i] = a[i] / 2;
            } else {
                divisible = false;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,i;
    cin>>n;
    int arr[n];
    for(i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n);
    // if(arr[n/2]==arr[n/2+1])
    // cout<<"0"<<endl;
    // else
    // {
    //     for(i=arr[n/2];i<arr[n/2+1];i++)
    //     {
    //         count++;
    //     }
    // }
    cout<<abs(arr[n/2-1]-arr[n/2])<<endl;
    
}

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

int main() {
	int a, b, c;

  	cin >> a >> b;
  
  	if (( (a + b) % 2)==0)
    {
      c = (a + b) / 2;
    }
  	else
    {
      c = ((a + b) / 2) + 1;
    }
  
  	cout << c << endl;
}


Measured memory_bytes: 256
def solve(a, b, c):
    l = 0; r = a;
    t = 0
    for i in range(80):
        t = l // 60
        p = 60*t + c
        if l <= p <= r:
            print(p)
            exit()

        l = r + b
        r = l + a

    print(-1)

a, b, c = map(int, input().split())
solve(a,b,c)

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

using namespace std;

typedef long long int ll;

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

  int n;
  cin >> n;
  string s;
  cin >> s;
  string tmp = "SW";
  for(int p = 0; p < 2; p++){
    for(int q = 0; q < 2; q++){
      for(int r = 0; r < 2; r++){
        vector < char > res(n + 1);
        res[n] = tmp[p];
        res[1] = tmp[q];
        res[2] = tmp[r];
        if(res[1] == 'S'){
          if(s[0] == 'o'){
            if(res[n] != res[2]) continue;
          }else if(res[n] == res[2]) continue;
        }else{
          if(s[0] == 'o'){
            if(res[n] == res[2]) continue;
          }else if(res[n] != res[2]) continue;
        }

        char ch = res[n];

        for(int i = 1; i < n - 1; i++){
          if(res[i + 1] == 'S'){
            if(s[i] == 'o') res[i + 2] = res[i];
            else if(res[i] == 'S') res[i + 2] = 'W';
            else res[i + 2] = 'S';
          }else{
            if(s[i] == 'x') res[i + 2] = res[i];
            else if(res[i] == 'S') res[i + 2] = 'W';
            else res[i + 2] = 'S';
          }
        }

        if(res[n] == 'S'){
          if(s[n - 1] == 'o' && res[n - 1] != res[1]) continue;
          else if(s[n - 1] == 'x' && res[n - 1] == res[1]) continue;
        }else{
          if(s[n - 1] == 'o' && res[n - 1] == res[1]) continue;
          else if(s[n - 1] == 'x' && res[n - 1] != res[1]) continue;
        }

        if(res[n] != ch) continue;

        for(int i = 1; i <= n; i++) cout << res[i];
        cout << endl;
        return 0;
      }
    }
  }

  cout << -1 << '\n';
}


Measured memory_bytes: 640
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());
            string ans = "";
            if (D == 25)
            {
                ans = "Christmas";
            }
            else if (D == 24)
            {
                ans = "Christmas Eve";
            }
            else if (D == 23)
            {
                ans = "Christmas Eve Eve";
            }
            else
            {
                ans = "Christmas Eve Eve Eve";
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
   int n;
   cin>>n;
   map<string,int>mp;
   vector<string>s;
  int ans = 0;
   for(int i=0;i<n;i++)
   {
       string x;
       cin>>x;
       if(mp.find(x)==mp.end())
       {
           mp[x] = 1;
           ans = max(1,ans);
       }
       else
       {
           mp[x]++;
           ans = max(ans,mp[x]);
       }
   }
   for(auto i:mp)
   {
       if(i.second==ans)
       {
           s.push_back(i.first);
       }
   }
   sort(s.begin(),s.end());
   for(auto i:s)
    cout<<i<<endl;
}


Measured memory_bytes: 26608