akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <boost/format.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/optional.hpp>

#ifdef DEBUG
#include "libs/debug.cpp"
#define DEBUG 1
#else
#define DEBUG 0
#endif

#define rep(i, n) repr((i), 0, (n))
#define repr(i, a, t) reps((i), (a), (t), 1)
#define reps(i, a, t, s) for (long long (i) = (a); (i) < (long long)(t); (i) += (s))
#define rrep(i, n) rrepr((i), (n) - 1, 0)
#define rrepr(i, a, t) rreps((i), (a), (t), 1)
#define rreps(i, a, t, s) for (long long (i) = (a); (i) >= (long long)(t); (i) -= (s))
#define each(v, c) for (auto &&(v) : (c))
#define all(c) (c).begin(), (c).end()

using namespace std;
namespace mp = boost::multiprecision;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using ml = mp::cpp_int;
template<typename T>
using optional = boost::optional<T>;
const auto none = boost::none;
const long long MOD = 1e9 + 7;
const long long INF = 1e18;

ll solve(ll l, ll r, const vector<vector<ll>> &dp) {
  ll ret = 0;
  while (l < r) {
    ll d = max(0l, lower_bound(all(dp[l]), r - l) - dp[l].begin() - 1);
    ret += pow(2, d);
    l += dp[l][d];
  }
  return ret;
}

int main() {
  cout << fixed << setprecision(10);
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ifstream ifs;
  if (DEBUG) {
    ifs.open("src/_in.txt");
    cin.rdbuf(ifs.rdbuf());
  }

  ll N, L, Q;
  cin >> N;
  vector<ll> X(N);
  rep (i, N) {
    cin >> X[i];
  }
  cin >> L >> Q;
  vector<pair<ll, ll>> AB;
  rep (i, Q) {
    ll a, b;
    cin >> a >> b;
    AB.emplace_back(a, b);
  }

  N += 2;
  X.insert(X.begin(), X[0] - 1);
  X.push_back(X[X.size() - 1] + 1);

  vector<vector<ll>> dp(N);
  rep (i, N) {
    dp[i].push_back(upper_bound(all(X), X[i] + L) - X.begin() - i - 1);
  }
  ll d = 0;
  while (pow(2, d++) < N) {
    rep (i, N) {
      dp[i].push_back(dp[i][d - 1] + dp[i + dp[i][d - 1]][d - 1]);
    }
  }

  rep (i, Q) {
    ll a, b;
    tie(a, b) = AB[i];
    ll ans = solve(min(a, b), max(a, b), dp);
    cout << ans << "\n";
  }
}

Measured memory_bytes: 32864
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
int p,q;
vector<int>primes;

const int MA=30000000;
bool t[MA*2];

void eratosu(){
	t[1]=1;

	for(int i=2;i<=MA;i++){
		if(t[i]==0){
			primes.push_back(i);
			for(int j=i*2;j<=MA;j+=i)t[j]=1;
		}
	}
}

int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int main(){
eratosu();
	cin>>p>>q;


for(int i=0;i<primes.size();i++){
	int now=primes[i];
	while(q%now==0&&p%now==0)q/=now,p/=now;
}


int gc=gcd(p,q);
int np=p,nq=q;
//p=np/gc;
//q=nq/gc;
int ans=1,qq=q;
int cnt=0;

for(int i=0;i<primes.size();i++){
	int now=primes[i];
	if(q%now==0){ans*=now,cnt++;}
	while(q%now==0)q/=now;

	//if(now>sqrt(qq))break;
}
ans*=q;
cout<<ans<<endl;
	return 0;
}


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

int main()
{
    int n;
    cin>>n;
    vector<int>v;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    n/=2;
    cout<<v[n]-v[n-1]<<endl;
}


Measured memory_bytes: 892
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <vector>
using namespace std;
// #include "prettyprint.hpp"

int main() {
  string s;
  cin >> s;
  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3]) {
    cout << "Bad" << endl;
  } else {
    cout << "Good" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
A = [list(map(int,input().split())) for _ in range(3)]
N = int(input())
B = [int(input()) for _ in range(N)]
C = [[False]*3 for _ in range(3)]
for i in B:
    for j in range(3):
        for k in range(3):
            if A[j][k]==i:
                C[j][k]=True
def bingo(C):
    for i in range(3):
        if C[i][0]==C[i][1]==C[i][2]==True:
            return True
    for i in range(3):
        if C[0][i]==C[1][i]==C[2][i]==True:
            return True
    if C[0][0]==C[1][1]==C[2][2]==True:
        return True
    if C[2][0]==C[1][1]==C[0][2]==True:
        return True
if bingo(C):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38496
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500* i + 100 * j + 50 * k == x:
                count +=1
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,T,A;
  cin>>N>>T>>A;
  vector<int> height(N);
  for(int i=0;i<N;i++){
    cin>>height[i];
  }
  int k,l=1;
  if(A*1000<T*1000-height[0]*6){
    k=T*1000-height[0]*6-A*1000;
  }
  else{
    k=A*1000-T*1000+height[0]*6;
  }
  for(int j=0;j<N;j++){
    if(A*1000<T*1000-height[j]*6&&k>T*1000-height[j]*6-A*1000){
      k=T*1000-height[j]*6-A*1000;
      l=j+1;
    }
    if(A*1000>=T*1000-height[j]*6&&k>A*1000-(T*1000-height[j]*6)){
      k=A*1000-(T*1000-height[j]*6);
      l=j+1;
    }
  }
  cout<<l<<endl;
}
      


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x =sc.nextInt();
        int x1=x;
        int n =sc.nextInt();
        boolean [] arr = new boolean [120];
        for (int i = 0; i <n ; i++) {
            int y =sc.nextInt();
            arr[y]=true;
        }
        int ans1 =0,ans2 = 0;
        int cn1=0,cn2=0;
        for (int i = 0; i < arr.length; i++) {
            cn1++;
            if(!arr[x]){
                ans1=x;
                break;
            }
            x--;
        }for (int i = 0; i < arr.length; i++) {
            cn2++;
            if(!arr[x1]){
                ans2=x1;
                break;
            }
            x1++;
        }
        if(cn1<cn2){
            System.out.println(ans1);
        }
        else if(cn2<cn1) System.out.println(ans2);
        else
        System.out.println(Math.min(ans1,ans2));
    }
}

