akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
#include<assert.h>
typedef long long ll;
const ll inf=1e17;
ll f[3][2],g[3][2];
//f[i][j][k]:i~60 ok, %3=j, locked?
ll s[3];
void dp(ll n,ll m){//sum[i<=m & i in n & i%3=r]
	if(m<0){
		memset(s,0,sizeof(s));
		return;
	}
	int i,j;
	memset(f,0,sizeof(f));
	f[0][1]=1;
	for(i=60;i>=0;i--){
		memset(g,0,sizeof(g));
		for(j=0;j<3;j++){
			g[j][0]+=f[j][0];
			if(n>>i&1)g[(j+(1ll<<i))%3][0]+=f[j][0];
			if(m>>i&1){
				g[j][0]+=f[j][1];
				if(n>>i&1)g[(j+(1ll<<i))%3][1]+=f[j][1];
			}else
				g[j][1]+=f[j][1];
		}
		memcpy(f,g,sizeof(g));
	}
	for(i=0;i<3;i++)s[i]=f[i][0]+f[i][1];
}
ll get(ll n,ll l,ll r,int t){
	dp(n,r);
	ll s=::s[t];
	dp(n,l-1);
	return s-::s[t];
}
ll x[10010],y[10010];
int n;
const ll c=2*inf;
ll get(ll l,ll r,int t){
	ll s;
	int i;
	s=0;
	for(i=1;i<=n;i++)s+=get(c-x[i]-y[i],l-x[i],r-x[i],((t-x[i])%3+3)%3);
	return s;
}
bool C(ll n,ll k){return(n&k)==k;}
bool light(ll a){
	int i,f=0;
	for(i=1;i<=n;i++){
		if(x[i]<=a)f^=C(c-x[i]-y[i],a-x[i]);
	}
	return f;
}
int main(){
	int i;
	ll l,r,mid,x1,x2;
	bool flag;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%lld%lld",x+i,y+i);
	l=-inf;
	r=inf;
	while(l<r){
		mid=(l+r)>>1;
		flag=0;
		for(i=0;i<3;i++){
			if(get(l,mid,i)&1){
				flag=1;
				break;
			}
		}
		if(flag)
			r=mid;
		else
			l=mid+1;
	}
//	assert(light(l));
	x1=x2=l;
	for(i=60;i>=0;i--){
		if(light(x1-(1ll<<i)))x1-=1ll<<i;
		if(light(x2+(1ll<<i)))x2+=1ll<<i;
	}
	printf("%lld %lld",x1,c-x2);
}

Measured memory_bytes: 384
H, W = map(int, input().split())
S = [[s if s == '#' else 0 for s in input().rstrip()] for _ in range(H)]

for i in range(H):
    for j in range(W):
        count = 0
        if S[i][j] != '#':
            if i-1 >= 0:
                if S[i-1][j] == '#':  # top
                    count += 1
                if j-1 >= 0 and S[i-1][j-1] == '#':  # top_left
                    count += 1
                if j+1 < W and S[i-1][j+1] == '#':  # top_right
                    count += 1
            if j-1 >= 0 and S[i][j-1] == '#':  # mid_left
                count += 1
            if j+1 < W and S[i][j+1] == '#':  # mid_right
                count += 1
            if i+1 < H:
                if S[i+1][j] == '#':  # bottom_center
                    count += 1
                if j-1 >= 0 and S[i+1][j-1] == '#':  # bottom_left
                    count += 1
                if j+1 < W and S[i+1][j+1] == '#':  # bottom_right
                    count += 1
            S[i][j] += count

for row in S:
    for s in row:
        print(s, end="")
    print()

Measured memory_bytes: 3572
from collections import defaultdict
import heapq

N, M = [int(x) for x in input().split()]

dict = defaultdict(list)
for _ in range(N):
    A, B = [int(x) for x in input().split()]
    dict[A].append(B)

h = []
total = 0
for x in range(1, M + 1):
    for y in dict[x]:
        heapq.heappush(h, -y)
    if h:
        total += heapq.heappop(h)

print(-total)





Measured memory_bytes: 27684
#include <bits/stdc++.h>
#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__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int a,b,c;
    cin >> a >> b >> c;
    string y = "YES", n = "NO";
    int d = a%b;
    bool can = false;
    rep(i,1,100){
        if((d*i)%b==c) can = true;
    }
    if(can) cout << y << endl;
    else cout << n << endl;
}

Measured memory_bytes: 256
#include <iostream>

int GCD(int a, int b) {
  if (b == 0) return a;
  if (a < b) {
    int tmp = a;
    a = b;
    b = tmp;
  }
  return GCD(b, a % b);
}
int main() {
  int a, b;
  std::cin >> a >> b;
  std::cout << GCD(a, b) << std::endl;
}



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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef pair<LL, LL> PLL;
typedef vector<PLL> VPLL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
//#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SORT_DESC(c) sort((c).rbegin(),(c).rend())
#define REV(c) reverse((c).begin(), (c).end())
#define SIZE(a) int((a).size())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

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

