akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define floop(i,a,n) for (int i=a;i<n;i++)
#define rfloop(i,a,n) for (int i=n-1;i>=a;i--)
#define mloop(it,x) for(it=x.begin();it!=x.end();it++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((ll)(x).size())
#define cases ll t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
typedef unsigned long long int ull;
typedef vector<ll> vec;
typedef pair<ll,ll> pll;
typedef double db;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const ll mod=1000000007;
ll pm(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=((result%mod)*(x%mod))%mod; x=((x%mod)*(x%mod))%mod; n/=2;} return result;}
ll p(ll x,ll n) {ll result=1; while(n>0){if(n%2==1) result=result*x; x=x*x; n/=2;} return result;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ncr(ll n,ll r) { ll p=1,k=1; if(n-r<r) r=n-r; if(r!=0) {while(r!=0) {p*=n; k*=r; ll temp=gcd(p,k); p/=temp; k/=temp; n--; r--;} } else p=1; return p;}
ll factorial[300000+1];
void fact(ll n) { factorial[0]=1; factorial[1]=1; floop(i,2,n+1) factorial[i] = (i * factorial[i-1]%mod) % mod; }
ll d,coeff1,coeff2; 
void euclid(ll a, ll b) { if(b==0) { d=a; coeff1=1; coeff2=0; } else { euclid(b,a%b); ll temp=coeff1; coeff1=coeff2; coeff2=temp-(a/b)*(coeff2); } }
ll modinv(ll a) { euclid(a,mod); return (coeff1%mod+mod)%mod; }
int prime[1000001]={};
int spf[1000001]={};
void sieve(ll n)
{
	prime[0]=1;
	prime[1]=1;
	for(ll i=2;i*i<=n;i++)
	{
		if(prime[i]==0)
		{
			for(ll j=i*i;j<=n;j+=i)
			{
				prime[j]=1;	
				if(spf[j]==j)
				spf[j]=i;	
			}		
		}
	}
}
/*
vec s(300000,0);
vec si(300000,1);
ll root(ll a)
{
	while(s[a]!=a)
	a=s[a];
	return a;
}
void uni(ll a,ll b)
{
	ll r1=root(a);
	ll r2=root(b);
	if(si[r1]<si[r2])
	{
		s[r1]=s[r2];
		si[r2]+=si[r1];
	}
	else
	{
		s[r2]=s[r1];
		si[r1]+=si[r2];
	}
}
vector<vec > adj(300000);
vec vis(300000,0);
vec dist(300000,0);
void dfs(ll t,ll n)
{
	vis[t]=1;
	floop(i,0,sz(adj[t]))
	{
		if(vis[adj[t][i]]==0)
		{
			dist[adj[t][i]]=dist[t]+1;
			vis[adj[t][i]]=1;
		//	sum[adj[t][i]]=sum[t]+c[t][adj[t][i]];
			dfs(adj[t][i],n);
		}
	}
}*/
struct my_comp
{
	bool operator()(pair<ll,pll> p1, pair<ll,pll> p2)
	{
		if(p1.fi!=p2.fi)
		return p1.fi>p2.fi;
		return p1.se.fi<p2.se.fi;
	}
};
int main()
{
	ll n;
	cin>>n;
	vec a(n);
	ll temp=0;
	floop(i,0,n)
	{cin>>a[i]; temp=(temp^a[i]);}
	/*bitset<63> w(temp);
	vec ans(n);
	floop(i,0,n)
	{
		bitset<63> te(a[i]);
		floop(j,0,63)
		{
			if((w[j]^te[j])==1)
			{
				if(te[j]==0)
				ans[i]+=p(2,j);
			}
			else
			{
				if(te[j]==1)
				ans[i]+=p(2,j);
			}
		}
	}*/
	floop(i,0,n)
	cout<<(temp^a[i])<<" ";
	return 0;
}

Measured memory_bytes: 4752
#include <iostream>
#include <algorithm>
#include <cmath>
#include <set>
#include <string>
#include <vector>
#include <iomanip>
#include <map>
#include <deque>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;

const ll SIZE = 1e6 + 10, S2 = 1e7 * 2, MOD = 1e9 + 7, INF = 1e9 * 1e9;

struct circle {
    ld x, y, r;
};
vector<circle> vec;

ld dist[1003], used[1003];

ld d(int i, int j) {
    ld cur_d = sqrt((vec[i].x - vec[j].x) * (vec[i].x - vec[j].x) + (vec[i].y - vec[j].y) * (vec[i].y - vec[j].y)) - (vec[i].r + vec[j].r);
    cur_d = max(cur_d, ld(0));

    return cur_d;
}
int main() {
    fastInp;

    ld x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    vec.push_back({ x1, y1, 0 });
    ll n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        ld x, y, r;
        cin >> x >> y >> r;
        vec.push_back({ x, y, r });
    }
    vec.push_back({ x2, y2, 0 });

    for (int i = 1; i < vec.size(); i++) dist[i] = INF;

    for (int i = 1; i < vec.size(); i++) {
        pair<ld, ll> cur = { INF, -1 };
        for (int j = 0; j < vec.size(); j++) {
            if (!used[j] && dist[j] < cur.first) cur = { dist[j], j };
        }

        used[cur.second] = 1;
        for (int j = 0; j < vec.size(); j++) {
            if (!used[j]) {
                dist[j] = min(dist[j], dist[cur.second] + d(cur.second, j));
            }
        }
    }

    cout.precision(14);
    cout << dist[n + 1];
    return 0;
}



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

