akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<ll> c;

bool is357(string x) {
	int exist3 = x.find('3');
	int exist5 = x.find('5');
	int exist7 = x.find('7');
	if (exist3 != -1 && exist5 != -1 && exist7 != -1) return true;
	else return false;
}

void get357Number(string s_prev) {

	if (s_prev.size() == 10) {
		return;
	}

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

		if (i == 0) {
			string s_now = s_prev + '3';
			if (is357(s_now)) {
				c.emplace_back(stoll(s_now));
			}
			get357Number(s_now);
		}
		else if (i == 1) {
			string s_now = s_prev + '5';
			if (is357(s_now)) {
				c.emplace_back(stoll(s_now));
			}
			get357Number(s_now);
		}
		else { // i == 2
			string s_now = s_prev + '7';
			if (is357(s_now)) {
				c.emplace_back(stoll(s_now));
			}
			get357Number(s_now);
		}
	}
}


int main() {

	ll n; cin >> n;
	
	string s = "";

	get357Number(s);
	sort(c.begin(), c.end());

	ll ans;
	for (ll i = 0; i < c.size(); i++) {
		if (c[i] <= n) {
		}
		else {
			ans = i;
			break;
		}
	}

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

Measured memory_bytes: 1400
#include <iostream>
#include <cmath>
#include <climits>

using namespace std;

#define ll long long int

ll minAns(ll *arr,int num,int k){
    ll *dp = new ll[num];
    for(int i=0;i<num;i++){
        dp[i] = INT_MAX;
    }
    
    dp[0] = 0;
    
    for(ll i=1;i<num;i++){
        for(int j=1;j<=k;j++){
            if((i-j)>=0){
                // cout<<i<<" "<<j<<endl;
                dp[i]= min(dp[i],dp[i-j] + abs(arr[i]-arr[i-j]));
            }
        }
    }
    
    
    return dp[num-1];
}

int main()
{
    ll num,k;
    cin>>num>>k;
    ll *arr = new ll[num];
    for(int i=0;i<num;i++){
        cin>>arr[i];
    }
    
    cout<<minAns(arr,num,k);
    
    return 0;
}


Measured memory_bytes: 5092
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


int n;
vll vh;
vll dp;

void init()
{
	cin >> n;
	vh.resize(n);
	REP(i, n)
		cin >> vh[i];
	dp.resize(n, INTMAX);
	dp[0] = 0;

}

int main()
{
	init();

	REP(i, n)
	{
		if (i + 1 < n)
			chmin(dp[i + 1], dp[i] + abs(vh[i + 1] - vh[i]));
		if (i + 2 < n)
			chmin(dp[i + 2], dp[i] + abs(vh[i + 2] - vh[i]));
	}

	cout << dp[n - 1] << endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll H,A; cin>>H>>A;
    ll ans=0;
    ans=(H+A-1)/A;
    cout<< ans <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		long a = (long)Math.pow(10, 18);
		int n = scan.nextInt();
		long ans = 1;
		
		for(int i=0;i<n;i++) {
			long x = scan.nextLong();
			
			if(a < x) {
				for(int j=i+1;j<n;j++) {
					long z = scan.nextLong();
					if(z == 0) {
						System.out.println(0);
						System.exit(0);
					}
				}
				System.out.println(-1);
				System.exit(0);
			}else {
				if(x == 0) {
					System.out.println(0);
					System.exit(0);
				}
				a = a/x;
				ans *= x;
			}
			
		
		}
		
		System.out.println(ans);
		
		
	}	
	
	//�ŏ�����
	/*
	static int gcd (int a, int b) {
		int temp;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return b;
	}
	*/
	
	//����ւ�
	/*
	static int swap (int a, int b) {
		int swap_arr[] = new int[2];
		
		swap[0] = b;
		swap[1] = a;
		
		return swap_arr;
	}
	*/
	
}


Measured memory_bytes: 59756
#include<iostream>
#include "string"

using namespace std;
int N,a[10000];
int t,f,ans;
 
