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

using namespace std;

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

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos

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

  string S;
  cin >> S;

  for (char c : S) {
    cout << 'x';
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#define pi 2*acos(0.0)
int main()
{
    double R,s=0,t;
    scanf("%lf",&R);
    s=2*pi*R;
    t=s*1*pow(10,-2);
    printf("%.20lf\n",s);









    return 0;
}


Measured memory_bytes: 1752
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main(){
	fast;
	ll n,t;
	cin>>n>>t;
	ll arr[n];
	for(int i=0;i<n;i++)
		cin>>arr[i];
	ll buy=arr[0];
	ll maxProfit=0;
	ll ans=0;
	for(int i=1;i<n;i++)
	{
		if(arr[i]>buy)
		{
			if(arr[i]-buy>maxProfit)
				maxProfit=arr[i]-buy,ans=1;
			else if(arr[i]-buy==maxProfit)
				ans++;
		}
		else
			buy=arr[i];
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 4376
import collections

n,k = map(int,input().split())

d = []
a = []

for i in range(k):
    d_ = int(input())
    d.append(d_)
    a_ = list(map(int,input().split()))
    a = a + a_

c = collections.Counter(a)

# print(c)
# print(c.keys())
ans = 0
for i in range(n):
    if i+1 not in c.keys():
        ans += 1
print(ans)

Measured memory_bytes: 9488
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <limits>
#include <tuple>
#include <queue>
#include <stack>
#include <array>

using namespace std;
typedef long long ll;

int main()
{
	string S, T;
	cin >> S >> T;
	string ans;
	for (int i = (int)(S.length() - T.length()); i >= 0; i--) {
		bool match = true;
		for (auto j = 0; j < (int)T.length(); j++) {
			if (S[i + j] != '?' && S[i + j] != T[j]) {
				match = false;
				break;
			}
		}
		if (match) {
			ans = S.substr(0, i) + T + S.substr(i+T.length());
			replace(ans.begin(), ans.end(), '?', 'a');
			break;
		}
	}
	cout << (ans.empty() ? "UNRESTORABLE" : ans) << endl;
	return 0;
}


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

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

using namespace std;

int main(){
  int n,a;
  cin>>n;
  cin>>a;
  
  if(n%500<=a){
    cout<<"Yes";
  }else{
    cout<<"No";
  }
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define llu unsigned long long
#define loop(i,a,b) for (long long int i=a; i<b; i++)
#define loopr(i,a,b) for(long long int j=a-1;j>b;j--)
#define st string
#define sz size()
#define maxe *max_element
#define mine *min_element
#define gt greater<ll>()
#define F first
#define S second
#define R return
#define B break
#define C continue
#define pb push_back
#define tc ll t; cin>>t; while(t--)
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ROG ios::sync_with_stdio(0); cin.tie(0);
#define sortA(v)   sort(v.begin(), v.end())
#define sortD(v)   sort(v.begin(), v.end(), greater<auto>())
#define next cout<< "\n"
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<long long int> vll;
typedef vector<char> vc;
typedef long double ld;





int main()
{
    ROG
    
    ll x;
  cin >> x;
  if(x==0)
  {
    cout << 1 << "\n";
  }
  else
  {
    cout << '0' << "\n";
  }
        
    
}











Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < n; i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(ll i = m; i <= n; i++)
#define FORR(i, m, n) for(ll i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n)
#define MAX 100000
#define inf 1000000007
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
using graph = vector<vector<int>>;

int main() {
    //cin高速化
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a_min, sum;
    cin >> n;
    sum = 0;
    vll a(n, 0);//初期化忘れない
    REP(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    if(a.size() % 2 == 0){
        FORR(i, n-1, n/2){
            sum += a[i] * 2;
        }
        sum -= a[n-1];
    }else{
        FORR(i, n-1, (n-1)/2){
            sum += a[i] * 2;
        }
        sum -= a[n-1];
        sum -= a[(n-1)/2];
    }

    cout << sum <<"\n";
	return 0;
}

Measured memory_bytes: 4776
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
ll Max = 10 + 1e12;
int N = 5 + 1e5;

int main()
{
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	int cnt = 0;
	while (a >= b) {
		b *= 2;
		cnt++;
	}
	while (b >= c) {
		c *= 2;
		cnt++;
	}
	if (cnt <= k) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 3620
n=int(input())
A=list(map(int,input().split()))
B,C=[0 for i in range(n+1)],[]
cnt=0
for i in range(1,n+1)[::-1]:
    sum_list=sum([B[j] for j in range(i,n+1,i)])
    if sum_list%2!=A[i-1]:
        B[i]=1
        cnt +=1
        C.append(i)
print(cnt)
print(*[i for i in C[::-1]])

Measured memory_bytes: 14720
#include <stdio.h>

int main(){
    int n;
    int h[101]; 
 
    scanf("%d", &n);
    for(int i=0 ; i<n; ++i)scanf("%d",&h[i]);
 
    int max_height = h[0];
    int count=1;
    for(int i=1 ; i<n ; ++i){
        if(max_height <= h[i]){
            count++;
            max_height = h[i];
        }
    }
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
class Main
{
public static void main(String[] args)
 {
 Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int m = sc.nextInt();
  int a[][] = new int[n][m];
  int b[] = new int[m];
  long c;
  int i, j;
  
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      a[i][j]=sc.nextInt();
    }
  }
  for(j=0;j<m;j++){
    b[j]=sc.nextInt();
  }
  for(i=0;i<n;i++){
   c=0;
    for(j=0;j<m;j++){
      c+= a[i][j]*b[j];
    }
   System.out.println(c);
  }
}
}



Measured memory_bytes: 41036
import sys
import math

def dp(costs, K):
    table = [0]
    for i in range(1, len(costs)):
        min_cost = table[i-1] + abs(costs[i-1] - costs[i])
        for j in range(2, K + 1):
            jump = i - j
            if(jump >= 0):
                step = table[jump] + abs(costs[jump] - costs[i])
                min_cost = min([min_cost, step])
            else: 
                break
        table.append(min_cost)
    return table[-1]
        
def main():
    for index in range(2):
        line = input()
        if index == 0:
            K = int(line.split(" ")[1])
            continue
        costs = [int(s) for s in line.split(" ")]
        print(dp(costs, K))

if __name__ == "__main__":
    main()

Measured memory_bytes: 60256
from itertools import permutations
def wf(d):
  n=len(d[0])
  for k in range(n):
    for i in range(n):
      for j in range(n):
        if d[i][j]>d[i][k]+d[k][j]:
          d[i][j]=d[i][k]+d[k][j]
  return d
n,m,r=map(int,input().split());R=min(r,8)
d = [[10**12for i in range(n)]for j in range(n)]
l=[int(i)-1 for i in input().split()]
for i in range(m):
  a,b,c=map(int,input().split())
  d[a-1][b-1]=d[b-1][a-1] = c
d=wf(d)
#print(d)
ans=30**8
for v in permutations(l):
  cnt=sum(d[v][u] for v, u in zip(v, v[1:]))
  ans=min(ans,cnt)
print(ans)

Measured memory_bytes: 4672
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;
using ll = long long;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
const ll LINF = 1e18;

int main()
{
  int A, B, T; cin >> A >> B >> T;

  cout << T/A*B << endl;
}

Measured memory_bytes: 768
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    double A = scan.nextDouble();
    double B = scan.nextDouble();
    double H = scan.nextDouble();
    double M = scan.nextDouble();
    double hour, minute, c, co, ans;
    hour = H * 30 + M * 0.5;
    minute = M * 6;
    c = hour - minute;
    if (c > 180) {
      c = 360 - c;
    }
    else if (c < 0) {
      c = 360 + c;
    }
    co = Math.cos(Math.toRadians(c));
    ans = A * A + B * B - 2 * A * B * co;
    System.out.println(Math.sqrt(ans));
  }
}



Measured memory_bytes: 37532
// gcd lcm毎回勘で書いてるよね
// py, rbで解いてたから気づかんかったけどオーバーフローするなこれ

package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	var ans int
	fmt.Scan(&ans)
	for i := 1; i < N; i++ {
		var V int
		fmt.Scan(&V)
		ans = lcm(ans, V)
	}
	fmt.Println(ans)
}

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

func gcd(a, b int) int {
	if a > b {
		a, b = b, a
	}
	for a > 0 {
		a, b = b%a, a
	}
	return b
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define INF INT_MAX;
typedef long long ll;
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  char a[H][W];
  rep(i,H){
    rep(j,W){
      cin >> a[i][j];
    }
  }

  rep(i,W+2) cout << "#";
  cout << endl;
  rep(i,H){
    cout << "#";
    rep(j,W){
      cout << a[i][j];
    }
    cout << "#" << endl;
  }
  rep(i,W+2) cout << "#";
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	string s;
	int z[26];
	for(int k=0;k<26;k++){
		z[k]=0;
	}
	while(1){
		getline(cin,s);
		if (s=="") break;
		for(int i=0;i<s.size();i++){
			if(s[i]>='a'&&s[i]<='z')z[(int)s[i]-'a']++;
			else if(s[i]>='A'&&s[i]<='Z')z[(int)s[i]-'A']++;
		}
	}
	for(int j=0;j<26;j++){
		cout<<(char)(j+97)<<" : " <<z[j]<<endl;
	}
	return 0;
}



Measured memory_bytes: 3188
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
#include <random>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;
using pis = std::pair<int, std::string>;

const long long INF = 1000000000000000001;
const long long _MOD_ = 1000000000000000009;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
namespace mp = boost::multiprecision;

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

	int n;
	cin >> n;
	string* s = new string[n];
	rep(i, n) cin >> s[i];
	sort(s, s + n, [](const string &x, const string &y) { return x.length() < y.length(); });

	ll ans = 0;
	map<mp::int128_t, ll> rh;
	ll alpha[27];
	random_device rnd;
	mp::int128_t t = rnd();
	if (t < 125) t += 125;
	rep(i, n) {
		memset(alpha, 0, sizeof(ll) * 27);
		mp::int128_t hash = 0;

		rep(j, s[i].length()) ++alpha[s[i][j] - 'a' + 1];
		rep(k, 26) {
			mp::int128_t _hash = 0;
			if (alpha[k + 1]) {
				_hash = t * hash;
				_hash %= _MOD_;
				_hash += k + 1;
				_hash %= _MOD_;

				if(rh.find(_hash) != rh.end()) ans += rh[_hash];
			}
		}
		rrep(j, s[i].length() - 1) {
			--alpha[s[i][j] - 'a' + 1];

			hash *= t;
			hash %= _MOD_;
			hash += s[i][j] - 'a' + 1;
			hash %= _MOD_;

			rep(k, 26) {
				mp::int128_t _hash = 0;
				if (alpha[k + 1]) {
					_hash = t * hash;
					_hash %= _MOD_;
					_hash += k + 1;
					_hash %= _MOD_;

					if (rh.find(_hash) != rh.end()) ans += rh[_hash];
				}
			}
		}

		rh[hash] += 1;
	}

	cout << ans << "\n";

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
#define MEMS(a,b) memset(a,b,sizeof(a))
#define mp make_pair
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

const int MAX_N = 600000;

ll fact[MAX_N+100];
ll frev[MAX_N+100];

ll rev(ll a, ll p){
    if(p == 0) return 1;
    ll tmp = rev(a, p/2);
    tmp = tmp * tmp % MOD;
    if(p % 2 == 1) tmp = tmp * a % MOD;
    return tmp;
}


void calc_fact(){
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }
}


ll comb(int n, int k){
    if(n < 0 || k < 0 || n < k) return 0;
    if(n == 0 || k == 0) return 1;
    return fact[n] * frev[k] % MOD * frev[n-k] % MOD;
}

ll mod_pow(ll x, ll n, ll mod){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

ll mod_div(ll a, ll b){
    ll ret = a;
    ret *= mod_pow(b, MOD-2, MOD);
    return ret % MOD;
}

int main(){
    ll N, M;
    cin >> N >> M;

    //in main function
    fact[0] = frev[0] = 1;
    for(int i = 1; i <= MAX_N; i++){
        fact[i] = (fact[i-1] * i) % MOD;
        frev[i] = rev(fact[i], MOD-2);
    }

    vector<ll> K(N+1);
    K[0] = 1;
    for(int i = 1; i <= N; i++){
        K[i] = K[i-1] * i;
        K[i] %= MOD;
    }

    ll num = K[N];

    num *= comb(M, N);
    num %= MOD;


    ll h = 0;
    for(int k = 1; k <= N; k++){
        ll n = comb(N, k) * comb(M-k, N-k);
        n %= MOD;
        n *= K[N-k];
        n %= MOD;

        if(k % 2)
            h = (h + n) % MOD;
        else
            h = (h - n + MOD) % MOD;
    }

    ll num2 = (num - h + MOD) % MOD;

    ll ans = num * num2;
    ans %= MOD;

    cout << ans << endl;
    return 0;
}


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

int main()
{
    int n,m,a,i,s=0;

    cin>>n>>m;

    for(i=0;i<m;i++){
        cin>>a;
        s=s+a;
    }
    if(s>n){
        cout<<"-1"<<endl;
    }
    else{
        cout<<n-s<<endl;
    }
    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    multiset<string> s;
    string in;
    for (int i = 0; i < n; i++)
    {
        cin >> in;
        s.insert(in);
    }

    int num = 1;
    multiset<string>::iterator itr_start = s.begin();
    multiset<string>::iterator itr_next = s.begin();
    itr_next++;
    for (; itr_next != s.end(); itr_next++)
    {
        if (*itr_next == *itr_start)
            continue;
        else
        {
            itr_start = itr_next;
            num++;
        }
    }

    cout << num;
}


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

typedef long long int ll;


int main()
{
    ll n, x, y;
    cin >> n >> x >> y;
    vector<ll> ans(n - 1);
    for(ll i = 1;i <= n;i++){
        for(ll j = i + 1;j <= n;j++){
            ans[min(j - i, abs(i - x) + 1 + abs(j - y)) - 1]++;
        }
    }

    for(ll i = 0;i < (ll)ans.size();i++){
        cout << ans[i] << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX 100000
int head,tail;
int Q[MAX];
char QN[MAX][11];
char retname[11];

void initialize(void){
	head=0;
	tail=0;
}

int isEmpty(){
	return head==tail;
}

int isFull(){
	return head==(tail+1)%MAX;
}

void enqueue(char *name, int x){
	if(isFull()){
		exit(1);
	}
	strcpy(QN[tail],name);
	Q[tail]=x;
	if(tail+1==MAX){
		tail=0;
	}else{
		tail++;
	}
}

int dequeue(){
	int x;
	if(isEmpty()){
		exit(1);
	}
	x=Q[head];
	strcpy(retname,QN[head]);
	if(head+1==MAX){
		head=0;
	}else{
		head++;
	}
	return x;
}

int main(void){
	int n,q;
	int alltime=0;
	int i;
	char inputN[11];
	int inputT;
	scanf("%d",&n);
	scanf("%d",&q);
	initialize();
	for(i=0;i<n;i++){
		scanf("%s",inputN);
		scanf("%d",&inputT);
		enqueue(inputN, inputT);
	}
	int useT;
	while(1){
		if(isEmpty()==1) break;
		useT=dequeue();
		if(useT<=q){
			alltime+=useT;
			printf("%s %d\n",retname,alltime);
		}else{
			alltime+=q;
			useT-=q;
			enqueue(retname,useT);
		}
	}
	
	return 0;
}

Measured memory_bytes: 3164
import sys
from heapq import heappush, heappop

input = sys.stdin.readline
pq = []
while True:
    command = list(map(str, input().split()))
    if command[0] == 'insert':
        heappush(pq, int(command[1])*(-1))
    elif command[0] == 'extract':
        print(heappop(pq)*(-1))
    else:
        break



Measured memory_bytes: 45584
#include<stdio.h>
#define N 1000000

int min(int a,int b){return (a>b)?b:a;}

int dp[N],dp_odd[N];

int main(void){
  int i,j,n,tmp;
  int plc[1000],num;

  for(i=0;i<N;i++)dp[i] = dp_odd[i] = N+1;
  dp[0] = dp_odd[0] = 0;

  tmp = 1;
  for(num=1;;num++){
    plc[num] = tmp;
    tmp *= num+3; tmp /= num;
    if(tmp>=N)break;
  }
  
  for(i=0;i<N;i++){
    for(j=1;j<num;j++){
      if(i<plc[j])break;
      dp[i] = min(dp[i],dp[i-plc[j]]+1);
      if(plc[j]&1)dp_odd[i] = min(dp_odd[i],dp_odd[i-plc[j]]+1);
    }
  }

  while(scanf("%d",&n) && n)printf("%d %d\n",dp[n],dp_odd[n]);
  return 0;
}

Measured memory_bytes: 8092
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var list = new List<char>() { 'a', 'e', 'i', 'o', 'u' };
            var c = Console.ReadLine();
            foreach (var l in list)
            {
                if (c.Contains(l))
                {
                    Console.WriteLine("vowel");
                    return;
                }
            }

            Console.WriteLine("consonant");
        }
    }
}


Measured memory_bytes: 13152
#include<cstdio>
#include<string>
#include<queue>
using namespace std;

int main(){
	char com[20];
	priority_queue<int> PQ;
	while(1){
		scanf("%s",com);
		if(com[0] == 'i'){
			int key;scanf("%d",&key);
			PQ.push(key);
		}else if(com[1] == 'x'){
			printf("%d\n",PQ.top());
			PQ.pop();
		}else if(com[0] == 'e'){
			break;
		}
	}
	return 0;
}



Measured memory_bytes: 6536
x = int(input())
if 400 <= x < 600: kyu = 8
if 600 <= x < 800: kyu = 7
if 800 <= x < 1000: kyu = 6
if 1000 <= x < 1200: kyu = 5
if 1200 <= x < 1400: kyu = 4
if 1400 <= x < 1600: kyu = 3
if 1600 <= x < 1800: kyu = 2
if 1800 <= x < 2000: kyu = 1
print(kyu)

Measured memory_bytes: 9208
from collections import deque

INF = -1

sizeI, sizeJ = map(int, input().split())
a = [input().rstrip() for _ in range(sizeI)]

def bfs(startI, startJ):
    dist = [[INF for _ in range(sizeJ)] for _ in range(sizeI)]
    dist[startI][startJ] = 0
    q = deque([(startI, startJ)])
    while q:
        i, j = q.pop()
        curDist = dist[i][j]
        for di, dj in ((1, 0), (-1, 0), (0, 1), (0, -1)):
            ni, nj = i + di, j + dj
            if 0 <= ni < sizeI and 0 <= nj < sizeJ and dist[ni][nj] == INF and a[ni][nj] == '.':
                dist[ni][nj] = 1 + curDist
                q.appendleft((ni, nj))
    return max([max(row) for row in dist])

ret = -float('inf')
for i in range(sizeI):
    for j in range(sizeJ):
        if a[i][j] == '.':
            ret = max(ret, bfs(i, j))
print(ret)

Measured memory_bytes: 3316
from collections import Counter
import numpy


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

even = a[0::2]
odd= a[1::2]
even_counter = Counter(even)
odd_counter = Counter(odd)
#print(len(even_counter.most_common()))
#print(odd_counter.most_common()[0][0])
c = even_counter.most_common()[0][0]
d = odd_counter.most_common()[0][0]

cnt = 0
if even_counter.most_common()[0][0] == odd_counter.most_common()[0][0]:
	if len(even_counter.most_common())==1 and len(odd_counter.most_common())==1:
		print(int(n/2))
		quit()
	elif len(even_counter.most_common())!=1 and len(odd_counter.most_common())==1:
		c = even_counter.most_common()[1][0]
	elif len(even_counter.most_common())==1 and len(odd_counter.most_common())!=1:
		d = odd_counter.most_common()[1][0]
	else:
		if len(even_counter.most_common())<len(odd_counter.most_common()):
			c = even_counter.most_common()[1][0]
		else:
			d  = odd_counter.most_common()[1][0]
            
    	
for i in range(int(n/2)):
	if a[i*2] != c:
		cnt = cnt+1
	if a[i*2+1] != d:
		cnt = cnt+1
#print(c)
print(cnt)

Measured memory_bytes: 27024
/**
 *	author: tanishq_code_c
**/
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>

using namespace std;
// using namespace __gnu_pbds;
// template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



void __print(int x) {cerr << x;}; void __print(long x) {cerr << x;}; void __print(long long x) {cerr << x;}; void __print(unsigned x) {cerr << x;}; void __print(unsigned long x) {cerr << x;}; void __print(unsigned long long x) {cerr << x;}; void __print(float x) {cerr << x;}; void __print(double x) {cerr << x;}; void __print(long double x) {cerr << x;}; void __print(char x) {cerr << '\'' << x << '\'';}; void __print(const char *x) {cerr << '\"' << x << '\"';}; void __print(const string &x) {cerr << '\"' << x << '\"';}; void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}


