akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  vector<int> a(3), b(3);

  rep(i, 3){
    cin >> a[i] >> b[i];
  }

  bool ok = false;
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      for(int k = 0; k < 3; k++){
        if(i==j || j==k || i==k) continue;

        // i-> j -> kの順
        if(b[i]==a[j] && b[j]==a[k]){
          ok = true;
          break;
        }
        if(b[i]==a[j] && b[j]==b[k]){
          ok = true;
          break;
        }
        if(b[i]==b[j] && a[j]==a[k]){
          ok = true;
          break;
        }
        if(b[i]==b[j] && a[j]==b[k]){
          ok = true;
          break;
        }
        if(a[i]==a[j] && b[j]==a[k]){
          ok = true;
          break;
        }
        if(a[i]==a[j] && b[j]==b[k]){
          ok = true;
          break;
        }
        if(a[i]==b[j] && a[j]==a[k]){
          ok = true;
          break;
        }
        if(a[i]==b[j] && a[j]==b[k]){
          ok = true;
          break;
        }


      }
    }
  }

  if(ok){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
H = int(input())
W = int(input())
N = int(input())

if H >= W:
    if N%H == 0:
        count = N/H
    else:
        count = int(N/H) + 1
else:
    if N%W == 0:
        count = N/W
    else:
        count = int(N/W) + 1
print(int(count))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int n;
	cin >> n;
	set<string> st;
	rep(i, 0, n) {
		string s;
		cin >> s;
		st.insert(s);
	}
	int m;
	cin >> m;
	vs t(m);
	rep(i, 0, m) {
		cin >> t[i];
	}
	bool open = false;
	rep(i, 0, m) {
		if (st.count(t[i])) {
			if (!open) {
				cout << "Opened by ";
				open = true;
			}
			else {
				cout << "Closed by ";
				open = false;
			}
		}
		else {
			cout << "Unknown ";
		}
		cout << t[i] << endl;
	}
	return 0;
}


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

int main() {
	int N,M;
	cin >> N>>M;
	vector<int>fir(0);
	vector<int>sec(0);
	
	for(int i=0;i<M;i++){
		int a, b;
		cin >>a>>b;
		
		if (a==1){
			fir.push_back(b);
		}
		
		if (b==N){
			sec.push_back(a);
		}
	}
	
	string ans ="IMPOSSIBLE";
	set<int> jud;
	
	for (int i=0 ;i<fir.size();i++){
		jud.insert(fir.at(i));
	}
	
	for (int i=0;i<sec.size();i++){
		if (jud.count(sec.at(i))==true){
			ans ="POSSIBLE";
			break;
		}
	}
	
	
	cout << ans <<endl;
	
}


Measured memory_bytes: 7796
awk 'function lower(x){
  return x == "A" ? "a" : x == "B" ? "b" : "c"
}
NR<2{n=$1;k=$2}
NR>1{
  for (i = 1; i <= n; ++i) {
    c = substr($1, i, 1)
    s = s (i == k ? lower(c) : c)
  }
  print s
}'


Measured memory_bytes: 552
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define ALL(v) v.begin(), v.end()
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define chmax(x, a) x = max(x, a)
#define chmin(x, a) x = min(x, a)

int main() {
    int N, M; cin >> N >> M;
    if (M % 2 == 1) {
        int tmp = 1;
        int mx = M;
        while(tmp != mx) {
            cout << tmp << " " << mx << endl;
            tmp++;
            mx--;
        }
        tmp = M+1;
        mx = 2*M+1;
        while(tmp < mx) {
            cout << tmp << " " << mx << endl;
            tmp++;
            mx--;
        }
    }
    else {
        int tmp = 1;
        int mx = M+1;
        while(tmp != M-tmp+2) {
            cout << tmp << " " << mx << endl;
            tmp++;
            mx--;
        }
        tmp = M+2;
        mx = 2*M+1;
        while(tmp < mx) {
            cout << tmp << " " << mx << endl;
            tmp++;
            mx--;
        }
    }
}


Measured memory_bytes: 3548
import sys
input = sys.stdin.readline

N = int(input())
S = list(input().rstrip())

A = [0]
a = 0
for s in S:
    if s == ".":
        a += 1
    A.append(a)

B = A[-1]

ans = N+1
for i, a in enumerate(A):
    score = (i - a) + B - a
    ans = min(ans, score)

print(ans)

Measured memory_bytes: 18084
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H) {
		cout << "Yes" << "\n";
	} else {
		cout << "No" << "\n";
	}
}


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

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

  int maxv = -2000000000;
  int minv = R[0];

  for (int i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }

  cout << maxv << endl;

  return 0;
}


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

using namespace std;

int v[500000];

int main () {
        int n;

        scanf("%d", &n);

        for(int i = 0; i < n; i++) {
                scanf("%d", &v[i]);
        }
        long long resp = 0;
        
        int i = 0, j = 0;
        int temp = v[i];

        while(i < n) {
                if (j < i) {
                        j = i;
                        temp = v[i];
                }

                if ((j == n - 1) || ((temp & v[j + 1]) != 0)) {
                        resp += j - i + 1;
                        temp ^= v[i];
                        i++;
                } else {
                        temp ^= v[j + 1];
                        j++;
                }
        }
 
        printf("%lld\n", resp);

        return 0;
}


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

