akhauriyash/Code-Regression huggingface dataset:
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vi a(n);
    vi sum(n+1);
    rep(i, n) {
        cin >> a[i];
        sum[i+1] += a[i] + sum[i];
    }

    vvi field(h, vi(w));
    rep(i, h) rep(j, w) {
        int j_ = (i&1?w-1-j:j);
        int num = i*w+j+1;
        auto itr = lower_bound(all(sum), num);
        field[i][j_] = itr-sum.begin();
    }

    rep(i, h) rep(j, w) {
        cout << field[i][j] << (j == w-1?'\n':' ');
    }
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
 int main(){
  int X;
  cin>>X;
  int k=0,n=1;
  while(true){
    if(360*n%X==0){
      cout<<360*n/X<<endl;
      break;
    }
    else{
      n++;
    }
  }
 }

Measured memory_bytes: 3568
# Problem D - Line++

# input
N, X, Y = map(int, input().split())

# initialization
INF = N
kyori_graph = [[INF]*N for i in range(N)]
kosu_list = [0]*(N-1)

# graph search
for i in range(N):
    for j in range(i+1, N):
        # グラフの更新
        kyori_graph[i][j] = min(abs(j-i), abs(X-1-i)+1+abs(j-(Y-1)))
        # abs((Y-1)-i)+1+abs(j-(X-1))

# 個数の数え上げ
for i in range(N):
    for j in range(i+1, N):
        kyori = kyori_graph[i][j]
        kosu_list[kyori-1] += 1

# output
for k in kosu_list:
    print(k)


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); 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)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;cin >> n;
    vector<int> a(n),b(n);
    for (int i = 0;i < n;++i) cin >> a[i] >> b[i];
    int l1,r1,l2,r2;
    int mn = 0,mx = 1e9+10;
    while (mx-mn > 1) {
        int mid = (mn+mx)/2;
        int cnt = 0;
        for (int i = 0;i < n;++i) if (mid >= a[i]) cnt++;
        (cnt >= (n+1)/2 ? mx : mn) = mid;
    }
    l1 = mx;
    mn = 0,mx = 1e9+10;
    while (mx-mn > 1) {
        int mid = (mn+mx)/2;
        int cnt = 0;
        for (int i = 0;i < n;++i) if (mid > b[i]) cnt++;
        (cnt >= (n+1)/2 ? mx : mn) = mid;
    }
    r1 = mn;
    mn = 0,mx = 1e9+10;
    while (mx-mn > 1) {
        int mid = (mn+mx)/2;
        int cnt = 0;
        for (int i = 0;i < n;++i) if (mid >= a[i]) cnt++;
        (cnt >= (n+1)/2+1 ? mx : mn) = mid;
    }
    l2 = mx;
    mn = 0,mx = 1e9+10;
    while (mx-mn > 1) {
        int mid = (mn+mx)/2;
        int cnt = 0;
        for (int i = 0;i < n;++i) if (mid > b[i]) cnt++;
        (cnt >= (n+1)/2+1 ? mx : mn) = mid;
    }
    r2 = mn;
    if (n&1) cout << r1-l1+1 << endl;
    else cout << (r1+r2)-(l1+l2)+1 << endl;
}

Measured memory_bytes: 4836
package main

import "fmt"