void Main()
{
    LL a,b,c;cin>>a>>b>>c;
    LL x,y;cin>>x>>y;

    LL result = INF_LL;

    REP(i,max(x,y)+1){
        LL money = 0;
        money += c*i*2;
        money += a*max(0LL,x-i);
        money += b*max(0LL,y-i);
        result = min(result, money);
    }

    cout<<result<<endl;
	return;
}

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

Measured memory_bytes: 256
import math
N=int(input())
upperA = int(math.sqrt(2*N))
ceilA = 0
for i in range(upperA,-1,-1):
  if (i*(i+1) <= 2*N) and (2*N < (i+1)*(i+2)):
    ceilA = i+1
    break
nums = [x for x in range(1,ceilA+1)]
nums.remove(sum(nums)-N)
for num in nums:
  print(num)

Measured memory_bytes: 3572
N = int(input())
# ソートすればアナグラムは同じ文字列になる
s = [str(sorted(input())) for i in range(N)]

ans = 0

# 既に見た文字列 : 累計出現回数
cnt = {}

for i in range(N):
    # 既に見た文字列の場合
    if s[i] in cnt:
        # 既にn個ある時、新しく1個増えると組み合わせはn通り増える
        ans += cnt[s[i]]
        cnt[s[i]] += 1
    # 始めて見る文字列
    else:
        cnt[s[i]] = 1

print(ans)


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

typedef long long ll;

#define debug(x) cout << #x << '=' << x << endl;
#define debug_arr(a, n) for(ll i = 0; i < n; i++)cout << a[i] << ' '
#define inf 100000000000
#define loop(i,n) for(ll i = 0; i < n; i++)
#define graph vector<vector<ll>>
#define P pair<ll,ll>

using namespace std;

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

    string s;
    cin >> s;

    int revN = 0;
    loop(i,n-1){
        if(s[i] != s[i+1])revN++;
    }

    vector<int> a(revN+3, 0);

    int count;
    
    if(s[0] == '1'){
        count = 0;
        a[0] = 1;
        for(int i=1; i<n; i++){
            if(s[i] != s[i-1])count++;
            a[count]++;
        }
    }else{
        a[0] = 0;
        a[1] = 1;
        count = 1;
        for(int i=1; i<n; i++){
            if(s[i] != s[i-1])count++;
            a[count]++;
        }
    }

    int result = 0;
    int tmpSum = 0;
    int l=0,r=2*k;
    if(r >= a.size()){
        cout << n << endl;
        return 0;
    }

    for(int i=l; i<=r; i++){
        tmpSum += a[i];
    }
    result = tmpSum;
    while(1){
        if(r+2 >= a.size())break;
        tmpSum += a[r+1] + a[r+2];
        tmpSum -= a[l] + a[l+1];
        result = max(result,tmpSum);

        l+=2;
        r+=2;
    }

    cout << result << endl;
}

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

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

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

    int cnt[200010] = {};

    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        cnt[x-1]++;
    }
    sort(cnt, cnt+n);
    int ans = 0;
    for(int i = 0; i < n-k; i++){
        ans += cnt[i];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define endl '\n'
#define debug(x) std::cerr << #x << " = " << (x) << endl;

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::vector<ll> G[100010];
ll g[100010];

void dfs( ll v, ll p = -1 ) {
  g[v] = 0;

  for( auto u : G[v] ) if( u != p ) {
    dfs( u, v );

    g[v] ^= g[u]+1;
  }

  return;
}

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

  rep( i, N-1 ) {
    ll x, y;
    std::cin >> x >> y;
    --x; --y;

    G[x].emplace_back( y );
    G[y].emplace_back( x );
  }

  dfs( 0 );

  puts( g[0] ? "Alice" : "Bob" );

  return 0;
}

Measured memory_bytes: 16108
#include <bits/stdc++.h>
#define rep(i, a) for(int i = 0; i < a; i++)
#define all(v) v.begin(), v.end()
#define dcout cout << fixed << setprecision(15)
#define arep(i, a) for(auto i : x)
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
#define MOD 1000000007
#define INF 10000000000
#define int long long
#define KETA(n) floor(log10(n) + 1)
using namespace std;
signed main() {
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n + 1) {
        if(i % 3 == 0 || i % 5 == 0)
            continue;
        else
            ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <utility>
#include <numeric>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cmath>
#include <limits>
#include <cassert>

#define for0(i, N)    for (int i = 0  ; i <  (N); ++i)
#define for1n(i, N)   for (int i = 1  ; i <= (N); ++i)
#define for1(i, N)    for (int i = 1  ; i <  (N); ++i)
#define forn(i, N)    for (int i = 0  ; i <= (N); ++i)
#define forx(i, N, x) for (int i = (x); i <  (N); ++i)
#define forl(i, N, x, a) for (int i = (x), a = 0; a < (N);  \
                              i = (i + 1) % (N), ++a)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef priority_queue<ll> pq;