using namespace std;

int a[100000];

inline int read(){
    int ret,flag = 0;
    char c;
    while((c = getchar()) < '0' || c > '9') if(c == '-') flag = 1;
    ret = c - '0';
    while((c = getchar()) >= '0' && c <= '9') ret = (ret << 3) + (ret << 1) + c - '0';
    return flag ? -ret : ret;
}

int main(){
    int n,m;
    n = read();
    m = read();
    for(int i=1;i<=n;i++)
        a[i] = read();
    sort(a + 1,a + n + 1);
    int sum = 0;
    for(int i = n;i >= n-m+1;i--)
    sum += a[i];
    printf("%d",sum);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

bool is_ok_binarysearch_number(ll index, ll key) {
  index = index * (index + 1) / 2;
  return index >= key ? true : false;
}

ll binarysearch_number(ll key) {
  ll ng = 0;
  ll ok = 1000000001;

  while (abs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (is_ok_binarysearch_number(mid, key))
      ok = mid;
    else
      ng = mid;
  }

  return ok;
}

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

  int x;
  cin >> x;
  cout << binarysearch_number(x) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    ll n, k; cin >> n >> k;
    int res = 0;
    while (n > 0) {
        res++;
        n = n / k;
    }
    cout << res;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long q,a,b;
    cin>>a>>b;
    int x=a/b;
    long long ans=pow(x,3);
    q=0;
    if(b%2==0)
    {
        for(int i=1; i<=a; i++)
        {
            if(i%b==b/2)
                q++;
            //ans+=pow(q,3);
            //cout<<ans<<endl;
        }
    }
    ans+=pow(q,3);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
import copy
s = list(input())
t = []
t.append(s[0])
for i in range(1,len(s)):
    t.append('+')
    t.append(s[i])
# print(t)
# print(''.join(t))

sum = 0
for i in range(1 << (len(s)-1)):
    tmp = copy.deepcopy(t)
    for j in range(len(s)):
        if ( i >> j & 1 ):
            # print(j)
            tmp[(j+1)*2-1] = ''
            # print(eval(''.join(tmp)))
    sum += eval(''.join(tmp))
    # print(tmp)
    # print('loop end')
print(sum)

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-9;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i > 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()



int main() {
    ll n, a[MAX_N], ans[MAX_N]{};
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];

    for(int i=0;i<n;i++){
        if(i%2==0) ans[0] += a[i];
        else ans[0] -= a[i];
    }
    for(int i=0;i<n-1;i++){
        ans[i+1] = (a[i]-ans[i]/2)*2;
    }
    REP(i,n){
        cout << ans[i] << " \n"[i==n-1];
    }
    return 0;
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,ck;
    bool ck2;
    cin>>n;
    while(1){
        m=n;
        ck=m%10;
        ck2=true;
        while(m){
            if((m%10)!=ck) {
                ck2=false;
                break;
            }
            m/=10;
        }
        if(ck2){
            cout<<n<<endl;
            break;
        }
        n++;
    }
    cout<<endl;
    return 0;
}



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