func main() {
	var X,Y int
	fmt.Scan(&X,&Y)
	Y2 := X * 2
	flag := false
	for i:= 1; i<=X; i++ {
		// 一匹ずつ亀にしてみる
		if Y2 == Y {
			flag = true
		} else {
			Y2 += 2
		}
	}
	if !flag {
		if X*4 == Y {
			fmt.Println("Yes")
		} else {
			fmt.Println("No")
		}
	} else {
		fmt.Println("Yes")
	}
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int n,k;
    cin>>n>>k;
    int a[n+2];
    for(int i=1;i<=n;i++)cin>>a[i];
    int ans=1;n-=k;k--;
    ans+=n/k;
    if((n%k)!=0)ans++;
    cout<<ans;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <cmath>
#include <vector>
#include <vector>
#include <queue>

typedef long long ll;
const ll LL_MAX (1LL<<60);

#define rep(i,s,e) for(ll i=(s); i<(e); i++) 

using namespace std;

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

    bool ok(false);
    ll n;
    cin >>n;

    rep(i,1,10)
        rep(j,1,10)
            if (i*j == n) ok = true;;

    if (ok)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
ll gcd(ll a, ll b) {
  if(a<b) swap(a,b);
  ll c = -1;
  while(c != 0){
    c = a % b;
    a = b;
    b = c;
  }
  return a;
}

int main() {
  ll A,B;
  ll C,D;
  cin >> A >> B >> C >> D;
  ll CD = (C * D) / gcd(C,D);
  ll BdivC = B / C;
  ll BdivD = B / D;
  ll BdivCD = B / CD;
  ll AdivC = (A-1) / C;
  ll AdivD = (A-1) / D;
  ll AdivCD = (A-1) / CD;
  ll out = BdivC + BdivD - BdivCD - (AdivC + AdivD - AdivCD);
  cout << B - A + 1 - out << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxn 10000500000000000
#define pb push_back
#define ff first
#define ss second
#define all(x) x.begin(),x.end()
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e15+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
//for making unordered_map with pair
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
int32_t main()
{
    fastio;
   
    int t=1;
    //in t;
    int tt=0;
    while(t--){
            int n;in n;
            vector<bool> visited(n+1,0);
            vi edges[n+1];
            int q;in q;
            while(q--){
                int a,b;
                cin>>a>>b;
                edges[a].pb(b);
                edges[b].pb(a);
            }
            int count=0;
            for(int i=1;i<=n;i++){
                if(!visited[i]){
                    count++;
                    stack<int> Stack;
                    Stack.push(i);
                    while(!Stack.empty()){
                        int u=Stack.top();
                        Stack.pop();
                        visited[u]=true;
                        for(auto j: edges[u]){
                            if(!visited[j])
                                Stack.push(j);
                        }
                    }
                }
            }
            cout<<count-1<<endl;

    }

        return 0;
}

/*
google kick start
  cout << "Case #" << tt << ": "<<ans<<endl;
*/


Measured memory_bytes: 9720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll INF = 1e15;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// __uint128_t
const ll MOD = 1e9+7;

int main(){
    ll D, T, S; cin >> D >> T >> S;
    if(T*S >= D) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
x1, y1, x2, y2 = map(int, input().split())

x3 = x2 + (y1 - y2)
y3 = y2 + (x2 - x1)
x4 = x1 + (y1 - y2)
y4 = y1 + (x2 - x1)

print(x3, y3, x4, y4)

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

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

    int n, m;
    cin >> n >> m;

    const int N = 100010;
    vector<int> B(N, 0);
    int ma = 0;
    for(int i = 0; i < m; i++){
        int l, r;
        cin >> l >> r;
        ma = max(ma, r);
        B[l]++;
        B[r + 1]--;
    }

    for(int i = 1; i <= N; i++){
        B[i] += B[i - 1];
    }

    int ans = 0;
    for(int i = 0; i <= ma + 1; i++){
        if(B[i] == m) ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
program test
implicit none
character*26 :: s1
character*26 :: s2 = 'abcdefghijklmnopqrstuvwxyz'
integer :: i,max_i=0,num_s1,num_s2

read(*,*) s1 

if(s1 == 'zyxwvutsrqponmlkjihgfedcba') then
  write(*,*) -1
else if (len_trim(s1) < 26) then
  write(*,*) trim(s1)//s2(verify(s2,s1):verify(s2,s1))
else
  do i = 1,25
    if(llt(s1(i:i),s1(i+1:i+1))) then
      max_i = i
    endif
  end do
  
  num_s1 = scan(s2,s1(max_i:max_i))
  num_s2 = scan(s2(num_s1+1:26),s1(max_i+1:26)) + num_s1
  write(*,*) s1(1:max_i-1),s2(num_s2:num_s2)
end if
end program

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

int main(){
  int x,y;
  cin >> x >> y;

  int total=1+x+y;

  for(int i=1; i<=x; i++){
    for(int j=1; j<=y; j++){
      if(x*j==y*i){
        total--;
      }
    }
  }

  cout << total << endl;

  return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  rep(i, n){
    int in;
    cin >> in;
    a.at(0).at(i) = in;
  }
  rep(i, n){
    int in;
    cin >> in;
    a.at(1).at(i) = in;
  }

  rrep(i, n){
    if(i == n-1) continue;
    a.at(1).at(i) += a.at(1).at(i+1);
  }

  int ans = 0, sum = 0;
  rep(i, n){
    sum += a.at(0).at(i);
    int add = sum + a.at(1).at(i);
    ans = max(add, ans);
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;
 
 #define tr(c, i) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define   ipr         	pair<int, int>
#define   pb            push_back
#define   ff            first
#define   ss            second
#define fill(a,b) memset(a, b, sizeof(a))
#define   fr(i, j, k)   for (int i = j; i < k; i++)
#define   rf(i, j, k)   for (int i = j; i >= k;i--)
#define   int           long long int
#define   ll 			unsigned long long
#define   ld            long double
#define   all(x)        x.begin(), x.end()
#define   rall(x)       x.rbegin(),x.rend()
#define   mp            make_pair
#define L(x) ('a'<=x && x<='z')
#define   inf           INT_MAX
#define   read_file();	freopen("input.txt", "r", stdin);	freopen("output.txt", "w", stdout);
#define   IOS           std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int Maxn  =  200*1000 + 1;
const ld  pi   =  acos(-1);
const int mod =  1000000007;
const double epsilon = 1e-9; 
 
 
template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template<class T> ostream& operator <<(ostream &out,unordered_set<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}

int binpow(int a,int b) {
    a=a%mod;
   
    int res = 1;
while (b > 0) {
        if (b & 1)res = (res * a)%mod;
        a = (a * a)%mod;
        b >>= 1;
}
return (res+mod)%mod;
}



 int32_t main(){
    IOS;
 
   int t;
   //cin>>t;
       t=1;
   while(t--){

    string s,t;
    cin>>s>>t;

    int n=s.length();
    int m=t.length();

    vector<vector<int>>dp(n+1,vector<int>(m+1));

    fr(i,1,n+1){
       fr(j,1,m+1){
          if(s[i-1]==t[j-1])dp[i][j]=dp[i-1][j-1]+1;
          else dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
       }
    }

    string ans="";

    int x=n,y=m;

    while(x!=0 && y!=0){
       if(dp[x][y-1]==dp[x][y])y--;
       else if(dp[x-1][y]==dp[x][y])x--;
       else {
          ans=s[x-1]+ans;
          x--;
          y--;
       }
    }
    

    cout<<ans<<endl;



    
   }
}
 

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

int main() {
	int k;
	string s;
	cin >> k >> s;
	if ((int) s.length() <= k) {
		cout << s << endl;
	}
	else {
		cout << s.substr(0, k) << "..." << endl;
	}
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
const ll mod=1e9+7;
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
const ll N=1e6+8;
const ll INF=1e18;
ll n=408;
ll a[500],sum[500]={0};
ll dp[500][500];
ll naruto(ll l,ll r){
  if(l==r)
  return 0;
  if(l+1==r)
    return a[l]+a[r];
  if(dp[l][r]!=-1)
  return dp[l][r];
    ll res=INF;
  for(ll i=l;i<r;i++){
    res=min(res,sum[r]-sum[l-1]+naruto(l,i)+naruto(i+1,r));
  }
  return dp[l][r]=res;
}
int main(){
  IOS;
 cin>>n;
  for(ll i=1;i<=n;i++){
    cin>>a[i];
     sum[i]+=sum[i-1]+a[i];
  }
  memset(dp,-1,sizeof(dp));
  cout<<naruto(1,n);
}

Measured memory_bytes: 2304
#include <stdio.h>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cctype>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>

using namespace std;

/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;*/ //int order_of_key, it find_by_order

typedef long long ll;
typedef unsigned int ui;
typedef long double ld;
typedef pair<int, int> pii;

#define pb push_back
#define ft first
#define sd second
#define mpr make_pair
#define max3(a, b, c) max((a), max((b), (c)))
#define max4(a, b, c, d) max(max((a), (b)), max((c), (d)))
#define all(x) begin((x)), end((x))
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define isz(x) (int)(x).size()

/* <----------------------------------------------------------> */

int a[2][103], d[2][103];

void solve()
{
    int n;
    scanf("%d", &n);
    forn (i, 2) forn (j, n) scanf("%d", &a[i][j]);
    d[0][0] = a[0][0];
    forn (i, 2) forn (j, n)
    {
        if (!i) d[i + 1][j] = max(d[i + 1][j], d[i][j] + a[i + 1][j]);
        if (j < n - 1) d[i][j + 1] = max(d[i][j + 1], d[i][j] + a[i][j + 1]);
    }
    printf("%d", d[1][n - 1]);
}

/* <----------------------------------------------------------> */

// #define LOCAL
// #define FILE_NAME ""

int main()
{
    #if defined LOCAL
        freopen("input.txt", "r", stdin);
    #elif defined FILE_NAME
        freopen(FILE_NAME".in", "r", stdin);
        freopen(FILE_NAME".out", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<int,int> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define FILL(i,n) memset(i,n,sizeof(i));
#define X first
#define Y second
#define pb push_back
#ifdef brian
#define  debug(...) do{\
    fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename t> void _do(t &&x){cerr<<x<<endl;}
template<typename t,typename ...T> void _do(t &&x,T &&...tail){cerr<<x<<", ";_do(tail...);}
#else
#define debug(...)
#endif // brian


ll n;
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    string s;
    cin>>s;
    cout<<s.substr(0,5)<<" "<<s.substr(6,7)<<" "<<s.substr(14)<<endl;

}


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

int main(){
	int h, w, i, j;
	while(cin >> h >> w, h != 0 or w != 0){
		int root[h][w];
		char tile[h][w];
		for(i = 0; i < h; i++){
			for(j = 0; j < w; j++){
				root[i][j] = 0;
			}
		}
		for(i = 0; i < h; i++){
			for(j = 0; j < w; j++){
				cin >> tile[i][j];
			}
		}
		
		i = 0;
		j = 0;
		while(tile[i][j] != '.'){
			if(root[i][j] != 0){
				cout << "LOOP" << endl;
				break;
			}
			root[i][j]++;
			switch(tile[i][j]){
				case '>':
					j++;
					break;
				case '<':
					j--;
					break;
				case 'v':
					i++;
					break;
				case '^':
					i--;
					break;
			}
		}
		if(tile[i][j] == '.') cout << j << ' ' << i << endl;
	}
	return 0;
}

Measured memory_bytes: 1204
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i > 0; i--)
#define repc(i, m, n) for (int i = m; i < n; i++)
#define reprc(i, m, n) for (int i = m; i > n; i--)
#define all(v) v.begin(), v.end
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    ll A,B,N;
    int ans;
    cin >> A >> B >> N;

    int key = A * min(B - 1, N) / B - A * (min(B - 1, N) / B);
    ans = key;

    cout << ans << endl;
}

Measured memory_bytes: 3592
/* AtCoder コピペ */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repEq(i, n) for (int i = 0; i <= (int)(n); i++)
#define repVector(i, v) for (auto i = v.begin(); i != v.end(); ++i)

#define ifBetween(n, a, b) if (n > a && n < b)
#define ifBetweenEq(n, a, b) if (n >= a && n <= b)

int main() {
	string s;
  	vector<string> vec;
  	string result = "";
  
  	cin >> s;
  	int l = s.length();
  
  	char cs[l + 1];
  	strcpy(cs, s.c_str());
  
  	rep(i, l) {
      	if(cs[i] == '0') vec.push_back("0");
      	if(cs[i] == '1') vec.push_back("1");
      	if(cs[i] == 'B') {
          if (vec.size() > 0) {
          	vec.pop_back();
          }
        }
    }
  	
  	result = accumulate(vec.begin(), vec.end(), result);
  
  	cout << result << endl;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, string> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

ll N,M,K,L;
bool isfav[100010];
vector<ll> A,fav;
vector<string> S;
map<string,ll> id;
vector<ll> ord;

bool ok(ll X){
  if(X>K)return false;

  ll cnt=0;
  rep(i,K){
    if(isfav[ord[i]])cnt++;
  }
  if(X<=cnt)return true;

  ll add=X;
  ll rest=X-cnt;
  ll sum=0;
  for(ll i=K-1;i>=0;i--){
    if(!isfav[ord[i]]){
      rest--;
      if(rest==0){
        rep(j,N){
          if(isfav[ord[j]]){
            if(j>i){
              if(S[ord[i]]<S[ord[j]]) sum+=A[ord[i]]-A[ord[j]]+1;
              else sum+=A[ord[i]]-A[ord[j]];
            }
            add--;
            if(add==0)break;
          }
        }
        break;
      }
    }
  }
  return sum<=L;
}

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

  while(1){
    A.clear(); S.clear(); fav.clear(); ord.clear();
    id.clear();
    cin>>N>>M>>K>>L;
    if(N==0)break;
    rep(i,N)isfav[i]=false;
    A.resize(N);
    S.resize(N);
    rep(i,N){
      string name;
      cin>>S[i]>>A[i];
      id[S[i]]=i;
    }
    rep(i,M){
      string name;
      cin>>name;
      fav.push_back(id[name]);
      isfav[id[name]]=true;
    }

    rep(i,N){
      ord.push_back(i);
    }
    sort(all(ord),[=](const ll& a,const ll& b){
      if(A[a]==A[b])return S[a]<S[b];
      else return A[a]>A[b];
    });

    //rep(i,N){
      //dbg(S[ord[i]]);
    //}

    ll lb=0,ub=M+1;
    while(ub-lb>1){
      ll mid=(ub+lb)/2;
      if(ok(mid)) lb=mid;
      else ub=mid;
    }
    cout<<lb<<endl;
  }

  return 0;
}



Measured memory_bytes: 17524
// -----------------------------------------------
// 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, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

#[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()
        })*
    };
}

#[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()),*)
    }};
}