#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif


#define int             							long long
#define setbits(x)     							    __builtin_popcountll(x)
#define zerobits(x)     							__builtin_ctzll(x)
#define mod             							1000000007
#define inf            							    1e18
#define endl            							'\n'
#define pb              							push_back
#define all(x)          							x.begin(),x.end()
#define ff              							first
#define ss              							second
#define rep(i,n)                                  	for(int i = 0; i < n; i++)
#define set(n)                                      fixed << setprecision(n)

int powmod(int a, int b) {int res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a % mod; a = a * a % mod;} return res;}
int fast_pow(int a, int b) {if (b == 1) return a; if (b == 0) return 1; int x = fast_pow(a, b / 2); x *= x; if (b & 1) x *= a; return x;}

void t_c_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	/*#ifndef ONLINE_JUDGE
		freopen("inp.txt", "r", stdin);
		freopen("out.txt", "w", stdout);
	#endif*/
	int d, t, s; cin >> d >> t >> s;
	if (s * t < d) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
}

int32_t main()
{
	t_c_c();
	return 0;
}


Measured memory_bytes: 3652
x, k, d = map(int, input().split())
x = abs(x)
a = x // d # 必要回数
if k <= a:
  print(x - k * d)
  exit()
k -= a
eveng = x - d * a
oddg = abs(x - d * (a + 1))
if k % 2 == 0:
  print(eveng)