int main(){
	cin >> N;
	t=1;
	for(int i=1;i<8;i++){
		if(N<t*2){
			ans=t;
			break;
		}
		t=t*2;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#![allow(clippy::needless_range_loop)]
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::*;
use num::BigInt;

fn gcd(a: &BigInt, b: &BigInt) -> BigInt {
    let r = a % b;
    if r == BigInt::from(0) {
        b.clone()
    } else {
        gcd(b, &r)
    }
}

fn main() {
    input! {
        a: [BigInt]
    }

    let lcm = a.iter().cloned().fold1(|a, b| &a * &b / gcd(&a, &b)).unwrap();
    let sum: BigInt = a.iter().map(|x| &lcm / x).sum();
    let ans = sum % BigInt::from(1000000007);
    println!("{}", ans);
}


Measured memory_bytes: 3724
n,t = map(int, input().split())
ct = [[0,0] for j in range(n)]
lst = []
for j in range(n):
    ct[j][0], ct[j][1] = map(int, input().split())
for j in range(n):
    if ct[j][1] <= t:
        lst.append(ct[j][0])
if lst == []:
    print('TLE')
else:
    print(min(lst))     

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

int main()
{
  int n,temp,k;cin>>n;
  //deque<int> dq;
  vector<pair<int,int> > v;
  for(int i=0;i<n;i++)
  {
    cin>>temp;
    v.push_back(make_pair(temp,i));
  }
  sort(v.begin(),v.end());
  for(auto a:v) cout<<a.second+1<<' ';
}

Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;
using namespace std;

int main(){
  ll N;
  string S;
  cin >> N >> S;
  
  ll r[N],g[N],b[N];
  ll ir,ig,ib,nr,ng,nb;
  ir=0; ig=0; ib=0;
  REP(ll, i, 0, N){
    if(S[i]=='R'){
      r[ir]=i;
      ir++;
    }else if(S[i]=='G'){
      g[ig]=i;
      ig++;
    }else{
      b[ib]=i;
      ib++;
    }
  }
  nr=ir; ng=ig; nb=ib;

  ll ans=nr*ng*nb;
  for(ir=0; ir<nr; ir++){
    for(ig=0; ig<ng; ig++){
      if(r[ir]<g[ig]){
        if(2*g[ig]-r[ir]<N && S[2*g[ig]-r[ir]]=='B') ans--;
        if((g[ig]+r[ir])%2==0 && S[(g[ig]+r[ir])/2]=='B') ans--;
        if(2*r[ir]-g[ig]>-1 && S[2*r[ir]-g[ig]]=='B') ans--;
      }else{
        if(2*g[ig]-r[ir]>-1 && S[2*g[ig]-r[ir]]=='B') ans--;
        if((g[ig]+r[ir])%2==0 && S[(g[ig]+r[ir])/2]=='B') ans--;
        if(2*r[ir]-g[ig]<N && S[2*r[ir]-g[ig]]=='B') ans--;
      }
    }
  }
  
  printf("%lld",ans);
}

Measured memory_bytes: 3776
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>

using namespace std;
typedef long long ll;

const ll MOD=1000000007;

int main(){
  int N,K;
  cin >> N >> K;
  vector<ll> A(N+2);
  A[0]=-1000000100;
  A[N+1]=1000000100;
  for(int i=1;i<=N;i++) cin >> A[i];

  vector<ll> fac(N+1);
  vector<ll> inv(N+1);
  vector<ll> facinv(N+1);

  fac[0]=fac[1]=1;
  facinv[0]=facinv[1]=1;
  inv[1]=1;

  for(int i=2;i<=N;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    facinv[i]=facinv[i-1]*inv[i]%MOD;
  }

  ll ans=0;
  sort(A.begin(),A.end());
  int cur=1;
  while(cur<=N+1-K){
    ll a=A[cur];
    int n=0;
    while(a==A[cur+n]) n++;
    for(int i=1;i<=min(n,K);i++){
      if(0<=N-cur-n+1-K+i){
        ans-=a*fac[n]%MOD*facinv[i]%MOD*facinv[n-i]%MOD*fac[N-cur-n+1]%MOD*facinv[K-i]%MOD*facinv[N-cur-n+1-K+i]%MOD;
        ans%=MOD;
      }
    }
    cur+=n;
  }

  sort(A.begin(),A.end(),greater<ll>());
  cur=1;
  while(cur<=N+1-K){
    ll a=A[cur];
    int n=0;
    while(a==A[cur+n]) n++;
    for(int i=1;i<=min(n,K);i++){
      if(0<=N-cur-n+1-K+i){
        ans+=a*fac[n]%MOD*facinv[i]%MOD*facinv[n-i]%MOD*fac[N-cur-n+1]%MOD*facinv[K-i]%MOD*facinv[N-cur-n+1-K+i]%MOD;
        ans%=MOD;
      }
    }
    cur+=n;
  }

  cout << (ans+MOD)%MOD << endl;

  return 0;
}

Measured memory_bytes: 3328
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
#include <vector> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int         long long 
#define ll          long long 
#define ld	    long double
#define pb          push_back
#define pp	    pop_back()
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),a.rend()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j,a,b) for(ll j=a;j<b;j++)
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end())
#define IOS	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//CONSTANTS----------------------------------
#define PI 	    3.141592653589793238462643
const ll hell=1000000007;
const ll mod=1000000007;
//function-----------------------------------
ll GCD(ll a , ll b)
{
    if(b==0)
        return a;
    else
        return GCD(b,a%b);
}
ll LCM(ll a, ll b)
{
    return a*(b/GCD(a,b));
}
bool isPrime(ll n) {
 
    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
ll fact(ll n)
{
    ll f=1;
    for(ll i=2;i<=n;i++)
	f=f*i;
    return f;
}
ll power(ll a,ll b)
{
  if(b==0)return 1;
  if(b==1)return a;
  ll t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}
//CODE------------------------------------------
ll solve()
{
 	ll a,b; cin>>a>>b;
  cout<<a*b;
  return 0;
}
//MAIN------------------------------------------
signed main(){
    IOS
    #ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3668
n = int(input())
p = list(map(int, input().split()))
#n = 5
#p = [4,2,5,1,3]

count = 0
temp_min = p[0]
for i in range(n):
  if temp_min >= p[i]:
        count+=1
        temp_min = p[i]
print(count)

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

int N, M;
string board[60];
string pattern[60];

bool match(int x, int y) {
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < M; j++) {
			if (board[x + i][y + j] != pattern[i][j])
				return false;
		}
	}
	return true;
}