#define fst first
#define snd second
#define fore(i,a,b) for(int i=a, ThxDem=b; i<ThxDem; ++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define SZ(s) int(s.size())
#define DBG(x) cerr <<#x << " = " << (x) << "\n"

#define SQR(x) ((x) * (x))

#define PI 3.1415926535897932385
#define INF 1000111222
#define eps 1e-7
#define maxN 11

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<bool> vbool;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vbool> vvbool;

int main(){FIN

	ll n,w,wi,vi;
	
	cin >> n >> w;
	vll dp(w+1);
	
	fore(i,0,n){
		cin >> wi >> vi;
		for(int j=(w-wi);j>=0;j--)
			dp[j+wi] = max(dp[j+wi],dp[j]+vi);
	}
	ll ans = 0;
	fore(i,0,w+1)ans = max(ans,dp[i]);
	cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 3972
/**
 *
 * AtCoder Beginner Contest 100 - Problema A: Happy Birthday! (https://abc100.contest.atcoder.jp/tasks/abc100_a)
 *
 * Abridge version.
 *
 * Solution: text
 */
#include <iostream>

#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <vector>
#include <bitset>
#include <cstring>
#include <algorithm>

using namespace std;

using ll = long long;
using ii = pair<ll, ll>;

#define LOG(var, sep) (cerr << #var << " = " << (var) << (sep))
#define LOGM(msg) (cerr << (msg))
#define LOGV(vec, sep) { cerr << #vec << " ="; for (const auto& v : vec) cerr << " " << v; cerr << (sep); }
#define LOGA(arr, N, sep) { cerr << #arr << " ="; for (int i = 0; i < N; ++i) cerr << " " << (arr)[i]; cerr << (sep); }
#define LOGA2(arr, N, M, sep) { cerr << #arr << " =\n"; for (int i = 0; i < N; ++i) { for (int j = 0; j < M; ++j) cerr << (arr)[i][j] << " "; cerr << endl; } cerr << (sep); }

ostream& operator<<(ostream& os, const ii& p)
{
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

void solve(int A, int B)
{
    cout << (A <= 8 and B <= 8 ? "Yay!" : ":(") << endl;
}

int main()
{
    ios::sync_with_stdio(false);

    int A, B;
    cin >> A >> B;

    solve(A, B);

    return 0;
}


Measured memory_bytes: 256
use std::collections::HashMap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let nm: Vec<u32> = read_vec();
    let _n = nm[0];
    let m = nm[1];

    let ps_vec: Vec<Vec<String>> = read_vec2(m);

    let mut ac_map = HashMap::new();
    let mut wa_map = HashMap::new();

    for ps in &ps_vec {
        let p = &ps[0];
        let s = &ps[1];

        if s == "WA" {
            match ac_map.get(&p) {
                Some(_) => {}
                None => {
                    let v = wa_map.entry(p).or_insert(0);
                    *v += 1;
                }
            }
        } else if s == "AC" {
            ac_map.insert(p, 1);
        }
    }

    let mut answers: u32 = 0;
    let mut penalties: u32 = 0;

    for p in ac_map.keys() {
        match ac_map.get(p) {
            Some(_) => answers += 1,
            None => {}
        }

        match wa_map.get(p) {
            Some(i) => penalties += *i,
            None => {}
        }
    }

    println!("{} {}", answers, penalties);
}


Measured memory_bytes: 22780
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
int main() {
  int n,t;
  cin >> n >> t;
  int minCost = 10000;
  for(int i=0;i<n;i++){
    int ci,ti;
    cin >> ci;
    cin >> ti;
    if(ti<=t) minCost = min(minCost,ci);
  }
  if(minCost>1000){
    cout << "TLE" << endl;
    return 0;
  }
  cout << minCost << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

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

	int64_t m;
	m = INT64_MAX;
	for (int64_t i = 0; i < 5; i++) {
		int64_t n;
		cin >> n;
		m = min(n, m);
	}

	cout << (N + m - 1) / m + 4 << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
 cin >> s;
  bool b = false;
  for (int i = 0; i < 3; i++) {
  if(s[i]==s[i+1]){
  	b = true;
  }
 }
       if(b) {
       	cout << "Bad" << endl;
       }
       else {
       cout << "Good" << endl;
       }
       
 }

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

void main_()
{
    ll N;
    size_t A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string S;
    cin >> S;

    A--;
    B--;
    C--;
    D--;

    auto ng1 = S.find("##", B) < D;
    auto ng2 = S.find("##", A) < C;
    if (C < D) {
        cout << (ng1 || ng2 ? "No\n" : "Yes\n");
    } else {
        auto ng3 = !(S.find("...", B - 1) <= D - 1);
        cout << (ng1 || ng2 || ng3 ? "No\n" : "Yes\n");
    }
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 592
N, X, Y = map(int, input().split())
ls = [0] * N
for i in range(1, N+1):
    for j in range(i+1, N+1):
        dis = min([abs(j-i), abs(X-i) + 1 + abs(j-Y), abs(Y-i) + 1 + abs(j-X)])
        ls[dis] += 1
for i in range(1, len(ls)):
    print(ls[i])

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s1,s2;
	cin>>s1>>s2;
	int len = s1.length();
	string s;
	for(int i=0;i<len;i++){
		s=s1.substr(i,len)+s1.substr(0,i);
		if(s==s2){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    string s; cin >> s;
    REP(i, 0, s.size() - 1) {
        if (s[i] == 'A' && s[i + 1] == 'C') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define endl '\n'
#define INF 2147483647

int mem[105][1000005];
bool vis[105][1000005];
int pesos[105];
int valores[105];

int n,w,v,p;

int maxSum(int ind, int capacidad){
	if(ind==n){
		return 0;
	}
	if(capacidad<0){
		return -INF;
	}
	if(vis[ind][capacidad]){
		return mem[ind][capacidad];
	}
	vis[ind][capacidad] = true;
	int si,no;
	si = maxSum(ind,capacidad-pesos[ind]) +valores[ind];
	no = maxSum(ind+1,capacidad);
	return mem[ind][capacidad] = max(si,no);
}

int main(){
	cin >> n >> w;
	for(int i=0; i<n; i++){
		cin >> v >> p;
		valores[i] = v;
		pesos[i] = p;
	}
	cout << maxSum(0,w) << endl;
}



Measured memory_bytes: 9232
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	char N;
	cin >> N;
	if (N >= 'a') {
		cout << 'a' << endl;
	}
	else {
		cout << 'A' << endl;
	}

	

}


Measured memory_bytes: 3620
/* ex7_3
   Acro    */

#include <stdio.h> 
#include <stdlib.h>

int main(void){
    int row,column,value,i,j,k;
    scanf("%d %d",&row,&column);
    /* メモリの動的確保 */
    char **squares;
    /* 各行の配列へのポインタ分のメモリ領域を確保 */
    squares = (char**)calloc(row, sizeof(char*));
    if (squares == NULL)
    {
        exit(1);
    }
    /* 各行の要素分のメモリ領域を確保 */
    for ( i = 0; i < row; i++)
    {
        squares[i] = (char*)calloc(column, sizeof(char));
        if (squares[i] == NULL)
        {
            exit(1);
        }
        
    }
    /* 入力 */
    for ( i = 0; i < row; i++)
    {
        for ( j = 0; j < column; j++)
        {
            scanf(" %c",&squares[i][j]);
        }
    }
    /* 列の探索 */
    for ( i = 0; i < row; i++)
    {
        value = 1;
        for ( j = 0; j < column; j++)
        {
            if (squares[i][j] == '#')
            {
                value = 0;
            }
        }
        /* 列が全て白だった場合 */
        if (value)
        {
            for (j = i;j < row-1;j++)
            {
                for ( k = 0; k < column; k++)
                {
                    /* 列を上に寄せていく */
                    squares[j][k] = squares[j+1][k];
                }
                
            }
            row -= 1;
            i -= 1;
        }
        
        
    }
    /* 行の探索 */
    for ( i = 0; i < column; i++)
    {
        value = 1;
        for ( j = 0; j < row; j++)
        {
            if (squares[j][i] == '#')
            {
                value = 0;
            }
            
        }
        /* 行が全て白だった場合 */
        if (value)
        {
            for ( j = i; j < column-1; j++)
            {
                for ( k = 0; k < row; k++)
                {
                    squares[k][j] = squares[k][j+1];
                }
                
            }
            column -= 1;
            i -= 1;
        }
        
        
    }
    /* 出力 */
    for ( i = 0; i < row; i++)
    {
        for ( j = 0; j < column; j++)
        {
            printf("%c",squares[i][j]);
        }
        printf("\n");
        
    }
    /* メモリ領域の解法 */
    for ( i = 0; i < row; i++)
    {
        free(squares[i]);
    }
    free(squares);
    return 0;
}


Measured memory_bytes: 1644
"""
dp[t][v] = 時刻tに速度vで走っている時の今までの走行距離の最大値
dp[0][0] = 0, dp[0][i] = -inf(i>0)
条件を考える
  dp[t][v]について、時刻tにおける速度の最大値をM(t)とすると、
  v >  M[t] -> dp[v][t] = -inf
  v <= M[t] -> dp[v][t] = max(dp[t-1][v+1]+(2*v+1)/2, dp[t-1][v]+v, dp[t-1][v-1]+(2*v-1)/2)
ans = max(dp[sum(T)])
"""
from itertools import accumulate
U = 300
n = int(input())
T = [0] + list(map(lambda x:int(x)*2, input().split()))
V = list(map(lambda x:int(x)*2, input().split())) + [0]
S = sum(T)
M = [0]*(S+1)
K = list(accumulate(T))
for i in range(n):
  for j in range(K[i]+1, K[i+1]):
    M[j] = V[i]
  M[K[i+1]] = min(V[i], V[i+1])
dp = [[-float("inf")]*(U+1) for _ in range(S+1)]
dp[0][0] = 0
for t in range(1, S+1):
  for v in range(U+1):
    if v > M[t]:
      continue
    dp[t][v] = dp[t-1][v] + v
    if v > 0:
      dp[t][v] = max(dp[t][v], dp[t-1][v-1]+(2*v-1)/2)
    if v < U:
      dp[t][v] = max(dp[t][v], dp[t-1][v+1]+(2*v+1)/2)
ans = max(dp[S]) / 4
print(ans)

Measured memory_bytes: 166592
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int l[n] = {0};
    int r[n] = {0};

    l[0] = 0;
    rep2(i,1,n)
    {
        l[i] = l[i-1];
        if(s.substr(i-1,1) == "W")
            l[i]++; 
    }

    r[n-1] = 0;
    for(int i=n-2;i>=0;--i)
    {
        r[i] = r[i+1];
        if(s.substr(i+1,1) == "E")
            r[i]++;
    }

    int min_cnt = 1<<29;
    rep(i,n)
        min_cnt = min(min_cnt,r[i]+l[i]);
    cout << min_cnt << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  vector<int> res(n);
  rep(i, 31) {
    int odd = 0;
    rep(j, n) {
      if (a[j]>>i & 1)
        odd++;
    }
    if (odd%2) {
      rep(j, n) {
        if (!(a[j]>>i & 1))
          res[j] ^= 1<<i;
      }
    } else {
      rep(j, n) {
        if (a[j]>>i & 1)
          res[j] ^= 1<<i;
      }
    }
  }
  rep(i, n) {
    if (i)
      cout << ' ';
    cout << res[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4776
package main

import (
	"fmt"
	"sort"
)

type Restaurant struct {
	name  string
	score int
	id    int
}

type SortBy []Restaurant

func (a SortBy) Len() int      { return len(a) }
func (a SortBy) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a SortBy) Less(i, j int) bool {
	if a[i].name != a[j].name {
		return a[i].name < a[j].name
	}
	return a[i].score > a[j].score
}

func main() {
	var n int
	fmt.Scan(&n)
	var rs = make([]Restaurant, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&rs[i].name, &rs[i].score)
		rs[i].id = i + 1
	}
	sort.Sort(SortBy(rs))
	for i := 0; i < n; i++ {
		fmt.Println(rs[i].id)
	}
}


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

int main()
{
    int cntB = 0, x = 1;
    int n;
    cin >> n;

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

        if(a != x)
            cntB++;
        else
            x++;
    }

    if(x == 1)
        cout << "-1" << endl;
    else
        cout << cntB << endl;

    return 0;
}


Measured memory_bytes: 384
//解説の別解
// 左がxとすると右はsum-xなので
// 最小のabs(sum-2x)をみつける
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using ll = long long;
const int INF = 2147483647;
// const ll INF = 1000000000000000000LL;

ll gcd(ll a,ll b){
    if(a<b) swap(a,b);
    bool have_mod =true;
    while(have_mod){
        ll mod = a % b;
        if(mod == 0 ) have_mod = false;
        a = b;
        b = mod;
    }
    return a;
}

int main(){
	int n;
	cin >> n;
	vector<ll> t(n);
	rep(i,n) cin >> t[i];
	ll num = t[0];
	for(int i=1;i<n;i++){
		num = t[i]/gcd(num,t[i])*num;
	}
	cout << num << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	private static long max = 0;
	private static List<Long> getStrings(Scanner sc, int num) {
		List<Long> stringList = new ArrayList<>();
		while(num>0) {
			Long nextInt = sc.nextLong();
			stringList.add(nextInt);
			if (nextInt > max) {
				max = nextInt;
			}
			num--;
		}
		return stringList;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long k = sc.nextLong();
		List<Long> array= getStrings(sc, n);
		long l = 1;
		long r = max;
		while (r>l) {
			long mid = (l+r)/2;
			long re = split(array, mid);
			if (re <= k) {
				r = mid;
			}  else {
				l = mid+1;
			}
		}
		System.out.println(r);
	}

	private static long split(List<Long> array, long standard) {
		long result = 0;
		for(Long t: array) {
			result += t/standard;
			if (t % standard != 0) {
				result++;
			}
			result--;
		}
		return result;
	}

}


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

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define DEBUG(x) cout<<#x<<": "<<x<<endl

#define MAX_N 10
#define MAX_D 10
#define MAX_X 100000

//??\??????
int n,d,x;
int P[MAX_D][MAX_N];
int dp[MAX_N][MAX_X];

int rec(int hi, int ban, int nokori){
	if(ban==n){
		return 0;
	}
	if(dp[ban][nokori]>=0){
		return dp[ban][nokori];
	}
	int ans=0;
	for(int i=0;  ; ++i){
		if(P[hi][ban]*i>nokori){
			ans=max(ans,rec(hi,ban+1,nokori));
			break;
		}
		ans = max(ans,max((P[hi+1][ban]-P[hi][ban])*i + rec(hi,ban+1,nokori-P[hi][ban]*i), rec(hi,ban+1,nokori)));
		//DEBUG(hi);
		//DEBUG(ban);
		//DEBUG(i);
	}
	dp[ban][nokori]=ans;
	return ans;
}

int main(){
	cin>>n>>d>>x;
	REP(i,d){
		REP(j,n){
			cin>>P[i][j];
		}
	}
	/*
	//?????\?????§??????????±???????
	REP(i,d-1){
		int tmpx=x;//????????\????????\??????????????????
		int mouke=0;//?????\????????????
		while(true){
			vector<tuple<int,int> > Q(n);//???????????????????????§??????????????????
			REP(j,n){
				get<0>(Q[j]) = j;//??????????????£???????????¢??£?????????
				get<1>(Q[j]) = (P[i+1][j] - P[i][j]) * (tmpx/P[i][j]);
			}
			sort(Q.begin(),Q.end(),[](const tuple<int,int>& a, const tuple<int,int>& b){return get<1>(a) > get<1>(b);});//??????????????????
			//????????\???????????????or?????????????????´????????????
			if(get<1>(Q[0])<=0){
				break;
			}
			mouke += get<1>(Q[0]);
			tmpx -= P[i][get<0>(Q[0])]*(tmpx/P[i][get<0>(Q[0])]);
		}
		x+=mouke;
	}
	*/
	REP(i,d-1){
		REP(j,MAX_N){
			REP(k,MAX_X){
				dp[j][k]= -1;
			}
		}
		x = x + rec(i,0,x);
	}
	cout<<x<<endl;
	return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var ar = (H * W) / 2.0;
		int chk = (X * 2 == W) && (Y * 2 == H) ? 1 : 0;
		Console.WriteLine("{0} {1}",ar,chk);
		
		
	}
	long W,H,X,Y;
	public Sol(){
		var d = rla();
		W = d[0]; H = d[1]; X = d[2]; Y = d[3];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#define _USE_MATH_DEFINES

#include<math.h>
#include<unordered_map>

#define min(a,b) (a)>(b)?(b):(a)
#define max(a,b) (a)>(b)?(a):(b)

using namespace std;

int main()
{
	vector<int> n, x;

	while (true)
	{
		int tn, tx;

		scanf("%d %d", &tn, &tx);

		if (tn == 0 && tx == 0)
		{
			break;
		}
		else
		{
			n.push_back(tn);
			x.push_back(tx);
		}
	}

	for (int l = 0; l != n.size(); l++)
	{
		int ans = 0;
		for (int i = 1; i <= n[l]; i++)
		{
			for (int j = i + 1; j <= n[l]; j++)
			{
				for (int k = j + 1; k <= n[l]; k++)
				{
					if ((i + j + k) == x[l])
					{
						ans++;
					}
				}
			}
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 3248
from math import gcd
a, b = map(int, input().split())

def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n //i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

v = gcd(a,b) # greatest common divisors
divs = make_divisors(v)

k = 1
ans = 0
for d in divs:
    test = gcd(k, d)
    if test == 1:
        ans += 1
        k *= d
print(ans)


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

int N;
int B[110];
bool used[110];
std::vector<int> op;

bool can(){
    for(int t=0;t<N;++t){
        int n = 0, j = -1, k = -1;

        for(int i=1;i<=N;++i){
            if(used[i]){
                continue;
            }

            n += 1;

            if(B[i] == n){
                j = i;
                k = n;
            }
        }

        if(j == -1){
            return false;
        }

        used[j] = 1;
        op.emplace_back(k);
    }

    return true;
}

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

    std::cin >> N;

    for(int i=1;i<=N;++i){
        std::cin >> B[i];
    }

    if(can()){
        std::reverse(op.begin(), op.end());

        for(int i : op){
            std::cout << i << std::endl;
        }
    }else{
        std::cout << (-1) << std::endl;
    }
}


Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int n; string s[309];
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	int ret = 0;
	for (int i = 0; i < n; i++) {
		bool ok = true;
		for (int j = 0; j < n; j++) {
			for (int k = 0; k < j; k++) {
				if (s[j][(k + i) % n] != s[k][(j + i) % n]) {
					ok = false;
				}
			}
		}
		if (ok) ret += n;
	}
	cout << ret << "\n";
	return 0;
}

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

class D{
    public:
    int f[6];
    D(){}
    void rollx(){
        roll(0,2,5,3);
    }
    void rolly(){
        roll(0,1,5,4);
    }
    void roll(int a,int b,int c,int d){
        int t=f[a];
        f[a]=f[b];
        f[b]=f[c];
        f[c]=f[d];
        f[d]=t;
    }
};

int main(){
    D c;
    string s;
    for(int i=0;i<6;i++){
        cin>>c.f[i];
    }
    cin>>s;
    for(int j=0;j<s.size();j++){
        if(s[j]=='E'){
            for(int i=0;i<3;i++){
                c.rollx();
            }
        }
        if(s[j]=='W')c.rollx();
        if(s[j]=='N')c.rolly();
        if(s[j]=='S'){
            for(int i=0;i<3;i++){
                c.rolly();
            }
        }
    }
    cout<<c.f[0]<<endl;
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <string>
using namespace std;
int main(void){
    char c;
    cin >> c;
    
    if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
        cout << "vowel" << endl;
    }else {
        cout << "consonant" << endl;
    }
    
}


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

using namespace std;

int main() {
	int n;
    cin >>n;
	vector<int> p(n);
	for (int i =0;i<n;i++)
    {
      cin >> p.at(i);
    }
	int check=0;
	for (int i = 0; i < n; i++)
	{
      if(p.at(i)!=i+1) {check = check+1;}	
	}
	if (check==0||check==2) {cout << "YES"<<endl;}
	else
	{
		cout << "NO"<<endl;
	}
	
	

	return 0;
}



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	MyScanner sc = new MyScanner();
	Scanner sc2 = new Scanner(System.in);
	final int MOD = 1000000007;
	int[] dx = { 1, 0, 0, -1 };
	int[] dy = { 0, 1, -1, 0 };

	void run() {
		for (;;) {
			int n = sc.nextInt();
			int l = sc.nextInt();
			if ((n | l) == 0) {
				return;
			}
			Ant[] ant = new Ant[n];
			for (int i = 0; i < n; i++) {
				ant[i] = new Ant(i + 1, sc.next(), sc.nextInt(), false);
			}
			int cnt = 0;
			int last = 0;
			int time = 0;
			int tmp = 0;
			while (cnt != n) {
				for (int i = 0; i < n; i++) {
					if (!ant[i].leave) {
						if (ant[i].dir.equals("R")) {
							ant[i].dis += 1;
						} else {
							ant[i].dis -= 1;
						}
					}
				}

				for (int i = 0; i < n; i++) {
					for (int j = i + 1; j < n; j++) {
						if (ant[i].leave || ant[j].leave) {
							continue;
						}
						if (ant[i].dis == ant[j].dis) {
							if (ant[i].dir.equals("R")) {
								ant[i].dir = "L";
								ant[j].dir = "R";
							} else {
								ant[i].dir = "R";
								ant[j].dir = "L";
							}
						}
					}
				}
				tmp = 0;
				for (int i = 0; i < n; i++) {
					if (!ant[i].leave && (ant[i].dis == 0 || ant[i].dis == l)) {
						ant[i].leave = true;
						cnt++;
						if (time == tmp && ant[i].dir.equals("L")) {
							last = ant[i].num;
						} else if (tmp == 0) {
							last = ant[i].num;
						}
						tmp = time;
					}
				}
				time++;
			}
			System.out.println(time + " " + last);
		}
	}

	class Ant {
		int num;
		String dir;
		int dis;
		boolean leave;

		public Ant(int num, String dir, int dis, boolean leave) {
			super();
			this.num = num;
			this.dir = dir;
			this.dis = dis;
			this.leave = leave;
		}

	}

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

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	void debug2(int[][] array) {
		for (int i = 0; i < array.length; i++) {
			for (int j = 0; j < array[i].length; j++) {
				System.out.print(array[i][j]);
			}
			System.out.println();
		}
	}

	class MyScanner {
		int nextInt() {
			try {
				int c = System.in.read();
				while (c != '-' && (c < '0' || '9' < c))
					c = System.in.read();
				if (c == '-')
					return -nextInt();
				int res = 0;
				do {
					res *= 10;
					res += c - '0';
					c = System.in.read();
				} while ('0' <= c && c <= '9');
				return res;
			} catch (Exception e) {
				return -1;
			}
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		String next() {
			try {
				StringBuilder res = new StringBuilder("");
				int c = System.in.read();
				while (Character.isWhitespace(c))
					c = System.in.read();
				do {
					res.append((char) c);
				} while (!Character.isWhitespace(c = System.in.read()));
				return res.toString();
			} catch (Exception e) {
				return null;
			}
		}
	}
}

Measured memory_bytes: 23936
import java.util.*;

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

    for(int i = 0; i < 9; i++){
      a[i]= sc.nextInt();
    }

    //0-1 = 3-4 = 6-7
    int b11 = a[0] - a[1];
    int b12 = a[3] - a[4];
    int b13 = a[6] - a[7];
    //1-2 = 4-5 = 7-8
    int b21 = a[1] - a[2];
    int b22 = a[4] - a[5];
    int b23 = a[7] - a[8];
    //2-0 = 5-3 = 8-6
    int b31 = a[2] - a[0];
    int b32 = a[5] - a[3];
    int b33 = a[8] - a[6];

    if(b11 == b12){if(b12 ==b13){
      if(b21 == b22){if(b22 == b23){
        if(b31 == b32){if(b32 == b33){
          ans++;
        }}
      }}
    }}

    if(ans == 1){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }

  }
}

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

int N;

vector<int> b;

int find_insert(vector<int> v, int k, int id){
	if(v.size() < k - 1) return -1;

	for(int i=k-1;i<=v.size();i++){
		int count = k;
		if(i == v.size() && k == id) return id-1;

		for(int j=i;j<v.size();j++){
			if(v[j]<=count) count++;
		}
		if(count == id) return i;
	}
	return -1;
}


int solve(){
	vector<int> ans;

	for(int i=0;i<N;i++){
		int a = find_insert(ans, b[i], i+1);
		if(a == -1){
			cout << -1 << endl;
			return 0;
		}else{
			ans.insert(ans.begin()+a, b[i]);
		}

	}

	for(auto u:ans) cout << u << endl;
	return 0;
}



int main(){
	cin >> N;
	b.resize(N);
	for(int i=0;i < N;i++){
		cin >> b[i];
	}

	solve();
	return 0;
}

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

using namespace std;

using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FORE(i, a, b) for(int i=(a);i<=(b);++i)
#define rep(i, n) for(int i=0;i<(n);++i)
#define repe(i, n) for(int i=0;i<=(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define SP cout<<fixed<<setprecision(10)
typedef pair<int, int> P;
const ll INF = (ll) 1e18;
const int MOD = (int) 1e9 + 7;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n, k;
	cin >> n >> k;
	ll a[n];
	rep(i, n) cin >> a[i];
	
	ll sum[n + 1], sum2[n + 1];
	sum[0] = 0, sum2[0] = 0;
	rep(i, n) {
		sum[i + 1] = sum[i] + a[i];
		sum2[i + 1] = sum2[i];
		if (a[i] > 0) sum2[i + 1] += a[i];
	}
	
	ll ans = 0;
	rep(i, n - k + 1) {
		ans = max(ans, sum2[i] - sum2[0] + sum2[n] - sum2[i + k] + max(sum[i + k] - sum[i], 0ll));
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define endl '\n'
int main()
{
    ll n,w1;cin>>n>>w1; vector<ll>w(n),v(n);
    for(int i=0;i<n;i++){cin>>w[i];cin>>v[i];}
   ll dp[n+1][w1+1]={0};
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w1;j++)
        {
            if(i==0||j==0)dp[i][j]=0;
            else if(j-w[i-1]<0)
            {
               dp[i][j]=dp[i-1][j]; 
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i-1][j-w[i-1]]+v[i-1]);
            }
        }
    }cout<< dp[n][w1];
    
}

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