#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

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

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

    let mut B = vec![];
    for l in 0..N {
        let mut s = 0_i64;
        for r in l + 1..N + 1 {
            s += A[r - 1];
            B.push(s);
        }
    }

    let mut current = (0..B.len()).collect::<HashSet<_>>();
    let mut next = HashSet::new();
    let mut s = 0_i64;

    for t in (0..64).rev() {
        next.clear();
        for &i in current.iter() {
            if B[i] & (1 << t) != 0 {
                next.insert(i);
            }
        }

        if next.len() >= K {
            swap(&mut current, &mut next);
            s += 1 << t;
        }
    }

    println!("{}", s);
}


Measured memory_bytes: 28920
#include<bits/stdc++.h>
 
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"

using namespace std;

int32_t main()
{
	IOS;
	int n, d;
	cin >> n >> d;
	d = d*d; 
	int cnt = 0;
	for(int i = 0; i < n; i++)
	{
		int x, y;
		cin >> x >> y;
		if(x*x + y*y <= d)
			cnt++;
	}
	cout<<cnt<<endl;
}

Measured memory_bytes: 3636
#include<cstdio>
#include<cstdlib>
#include<map>
#include<algorithm>
#define mp make_pair
#include<iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int,int> pi;
char in[20];
int n;
pi table[20000];
int main(){
	while(scanf("%d",&n),n){
		rep(i,n)rep(j,2){
			cin>>in;
			table[i*2+j]=mp(atoi(in)*3600+atoi(&in[3])*60+atoi(&in[6]),1-j);
		}
		sort(table,table+2*n);
		int ans=0,c=0;
		rep(i,2*n){
			if(table[i].second)
				c++;
			else c--;
			ans=max(ans,c);
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

public class Main{

    final long mo=(long)1e9+7;
    
    public static void main(String[] args){
		new Main().run();
    }

    void run(){
      Scanner sc=new Scanner(System.in);
      int N=sc.nextInt();
      int K=sc.nextInt();
      long[] H=new long[N];
      for(int i=0;i<N;++i){
          H[i]=sc.nextLong();
      }
      long[] cost=new long[N];
      Arrays.fill(cost,1L<<60);
      cost[0]=0;
      for(int i=0;i<N;++i){
          for(int j=1;j<=K&&i+j<N;++j){
    	      cost[i+j]=Math.min(cost[i+j],cost[i]+Math.abs(H[i]-H[i+j]));
          }
      }
      System.out.println(cost[N-1]);
    }
}


Measured memory_bytes: 59140
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <iomanip>
#include <cmath>
#include <cstdlib>
#include <math.h>
#include <stdlib.h>
#include <numeric>

int main(){
	long int a, b, q, s[100001], t[100001];
	std::cin >> a >> b >> q;
	for(int i = 0; i < 100001; i++){
		s[i] = 30000000000;
	}
	for(int i = 0; i < 100001; i++){
		t[i] = 30000000000;
	}
	for(int i = 0; i < a; i++){
		std::cin >> s[i];
	}
	for(int i = 0; i < b; i++){
		std::cin >> t[i];
	}
	for(int i = 0; i < q; i++){
		long int x, ans, ls = 0, lt = 0, tmp;
		std::cin >> x;
		/*for(int j = 0; j < a; j++){
			if(s[j] <= x){
				ls = j;
			}
			if(t[j] <= x){
				lt = j;
			}
		}*/
		ls = std::max(0, (int)(std::lower_bound(s, s + 100000, x) - s - 1));
		lt = std::max(0, (int)(std::lower_bound(t, t + 100000, x) - t - 1));
		
		ans = std::abs(x - s[ls]) + std::abs(s[ls] - t[lt]);
		tmp = std::abs(x - t[lt]) + std::abs(t[lt] - s[ls]);
		ans = std::min(ans,tmp);
		
		tmp = std::abs(x - s[ls]) + std::abs(s[ls] - t[lt+1]);
		ans = std::min(ans,tmp);
		tmp = std::abs(x - t[lt+1]) + std::abs(t[lt+1] - s[ls]);
		ans = std::min(ans,tmp);
		
		tmp = std::abs(x - s[ls+1]) + std::abs(s[ls+1] - t[lt]);
		ans = std::min(ans,tmp);
		tmp = std::abs(x - t[lt]) + std::abs(t[lt] - s[ls+1]);
		ans = std::min(ans,tmp);
		
		tmp = std::abs(x - s[ls+1]) + std::abs(s[ls+1] - t[lt]);
		ans = std::min(ans,tmp);
		tmp = std::abs(x - t[lt]) + std::abs(t[lt] - s[ls+1]);
		ans = std::min(ans,tmp);
		tmp = std::abs(x - s[ls+1]) + std::abs(s[ls+1] - t[lt+1]);
		ans = std::min(ans,tmp);
		tmp = std::abs(x - t[lt+1]) + std::abs(t[lt+1] - s[ls+1]);
		ans = std::min(ans,tmp);
		
		std::cout << ans << std::endl;
	}
	return 0;
}



Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int n;
int main(){
	scanf ( "%d" , &n );
	for ( int i = 0 ; i < n ; i++ ) 
		for ( int j = i + 1 ; j < n ; j++ ) {
			int tmp = ( i ^ j );
			int ans = 0;
			while ( tmp ) {
				ans++;
				tmp >>= 1;
			}
			printf ( "%d%c" , ans,j==n-1?'\n':' ');
		}
	return 0;
}

Measured memory_bytes: 512
import java.io.PrintStream;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

public class Main {
	static boolean debug = true;

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int[] k=new int[N];
		for(int i=0;i<M;i++){
			int s=sc.nextInt();int f=sc.nextInt();
			k[s-1]++;k[f-1]++;
		}
		String res="YES";
		for(int i=0;i<N;i++){
			if((k[i]&1)==1) {
				res="NO";
				break;
			}
		}
		System.out.println(res);
		
	}

	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	private static void print(String string) {
		// TODO Auto-generated method stub
		if (debug)
			System.out.println(string);
	}

	private static void print(int[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(String[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(char[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(double[] data) {
		if (debug) {
			for (int i = 0; i < data.length; i++)
				System.out.println(i + ":" + data[i]);
		}
	}

	private static void print(int[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i+" "+j + ":" + data[i]);
				}
				System.out.println();
			}
		}
	}
	private static void print(char[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i+" "+j + ":" + data[i]);
				}
				System.out.println();
			}
		}
	}
	private static void print(String[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i+" "+j + ":" + data[i]);
				}
				System.out.println();
			}
		}
	}
	private static void print(double[][] data) {

		if (debug) {
			for (int i = 0; i < data.length; i++) {
				for (int j = 0; j < data.length; j++) {
					System.out.print(i+" "+j + ":" + data[i]);
				}
				System.out.println();
			}
		}
	}
}