int main()
{
    int N;
    cin >> N;
    vector<int> P(N, 0);
    for(auto&& p:P){
        cin >> p;
    }

    sort(P.begin(), P.end());

    int ans = 0;
    for (int i = 0; i < N; ++i)
    {
        if( i==N-1 ){
            ans += P[i] / 2;
        }else
        {
            ans += P[i];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(i=0;i<(n);i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(){
  int D, T, S;
  cin >> D >> T >> S;
  if((double)(D) / S <= T){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 3580
a,b,c,x,y=map(int,input().split())
if 2*c>=a+b:
  print(a*x+b*y)
else:
  ans=min(x,y)*c*2
  if x<=y:
    ans+=(y-x)*min(b,2*c)
  else:
    ans+=(x-y)*min(a,2*c)
  print(ans)
      


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
int main(){
    int n,k; cin >> n >> k;
    vector<ll> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(),h.end());
    vector<ll> dist(n-k+1);
    rep(i,n-k+1) dist[i] = h[i+k-1] - h[i];
    ll ans = 1e9 + 7;
    rep(i,n-k+1) if(ans > dist[i]) ans = dist[i];
    cout << ans << endl;
}

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

int main(){
    int N;
    cin >> N;
    vector<int64_t> A(N);
    for(int i=0; i<N; i++) cin >> A.at(i);
    int64_t sum=1;
    for(int i=0; i<N; i++){
        if(A.at(i) == 0){
            sum = 0;
            break;
        }
        if(1000000000000000000 / A.at(i) < sum){
            sum = -1;
            break;
        } 
        sum *= A.at(i);
    }
    for(int i=0; i<N; i++){
        if(A.at(i) == 0) sum = 0;
    }
    cout << sum << endl;

}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

struct edge{
    int src; int dst; int weight;
    edge() : src(0), dst(0), weight(0) {}
    edge(int s, int d, int w) : src(s), dst(d), weight(w) {}
};

using edges = V<edge>;
using graph = V<edges>;

void add_edge(edges &g,int s, int d, int w=1, bool undirected = true){
    g.pb(edge(s,d,w));
    if(undirected) g.pb(edge(d,s,w));
}
void add_edge(graph &g,int s, int d, int w=1, bool undirected = true){
    g[s].pb(edge(s,d,w));
    if(undirected) g[d].pb(edge(d,s,w));
}

struct unionFind{
    private:
        Vi data;
    public:
        unionFind(int size) : data(size,-1){}
        bool unionSet(int x,int y){
            x=root(x);y=root(y);
            if(x!=y){
                if(data[y]<data[x]){swap(x,y);}
                data[x]+=data[y]; data[y]=x;
            }
            return x!=y;
        }
        bool findSet(int x,int y){ return root(x)==root(y);}
        int root(int x){return ((data[x]<0)?x:(data[x]=root(data[x])));}
        int size(int x){return -data[root(x)];}
};

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    graph Friends(n),Blocks(n);
    unionFind U(n);
    REP(i,m){
        int a,b;
        cin>>a>>b;
        a--; b--;
        add_edge(Friends,a,b);
        U.unionSet(a,b);
    }

    REP(i,k){
        int c,d;
        cin>>c>>d;
        c--; d--;
        add_edge(Blocks,c,d);
    }

    Vi Candidate(n);
    REP(i,n){
        int block_j = 0;
        for(auto b : Blocks[i]) if(U.findSet(i,b.dst)) block_j++;
        
        int friend_j = 0;
        for(auto f : Friends[i]) if(U.findSet(i,f.dst)) friend_j++;

        Candidate[i] = U.size(i) - block_j - friend_j -1;
    }

    REP(i,n){
        cout<<Candidate[i]<<" ";
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 14644
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

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(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//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 SQ(a) ((a)*(a))
#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,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

int main() {
    int N = readInt();
    if(N%2==0){
        cout << N << endl;
    }else{
        cout << N*2 << endl;
    }
	return 0;
}

Measured memory_bytes: 256
s = input()

dp = [[0 for j in range(4)] for i in range(len(s)+1)]
dp[0][0] = 1
mod = 10**9+7
for i in range(len(s)):
    for j in range(4):
        dp[i+1][j] = dp[i][j]
        dp[i+1][j] %= mod
        dp[i][j] %= mod
    if s[i] == "A":
        dp[i+1][1] += dp[i][0]
    elif s[i] == "B":
        dp[i+1][2] += dp[i][1]
    elif s[i] == "C":
        dp[i+1][3] += dp[i][2]
    else:
        dp[i+1][0] += dp[i][0] * 2
        dp[i+1][1] += dp[i][1] * 2 + dp[i][0]
        dp[i+1][2] += dp[i][2] * 2 + dp[i][1]
        dp[i+1][3] += dp[i][3] * 2 + dp[i][2]

print(dp[-1][3]%mod)


Measured memory_bytes: 27600
import java.util.Scanner;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.TreeMap;
import java.util.TreeSet;
import java.math.BigInteger;
import java.util.Set;
 
public class Main {
	static Scanner scn = new Scanner(System.in);
	static int mod = 1000000007;
	//static int count = 0;
 
	public static void main(String[] args) {
		int h=scn.nextInt();
		int a=scn.nextInt();
		int count=1;
		while(h>a)
		{
			h=h-a;
			count++;
		}
		System.out.println(count);
	}
}

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

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

const ll inf = 1e15;
const ll mod = 1e9+7;

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

int main() {
    string s;
    cin >> s;
    
    ll K;
    cin >> K;
    
    vector<string> sub;
    
    ll n = s.length();
    rep(i, n) rep(j, 6) {
        if (j == 0) continue;
        sub.push_back(s.substr(i, j));
    }
    sort(sub.begin(), sub.end());
    unique(sub.begin(), sub.end());
    
    cout << sub[K - 1] << endl;
    
    return 0;
}


Measured memory_bytes: 1660
global t
t = 0

class Node:
    def __init__(self, num, deg, neib):
        self.num = num
        self.deg = deg
        self.neib = neib

def dfs(G, d, f, now): #now:1,2,...
    #print("now:",now)
    global t
    t += 1
    #print("t:",t)
    if d[now-1] != 0:
        t -= 1
        #print("has searched or hit roop")
    else:
        d[now-1] = t
        #print("d:",d)
        #print("f:",f)
        for i in G[now-1].neib:
            #print("i:",i)
            if i != -1:
                #print("next node")
                dfs(G, d, f, i)
            #else: print("end of branch")
        t += 1
        f[now-1] = t

        #print("f:",f)


dnum = int(input()) #頂点数
N = []
for i in range(dnum):
    data = input().split()
    
    u = int(data[0])
    k = int(data[1])
    if k > 0:
        v = list(map(int, data[2:]))
    else:
        v = [-1]

    node = Node(u,k,v)
    N.append(node)

d = [0]*dnum #find time
f = [0]*dnum #finish time

while 0 in d:
    s = d.index(0)
    dfs(N, d, f, s+1)
    #print("looks like finish")

for i in range(dnum):
    print(i+1, d[i], f[i])



Measured memory_bytes: 5732
L = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

K = int(input())

print(L[K-1])

Measured memory_bytes: 3060
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
int dist[100004],n,m;
bool vis[100004];
vector <int> v;
bool ok[1000004];
vector <int> t[100004];
void dfs(int x){
	if (vis[x])return;
	vis[x]=1;
	for (int i=0;i<t[x].size();i++)
		dfs(t[x][i]);
	v.push_back(x); 
} 
int main(){
	vector <int> tt;
	cin>>n>>m;
	for (int i=0;i<m;i++){
		int x,y; 
		cin>>x>>y;
		t[x].push_back(y); 
		ok[y]=1;
	}
	for (int i=1;i<=n;i++) if (!ok[i]) dfs(i);
	reverse (v.begin(),v.end());
	memset (dist,0,sizeof(dist));
	for (int i=0;i<n;i++){
		for (int j=0;j<t[v[i]].size();j++){
			dist[t[v[i]][j]]=max(dist[t[v[i]][j]],dist[v[i]]+1);
		}
 }
	int ans=0;
	for (int i=1;i<=n;i++)
		ans=max(ans,dist[i]);
	cout<<ans;
}

Measured memory_bytes: 9976
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
using namespace std;

typedef istringstream ISS;
typedef ostringstream OSS;
typedef vector<string> VS;
typedef int INT;
typedef vector<INT> VI;
typedef vector<VI> VVI;
typedef pair <INT, INT> II;
typedef vector <II> VII;

template<class T> ostream& operator << ( ostream& os, vector<T> v ) {
    for ( typename vector<T>::iterator it_i = v.begin(); it_i != v.end(); ++it_i ) {
        os << *it_i << ", ";
    }
    return os;
}


bool check( int hh, int mm ) {
    if ( hh == 17 ) {
        return mm >= 30;
    } else if ( hh == 19 ) {
        return mm <= 30;
    }
    return hh == 18;
}

const int T[7][7] = {
    { 0, 300, 500, 600, 700, 1350, 1650 },
    { 6, 0, 350, 450, 600, 1150, 1500 },
    { 13, 7, 0, 250, 400, 1000, 1350 },
    { 18, 12, 5, 0, 250, 850, 1300 },
    { 23, 17, 10, 5, 0, 600, 1150 },
    { 43, 37, 30, 25, 20, 0, 500 },
    { 58, 52, 45, 40, 35, 15, 0 }
};

int main() {
    int a, b, h1, m1, h2, m2;
    while ( cin >> a && a ) {
        cin >> h1 >> m1 >> b >> h2 >> m2;
        bool flag = check( h1, m1 ) || check( h2, m2 );
        a --;
        b --;
        int price = T[min(a,b)][max(a,b)];
        int dist = T[max(a,b)][min(a,b)];
        if ( flag && dist <= 40 ) price /= 2;
        if ( price % 50 > 0 ) price += 50;
        price -= price % 50;
        cout << price << endl;
    }
    return 0;
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int[]> table = new List<int[]>();

            string input;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                int[] temp = Array.ConvertAll(input.Split(','), int.Parse);
                table.Add(temp);
            }

            int m = table.Count / 2;

            for (int i = 1; i <= m; i++)
            {
                table[i][0] += table[i - 1][0];
                table[i][table[i].Length - 1] += table[i - 1][table[i].Length - 2];

                for (int j = 1; j < table[i].Length - 1; j++)
                {
                    table[i][j] += Math.Max(table[i - 1][j - 1], table[i - 1][j]);
                }
            }

            for (int i = m + 1; i < table.Count; i++)
            {
                for (int j = 0; j < table[i].Length; j++)
                {
                    table[i][j] += Math.Max(table[i - 1][j], table[i - 1][j + 1]);
                }
            }
            Console.WriteLine(table[table.Count - 1][0]);
        }
    }
}

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int N, K;
vector<ll> a;

bool need(int x) {
    if (a[x] >= K) return true; // 1枚でKを超えていたらxは必要

    // a[x]を除いた総和で[K-a[x], K)となるものがあるか調べる
    vector<bool> dp(K);
    dp[0] = true;
    rep(i, N) {
        if (i == x) continue; // a[x]は除く
        for (int j = K - 1; j >= 0; j--) {
            if (j + a[i] >= K) continue; // 総和がKを超えてしまう組み合わせはスキップする
            if (dp[j]) dp[j + a[i]] = true;
        }
    }

    for (int i = K - a[x]; i < K; i++) {
        if (dp[i]) return true;
    }
    return false;
}


int main() {
    cin >> N >> K;
    a.resize(N);
    rep(i, N) cin >> a[i];
    sort(a.begin(), a.end());

    int l = -1, r = N;
    while (r - l > 1) {
        int c = (l + r) / 2;
        if (need(c)) r = c; else l = c;
    }
    cout << r << endl;
}

Measured memory_bytes: 256
/*エラトステネスの篩  例題 ABC172D,ABC170
これは主にN以下の素数を全て書き出す時に用いるアルゴリズムであるが、
整数の約数、倍数などを書き出す時にも非常に効果的に利用することができる

「ある整数N以下の〇〇を求めてくれ」という問題に対して、1の倍数、2の倍数、、、と埋めていく（もちろん指定された値の場合もある）
この計算量は意外と早くて、NlogNで得られる。

例として、ABC170D問題をいかにあげる。
*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define double long double
#define rep(i, n) for (int i = 0; i < n; i++)
#include <math.h> /* M_PI */
#define INF 2147483647
#define N 1000000

int main()
{
    ll n;
    cin >> n;
    vector<ll> A(n);
    ll max1 = 0;
    rep(i, n)
    {
        cin >> A[i];
        max1 = max(A[i], max1);
    }
    vector<ll> data(max1 + 1); //indexがその数を表すようにする。
    for (ll x : A)
    {
        for (int j = 1; j <= max1 / x; j++)
        {
            data[x * j] += 1; //割り切れたら1
        }
    }
    ll count = 0;
    //これは違うな。そうではないだろ。
    for (ll x : A)
    {
        if (data[x] == 1)
        {
            count += 1;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 12740
/*Always success does not build on success,success build on failure*/
#include <bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vec         vector<int>
#define map         map<int,int>
#define scn(t)      scanf("%d",&t);
#define lscn(t)      scanf("%lld",&t);
#define mod         1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define endl        "\n"
using namespace std;
const int N=1e5+5;
int main()
{
    ll n,m;
    lscn(n);
    lscn(m);
    
    char ch[n][m];
    
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            cin>>ch[i][j];
        }
    }
    
    ll ans[n][m];
    
    memset(ans,0,sizeof(ans));
    ans[0][0]=1;
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<m;j++)
        {
            if(ch[i][j]=='.')
            {
                if(i+1<n&&ch[i+1][j]=='.')
                ans[i+1][j]=(ans[i][j]+ans[i+1][j])%mod;
                
                if(j+1<m&&ch[i][j+1]=='.')
                ans[i][j+1]=(ans[i][j]+ans[i][j+1])%mod;
            }
        }
    }
    cout<<ans[n-1][m-1];
}

Measured memory_bytes: 9088
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.Scanner;

class Main {
    static final int MOD = 1000000007;
    static final int INF = 1 << 30;

    Main() {
        Scanner sc = new Scanner(System.in);
        long ans = 0;
        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] A = new int[N];
        for(int i=0;i<N;i++){
            A[i]=sc.nextInt();
        }
        Arrays.sort(A);
        for(int i=N-1;i>=0;i--){
            if(K>0){
                K--;
                // ans++;
            }else{
                ans+=A[i];
            }
        }
        System.out.println(ans);
    }

    public static void main(String[] args) {
        new Main();
    }
}


Measured memory_bytes: 89560
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//　ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const int mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};

int gcd(int a, int b){
  if (a%b==0){
    return(b);
  }
  else{
    return(gcd(b,a%b));
  }
}


// ll memo[2020][2020];
// int pascal_triangle(){
//   for(int i = 0; i < 2020; i++){
//     for(int j = 0; j < i+1; j++){
//       if(j == 0 || j == i) memo[i][j] = 1;
//       else{
// 	memo[i][j] = (memo[i-1][j-1]+memo[i-1][j]);
//       }
//     }
//   }
//   return 0;
// }


int factorial(int n){
  if(n == 0) return 1;
  return n*factorial(n-1);
}

int divisor(int a){
  int cnt = 0;
  for(int i=1; i <= a; i++) if(a%i == 0) cnt++;
  return cnt;
}

int comb(int n, int k){
  return factorial(n) / (factorial(n-k)*factorial(k));
}

int cans(bool f){
  if(f) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}




int a[3];

int main(){
  string s;
  cin >> s;
  rep(i,3){
    a[s[i]-'a']++;
  }
  bool f = true;
  rep(i,3) if(a[i] == 0) f=false;
  cans(f);
}




Measured memory_bytes: 256
import java.util.*;
public class Main { 
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        String o="";
        char x=sc.next().charAt(0);
        if((int)x>=97&&(int)x<=122)o="a";
        else o="A";
        
      System.out.println(o);
    }
    
}

Measured memory_bytes: 35496
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N = int(input())
lis = [0]*4
for i in range(N):
    s = input()
    if s=='AC':
        lis[0] += 1
    elif s=='WA':
        lis[1] += 1
    elif s=='TLE':
        lis[2] += 1
    else:
        lis[3] += 1

lis2 = ['AC', 'WA', 'TLE', 'RE']
for cnt, name in zip(lis, lis2):
    print('{} x {}'.format(name, cnt))

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

template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
/*
最小のQ個を取り出すことは当然出来る
一番小さいのが1つだけ-LINFとかで飛び抜けてるとそれを避けるように動きたい
答えでの最小値Xを固定すると、いや微妙
各Yを固定してそれに対する答えを出す？
*/

signed main(){
  priority_queue<int,vector<int>,greater<int>> que,tmp;
  int N,K,Q,ans=1e9;cin>>N>>K>>Q;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];if(Q==1)fin(0);
  for(int i=0;i<N;i++){
    while(que.size())que.pop();
    while(tmp.size())tmp.pop();
    int Y=v[i],let=max(0,i-K+1)-1,out=0,rit;
    for(int j=max(0,i-K+1);j<i;j++)if(v[j]<Y)let=j;
    for(int j=i+1;j<=let+K;j++){
      if(j>=N)out++;
      else if(v[j]<Y)out++;
    }
    if(out)continue;
    let=0;
    while(true){//Yより小さいのが出るまでガーってやる
      int now=let;if(now==i)now++;
      while(now<N&&v[now]>=Y){
        que.push(v[now++]);
        if(now==i)now++;
      }
      rit=now;//[l,r)が区間
      while((int)(que.size())-K>=0){
        tmp.push(que.top());
        que.pop();
      }
      while(que.size())que.pop();
      if(rit==N)break;
      let=rit+1;
    }
    if(tmp.size()+1<Q)continue;
    for(int j=0;j<Q-2;j++)tmp.pop();ans=min(ans,tmp.top()-v[i]);
  }
  fin(ans);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long int ll;
ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
}
ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
ll n,m,arr[100006];
int main()
{
	ios;
	cin>>n>>m;
	for(int i=1;i<=n;++i)
	{
		cin>>arr[i];
	}
	ll now=1;
	for(int i=1;i<=n;++i)
	{
		now=lcm(now,arr[i]/2);
		if(now>m)break;
	}
	if(now>m){cout<<0<<'\n';return 0;}
	int flag=1;
	for(int i=1;i<=n;++i)
	{
		int temp=now*2/arr[i];
		if(temp%2==0){flag=0;break;}
	}
	if(flag==0){cout<<0<<'\n';return 0;}
	else
	{
		int num=m/now;
		if(num&1){cout<<num/2+1<<'\n';}
		else cout<<num/2<<'\n';
	}
}

