akhauriyash/Code-Regression huggingface dataset:
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

str max(str a, str b){
  return (a.length()>b.length()) ? a : b;
}

int main(){
  str s,t;
  cin >> s >> t;
  ll m = s.length(), n = t.length();
  str dp[2][n+1];
  fill(dp[0],dp[2],"");
  for(ll i = 1; i <= m; i++){
    REP(j,n+1){
      if(j==0){
        dp[i%2][j] = "";
        continue;
      }
      str len = (dp[(i+1)%2][j].length()>dp[i%2][j-1].length()) ? dp[(i+1)%2][j] : dp[i%2][j-1];
      if(s[i-1]==t[j-1]){
        dp[i%2][j] = ((dp[(i+1)%2][j-1]+s[i-1]).length()> len.length()) ? dp[(i+1)%2][j-1]+s[i-1] : len;
      }else{
        dp[i%2][j] = len;
      }
    }
  }
  cout << dp[m%2][n] << endl;
  return 0;
}


Measured memory_bytes: 8980
#include <iostream>
#include <string>

using namespace std;

int main() {
    string S, T;
    cin >> S >> T;
    
    if (S.size() < T.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    
    string ans = "";
    
    for (int i = 0; i < S.size() - T.size() + 1; i++) {
        auto flag = false;
        for (int j = 0; j < T.size(); j++) {
            if (S[i + j] == '?') continue;
            if (S[i + j] != T[j]) {
                flag = true;
                break;
            }
        }
        if (flag) continue;
        string tmp = "";
        for (int j = 0; j < i; j++) {
            tmp += S[j] == '?' ? 'a' : S[j];
        }
        tmp += T;
        for (int j = i + T.size(); j < S.size(); j++) {
            tmp += S[j] == '?' ? 'a' : S[j];
        }
        if (ans == "" || tmp < ans) {
            ans = tmp;
        }
    }
    
    cout << (ans == "" ? "UNRESTORABLE" : ans) << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
    public static void main(String[] args){
	Scanner stdIn = new Scanner(System.in);
        int A = stdIn.nextInt();
	int B = stdIn.nextInt();
	int max = A+B;
	int m = A-B;
	int k = A*B;
	if(max<m){
	    max=m;
	}
	if(max<k){
	    max=k;
	}
	System.out.println(max);
    }
}
	    


Measured memory_bytes: 22740
#include<iostream>
#include<cstdio>
#include<cstring>
const int N=55;
const int mv[8][2]={-1,-1,-1,0,-1,1,0,-1,0,1,1,-1,1,0,1,1};
bool got(){for(char c;;)if((c=getchar())=='#')return 1;else if(c=='.')return 0;}
int s[N][N],t[N][N];
int n,m;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			s[i][j]=got();
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
		{
			if(s[i][j]){t[i][j]=-1;continue;}
			t[i][j]=0;
			for(int v=0;v<8;v++)
				t[i][j]+=s[i+mv[v][0]][j+mv[v][1]];
		}
	for(int i=1;i<=n;i++,printf("\n"))
		for(int j=1;j<=m;j++)
			if(t[i][j]<0)printf("#");
			else printf("%d",t[i][j]);
	return 0;
}


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

void solve() {
  int n;
  cin >> n;
  priority_queue<pair<ll, ll>> q;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    pair<ll, ll> p;
    p.first = b;
    p.second = a;
    q.push(p);
  }
  int t = q.top().first;
  while(!q.empty()) {
    if (t < 0) break;
    if (q.top().first < t) {
      t = q.top().first;
    }
    t -= q.top().second;
    q.pop();
  }
  if (!q.empty() || t < 0) cout << "No" << endl;
  else cout << "Yes" << endl;
}

int main() {
  solve();
  return 0;
}

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

using namespace std;

typedef long long ll;

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

  int n, k, a = 0;
  cin >> n >> k;
  while (n)
  {
    a++;
    n /= k;
  }
  cout << a << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

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; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
template<typename T>
class BIT{
  public:
    int N;
    vector<T> data;
    BIT(T _N):N(_N){
        data.assign(N, 0);
    };
    
    // a is 1-indexed
    void add(int a, T w){
        for(int x = a; x <= N; x += x & -x)data[x] += w;
    }
    // 1-indexed sum of prefix [0, a]
    T sum(int a){
        T res = 0;
        for(int x = a; x > 0; x -= x & -x)res += data[x];
        return res;
    }
    // 1-indexed sum of range [l, r]
    T sum(int l, int r){return sum(r) - sum(l-1);}