Measured memory_bytes: 65164
#n = int(input())
#s = input()
n,m = map(int,input().split())
#da = list(map(int,input().split()))

if(n == 1 and m == 1): print(1)
elif (n == 1 or m == 1): print(n*m-2)
else: print((m-2)*(n-2))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define fi first
#define se second
#define pb push_back
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rrep(i, s, n) for (int i = (n)-1; i >= (s); i--)
#define REP(i,n) for(int i = 0;i < n; i++)
#define all(a) a.begin(),a.end()
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
const long long MOD = 1000000007, INF = 1e18;
 
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
 
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;}
template<typename T>vector<T>
make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
	return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}
 
template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}

/*bool operator<(const data &d)const{
	return hoge;
}*/
 
const int dx[]={0,1,1,-1,-1,0};
const int dy[]={1,1,0,0,-1,-1};
set<char>vowel={'a','i','u','e','o'};

int marume(int x){
	if(x>255)return 255;
	if(x<=0)return 0;
	return x;
}
 
signed main(){
	IOS();
	int N,M;
	vector<int>ans;
	while(cin>>N>>M,N||M){
		vector<int>c(M),x(N);
		REP(i,M)cin>>c[i];
		REP(i,N)cin>>x[i];
		vector<int>dp(256,INF);
		dp[128] = 0;
		rep(i,0,N){
			vector<int>ndp(256,INF);
			rep(j,0,256){
				if(dp[j]==INF)continue;
				rep(k,0,M){
					int t =max(0ll,min(255ll,j+c[k]));
					chmin(ndp[t],dp[j]+(t-x[i])*(t-x[i]));
				}
			}
			swap(dp,ndp);
		}
		ans.push_back(*min_element(all(dp)));
	}
	for(auto e:ans){
		cout<<e<<endl;
	}
}