using namespace std;

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

typedef long long ll;
typedef long double ld;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    vector<int> a(3);
    cin >> a[0] >> a[1] >> a[2];
    sort(a.begin(), a.end());
    int res = 0;
    int d1, d2;
    d1 = a[2] - a[0];
    d2 = a[2] - a[1];
    if (d1 % 2 == d2 % 2) {
        if (d1 % 2) {
            res++;
            d1--, d2--;
        }
        res += d1 / 2;
        res += d2 / 2;
    } else {
        res++;
        if (d1 % 2) {
            d1++;
        } else {
            d2++;
        }
        res += d1 / 2;
        res += d2 / 2;
    }
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

fn main() {
    input! {
        n: usize,
        v: [i32; n],
    }

    let (ans, t) = bubble_sort(v);

    for i in 0..n {
        print!("{}", ans[i]);
        if i != n-1 {
            print!(" ");
        }
    }
    println!("");
    println!("{}", t);
}

fn bubble_sort(mut v: Vec<i32>) -> (Vec<i32>, u32) {
    let mut tmp;
    let mut t:u32 = 0;

    for i in 0..v.len()-1 {
        for j in (i+1..v.len()).rev() {
            if v[j] < v[j-1] {
                tmp = v[j];
                v[j] = v[j-1];
                v[j-1] = tmp;
                t += 1;
            }
        }
    }
    (v, t)
}



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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  string S;
  cin >> S;
  cout << ((S.back() == 's') ? S + "es" : S + "s") << "\n";
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

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

	int N;
	cin >> N;

	vector<int> W(N);
	rep(i, N) cin >> W[i];

	int ans = 1000000;
	for(int t = 1; t < N; t++){
		int s1 = 0, s2 = 0;
		for(int i = 0; i < N; i++){
			if(i <= t) s1 += W[i];
			else s2 += W[i];
		}

		ans = min(ans, abs(s2 - s1));
	}

	cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