    // 0-indexed add
    void add0(int a, T w){add(a + 1, w);}
    // 0-indexed sum
    T sum0(int a){return sum(a + 1);}
    // 0-indexed sum of range
    T sum0(int l, int r){return sum0(r) - sum0(l-1);}
    // show the value
    void debug(){print(data);}
};

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

    ll N;
    cin >> N;
    ll half = (N+1) * N / 4;
    vector<ll> a(N);
    rep(i,N)cin>>a[i];
    if(N == 1){
        cout << a[0] << endl;
        return 0;
    }
    ll ok = 0;
    ll ng = INFLL;
    //dump(half);
    //print(a);
    // 中央値がX以上になる区間が半分以上あるか？
    auto check = [&](ll X){
        vector<ll> b(N);
        rep(i,N)b[i] = ((a[i] >= X) ? 1: -1);
        vector<ll> cum(N+1);
        rep(i,N)cum[i+1] = cum[i] + b[i];
        //print(b);print(cum);
        BIT<ll> Tree(2 * N + 10);
        ll cnt = 0;
        rep(i,N+1){
            //Tree.debug();
            cnt += Tree.sum0(cum[i]+N);
            Tree.add0(cum[i]+N, 1);
        }
        //cerr << X << " " << cnt << endl;
        return half  <= cnt;
    };
    while(ng - ok  > 1){
        ll mid = (ok + ng) / 2;
        if(check(mid))ok = mid;
        else ng = mid;
    }
    cout << ok << endl;
}

Measured memory_bytes: 4236
def min(a,b)
  if(a > b)then
    return b
  else
    return a
  end
end

N = gets.to_i
a_list = gets.split(/\s/).map {|s|s.to_i}

max = a_list.max
min = a_list.min

if(max-min==0)then
  puts 0
else
  result = 1000000000
  (min..max).each do |k|
    calc   = 0
    a_list.each do |a|
      calc += (k-a)*(k-a)
    end
    result = min(result,calc)
  end
end

puts result