Measured memory_bytes: 3256
#include <bits/stdc++.h>
#define rep(i,n) for ((i)=1;(i)<=(n);(i)++)
#define per(i,n) for ((i)=n;(i)>=(1);(i)--)
using namespace std;
long long ans;
int n,sz[100005],mx[100005];
vector<pair<int,int> > e[100005];
vector<int> cen;
void dfs(int x,int fa)
{
	sz[x]=1;
	int i;
	for(i=0;i<e[x].size();i++)
	{
		if(e[x][i].first==fa) continue;
		dfs(e[x][i].first,x);
		sz[x]+=sz[e[x][i].first];
		mx[x]=max(mx[x],sz[e[x][i].first]);
		ans+=2ll*min(sz[e[x][i].first],n-sz[e[x][i].first])*e[x][i].second;
	}
	mx[x]=max(mx[x],n-sz[x]);
	if(mx[x]<=n/2)
	{
		cen.push_back(x);
	}
}
int main()
{
	int i;
	scanf("%d",&n);
	rep(i,n-1)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		e[x].push_back(make_pair(y,z));
		e[y].push_back(make_pair(x,z));
	}
	dfs(1,0);
	if(cen.size()==2)
	{
		int i;
		for(i=0;i<e[cen[0]].size();i++) if(e[cen[0]][i].first==cen[1]) ans-=e[cen[0]][i].second;
		cout<<ans<<endl;
	}
	else
	{
		int i,mi=0x3f3f3f3f;
		for(i=0;i<e[cen[0]].size();i++) mi=min(mi,e[cen[0]][i].second);
		cout<<ans-mi<<endl;
	}
	return 0;
}