Measured memory_bytes: 36012
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N){
    cout << ((N%2==0)? N: N*2) << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

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

		int flag=0;
		loop: for (int a=0;a<N+1;a++) {
			for (int b=0;b<N+1;b++) {
				if ((Y-10000*a-5000*b)==1000*(N-a-b) && (N-a-b)>=0) {
					System.out.println(a+" "+b+" "+(N-a-b));
					flag=1;
					break loop;
				}
			}
		}

		if(flag==0) {
			System.out.println((-1)+" "+(-1)+" "+(-1));
		}
	}
}

Measured memory_bytes: 23252
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  var a, b = sc.nextInt() - 1
  val n = 100

  val ans = Array.fill(n)("")
  var i = 0

  ans(i) = "." * n
  i += 1

  while (b > 0) {
    val x = b.min(n/2)
    ans(i) = s"${"#." * x}${".." * (n/2 - x)}"
    ans(i+1) = "." * n
    i += 2
    b = b - x
  }

  ans(i) = "#" * n
  i += 1

  while (a > 0) {
    val x = a.min(n/2)
    ans(i) = s"${"#." * x}${"##" * (n/2 - x)}"
    ans(i+1) = "#" * n
    i += 2
    a = a - x
  }

  for (j <- i until n) {
    ans(j) = "#" * n
  }

  println("100 100")
  println(ans.mkString("\n"))
}

Measured memory_bytes: 55604
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>

#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>
#include<climits>

using namespace std;
const int MAX = 10;
const int INF = INT_MAX/3;
int main(){
  ios::sync_with_stdio(false);
  int cost[MAX][MAX];
  bool existTown[MAX];
  int n;
  while(cin >> n && n != 0){
    fill(*cost,*(cost+MAX),INF);
    fill(existTown,existTown+MAX,false);
    for(int i = 0;i < n;i++){
      int a,b,c;
      cin >> a >> b >> c;
      cost[a][b] = cost[b][a] = c;
      existTown[a] = existTown[b] = true;
    }

    for (int k = 0; k < MAX; ++k){
      for (int j = 0; j < MAX; ++j){
	for (int i = 0; i < MAX; ++i){
	  int sum = cost[i][k] + cost[k][j];
	  if(cost[i][j] > sum){
	    cost[i][j] = cost[j][i] = sum;
	  }
	}
      }
    }
    /*
    for (int i = 0; i < MAX; ++i){
      for (int j = 0; j < MAX; ++j){
	if(cost[i][j] == INF)cout << INF;
	else cout << cost[i][j];
	cout << ' ';
      }
      cout << endl;
    }
    */
    int ans = 100;
    int mini = INF;
    for(int i = 0;i < MAX;i++){
      if(!existTown[i])continue;
      int sum = 0;
      for(int j = 0;j < MAX;j++){
	if(existTown[j] && j != i)sum += cost[i][j];
      }
      if(mini > sum){
	mini = sum;
	ans = i;
      }
    }
    cout << ans  << ' ' << mini << endl;
  }
  
  return 0;
}

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

using P=pair<int,int>;
using Data=pair<P,string>;

map<string,Data> dic;
set<Data> work;
set<Data> idle;

int jd=0;
int w=0;
const double EPS=1e-6;
void join(string s,int a){
    w++;    
    dic[s]={{a,jd},s};    
    jd++;
}

void erase(string s){
    w--;
    Data d=dic[s];
    if(idle.count(d)) idle.erase(idle.find(d)); 
    if(work.count(d)) work.erase(work.find(d));
    dic.erase(dic.find(s));
}
void toWork(Data x){
    if(idle.count(x)) idle.erase(idle.find(x));
    work.insert(x);
    cout<<x.second<<" is working hard now."<<endl;
}