Measured memory_bytes: 4408
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=1e5+5;
int a[maxn]={0};
int main()
{
	int n,t=0,f=1,sum=0;
	cin>>n;
	while(n--)
	{
		long long x;
		cin>>x;
		if(t==0)
		{
			f=1;
			a[t]=x;
			t++;
		}
		else if(t==1)
		{
			if(a[t-1]==x)
				t=0;
			else if(a[t-1]<x)
				f=1;
			else if(a[t-1]>x)
				f=-1;
			a[t]=x;
			t++;
		}
		else
		{
			if(f==1)
			{
				if(a[t-1]>x)
				{
					sum++;
					t=0;
					a[t]=x;
					t++;
				}
				else
				{
					a[t]=x;
					t++;
				}
			}
			else
			{
				if(a[t-1]<x)
				{
					sum++;
					t=0;
					a[t]=x;
					t++;
				}
				else
				{
					a[t]=x;
					t++;
				}
			}
		}
	}
	cout<<sum+1<<endl;
}

Measured memory_bytes: 640
#include <cstdio>

bool isProductOdd (int x, int y)
{
    if (x & y & 1 == 1) {
        return true; 
    }
    else {
        return false;
    }
}
int main ()
{
    int a, b;
    scanf("%d%d", &a, &b);
    if (isProductOdd(a, b)) {
        printf("Yes");
    }
    else {
        printf("No");
    }
}