Measured memory_bytes: 10496
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import bisect
import sys
import logging
import heapq
logging.basicConfig(level=logging.DEBUG)

input = sys.stdin.readline

setrecursionlimit(1000000)

MOD = 10**9+7

def __lt__(self, other):
    return self[0] < other[0]

def main():
    N=int(input())
    A=[int(x) for x in input().split()]

    ans=[]
    heapq.heapify(ans)
    for i in range(len(A)):
        t=(A[i], i+1)
        heapq.heappush(ans, t)
    
    while ans:
        a = heapq.heappop(ans)
        print(a[1]) 
main()

Measured memory_bytes: 98024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int N, W; 
    cin >> N >> W;
    vector<int> w(N); vector<int>v(W);
    rep(i,N) cin >> w[i] >> v[i];
    vector<vector<ll>> dp(N+1, vector<ll>(W+1,0));
    for(int i = 0; i < N; i++){
        for(int j = 0; j <= W; j++){
            if(j - w[i] < 0) dp[i+1][j] = dp[i][j];
            else dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]]+v[i]);
        }
    }
    cout << dp[N][W] << endl;
}

Measured memory_bytes: 80640
<?php

fscanf(STDIN, "%d", $n);
$red = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d %d", $x, $y);
    $red[] = [$x, $y];
}
$blue = [];
for ($i = 0; $i < $n; ++$i) {
    fscanf(STDIN, "%d %d", $x, $y);
    $blue[] = [$x, $y];
}

usort($red, function ($a, $b) {
    return $a[0] > $b[0];
});
usort($blue, function ($a, $b) {
    return $a[0] > $b[0];
});