void toIdle(Data x){
    if(work.count(x)) work.erase(work.find(x));
    idle.insert(x);
    cout<<x.second<<" is not working now."<<endl;
}
int main(){
    int n;
    cin>>n;
    vector<Data> acm(n);
    for(int i=0;i<n;i++){
        string s;
        int a;
        cin>>s>>a;
        acm[i]={{a,jd},s};
        join(s,a);
    }
    sort(acm.begin(),acm.end());
    int index=n-1;
    while(work.size()+1<=(int)(w*0.2+EPS)){
        work.insert(acm[index]);
        index--;
    }
    for(;index>=0;index--) idle.insert(acm[index]);

    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        char com;
        cin>>com;
        if(com=='+'){
            string s;
            int a;
            cin>>s>>a;
            Data d={{a,jd},s};
            join(s,a);
            if(int(w*0.2+EPS)>work.size()){
                auto it=idle.end(); it--;
                Data k=*it;
                if(k<d){
                    toWork(d);
                }else{
                    toIdle(d);
                    toWork(k);
                }
            }else{
                if(work.size()!=0){
                    auto it=work.begin();
                    Data k=*it;
                    if(k<d){
                        toWork(d);
                        toIdle(k);
                    }else{
                        toIdle(d);
                    }
                }else{
                    toIdle(d);
                }

            }
        }else{
            string s;
            cin>>s;
            erase(s);
            if((int)(w*0.2+EPS)>work.size()){
                auto it=idle.end();
                it--;
                Data k=*it;
                toWork(k);
            }else if((int)(w*0.2+EPS)<work.size()){
                auto it=work.begin();
                Data k=*it;
                toIdle(k);
            }
        }

    }
        return 0;
}

Measured memory_bytes: 12712
//#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int n,m,x;
int ans=987654321;
bool buy[12];
int a[12][12];
int pr[12];
void d(int index){
    if(index==n){
        int price=0;
        vector<int> sum(m,0);
        for(int i=0;i<n;i++){
            if(buy[i]){
                price += pr[i];
                for(int j=0;j<m;j++){
                    sum[j]+=a[i][j];
                }
            }
        }
        bool ok=true;;
        for(int i=0;i<m;i++){
            if(sum[i]<x){
                ok=false;
            }
        }
        if(ok){
            ans = min(ans,price);
        }
    }else{
        buy[index]=true;
        d(index+1);
        buy[index]=false;
        d(index+1);
    }
}
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    cin>>n>>m>>x;
    
    for(int i=0;i<n;i++){
        cin>>pr[i];
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }/*
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cout<<a[i][j]<<' ';
        }
        cout<<'\n';
    }*/
    d(0);
    if(ans==987654321)cout<<-1;
    else cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
#include <climits>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

int n;

int main() {
    cin >> n;
    int a[5] = {105,135,165,189,195};
    int res=0;
    REP(i,5){
        if(a[i]<=n){
            res++;
        }
    }
    put(res);
    return 0;
}


Measured memory_bytes: 256
n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_f)
num = a.inject(:+)
m = m.to_f
cnt = 0
n.times do |e|
  if (a[e]/num)>=1/(4*m)
    cnt = cnt+1
  else
  end
end
puts cnt>=m ? "Yes":"No"


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using std::cerr;using std::cin;using std::cout;using std::abs;using std::min;using std::max;using std::swap;using std::map;using std::unordered_map;using std::unordered_set;using std::bitset;using std::pair;using std::set;using std::string;using std::vector;using std::sort;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;using vci=vector<int>;using vcl=vector<ll>;template<typename T>void _dbg(const char*_s,T _h){cerr<<_s<<" = "<<_h<<"\n";}template<typename T,typename...Ts>void _dbg(const char*_s,T _h,Ts..._t){int _b=0;while(((_b+=*_s=='(')-=*_s==')')!=0||*_s!=',')cerr<<*_s++;cerr<<" = "<<_h<<",";_dbg(_s+1,_t...);}
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}
#define int ll

const int N=2018;
int a[N][N];