int main(){
  int N; cin >> N;
  
  vector <ll> T(N), A(N);
  for (int i = 0; i < N; i++) cin >> T[i];
  for (int i = 0; i < N; i++) cin >> A[i];

  vector <ll> H1(N), H2(N);

  H1[0] = T[0];
  for (int i = 1; i < N; i++){
    if (T[i - 1] < T[i]){
      H1[i] = T[i];
    }
  }
  
  H2[N - 1] = A[N - 1];
  for (int i = N - 2; i >= 0; i--){
    if (A[i] > A[i + 1]){
      H2[i] = A[i];
    }
  }

  ll ans = 1;
  for (int i = 0; i < N; i++){
    if (H1[i] == 0 && H2[i] == 0){
      ans *= min(T[i], A[i]);
    }else if(H1[i] != 0 && H2[i] != 0 && H1[i] != H2[i]){
      ans = 0;
    }else if(H1[i] != 0 && H2[i] == 0 && H1[i] > A[i]){
      ans = 0;
    }else if(H1[i] == 0 && H2[i] != 0 && T[i] < H2[i]){
      ans = 0;
    }
    ans %= nmax;
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>
#include <stdlib.h>

int main(void) {
	int i, j, N, M, C, judge, answer = 0;
	int *judging_numbers;
	int **numbers;
	scanf("%d %d %d", &N, &M, &C);
	judging_numbers = (int *)malloc(sizeof(int)*M);
	for (i = 0; i < M; i++)
		scanf("%d", judging_numbers + i);
	numbers = (int **)malloc(sizeof(int *)*N);
	for (i = 0; i < N; i++) {
		numbers[i] = (int *)malloc(sizeof(int)*M);
		for (j = 0; j < M; j++)
			scanf("%d", *(numbers + i) + j);
	}
	for (i = 0; i < N; i++) {
		judge = 0;
		for (j = 0; j < M; j++) {
			judge += numbers[i][j] * judging_numbers[j];
		}
		judge += C;
		if (judge > 0)
			answer++;
	}
	printf("%d\n", answer);
	free(judging_numbers);
	free(numbers);
/*	for (i = 0; i < N; i++) {
		free(numbers[i]);
	}*/
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
	int m,d,sum;
	while(1){
		sum = 0;
		scanf("%d %d", &m, &d);
		switch (m){
			case 12:
				sum += 30;
			case 11:
				sum += 31;
			case 10:
				sum += 30;
			case 9:
				sum += 31;
			case 8:
				sum += 31;
			case 7:
				sum += 30;
			case 6:
				sum += 31;
			case 5:
				sum += 30;
			case 4:
				sum += 31;
			case 3:
				sum += 29;
			case 2:
				sum += 31;
			case 1:
				break;
			default:
				goto END;
		}
		sum += d;
		switch (sum % 7){
			case 0:
				printf("Wednesday\n");
				break;
			case 1:
				printf("Thursday\n");
				break;
			case 2:
				printf("Friday\n");
				break;
			case 3:
				printf("Saturday\n");
				break;
			case 4:
				printf("Sunday\n");
				break;
			case 5:
				printf("Monday\n");
				break;
			case 6:
				printf("Tuesday\n");
		}
	}
	END:
	return 0;
}

Measured memory_bytes: 584
#include <iostream>
#include <algorithm>

#include <cstdio>

int main() {

  int n;
  std::cin >> n;

  int max = -1 * 1000000000;
  int now, ri, min;

  std::cin >> min;

  for (auto i = 1; i < n; i++) {

    std::cin >> ri;

    //printf("before : ri = %d, min = %d, max = %d, now = %d.\n", ri, min, max, now);

    now = ri - min;
    max = std::max(max, now);
    min = std::min(min, ri);

    //printf("after : ri = %d, min = %d, max = %d, now = %d.\n", ri, min, max, now);
  }

  //printf("max = %d.\n", max);
  std::cout << max << std::endl;

  return 0;
}



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

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

#define p_ary(ary,a,b,i) do { cout << "["; for (int (i) = (a);(i) < (b);++(i)) cout << ary[(i)] << ((b)-1 == (i) ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct SparseTable1 {
private:
    vector<vector<int>> st;
    vector<int> lookup;
public:
    SparseTable1(vector<int>& v) {
        int b = 0,n = v.size();
        while ((1<<b) <= n) ++b;
        st.assign(b,vector<int>(1<<b));
        for (int i = 0;i < n;++i) {
            st[0][i] = v[i];
        }
        for (int i = 1;i < b;++i) {
            for (int j = 0;j+(1<<i) <= (1<<b);++j) {
                st[i][j] = min(st[i-1][j],st[i-1][j+(1<<(i-1))]);
            }
        }
        lookup.resize(n+1);
        for (int i = 2;i < n+1;++i) {
            lookup[i] = lookup[i>>1]+1;
        }
    }
    int getmin(int l,int r) {
        int b = lookup[r-l];
        return min(st[b][l],st[b][r-(1<<b)]);
    }
};

struct SparseTable2 {
private:
    vector<vector<int>> st;
    vector<int> lookup;
public:
    SparseTable2(vector<int>& v) {
        int b = 0,n = v.size();
        while ((1<<b) <= n) ++b;
        st.assign(b,vector<int>(1<<b));
        for (int i = 0;i < n;++i) {
            st[0][i] = v[i];
        }
        for (int i = 1;i < b;++i) {
            for (int j = 0;j+(1<<i) <= (1<<b);++j) {
                st[i][j] = max(st[i-1][j],st[i-1][j+(1<<(i-1))]);
            }
        }
        lookup.resize(n+1);
        for (int i = 2;i < n+1;++i) {
            lookup[i] = lookup[i>>1]+1;
        }
    }
    int getmax(int l,int r) {
        int b = lookup[r-l];
        return max(st[b][l],st[b][r-(1<<b)]);
    }
};

int main() {
    int n,k;
    cin >> n >> k;
    vector<int> a(n),sum(n,0);
    for (int i = 0;i < n;++i) scanf("%d",&a[i]);
    SparseTable1 sp1(a);
    SparseTable2 sp2(a);
    bool f = false;
    int ans = n-k+1;
    for (int i = 1;i < n;++i) if (a[i-1] > a[i]) sum[i] = 1;
    for (int i = 1;i < n;++i) sum[i] += sum[i-1];
    for (int i = 0;i < n-k+1;++i) if (sum[i+k-1] == sum[i]) ans--,f = true;
    for (int i = 0;i < n-k;++i) {
        if (sum[i+k-1] == sum[i] || sum[i+k] == sum[i+1]) continue;
        if (a[i] == sp1.getmin(i,i+k) && sp2.getmax(i+1,i+k+1) == a[i+k]) ans--;
    }
    if (f) ans++;
    cout << ans << endl;
}

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

int main()
{

        int N;
        cin >> N;
        string S;
        int m = 0;
        int a = 0;
        int r = 0;
        int c = 0;
        int h = 0;
        for (int i = 0; i < N; ++i) {
                cin >> S;
                if (S[0] == 'M') m++;
                if (S[0] == 'A') a++;
                if (S[0] == 'R') r++;
                if (S[0] == 'C') c++;
                if (S[0] == 'H') h++;
        }
        long long A[10] = {0, 0, 0, 0, 0, 0, 1, 1, 1, 2 };
        long long B[10] = {1, 1, 1, 2, 2, 3, 2, 2, 3, 3 };
        long long C[10] = {2, 3, 4, 3, 4, 4, 3, 4, 4, 4 };

        long long D[5];
        D[0] = m;
        D[1] = a;
        D[2] = r;
        D[3] = c;
        D[4] = h;

        long long ans = 0;
        for (int i = 0; i < 10; ++i) {

                ans += D[A[i]] * D[B[i]] * D[C[i]];

        }
        cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int cnt = 0;
    for(int k = 1; k <= 7; k++) {
        int mini = (int)pow(10, k - 1);
        int maxi = min(mini * 10 - 1, N);
        if(mini > N) break;
        if(k % 2 == 1) {
            cnt += maxi - mini + 1;
        }
    }
    cout << cnt << endl;
	return 0;
}

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

int main(){
  char alpha;
  cin >> alpha;
  
  if (alpha == 'A'||alpha == 'B'||alpha == 'C'||alpha == 'D'||alpha == 'E'||alpha == 'F'||alpha == 'G'||alpha == 'H'||alpha == 'J'||alpha == 'K'||alpha == 'L'||alpha == 'M'||alpha == 'N'||alpha == 'O'||alpha == 'P'||alpha == 'Q'||alpha == 'R'||alpha == 'S'||alpha == 'T'||alpha == 'U'||alpha == 'V'||alpha == 'W'||alpha == 'X'||alpha == 'Y'||alpha == 'Z'){
    cout << "A" << endl;
  }
  
  else {
    cout << "a" << endl;
  }
}

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

lint my_gcd(lint x, lint y) {
    while (y != 0) {
        lint tmp = x % y;
        x = y;
        y = tmp;
    }
    return x;
}

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

    lint x, y;
    cin >> x >> y;
    cout << my_gcd(x, y) << endl;
    return 0;
}



Measured memory_bytes: 3216
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
int dp[220000][3][2];
signed main(){
	string s;cin >> s;
	int n = s.size();
	rep(i,n)for(int j = 1;j <= 2;j++)rep(l,2){
		for(int k = 1;k <= 2;k++){
			if(i-j >= 0 && s.substr(i-j,j) != s.substr(i,k))dp[i+k][k][1] = max(dp[i+k][k][1],dp[i][j][l]+1);
			else dp[i+k][k][l] = max(dp[i+k][k][l],dp[i][j][l]);
		}
	}
	int ret = 0;
	rep(i,3)ret = max(ret,dp[n][i][1]);
	cout << ret +1 << endl;


	return 0;
}

Measured memory_bytes: 13128