else:
  print(oddg)

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int five = 0,seven = 0;
  if(a==5){
    five++;
  }
  else if(a==7){
    seven++;
  }
  if(b==5){
    five++;
  }
  else if(b==7){
    seven++;
  }
  if(c==5){
    five++;
  }
  else if(c==7){
    seven++;
  }
  if(five==2 && seven==1){
    cout<<"YES";
  }
  else{
    cout<<"NO";
  }
}

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

int nums[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

signed main(){
  int k;
  cin >> k;
  cout << nums[k - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxN = 2e5+7;
const int maxM = 1e5+7;
const int maxV = 90010;
//const int INF = 1e9+9;
//const ll INF = (1ll)<<60;
const int INF = 2e9+9;
const int MOD = 1e9+7;

int n;
pii a[maxN];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d",&a[i].second,&a[i].first); 
	}
	sort(a+1,a+1+n);
	int st = 0;
	int flag = 1;
	for(int i=1;i<=n;i++)
	{
		int x = a[i].first;
		int y = a[i].second;
		if(st+y <= x)
		{
			st += y;
		}
		else
		{
			flag = 0;
			break;
		}
	}
	if(flag)
	{
		puts("Yes");
	}
	else
	{
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define SUM(n) ((n)+1)*(n)/2 //1〜nまでの総和を求める式
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) fixed<<setprecision(x+1) //小数点桁数を指定する
#define abs(x,y) max(x,y)-min(x,y)
#define all(v) v.begin(),v.end()
#define UPDigit(a,b) (a+b-1)/b //小数点切り上げ 
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7; 
using namespace std;
using pii = pair<int, int>;
typedef vector<int> vit;
const int dy[] = {0, 1, 0, -1, -1, 1, 1, -1};
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};

//最大公約数
lol gcd(lol x, lol y){
  if(x < y) swap(x, y);
  lol r = x % y;
  while(r != 0){
    x = y;
    y = r;
    r = x % y;
  }
  return y;
}

//最小公倍数
lol lcm(lol x, lol y){
  lol a = x * y;
  return (a / gcd(x, y));
}
  
signed main(void){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int n;
  cin >> n;
  lol a[n + 5];
  map<lol, lol> l, r;
  reps(i, n){
    cin >> a[i];
    l[i - a[i]] ++;
    r[i + a[i]] ++;
  }
  lol ans = 0;
  for(auto x : l){
    int foo = r[x.first];
    ans += x.second * foo;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 39480
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;

ll dp[60][60][3000];

void solve(){
    int n,a;
    cin >> n >> a;
    vector<int> x;
    rep(i,n){
        int tmp;
        cin >> tmp;
        x.emplace_back(tmp);
    }
    /*dpで解く
    dp[j][k][s]：x1,...,xjからk枚を選んで総和をsにする場合の数
    dp[j][k][s]=dp[j-1][k][s] + dp[j-1][k-1][s-xj]
    ただし、
    j=0:0
    k=0:0
    s<xj:dp[j-1][k][s]
    dp[0][0][0]:1とする
    dp[n][k][k*A]を全てのkについて計算して総和をとる
    */
    
    

    for(int i=0; i<=n; i++){
      for(int j=0; j<=n; j++){
        for(int k=0; k<=n*a; k++){
          if(i==0||j==0||k==0) dp[i][j][k]=0;
          if(j==0&&k==0) dp[i][j][k]=1;
        }
      }
    }

    dp[0][0][0]=1;

    for(int i=1; i<=n; i++){
      for(int j=1; j<=n; j++){
        for(int k=1; k<=n*a; k++){
          if(k<x[i-1]) dp[i][j][k]=dp[i-1][j][k];
          else dp[i][j][k]=dp[i-1][j][k]+dp[i-1][j-1][k-x[i-1]];
          //cout << "i:" << i << " j:" << j << " k:" << k << " dp[i][j][k]:" << dp[i][j][k] << endl;
        }
      }
    }

    ll count = -1;
    rep(i,n+1){
      count += dp[n][i][i*a];
    }
    cout << count << endl;
    
}

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


Measured memory_bytes: 71680
#include<iostream>
#define INF 100000001
using namespace std;

int N,M,L,K,A,H,T[101],map[101][101];

void floyd()
{
  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	map[i][j]=min(map[i][j],map[i][k]+map[k][j]);
      }
    }
  }
}