int32_t main() {
    int k;
    cin>>k;
    if(k==1){
        cout<<"1\n1\n";
        return 0;
    }
    int n=2*((k+3)/4);
    cout<<n<<'\n';
    forn(i,n/2){
        forn(j,n){
            int v=(i+i+j)%n;
            cout<<v+1<<' ';
        }
        cout<<'\n';
        forn(j,n){
            int v=n+(i+i+1+j)%n;
            if(v>=k)v-=n;
            cout<<v+1<<' ';
        }
        cout<<'\n';
    }


    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
typedef long double LD;
const int N = 10;
const int C = 305;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, c, nc, len[N], p[N];
LL dp[C][C][1 << 5];
LD ans;

void init() {
	read(n); read(c);
	nc = n * c;
	for (int i = 1; i <= n; ++i) {
		read(len[i]);
	}
	sort(len + 1, len + n + 1);
}

void solve() {
	for (int i = 1; i <= n; ++i) {
		p[i] = i;
	}
	int S = (1 << (n - 1));
	do {
		mset(dp, 0);
		dp[0][n * len[n]][0] = 1;
		for (int i = 1; i < nc; ++i) {
			for (int j = i; j <= nc; ++j) {
				for (int s = 0; s < S; ++s) {
					dp[i][j][s] += dp[i - 1][j][s];
					int k = i % n;
					if (!k || ((s >> (k - 1)) & 1)) continue;
					int jv = min(nc, max(j, i + len[p[k]] * n));
					dp[i][jv][s | (1 << (k - 1))] += dp[i - 1][j][s];
				}
			}
		}
		ans += dp[nc - 1][nc][S - 1];
	} while (next_permutation(p + 1, p + n));
	for (int i = 1; i < n; ++i) {
		ans /= i * c;
	}
	printf("%.13Lf\n", ans);
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 26996
import java.io.*;

public class Main{
    public static void main(String[] args)throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

        char[] c = new char[200];
        char[] d = new char[200];

        while(true){
            String str = br.readLine();

            if(str.equals("-"))break;

            int l = str.length();

            for(int i=0; i<l; i++){
                c[i] = str.charAt(i);
            }

            String N = br.readLine();
            int num = Integer.parseInt(N);

            int nnum = 0;
            for(int i = 0; i<num; i++){
                nnum += Integer.parseInt(br.readLine());
            }

            int a = nnum % l;

            for(int i=0; i<l; i++){
                d[i] = c[(i+a)%l];
            }

            for(int i=0; i<l; i++){
                System.out.print(d[i]);
            }
            System.out.print("\n");
        }
    }
} 


Measured memory_bytes: 24456
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/tag_and_trait.hpp>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll n;
  cin >> n;
  map<string, ll> ma;
  string s;
  rep(i, n) {
    cin >> s;
    ma[s]++;
  }

  ll maxi = 0;
  for (auto&& i : ma) {
    cmax(maxi, i.second);
  }

  cerr << endl;
  for (auto&& i : ma) {
    if (i.second == maxi) {
      cout << i.first << endl;
    }
  }
}


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

int gcd(long long a, long long b){
  long long M = max(a, b), m = min(a, b);
  while(m != 0){
  	long long r = M%m;
    M = m; m = r;
  }
  return M;
}

int digit_sum(long long n){
  long long ans;
  while(n != 0){
  	ans += n%10;
  	n /= 10;
  }
  return ans;
}