$cnt = 0;
for ($i = 0; $i < $n; ++$i) {
    $bx = $blue[$i][0];
    $by = $blue[$i][1];

    $j_max = null;
    $r_max = -1;
    for ($j = 0; $j < $n; ++$j) {
        $rx = $red[$j][0];
        $ry = $red[$j][1];
        if ($rx > $bx) break; // sortしているので
        if ($ry > $by) continue;

        if ($ry > $r_max) {
            $j_max = $j;
            $r_max = $ry;
        }
    }
    if (isset($j_max)) {
        ++$cnt;
        unset($red[$j_max]);
    }
}
echo $cnt, PHP_EOL;


Measured memory_bytes: 16252
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}
vector<ll>sura;
ll k;
ll n;

bool solve(ll x)
{
ll d=k;
for(ll i=0;i<n;i++)
{
 if(sura[i]%x==0)
 {
     d-=((sura[i]/x)-1);
 }
 else
 d-=(sura[i]/x);
}
if(d>=0)
return true;
else
return false;


}


int main()
{
cin>>n>>k;
for(ll i=0;i<n;i++)
{
    ll d;
    cin>>d;
    sura.push_back(d);
}
ll l=1;
ll r=1000000000;
ll ans=0;
while(r>=l)
{
    ll mid=(l+r)/2;
    if(solve(mid))
    {
        ans=mid;
        r=mid-1;
    }
    else
    l=mid+1;
}
cout<<ans<<endl;

}



   
      
    
        



Measured memory_bytes: 5288
#include <stdio.h>
  int main(){
int i,j;
int x[12]={0,31,60,91,121,152,182,213,244,274,305,335};
int n,m;
while(1){
scanf("%d%d",&n,&m);
if(n==0){
break;
}
int q=x[n-1]+m;
q %= 7;
if(q==0){
printf("Wednesday\n");
}else if(q==1){
printf("Thursday\n");
}else if(q==2){
printf("Friday\n");
}else if(q==3){
printf("Saturday\n");
}else if(q==4){
printf("Sunday\n");
}else if(q==5){
printf("Monday\n");
}else if(q==6){
printf("Tuesday\n");
}
}
return 0;
}

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

using namespace std;

typedef long long LL;
typedef unsigned long UL;

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

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

    if (c <= a + b)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<int> a(n),b(n);
	for(int i=0;i<n;++i){
		cin>>a[i]>>b[i];
	}
	int cnt = 0;
	for(int i=0;i<n-2;++i){
		if((a[i]==b[i]) && (a[i+1]==b[i+1]) && (a[i+2]==b[i+2])){
			++cnt;
			break;
		}
	}
	cout<<(cnt ? "Yes" : "No")<<'\n';
	return 0;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main(){
    int x;
    scanf("%d", &x);
    int a[x];
    for(int i=0; i<x; i++){
        scanf("%d", &a[i]);
    }
    for(int i=1; i<=x; i++){
        printf("%d", a[x-i]);
        if(i!=x){
            printf(" ");
        }
    }
    puts("");
 }


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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

int main()
{
    int k, x;
    cin >> k >> x;
    
    if(500 * k >= x)
        cout << "Yes\n";
    else
        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
//さっさと済ませられるところはさっさと済ましてしまう．ただし注意深く
#include <cstdio>
#include <iostream>
#include <queue>
#define MAX_VERTEXES 100
#define ZERO 0
#define NIL -1

using namespace std;

//think easy make easy

int n;//num of vertexes(頂点)
int matrix_graph[MAX_VERTEXES+1+1][MAX_VERTEXES+1+1];//1オリジン
int min_path[MAX_VERTEXES+1+1];


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

	int v_num;
	int k;//v_numの出次数

	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			matrix_graph[i][j] = ZERO;
		}
	}

	for(int i=0;i<n;i++){
		scanf("%d",&v_num);
		scanf("%d",&k);

		for(int j=0;j<k;j++){
			int v_num2;
			scanf("%d",&v_num2);
			matrix_graph[v_num][v_num2] = 1;
		}
	}

	for(int i=1;i<=n;i++){
		min_path[i] = NIL;
	}
	min_path[1] = 0;

	int s = 1;
	queue<int> q;
	q.push(1);
	while(!q.empty()){
		s = q.front();
		q.pop();
		for(int i=1;i<=n;i++){
			if(min_path[i] == NIL && matrix_graph[s][i] == 1){
				q.push(i);
				min_path[i] = min_path[s] + 1;
			}
		}
	}
	for(int i=1;i<=n;i++){
		cout <<i <<" " <<min_path[i] <<endl;
	}

	return 0;
}

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

int dat[2002];
vector<int> graph[2002];
bool visit[2005];
int n;

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

vector<int> merge(vector<vector<int>> vvt, int head)
{
	int total = 0;
	for (auto &&v : vvt) total += v.size();
	vector<int> ret(total + (head >= 0));
	int ptr = 0;
	if (head >= 0) ret[ptr++] = head;
	priority_queue<tuple<int, int, int>> pq;
	for (int i = 0; i < vvt.size(); i++)
	{
		pq.emplace(vvt[i][0], i, 0);
	}
	while (pq.empty() == false)
	{
		int val, idx, nxt;
		tie(val, idx, nxt) = pq.top();
		pq.pop();
		ret[ptr++] = val;

		if (nxt + 1 < vvt[idx].size())
			pq.emplace(vvt[idx][nxt + 1], idx, nxt + 1);
	}
	return ret;
}