int main()
{
  int a,b,time;
  while(1){
    cin>>N>>M>>L>>K>>A>>H;
    if(N==0&&M==0&&L==0&&K==0&&A==0&&H==0)break;
    for(int i=0;i<N;i++){
      T[i]=0;
      for(int j=0;j<N;j++)map[i][j]=INF;
    }
    for(int i=0;i<L;i++){
      cin>>a;
      T[a]=1;
    }
    T[A]=1;T[H]=1;
    for(int i=0;i<K;i++){
      cin>>a>>b>>time;
      map[a][b]=time;
      map[b][a]=time;
    }
    floyd();
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	if(map[i][j]>M || T[i]==0 || T[j]==0)map[i][j]=INF;
      }
    }
    floyd();
    if(map[A][H]>=INF)cout<<"Help!"<<endl;
    else if(map[A][H]<M)cout<<map[A][H]<<endl;
    else cout<<map[A][H]*2-M<<endl;
  }
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vp;
typedef set<ll> si;
typedef map<string, ll> msi;
#define REP(i,a,b) \
for(ll i=ll(a);i<=ll(b);i++)
#define DEP(i,a,b) \
for(ll i=ll(a);i>=ll(b);i--)
#define TR(c, it) \
for (auto it = (c).begin(); it != (c).end(); it++)
#define mp make_pair
#define pb push_back
#define F first
#define S second
//ll mod 1e9+7;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  
  int T;
  T=1;
  while(T--)
  {
      ll n,i,j,k,l,m;
      cin>>n;
      string s;
      vector<ll> v;
      REP(i,1,n){
        cin>>j;
        v.pb(j);
      }
      sort(v.begin(),v.end());
      ll ans=v[n-1];
      k=n-2;
      DEP(i,n-2,0){
        if(k<=0)break;
        ans+=v[i];
        k=k-1;
        if(k<=0)break;
        ans+=v[i];
        k=k-1;
      }
      cout<<ans;
  }
  return 0;
}