Measured memory_bytes: 128
n=int(raw_input())
p=[]
w=0
for i in range(n):
    a,v=map(int,raw_input().split())
    p.append((a,v))
    w=max(w,v)
p.sort()
for i in p:
    if i[1]==w:
        print i[0],w
        exit()

Measured memory_bytes: 6384
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.nextLine());
		int[] k= new int[n];
		String[] line = sc.nextLine().split(" ");
		k[0]=Integer.parseInt(line[0]);
		k[1]=Integer.parseInt(line[1]);
		if(n==3){
			k[2]=Integer.parseInt(line[2]);
		}
		int answer;
		while(!(k[0]==k[1])){
			if(k[0]>k[1]){
				answer=k[0]-k[1];
				k[0]=answer;
			}else{
				answer=k[1]-k[0];
				k[1]=answer;
			}
		}
		if(n==3){
			while(!(k[0]==k[2])){
				if(k[0]>k[2]){
					answer=k[0]-k[2];
					k[0]=answer;
				}else{
					answer=k[2]-k[0];
					k[2]=answer;
				}
			}
		}
		for(int i=0;i<k[0];i++){
			if(k[0]%(i+1)==0){
				System.out.println(i+1);
			}
		}
	}
}



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

using namespace std;
typedef long long LL;

int main() {
  int N;
  cin >> N;

  vector<vector<int>> input(N, (vector<int>(N, 2)));
  for (int i = 0; i < N; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int x, y;
      cin >> x >> y;
      x--;
      input[i][x] = y;
    }
  }

  int maxim = 0;
  for (int bit = 0; bit < (1 << N); bit++) {
    vector<int> member, other;
    bool ok = true;
    for (int i = 0; i < N; i++) {
      if ((bit >> i) & 1)
        member.push_back(i);
      else
        other.push_back(i);
    }
    for (auto i : member) {
      for (auto j : member)
        if (input[i][j] == 0) ok = false;
      for (auto j : other)
        if (input[i][j] == 1) ok = false;
    }
    if (ok) maxim = max(maxim, (int)member.size());
  }
  cout << maxim << endl;

  return 0;
}

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