int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) cin >> board[i];
	for (int i = 0; i < M; i++) cin >> pattern[i];
	bool found = false;
	for (int i = 0; i <= N - M; i++) {
		for (int j = 0; j <= N - M; j++) {
			if (match(i, j)) found = true;
		}
	}
	cout << (found ? "Yes" : "No") << endl;
	return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

int main() {
    int n;
    cin >> n;
    string s = to_string(n);
    int sn = 0;
    rep(i, s.size()) sn += s[i]-'0';
    cout << (n%sn == 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string

A ,B, K = map(int, input().split())

x = min(A, K)
A -= x
K -= x

x = min(B, K)
B -= x

print(A, B)



Measured memory_bytes: 7880
N = int(input())
list1 = list(input())
RN = list1.count('R')
ii = 0
for i in range(N):
    if list1[i] == 'W' and RN != 0:
        RN += -1
        ii += 1
    elif list1[i] == 'R' and RN != 0:
        RN += -1
    elif RN == 0:
        break
print(ii)


Measured memory_bytes: 10756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+7;
int main(){
    //ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    string s,str="keyence";
    cin>>s;
    if(s.substr(s.length()-7)==str)
        return 0*printf("YES\n");
    for(int i=0;i<s.length()-7;i++)
        if(s.substr(i,i+7)==str)
            return 0*printf("YES\n");
    for(int i=1;i<=6;i++){
        string t=s.substr(0,i)+s.substr(s.length()-7+i);
        if(t==str)
            return 0*printf("YES\n");
    }
    puts("NO");
    return 0;
}


Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m,k;
vector<int> a,b,c,d;
// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<int> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<int> sizes;

  UnionFind(int n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  int find(int x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(int x, int y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n>>m>>k;
    UnionFind uf(n);
    vector<vector<int>>v(n);
    for (int i = 0; i < m; i++)
    {
        int temp,temp1,l,r;
        cin >> temp>>temp1;
        temp--;
        temp1--;
        l=min(temp,temp1);
        r=max(temp,temp1);
        v[temp].push_back(temp1);
        v[temp1].push_back(temp);
        a.push_back(temp);
        b.push_back(temp1);
        uf.unite(temp,temp1);
    }
    map<int,int> m;
    for(int i=0;i<n;i++){
        m[uf.find(i)]++;
    }
    vector<int> ans(n);
    for(int i=0;i<n;i++){
        ans[i]=m[uf.find(i)]-v[i].size();
    }
    for (int i = 0; i < k; i++)
    {
        int temp,temp1;
        cin >> temp>>temp1;
        temp--;
        temp1--;
        if(uf.find(temp)==uf.find(temp1)){
            ans[temp]--;
            ans[temp1]--;
        }
        c.push_back(temp);
        d.push_back(temp1);
    }
    rep(i,n)
    cout << ans[i]-1 << "\n";
}


Measured memory_bytes: 12020
str = input()
dict = {}
isBeautiful = True

for i in range(len(str)):
  if str[i] in dict:
    dict[str[i]] += 1
  else:
    dict[str[i]]  = 1

    
for val in dict.values():
  if(val %2 != 0):
    isBeautiful = False

if isBeautiful == True:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int keta(int a){
  int S=0;
  while(a>0){
    S=S+a%10;
    a=a/10;
  }
  return S;
}

int main(){
  int N;
  int A;
  cin >> N;
  A=keta(N);
  if(N%A==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int dp[1010][1010];
int main(){
  int q;
  cin>>q;
  for(int cn=0;cn<q;cn++){
    string x,y;
    cin>>x>>y;
    memset(dp,0,sizeof(dp));
    for(int i=1;i<=x.size();i++){
      for(int j=1;j<=y.size();j++){
	if(x[i-1]==y[j-1])dp[i][j]=dp[i-1][j-1]+1;
	dp[i][j]=max(dp[i-1][j],dp[i][j]);
	dp[i][j]=max(dp[i][j-1],dp[i][j]);
      }
    }
    cout<<dp[x.size()][y.size()]<<endl;
  }
  return 0;
}



Measured memory_bytes: 7168
N = int(input())
button = [0]*(N+1)
for i in range(1,N+1):
    button[i] = int(input())
current_button = 1
count = 0
while count < 10**5:
    current_button = button[current_button]
    count += 1
    if current_button == 2:
        print(count)
        exit()
print(-1)

Measured memory_bytes: 6900
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include<ext/pb_ds/assoc_container.hpp>
//#nclude<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 1000005


int main ()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("in.txt","r",stdin);
//   freopen("out.txt","w",stdout);
    int t,n,m,k,a,b,c,x;
    string s;
    cin>>n>>s;
    ll sum=0;
    map<char,ll>mpl,mpr;
    for(int i=0;i<n;i++) mpr[s[i]]++;
    for(int i=0;i<n;i++){
        mpr[s[i]]--;
        if(s[i]=='R') sum+=(mpl['G']*mpr['B'])+(mpl['B']*mpr['G']);
        else if(s[i]=='G') sum+=(mpl['R']*mpr['B'])+(mpl['B']*mpr['R']);
        else sum+=(mpl['G']*mpr['R'])+(mpl['R']*mpr['G']);
        mpl[s[i]]++;
    }
    for(int j=0;j<n;j++){
        for(int i=j-1,k=j+1;i>=0&&k<n;i--,k++){
            set<char>st;
            st.insert(s[i]);
            st.insert(s[j]);
            st.insert(s[k]);
            if(st.size()==3) sum--;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3652
import math
a, b, C = map(float, input().split())
c = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(C)))
L = a + b + c
S = (a*b*math.sin(math.radians(C)))/2
h = (S*2)/a
print('{}\n{}\n{}'.format(S, L, h))


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

using ll=long long;
int main(){
    int t;
    cin>>t;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        if(d<b){
            cout<<"No"<<endl;
            continue;
        }
        if(a<c && a-b<0){
            cout<<"No"<<endl;
            continue;
        }
        if(b<=c){
            cout<<"Yes"<<endl;
            continue;
        }
        ll g=__gcd(b,d);
        ll n=(c-a)/g;
        if((c-a)%g==0){
            n++;
        }
        if(a+n*g<b){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,k = LI()
    ans = 0
    for l in range(1,n+1):
        for i in range(1000):
            if i*k > l:break
            j = l-i*k+i
            if j%2:
                j //= 2
                j += 1
                s = 1
                for a in range(i):
                    s *= j-a
                    s //= a+1
                ans += s
    print(ans)
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    A()



Measured memory_bytes: 8236
#include <bits/stdc++.h>
using namespace std;
/* run this program using the console pauser or add your own getch, system("pause") or input loop */

int main(int argc, char** argv) 
{
	string a;
	cin>>a;
	int x=a.size();
	cout<<a[0]<<x-2<<a[x-1];
	return 0;
}

Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=0,n,e,f,x=0,g,p=0,q=0,y=0,z=0;
    vector<long long>v;
    vector<long long>u;
    set<long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4;
    cin>>n>>s1;
    l(i,0,n)
    {
        if(s1[i]=='A'&&s1[i+1]=='B'&&s1[i+2]=='C')
        {
            d++;
        }

    } cout<<d<<endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

//int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1}; //RDLU
int dx[8] = {1,1,0,-1,-1,-1,0,1}, dy[8] = {0,1,1,1,0,-1,-1,-1}; //RR-RU

int h,w;
int main() {
    //ios::sync_with_stdio(false); cin.tie(0);
    cin>>h>>w;

    vector<vector<char>> m(h+2, vector<char>(w+2,'0'));
    FOR(i,1,h+1) FOR(j,1,w+1){
        //scanf("%1c", &m[i][j]);
        //cin.get(m[i][j]);
        cin>>m[i][j];
        if(m[i][j]=='.')
            m[i][j]='0';
    }

    FOR(i,1,h+1) {
        FOR(j,1,w+1){

            if(m[i][j] != '#'){
                REP(k,8){
                    int cy=i+dy[k],cx=j+dx[k];
                    if(m[cy][cx]=='#'){
                        m[i][j] += 1;
                    }
                }
            }
            cout<<m[i][j];
        }
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;
typedef pair<int,int> P;

#define inf 1e9
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define reverse(v) reverse(v.begin(),v.end())

priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }

void solve(){
    double t,x;
    cin >> t >> x;
    double ans=t/x;
    printf("%.10f\n",ans);
    
}

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




Measured memory_bytes: 3764
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            var w = Console.ReadLine().Split(' ').ToArray();

            int n = int.Parse(w[0]);
            int a = int.Parse(w[1]);
            int b = int.Parse(w[2]);

            int i = 1;
            int ans=0;
            int sum = 0;
            for (i = 1; i <= n; i++)
            {
                var nums = i.ToString().ToCharArray().Select(x => int.Parse(x.ToString()));
                var dic = new Dictionary<int, int>();
                foreach (var item in nums)
                {
                    if (dic.ContainsKey(item))
                    { dic[item]++; }
                    else { dic.Add(item, 1); }
                }

                sum = dic.Select(x => x.Key * x.Value).Sum();

                if (a <= sum && sum <= b)
                    ans = ans +i;
            }


            Console.WriteLine(ans);
        }




    }
}


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

const ll INF = 1e18;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<ll> dp(n, INF);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for (int i = 2; i < n; i++) {
		for (int j = 1; j <= 2; j++) {
			dp[i] = min(abs(h[i] - h[i - j]) + dp[i - j], dp[i]);
		}
	}
	cout << dp[n - 1];
	
	return 0;
}


Measured memory_bytes: 4480
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include<stack>
using namespace std;
typedef long long ll;
#define MAX 200000
#define INFTY 9000000000

int main(){
  ll N,K,t,d,X[MAX],Y[MAX];
  cin>>N>>K;
  vector<ll> V[MAX];
  for(ll i=0;i<N;i++){
    cin>>t>>d;
    V[t].push_back(d);
  }
  for(ll i=1;i<=N;i++){
    sort(V[i].begin(),V[i].end(),greater<ll>());
  }
  ll countX=0,countY=0;
  for(ll i=1;i<=N;i++){
    for(ll j=0;j<V[i].size();j++){
      if(j!=0) X[countX++]=V[i][j];
      else Y[countY++]=V[i][j];
    }
  }
  sort(X,X+countX,greater<ll>());
  sort(Y,Y+countY,greater<ll>());
  ll sumX[MAX],sumY[MAX];
  sumX[0]=0; sumY[0]=0;
  for(ll i=0;i<countX;i++){
    sumX[i+1]=sumX[i]+X[i];
  }
  for(ll i=0;i<countY;i++){
    sumY[i+1]=sumY[i]+Y[i];
  }
  ll ans=0;
  for(ll i=1;i<=K;i++){
    if(i>countY) break;
    else ans=max(ans,sumY[i]+sumX[K-i]+i*i);
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 13696
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

string o = "0123456789ABCD";
int main(void){
    int n, m, q; 

    while(cin >> n >> m >> q, n){
        vs _s(q), b(q), s(q);
        rep(i, q){
            cin >> _s[i] >> b[i];
            s[i] = _s[i];
        }
        rep(i, q){
            if(i == 0) continue;
            rep(j, n){
                if(_s[i][j] == '1'){
                    s[i][j] = s[i - 1][j] == '1' ? '0':'1';
                }
                else s[i][j] = s[i - 1][j];
            }
        }

        vector< vector<bool> > tbl = vector< vector<bool> >(m, vector<bool>(n, true));

        rep(i, q){
            rep(j, m){
                rep(k, n){
                    if((s[i][k] == '1' && b[i][j] == '0') || (s[i][k] == '0' && b[i][j] == '1'))
                        tbl[j][k] = false;
                }
            }
        }

        rep(i, m){
            char res;
            int cnt = 0;
            rep(j, n) if(tbl[i][j]) res = j < 10 ? '0' + j:'A' + j - 10, cnt++;

            if(cnt == 1) cout << res;
            else cout << '?';
        }
        cout << endl;
    }


	return 0;
}

Measured memory_bytes: 2536
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	vector<int> A(N);
	for (int i = 0; i < N; i++) cin >> A[i];

	vector<int> ans, used(N);
	int loop = 0;
	while(loop < N){

		int ok = -1, cnt = 1;
		for (int j = 0; j < N; j++) {
			if (!used[j]) {
				if (A[j] == cnt) ok = j;
				cnt++;
			}
		}
		if (ok == -1) break;
		ans.emplace_back(A[ok]);
		used[ok] = 1;
		loop++;
	}

	if (ans.size() != N) {
		cout << -1 << "\n";
		return 0;
	}
	reverse(ans.begin(), ans.end());
	for (const auto &e : ans) cout << e << "\n";

	return 0;
}

Measured memory_bytes: 256
class Graph():
    def __init__(self):
        """ ノードのつながりを辞書型で表現する """
        self.adjacency_dict = {}

    def add_vertex(self, v):
        """ ノードを追加する """
        self.adjacency_dict[v] = []
    def add_edge(self, v1, v2):
        """ ノード同士をつなぐ。"""
        # 無向グラフの場合は双方向。もし有向グラフなら片側のみ。
        self.adjacency_dict[v1].append(v2)
        self.adjacency_dict[v2].append(v1)
    def remove_edge(self, v1, v2):
        """ ノード同士のつながりを削除する。"""
        self.adjacency_dict[v1].remove(v2)
        self.adjacency_dict[v2].remove(v1)
    def remove_vertex(self,v):
        """ ノードを削除する。"""
        while self.adjacency_dict[v] != []:
            adjacent_vertex = self.adjacency_dict[v][-1]
            self.remove_edge(v, adjacent_vertex)
        del self.adjacency_dict[v]

    def print_graph(self):
        print(self.adjacency_dict)

n, m = map(int, input().split())
h = list(map(int, input().split()))
graph = Graph()
for i in range(n):
    graph.add_vertex(i+1)
for i in range(m):
    a, b = map(int, input().split())
    graph.add_edge(a, b)

ans = 0
for i in range(n):
    ans += 1
    for j in graph.adjacency_dict[i+1]:
        if h[i] <= h[j-1]:
            ans -= 1
            break
print(ans)


Measured memory_bytes: 37892
import java.util.Scanner;
import java.util.regex.Pattern;

public class Main {
	public static void main(String[] args) {
		Scanner as = new Scanner(System.in);
		while(true) {
			String m = as.next();
			if(m.equals(".")) {
				break;
			}
			int s = 0;
			boolean ss = false;
			String m2 = as.next();
			Pattern p = Pattern.compile("^\"");
			if(p.matcher(m).find()) {
				m = "a" + m;
				m2 = "a" + m2;
			}
			String[] mm = m.replace("\"", "-a").split("-");
			String[] mm2 = m2.replace("\"", "-a").split("-");
			if(mm.length == mm2.length) {
				for(int i = 0; i < mm.length; i++) {
					if(!mm[i].equals(mm2[i])) {
						if(i % 2 == 0) {
							s += 2;
							break;
						}else {
							if(ss) {
								s++;
								break;
							}else {
								s++;
								ss = true;
							}
						}
					}
				}
				if(s == 0) {
					System.out.println("IDENTICAL");
				}else if(s == 1) {
					System.out.println("CLOSE");
				}else {
					System.out.println("DIFFERENT");
				}
			}else {
				System.out.println("DIFFERENT");
			}
		}
	}
}


Measured memory_bytes: 34172
#include <bits/stdc++.h>
const long long INF = 1LL << 60;
const long long MOD = 1000000007;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep1(i, n) for (ll i = 1; i <= (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define perm(c) sort(ALL(c));for(bool c##p=1;c##p;c##p=next_permutation(ALL(c)))
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define MAX max<ll>
#define MIN min<ll>
#define pb push_back
#define to_s to_string
#define len(v) (ll)v.size()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define print(x) cout << (x) << '\n'
#define drop(x) cout << (x) << '\n', exit(0)
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vector<ll>> vec2;
typedef vector<vector<vector<ll>>> vec3;
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; }
ll devc(ll x, ll y) { return (x + y - 1) / y; }

ll LIS(vector<ll>& sequence){
    multiset<ll> s;
    s.insert(sequence[0]);
    
    for(ll i = 1; i < sequence.size(); i++){
        ll now = sequence[i];
        //広義単調増加列の場合、以下を now >= *--s.end()にする
        if(now >= *--s.end()) s.insert(now);
        else{
        //広義単調増加列の場合、以下をupper_boundにする
            auto itr = s.upper_bound(now);
            s.erase(itr);
            s.insert(now);
        }
    }
    return s.size();
}


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

    ll N;
    cin >> N;
    vec A(N);
    rep(i, N) cin >> A[i];
    reverse(ALL(A));

    ll ans = LIS(A);
    print(ans);

    return 0;
}

Measured memory_bytes: 5760
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = Long.parseLong(sc.next());
        long m = Long.parseLong(sc.next());
        long ans = 0;
        if (n * m == 1) {
            ans = 1;
        } else if (n == 1) {
            ans = m - 2;
        } else if (m == 1) {
            ans = n - 2;
        } else {
            ans = (n - 2) * (m - 2);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; cin >> n; std::vector<i64> x(n), y(n);
	
	int tmp = -1;
	for(int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
		
		if(~tmp and tmp != std::abs(x[i] + y[i]) % 2) {
			cout << -1 << endl;
			return 0;
		} else {
			tmp = std::abs(x[i] + y[i]) % 2;
		}
	}
	assert(tmp != -1);
	
	std::vector<i64> d;
	for(i64 i = 1; i < 1e12; i *= 2) d.push_back(i);
	d.pop_back();
	
	cout << d.size() + !tmp << endl;
	if(!tmp) cout << 1 << " ";
	for(auto v : d) cout << v << " "; cout << endl;
	
	reverse(begin(d), end(d));
	for(int i = 0; i < n; i++) {
		if(!tmp) cout << "R", x[i]--;
		
		std::string ans = "";
		for(auto j : d) {
			if(x[i] < y[i]) {
				if(x[i] + y[i] > 0) {
					ans += "U";
					y[i] -= j;
				} else {
					ans += "L";
					x[i] += j;
				}
			} else {
				if(x[i] + y[i] > 0) {
					ans += "R";
					x[i] -= j;
				} else {
					ans += "D";
					y[i] += j;
				}
			}
		}
		reverse(begin(ans), end(ans));
		cout << ans << endl;
		
		assert(!x[i] and !y[i]);
	}
	
	return 0;
}


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

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int64_t n = input<int64_t>();
    int64_t ans = 0;

    auto f = [&](int64_t div) {
        if (div == 1)
            return;

        int64_t m = div - 1;
        if (n / div >= m)
            return;

        ans += m;
    };
    
    for (int64_t i = 1; i * i <= n; ++i)
        if (n % i == 0) {
            f(i);

            if (i * i != n)
                f(n / i);
        }


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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);

using namespace std;
const int N = 1E6+7;
const long long INF = 1E18;

long long a[N], f[N];
int n,k;

int main()
{
    fastIO
    cin>>n>>k;
    
    for (int i = 1;i <= n;++i) 
    {
        cin>>a[i];
        f[i] = INF;
    }

    f[1] = 0;
    for (int i = 2;i <= n;++i)
    {
        for (int j = 1;j <= k;++j) 
        if (i-j >= 1)f[i] = min(f[i],f[i-j]+abs(a[i]-a[i-j]));
        else break;
    }
    
    cout<<f[n];
}

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

extern inline char gc() {
    static char RR[23456], *S = RR + 23333, *T = RR + 23333;
    if(S == T) fread(RR, 1, 23333, stdin), S = RR;
    return *S ++;
}
inline int read() {
    int p = 0, w = 1; char c = gc();
    while(c > '9' || c < '0') { if(c == '-') w = -1; c = gc(); }
    while(c >= '0' && c <= '9') p = p * 10 + c - '0', c = gc();
    return p * w;
}

#define ri register int
#define sid 305

int n;
int v[sid][sid], mp[sid][sid];

int main() {
    n = read();
    for(ri i = 1; i <= n; i ++)
    for(ri j = 1; j <= n; j ++)
    v[i][j] = mp[i][j] = read();

    bool flag = 0;

    for(ri i = 1; i <= n; i ++)
    for(ri j = 1; j <= n; j ++)
    for(ri k = 1; k <= n; k ++)
    if(i != k && j != k && i != j) {
        if(mp[i][j] > mp[i][k] + mp[k][j]) flag = 1;
        if(mp[i][j] == mp[i][k] + mp[k][j])
        v[i][j] = v[j][i] = 0;
    }

    long long ans = 0;
    for(ri i = 1; i <= n; i ++)
    for(ri j = 1; j <= n; j ++)
    ans += v[i][j];
    
    if(flag) printf("-1\n");
    else printf("%lld\n", ans / 2);
    return 0;
}

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

int main() {
	int N, K, Q;
	cin >> N >> K >> Q;
	vector<int> v(N, 0);
	vector<int> correct(Q);
	for (int i = 0; i < Q; i++) {
		int t;
		cin >> t;
		v[t-1]++;
	}
	for (int i = 0; i < N; i++) {
		v[i] = K - (Q-v[i]);
	}
	for (int i = 0; i < N; i++) {
		if (v[i] <= 0) {
			cout << "No" << endl;
		} else {
			cout << "Yes" << endl;
		}
	}
}


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

int dp[100005];

int main() {
    int n,k; cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[i]=0;
    }
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++){
        int x=INT_MAX;
        for(int j=1;j<=k && i-j>=0;j++){
            x = min(dp[i-j]+abs(a[i]-a[i-j]), x);
            //cout<<i-j<<" ";
        }
        //cout<<endl;
        dp[i]=x;
    }
    // for(int i=0;i<n;i++) cout<<dp[i]<<" ";
    // cout<<endl;
    cout<<dp[n-1];
}

Measured memory_bytes: 4344
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<string>

using namespace std;

#define vi vector<int>
#define ll long long int

int main(){
	ll n,a,b;
	cin>>n>>a>>b;
	if((b-a-1)%2 == 0){
		cout<<"Borys"<<endl;
	}else{
		cout<<"Alice"<<endl;
	}
	return 0;
}


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

using namespace std;
vector<int> road[100000];

int main() {
	int N, M, tmp,ans;
	ans = 0;
	vector<int> H;
	
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> tmp;
		H.push_back(tmp);
	}
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;

		road[a-1].push_back(b-1);
		road[b-1].push_back(a-1);
	}
	for (int i = 0; i < N; i++) {
		if (road[i].size() == 0)ans++;
		else {
			int flag = 1;
			for (int j = 0; j < road[i].size(); j++) {
				if (H[i] <= H[road[i][j]])flag = 0;
			}
			if (flag == 1)ans++;
		}
	}
	cout << ans << endl;

}

Measured memory_bytes: 8780
#include <stdio.h>

#define SMAX 10000
#define TMAX 500
#define NOT_FAUND -1

int linearSearch(int*,int,int);

int main(){

  int i,n,q,S[SMAX],T[TMAX],count=0;

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

  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    if(linearSearch(S,n,T[i])!=NOT_FAUND){
      count++;
    }
  }

  printf("%d\n",count);
  return 0;
}

int linearSearch(int* A,int n,int key){

  int i=0;
  A[n]=key;
  while(A[i]!=key){
    i++;
  }
  if(i==n) return NOT_FAUND;
  return i;
  
}

Measured memory_bytes: 640
#include<stdio.h>

void merge(int,int,int);
void mergeSort(int,int);

int count=0,S[500000];
int main(){
  int i,n,left=0,mid,right;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }
  right=n;
  mergeSort(left,right);
  for(i=0;i<n;i++){
    printf("%d",S[i]);
    if(i<n-1)printf(" ");
    if(i==n-1)printf("\n");
  }
  printf("%d\n",count);
}