Measured memory_bytes: 5340
n = int(input())
x = list(map(int, input().split()))
sorted_x = sorted(x)

lmid = sorted_x[n // 2 - 1]
rmid = sorted_x[n // 2]

for xi in x:
    if xi <= lmid:
        print(rmid)
    else:
        print(lmid)

Measured memory_bytes: 25220
#include <cstdio>
#include <algorithm>
#define rep(i, a, b) for (int i = a ; i <= b; ++ i) 
const int M = 18, N = 3e5 + 5 ;
using namespace std ;
int n,v[M+5],x[N],L[M+1][N],R[M+1][N],dpl[N],dpr[N],bit[N],m ;
int main() {
	scanf("%d%d",&n,&v[0]) ;
	rep(i,1,n) scanf("%d",&x[i]) ;
	for (m = 1;; m++) {
		v[m]=v[m-1]/2;
		if (!v[m]) break ;
	}
	rep(j,0,m) {
		L[j][1]=L[j][0]=1 ;
		rep(i, 2, n) L[j][i]=(x[i]-x[i-1]<=v[j]?L[j][i-1]:i);
		R[j][n]=R[j][n+1]=n;
		for (int i=n-1;i;--i) R[j][i] =(x[i+1]-x[i]<=v[j]?R[j][i+1]:i);
	}
	int st=(1<<m)-1;
	dpl[0]=0,dpr[0]=n+1;
	rep(i,1,st) {
		dpl[i]=0,dpr[i]=n+1;
		rep(j,1,m) if((i>>(j-1))&1) {
			dpl[i]=max(dpl[i],R[j][dpl[i^(1<<(j-1))]+1]) ;
			dpr[i]=min(dpr[i],L[j][dpr[i^(1<<(j-1))]-1]) ;
		}
	}
	rep(i,0,n+1) bit[i]=-n;
	rep(i,0,st) bit[dpr[i]]=max(bit[dpr[i]],dpl[st^i]);
	rep(i,1,n+1) bit[i]=max(bit[i],bit[i-1]);
	rep(i,1,n) puts((bit[R[0][i]+1]>=L[0][i]-1)?"Possible":"Impossible");
	return 0 ; 
}

Measured memory_bytes: 51072
import Control.Monad
import Data.List
 
main = do
  n <- readLn
  xs <- replicateM n getLine
  putStr . sort $ foldl1 f xs
 
f [] _ = []
f (x:xs) ys
  | x `elem` ys = x : f xs (delete x ys)
  | otherwise = f xs ys

Measured memory_bytes: 1020
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc048_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  ll a, b, x;
  cin >> a >> b >> x;

  ll min = a / x;
  ll max = b / x;
  ll ans = max - min;
  if (a % x == 0) ans++;

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n,ans=0,f;
	string base;
	string s;
	cin>>n;
	cin>>base;
	for(int kagasan=0;kagasan<n;kagasan++){
		cin>>s;
		f=0;
		for(int i=0;i<s.size() && f==0;i++){
			for(int j=0;j<s.size() && f==0;j++){
				for(int k=i,f2=1,l=0;f2==1 && f==0;k+=j,l++){
					if(k<s.size()){
						if(base[l]!=s[k])f2=0;
						else if(l==base.size()-1)f=1,f2=0;
					}
					else f2=0;
				}
			}
		}
		if(f==1)ans++;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1208
import collections
MOD = 10**18+9
n = int(input())
a = list(map(int, input().split()))
b = [[0 for j in range(2)] for i in range(n)]
c = collections.Counter(a)
s = 0
def nCr(nn, r, mod):
	r = min(r, nn-r)
	numer = denom = 1
	for i in range(1, r+1):
		numer = numer * (nn+1-i) % mod
		denom = denom * i % mod
	return numer * pow(denom, mod-2, mod) % mod
for i in c:
	if c[i] < 2:
		b[i-1][0] = 0
	else:
		b[i-1][0] = nCr(c[i],2,MOD)
		s += b[i-1][0]
	if c[i]-1 < 2:
		b[i-1][1] = 0
	else:
		b[i-1][1] = nCr(c[i]-1,2,MOD)
for i in a:
	ans = s-b[i-1][0] + b[i-1][1]
	print (ans)

Measured memory_bytes: 45628
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <functional>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <queue>

//#define INF 1000000000;
#define MOD 1000000007;
#define LIMIT 1000000000000000000;
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
typedef pair<int, int> P;
#define int long long

struct Setup {
    Setup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} SETUP;

template<class T>
bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = 1LL << 60;

char group[] = { 'M','A','R','C','H' };
map<char, int> mp;
signed main() {
    int n; cin >> n;
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        for (int j = 0; j < 5; j++) {
            if (s[0] == group[j]) {
                mp[group[j]]++;
            }
        }
    }

    ll ans = 0;
    for (int i = 0; i < 5; i++) {
        for (int j = i + 1; j < 5; j++) {
            for (int k = j + 1; k < 5; k++) {
                ans += mp[group[i]] * mp[group[j]] * mp[group[k]];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <stack>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <cctype>
#include <complex>
#include <string>
#include <sstream>

using namespace std;

#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define rep(i,n) for(int i=0;i<(n);i++)
#define tr(it,container) for(typeof(container.begin()) it = container.begin(); \
                                                  it != container.end(); ++it)
#define mp(a,b) make_pair((a),(b))

typedef long long ll;
typedef complex<double> point;

// up right down left
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};

const double EPS = 1e-9;
const int days[]     = {31,28,31,30,31,30,31,31,30,31,30,31};
const int daysleap[] = {31,29,31,30,31,30,31,31,30,31,30,31};

int main(){
    while(true){
        // pc student
        int N,M;
        cin >> N >> M;
        if(N==0) break;
        int r;
        cin >> r;
        // student pc login time
        vector<vector<int> > V(M,vector<int>(N));
        // User log
        vector<bitset<1300> > U(M);
        rep(i,r){
            // time pc student login?
            int t,n,m,s;
            cin >> t >> n >> m >> s;
            n--;m--;
            //login
            if(s==1){
                V[m][n] = t;
            }else{
                // close.
                for(int j=V[m][n];j<t;j++){
                    U[m][j]=true;
                }
            }
        }
        int q;
        cin >> q;
        rep(i,q){
            int ts,te,m;
            //from to student
            cin >> ts >> te >> m;
            m--;
            int cnt = 0;
            for(int j=ts;j<te;j++){
                if(U[m][j]) cnt++;
            }
            cout << cnt << endl;
        }
    }
    return 0;
}

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

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		long n = fs.nextLong(), a = fs.nextLong(), b = fs.nextLong();
		long c = a + b;
		
		long t = n/c;
		
		long ans = t * a;
		long rem = n%c;
		
		long plus = Math.min(rem, a);
		ans += plus;
		System.out.println(ans);
		
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
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 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: 22100
N = int(input())
dp = [[0] * 3 for i in range(100)]

MOD = int(1e9+7)
maxBit = 70
while not (N >> maxBit):
    maxBit -= 1

dp[maxBit][0] = 1
dp[maxBit][1] = 1
for i in range(maxBit-1, -1, -1):
    for j in range(3):
        bit = (N >> i) & 1
        for k in range(3):
            nj = 2 * j + bit - k
            if nj < 0:
                continue
            nj = min((nj, 2))
            dp[i][nj] += dp[i+1][j]
            dp[i][nj] %= MOD

print(sum(dp[0]) % MOD)


Measured memory_bytes: 38512
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pllll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector< pair<int, int> > vii;
typedef vector< pair<long long, long long> > vllll;
typedef map<int, int> mii;
typedef map<long long, long long> mllll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0ll)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
#define bitsum(x) __builtin_popcount(x)
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a / gcd(a, b) * b;
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  ll n, m;
  cin >> n;
  m = n;
  for(int i = 1; i <= sqrt(n); i++) {
    if(n % i) continue;
    ll x = n / i - 1;
    if(x > 0 && n / x == n % x)
      ans += n / i - 1;
    // int y = i - 1;
    // if(y > 0 && n / y == n % y)
    //   ans += y;
  }
  // unordered_set<int> st;
  // ans += n - 1;
  // while(n % 2 == 0) {
  //   if(st.count(2) == 0) {
  //     ans += m / 2 - 1;
  //     st.insert(2);
  //   }
  //   n /= 2;
  // }
  // for(int i = 3; i <= sqrt(n); i += 2) {
  //   while(n % i == 0) {
  //     if(st.count(i == 0)) {
  //       ans += m / i - 1;
  //       st.insert(i);
  //     }
  //     n /= i;
  //   }
  // }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    int N;
    cin >> N;
    int s[N];
    rep(i, N) cin >> s[i];
    int sum = 0;
    int min_num = 100; //各問題の配点で、10の倍数でなく、克一番小さい配点を格納
    int cnt = 0;
    rep(i, N){
        sum += s[i];
        if(s[i] % 10 != 0 && min_num > s[i]) min_num = s[i];
        if(s[i] % 10 == 0) cnt++;
    }
    if(cnt == N){
        cout << 0 << endl;
        return 0;
    }
    if(sum % 10 != 0) cout << sum << endl;
    else cout << sum - min_num << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <math.h>
const int N = 1e3+10;
int b[N];
int main() {
	int n, k; scanf("%d%d", &n, &k); int ans = n;
	for (int i=1; i<=k; i++) {
		int d; scanf("%d", &d);
		for (int j=1; j<=d; j++) {
			int x; scanf("%d", &x);
			if (!b[x]) --ans; ++b[x];
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define ll long long
#define cpp boost::multiprecision::cpp_int
#define dequeue deque
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = 1; i <= n; i++)
#define drep(i, n) for(int i = n-1; i >= 0; i--)
#define srep(i, s, t) for (int i = s; i < t; i++)
#define vi vector<int>
#define P pair<ll, ll>
int mod = 1'000'000'000 + 7;
const double PI = 3.1415926535897932384626433832795;
struct edge {
	int to;
	ll cost;
};
void reverse(string* s) {
	reverse((*s).begin(), (*s).end());
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
void COME_LET_THE_GAMES_BEGIN() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << setprecision(20);
}
int main() {
	COME_LET_THE_GAMES_BEGIN();
	ll x;
	cin >> x;
	ll ans = 0;
	ans = x / 11 * 2;
	ll k = x % 11;
	if (0 < k && k <= 6) {
		ans++;
	}
	else if (6 < k) {
		ans += 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val sList = Array(n) { readLine()!! }
    val countAB = sList.sumBy {
        var count = 0
        for (i in 0 until it.length - 1) {
            if (it[i] == 'A' && it[i + 1] == 'B') count++
        }
        count
    }
    val countBA = sList.count { it.first() == 'B' && it.last() == 'A' }
    val countLastA = sList.count { it.first() != 'B' && it.last() == 'A' }
    val countFirstB = sList.count { it.first() == 'B' && it.last() != 'A' }
    if (countBA > 0) {
        if (countLastA > 0 && countFirstB > 0) {
            println(countAB
                    + countBA - 1
                    + 2
                    + Math.min(countLastA - 1, countFirstB - 1))
        } else {
            println(countAB
                    + countBA - 1
                    + if (countLastA > 0 || countFirstB > 0) 1 else 0)
        }
    } else if (countFirstB > 0 && countLastA > 0) {
        println(countAB + Math.min(countLastA, countFirstB))
    } else {
        println(countAB)
    }
}

Measured memory_bytes: 34648
#include<iostream>
#include<vector>
using namespace std;
int main(){
	int n, m, x, y,amax,bmin;
	cin >> n >> m >> x >> y;
	vector<int> a(n), b(m);
	for (int i = 0; i < n; i++){
		cin >> a.at(i);
	}
	for (int i = 0; i < m; i++){
		cin >> b.at(i);
	}
	for (int i = 0; i < n; i++){
		if (i == 0){
			amax = a.at(i);
		}
		else{
			if (amax <= a.at(i)){
				amax = a.at(i);
			}
		}
	}
	for (int i = 0; i < m; i++){
		if (i == 0){
			bmin = b.at(i);
		}
		else{
			if (bmin >= b.at(i)){
				bmin = b.at(i);
			}
		}
	}

	if (amax < x){
		amax = x;
	}
	else if (bmin>y){
		bmin = y;
	}

	if (amax >= bmin){
		cout << "War" << endl;
	}
	else{
		cout << "No War" << endl;
	}


	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cstring>
#include <iostream>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

typedef long long llint;

const int MAX = 64*100100;
const int inf = 1e9;

char s[MAX];
int f[MAX];
int nx[MAX], nr[MAX], ns[MAX];


int main(void) {
  int t;
  scanf("%d", &t);
  while (t--) {
    scanf("%s", s);
    int len = strlen(s);
    int i = 0;
    int last = 0;
    int sum = 0;
    while (i < len) {
      if (s[i] == '.') {
        last /= 2;
        i++;
      } else {
        assert(s[i] == 'R');
        i++;
        int x = 0;
        while (i < len && isdigit(s[i])) x = x*10 + s[i++] - '0';
        last = 64 / x;
      }
      sum += last;
    }

    f[0] = 0;
    nx[0] = -1;
    FOR(s, 1, sum + 1) {
      f[s] = inf;
      auto test = [&] (int x, int d) {
        int len = 1 + 1 + (x >= 10) + d, tmp = x;
        int total = 64 / x;
        REP(i, d) total += 64 / (tmp *= 2);
        if (total > s) return;
        if (len + f[s - total] < f[s]) {
          f[s] = len + f[s - total];
          nx[s] = x, nr[s] = d, ns[s] = s - total;
        }
      };

      FOR(i, 1, 7) test(1, 7-i);
      REP(i, 7) test(16, 6-i);
      test(1, 0);
      for (int x: {2, 32, 4, 64, 8}) REP(i, 7) test(x, 6-i);
    }
  
    while (sum > 0) {
      putchar('R');
      printf("%d", nx[sum]);
      REP(i, nr[sum]) putchar('.');
      sum = ns[sum];
    }
    putchar('\n');
  }
  return 0;
}

Measured memory_bytes: 53288