akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <cstring>
#include <string>
#include <cctype>
#include <cassert>
#include <queue>

using namespace std;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,b,e) for(int i = (b); i <= (e); i++)
#define INF (1001001001)
#define EPS (1e-15)

#define pr(x) do{cerr << (#x) << " = " << (x) << endl;}while(0)
#define pri(x,i) do{cerr << (#x) << "[" << i << "] = " << (x[i]) << endl;}while(0)
#define pra(x,n) rep(__i,n) pri(x,__i);
#define prar(x,b,e) repr(__i,b,e) pri(x,__i);

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vint;
typedef vector<pint> vpint;

ll MOD = 1000000007;

int in() {
	int a;
	scanf("%d ", &a);
	return a;
}

struct V {
	pint w;
	vint ch;
	int par;
	int d;
	int X;
};

int main() {
	int N = in();
	vector<V> g(N);
	g[0].par = -1;
	g[0].d = 0;
	repr(i,1,N-1) {
		int P = in() - 1;
		g[i].par = P;
		g[i].d = g[P].d + 1;
		g[P].ch.pb(i);
	}
	rep(i,N) g[i].X = in();
	
	priority_queue<pint> q;
	rep(i,N) q.push(mp(g[i].d, i));
	while (! q.empty()) {
		int ind = q.top().second;
		q.pop();
		V &v = g[ind];
		pr(ind);
		
		vint ok(v.X + 1);
		ok[0] = 1;
		int sum = 0;
		rep(i,v.ch.size()) {
			pr(g[v.ch[i]].w.first);
			pr(g[v.ch[i]].w.second);
			pr(v.X);
			sum += g[v.ch[i]].w.first + g[v.ch[i]].w.second;
			for (int k = v.X; k >= 0; k--) {
				int a = k >= g[v.ch[i]].w.first && ok[k - g[v.ch[i]].w.first];
				int b = k >= g[v.ch[i]].w.second && ok[k - g[v.ch[i]].w.second];
				ok[k] = a || b;
			}
		}
		pr(sum);
		bool found = false;
		for (int i = v.X; i >= 0; i--) if (ok[i]) {
			int k = sum - i;
			pr(k);
			pr(v.X);
			v.w = mp(v.X, k);
			found = true;
			break;
		}
		if (! found) goto NG;
	}
	
	
	cout << "POSSIBLE" << endl;
	return 0;
	
	NG:;
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


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

using namespace std;

using ll = long long;

int main(){
    ll n; cin >> n;
    vector<string> v;
    ll ans[1000]={0}, garbo[1000] = {0};
    for(ll i = 0; i < n; ++i){
        string tmp; cin >> tmp;
        v.push_back(tmp);
    }
    for(ll i = 0; i < v[0].length(); ++i){
        ans[v[0][i]]++;
    }
    for(ll i = 1; i < n; ++i){
        for(ll j = 0; j < v[i].length(); ++j){
            garbo[v[i][j]]++;
        }
        for(ll j = 0; j < 1000; ++j){
            ans[j] = min(ans[j], garbo[j]);
        }
        memset(garbo, 0, sizeof(garbo));
    }
    for(ll i = 0; i < 1000; ++i){
        if(ans[i] != 0){
            for(ll j = 0; j < ans[i]; ++j){
                cout << char(i);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
//
// Created by Edward on 4/25/2020.
//

#include <bits/stdc++.h>

using namespace std;

namespace bitonictsp{
    int x[1000];
    int N;
    int y[1000];
    double long dist[1000][1000];
    double long t[1000][1000];
    double long dp[1000];
    int main(){
        cin >> N;
        for(int i = 0; i < N; i++){
            cin >> x[i] >> y[i];
        }
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                dist[i][j] = sqrt((x[i] - x[j])*(x[i] - x[j]) + (y[i]-y[j])*(y[i]-y[j]));
            }
        }
        for(int i = 0; i < N; i++) {
            t[i][i] = 0;
            for (int j = i + 1; j < N; j++) {
                t[i][j] = t[i][j - 1] + dist[j - 1][j];
            }
        }
        dp[0] = dist[0][1];
        for(int i = 1; i < N-1; i++){
            dp[i] = dp[i-1] + dist[i-1][i+1];
            for(int j = 0; j < i-1; j++){
                dp[i] = min(dp[i], dp[j] + t[j+1][i] + dist[j][i+1]);
            }
        }
        cout << fixed << setprecision(10) << (dp[N-2] + dist[N-2][N-1]) << endl;
    }
}

int main(){
    bitonictsp::main(); return 0;
}


Measured memory_bytes: 30192
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
 
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin>>n;
    map<string,int> mp;
    int mx = 0;
    vector<string> v;
    for(int i = 0 ; i < n ; i++){
        string s;
        cin>>s;
        mp[s]++;
        if(mx < mp[s]){
            v.clear();
            mx = mp[s];
            v.push_back(s);
        }else if(mx == mp[s]){
            v.push_back(s);
        }
            
    }
    sort(v.begin(),v.end());
    for(auto i:v){
        cout<<i<<'\n';
    }
}

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

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

    int maxPrime = 0;
    int n = 2;
    vector<int> primeList;
    while (maxPrime < x)
    {
        bool isPrime = true;
        for (int i = 0; i < primeList.size(); ++i)
        {
            int prime = primeList.at(i);
            if (n % prime == 0)
            {
                isPrime = false;
                break;
            }
        }
        if (isPrime)
        {
            primeList.push_back(n);
            maxPrime = n;
        }
        ++n;
    }

    cout << maxPrime << endl;
}

Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  int K;
  cin >> K;
  int n = 0, m = 0;
  rep1(i, K) {
    if (i % 2 == 0) n++;
    else m++;
  }
  cout << n * m << endl;
  return 0;
}


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

