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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
//#define mp make_pair

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;

  int r = 0, b = 0;
  rep (i, n) {
    if (s[i] == 'R') r++;
    else b++;
  }
  if (r > b) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define pb push_back
//#define mp make_pair
#define myfor(i, a, b) for (int i = a; i < b; ++i)

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int INF = 0x3f3f3f3f;

int n;
int a[20], b[20], ind[20];

bool vis[20];

bool check(vector<int> &tp, int id, int x, int is_b) {
    bool flag = false;
    myfor(i, 0, n) if (!vis[i] && (x == tp[i]) && ((abs(id - i) & 1) == is_b)) {
        vis[i] = 1;
        ind[id] = i;
        return true;
    }
    return false;
}

int cal_invesion_number() {
    int cnt = 0;
    myfor(i, 0, n) {
        for (int j = n - 1; j > i; j--) if (ind[j] < ind[j - 1]) {
            cnt++;
            swap(ind[j], ind[j - 1]);
        }
    }
    return cnt;
}

int main()
{
    cin >> n;
    myfor(i, 1, n + 1) cin >> a[i];
    myfor(i, 1, n + 1) cin >> b[i];

    int ans = INF;
    myfor(i, 0, (1 << n)) {

        bool flag = true;
        vector<int> tp;

        myfor (j, 0, n) {
            if ((i >> (n - j - 1)) & 1) tp.pb(b[j + 1]);
            else tp.pb(a[j + 1]);
        }
        sort(tp.begin(), tp.end());

        myfor(j, 0, n) {
            int is_b = (i >> (n - j - 1)) & 1;
            int x = is_b ? b[j + 1] : a[j + 1];
            if (!check(tp, j, x, is_b)){
                flag = false;
                break;
            }
        }

        if (flag) ans = min(ans, cal_invesion_number());

        memset(vis, 0, sizeof(vis));
        memset(ind, 0, sizeof(ind));
    }

    cout << ((ans == INF) ? -1 : ans) << endl;
    return 0;
}



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

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

    int x, y;
    cin >> x >> y;
    int f[7] = {1, 3, 5, 7, 8, 10, 12};
    int s[4] = {4, 6, 9, 11};
    int counterf = 0;
    int counters = 0;
    for (int i = 0; i < 7; i++) {
        if (x == f[i]) {
            counterf++;
        }
        if (y == f[i]) {
            counterf++;
        }
    }
    for (int j = 0; j < 4; j++) {
        if (x == s[j]) {
            counters++;
        }
        if (y == s[j]) {
            counters++;
        }
    }
    if (x == 2 && y == 2) {
        cout << "Yes";
        return 0;
    }
    if (counterf == 2 || counters == 2) {
        cout << "Yes";
        return 0;
    }
    if (counterf < 2 || counters < 2) {
        cout << "No";
        return 0;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pir pair<int,int>
#define qmin(x,y) (x=min(x,y))
#define qmax(x,y) (x=max(x,y))
#define rsort(x,y) sort(x,y),reverse(x,y)
#define fr first
#define se second
using namespace std;
typedef long long ll;
const int Maxn=2100000;
const int inf=0x3f3f3f3f;

int n,d,ans,x,y;

signed main() {
    // freopen("test.in","r",stdin);
    scanf("%d%d",&n,&d);
    ll sxz=1ll*d*d;
    for(int i=1;i<=n;i++) {
        scanf("%d%d",&x,&y);
        if(1ll*x*x+1ll*y*y<=sxz) ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define fr(a, b, c) for(int a = b, __ = c; a < __; a++)
#define dbg(x) cerr << ">>>>>> " << x << endl;
#define _ << " , " <<  

using namespace std;

const int inf = 400;
int bef[inf], af[inf], v[inf];

int go(const string &s, char ch){
	v[s.size()] = 0;
	for(int i = s.size() - 1; i > -1; i--){
		if(s[i] == ch){
			af[i] = 0;
		}
		else if(i + 1 < s.size()){
			af[i] = 1 + af[i+1];
		}
		else{
			af[i] = inf;
		}
		v[i] = af[i];
	}
	fr(i, 1, s.size()){
		v[i] = max(v[i], v[i-1]);
	}
	int ma = inf;
	fr(i, 0, s.size()){
		v[i] = max(int(s.size()) - i - 1, v[i]);
		ma = min(v[i], ma);
	}
	if(ma == -1)
		ma = inf;
	return ma;
}

int main(){
	ios::sync_with_stdio(0);
	string s;
	cin >> s;
	int ans = inf;
	fr(i, 'a', 'z'+1){
		ans = min(ans, go(s, i));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <utility>
#include <vector>

#define for_in(i, l, u) for (i = l; i <= u; ++i)
#define for_step(i, l, u, s) for (i = l; i <= u; i += s)
#define is_in(i, l, u) ((l) <= (i) && (i) <= (u))
#define times(N) for (int itr##N = 0; itr##N < N; ++itr##N)

using namespace std;

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

    //できない
    if (e - a > k)
    {
        cout << ":(" << endl;
    }
    else
    {
        cout << "Yay!" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <time.h>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define LINF 0x3f3f3f3f3f3f3f3f
#define INF 0x3f3f3f3f
#define PI 3.14159265
#define RAND (rand()*rand())
#define MAX(x, y) ((x) > (y) ? (x):(y)) 
#define MIN(x, y) ((x) > (y) ? (y):(x))
#define ABS(x) ((x) > 0 ? (x) : -(x))
#define CEIL(x, y) (((x) + (y) - 1)/(y))
using namespace std;
const int MAXN = 1e5 + 5;
const ll MOD = 1e9 + 7;
int N, M, K, Q, T;

int main()
{
	int i, j;
	int a, b;
	scanf("%d%d", &a, &b);
	if (500 * a >= b)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 764
# Highway Toll

PRICE_LIST = (
    (0, 0, 0, 0, 0, 0, 0, 0),
    (0, 0, 300, 500, 600, 700, 1350, 1650),
    (0, 6, 0, 350, 450, 600, 1150, 1500),
    (0, 13, 7, 0, 250, 400, 1000, 1350),
    (0, 18, 12, 5, 0, 250, 850, 1300),
    (0, 23, 17, 10, 5, 0, 600, 1150),
    (0, 43, 37, 30, 25, 20, 0, 500),
    (0, 58, 52, 45, 40, 35, 15, 0),
)

while True:
    i = int(raw_input())
    if i == 0:
        break

    it = int(raw_input().strip().replace(' ', ''))
    o = int(raw_input())
    ot = int(raw_input().strip().replace(' ', ''))

    half = False
    if (1730 <= it <= 1930 or 1730 <= ot <= 1930) and PRICE_LIST[o][i] <= 40:
        half = True

    p = PRICE_LIST[i][o]
    if half:
        p /= 2
        if p % 50:
            p = p - (p % 50) + 50

    print p

Measured memory_bytes: 4288
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int H,W;
char E[410][410];
int checked[410][410];
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
ll blk,wht;

void dfs(int x,int y){
  
  checked[x][y]=1;
  if(E[x][y]=='#'){
    blk++;
    }
  else{
    wht++;
  }

  for(int i=0;i<4;i++){
    int ny=y+dy[i];
    int nx=x+dx[i];
    if(nx< 0 || nx >=H || ny<0 || ny>=W || checked[nx][ny]==1) continue;
    if(E[x][y] == E[nx][ny]) continue;
    dfs(nx,ny);
  }
}
 
int main(){
  cin>>H>>W;
  string s;
  for(int i=0;i<H;i++){
    cin>>s;
    for(int j=0;j<W;j++){
      E[i][j]=s.at(j);
    }
  }
  ll ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(checked[i][j]==0){
        blk=0;
        wht=0;
        dfs(i,j);
        ans+=blk*wht; 
      }
    }
  }
  cout<<ans<<endl;
  return 0;
}
 

Measured memory_bytes: 14412
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;

int main() {
	string S;
	int K=0;
	cin >> S;
	
	for (int i = 0; i < S.length() - i -1; i++) {
		if (S[i] != S[S.length() - i - 1]) {
			K++;
		}
	}
	cout << K << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = sc.nextInt();
		int min = 1001;
		for(int i = 0; i < N; i++) {
			int m = sc.nextInt();
			X -= m;
			min = Math.min(min,m);
		}
		int result = N + X/min;
		System.out.println(result);
	}
}


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

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int k,s;
  cin >> k >> s;
  int ans = 0;
  for (int x = 0; x <= k; ++x) {
    for (int y = 0; y <= k; ++y) {
      if (x + y <= s and s - (x + y) <= k) ans += 1;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;



int main() {
    
    int n;
    cin>>n;
    rep(i,1LL<<n){
        cout<<i<<":";
        rep(j,19){
            if(1LL<<j&i)cout<<" "<<j;
        }
        cout<<endl;
    }
}


Measured memory_bytes: 3116
#include <iostream>
using namespace std;
int main(void) {
	long long x;
	cin >> x;
	long long ans = x / 11 * 2;
	if (x % 11 >= 7) ans += 2;
	else if (x % 11 > 0) ++ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
// N 为邻接矩阵的大小
#define N 101
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define INFTY 1 << 21

using namespace std;

int color[N], d[N], p[N], M[N][N];

void dijkstra (int s, int n) {
  for (int i = 0; i < n; i++) {
    color[i] = WHITE;
    d[i] = INFTY;
  }

  d[s] = 0;
  p[s] = -1;

  while (1) {
    int mincost = INFTY, u;

    for (int i = 0; i < n; i++) {
      if (color[i] != BLACK && d[i] < mincost) {
        mincost = d[i];
        u = i;
      }
    }

    if (mincost == INFTY)
      break;

    color[u] = BLACK;
    
    for (int v = 0; v < n; v++) {
      if (color[v] != BLACK && M[u][v] >= 0 && M[u][v] < INFTY) {

        if (d[u] + M[u][v] < d[v]) {
          d[v] = d[u] + M[u][v];
          p[v] = u;
          color[v] = GRAY;
        }        
      }
    }
  }
}

int main () {
  int n, u, v, degree, cost;
  
  cin >> n;

  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      M[i][j] = INFTY;

  for (int i = 0; i < n; i++) {
    cin >> u >> degree;
    
    for (int j = 0; j < degree; j++) {
      cin >> v >> cost;

      M[u][v] = cost;
    }
  }

  dijkstra(0, n);

  for (int i = 0; i < n; i++)
    cout << i << " " << d[i] << endl;

  return 0;
}


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

using namespace std;

typedef long long ll;


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

    if (2 * sum % (n * (n + 1)) != 0) {
        cout << "NO" << endl;
        return 0;
    }

    ll k = 2 * sum / (n * (n + 1));

    vector<ll> d(n, 0LL), t(n, 0LL);
    ll cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (i == 0) d[i] = a[0] - a[n - 1];
        else d[i] = a[i] - a[i - 1];
    }

    for (int i = 0; i < n; ++i) {
        if (k - d[i] < 0 || (k - d[i]) % n != 0) {
            cout << "NO" << endl;
            return 0;
        }
        if (i == 0) {
            t[n - 1] = (k - d[i]) / n;
            cnt += t[n - 1];
        } else {
            t[i - 1] = (k - d[i]) / n;
            cnt += t[i - 1];
        }
    }

    if (cnt != k) {
        cout << "NO" << endl;
        return 0;
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 2560
import heapq
D=int(input())
c=list(map(int,input().split()))
s=[0]
last=[0]*26
for i in range(D):
  s.append(list(map(int,input().split())))
contests=[]
for i in range(26):
  contests.append([])
  contests[-1].append(0)
  contests[-1].append(D+1)
schedule=[0]*(D+1)
score=0
for i in range(1,D+1):
  t=int(input())-1
  score+=s[i][t]
  last[t]=i
  contests[t].append(i)
  schedule[i]=t+1
  for j in range(26):
    score-=c[j]*(i-last[j])
for i in range(26):
  contests[i].sort()
m=int(input())
for i in range(m):
  d,q=map(int,input().split())
  changebefore=schedule[d]-1
  changeafter=q-1
  r=contests[changebefore]
  score-=s[d][changebefore]
  score+=s[d][changeafter]
  for j in range(len(r)-1):
    if r[j]==d:
      score-=c[changebefore]*((r[j+1]-r[j-1]-1)*(r[j+1]-r[j-1]))//2
      score+=c[changebefore]*((r[j+1]-d-1)*(r[j+1]-d))//2
      score+=c[changebefore]*((d-r[j-1]-1)*(d-r[j-1]))//2
      break
  contests[changebefore].remove(d)
  contests[changebefore].sort()
  r=contests[changeafter]
  for j in range(len(r)-1):
    if r[j+1]>d:
      score+=c[changeafter]*((r[j+1]-r[j]-1)*(r[j+1]-r[j]))//2
      score-=c[changeafter]*((r[j+1]-d-1)*(r[j+1]-d))//2
      score-=c[changeafter]*((d-r[j]-1)*(d-r[j]))//2
      break
  contests[changeafter].append(d)
  contests[changeafter].sort()
  schedule[d]=q
  print(score)

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



int main(){
    int a;
    cin >> a;
    int b;
    cin >> b;
    int k, l;
    k=min(a,b);
    l=max(a,b);
    for(int i=0;i<l;i++){
       cout<<k;
    ;}

   return 0;
}  


Measured memory_bytes: 256
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;
using std::min;
using std::max;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd(){static uint seed=416;return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());bool f(false);while(!isdigit(ch)) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();while(isdigit(ch)) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	f&&(x=-x);
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;*tar=ch,ch=getchar();while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=100005;

int main()
{
	int k;read(k);
	if(k<=500)
	{
		printf("%d\n",k);
		for(int i=1;i<=k;++i) for(int j=1;j<=k;++j) printf("%d%c",i," \n"[j==k]);
		return 0;
	}
	int n=((k+3)/4)*2;
	printf("%d\n",n);
	for(int i=0;i<n;++i)
	{
		for(int j=0;j<n;++j)
		{
			int val=i&1?n+(i+j)%n:(i+j)%n;
			if(val>=k) val-=n;
			printf("%d ",val+1);
		}
		printf("\n");
	}
	return 0;
}


Measured memory_bytes: 3756
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2582

#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

int main()
{
	int N;
	string f1,f2;
	int ans;
	while(cin >> N && N)
	{
		ans=0;
		f1 = f2 = "";
		rep(nth, N)
		{
			cin >> f1 ;

			if((f1=="lu" && f2=="ru") || (f1=="ru" && f2=="lu")){
				ans++;
			}
			else if((f1=="ld" && f2=="rd") ||(f1=="rd" && f2=="ld")){
				ans++;
			}
			f2 = f1;	
		}
		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 1212
#pragma GCC optimize("O3")
#include <iostream>
#include <climits>
#include <stdlib.h>

using namespace std;

int main(void) {
    int n, p[50], min = INT_MAX, minpos, tmp;
    bool swap = false;

    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < n-1; i++) {
        min = INT_MAX;
        for (int j = i+1; j < n; j++) {
            if (min > p[j]) {
                min = p[j];
                minpos = j;
            }
        }
        if (p[i] > min) {
            if (swap) {
                cout << "NO" << endl;
                return 0;
            }
            tmp = p[minpos];
            p[minpos] = p[i];
            p[i] = tmp;
            swap = true;
            i--;
        }
    }
    cout << "YES" << endl;
    return 0;
}


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

inline void ioThings() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#define debug(x) cerr << #x << ": <" << (x) << ">\n"
#else
#define debug(x)
#endif
}

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp(x, y)  make_pair(x, y);
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second
#define mod       1000000007
#define pi        acos(-1.0)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int main() {
  ioThings();

  int k;
  cin >> k;
  string s;
  cin >> s;

  if (sz(s) > k) cout << s.substr(0, k) + "...";
  else cout << s;

  return 0;
}


Measured memory_bytes: 3660
#include<iostream>
#include<algorithm>
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<vector>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
const long long mod = 1e9 + 7;

#define nil -1
#define max 25
struct node{int p, l, r;};
node t[25];
int h[25], d[25];

int setheight(int u){
    int h1 = 0, h2 = 0;
    if(t[u].r != nil) h1 = setheight(t[u].r) + 1;
    if(t[u].l != nil) h2 = setheight(t[u].l) + 1;
    return h[u] = (h1 > h2 ? h1 : h2);
}

void setdepth(int u, int k){
    if(u == nil) return;
    d[u] = k;
    setdepth(t[u].l, k+1);
    setdepth(t[u].r, k+1);
}

int getsibling(int u){
    if(t[u].p == nil) return nil;
    if(t[t[u].p].l != u && t[t[u].p].l != nil) return t[t[u].p].l;
    if(t[t[u].p].r != u && t[t[u].p].r != nil) return t[t[u].p].r;
    return nil;
}

void print(int u){
    cout << "node " << u << ": ";
    cout << "parent = " << t[u].p << ", ";
    cout << "sibling = " << getsibling(u) << ", ";
    int deg = 0;
    if(t[u].l != nil) deg++;
    if(t[u].r != nil) deg++;  
    cout << "degree = " << deg << ", ";
    cout << "depth = " << d[u] << ", ";
    cout << "height = " << h[u] << ", ";
    if(t[u].p == nil) cout << "root" << endl;
    else if(t[u].l == nil && t[u].r == nil) cout << "leaf" << endl;
    else cout << "internal node" << endl;
}

int main(){
    int n, v, l, r, root = 0;
    cin >> n;
    rep(i, n) t[i].p = nil;
    rep(i, n){
        cin >> v >> l >> r;
        t[v].l = l;
        t[v].r = r;
        if(l != nil) t[l].p = v;
        if(r != nil) t[r].p = v;
    }
    rep(i, n) if(t[i].p == nil) root = i;
    setdepth(root, 0);
    setheight(root);
    rep(i, n) print(i);
}


Measured memory_bytes: 3104
n = int(input())
A = [list(map(int,input().split())) for _ in range(2)]
ans = []
l = 0
for i in range(n):
  l += sum(A[0][0:i + 1])
  l += sum(A[1][i:])
  ans.append(l)
  l = 0
print(max(ans))

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

int main(){
	int n;cin>>n;
	int count=0;
	for(int i=0;i<n;++i){
		int a;cin>>a;
		count+=a%2;
	}
	if(count%2==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
 
using namespace std;
typedef long long int ll;
 
int n;
ll a[200010],r=0;
vector<ll> z={0},q;
 
vector<ll> krk(vector<ll> target){
    vector<ll> result;
    ll repeats=1,number=target[0];
    for(ll i=1;i<target.size();i++){
        if(number==target[i])repeats++;
        else{
            number=target[i];
            result.push_back(repeats);
            repeats=1;
        }
    }
    result.push_back(repeats);
    return result;
}
 
ll nCr(ll maxnum){
    ll res=0;
    for(int i=1;i<maxnum;i++){
        res+=i;
    }
    return res;
}
 
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
        z.push_back(z[i]+a[i]);
    }
    sort(z.begin(),z.end());
    q=krk(z);
    for(auto itr:q){
        r+=nCr(itr);
    }
    printf("%lld\n",r);
    
}

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

int parent( int i ) { return i / 2; }
int left( int i ) { return i * 2; }
int right( int i ) { return i * 2 + 1; }

int main()
{
	int H;
	cin >> H;
	vector<int> A( H );
	for( int i = 0; i < H; i++ ) {
		cin >> A[i];
	}

	for( int i = 0; i < H; i++ ) {
		int n = i + 1;
		cout << "node " << n << ": key = " << A[i] << ", ";
		if( parent(n) >= 1 ) cout << "parent key = " << A[parent(n) - 1] << ", ";
		if( left(n) <= H ) cout << "left key = " << A[left(n) - 1] << ", ";
		if( right(n) <= H ) cout << "right key = " << A[right(n) - 1] << ", ";
		cout << endl;
	}
}



Measured memory_bytes: 3068
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
#define ll  long long 
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
#define mod 1000000007
  vector<ll>to[1000005];
int main(){
  ll a;
  long double b;cin>>a>>b;
  ll c=b*100+0.5;
  cout<<a*c/100;
  }


Measured memory_bytes: 27140
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)
cost = 0
for i in range(1, n+1):
  cost = (cost + a[i-1]*(i+1)) % 1000000007
for i in range(1, n):
  cost = cost * 4 % 1000000007
print(cost)

Measured memory_bytes: 27108
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n;
    cin >> n ;
    int x=0;

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

        x+=b-a+1;

    }
    cout << x << endl;
}

Measured memory_bytes: 3572
#import<bits/stdc++.h>
#import<atcoder/all>
#define a(x,y)if(std::gcd(x,y)==1)A=x*atcoder::inv_mod(x,y),m=std::min(m,(A>1?A:A+N)-1);
int main(){long long m,N,A,i=1;std::cin>>N;N*=2;m=N*9;for(;i*i<N;i++)if(N%i==0){a(i,N/i)a(N/i,i)}std::cout<<m;}

Measured memory_bytes: 3660
import datetime as d
def main():
    s = d.datetime.strptime(input(), "%Y/%m/%d")
    s = d.date(s.year, s.month, s.day)
    if s <= d.date(2019,4,30):
        print("Heisei")
    else:
        print("TBD")

if __name__ == "__main__":
    main()

Measured memory_bytes: 10324
#include<cstdio>
 #include<cstring>
 #include<algorithm>
 using namespace std;
int n,ans,a[100100];
int main(){
    scanf("%d",&n);
   for(int i=1;i<=n;i++) scanf("%d",&a[i]);
   sort(a+1,a+n+1);
   reverse(a+1,a+n+1);
    for(int i=1;i<=n;i++){
        if(i+1>a[i+1]){
              for(int j=i+1;a[j]==i;j++) ans^=1;
              ans|=(a[i]-i)&1;
              puts(ans? "First":"Second");
              return 0;
           }    
    }    
} 

Measured memory_bytes: 640
#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;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;


int main(){
  int N; cin >> N;
  vector <ll> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];
  sort(A.begin(), A.end(), greater<ll>());

  map <ll, ll> count;
  for (int i = 0; i < N; i++){
    count[A[i]]++;
  }
  

  ll ans = 0;
  for (int i = 0; i < N - 1; i++){
    if (count[A[i]] > 0){
      ll num = A[i], cnt = 0;
      while (num > 0){
        cnt++; num /= 2;
      }
      ll next = pow(2, cnt) - A[i];

      if (count[next] > 0 && A[i] != next){
        ans++; count[next]--;
      }else if(count[next] > 1 && A[i] == next){
        ans++; count[A[i]]--;
      }
      count[A[i]]--;
    }
  }
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 26752
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return rand()%x;
}
inline ull rnd(){
	return ((ull)rand()<<30^rand())<<4|rand()%4;
}
const int N=1000005,mod=1000000007;
int n,sum[N],f[N];
ll ans;
int main(){
	n=read();
	sum[0]=f[0]=1;
	for(int i=1;i<=n;i++){
		f[i]=(sum[i-1]-(i>=2?f[i-2]:0)+mod)%mod;
		sum[i]=(sum[i-1]+f[i])%mod;
	}
	for(int i=0;i<n-1;i++){
		ans=(ans+(ll)f[i]*(n-1)%mod*(n-1))%mod;
		ans=(ans+(ll)f[i]*(i+1))%mod;
		//cout<<i<<" "<<ans<<endl;
	}
	ans=(ans+f[n]+(ll)f[n-1]*(n-1))%mod;
	cout<<ans<<endl;
}
/*
1 1 1
1 2 3
1 3 2
2 1 1
2 3 3
3 2 2
*/

Measured memory_bytes: 8064
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let 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: i32,
        a: [i32; n],
    };

    let res = a.iter()
        .map(|x| x.trailing_zeros())
        .min()
        .unwrap();

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


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

int main() {
  ll Ans = 0;  // 回答：
  int N; cin >> N; //段数
  int M; cin >> M; //壊れ段数：０～N-1
  vector<bool> K(N+1,false);  // 壊れてないフラグ
  int wk_K; // 壊れ段
  for(int i=0;i<M;i++){
    cin >> wk_K;
    K.at(wk_K)= true;
  }

  vector<ll> DP(N+1,0);  // その段までの移動方法数
  // DP(N) = DP(N-1) + DP(N-2)
  // 最初の２段は固定
  DP.at(0) = 1;
  if (!K.at(1)){DP.at(1)=1;}

  for(int i = 2; i <= N ; i++ ){
    if (K.at(i)){DP.at(i)=0;}
    else{
      DP.at(i) = DP.at(i-1) + DP.at(i-2);
      DP.at(i) %= MOD;
    }
  }
  cout << DP.at(N) << endl;
}


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

typedef long long ll;

int main(void){

  ll a,b;

  scanf("%lld%lld",&a,&b);

  if (a<b){
    ll tmp=a;
    a=b;
    b=tmp;
  }

  while (b) {
    ll k = a % b;
    a = b;
    b = k;
  }

  int ans=1;

  for(ll i=2;i<=1000000;i++){

    if(a%i==0){
      ans++;
      while(a%i==0) a/=i;
    }

  }
  
  if(a!=1) ans++;

  printf("%d",ans);puts("");

  return 0;

}


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

int main()
{
  int A, B;
  char op;
  cin >> A >> op >> B;
  switch (op)
  {
    case '+':
      cout << A + B;
      break;
    case '-':
      cout << A - B;
      break;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace AizuOnlineJudge {
    class Program {
        static void Main() {
            var stack = new Stack<int>();
            foreach (var v in Console.ReadLine().Split()) {
                switch (v) {
                    case "+":
                        stack.Push(stack.Pop() + stack.Pop());
                        break;

                    case "-":
                        stack.Push(- stack.Pop() + stack.Pop());
                        break;

                    case "*":
                        stack.Push(stack.Pop() * stack.Pop());
                        break;

                    default:
                        stack.Push(int.Parse(v));
                        break;
                }
            }

            Console.WriteLine(stack.Pop());
        }
    }
}



Measured memory_bytes: 18424
N=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

d=[0]*N
p=0
m=0
c=0
for i in range(N):
    d[i]=a[i]-b[i]
    if(d[i]>0):
        p+=d[i]
    else:
        m+=d[i]
        if(abs(d[i])%2==1):
            c+=1
m+=c

if(abs(m)>=(abs(p)*2)):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 40944
from math import atan, pi
a,b,x = map(float, input().split())

if a*a*b/2 > x:
    c = 2*x/a/b
    q = atan(b/c)
else:
    c = 2*x/(a**2)-b
    q = atan((b-c)/a)
q *= 180/pi
print(q)

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

int main(){
  double a, b, f;
    cin >> a >> b;
  int d, r, x = a, y = b;
  d = a/b;
  r = x%y;
  f = a/b;
  printf("%d %d %.5lf\n", d, r, f);
  return 0;
}



Measured memory_bytes: 3272
#include <iostream>
int main() {

  int N;
  double x;
  std::string u;
  double sum;
  sum = 0;

  std::cin >> N;
  for (int i = 0; i < N; i++) {
    std::cin >> x >> u;
    double tmp;
    if (u == "JPY") {
      sum += x;
    } else if (u == "BTC") {
      tmp = x * 380000.0;
      sum += tmp;
    }
  }
  std::cout << sum << std::endl;
  return 0;
}

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

int main() {
    int N;
    while (cin >> N, N) {
        int sum = 0;
        for (int i = 0, x; i < N/4; i++) cin >> x, sum += x;
        cout << sum << endl;
    }

    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define mod 1000000007



void solve()
{
    int x;cin>>x;
    int f=x/500;
    x=x%500;
    int ans=f*1000;
    int s=x/5;
    ans+=s*5;
    cout<<ans<<endl;
}
int32_t main() 
{
    rapido;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    solve();
    return 0;
}



Measured memory_bytes: 3588
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
nodes=[[] for i in range(N)]
for i in range(N-1):
    u,v,w=MAP()
    nodes[u-1].append((v-1, w))
    nodes[v-1].append((u-1, w))

ans=[-1]*N
def rec(cur, color):
    if ans[cur]!=-1:
        return
    ans[cur]=color
    for node in nodes[cur]:
        nxt,w=node
        if w%2==0:
            rec(nxt, color)
        else:
            rec(nxt, 1-color)
    return

rec(0, 0)

for i in range(N):
    print(ans[i])


Measured memory_bytes: 79408
m=24*60*60
while True:
	n=int(raw_input())
	if n==0:break
	dp=[0]*(m+1)
	for _ in range(n):
		a,d=raw_input().split()
		a,b,c=map(int,a.split(':'));
		d,e,f=map(int,d.split(':'));
		dp[a*3600+b*60+c]+=1
		dp[d*3600+e*60+f]-=1
	for i in range(m):
		dp[i+1]+=dp[i]
	print(max(dp))

Measured memory_bytes: 11652
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

pii l[105];

map<int, vector<int>> dp;

int solve(int minS, int left) {
  int ret = 0;
  for(auto x: dp) {
    if(x.first < minS) continue;
    ret = solve(x.first + 1, left);
    vector<int> amt = x.second;
    int now = 0;
    for(int i = 0; i < amt.size() && (i+1) * x.first <= left; i++) {
      now += amt[i];
      ret = max(ret, now + solve(x.first + 1, left - x.first * (i+1)));
    }
    break;
  }
  return ret;
}

int main() {
  int n, w;
  scanf("%d%d", &n, &w);
  for(int i = 0; i < n; i++) {
    int a, b;
    scanf("%d%d", &a, &b);
    l[i] = pii(a, b);
  }
  sort(l, l+n);
  for(int i = n-1; i >= 0; i--) {
    dp[l[i].first].push_back(l[i].second);
  }
  printf("%d\n", solve(0, w));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s; cin >> s;
  bool ans = false;
  for(int i=0; i<3; i++){
    if(s.at(i)=='7'){
      ans = true;
      break;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
#include <random>
using namespace std;
using ll = long long;


int main() {
	int x, y; cin >> x >> y;
	vector<int> a = { 0, 300000, 200000 ,100000, 0 };
	int s = 0;
	s += a[min(x, 4)];
	s += a[min(y, 4)];
	if (x == 1 && y == 1) s += 400000;
	cout << s << endl;
	return 0;
}


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

int main()
{
    double c1x, c1y, c1r, c2x, c2y, c2r;
	double dx, dy, d;
	scanf("%lf %lf %lf %lf %lf %lf", &c1x, &c1y, &c1r, &c2x, &c2y, &c2r);
	dx = c2x - c1x, dy = c2y - c1y;
	d = sqrt(dx * dx + dy * dy);

	double cos, sin, scale;
	double coord[4];
	if(d == c1r + c2r){
		cos = 1, sin = 0;
	}else{
		cos = (c1r * c1r + dx * dx + dy * dy - c2r * c2r) / (2 * c1r * d);
		sin = sqrt(1 - cos * cos);
	}
	scale = c1r / d;
	coord[0] = c1x + scale * (dx * cos - dy * sin);
	coord[1] = c1y + scale * (dx * sin + dy * cos);
	coord[2] = c1x + scale * (dx * cos + dy * sin);
	coord[3] = c1y + scale * (dy * cos - dx * sin);
    if(coord[0] > coord[2]){ swap(coord[0], coord[2]), swap(coord[1], coord[3]); }
    if(coord[0] == coord[2] && coord[1] > coord[3]){ swap(coord[1], coord[3]); }
    printf("%.12f %.12f %.12f %.12f\n", coord[0], coord[1], coord[2], coord[3]);

    return 0;
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=(a);i<(n);i++)
#define per(i,n,a) for (int i=(n)-1;i>=(a);i--)
#define SZ(a) int((a).size())
typedef long long ll;
typedef vector<int> VI;
typedef pair<int,int> PII;
#define pb push_back
#define mp make_pair

int h,w,n;
map<PII,int> cnt;
ll res[10];

int main() {
	scanf("%d %d %d",&h,&w,&n);
	rep(i,0,n) {
		int a,b;
		scanf("%d %d",&a,&b);
		rep(dx,-2,1) rep(dy,-2,1) {
			int x=a+dx,y=b+dy;
			if (x<=0||y<=0||x+2>h||y+2>w) continue;
			cnt[mp(x,y)]++;
		}
	}
	for (auto x:cnt) res[x.second]++;
	res[0]=ll(h-2)*(w-2);
	rep(i,1,10) res[0]-=res[i];
	rep(i,0,10) printf("%lld\n",res[i]);
}


Measured memory_bytes: 56448
import fractions
from functools import reduce

n = int(input())
a = list(map(int,input().split()))

#累積GCD
left = [0] * (n + 1)
right = [0] * (n + 1)
for i in range(n):
    #left.append(math.gcd(left[i],a[i]))
    left[i + 1] = (fractions.gcd(left[i],a[i]))
    #right.insert(0,math.gcd(right[0],a[n - 1 - i]))
    right[n - i - 1] = (fractions.gcd(right[n - i],a[n - 1 - i]))
#print(left)
#print(right)

ans = 0
for i in range(n):
    ans = max(ans,fractions.gcd(left[i],right[i + 1]))
print(ans)

Measured memory_bytes: 16144
import numpy as np
a, b, x = map(int, input().split())
ans = 0
if (a*a*b/2) <= x:
    ans = np.rad2deg(np.arctan((2*(a*a*b-x))/(a*a*a)))
else:
    ans = np.rad2deg(np.arctan((a*b*b)/(2*x)))
print('{:.10f}'.format(ans))


Measured memory_bytes: 12488
def make_divisors(n):
    divisors = []

    for i in range(1, int(n**0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    return divisors


N = int(input())
A = sorted([int(x) for x in input().split()])

ans = 1
divisors = make_divisors(A[0]) + make_divisors(A[1])
divisors = sorted(set(divisors), reverse=True)

for divisor in divisors:
    indivisible_count = 0
    for i in range(N):
        if A[i] % divisor != 0:
            indivisible_count += 1

    if indivisible_count <= 1:
        ans = divisor
        break

print(ans)


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

int main(void){
    char s[100001];

    scanf("%s", s);

    for(char i = 'a'; i <= 'z'; i++){
        for(int j = 0; j < strlen(s); j++){
            if(i == s[j]){
                break;
            }else{
                if(j == strlen(s) - 1){
                    printf("%c\n", i);
                    return 0;
                }
            }
        }
    }

    printf("None\n");

    return 0;

} 


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main()
{

	int n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i, 0, n)cin >> a[i];
	rep(i, 0, n - k) {
		if (a[i] >= a[k + i]) {
			puts("No");
		}
		else puts("Yes");
	}
	return 0;
}

Measured memory_bytes: 4048
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  string S, T;
  cin>>S>>T;
  int ans = inf;
  int tmpans;
  for(int i=0;i<=S.size()-T.size();++i) {
    tmpans = 0;
    for(int j=0;j<T.size();++j) {
      if(S[i+j]!=T[j]) tmpans++;
    }
    ans = min(ans, tmpans);
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 3604
def main():
    k, a, b = map(int, input().split())
    cookie = 1
    if b <= a + 1 or 1 + k <= a:
        cookie += k
    else:
        cookie += a - 1
        k -= a - 1
        if k % 2:
            k -= 1
            cookie += 1
        cookie += (b - a) * max(0, k // 2)
    print(cookie)


if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int AC = max(A, C);
  int BD = min(B, D);
  if (AC < BD)
    cout << BD - AC << endl;
  else
    cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;


int main(){
    ll s,t,k;
    cin >> s >> t >> k;
    if (s<k){
        cout << 0 << " " << max(0LL,t+s-k) << endl;
    }else{
        cout << s-k << " " << t << endl;
    }
    
    return 0;
}






Measured memory_bytes: 256