typedef priority_queue<ll,vector<ll>, greater<ll>> pql;
typedef stack<ll> stk;
typedef queue<ll> qu;
typedef pair<ll, ll> pll;
typedef map<ll, ll> mll;
typedef unordered_map<ll, ll> umll;
typedef set<ll> sll;
typedef unordered_set<ll> usll;


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

    int m1, d1, m2, d2;

    cin >> m1 >> d1 >> m2 >> d2;

    cout << (m1 == m2 ? 0 : 1);

    return 0;
}


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

using namespace std;
typedef pair<int,int> p;

int main(void){
  int n,a,b,c;
  cin >> n;
  int v[n][n];
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      v[i][j]=0;
    }
  }
  for(int i=0;i<n;i++){
    cin >> a >> b;
    for(int j=0;j<b;j++){
      cin >> c;
      v[a-1][c-1]=1;
    }
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(v[i][j]!=1)cout << 0;
      else cout << v[i][j];
      if(j!=n-1)cout << ' ';
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3072
/*
author : seryu
title : ABC175B_"Making Triangle"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
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; }

void solve()
{
    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];
    int ans = 0;
    sort(all(l));
    rep(i, n)mrep(j, i+1, n)mrep(k, j+1, n)
    {
        if(l[i] + l[j] > l[k] && l[i] != l[j] && l[j] != l[k])ans++;
    }
    cout << ans << endl;
    return;	
}

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


Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <cmath>

typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
using namespace std;

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int max_n = max(A, max(B, C));
    cout << A + B + C + (pow(2, K) - 1) * max_n << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<int> A(n);
  vector<int> B(n);
  for (int i=0; i<n; i++) {
    cin >> A.at(i);
  }
  for (int i=0; i<n; i++) {
    cin >> B.at(i);
  }
  int x=0;
  for (int i=0; i<n; i++) {
    if (A.at(i) > B.at(i)) {
      x+=A.at(i)-B.at(i);
    }
  }
  cout << x << endl;
  return 0;
}


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

using namespace std;
typedef long long ll;

struct mint{
    static const long long MOD = 1000000007;

    long long v;

    mint() : v(0) {}
    mint(long long x){
        x = x % MOD;
        if(x < 0){ x += MOD; }
        v = x;
    }
    mint& operator+=(mint a){
        v += a.v;
        if(v >= MOD){ v -= MOD; }
        return *this;
    }
    mint& operator*=(mint a){
        v *= a.v;
        v %= MOD;
        return *this;
    }
    mint& operator-=(mint a){
        v -= a.v;
        if(v < 0){ v += MOD; }
        return *this;
    }
    mint& operator/=(mint a){
        return (*this) *= a.inv();
    }

    mint operator*(mint a) const{
        return mint(v) *= a;
    }

    mint operator+(mint a) const {
        return mint(v) += a;
    }

    mint operator-(mint a) const {
        return mint(v) -= a;
    }

    mint operator/(mint a) const {
        return mint(v) /= a;
    }

    mint pow(long long k) const {
        mint res(1),tmp(v);
        while(k){
            if(k&1) res *= tmp;
            tmp *= tmp;
            k >>= 1;
        }
        return res;
    }
    mint inv(){return pow(MOD - 2); }

    static mint comb(long long n, int k){
        mint res(1);
        for(int i = 0; i < k; ++i){
            res *= mint(n - i);
            res /= mint(i + 1);
        }
        return res;
    }

    static mint factorial(long long n){
        mint res(1);
        for(int i = n; i > 1; --i){
            res *= mint(i);
        }
        return res;
    }

    bool operator<(const mint &a) const {
        return v < a.v;
    };
};

mint operator*(long long l, mint r){ return r * l; }

vector<vector<int>> a;
mint dp[21][1 << 21];
bool flg[21][1 << 21];

mint calc(ll i, ll s){
    if(i >= a.size()){
        return 1;
    }
    if(flg[i][s]){
        return dp[i][s];
    }
    mint ret = 0;
    for(int j = 0; j < a.at(i).size(); ++j){
        if(a.at(i).at(j) == 0){
            continue;
        }
        if((s >> j) & 1){
            continue;
        }
        ret += calc(i + 1, s | (1 << j));
    }
    flg[i][s] = true;
    dp[i][s] = ret;
    return ret;
}

int main(){
    ll n;
    cin >> n;
    a.resize(n, vector<int>(n, 0));
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            cin >> a.at(i).at(j);
        }
    }

    cout << calc(0, 0).v << endl;

    return 0;
}

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

int n;
map<int,ll> mp;

int main() {
  cin>>n;
  for (int i=0; i<n; i++) {
    int a,b; cin>>a>>b;
    mp[b]+=a;
  }
  int lo = 0;
  for (auto p: mp) {
    int deadline = p.first;
    ll len = p.second;

    if (len > deadline-lo) {
      cout<<"No"; return 0;
    }
    lo += len;
  }
  cout<<"Yes";
}


Measured memory_bytes: 12800
#include <iostream>
#define INF 1e+9
using namespace std;

int n,w[1000],c[1000],imos[1001] = {};
bool dp1[1000][1000];
int dp2[1001];

int main(){
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> c[i] >> w[i];
		imos[i + 1] = imos[i] + w[i];
		dp1[i][i] = true;
		dp2[i + 1] = INF;
	}
	for(int i = 1;i < n;i++){
        for(int j = 0;j < n - i;j++){
            if((c[j + i] >= imos[j + i] - imos[j] && dp1[j][j + i - 1]) || (c[j] >= imos[j + i + 1] - imos[j + 1] && dp1[j + 1][j + i])) dp1[j][j + i] = true;
            else dp1[j][i + j] = false;
        }
    }
	for(int i = 1;i <= n;i++){
		for(int j = 0;j <= i;j++){
			if(dp1[j][i - 1]) dp2[i] = min(dp2[i],dp2[j] + 1);
		}
	}
	cout << dp2[n] << endl;
	return 0;
}

Measured memory_bytes: 4084
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    w=list(input())
    if all(w.count(i)%2==0 for i in w):
        print('Yes')
    else:
        print('No')
resolve()

Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
    int a,b,c,d,e,f,abc[121];
    for(a=1;a<=120;a++){
        abc[a]=0;
    }
    scanf("%d",&e);
    for(f=1;f<=e;f++){
        scanf("%d%d%d%d",&a,&b,&c,&d);
        abc[a*30+b*10+c-40]+=d;
    }
    b=1;
    do{
        printf(" %d",abc[b]);
        if(b%10==0){
            printf("\n");
        }
        switch(b){
            case 30:
            case 60:
            case 90:
                printf("####################\n");
                break;
        }
        b++;
    }while(b<=120);
    return 0;
}


Measured memory_bytes: 2132
let  lines: number[] = [];
const reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', function (line: string) {
  lines = line.split(/\s/).map(i => parseInt(i));
});
reader.on('close', function() {
  let [a, b]: number[] = lines;
  if (b % a === 0) console.log(a + b);
  else console.log(b - a);
});

Measured memory_bytes: 11596
import sys
import os

MOD = 10 ** 9 + 7


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    a = int(sys.stdin.buffer.readline().rstrip())
    s = sys.stdin.buffer.readline().decode().rstrip()
    print(s if a >= 3200 else 'red')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#B
NM = input().split(' ')
N = int(NM[0]) ; M = int(NM[1])
Ai = input().split(' ')
all_A = 0
for k in Ai:
    all_A += int(k)
line = all_A / (4*M)
count = 0
for k in Ai:
    if int(k) >= line:
        count += 1
if count >= M:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream>
#include <math.h>
#include <string>
#include <algorithm>
using namespace std;
int kaijo(int n){
	int ans = 1;
	if (n != 0){
		for (int i = 0; i < n; i++){
			ans *= (n - i);
		}
	}
	else{
		ans = 1;
	}
	return ans;
}

int main(){
	int n;
	string s;
	string a;
	string b;
	cin >> s;
	n = s.size() - 2;
	a=s[0];
	b = s[s.size() - 1];
	cout << a<<n<<b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <math.h>
#include<bitset>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(void){
    bool flag = false;
    int n;
    cin >> n;

    rep(i,9){
        rep(j,9){
            if(n==((i+1)*(j+1))){
                flag = true;
            }
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
  n=int(input())
  uvw=[list(map(int,input().split())) for _ in range(n-1)]
  ki=[[] for _ in range(n)]
  for u,v,w in uvw:
    ki[u-1].append((v-1,w))
    ki[v-1].append((u-1,w))
  todo=[0]
  seen=[-1]*n
  seen[0]=0
  while len(todo)>0:
    a=todo.pop()
    l=ki[a]
    for li in l:
      if seen[li[0]]==-1:
        seen[li[0]]=seen[a] if li[1]%2==0 else (seen[a]+1)%2
        todo.append(li[0])
  for s in seen:
    print(s)
if __name__=='__main__':
  main()


Measured memory_bytes: 58572
#include<iostream>
using namespace std;
int x[10][2],sum[2],c,d;
int main(){
for(int i=0;i<20;i++){cin>>x[i%10][i/10];}
for(int i=9999;i>=0;i--){if(c>=3){break;}
for(int j=0;j<10;j++){if(x[j][0]==i){c++;sum[0]+=x[j][0];}}}
for(int i=9999;i>=0;i--){if(d>=3){break;}
for(int j=0;j<10;j++){if(x[j][1]==i){d++;sum[1]+=x[j][1];}}}
cout<<sum[0]<<' '<<sum[1]<<endl;}

Measured memory_bytes: 1160
#include<stdio.h>

int main(void) {
	int n, m, l;
	int i, j, k;
	int a[100][100], b[100][100];
	double c[100][100] = { 0 };

	scanf("%d %d %d", &n, &m, &l);
	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			scanf("%d", &a[i][j]);
		}
	}
	for (j = 0; j < m; j++) {
		for (k = 0; k < l; k++) {
			scanf("%d", &b[j][k]);
		}
	}
	for (i = 0; i < n; i++) {
		for (k = 0; k < l; k++) {
			for (j = 0; j < m; j++) {
				c[i][k] += a[i][j] * b[j][k];
			}
		}
	}
	for (i = 0; i < n; i++) {
		for (k = 0; k < l; k++) {
			if (k != 0) printf(" ");
			printf("%.0f", c[i][k]);
		}
		puts("");
	}
	return 0;
}


Measured memory_bytes: 2116
#include <iostream>
using namespace std;
#define BET 100

int main(int argc, char *argv[])
{
    int n, m, p, x, num, win, total, res;
    while (cin >> n >> m >> p, n | m | p) {
        total = res = 0;
        m--;
        for (int i = 0; i < n; ++i) {
            cin >> x;
            if (i == m)
                win = x;
            total += x;
        }
        if (win != 0)
            res = total * BET * (100 - p) / win / 100;
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;

const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int n;
    cin>>n;
    int a[n];
    int mi =INF;
    int cnt =0;
    ll ans=0;
    rep(i,n){
        cin>>a[i];
        if(a[i]<0)cnt++;
        mi=min(mi,abs(a[i]));
        ans+=abs(a[i]);
    }
    if(cnt%2==0){
        cout<<ans<<endl;
    }
    else{
        cout<<ans-mi-mi<<endl;
    }
    }

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount


int32_t main(){
	string s,t,u;
	int a,b;
	cin>>s>>t>>a>>b>>u;
	if(u==s){
		cout<<a-1<<" "<<b;
	}
	else {
		cout<<a<<" "<<b-1;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

int n;
int a[200005];
int nax1 = -1, nax2 = -2;

int main() {
  ios_base::sync_with_stdio(false);
  cin >> n;
  for(int i = 1; i <= n; i++)
    cin >> a[i];
  
  for(int i = 1; i <= n; i++) {
    if(nax1 < a[i]) {
      nax2 = nax1;
      nax1 = a[i];
    } else if(nax2 < a[i]) {
      nax2 = a[i];
    }
  }
  for(int i = 1; i <= n; i++) {
    if(a[i] == nax1) cout << nax2 << endl;
    else cout << nax1 << endl;
  }
}


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

#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

typedef long long ll;
typedef array<int, 3> tri;
typedef long double ld;

template <class T> istream& operator>>(istream& I, vector<T>& v) {for (T &e: v) I >> e; return I;}
template <class T> ostream& operator<<(ostream &O, const vector<T>& v) {for (const T &e: v) O << e << ' '; return O;}



void _main() {
        int n; cin >> n;
        ll ans = 0;
        int neg = 0;
        int m = 1e9;
        while (n--) {
                int x; cin >> x;
                ans += abs(x);
                neg += x < 0;
                m = min(m, abs(x));
        }


        if (neg & 1) ans -= 2 * m;

        cout << ans;
}



signed main() {
        ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//        freopen("input.txt", "r", stdin);
        int _t = 1;
//        cin >> _t;
        while (_t--) _main();
        return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string t;cin>>t;
    for(char c:t){
        if(c=='?')cout<<'D';
        else cout<<c;
    }
    return 0;
}

Measured memory_bytes: 3736
s = input()
x, y = list(map(int, input().split()))
F = [len(fs) for fs in s.split('T')]
x -= F[0]
Fx = F[2::2]
Fy = F[1::2]

xt2 = sum(Fx)-x
yt2 = sum(Fy)-y
if xt2%2==1 or yt2%2==1 or xt2<0 or yt2<0:
    print('No')
    exit()

xt = xt2//2
yt = yt2//2

dpx = [False]*(xt+1)
dpx[0] = True
for f in Fx:
    for i in range(xt, f-1, -1): dpx[i] |= dpx[i-f]

dpy = [False]*(yt+1)
dpy[0] = True
for f in Fy:
    for i in range(yt, f-1, -1): dpy[i] |= dpy[i-f]

print('Yes' if dpx[xt] and dpy[yt] else 'No')

Measured memory_bytes: 3188
import heapq
for _ in range(int(input())):
    N=int(input())
    ListL=[[] for _ in range(N)]
    ListR=[[] for _ in range(N)]
    ans=0
    for _ in range(N):
        k,l,r=map(int,input().split())
        ans+=min(l,r)
        if l>=r:
            ListL[k-1].append(abs(l-r))
        else:
            ListR[k-1].append(abs(l-r))
    S=[]
    for n,L in enumerate(ListL,1):
        for l in L:
            if len(S)<n:
                heapq.heappush(S,l)
            else:
                heapq.heappushpop(S,l) 
    ans+=sum(S)
    S=[]
    for n,L in enumerate(ListR[::-1][1:],1):
        for l in L:
            if len(S)<n:
                heapq.heappush(S,l)
            else:
                heapq.heappushpop(S,l) 
    ans+=sum(S)

    print(ans)

Measured memory_bytes: 49648
#include <iostream>
using namespace std;
int main()
{
  int K, A, B;
  cin >> K >> A >> B;
  for(int i=A; i<=B; i++)
  {
    if(i%K==0)
    {
      cout << "OK";
      return 0;
    }
  }
  cout << "NG";
  return 0;
}

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

using namespace std;
using int64 = long long;

struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;

int main() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n+x-1)/x * t << endl;
}


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

int main(){
  int n, d;
  cin >> n >> d;
  int count = 0;

  
  for(int i = 0; i < n; i++){
    int x, y;
    cin >> x >> y;
    
    if(sqrt(pow(x, 2) + pow(y, 2)) <= d) count++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N;
    cin >> N;
    vector<double> v(N);
    rep(i,N){
        cin >> v[i];
    }
    sort(all(v));
    while(N>1){
        v[1]=(v[0]+v[1])/2;
        v.erase(v.begin());
        sort(all(v));
        N--;
    }
    cout << v[0];

}

/*



 */



Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int D;
int p[10];
int c[10];
int G;

void solve(){
	int ans = 10000000;
	rep(i, 1 << D){
		int bit = 1;
		int cnt = 0;
		int s = 0;
		int b[10] = {};
		rep(j, D){
			if(i & bit){
				cnt += p[j];
				s += p[j] * (j + 1) * 100 + c[j];
				b[j] = p[j];
			}
			bit <<= 1;
		}
		if(s < G){
			repr(j, D){
				while(b[j] != p[j]){
					s += (j + 1) * 100;
					cnt++;
					b[j]++;
					if(b[j] == p[j])
						s += c[j];
					if(s >= G){
						j = -1;
						break;
					}
				}
			}
		}
		chmin(ans, cnt);
	}
	cout << ans << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> D >> G;
	rep(i, D) {
		cin >> p[i] >> c[i];
	}
		solve();
	return 0;
}


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

int main(){
  int flag=0;
  char s[5];

  cin >> s;

  for(int i=0;i<3;i++){
    if(s[i]==s[i+1]){
      flag=1;
    }
  }

  if(flag==0){
    cout << "Good\n";
  }else{
    cout << "Bad\n";
  }

  return 0;
}


Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn f(p: i64) -> f64 {
    ((p + 1) as f64) / 2.0
}

fn main() {
    let (N, K) = read!(usize, usize);
    let P = read![[i64]];

    let mut current = P[0..K].iter().cloned().map(f).sum::<f64>();

    let mut i = K;
    let mut m = 0.0;
    while i <= N {
        if m < current {
            m = current;
        }

        if i == N {
            break;
        }

        {
            let p = P[i - K];
            current -= f(p);
        }

        {
            let p = P[i];
            current += f(p);
        }

        i += 1;
    }

    println!("{}", m)
}


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

using namespace std;



bool is_prime(int x)
{
  if (x <= 1) return false;
  if (x == 2) return true;

  if (x % 2 == 0)return false;

  for (int i = 3; i * i <= x; i += 2)
  {
    if (x % i == 0) return false;
  }

  return true;
}


void next_prime()
{
  int x;
  cin >> x;

  int prime = x;
  while (!is_prime(prime)) prime++;

  cout << prime << "\n";
}


int factorial(int n)
{
  int fact = 1;
  for (int i = n; i > 0; i--) fact *= i;
  return fact;
}


int calc_order(int n, vector<int> x)
{
  int cnt = 0;
  for (int i = 0; i < n; i++)
  {
    cnt += (x[i] - 1) * factorial(n - 1 - i);
    for (int j = i + 1; j < n; j++) {
      if (x[j] > x[i]) x[j]--;
    }
  }
  return cnt;
}


void count_order()
{
  int n;
  cin >> n;

  vector<int> p(n);
  vector<int> q(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  for (int i = 0; i < n; i++) cin >> q[i];

  int p_cnt = 0, q_cnt = 0;
  p_cnt = calc_order(n, p);
  q_cnt = calc_order(n, q);

  cout << abs(p_cnt - q_cnt);
}




int main()
{
  next_prime();
  //count_order();
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(){
    int n, x;

    while(1){
        scanf("%d %d", &n, &x);
        if((n==0)&&(x==0)){
            break;
        }
        else{
            int num = 0;
            for(int i=1; i<=n; i++){
                for(int j=i+1; j<=n; j++){
                    for(int k=j+1; k<=n; k++){
                        if(i+j+k == x){
                            num = num + 1;
                        }
                    }
                }
            }
            printf("%d\n", num);
        }
    }


    return 0;
}


Measured memory_bytes: 2036
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
#include<vector>
using namespace std;

int n, k;
map<int, vector<int>> m;
vector<vector<int>*> v;
priority_queue<int> p;

int main() {
    scanf("%d %d", &n, &k);
    for (int i = 0; i < n; i++) {
        int t, d;
        scanf("%d %d", &t, &d);
        m[t].push_back(d);
    }
    for (map<int, vector<int>>::iterator i = m.begin(), e = m.end();
         i != e; i++) {
        sort(i->second.begin(), i->second.end());
        v.push_back(&i->second);
    }
    sort(v.begin(), v.end(), [](const vector<int> *v1, const vector<int> *v2)->bool {
        return v1->back() > v2->back();
    });
    int vs = (k <= v.size()) ? k : v.size();
    int ans[k];
    for (int i = 0; i < vs; i++) {
        ans[i] = v[i]->back();
        v[i]->pop_back();
    }
    for (int i = 0; i < vs; i++) {
        for (vector<int>::iterator j = v[i]->begin(), e = v[i]->end(); j != e; j++) {
            p.emplace(*j);
        }
    }
    for (int i = vs; i < k; i++) {
        ans[i] = p.top();
        p.pop();
    }
    int x = vs;
    while(true) {
        if (p.empty() || ans[x - 1] + 2 * x - 1 >= p.top()) break;
        ans[--x] = p.top();
        p.pop();
    }
    long sum = 0;
    for (int i = 0; i < k; i++) sum += ans[i];
    sum += static_cast<long>(x) * x;
    printf("%ld\n", sum);
    return 0;
}


Measured memory_bytes: 12408
package main

import (
	"fmt"
)

func main() {
	var a, b, c, d int
	fmt.Scanf("%d %d %d %d", &a, &b, &c, &d)

	a--
	n := b - a

	C := b/c - a/c
	D := b/d - a/d

	l := (b / (c * d / gcb(c, d))) - (a / (c * d / gcb(c, d)))

	ans := n - (C + D - l)
	fmt.Print(ans)
}

func gcb(c, d int) int {
	if c == 0 {
		return d
	} else if d == 0 {
		return c
	}
	return gcb(d, c%d)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod =1e9+7;
int dp[110][5][5][5];
int main()
{
   int n;
   scanf("%d",&n);
   dp[0][3][3][3]=1;
   for(int i=0;i<n;i++)
    for(int a=0;a<4;a++)
     for(int b=0;b<4;b++)
      for(int c=0;c<4;c++)
        for(int d=0;d<4;d++)
   {
       if(b==0&&c==1&&d==2)continue;
       if(b==1&&c==0&&d==2)continue;
       if(b==0&&c==2&&d==1)continue;
       if(a==0&&c==1&&d==2)continue;
       if(a==0&&b==1&&d==2)continue;

       dp[i+1][b][c][d]+=dp[i][a][b][c];
       dp[i+1][b][c][d]%=mod;
   }
   ll ans=0;
   for(int a=0;a<4;a++)
     for(int b=0;b<4;b++)
       for(int c=0;c<4;c++)
       {
           ans+=dp[n][a][b][c];ans%=mod;
       }
       printf("%lld\n",ans);
   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
vector<int> v[200001];
bool vis[200001];
int l1;
void dfs(int x)
{
  if(vis[x]) return ;
  vis[x]=1;l1++;
  for(int i=0;i<v[x].size();i++)
  {
    if(!vis[v[x][i]])
     dfs(v[x][i]);
  }
}
int32_t main()
{
  int t,n,i,j,k,m,l=0,max1=0;
  cin>>n>>m;
  for(i=1;i<=m;i++)
  {
    cin>>j>>k;
    v[j].push_back(k);
    v[k].push_back(j);
  }
  memset(vis,0,sizeof(vis));
  for(i=1;i<=n;i++)
  {
    if(!vis[i])
    {
      l1=0;
      dfs(i);
      max1=max(max1,l1);
    }
  }
  cout<<max1;
}

Measured memory_bytes: 20976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e14;
const ll mod = 1e9+7;
// __uint128_t



int main(){
    ll M, D; cin >> M >> D;
    ll ans = 0;
    vector<bool> Mem(105);
    for(int i = 10; i <= D; i++){
        if(i >= 10){
            ll d1 = i%10, d10 = i / 10;
            if(d10 >= 2 && d1 >= 2){
                ll m = d10*d1;
                if(m <= M) ans++;
            }
        }
    }
    cout << ans << endl;
}

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

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try{
	    int m, d;
	    while(true){
		String[] day= {"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
		String[] st = sc.readLine().split(" ");
		m = Integer.valueOf(st[0]);
		d = Integer.valueOf(st[1]);
		if(m==0 && d==0)
		    break;
		if(m>1){
		    d+=31;
		    if(m>2){
			d+=29;
			if(m>3){
			    d+=31;
			    if(m>4){
				d+=30;
				if(m>5){
				    d+=31;
				    if(m>6){
					d+=30;
					if(m>7){
					    d+=31;
					    if(m>8){
						d+=31;
						if(m>9){
						    d+=30;
						    if(m>10){
							d+=31;
							if(m>11)
							    d+=30;
						    }}}}}}}}}}
		System.out.println(day[d%7]);
	    }
	}catch (Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9348
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    string nap;
    cin >> nap;
    int n = nap.size();
    if (nap[0] == nap[n - 1])
    {
        if (n % 2 == 0)
            cout << "First";
        else
            cout << "Second";
    }
    else
    {
        if (n % 2 == 0)
            cout << "Second";
        else
            cout << "First";
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>   // #include<bits/stdc++.h>
using namespace std;       //using namespace std;
int main()                 //int main ()
{                          //{
	int n,h,s=0;           //int n,h,s=0;
	cin>>n;                //cin >>n;
	int a,b;               //int a,b;
	cin>>a>>b;              //cin >>a>>b;
	for (int i=1;i<=n; i++) //for (int i=1; i<=n; i++)
	{                       //{
		int p=0;            //int p=0;
		h=i;                //h=i;
		while (h!=0)        //while (h!=0)
		{                   //{
			p+=h%10;        //p+=h%q10;
			h/=10;          //h/=10;
		}                   //}
		if(p>=a&&p<=b)      //if (p>=a&&p<=b)
		{                   //{
			s+=i;           //s+=i;
		}                   //}
	}                       //}
	cout<<s<<endl;          //cout <<s<<endl;
	return 0;               //return 0;
}                           //}

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

#define in_fre freopen("redir.txt", "r", stdin);
#define out_fre freopen("out5.txt", "w", stdout);
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define debug(i) printf("\nDebug %d\n",i);
#define mod 1000000007
#define ll long long int

int main()
{	
clock_t begin, end;
double time_spent;
begin = clock();

//	fast();
#ifndef ONLINE_JUDGE
	in_fre
	out_fre
#endif

long long int n;
  cin>>n;
  string t;
  cin>>t;
  if(t.length()<=n)
    cout<<t<<"\n";
  else{
  	for(long long int i=0;i<n;i++)
      cout<<t[i];
    //for(long long int i=n;i<t.length();i++)
      cout<<"...";
  }

end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
cerr<<"Time spent = "<<time_spent<<endl;

return 0;
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll N; cin >> N;
  vector<ll> a(N); REP(i, N) cin >> a[i];
  string ans = "second";
  REP(i, N) {
    if(a[i] % 2 == 1) ans = "first";
  }
  cout << ans << endl;
}

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

int main() {
  string s, t;
  cin >> s;
  
  if (s == "Sunny") t = "Cloudy";
  else if(s == "Cloudy") t = "Rainy";
  else t = "Sunny";
  
  cout << t << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int nm , dgtsm = 0 , tmp;
  cin >> tmp;
  nm = tmp;
  while(tmp != 0){
    dgtsm += tmp % 10;
    tmp /= 10;
  }
  if (nm % dgtsm == 0) cout << "Yes"<< endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Twinkle Twinkle Little Star
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AFiveAntennas solver = new AFiveAntennas();
        solver.solve(1, in, out);
        out.close();
    }

    static class AFiveAntennas {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            int c = in.nextInt();
            int d = in.nextInt();
            int e = in.nextInt();
            int k = in.nextInt();
            boolean flag = true;
            if (Math.abs(a - b) <= k && Math.abs(a - c) <= k && Math.abs(a - d) <= k && Math.abs(a - e) <= k
                    && Math.abs(b - c) <= k && Math.abs(b - d) <= k && Math.abs(b - e) <= k &&
                    Math.abs(c - d) <= k && Math.abs(c - e) <= k && Math.abs(d - e) <= k)
                out.println("Yay!");
            else out.println(":(");
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

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

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

    }
}



Measured memory_bytes: 22868
import java.util.*;

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

		int N = sc.nextInt();
		int M = sc.nextInt();

		int maxL = 0;
		int minR = 0;
		for(int i=0; i<M; i++) {
			if(i == 0) {
				maxL = sc.nextInt();
				minR = sc.nextInt();
			} else {
				int L = sc.nextInt();
				int R = sc.nextInt();

				maxL = maxL < L ? L : maxL;
				minR = minR > R ? R : minR;
			}
		}

		int count = maxL>minR ? 0 : minR-maxL+1;
		println(count);
	}

	public static void println(Object o) {
		System.out.println(o);
	}
}

Measured memory_bytes: 64688