int main(){
  long long n;
  cin >> n;
  long long a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  a = min({a, b, c, d, e});
  
  if(n%a == 0){
  	cout << n/a + 4 << endl;
  }
  else{
  	cout << n/a + 5 << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int s,k,ans=0;
int main(){
	
	scanf("%d%d",&k,&s);
	for(int x=0;x<=k;x++){
		for(int y=0;y<=k;y++){
			if((s-x-y)>=0&&s-x-y<=k){
				ans++;
			}
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        int i = 1;
        int h,m,s;
        int S = 0;
        while(i>0){
            BufferedReader x = new BufferedReader(new InputStreamReader(System.in));
            S = Integer.parseInt(x.readLine());          
            if(S >= 0 && S < 86400 )
                i = -1;
         }
         h = S/3600;
         m = S%3600/60;
         s = S%3600%60;
         System.out.println(""+h+":"+m+":"+s+"");
    }
}

Measured memory_bytes: 24496
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define int long long
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define F first
#define S second
#define pb push_back
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repr(i, a, b) for(int i = a - 1; i >= b; i--)
#define iter(m) for(auto it = m.begin(); it != m.end(); it++)
#define iterr(m) for(auto it = m.rbegin(); it != m.rend(); it++)
#define N 500500
#define PI 3.14159265358979323846264338327950L
#define speed ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
    
const ll mod = (ll)1e9 + 7;
int quickPow(int x, int n) {
    int res = 1;
    while(n > 1) {
        if(n % 2 == 0) {
            n >>= 1;
            x *= x;
        } else {
            n--;
            res *= x;
        }
        res %= mod;
        x %= mod;
    }
    return (res * x) % mod;
}
int inverse(int x) {
    return quickPow(x, mod - 2);
}
int CK(int n, int k) {
    int ans = 1;
    int sub = 1;
    for(int i = 0; i < k; i++) ans = ans * (n - i) % mod;
    for(int i = 1; i <= k; i++) sub = sub * i % mod;
    
    return ans * inverse(sub) % mod;
}
signed main(){
    speed;
    int n, a, b; cin >> n >> a >> b;
    int ans = quickPow(2, n) - 1;
    ans = (ans - (CK(n, a) + CK(n, b))) % mod;
    cout << (ans + mod) % mod;
    return 0;
}

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

void solve(long long a, long long b, long long x)
{
    long double res = 0.0;
    if (a * a * b < 2 * x)
    {
        long double height = 2.0 * static_cast<long double>(a * a * b - x) / static_cast<long double>(a * a);
        res = (180.0000000 / 3.141592653589793238462643383279) * atan(height / static_cast<long double>(a));
    }
    else
    {
        long double width = 2.0 * static_cast<long double>(x) / static_cast<long double>(a * b);
        res = (180.0000000 / 3.141592653589793238462643383279) * atan(static_cast<long double>(b) / width);
    }
    cout << setprecision(10) << res << endl;
}

// 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)
int main()
{
    long long a;
    scanf("%lld", &a);
    long long b;
    scanf("%lld", &b);
    long long x;
    scanf("%lld", &x);
    solve(a, b, x);
    return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    int Ans[N] = {};

    int tmp;
    while (cin >> tmp) {
        Ans[tmp-1]++;
    }

    for (int i = 0; i < N; i++) {
        cout << Ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
int GCD(int a, int b){
    return b ? GCD(b, a%b) : a;
}
int main() {
	ll N,M;
	cin >> N >> M;
	vector<ll> a[N+1];
	rep(i,M){
		ll from,to;
		cin>>from>>to;
		a[from].push_back(to);
	}
	for(int i=0; i<a[1].size(); i++){
		ll tmp=a[1][i];
		for(int j=0; j<a[tmp].size(); j++){
			if(a[tmp][j]==N){
				cout<<"POSSIBLE"<<endl;
				return 0;
			}
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 8948
#include<stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if (a>b)
    {
        printf("a > b\n",a);
    }
    if (a<b)
    {
        printf("a < b\n",b);
    }
    if (a==b)
    {
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2032
#include <iostream>

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

    int sum_taste = 0, min_taste = 1 << 30, eat_taste = 0;
    for (int i = 1; i <= N; i++) {
        int taste = L + i - 1;
        sum_taste += taste;
        if (abs(taste) < min_taste) {
            min_taste = abs(taste);
            eat_taste = taste;
        }
    }

    std::cout << sum_taste - eat_taste << "\n";
}

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

using namespace std;
#define ll long long 
const int ma=1e9+7;
int maiaa(){
    ll i=0,j=0,res=0,c=0,div=0,n,m,k=0;
    string a,b;   
    cin>>a>>b;
    /*while( 1){
        cin>>a[i];
        i++;
        if(a.size()==i+1) break;
    }
    n=i;
    while( 1){
        cin>>b[j];
        j++;
        if(b.size()==j+1) break;
    }
    m=j;
    */
    ll cc=0;
  n=a.length();
  m=b.length();
  string x;
   for(i=0;i<(n-m)+1;i++){
       for(k=i;k<(i+m);k++){
            cc=k;
           x+=a[cc];
            cc++;
        }
        
   }
   ll vx=x.length();
   
   for(i=0;i<vx;i+=m){
        cc=i;
        for(j=0;j<m;j++){
                    
                    if(x[cc]!=b[j]){ c++;
                        cout<<x[cc]<< " "<<b[j];
                        
                    }
                    cout<<endl;
                    cc++;
        }
        cout<<" end";
      
       if(c%2==0){ res++;
           cout<<c<<" "<<res;
           c=0;
       }
       cout<<endl;
          
   }
   cout<<res;
    
    return 0;
}



int maa() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	long long a,i=0,b;
	cin>>a>>b;
	for(i=0;i<=ma;i++){
		if(abs(a-i)==abs(b-i)){
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	// your code goes here
	return 0;
}
int main() {
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    ll int n,i;
	cin>>n;
	ll int a[n+1],b[n];
	for(i=0;i<n+1;i++)
		cin>>a[i];
	for(i=0;i<n;i++)
		cin>>b[i];
	ll int count=0;
	for(i=0;i<n;i++)
	{
		//cout<<a[i]<<" "<<b[i]<<"\n";
		if(a[i]>=b[i])
		{
			count+=b[i];
			a[i]=a[i]-b[i];
			b[i]=0;
		}
		else
		{
			count+=a[i];
			b[i]=b[i]-a[i];
			a[i]=0;
		}
		//cout<<a[i+1]<<" "<<b[i]<<"\n";
		if(a[i+1]>=b[i])
		{
			count+=b[i];
			a[i+1]=a[i+1]-b[i];
			b[i]=0;
		}
		else
		{
			count+=a[i+1];
			b[i]=b[i]-a[i+1];
			a[i+1]=0;
		}
		//cout<<count<<" ";
	}
	cout<<count;
	return 0;
    
	
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/


//BinaryIndexTree(siz):長さsizで初期化
//sum(k):区間[0,k]の和を求める
//add(k,x):要素kにxを加える

template<typename T>
struct BinaryIndexTree {

	int n;
	vector<T> data;
	
	BinaryIndexTree(int siz)
	{
		n = siz;
		//1-indexなので配列は1つ多めに用意する
		data.resize(siz + 1, 0);
	}


	T sum(int k) {

		//[0,k)までの和を計算
		T ret = 0;
		while (k > 0) {
			ret += data[k - 1];
			k -= k & -k;
		}
		return ret;
	}

	//0-index
	void add(int k, int x)
	{
		//a_kにxを加算する
		while (k <= n) {
			data[k - 1] += x;
			k += k & -k;
		}
	}


	// bitに入ってる中でx番目に小さい数を求める
	// 1番小さい数はx = 1;
	// bitに3を入れる→add(3, 1), 3を出す→add(3, -1)
	// return == nの場合x個も入っていない
	ll min_xth(int x) {
		int left = -1, right = n;
		while (left + 1 < right) {
			int mid = (left + right) / 2;
			int temp = sum(mid + 1);
			if (temp < x) {
				left = mid;
			}
			else {
				right = mid;
			}
		}
		return right;
	}


	// pを順番通りにするための交換回数
	ll bubble(vector<T> p) {
		int n = p.size();
		ll ans = 0;
		for (int j = 0; j < n; j++) {
			ans += (j - sum(p[j] + 1));
			add(p[j], 1);
		}
		return ans;
	}


};


int main() {

	
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;


	return 0;
}


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

public class Main {
	public static void main(String[] args) {
	    FastScanner sc = new FastScanner(System.in);
	    PrintWriter pw = new PrintWriter(System.out);
	    long mod = (long)1e9 + 7;
		char[] s = sc.next().toCharArray();
		int n = s.length;
		long[][] dp = new long[n + 1][4];
		dp[0][3] = 1;
		for(int i = n; i >= 0; --i){
            for(int j = 3; j >= 0; --j){
                if(i == n){
                    dp[i][j] = (j == 3 ? 1 : 0);
                }else{
                    dp[i][j] = dp[i+1][j] * (s[i] == '?' ? 3L : 1L);
                    if(j < 3 && (s[i] == '?' || s[i] == "ABC".charAt(j))){
                        dp[i][j] += dp[i+1][j+1];
                    }
                    dp[i][j] %= mod;
                }
            }
        }
        pw.println(dp[0][0]);
        pw.flush();
	}
}


class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;
    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

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

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken("\n");
    }

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

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

    public double nextDouble() {
         return Double.parseDouble(next());
    }
    
    public String[] nextArray(int n) {
        String[] a = new String[n];
        for (int i = 0; i < n; i++)
            a[i] = next();
        return a;
    }

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    } 
}


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

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

  bool yes = false;

  for(int i=1;i<10;i++) {
    if(n < i * 9 + 1 && n % i == 0) {
      yes = true;
      break;
    }
  }

  if(yes) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<map>
#include<utility>
#include<tuple>
#include<algorithm>
#include<cmath>
using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;

int main() {
  int W, a, b;
  cin >> W >> a >> b;
  int ans;
  if(a <= b) {
    if(a+W >= b)
      ans = 0;
    else
      ans = b-(a+W);
  } else {
    if(b+W >= a)
      ans = 0;
    else
      ans = a-(b+W);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		long N=scan.nextLong();
		long K=scan.nextLong();
		
		
		
	
		if(N==0||N%K==0) {
			System.out.println("0");
		}
		else {
			List<Long> list=new ArrayList<Long>();
			boolean flag=false,flagb=false;
			if(N>K)N=N%K;
			for(;;) {
				long A=Math.abs(N-K);
				
				N=A;
				if(A==1) {
					flag=true;
					flagb=true;
				}
				for(Long i:list) {
					if(i==A)flag=true;
				}
				if(flag)break;
				list.add(A);
			}
			if(flagb) {
				System.out.println("1");
			}
			else {
				long min=list.get(0);
				for(Long i:list) {
					if(min>i)min=i;
				}
				System.out.println(min);
			}
		}

	}

}


Measured memory_bytes: 21972
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int H, W;
int ch, cw;
int dh, dw;
vector<string> S;

void input(void) {
	cin >> H >> W;
	cin >> ch >> cw;
	--ch, --cw;
	cin >> dh >> dw;
	--dh, --dw;
	S.resize(H);
	for (auto& si : S)
		cin >> si;
}

vector<vector<pair<int, int>>> g;

void construct_g(void) {
	g.resize(H * W);
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j) {
			if (S[i][j] == '#') continue;

			int idx = W * i + j;

			const vector<int> d1 = { -1, 0, 1 };

			for (auto dx : d1) {
				for (auto dy : d1) {
					if (dx != 0 && dy != 0) continue;
					if (dx == 0 && dy == 0) continue;
					if (i + dy < 0 || i + dy >= H) continue;
					if (j + dx < 0 || j + dx >= W) continue;
					if (S[i + dy][j + dx] == '#') continue;
					int tmp = idx + dx + W * dy;
					g[idx].push_back({ tmp, 0 });
				}
			}

			const vector<int> d2 = {-2, -1, 0, 1, 2};

			for (auto dx : d2) {
				for (auto dy : d2) {
					if (dx == 0 && dy == 0) continue;
					if (i + dy < 0 || i + dy >= H) continue;
					if (j + dx < 0 || j + dx >= W) continue;
					if (S[i + dy][j + dx] == '#') continue;
					int tmp = idx + dx + W * dy;
					g[idx].push_back({ tmp, 1 });
				}
			}
		}
	}
}

void show_g(void) {
	for (int i = 0; i < H * W; ++i) {
		cout << i << " : ";
		for (auto& e : g[i]) {
			cout << "(" << e.first << ", " << e.second << ") ";
		}
		cout << endl;
	}
}

template<typename T>
vector<T> dijkstra(int s, vector<vector<pair<int, T>>>& G) {
	const int n = G.size();
	vector<T> d(n, numeric_limits<T>::max());
	vector<int> b(n, -1);
	priority_queue<pair<T, int>, vector<pair<T, int>>, greater<pair<T, int>>> q;
	d[s] = 0;
	q.emplace(d[s], s);
	while (!q.empty()) {
		pair<T, int> p = q.top();
		q.pop();
		int v = p.second;
		if (d[v] < p.first) continue;
		for (auto& e : G[v]) {
			int u = e.first;
			T c = e.second;
			if (d[u] > d[v] + c) {
				d[u] = d[v] + c;
				b[u] = v;
				q.emplace(d[u], u);
			}
		}
	}
	return d;
}

int solve(void) {
	int st = ch * W + cw;
	int gl = dh * W + dw;
	auto res = dijkstra<int>(st, g);
	if (res[gl] <= 1000000) return res[gl];
	return -1;
}

int main(void) {
	input();
	construct_g();
	// show_g();
	cout << solve() << endl;
	return 0;
}

Measured memory_bytes: 118356
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll a,b;cin>>a>>b;
	if(a>=1 && b>=1){
		if(a<=9 && b<=9){
			cout<<a*b<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;































	
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
const int man = 2e5+10;
#define IOS ios::sync_with_stdio(0)
template <typename T>
inline T read(){T sum=0,fl=1;int ch=getchar();
for(;!isdigit(ch);ch=getchar())if(ch=='-')fl=-1;
for(;isdigit(ch);ch=getchar())sum=sum*10+ch-'0';
return sum*fl;}
template <typename T>
inline void write(T x) {static int sta[35];int top=0;
do{sta[top++]= x % 10, x /= 10;}while(x);
while (top) putchar(sta[--top] + 48);}
template<typename T>T gcd(T a, T b) {return b==0?a:gcd(b, a%b);}
template<typename T>T exgcd(T a,T b,T &g,T &x,T &y){if(!b){g = a,x = 1,y = 0;}
else {exgcd(b,a%b,g,y,x);y -= x*(a/b);}}
#ifndef ONLINE_JUDGE
#define debug(fmt, ...) {printf("debug ");printf(fmt,##__VA_ARGS__);puts("");}
#else
#define debug(fmt, ...)
#endif
typedef long long ll;
const ll mod = 1e9+7;
int f[man];

int q(int a,int b){
	int ans = 1;
	while(b){
		if(b&1)ans = 1ll * ans * a % mod;
		a = 1ll * a * a % mod;
		b >>= 1;
	}
	return ans;
}

int main() {
	#ifndef ONLINE_JUDGE
		//freopen("in.txt", "r", stdin);
		//freopen("out.txt","w",stdout);
	#endif
	int n,k;
	cin >> n >> k;
	for(int i = k;i >= 1;i--){
		f[i] = q(k/i,n);
		for(int j = 2*i;j <= k;j += i){
			f[i] = (f[i] - f[j] + mod) % mod;
		}
	}
	ll ans = 0;
	for(int i = 1;i <= k;i++){
		ans += 1ll * i * f[i] % mod;
		ans %= mod;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4080
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int MAX = 101;

int n,k,t;
vector<int> c;

int judge(){
  int max_ = -1<<28;
  for(int i = 0 ; i <= n - k ; i++){
    t = 1;
    for(int j = i ; j < i + k ; j++){
      t *= c[j];
    }
    max_ = max(max_,t);
  }
  return max_;
}

int main(){

  while(cin >> n >> k , n){
    int in;
    c.clear();

    for(int i = 0 ; i < n ; i++){
      cin >> in;
      c.push_back(in);
    }

    int tmx = judge() ,smx = -1<<28;
   

    for(int i = 0 ; i < n-1 ; i++){
      for(int j = i + 1 ; j < n ; j++){
	swap(c[i],c[j]);
	smx = max(smx,judge());
	swap(c[i],c[j]);
      }
    }

    if(tmx > smx) cout << "NO GAME" << endl;
    else cout << smx - tmx << endl;
  }

  return 0;
}

Measured memory_bytes: 1216
n = int(input())
ans = [0] * n

cnt = 0
for x in range(1, 100):
  for y in range(1, 100):
    for z in range(1, 100):
      f = x ** 2 + y ** 2 + z ** 2 + x * y + y * z + z * x
      if f <= n:
        ans[f - 1] += 1
ans.append(cnt)

for j in range(n):
  print(ans[j])

Measured memory_bytes: 69484
dp = [0]*(31)
dp[0] = 0
dp[1] = 1
dp[2] = 2
dp[3] = 4
ans = [0]*31
ans[1] = 1
ans[2] = 1
ans[3] = 1 
input_line = [-1]*31
for i in range(4,31):
    dp[i] += dp[i-1]+dp[i-2]+dp[i-3]
    if dp[i]%10==0:
        ans[i] = dp[i]//10
    else:
        ans[i] = dp[i]//10+1
for i in range(31):
    if ans[i] % 365 == 0:
        ans[i] = ans[i]//365
    else:
        ans[i] = ans[i]//365+1
for i in range(31):
    input_line[i] = int(input())
    if input_line[i] == 0:
        end = i
        break
for i in range(end):
    print(ans[input_line[i]])


Measured memory_bytes: 5600
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 5, mod = 1e9 + 7;



int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int a, b;
    cin >> a >> b;
    if(a > b) swap(a, b);
    if(b > 9) cout << -1;
    else cout << a * b;

    return 0;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	
	ll n;
	ll ans = 0;
	string str;
	map<string, ll> mp;
	
	cin >> n;
	
	for(int i = 0; i < n; i++){
		cin >> str;
		sort(str.begin(), str.end());
		mp[str]++;
	}
	
	for(auto it = mp.begin(); it != mp.end(); it++){
		n = it->second;
		ans += (n * (n - 1)) / 2;
	}
	
	cout << ans << endl;
	
    return 0;
}



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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()
#define vprint(v) for(auto e:v){cout<<e<<" ";};cout<<endl;
#define vvprint(vv) for(auto v:vv)vprint(v);

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(20);

    ll H, W;
    cin >> H >> W;
    vll A(H), B(H);
    rep(i, H) cin >> A[i] >> B[i];

    map<int, int> m;
    rep(i, W) m[i] = 0;
    multiset<int> ms;
    rep(i, W) ms.insert(0);
    vll ans(H, 0);
    rep(i, H){
        int a = A[i]-1;
        int b = B[i]-1;
        auto lb = m.lower_bound(a);
        auto ub = m.upper_bound(b);
        if(lb!=m.end() && lb!=ub){
            --ub;
            auto it = lb;
            int k = ub->first;
            int v = ub->second;
            while(it!=m.end() && it->first!=k){
                int v = it->second;
                ms.erase(ms.find(v));
                it = m.erase(it);
            }
            if(b<W-1 && m.count(b+1)==0){
                m[b+1] = v+b-k+1;
                ms.insert(v+b-k+1);
            }
            m.erase(k);
            ms.erase(ms.find(v));
        }
        if(ms.empty()) ans[i] = -1;
        else ans[i] = *ms.begin() + i + 1;
    }
    rep(i, H) cout << ans[i] << endl;
}


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

int A[3];

int main(){
    cin >> A[0] >> A[1] >> A[2];

    sort(A,A+3);
    
    int cc=0;

    for(int i=1;i<3;i++){
        cc+=abs(A[i]-A[i-1]);
    }

    cout << cc << endl;

    return 0;
}


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

using namespace std;
using ll = long long;
#define int ll
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

signed main(void)
{
  int n;
  cin >> n;
  cout << n/3 << endl;

  return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
            #include<iostream>
            #include<cstdio>
            #include<vector>
            #include<queue>
            #include<map>
            #include<cstring>
            #include<string>
            #include <math.h>
            #include<algorithm>
        //    #include <boost/multiprecision/cpp_int.hpp>
            #include<functional>
          #define int long long
            #define inf  1000000007
            #define pa pair<int,int>
    #define ll long long
            #define pal pair<ll,ll>
            #define ppa pair<int,pa>
            #define  mp make_pair
            #define  pb push_back
            #define EPS (1e-10)
            #define equals(a,b) (fabs((a)-(b))<EPS)
     
            using namespace std;
     
            class Point{
            	public:
            	double x,y;
            	Point(double x=0,double y=0):x(x),y(y) {}
            	Point operator + (Point p) {return Point(x+p.x,y+p.y);}
            	Point operator - (Point p) {return Point(x-p.x,y-p.y);}
            	Point operator * (double a) {return Point(x*a,y*a);}
            	Point operator / (double a) {return Point(x/a,y/a);}
            	double absv() {return sqrt(norm());}
            	double norm() {return x*x+y*y;}
            	bool operator < (const Point &p) const{
            		return x != p.x ? x<p.x: y<p.y;
            	}
            	bool operator == (const Point &p) const{
            		return fabs(x-p.x)<EPS && fabs(y-p.y)<EPS;
            	}
            };
            typedef Point Vector;
     
            struct Segment{
            Point p1,p2;
            };
     
        double hen(Vector a){
        if(fabs(a.x)<EPS && a.y>0) return acos(0);
        else if(fabs(a.x)<EPS && a.y<0) return 3*acos(0);
        else if(fabs(a.y)<EPS && a.x<0) return 2*acos(0);
        else if(fabs(a.y)<EPS && a.x>0) return 0.0;
        else if(a.y>0) return acos(a.x/a.absv());
        else return 2*acos(0)+acos(-a.x/a.absv());
     
        }
     
int gcd(int v,int b){
	if(v>b) return gcd(b,v);
	if(v==b) return b;
	if(b%v==0) return v;
	return gcd(v,b%v);
}
            double dot(Vector a,Vector b){
            	return a.x*b.x+a.y*b.y;
            }
            double cross(Vector a,Vector b){
            	return a.x*b.y-a.y*b.x;
            }
        
            //----------------kokomade tenpure------------
string s,t;
int n,k;
    signed main(){
 cin>>n;
    	int d=1;
    	 k=0;
    	while(k<n){
    		k +=d;
    		d++;
    	}
    	
    	int u= k-n;
    	if(u==0){
    		
    		for(int i=1;i<=d-1;i++) cout<<i<<" ";
    		cout<<endl;
    		
    	}
    	else{
    		for(int i=1;i<=d-1;i++)if(i!=u) cout<<i<<" ";
    		cout<<endl;
    		
    	}
    	
    //	printf("%.10f\n",ans);
    	return 0;
    }

Measured memory_bytes: 256