using namespace std;
using pii = pair<int, int>;

#define rep(i,n) for(int i=0;i<(n);++i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
#define in(v) cin>>v;
#define out(v) cout<<v<<"\n"
const int INF = numeric_limits<int>::max();
const int W = 0, B = 1, NONE = 2;

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

  vector<vector<pii>> edge(N, vector<pii>());
  vector<int> color(N, NONE);

  rep(i, N-1) {
    int u, v, w;
    cin >> u >> v >> w;
    --u; --v;
    edge[u].push_back(pii(v, w));
    edge[v].push_back(pii(u, w));
  }
  queue<int> q;
  q.push(0);
  color[0] = W;
  while (!q.empty()) {
    int p = q.front(); q.pop();
    iter(it, edge[p]) {
      int to = it->first,
          w = it->second;
      if (color[to] == NONE) {
        q.push(to);
        if (w % 2 == 1)
          color[to] = 1 - color[p];
        else
          color[to] = color[p];
      }
    }
  }
  rep(i, N)
    out(color[i]);

  return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if(s[0] == s[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define MAX 1000000

using namespace std;

int isprime[MAX];

void ERATOSUTENESUNOHURUI(void){

  for( int i = 0 ; i < MAX ; i++ ) isprime[i] = 1;
  isprime[0] = isprime[1] = 0;

  for( int i = 2 ; i*i < MAX ; i++ ){
    if( isprime[i] ){
      for( int j = i+i ; j < MAX ; j += i ){
	isprime[j] = 0;
      }
    }
  }

}


int main(void){

  ERATOSUTENESUNOHURUI();

  int n;
  while( cin >> n , n ){
 
    int cnt = 0;
    for( int i = 2 ; i <= n/2 ; i++ ){
      if( isprime[i] && isprime[n - i] ) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

#define REP(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62LL)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;

  for (int i = 1; i <= s.size() - 2; i++) {
    int len = s.size() - i;
    if (len % 2 != 0)
      continue;

    string s1(s.begin(), s.begin() + len/2);
    string s2(s.begin() + len/2, s.begin() + len);

    if (s1 == s2) {
      cout << len << endl;
      return 0;
    }
  }
  return 0;
}

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

using namespace std;

int main() {
    int N;
    cin >> N;
    string result = "APPROVED";
    while (N > 0) {
        int num;
        cin >> num;
        if (num % 2 == 0) {
            if (num % 3 != 0 && num % 5 != 0) {
                result = "DENIED";
            }
        }
        N--;
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

int main (){
  ll n;
  cin>>n;
  ll ans=0;
  vector<vector<vector<vector<ll> > > >v(n+1,vector<vector<vector<ll> > >(4,vector<vector<ll> >(4,vector<ll>(4,0))));
  for(ll i1=0;i1<4;i1++){
    for(ll i2=0;i2<4;i2++){
      for(ll i3=0;i3<4;i3++){
        if(!((i1==0&&i2==1&&i3==2)||(i1==0&&i2==2&&i3==1)||(i1==1&&i2==0&&i3==2))){
          v[3][i1][i2][i3]+=1;
        }
      }
    }
  }
  for(ll i=4;i<=n;i++){
    for(ll i1=0;i1<4;i1++){
      for(ll i2=0;i2<4;i2++){
        for(ll i3=0;i3<4;i3++){
          for(ll i4=0;i4<4;i4++){
            if(!((i4==0&&i1==1&&i3==2)||(i4==0&&i2==1&&i3==2)||(i1==0&&i2==1&&i3==2)||(i1==0&&i2==2&&i3==1)||(i1==1&&i2==0&&i3==2))){
              v[i][i1][i2][i3]+=v[i-1][i4][i1][i2];
              v[i][i1][i2][i3]%=MOD;
            }
          }
        }
      }
    }
  }
  for(ll i1=0;i1<4;i1++){
    for(ll i2=0;i2<4;i2++){
      for(ll i3=0;i3<4;i3++){
        ans+=v[n][i1][i2][i3];
        ans%=MOD;
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<string>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main()
{
	int x,a,b;
	cin>>x>>a>>b;
	int a1=abs(a-x),b1=abs(b-x);
	if(a1<b1)
	cout<<"A";
	else
	cout<<"B";
	return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map(String::toInt)
    val a = readLine()!!.split(' ').map(String::toInt)
    val odd = a.filter { it % 2 == 1 }
    val even = a.filter { it % 2 == 0 }
    if (odd.size > 2) println("Impossible") else {
        val aa = ArrayList<Int>()
        val bb = ArrayList<Int>()
        if (a.size == 1) {
            aa.add(a[0])
            if (a[0] == 1) {
                bb.add(1)
            } else {
                bb.add(a[0] - 1)
                bb.add(1)
            }
        } else {
            var bg = 0
            if (odd.size > 0) {
                aa.add(odd[0])
                bb.add(odd[0] + 1)
            } else {
                aa.add(even[0])
                bb.add(even[0] + 1)
                bg = 1
            }
            for (i in bg..even.size - 1) {
                aa.add(even[i])
                bb.add(even[i] - (if (i == even.size - 1 && odd.size < 2) 1 else 0))
            }
            if (odd.size == 2) {
                aa.add(odd[1])
                if (odd[1] > 1) bb.add(odd[1] - 1)
            }
            if (aa.size == 1) {
                bb.add(1)
            }
        }
        println(aa.joinToString(" ", transform = Int::toString))
        println(bb.size)
        println(bb.joinToString(" ", transform = Int::toString))
    }
}


Measured memory_bytes: 22584
use proconio::input;

fn main() {
  input! {
    n: usize,
    k: usize,
    ps: [f64;n]
  }

  let mut range = (0,k-1);
  let mut max = ps.iter().by_ref().take(k).sum::<f64>();
  let mut previous = max;
  for i in k..n {
    let val = previous - ps[i - k] + ps[i];
    if max < val {
      range = (i - k + 1, i);
      max = val;
    }
    previous = val;
  }
  
  let mut result = 0f64;
  for i in (range.0)..=(range.1) {
    result += (1f64 + ps[i]) / 2f64;
  }
  
  println!("{}", result);
}

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

int main() {
  int a,b,c,d,e,f,g,h,i,N,j,k,l,m,n,o,p,q,r,s;
  cin>>a>>b>>c>>d>>e>>f>>g>>h>>i>>N>>j>>k>>l>>m>>n>>o>>p>>q>>r>>s;
    if(a==j || a==k || a==l || a==m || a==n || a==o || a==p || a==q || a==r || a==s){a=0;} 
    if(b==j || b==k || b==l || b==m || b==n || b==o || b==p || b==q || b==r || b==s){b=0;}
    if(c==j || c==k || c==l || c==m || c==n || c==o || c==p || c==q || c==r || c==s){c=0;}
    if(d==j || d==k || d==l || d==m || d==n || d==o || d==p || d==q || d==r || d==s){d=0;}
    if(e==j || e==k || e==l || e==m || e==n || e==o || e==p || e==q || e==r || e==s){e=0;}
    if(f==j || f==k || f==l || f==m || f==n || f==o || f==p || f==q || f==r || f==s){f=0;}
    if(g==j || g==k || g==l || g==m || g==n || g==o || g==p || g==q || g==r || g==s){g=0;}
    if(h==j || h==k || h==l || h==m || h==n || h==o || h==p || h==q || h==r || h==s){h=0;}
    if(i==j || i==k || i==l || i==m || i==n || i==o || i==p || i==q || i==r || i==s){i=0;}
 
 if(a==0 && b==0 && c==0){cout<<"Yes"<<endl;}
  else if(d==0 && e==0 && f==0){cout<<"Yes"<<endl;}
  else if(g==0 && h==0 && i==0){cout<<"Yes"<<endl;}
  else if(a==0 && d==0 && g==0){cout<<"Yes"<<endl;}
  else if(b==0 && e==0 && h==0){cout<<"Yes"<<endl;}
  else if(c==0 && f==0 && i==0){cout<<"Yes"<<endl;}
  else if(a==0 && e==0 && i==0){cout<<"Yes"<<endl;}
  else if(c==0 && e==0 && g==0){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}




Measured memory_bytes: 256
n=int(input())
D=[[0 for _ in range(10)] for _ in range(10)]
for i in range(1,n+1):
    s=str(i)
    D[int(s[0])][int(s[-1])]+=1
a=0
for i in range(10):
    for j in range(10):
        a+=D[i][j]*D[j][i]
print(a)

Measured memory_bytes: 40428
//“Make it work, make it right, make it fast.” – Kent Beck
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double dd;
const int siz = 1e6 + 5;
const int MOD = 1e9 + 7;
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl;

void solve() {
  string s;
  cin >> s;
  int n = (int)s.size();
  ll ans = 0;
  for(int i = 1; i < (1 << (n-1)); i++) {
    string res = "";
    res += s[0];
    for(int j = 0; j < n-1; j++) {
      if((1 & (i >> j))) {
        ans += stoll(res);
        res.clear();
      }
      res += s[j+1];
    }
    ans += stoll(res);
  }
  cout << ans+stoll(s) << endl;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  cout << fixed << setprecision(10);
  int t = 1;
  // cin >> t;
  for(int tt = 1; tt <= t; tt++) {
    //cout << "Case #" << tt << ": ";
    solve();
  }
  return 0;
}  

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b;
  in2(a, b);
  a = max(a - b, 0ll);
  out(a);
  memi;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

INF = 10**16

def solve(N: int, W: int, w: "List[int]", v: "List[int]"):

    V = max(v) * N
    dp = []
    for _ in range(N):
        l = [INF]*(V + 1)
        dp.append(l)
    
    # initialize
    for j in range(V + 1):
        dp[0][j] = w[0] if j == v[0] else INF
        dp[0][0] = 0

    for i in range(1, N):
        for j in range(V + 1):
            if j >= v[i]:
                dp[i][j] = min(dp[i - 1][j - v[i]] + w[i], dp[i - 1][j])
            else:
                dp[i][j] = dp[i - 1][j]
    
    res = 0
    for j in range(V + 1):
        if dp[N - 1][j] <= W:
            res = j
    print(res)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = int(next(tokens))  # type: int
    w = [int()] * (N)  # type: "List[int]"
    v = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        w[i] = int(next(tokens))
        v[i] = int(next(tokens))
    solve(N, W, w, v)

if __name__ == '__main__':
    main()


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

struct mint {
    ll x;
    mint(ll x = 0) : x((x % MOD + MOD) % MOD) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a) {
        if ((x += a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator-=(const mint a) {
        if ((x += MOD - a.x) >= MOD)
            x -= MOD;
        return *this;
    }
    mint &operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }

    mint inv() const { return pow(MOD - 2); }
    mint &operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

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

    vector<mint> comb(n + 1);
    comb[0] = 1;
    for (int i = 1; i <= n; ++i) {
        comb[i] = comb[i - 1] * (n - i) / i;
    }

    mint ans = 0;
    mint col = m;
    for (int x = n - 1; x >= 0; --x) {
        mint now = col;
        now *= comb[x];
        if (x <= k)
            ans += now;
        col *= m - 1;
    }

    cout << ans << endl;

    return 0;
}

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

map<string, int> mp;
int n;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        string x;
        cin >> x;
        sort(x.begin(), x.end());
        mp[x]++;
    }
    ll ans = 0;
    for (auto &v : mp) {
        if (v.second > 1) {
            ans = ans + 1LL * v.second * (v.second - 1) / 2;
        }
    }
    printf("%lld\n", ans);
    return 0;
}

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

#define int long long
#define mod 1000000007

using namespace std;

int32_t main()
{
    int k,a,b;
    cin >> k >> a >> b;

    if(b-a <= 1 || k+1 <= a)
        cout << k+1 << endl;
    else
    {
        k -= (a-1);
        int ans = a + (b-a)*(k/2) + k%2;
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
n = int(input())
otosidama_list=[]
ans = 0
for i in range(n):
        otosidama_list.append(input().split(" "))
#print(otosidama_list)
for j in range(n):
        otosidama_list[j][0] = float(otosidama_list[j][0])
        if otosidama_list[j][1] == "JPY":
                ans += otosidama_list[j][0]
        elif otosidama_list[j][1] == "BTC":
                ans += otosidama_list[j][0] * 380000.0
print(ans)


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

int main()
{
    #ifdef DOC
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    int n, k; cin >> n >> k;
    string s; cin >> s;
    s[k-1] += (97-65);
    cout << s;
    
}


Measured memory_bytes: 256
K = gets.to_i
X, Y = gets.split.map(&:to_i)
A, B = [X.abs, Y.abs].min, [X.abs, Y.abs].max

def solve()
  return nil if K.even? && (A + B).odd?

  res = []

  if K <= B
    x = y = 0
    d = (K - A - B) % K
    unless d.zero?
      i = d / 2
      i += K / 2 + 1 if d.odd?
      res << [x - i, y + K - i]
      x += -i
      y += K - i
    end
    until x == A && y == B
      a = A - x
      b = B - y
      dx = [a, K].min
      dy = [b, K - dx].min
      res << [x + dx, y + dy]
      x += dx
      y += dy
    end
  else
    if A + B == K
      res << [A, B]
    elsif (A + B).even?
      i = (B - A) / 2
      res << [K - i, i]
      res << [A, B]
    else
      x = K - (K / 2)
      y = 0 - (K / 2)
      res << [x, y]
      x -= K
      i = (A + B) / 2
      res << [x + i, y + i]
      res << [A, B]
    end
  end

  res
end

score = solve

unless score
  puts -1
else
  puts score.size, score.map{|x, y|
    x, y = y, x if X.abs > Y.abs
    y    = -y   if Y < 0
    x    = -x   if X < 0
    "#{x} #{y}"
  }
end


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

int main() {
  string s, t;
  cin >> s >> t;
  sort(s.begin(), s.end());
  sort(t.begin(), t.end(), greater<int>());
  string ans = "No";
  if (s < t) ans = "Yes";
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main() {
    // g++ -Wall -Wextra -O2 -std=c++17 helloworld.cpp
    double n;

    cin >> n;

    int x1, x2;

    int x = n / 1.08;
    x1 = floor(x);
    x2 = floor(x) + 1;

    if (floor(x1 * 1.08) == n) {
        cout << x1 << endl;
        return 0;
    }

    if (floor(x2 * 1.08) == n) {
        cout << x2 << endl;
        return 0;
    }

    cout << ":(" << endl;
    return 0; 
}

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

using namespace std;

using int64 = long long;

struct Node {
  vector< Node * > child;
  int64 mult;
  int64 sum;
  string s;

  Node() : mult(1), sum(0) {}

  char dfs(int pos) {
    if(pos >= mult * sum) return '0';
    pos %= sum;
    if(s.size()) return s[pos];
    for(auto &p : child) {
      if(pos - p->mult * p->sum < 0) return p->dfs(pos);
      pos -= p->mult * p->sum;
    }
    throw 0;
  }
};

const int64 LIM = 1 << 29;

string S;
int ptr;

Node *expr() {
  if(S[ptr] == '(') {
    ++ptr;
    Node *ret = expr();
    ++ptr;
    return ret;
  } else {
    Node *root = new Node();
    while(isdigit(S[ptr]) || isalpha(S[ptr])) {
      Node *beet;
      if(isalpha(S[ptr])) {
        beet = new Node();
        beet->s += S[ptr++];
        beet->sum = (int) beet->s.size();
      } else {
        int mult = 0;
        while(isdigit(S[ptr])) mult = mult * 10 + S[ptr++] - '0';
        if(isalpha(S[ptr])) {
          beet = new Node();
          beet->s += S[ptr++];
          beet->sum = (int) beet->s.size();
        } else {
          beet = expr();
        }
        beet->mult = mult;
      }
      root->sum += min(LIM, beet->mult * beet->sum);
      root->sum = min(LIM, root->sum);
      root->child.emplace_back(beet);
    }
    return root;
  }
}


int main() {
  int idx;
  while(cin >> S >> idx, S != "0") {
    ptr = 0;
    S += "$";
    auto root = expr();
    cout << root->dfs(idx) << endl;
  }
}


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

long int grid[3][3];

bool find(
set<long int>hash){
    long int i,j;
    for(i=0;i<3;i++){
        int r=0;
        int c=0;
        for(j=0;j<3;j++){
            if(hash.find(grid[i][j])!=hash.end()) r++;
            if(hash.find(grid[j][i])!=hash.end()) c++;
        }
        if(r==3 || c==3) return true;
    }
    return false;
}


bool diagonal(
set<long int>hash){
  
    int cnt=0;
    if(hash.find(grid[0][0])!=hash.end()) cnt++;
    if(hash.find(grid[1][1])!=hash.end()) cnt++;
    if(hash.find(grid[2][2])!=hash.end()) cnt++;
    
    if(cnt==3) return true;
    cnt=0;
    if(hash.find(grid[0][2])!=hash.end()) cnt++;
    if(hash.find(grid[1][1])!=hash.end()) cnt++;
    if(hash.find(grid[2][0])!=hash.end()) cnt++;
    
    return cnt==3;
}

int main()
{
    long int i,j,d;
 
    for(i=0;i<3;i++) for(j=0;j<3;j++) cin>>grid[i][j];
    long int n;
    cin>>n;
    
    set<long int>hash;
     
    for(i=0;i<n;i++){ cin>>d; hash.insert(d);}
    
    if(find(hash) || diagonal(hash)) cout<<"Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()
def resolve():
    n,x=map(int,input().split())
    A=list(map(int,input().split()))
    ans=sum(A)

    now=A[:]
    for i in range(1,n):
        now=[min(now[j],A[(i+j)%n]) for j in range(n)]
        ans=min(ans,sum(now)+i*x)

    print(ans)
resolve()

Measured memory_bytes: 43996
while True:
    w, h = map(int, input().split())
    if w == 0:
        break
    a = []
    for i in range(h):
        t = list(input())
        a.append(t)
        if '@' in t:
            x = i
            y = t.index('@')
    stk = [[x, y]]
    c = 1
    while True:
        if stk == []:
            break
        x, y = stk.pop()
        if y != w-1 and a[x][y+1] == '.':
            a[x][y+1] = '@'
            stk.append([x, y+1])
        if y != 0 and a[x][y-1] == '.':
            a[x][y-1] = '@'
            stk.append([x, y-1])
        if x != h-1 and a[x+1][y] == '.':
            a[x+1][y] = '@'
            stk.append([x+1, y])
        if x != 0 and a[x-1][y] == '.':
            a[x-1][y] = '@'
            stk.append([x-1, y])
    print(sum([t.count('@') for t in a]))

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

int main() {
  int X;
  cin >> X;
  if (X <=599) {
    cout << 8 << endl;
  } else if(X <= 799) {
    cout << 7 << endl;
  } else if(X <= 999) {
    cout << 6 << endl;
  } else if(X <= 1199) {
    cout << 5 << endl;
  } else if(X <= 1399) {
    cout << 4 << endl;
  } else if (X <=1599) {
    cout << 3 << endl;
  } else if(X <= 1799) {
    cout << 2 << endl;
  } else
  {
    cout << 1 << endl;
  }
  
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define dbg(x) #x "=" << x << " "
#define fore(i,a,b) for(int i=a,gon=b;i<gon;++i)
#define pb push_back
#define F first
#define S second
typedef double lf;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifdef LOCAL
        freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #else
        #define endl '\n'
    #endif
    int n, k;
    cin >> n >> k;
    int mn = 1e9;
    fore(i,0,n+1) {
        int val = (1<<i) + (n-i)*k;
        mn = min(mn, val);
    }
    cout << mn << endl;
}


Measured memory_bytes: 256
/**
 * We'll use dynamic programming to solve this problem.  The number of ways a
 * particular square can be reached is equal to the number of ways the square
 * above it can be reached plus the number of ways the square to the left of
 * it can be reached.  Then we have for N(i, j), the number of ways square
 * (i, j) can be reached, that:
 * 
 * N(1, 1) = 1
 * N(i, j) = N(i-1, j) + N(i, j-1) if (i, j) is empty
 * N(i, j) = 0                     if (i, j) is a wall
 */

int get_grid_count(unsigned char **arr, int h, int w)
{
    int n[h][w];
    int i, j;
    
    n[0][0] = 1;
    
    for (i=1; i<h; i++)
    {
        if (!arr[i][0])
        {
            n[i][0] = 0;
        }
        else
        {
            n[i][0] = n[i-1][0];
        }
    }
    
    for (i=1; i<w; i++)
    {
        if (!arr[0][i])
        {
            n[0][i] = 0;
        }
        else
        {
            n[0][i] = n[0][i-1];
        }
    }
    
    for (i=1; i<h; i++)
    {
        for (j=1; j<w; j++)
        {
            if (!arr[i][j])
            {
                n[i][j] = 0;
            }
            else
            {
                int left = n[i-1][j] % 1000000007;
                int up = n[i][j-1] % 1000000007;
                n[i][j] = (left + up) % 1000000007;
            }
        }
    }
    
    /*for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            printf("%d\t", n[i][j]);
        }
        printf("\n");
    }*/
    
    return n[h-1][w-1];
}

int main(int argc, char **argv)
{
    int h, w;
    unsigned char **arr;
    int i, j;
    
    scanf("%d %d", &h, &w);
    
    arr = (unsigned char **)malloc(sizeof(unsigned char *)*h);
    
    for (i=0; i<h; i++)
    {
        arr[i] = (unsigned char *)malloc(sizeof(unsigned char)*w);
        for (j=0; j<w; j++)
        {
            char c;
            scanf("%c", &c);
            if (c == '.')
            {
                arr[i][j] = 1;
            }
            else if (c == '#')
            {
                arr[i][j] = 0;
            }
            else if (c == '\n')
            {
                // Ignore newlines.
                j--;
            }
        }
    }
    
    /*for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            if (arr[i][j])
            {
                printf(".");
            }
            else
            {
                printf("#");
            }
        }
        printf("\n");
    }*/
    
    printf("%d", get_grid_count(arr, h, w));
    
    return 0;
}

Measured memory_bytes: 5120
#include<stdio.h>
int main(void){
  int n, i, j, temp, ans=1;
  scanf("%d", &n);
  int a[n];
  for(i=0;i<n;i++){
      scanf("%d", &a[i]);
  }
  for(i=0; i<n; i++){
      for(j=n-1; j>i; j--){
        if(a[j] < a[j-1]){
          temp = a[j];
          a[j] = a[j-1];
          a[j-1] = temp;
        }
      }
    }
  for(i=0;i<n-1;i++){
    if(a[i]!=a[i+1]){
      ans++;
    }
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    int t;
    t=n*a;
    if (t<b)
    {
        cout<< t;
    }
    
    else {
        cout <<b;
    }

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
#ABC126 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n,k = LI()
ans = 0
for i in range(1,n+1):
    if k <= i:
        ans += 1/n
    else:
        cnt = 0
        m = i
        while m < k:
            m *= 2
            cnt += 1
        ans += (1/n)*(1/2)**cnt
print(ans)


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

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> A(n, 0);
  vector<int> B(n, 0);
  vector<int> C(n-1, 0);
  for (int i = 0; i < n; i++) cin >> A[i];
  for (int i = 0; i < n; i++) cin >> B[i];
  for (int i = 0; i < n - 1; i++) cin >> C[i];
  
  int ans = B[A[0] - 1];
  
  for (int i = 1; i < n; i++) {
   	ans += B[A[i] - 1];
    if (A[i] - A[i-1] == 1) {
      ans += C[A[i-1] - 1];
    }      
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		try(Scanner sc = new Scanner(System.in)) {
			
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if ( a < b ) {
				System.out.println(buildStr(a,b));
			}
			else {
				System.out.println(buildStr(b,a));
			}

		}
	}
	
	private static String buildStr(int base, int times) {
		StringBuilder sb = new StringBuilder();
		
		for(int i = 0 ; i < times ; i++ ) {
			sb.append(String.valueOf(base));
		}
		
		return sb.toString();
		
	}
}

Measured memory_bytes: 21076
from itertools import combinations

n = int(input())
s = [input() for _ in range(n)]

cnt = dict({'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0})
for name in s:
    if name[0] in cnt:
        cnt[name[0]] += 1

ans = 0
for i, j, k in combinations(cnt, 3):
    ans += cnt[i] * cnt[j] * cnt[k]
print(ans)


Measured memory_bytes: 16280
n = int(input())
 
c = []
s = []
f = []
 
for i in range(n-1):
    c_, s_, f_ = map(int, input().split())
    c.append(c_)
    s.append(s_)
    f.append(f_)

for i in range(n-1):
    time = 0
    for j in range(i, n-1):
        if  time < s[j]:
            time = s[j]
        elif time % f[j] == 0:
            pass
        else:
            time += f[j] - (time % f[j])
        time += c[j]
    print(time)
print(0)

Measured memory_bytes: 3064
/*
welcome to my code           hi from    s_agnik1511 
Don't just copy it.
Analyze it.
coz that's what heroes do.....
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<string.h>
#include<numeric>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
#define dude             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mesc(number,character)   char f[number];memset(f,character,number);
#define mesi(number,value)   int f[number];memset(f,value,number);
#define specio           ifstream cin("input.txt");ofstream cout("output.txt");
#define fr(i,start,end)  for(i=start;i<=end;i++)
#define rf(i,start,end)  for(i=start;i>=end;i--)
#define tst              int t;cin>>t;while(t--)
#define ai               ll n,i;cin>>n;ll a[n];
#define pi               3.14159265358979323846
#define ll               long long int
#define acc              accumulate
#define ld               long double
#define pb               push_back
#define r0               return 0;
#define pp               pop_back
#define vec              vector
#define sec              second
#define S                string
#define D                double
#define len              length
#define br               break;
#define wh               while
#define fs               first
#define F                float
#define gcd              __gcd
#define sz               size
#define endl              "\n"
#define sp              " "
const ll ifn=-1000000000000000000;
const ll inf=1000000000000000000;
const int N=100000;
    //vec<ll>arr(N,-1);
    //memset(arr,0,N);
ll power(ll x, ll y, ll p) { 
    ll res = 1;
    x = x % p;  
    while (y > 0) { 
        if (y & 1) 
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p; 
    } 
    return res; 
} 
void swap(int x,int y) {
    int t=x;
    x=y;
    y=t;
}
bool vow(char c) {
    if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u'||c=='A'||c=='E'||c=='I'||c=='O'||c=='U') {
        return true;
    }
    else {
        return false;
    }
}
/*int facti(ll x) {
    if(arr[x]!=-1)return arr[x];
    else {
    if(x<=1) {
        arr[x]=1;
    }
    else if(x==2) {
        arr[x]=2;
    }
    else {
        arr[x]=x*facti(x-1);
        arr[x]%=1000000007;
    }
    return arr[x]%1000000007;
    }
}*/
bool prim(ll x) {
    if(x==1) {
        return false;
    }
    ll i;
    fr(i,2,sqrt(x)) {
        if(x%i==0) {
            return false;
        }
    }
    return true;
}
int chek(S s,int i,int j) {
    ll cnt=0,k,a;
    fr(k,i,j) {
        //cnt=(cnt*10)+(int(s[k])-48);
        a=int(s[k])-48;
        cnt=(cnt*10)+(a);
    }
    return cnt;
}
int lcm(ll a,ll b) {
    return (a*b)/gcd(a,b);
}
int fun(S s) {
    sort(s.begin(),s.end());
    return (int(s[0])-48)*(int(s[s.len()-1])-48);
}
ll ciel(ll x,ll y) {
    if(x%y) {
        return x/y +1;
    }
    return x/y;
}
int perm(ll x) {
    return x*(x-1)/2;
}
ll sofs(ll n) {
    return (n*(n+1))/2;
}
void what_should_be_the_logic() {
ll a,b;
cin>>a>>b;
cout<<a*b;
}
int main() {
    dude
    what_should_be_the_logic();
   r0
}

Measured memory_bytes: 3600
using System;
class aoj
{
    static void Main()
    {
        bool[] a = new bool[30];
        for(int i = 0; i < 30; i++)
        {
            a[i] = true;
        }
        for (int i = 0; i < 28; i++)
        {
            int b = int.Parse(Console.ReadLine());
            a[b - 1] = false;
        }
        for (int i = 0; i < 30; i++)
        {
            if (a[i])
            {
                Console.WriteLine(i + 1);
            }
        }
    }
}

Measured memory_bytes: 9148
#include <bits/stdc++.h> 
using namespace std;
#define ll long long 
#define f(i, a, b) for(ll i=a;i<b;i++)
#define fi(i, a, b) for(ll i=b-1;i>=a;i--)
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define ml map<ll,ll> 
#define pll pair<ll,ll>

class segment_tree
{
   public:
   vector<ll> arr,tree;
   segment_tree(vector<ll> a)
   {
      this->arr = a;
      ll n = a.size();
      ll height = 4*n;
      ll len = 2*height -1;
      tree.resize(len);
      build(0,n-1,0);
   }

   void build(ll l, ll r, ll node)
   {
      if(l==r)
      tree[node] = arr[l];
      else
      {
         ll mid = (l+r)/2;
         build(l,mid,2*node+1);
         build(mid+1,r,2*node+2);
         tree[node] = max(tree[2*node+1] , tree[2*node+2]);
      }
   }

   void updateutil(ll l, ll r,ll i, ll diff,ll node)
   {
      if(i<l || i>r)return;
      ll mid = (l+r)/2;
      tree[node] = max(tree[node],diff);
      if(l!=r){
         updateutil(l,mid,i,diff,2*node+1);
         updateutil(mid+1,r,i,diff,2*node+2);
      }
   }

   void update(ll i, ll x)
   {
      ll diff = x;
      updateutil(0,arr.size(),i,diff,0);
   }

   ll getq(ll tl,ll tr,ll l, ll r,ll node)
   {
      if(l<=tl && r>=tr) return tree[node];

      if(l>tr || r<tl) return 0;
      ll mid = (tr+tl)/2;
      return max(getq(tl,mid,l,r,2*node+1),getq(mid+1,tr,l,r,2*node+2));
   }
   
};

void solve()
{
   int n;
   cin>>n;
   vl h(n),b(n);
   f(i,0,n)
   cin>>h[i];
   f(i,0,n)cin>>b[i];
   vl dp(n+1,0);
   segment_tree st(dp);
   ll ans=0;
   f(i,0,n)
   {
      ll maxi = st.getq(0,n,0,h[i]-1,0);
      dp[h[i]] = maxi+b[i];
      st.update(h[i],dp[h[i]]);
      ans=max(ans,dp[h[i]]);
   }
   cout<<ans<<"\n";
}

int main()
{
   ll t;
   t=1;
//    cin>>t;
   while (t--)
   {
       solve();
   }  
}

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

int main() {

     string S;
    cin >> S;
    
    if (S == "Sunny") {
        cout << "Cloudy" << endl;
    }
    
    if (S == "Cloudy") {
        cout << "Rainy" << endl;
    }
    
    if (S == "Rainy") {
        cout << "Sunny" << endl;
    }
    
 }


Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

ans = []
for i in range(X):
    for j in range(Y):
        if (i + 1) * (j + 1) > K:
            break

        for k in range(Z):
            if (i + 1) * (j + 1) * (k + 1) <= K:
                ans.append(A[i] + B[j] + C[k])
            else:
                break

print(*sorted(ans, reverse=True)[:K], sep='\n')


Measured memory_bytes: 46064
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, int> pli;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int n;
xy_t p[310];
const double pi = acos(-1.0);

bool in_circle(xy_t t, xy_t c){
    return abs(t - c) <= 1;
}

int cnt(int k, double t){
    xy_t c = p[k] + xy_t(cos(t), sin(t));
    int ret = 1;
    rep(i, n)if(i != k){
        ret += in_circle(p[i], c);
    }
    return ret;
}

int main(){
    while(scanf("%d", &n) && n){
        rep(i, n){
            double x, y;
            scanf("%lf%lf", &x, &y);
            p[i] = xy_t(x, y);
        }
        int ans = 0;
        rep(i, n)rep(d, 500){
            ans = max(ans, cnt(i, 2*pi*d/500));
        }
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 3452
#include<iostream>
using namespace std;
int main(){
  int m,d;
  while(cin >> m >> d){
    if(m==0)
      break;
    int cd=d;
    for(int i=1;i<=m;i++){
      switch(i){
      case 2:cd+=31;break;
      case 3:cd+=29;break;
      case 4:cd+=31;break;
      case 5:cd+=30;break;
      case 6:cd+=31;break;
      case 7:cd+=30;break;
      case 8:cd+=31;break;
      case 10:cd+=30;break;
      case 9:cd+=31;break;
      case 11:cd+=31;break;
      case 12:cd+=30;break;
      }
    }
    switch(cd%7){
    case 0:cout << "Wednesday" << endl;break;
    case 1:cout << "Thursday" << endl;break;
    case 2:cout << "Friday" << endl;break;
    case 3:cout << "Saturday" << endl;break;
    case 4:cout << "Sunday" << endl;break;
    case 5:cout << "Monday" << endl;break;
    case 6:cout << "Tuesday" << endl;break;
    }
  }
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

typedef struct pair{ll x,y;}P;
int pcmp(const void*a,const void*b){
	if((*(P*)a).y<(*(P*)b).y)return -1;
	return 1;
}

P kukan[100010];

int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll x,y;
		scanf("%lld%lld",&x,&y);
		kukan[i].x=x;
		kukan[i].y=y;
	}
	qsort(kukan,m,sizeof(P),pcmp);
	
	ll pre=-1;
	ll ans=0;
	rep(i,0,m){
		if(pre<kukan[i].x){
			ans++;
			pre=kukan[i].y-1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 3324
n = int(input())

if n < 357:
    print(0)
    exit()

def dfs(start):
    if int(start) > n:
        return 0
    if not ("3" in start and "5" in start and "7" in start):
        count=0
    else:
        count=1
    count += dfs(start + "3")
    count += dfs(start + "5")
    count += dfs(start + "7")
    return count
print(dfs("3")+dfs("5")+dfs("7"))

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

int main(){
    int N, K; cin >> N >> K;
    int h[N];
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }

    sort(h, h+N);
    int j;
    int minV = h[K-1] - h[0];
    for(int i = 0; i < N - K + 1; i++){
        j = i + K - 1;
        minV = min(minV, h[j] - h[i]);
    }

    cout << minV << endl;


    return 0;
}

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

#define range 524289
#define mod 998244353
#define eps 1e18
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<

using namespace std;

typedef long long ll;
typedef vector <ll> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;


int e[8] = {1,-1,1, -1, 2,2,-2,-2};
int z[8] = {2, 2,-2, -2, 1,-1,1,-1};



int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while(t--){
        int n;
        cin>>n;

        vi a(n);
        for (int i = 0; i < n; ++i)
        {
            /* code */
            cin>>a[i];
        }

        vi dp(n);
        dp[1] = abs(a[0]-a[1]);
        // cout<<a[0]<<a[1]<<endl;
        for (int i = 2; i <n; ++i)
        {
            /* code */
            dp[i] = min(dp[i-1]+abs(a[i-1]-a[i]), dp[i-2]+abs(a[i-2]-a[i]));
        }
        cout<<dp[n-1]<<endl;
        return 0;

    }

}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
const int INF = 1ll << 50;
const int MOD = 1e9 + 7;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define itn int
#define asn ans
bool dbg = false;

int N, M, cnt[101010];

void solve() {
}

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

    cin >> N >> M;
    while (M--) {
        int a, b;
        cin >> a >> b;
        cnt[a]++;
        cnt[b]++;
    }
    bool check = true;
    for (int i = 0; i <= N; i++) {
        if (cnt[i] % 2 != 0)
            check = false;
    }
    YES(check);

    solve();
    return 0;
}


Measured memory_bytes: 4456
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		String A = scan.next();
		String B = scan.next();

		String ans="EQUAL";//A>B true B<A false

		if(A.length()>B.length()){
			ans = "GREATER";
		}else if(A.length()<B.length()){
			ans = "LESS";
		}else{
			//桁数が同じ
			for(int i=0;i<A.length();i++){
				int a =Integer.parseInt(A.substring(i, i+1));
				int b =Integer.parseInt(B.substring(i, i+1));
				if(a>b){
					ans ="GREATER";
					break;
				}else if(a<b){
					ans ="LESS";
					break;
				}
			}
		}


		System.out.println(ans);

	}

}


Measured memory_bytes: 23124
#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll long long
#define inf 1000000000
#define MOD 1000000007
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
inline ll readl(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}return x*f;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
inline ll power(ll a,ll b){ll ans=1;while(b){if(b&1){ans=ans*a%MOD;--b;}b>>=1;a=a*a%MOD;}return ans%MOD;}
/*================Header Template==============*/
int main(){
	int a=read(),b=read(),k=read();
	if(a+k-1>=b){
		for(int i=a;i<=b;i++) cout<<i<<"\n";
	}else{
		for(int i=a;i<=a+k-1;i++) cout<<i<<"\n";
		for(int i=max(a+k,b-k+1);i<=b;i++) cout<<i<<"\n"; 
	}
}


Measured memory_bytes: 256