int main() {
  int a,b;
  cin>>a>>b;
  
  int z=a+b;
  if (z<a-b)
    z=a-b;
  
  if (z<a*b)
    z=a*b;
  
  cout<<z<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int N,X,T;
	cin >> N >> X >> T;
	if( N % X != 0) 
	cout << (N / X+ 1 ) * T << endl;
	else 
	cout << N / X * T << endl; 	
}


Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <time.h>
#include <stack>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <cassert>

using namespace std;

const int N = 105;
const int inf = 1000 * 1000 * 1000;
const int mod = 1000 * 1000 * 1000 + 7;

int n,m,q;
int answ[N][N];
int x,y,z;

int main(){
    scanf("%d%d%d",&n,&m,&q);
    x = 1;
    y = 1;
    z = 1;
    for(int i=1;i<=q;i++){
        int a;
        scanf("%d",&a);
        while(a--){
            answ[x][y] = i;
            if(z == 1){
                if(y == m){
                    x++;
                    z = -1;
                }
                else
                    y++;
            }
            else{
                if(y == 1){
                    x++;
                    z = 1;
                }
                else
                    y--;
            }
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            printf("%d ",answ[i][j]);
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	while(1){
		ll h,w; cin >> h >> w;
		if(!h && !w) break;
		ll mn = inf;
		ll t = h*h + w*w;
		P ans = P(150,150);
		REP(i,1,150){
			REP(j,i+1,151){
				ll u = i*i + j*j;
				if(t < u){
					if(u < mn) ans = P(i,j), mn = u;
					else if(u == mn && i < ans.first) ans = P(i,j), mn = u;;
				}else if(u == t){
					if(i > h){
						if(u < mn) ans = P(i,j), mn = u;
						else if(i < ans.first) ans = P(i,j);
					}
				}
			}
		}
		print2(ans.first,ans.second);
	}
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef string::const_iterator State;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int number(string s){
  int ret=0;
  for(int i=0;i<(int)s.size();i++){
    if(isdigit(s[i])){
      ret*=10;
      ret+=(s[i]-'0');
    }else{
      break;
    }
  }
  return ret;
}

int calc(int ret,int num,char x){
  if(ret==-1)return num;
  if(x=='+')return ret+num;
  if(x=='-')return ret-num;
  if(x=='*')return ret*num;
  if(x=='/')return ret/num;
}

int main(){
  int n;
  while(cin>>n,n){
    string s;
    vector<pair<int,string> > v(n);
    int maxi=0;
    rep(i,n){
      cin>>s;
      int cnt=0;
      for(int j=0;j<s.size();j++){
	if(s[j]=='.')cnt++;
      }
      maxi=max(maxi,cnt);
      s.erase(s.begin(),s.begin()+cnt);
      v[i].first=cnt;
      v[i].second=s;
    }
    maxi--;
    
    while(v.size()!=1){  
      bool update=false;
      for(int i=0;i<v.size();i++){
	int start;
        if(v[i].first==maxi&&!isdigit(v[i].second[0])){
	  start=i;
	  char c=v[i].second[0];
	  i++;
	  int ret=-1;
	  while(i<v.size()&&v[i].first==maxi+1){
	    // cout<<v[i].second<<endl;
	    ret=calc(ret,number(v[i].second),c);
	    i++;
	  }
	  v[start].second=to_string(ret);
	  v.erase(v.begin()+start+1,v.begin()+i);
	  update=true;
	  break;
	}
      }
      // cout<<"debug >> "<<endl;
      // for(auto x : v)cout<<x.first<<" "<<x.second<<endl;
      if(!update)maxi--;
    }
    cout<<v[0].second<<endl;
  }
  return 0;
}



Measured memory_bytes: 3256
x, y = map(int,input().split())
A = [1, 3, 5, 7, 8, 10, 12]
B = [4, 6, 9, 11]

if((x in A and y in A) or (x in B and y in B) or x == y == 2):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
using matrix = vector<vector<uint>>;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acos(-1);

struct edge {
    int to, cost, tm;
};

struct dat {
    ll dist;
    int v, coin;
};

inline bool operator>(const dat &a, const dat &b) {
    return a.dist > b.dist;
}

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

    int N, M, S;
    cin >> N >> M >> S;
    Graph<edge> G(N);
    vector<pii> change(N);
    for (int i = 0; i < M; ++i) {
        int U, V, A, B;
        cin >> U >> V >> A >> B;
        U--, V--;
        G[U].push_back({V, A, B});
        G[V].push_back({U, A, B});
    }
    for (int i = 0; i < N; ++i)
        cin >> change[i].first >> change[i].second;

    auto dijkstra = [&](int s = 0) {
        vector<vector<ll>> dist(N, vector<ll>(50 * N + 5, 1e18));
        dist[s][min(S, 50 * N)] = 0;
        priority_queue<dat, vector<dat>, greater<dat>> que;
        que.push({dist[s][min(S, 50 * N)], s, min(S, 50 * N)});
        while (!que.empty()) {
            dat tmp = que.top();
            que.pop();

            // 両替
            {
                int ncoin = min(tmp.coin + change[tmp.v].first, 50 * N);
                if (dist[tmp.v][ncoin] > tmp.dist + change[tmp.v].second) {
                    dist[tmp.v][ncoin] = tmp.dist + change[tmp.v].second;
                    que.push({dist[tmp.v][ncoin], tmp.v, ncoin});
                }
            }

            for (auto ne : G[tmp.v]) {
                int ncoin = tmp.coin - ne.cost;
                if (ncoin < 0)
                    continue;
                if (dist[ne.to][ncoin] <= tmp.dist + ne.tm)
                    continue;
                dist[ne.to][ncoin] = tmp.dist + ne.tm;
                que.push({dist[ne.to][ncoin], ne.to, ncoin});
            }
        }
        for (int i = 1; i < N; ++i) {
            ll mi = 1e18;
            for (int j = 0; j <= N * 50; ++j)
                mi = min(dist[i][j], mi);
            cout << mi << endl;
        }
    };

    dijkstra();
    return 0;
}


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

using namespace std;

int main() {
  int A, B;
  
  cin >> A >> B;
  string s, s2;
  int cnt = 0;
  for (int i = A; i <= B; i++) {
    s = to_string(i);
    s2 = s;
    reverse(s.begin(), s.end());
    if (s == s2) cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdlib.h>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
if(c<=0){
    cout<<"Yes";
    // break;
    exit(0);
}else if(a<=0){
    cout<<"No";
    exit(0);
    // break;
}else if(a<=0 && c<=0){
    cout<<"Yes";
    exit(0);
    // break;

}
while(a>0 || c>0){
    c=c-b;
    // cout<<"c"<<c;
    if(c<=0){
        cout<<"Yes";
        break;
    }
    a=a-d;
    // cout<<" "<<a;
    // cout<<"saaaaaaaaaaaaaaaaa";
     if( a<=0){
        cout<<"No";
        break;}
    

}
  


return 0; 
}

Measured memory_bytes: 3636
#include <cstdio>
#include <cstring>
#include <cmath>
#include <climits>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<long> vl;

#define COUT cout <<
#define SPACE_COUT << " "  <<
#define COMMA_COUT << ", " <<
#define ENDL << endl;

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

    long long N, T;
    vector<long long> M;
    vector<long long> A;
    cin >> N >> T;
    A.resize(N);
    M.resize(N);
    for (int i = 0; i < N; ++i) {
        long long tmp;
        cin >> tmp;
        A[i] = tmp;
        M[i] = 0;
    }
    M.push_back(A[N-1]);
    
    for (int i = N-1; i >= 0; --i)
        M[i] = max(M[i+1], A[i]);
    
    int total = 0;
    long long max_gap = 0;
    for (int i = 0; i < N; ++i) {
        long long value = M[i]-A[i];
        if (max_gap == value) {
            total++;
            continue;
        }
            
        if (max_gap < value) {
            total = 1;
            max_gap = value;
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;
const int N_MAX = pow(10, 5);
int main (void) {
    int N;
    int A[N_MAX] = {0};

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

    int cnt = 0;
    for (int i = 0; i < N_MAX; i++) {
        if (A[i] > 0) cnt += A[i] - 1;
    }
    int ans = cnt % 2 == 0 ? N - cnt : N - cnt - 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
import java.util.*;
class Main{
  public static void main(String[] s){
    Scanner sc = new Scanner(System.in);
    int a =sc.nextInt()+sc.nextInt()+sc.nextInt()-21;
    if(a>0){System.out.println("bust");}
    else{System.out.println("win");
        }
  }
}

Measured memory_bytes: 35692
#include<iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int chk = 0;
  for (int i = 0; i < 3; i++){
    if (s[i] == s[i+1])
      chk += 1;
  }
  if (chk == 0)
    cout << "Good" << endl;
  else
    cout << "Bad" << endl;
  return 0;
}

Measured memory_bytes: 256
n,k=gets.chomp.split(' ').map(&:to_i)
coin_percentage = 0.5
ans_ary = []
if n<=k
  n.times do |i|
    temp_percentage = 1/n.to_f
    temp_score = i+1
    while true
      if temp_score<k
        temp_score *=2
        temp_percentage *=coin_percentage
      else
        break
      end
    end
    ans_ary << temp_percentage
  end
else
  k.times do |i|
    temp_percentage = 1/n.to_f
    temp_score = i+1
    while true
        if temp_score<k
            temp_score *= 2
            temp_percentage *= coin_percentage
        else
            break
        end
    end
    ans_ary << temp_percentage
  end
  ans_ary << (n-k)/n.to_f
end
puts ans_ary.inject(0){|sum,num|sum+num}

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

int a(char x){ return x-'0'; }
int cal(string s){
  int h = a(s[0])*10 + a(s[1]), m = a(s[3])*10 + a(s[4]);
  return h*60+m;
}

int main(){
  int n,t;
  cin >> n >> t;

  vector<string> ansn;
  vector<int> anst;

  int bt = -1;
  for(int i=0;i<n;i++){
    string st, sn, et, en;
    cin >> st >> sn >> et >> en;
    int at = cal(st);

    if(i>0){
      if(at-bt >= t){
	ansn.push_back(sn);
	anst.push_back(at-bt);
      }
    }
    bt = cal(et);
  }

  cout << ansn.size() << endl;
  for(int i=0;i<(int)ansn.size();i++){
    cout << ansn[i] << " " << anst[i] << endl;
  }
}

Measured memory_bytes: 1236