vector<int> process(int t)
{
	vector<vector<int>> vvt;
	visit[t] = true;

	for (int nxt : graph[t])
	{
		if (visit[nxt]) continue;
		vvt.emplace_back(process(nxt));
	}

	return merge(move(vvt), t);
}

int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &dat[i]);
	}

	sort(dat, dat + n);

	for (int i = 0; i < n - 1; i++)
	{
		for (int j = i + 1; j < n; j++)
		{
			if (gcd(dat[i], dat[j]) > 1)
			{
				graph[i].push_back(j);
				graph[j].push_back(i);
			}
		}
	}

	//for (int i = 0; i < n; i++) sort(graph[i].begin(), graph[i].end());

	vector<vector<int>> vvt;

	for (int i = 0; i < n; i++)
	{
		if (visit[i]) continue;
		vvt.emplace_back(process(i));
	}

	auto ret = merge(move(vvt), -1);

	for (int t : ret) printf("%d ", dat[t]);
	printf("\n");
}


Measured memory_bytes: 17792
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($r :tt ) *) =>{let stdin =std ::io ::stdin () ;let mut bytes =std ::io ::Read ::bytes (std ::io ::BufReader ::new (stdin .lock () ) ) ;let mut next =move ||->String {bytes .by_ref () .map (|r |r .unwrap () as char ) .skip_while (|c |c .is_whitespace () ) .take_while (|c |!c .is_whitespace () ) .collect () } ;input_inner !{next ,$($r ) *} } ;}
macro_rules !input_inner {($next :expr ) =>{} ;($next :expr ,) =>{} ;($next :expr ,$var :ident :$t :tt $($r :tt ) *) =>{let $var =read_value !($next ,$t ) ;input_inner !{$next $($r ) *} } ;}
macro_rules !read_value {($next :expr ,($($t :tt ) ,*) ) =>{($(read_value !($next ,$t ) ) ,*) } ;($next :expr ,[$t :tt ;$len :expr ] ) =>{(0 ..$len ) .map (|_ |read_value !($next ,$t ) ) .collect ::<Vec <_ >>() } ;($next :expr ,chars ) =>{read_value !($next ,String ) .chars () .collect ::<Vec <char >>() } ;($next :expr ,usize1 ) =>{read_value !($next ,usize ) -1 } ;($next :expr ,$t :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      s: String,
      k: usize,
   }
   let n = s.len();
   let mut set = std::collections::BTreeSet::new();
   for l in 1..std::cmp::min(5, n) + 1 {
      for i in 0..n - l + 1 {
         set.insert(&s[i..i + l]);
      }
   }
   let &ans = set.iter().nth(k - 1).unwrap();
   println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
char s[10];
int main(){
	long long x;
	cin>>x;
	cin>>s;
	long long y;
	y=(s[0]-'0')*100+(s[2]-'0')*10+(s[3]-'0');
	long long z=x*y/100;
	printf("%lld\n",z); 
	return 0;
} 

Measured memory_bytes: 3736
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int d[n];

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

    set<int> values;

    for (size_t i = 0; i < n; i++)
    {
        values.insert(d[i]);
    }
    cout << values.size() << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef vector<vl> mt;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<string> vs;
typedef vector<vs> table;
typedef vector<vl> v2;
typedef vector<v2> v3;
typedef vector<v3> v4;


const ll e5 = 1 << 20;
const ll mod = 1000000007;
const ll e3 = 1 << 13;
const ll INF = 1ll << 50;

ll n,m;
unordered_map<ll,vl> mp;

class union_find {
private:
  vl *par;
  vl *rnk;
  vl *siz;
public:
  union_find (ll n){
    par = new vl(n);
    iota(par->begin(),par->end(),0);
    rnk = new vl(n,0);
    siz = new vl(n,1);
  }
  ll find(ll x){
    if(par->at(x) == x) return x;
    else return par->at(x) = find(par->at(x));
  }
  ll size(ll x){
    return siz->at(find(x));
  }
  void unite(ll x,ll y){
    x = find(x);y = find(y);
    if(x == y)return;
    if(rnk->at(x) < rnk->at(y)){
      par->at(x) = y;
      siz->at(y) += siz->at(x);
    }
    else {
      par->at(y) = x;
      siz->at(x) += siz->at(y);
      if(rnk->at(x) == rnk->at(y)) rnk->at(x)++;
    }
  }
  bool same(ll x,ll y){
    return find(x) == find(y);
  }
};

union_find uf(0);

int main(){
  cin >> n >> m;
  for(ll i = 1;i <= n;i++){
    ll k;
    cin >> k;
    for(ll j = 0;j < k;j++){
      ll l;
      cin >> l;
      mp[l].push_back(i);
    }
  }
  uf = union_find(n+1);
  for(auto x : mp){
    for(ll y : x.second){
      uf.unite(x.second[0],y);
    }
  }
  if(uf.size(1) == n) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Measured memory_bytes: 6668