void merge(int left,int mid,int right){
    int i,j,k,n1,n2,L[mid-left],R[right-mid];
    n1=mid-left;
    n2=right-mid;
    for(i=0;i<n1;i++){
      L[i]=S[left+i];
    }
    L[n1]=1000000001;
    for(j=0;j<n2;j++){
      R[j]=S[mid+j];
    }
    R[n2]=1000000001;
    i=0;
    j=0;
    for(k=left;k<right;k++){
      if(L[i]<=R[j]){
	S[k]=L[i];
	i=i+1;
	count++;
      } else {
	S[k]=R[j];
	j=j+1;
	count++;
      }
    }
  }

void mergeSort(int left,int right){
    int mid;
    if((left+1)<right){
      mid=(left+right)/2;
      mergeSort(left,mid);
      mergeSort(mid,right);
      merge(left,mid,right);
    }
  }
    
	
    
    
      
  
  
  



Measured memory_bytes: 5636
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits.h>
#include <queue>

using namespace std;

//typedef long long ll;
//typedef unsigned long long ull;

int N, A, B,C;



int main() {
	scanf("%d", &N);
	if (N == 2) {
		scanf("%d %d", &A, &B);
		C = A + B;
		printf("%d", C);
		
	}
	if (N == 1) printf("Hello World");
	
	
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top, S[1000];

void push(int x){
  S[++top] = x;
}

int pop(){
  top--;
  return S[top + 1];
}

int main(){
  int a, b;
  top = 0;
  char s[100];
  while(scanf("%s",s) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(s[0] == '-'){
      b = pop();
      a = pop();
      push(a - b);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else push(atoi(s));
  }

  printf("%d\n",pop());

  return 0;
}

Measured memory_bytes: 548
#include <cstdio>
#include <set>
#include <algorithm>

using namespace std;

int main() {
    int n, a, cnt = 0;
    scanf("%d", &n);
    set<int> d;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a);
        if (a >= 3200) ++cnt;
        else d.insert(a / 400);
    }
    printf("%d %ld\n", max(1, int(d.size())), d.size() + cnt);
    return 0;
}


Measured memory_bytes: 256
x, k, d = map(int,input().split())
x = abs(x)

m = x // d
p = k - m if m <= k else 0

if p == 0:
  print(x - (k*d))
else:
  x -= m * d
  if p & 1:
    print(abs(x - d))
  else:
    print(x)

Measured memory_bytes: 9188
#include <algorithm>
#include <array>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define vint vector<int>

int main() {
    int N;
    cin >> N;
    map<int, int> mp;
    rep(i, N) {
        int a;
        cin >> a;
        if (mp[a] == 0)
            mp[a]++;
        else
            mp[a]--;
    }
    int ans = 0;
    for (auto v : mp) {
        // cout << v.second << endl;
        ans += v.second;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4864
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  string s;
  cin>>s;
  ll r=0,b=0;
  for(ll i=0;s[i]!='\0';++i)
    (s[i]=='0')?(r++):(b++);
  (r>b)?(cout<<b*2<<endl):(cout<<r*2<<endl);
  return 0;
}

Measured memory_bytes: 512