Measured memory_bytes: 1916
#include<cmath>
#include<iostream>
using namespace std;
int main(){
	int A,B,C;
	cin >> A >> B >> C;
	if(A==5&&B==5&&C==7) cout << "YES" << endl;
	else if(B==5&&C==5&&A==7) cout << "YES" << endl;
	else if(C==5&&A==5&&B==7) cout << "YES" << endl;
	else  cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(void) {
  int i,a,b,catNumber;

  scanf("%d %d %d",&a,&b,&catNumber);


  for(i = b; i >= 0 ; i--) {
    if(a == catNumber) {
      printf("YES\n");
      return 0;
    }
    a += 1;
  }

  printf("NO\n");
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
map<string,int>mp;
vector<string>vec;
int main(){
  int n,m,ans=0;
  cin>>n;
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    if(mp.count(s)==0){
      vec.push_back(s);
      mp[s]=1;
    }
    else mp[s]++;
  }
  cin>>m;
  for(int i=0;i<m;i++){
    string s;
    cin>>s;
    if(mp.count(s)==0){
      vec.push_back(s);
      mp[s]=-1;
    }
    else mp[s]--;
  }
  for(int i=0;i<vec.size();i++){
    ans=max(ans,mp[vec[i]]);
  }
  cout<<ans<<endl;
  return(0);
}


Measured memory_bytes: 256
#!/usr/bin/env python3
n = int(input())
ps = list(map(int,input().split()))
imos = [None] * n
for i, p in enumerate(ps):
    imos[p-1] = i
a = [ 0 ]
b = [ 0 ]
for i in range(n):
    a += [ a[-1] + 1 + imos[i]     ]
    b += [ b[-1] + 1 + imos[n-i-1] ]
print(*a[1:])
print(*reversed(b[1:]))

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

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  std::vector<i64> A;
  tools::read(A, N - 1);
  for (i64& A_i : A) {
    --A_i;
  }

  std::unordered_map<i64, i64> map;
  for (const i64& A_i : A) {
    ++map[A_i];
  }

  for (i64 i = 0; i < N; ++i) {
    std::cout << map[i] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 13032
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

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

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

    h[0]--;
    for (int i=1; i<n; i++)
        if (h[i-1] <= h[i]-1) h[i]--;


    bool ans = true;
    for (int i=0; i<n-1; i++) {
        if (h[i] > h[i+1]) ans = false;
    }

    cout << (ans? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
typedef long long ll;
const int INF=1e9;
const ll MOD=1e9+7;
template<typename A,size_t N,typename T>
void Fill(A (&array)[N],const T &val)
{
    std::fill( (T*)array,(T*)(array+N),val );
}
int H,W;
string board[25];
int ans=0;
int tmpmx=0;
bool visited[25][25];
int turns[25][25];
int dy[] = { -1, 0, 1, 0};
int dx[] = { 0, -1, 0, 1};
bool outrange(int y,int x,int turn)
{
    if(y<0 || y>=H || x<0 || x>=W) return true;
    else if(board[y][x]=='#' || 
    (turns[y][x]!=-1 && turns[y][x]<=turn)) return true;
    else return false;
}

void solve(int y,int x, int turn)
{
    visited[y][x]=true;
    turns[y][x]=turn;
    //cout << y << ' ' << x << ' ' << turn << endl; 
    for(int k=0;k<4;k++)
    {
        int nx=x+dx[k],ny=y+dy[k];
        if(!outrange(ny,nx,turn+1)) solve(ny,nx,turn+1);
    }
}

int main(void)
{

    cin >> H >> W;
    for(int i=0;i<H;i++)
    {
        cin >> board[i];
    }
    for(int i=0;i<H;i++)
    {
        for(int j=0;j<W;j++)
        {
            memset(visited,false,sizeof(visited));
            Fill(turns, -1);
            if(board[i][j]!='#')
            {
                solve(i,j,0);
                for(int i=0;i<H;i++)
                {
                    for(int j=0;j<W;j++) ans=max(ans,turns[i][j]);
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long x = scan.nextLong();

    long sum = 0;
    long start = 1;
    long end = find1(n);

    while (n >= 1){
      long mid = (long) (start+end)/2;
      if (x == start){
        break;
      }

      if (x == end){
        sum += 2*find2(n-1);
        sum += 1;
        break;
      }

      if (n == 1){
        sum += x-start;
        break;
      }

      if (x == mid){
        sum += 1;
        long add = find2(n-1);
        sum += add;
        System.out.println(sum);
        return;
      }

      if (x > mid){
        sum += 1;
        long add = find2(n-1);
        sum += add;
        start = mid+1;
        end -= 1;
      }
      else{
        end = mid-1;
        start += 1;
      }
      n -= 1;
    }
    System.out.println(sum);
  }

  static long find1(long n){
    long ret = 1;
    long base = 2;
    n += 2;
    while (n > 0){
      if ((n & 1) == 1){
        ret *= base;
      }
      base = base*base;
      n >>= 1;
    }
    ret -= 3;
    return ret;
  }

  static long find2(long n){
    long ret = 1;
    long base = 2;
    n += 1;
    while (n > 0){
      if ((n & 1) == 1){
        ret *= base;
      }
      base = base*base;
      n >>= 1;
    }
    ret -= 1;
    return ret;
  }
}


Measured memory_bytes: 35628
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val array = IntArray(n){sc.nextInt()}
    val cnt = array.filter { isPrime(it) }.count()
    println(cnt)
}

fun isPrime(x: Int):Boolean {
    if (x == 2) {
        return true
    } else if (x % 2 == 0) {
        return false
    }
    var i = 3
    while (i <= Math.sqrt(x.toDouble())) {
        if (x % i == 0) {
            return false
        }
        i += 2
    }
    return true
}


Measured memory_bytes: 42756
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0117
#include <iostream>
#include <vector>
using namespace std;

const int INF = 1<<28;

int main(){
  int n,m;
  cin>>n>>m;
  char dummy;
  vector<vector<int>> d(n, vector<int> (n,INF));
  for(int i=0;i<m;++i){
    int a,b,c,e;
    cin>>a>>dummy>>b>>dummy>>c>>dummy>>e;

    d[a-1][b-1] = c;
    d[b-1][a-1] = e;
  }

  int x1,x2,y1,y2;
  cin>>x1>>dummy>>x2>>dummy>>y1>>dummy>>y2;

  // wa-sharufuroidohou
  for(int k = 0; k < n; ++k)
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

  int ans = y1 - y2 - (d[x1-1][x2-1] + d[x2-1][x1-1]);

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 1208
a = gets.chomp.to_s
if a == 'A' || a == 'T'
  b = ['A', 'T']
  puts b[b.index(a) - 1]
elsif a == 'C' || a == 'G'
  b = ['C', 'G']
  puts b[b.index(a) - 1]
end

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

int main() {
  int N, f = 0;
  cin >> N;
  for(int i = 1; (N / i) != 0; i *= 10) {
    f += (N / i) % 10;
  }
  if(N % f) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int main(void)
{
  int A, B;
  cin >> A >> B;

  int s[MAX_N];
  s[0] = 1;
  s[1] = A;
  for (int i = 1; i < 20; i++) {
    s[i + 1] = s[i] - 1 + A;
  }

  int cnt;
  for (int i = 0; i < 20; i++) {
    if (s[i] >= B) {
      cnt = i;
      break;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial
from heapq import heappop, heappush, heappushpop
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    s = ST()
    print(s.count("1"))
if __name__ == '__main__':
    main()

Measured memory_bytes: 38256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <utility>
#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;

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

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,x,count;
  int i,j,k;
  for(;;){
    scanf("%d%d",&n,&x);
    count = 0;
    if(n == 0 && x == 0)break;
    for(i = 1;i <= n;i++){
      for(j = i + 1;j <= n;j++){
        for(k = j + 1;k <= n;k++){
          if(j != i && k != i && k != j &&(i + j + k == x)){
            count++;
        }
        }
    }
  }
    printf("%d\n",count);
  }
   return 0;
}

Measured memory_bytes: 600
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("7");
            WillReturn.Add("beat");
            WillReturn.Add("vet");
            WillReturn.Add("beet");
            WillReturn.Add("bed");
            WillReturn.Add("vet");
            WillReturn.Add("bet");
            WillReturn.Add("beet");
            //beet
            //vet
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("8");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            WillReturn.Add("buffalo");
            //buffalo
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("7");
            WillReturn.Add("bass");
            WillReturn.Add("bass");
            WillReturn.Add("kick");
            WillReturn.Add("kick");
            WillReturn.Add("bass");
            WillReturn.Add("kick");
            WillReturn.Add("kick");
            //kick
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("4");
            WillReturn.Add("ushi");
            WillReturn.Add("tapu");
            WillReturn.Add("nichia");
            WillReturn.Add("kun");
            //kun
            //nichia
            //tapu
            //ushi
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        string[] SArr = InputList.Skip(1).ToArray();

        var CntDict = new Dictionary<string, int>();
        foreach (string EachStr in SArr) {
            if (CntDict.ContainsKey(EachStr)) {
                CntDict[EachStr]++;
            }
            else {
                CntDict[EachStr] = 1;
            }
        }

        int MaxCnt = CntDict.Values.Max();
        var wkList = new List<string>();
        foreach (var EachPair in CntDict) {
            if (EachPair.Value == MaxCnt) {
                wkList.Add(EachPair.Key);
            }
        }
        wkList.Sort(StringComparer.Ordinal);
        string[] wkArr = wkList.ToArray();

        //Array.Sort(wkArr, StringComparison.Ordinal);
        wkList.ForEach(pX => Console.WriteLine(pX));

        //var tmp1 = SArr.GroupBy(pX => pX).Select(pX => new { pX.Key, Cnt = pX.Count() });
        //var tmp2 = tmp1.OrderByDescending(pX => pX.Cnt).ThenBy(pX => pX.Key);
        //int MaxCnt = int.MinValue;
        //foreach (var EachPair in tmp2) {
        //    if (MaxCnt > EachPair.Cnt) break;
        //    MaxCnt = EachPair.Cnt;
        //    Console.WriteLine(EachPair.Key);
        //}
    }
}


Measured memory_bytes: 44424
using System;
using System.Linq;
using System.Collections.Generic;

class Amondai
{
    static void Main()
    {
        var line=Console.ReadLine();
        string ans;
        if (line.Count() == 2) ans = line;
        else ans = new String(line.Reverse().ToArray());
        Console.WriteLine(ans);
    }
}

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

int main() {
  int n;
  cin >> n;
  if (n%10==2 || n%10==4 || n%10==5 || n%10==7 || n%10==9) cout << "hon" << endl;
  if (n%10==0 || n%10==1 || n%10==6 || n%10==8) cout << "pon" << endl;
  if (n%10==3) cout << "bon" << endl;
}

Measured memory_bytes: 3636
def main():
    from collections import deque
    s = list(input())
    ans = deque([])
    for i in s:
        if i == '0':
            ans.append('0')
        elif i == '1':
            ans.append('1')
        else:
            if len(ans)!= 0:
                ans.pop()

    print(''.join(ans))

main()

Measured memory_bytes: 9324
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct BoolName : numpunct<char> {
  string t, f;
  BoolName (string t = "Yes", string f = "No") : t(t), f(f) {}
  string do_truename() const {return t;}
  string do_falsename() const {return f;}
};

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
    cout.imbue(locale(cout.getloc(), new BoolName));
  }
} initializer;

template<typename T> istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

void set_bool_name(string t, string f) {
  cout.imbue(locale(cout.getloc(), new BoolName(t, f)));
}

int main() {
  string n;
  cin >> n;
  for (char c : n) cout << char(c ^ '1' ^ '9');
  cout << endl;
}



Measured memory_bytes: 256
N = int(input())
A = [None] * N
B = [None] * N
for i in range(N):
  A[i],B[i] = map(int, input().split())
  
ans = 0
for i in range(N):
  p = (A[N-1-i] + ans) % B[N-1-i]
  ans += (B[N-1-i] - p) % B[N-1-i]
print(ans)

Measured memory_bytes: 10868
#define MAX 10000001
int p[MAX];
int four[1000];

int main(void)
{
  int i,j,f=0;

  for(i=2 ; i<=MAX ; i++){
    if(p[i]==0)
      {
	for(j=i*2 ; j<=MAX ; j+=i){
	  p[j] = 1;
	}
      }
  }
  
  for(i=3 ; i < MAX-7 ; i+=2){
    if(p[i] == 0 && p[i+2]==0 && p[i+6]==0 && p[i+8]==0)
      {
	four[f++]=i+8;
      }
    four[f]=10000005;
  }
  
  for(;scanf("%d",&j);)
    {
      if(j==0)
	exit(0);
      for(i=0 ;four[i]<=j; i++);
      printf("%d\n",four[i-1]);
    }
  
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include <cstdio>
#include<cctype>
#include <algorithm>
#include<string>

using namespace std;

int main(){
	int cnt = 0,a = 0,b = 0;
	string str, cmd , p;
	
	cin >> str;
	cin >> cnt;
	
	for(int x = 0; x < cnt; x++){
		cin >> cmd >> a >> b;
	
		if (cmd == "print"){
			cout << str.substr(a,b-a+1) << endl;
		}
		else if (cmd == "reverse"){
			reverse(str.begin()+a,str.begin()+b+1);
		}
		else if (cmd == "replace"){
			cin >> p;
			str.replace(a,p.length(),p);
		}
	}
	
	return 0;
}

Measured memory_bytes: 1220
#include <cstdio>

int main(){
    int a, b;
    scanf("%d%d", &a, &b);

    if((a<=0)&&(b>=0)) printf("Zero\n");
    else if((a<0)&&(((-a)-(-b))%2==0)) printf("Negative\n");
    else printf("Positive\n");

    return 0;
}


Measured memory_bytes: 128
n,m=map(int,input().split())
lst=[list(map(int,input().split())) for i in range(n)]
lst.sort(key=lambda x:x[0])
ans=0
for i in lst:
  ans+=min(m,i[1])*i[0]
  m-=i[1]
  if m<=0:
    break
print(ans)
  

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

using namespace std;

string s;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> s;
    int cur = 0;
    long long ans = 0;
    for(int i = 0; i < (int)s.size(); ++i) {
        if (s[i] == 'B') ++cur;
        else ans += cur;
    }
    cout << ans;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n,a;
  cin >> n >> a;
  
  if(n%500 <= a)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=a; i<=b; i++)
#define all(v) v.begin(), v.end()
#define F first
#define S second
#define INF 1000000000000
#define MOD 10000007
#define PI 3.14159265359
#define dij priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>>
typedef long long ll;
//

int main(){
    string s;cin>>s;
    int ans=0;
    for(auto e:s){
        ans+=e-(int)'0';
    }
    if(ans%9==0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

}

Measured memory_bytes: 3752
#pragma GCC optimize("Ofast")
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <functional>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H,W;
  cin >> H >> W;
  int sy,sx;
  cin >> sy >> sx;
  sy--;sx--;
  int gy,gx;
  cin >> gy >> gx;
  gy--;gx--;
  vector<string> G(H);
  for(int i=0; i<H; i++){
    cin >> G[i];
  }
  priority_queue<pair<int,P>,vector<pair<int,P>>,greater<>> que;
  vector<vector<int>> dist(H,vector<int>(W,inf));
  dist[sy][sx] = 0;
  que.emplace(0,P(sy,sx));
  while(que.size()){
    int cost,y,x;
    cost = que.top().first;
    y = que.top().second.first;
    x = que.top().second.second;
    que.pop();   
    if(dist[y][x] < cost) continue;
    for(int k=0; k<4; k++){
      int ny = y + dy[k];
      int nx = x + dx[k];
      if(ny<0 || ny>=H || nx<0 || nx>=W) continue;
      if(G[ny][nx] == '#') continue;
      if(cost < dist[ny][nx]){
        dist[ny][nx] = cost;
        que.emplace(cost,P(ny,nx));
      }
    }
    for(int i=-2; i<=2; i++){
      for(int j=-2; j<=2; j++){
        int ny = y + i;
        int nx = x + j;
        if(ny<0 || ny>=H || nx<0 || nx>=W) continue;
        if(G[ny][nx] == '#') continue;
        if(cost+1 < dist[ny][nx]){
          dist[ny][nx] = cost + 1;
          que.emplace(cost+1,P(ny,nx));
        }
      }
    }
  }
  // for(int i=0; i<H; i++){
  //   for(int j=0; j<W; j++){
  //     cout << dist[i][j] << " \n"[j+1==W];
  //   }
  // }
  if(dist[gy][gx] == inf){
    cout << -1 << "\n";
  }else{
    cout << dist[gy][gx] << "\n";
  }
  return 0;
}

Measured memory_bytes: 8476
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1000005;
struct A{
	int num,cnt;
}a[N];
long long n,k;
bool cmp(A x,A y){
	return x.num < y.num;
}
int main(){
	cin >> n >> k;
	for (int i = 1;i <= n;i++)	cin >> a[i].num >> a[i].cnt;
	sort(a+1,a+n+1,cmp);
	int ans = 0;
	for (int i = 1;k > 0;i++){
		k -= a[i].cnt;
		ans = i;
	}
	cout << a[ans].num;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<vector>
#include <fstream>
#include<math.h>
#include <numeric>
#include<algorithm>

using namespace std;

int main(){
    int n;
    int cnt;
    string s;
    cin >> n >> s;
    for(int i =0 ;i < n -1 ; i++){
        if ((s[i] == 'A') && (s[i+1] == 'B') && (s[i+2] == 'C')){
            cnt += 1;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;
  vector <int> vec(N);
  //int a[N];
  rep(i,N) cin >> vec.at(i);//a_i

  vector <int> kaisuu(N);//a_iが2で割れる回数
  rep(i,N){
    //int kaisuu = 0;
    for (; vec.at(i) % 2 == 0; vec.at(i) /= 2){
      kaisuu.at(i) += 1;
    }
  }

  sort(kaisuu.begin(), kaisuu.end());
  cout << kaisuu.at(0) << endl;

}


Measured memory_bytes: 3660
import math
S = int(input())
i = 1
ans = 0
while (S - i*3) >= 0:
    ans += math.factorial((S-i*3) + (i-1)) // \
        (math.factorial(S-i*3)*math.factorial((i-1)))
    i += 1
print(ans % (10**9+7))


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

ll dfs(int K, const Graph&graph, int now,int from) {
    int can_use_color_num;

    if (from == -1){
        can_use_color_num = K - 1;
    } else {
        can_use_color_num = K - 2;
    }

    if (K < graph[now].size()){
        return 0;
    } else {
        ll case_num = 1;
        for (auto e: graph[now]){
            if (e == from){continue;}
            case_num *= can_use_color_num;
            can_use_color_num--;
            case_num %= MOD;
        }
        for (auto e: graph[now]){
            if (e == from){continue;}
            case_num *= dfs(K, graph, e, now);
            case_num %= MOD;
        }
        return case_num;
    }
}

void Main() {
    ll N, K; cin >> N >> K;
    // Graph graph(N, vector<ll>(N, INF));
    Graph g(N);
    rep(i, N - 1){
        ll a, b; cin >> a >> b;
        a--; b--;
        g.at(a).push_back(b);
        g.at(b).push_back(a);
    }

    // 頂点0を根とする根付き木と考える，ある頂点とその親が既に塗られれている時，xの個の数c_{x}について塗り分け方は(K-2)P(c_{x})
    ll ans = K * dfs(K, g, 0, -1);
    cout << ans % MOD << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 11648
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <fstream>

using namespace std;

typedef pair<int,int> pii;
typedef long long ll;


int N,M;
vector<pii> G[501];

int dp[510];

int dfs(int pos){
  if(dp[pos]>=0)return dp[pos];
  int res=0;
  for(int i=0;i<(int)G[pos].size();i++){
    int cost=G[pos][i].second;
    int to=G[pos][i].first;
    res=max(res,dfs(to)+cost);
  }
  return dp[pos]=res;
}

int main(){

  cin>>N>>M;
  for(int i=0;i<N;i++)G[i].clear();
  for(int i=0;i<M;i++){
    int a,b,c;
    cin>>a>>b>>c;
    G[b].push_back(pii(a,c));
  }
  memset(dp,-1,sizeof(dp));
  cout<<dfs(N-1)<<endl;

  return 0;
}

Measured memory_bytes: 1216
#include "iostream"
#include "math.h"
#include "algorithm"
#include "string"
#include "vector"
using namespace std;

bool isPrime(int a) {
	if (a == 2) {
		return 1;
	}
	else if (a < 2 || a % 2 == 0) {
		return 0;
	}
	else {
		int i = 3;
		while (i*i <= a) {
			if (a%i == 0) {
				return 0;
			}
			i += 2;
		}
		return 1;
	}
}

int main() {
	int n;
	cin >> n;
	int num;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		cin >> num;
		if (isPrime(num))cnt++;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3116
#include<iostream>

using namespace std;

int main() {
	int a[100] = { 0 };
	for (int i = 0; i < 10; i++) {
		cin >> a[i];
	}
	int big1, big2, big3;
	big1 = a[0];
	big2 = big3 = 0;
	for (int k = 1; k < 10; k++) {
		if (a[k] > big1) {
			big3 = big2;
			big2 = big1;
			big1 = a[k];
		}
		else if (a[k] > big2) {
			big3 = big2;
			big2 = a[k];
		}
		else if (a[k] > big3) {
			big3 = a[k];
		}
	}
	cout << big1 << endl << big2 << endl << big3 << endl;
	return 0;
}

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

const long long mod = 1e9 + 7;

long long modpow(long long x, long long n){
	if(n == 0) return 1;
	long long val = modpow(x, n / 2);
	val = (val * val) % mod;
	if(n % 2 == 1) val = (val * x) % mod;
	return val; 
}

int n, a, b;

int main(){
	cin >> n >> a >> b;
	long long cnt = modpow(2, n) - 1, fac = 1;
	long long af = 1, bf = 1;
	for(int i = 2; i <= a; i++) af = (af * i) % mod;
	for(int i = 2; i <= b; i++) bf = (bf * i) % mod;
	while(a > 0 || b > 0){
		fac = (fac * (n--)) % mod;
		a--, b--;
		if(a == 0) cnt = (cnt - (fac * modpow(af, mod - 2)) % mod) % mod;
		else if(b == 0) cnt = (cnt - (fac * modpow(bf, mod - 2)) % mod) % mod;
	}
	while(cnt < 0) cnt += mod;
	cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

using namespace std;

int main(){
  int X;
  cin >> X;
  if(X==7 || X==5 || X==3)  cout << "YES" << endl;
  else  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef double db;

#define fr first
#define sc second
#define pb push_back
#define rep(i,x) for(ll i=0;i<x;i++)
#define rep1(i,x) for(ll i=1;i<=x;i++)
#define rrep(i,x) for(ll i=x-1;i>=0;i--)
#define rrep1(i,x) for(ll i=x;i>0;i--)

ll n,m;
vector<P> rocks[150];
ll k;
ll dp[150][10][77];//dp[i][j][k] rock[i][j]?????????k???????????£??????
const ll INF=0xffffffffffff;
int main()
{while(1){
	scanf("%lld%lld",&n,&m);
	if(!n) return 0;
	rep(i,150) rocks[i].clear();
	fill(dp[0][0],dp[149][10],INF);
	rep(i,n){
		scanf("%lld",&k);
		rep(j,k){
			ll x,y;
			scanf("%lld%lld",&x,&y);
			x--;
			rocks[i].pb(P(x,y));
		}
	}
	rep(i,rocks[0].size()){
		dp[0][i][m]=0;
	}
	rep(i,rocks[1].size()){
		if(m>1) dp[1][i][m-1]=0;
	}
	rep(i,n-1){
		rep(j,rocks[i].size()){
			rep(k,m+1){
				if(dp[i][j][k]==INF) continue;
				//??????
				rep(l,rocks[i+1].size()){
					dp[i+1][l][k]=min(dp[i+1][l][k],dp[i][j][k]+abs(rocks[i][j].fr-rocks[i+1][l].fr)*(rocks[i][j].sc+rocks[i+1][l].sc));
				}
				//??????
				if(k>0&&i<n-2){
					rep(l,rocks[i+2].size()){
						dp[i+2][l][k-1]=min(dp[i+2][l][k-1],dp[i][j][k]+abs(rocks[i][j].fr-rocks[i+2][l].fr)*(rocks[i][j].sc+rocks[i+2][l].sc));
					}
				}
			}
		}
	}
	ll ans=INF;
	rep(i,rocks[n-1].size()){
		rep(j,m+1){
			ans=min(ans,dp[n-1][i][j]);
		}
	}
	rep(i,rocks[n-2].size()){
		rep1(j,m) ans=min(ans,dp[n-2][i][j]);
	}
	cout<<ans<<endl;
}}

Measured memory_bytes: 4084
#include <stdio.h>
#include <string.h>
#define N 100010
int n;char flag=0,mat[N];
int ne=0,h[N];struct edge{int to,x;}e[N<<1];
inline void ins(int s,int t) {
	e[++ne].to=t;e[ne].x=h[s];h[s]=ne;
}
void dfs(int s,int fa) {
	mat[s]=0;
	for(int i=h[s],v;i;i=e[i].x) {
		v=e[i].to;
		if(v!=fa) {
			dfs(v,s);
			if(!mat[v]) {
				if(!mat[s]) mat[s]=1;
				else flag=1;
			}
		}
	}
}
int main() {
	int a,b;
	scanf("%d",&n);
	for(int i=1;i<n;++i) {
		scanf("%d%d",&a,&b);
		ins(a,b);ins(b,a);
	}
	dfs(1,0);
	puts(flag||!mat[1]?"First":"Second");
	return 0;
}

Measured memory_bytes: 2176
#include <stdio.h>
#include <algorithm>

int main() {
	int n;
	char s, flag = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%c", &s);
		if (s == 'Y')
			flag |= 1;
	}
	printf("%s\n", flag ? "Four" : "Three");
}

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

int main(void){
    string s;
    int l, cnt;
    cnt = 0;
    cin >> s;

    l = s.size();
    char c[l];

    for(int i = 0; i < l; ++i){
        c[i] = s[i];
    }

    for(int i = 0; i < l; ++i){
        if(c[i] == c[l - i - 1])cnt = 1;
        else{
            cnt = 0;
            break;
        }
    }

    if(cnt == 1){
        for(int i = 0; i < l / 2; ++i){
            if(c[i] == c[(l - 1) / 2 - 1 - i] && c[(l + 3) / 2 - 1 + i] == c[l - 1 - i])cnt = 1;
            else{
                cnt = 0;
                break;
            }
        }
    }

    if(cnt == 1)cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
for e in iter(input,'0 0'):
 r,_=map(int,e.split())
 d=[int(''.join(x),2)for x in zip(*[input().split()for _ in[0]*r])]
 a=0
 for i in range(1<<r):
  b=0
  for j in d:
   c=bin(i^j).count('1')
   b+=c if c>r//2else r-c
  a=max(a,b)
 print(a)


Measured memory_bytes: 6912
from functools import reduce
from fractions import gcd

N, K=map(int, input().split())
an=list(map(int,input().split()))

m = max(an)
g = reduce(lambda x, y: gcd(x, y), an)

if K <=m and K % g == 0:
    print ('POSSIBLE')
else:
    print ('IMPOSSIBLE')

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

int main(void)
{
    int a, b, x;
    cin >> a >> b >> x;
    double theta;
    if(x <= (double) (a*a*b*0.5)){
        theta = atan2((double) a * b * b, 2 * x);
    } else {
        theta = atan2((double) 2 * (a*a*b - x), a*a*a);
    }

    cout << fixed << setprecision(10) << theta / M_PI * 180 << endl;
    return 0;
}


Measured memory_bytes: 4036
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
  int n, k = 2;
  cin >> n >> k;
  vector<int> v(n), dp(n, INT_MAX);
  for (int i = 0; i < n; i++)
  {
    cin >> v[i];
  }
  dp[0] = 0;
  for (int i = 1; i < n; i++)
  {
    for (int j = i - 1; abs(i - j) <= k && j >= 0; j--)
    {
      if (j >= 0)
      {
        dp[i] = min(dp[j] + abs(v[i] - v[j]), dp[i]);
      }
    }
  }
  cout << dp[n - 1] << endl;
  return 0;
}

Measured memory_bytes: 1024
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(m)]

graph = {x:[] for x in range(1, n+1)}
for x, y in ab:
    graph[x].append(y)
    graph[y].append(x)

def dfs(v):
    visited.append(v)
    for v2 in graph[v]:
        if v2 not in visited:
            dfs(v2)

res = 0
for a, b in ab:
    graph[a].remove(b)
    graph[b].remove(a)
    visited = []
    dfs(1)
    if len(visited) != n:
        res += 1
    graph[a].append(b)
    graph[b].append(a)

print(res)


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


int main(){
    string  X, Y;
    cin >> X >> Y;
    
    int x=stoi(X, nullptr, 16);
    int y=stoi(Y, nullptr, 16);
    
    if(x < y){
        cout << '<' << endl;
    }
    else if(x > y){
        cout << '>' << endl;
    }
    else{
        cout << '=' << endl;
    }
    }
    
    

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int w,h,x,y,r;

    scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

    if((w>x && x>0) && (h>y && y>0)) {
      if((w>=x+r && x+r>=0) && (h>=y+r && y+r>=0))
        printf("Yes\n");
      else
        printf("No\n");
    }
    else
      printf("No\n");

    return 0;
}




Measured memory_bytes: 2104
#include <vector> 
#include <list> 
 #include <map>
 #include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << '=' << (x) << endl;
#define debug(x) cerr << #x << '=' << (x) << '('<<'L' << __LINE__ << ')' << ' ' << __FILE__ << endl;


int main(){
   string s,t;
   cin>>s;
   cin>>t;
    sort(ALL(s),less<char>());
    sort(ALL(t),greater<char>());
    debug(s);
    debug(t);
    if(s<t){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}

}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
#define range(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) range(i,0,n)
const ll INF=1e10;
#define PI 3.141592
#define pb push_back

void show(vector<vll> a){
    range(i,1,a.size()){
        range(j,1,a[i].size()){
            cout << a[i][j] << " ";
        }
        cout << endl;
    }
}

int main(){
    int n,m; cin >> n >> m;
    char ch;
    vint a(m),b(m),c(m),d(m);
    vector<vll> K(n+1,vll(n+1,INF));
    rep(i,m){
        int a,b; cin >> a >> ch >> b >> ch;
        cin >> K[a][b] >> ch >> K[b][a];
    }
    int s,g,v,p; cin >> s >> ch >> g >> ch >>  v >> ch >> p;

    range(k,1,n+1) range(i,1,n+1) range(j,1,n+1){
        if(K[i][j]>K[i][k]+K[k][j]){
            K[i][j]=K[i][k]+K[k][j];
        }
    }
    cout << v-p-K[s][g]-K[g][s] << endl;
}


Measured memory_bytes: 3128
#include <iostream>
#include <map>
using namespace std;
int main(){
    string s;
    map<string,int> m;
    int q,k;
    cin>>q;
    while(q--){
        cin>>k>>s;
        if(k==0){
            cin>>k;
            if(m.find(s)!=m.end())m[s]=k;
            else m.insert({s,k});
        }
        else if(k==1){
            if(m.find(s)==m.end())cout<<0<<endl;
            else cout<<m[s]<<endl;
        }
        else m.erase(s);
    }
}


Measured memory_bytes: 27672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/gcd(a,b)
#define ff first
#define ss second
#define p pair<int,int>
#define pb push_back
#define endl '\n'
#define w(t) ll test;cin>>test;while(test--)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(0);
#define pi acos(-1)

int main()
{
    fast;
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    for(int i=0;i<k;i++)
    {
        if(b<=a)b*=2;
        else if(c<=b)c*=2;
    }
    cout<<(a<b&&b<c?"Yes":"No")<<endl;
}



Measured memory_bytes: 3648
#include<stdio.h>
#include<string.h>
#include<math.h>
//dp[i] = min cost incurred going from stone i to stone n
int dp[100005], h[100005], min[105], n, k;

int minimum(const int a[], int j)
{
    int least = 1e9 + 7;
    for (int i = 1; i<j; i++)
    {
        if (min[i]<=least)
            least = a[i];
    }
    return (least);
}

int solve(int i)
{
    int j;
    if (dp[i] != -1)
        return (dp[i]);
    if (i == n)
        return (dp[i] = 0);
    for (j = 1; j<=k; j++)
    {
        if (j == n+1-i)
            break;
        min[j] = abs(h[i-1+j]-h[i-1])+solve(i+j);
    }
    return (dp[i] = minimum(min, j));
}

int main()
{
    scanf("%d %d", &n, &k);
    memset(dp, -1, (n+2)*sizeof(int));
    for (int i = 0; i<n; i++)
    {
        scanf("%d", &h[i]);
    }
    int ans = solve(1);
    printf("%d\n", ans);
    return (0);
}

Measured memory_bytes: 8704
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>
#include <limits>
#include <cmath>
#include <iomanip>
#include <sstream>
 
#define ALL(a)  (a).begin(),(a).end()
 
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

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

    ll h, a;

    cin >> h >> a;

    (h % a == 0) ? (cout << h/a << endl) : (cout << h/a + 1 << endl);

    

}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		int money = 0;
		
		if(a <= b) {
			money += a;
		}else {
			money += b;
		}
		
		if(c <= d) {
			money += c;
		}else {
			money += d;
		}
		
		System.out.println(money);
	}
	
}

Measured memory_bytes: 22100