akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <math.h>
typedef long long ll;

int main(){
    char s[100000];
    scanf("%s",s);
    static int x[100000][3];
    int a=1,b=0,i;
    int y[100000]={0};
    x[0][0] = 0;
    for(i=1;s[i]!='\0';i++){
        if(a==0) {
            if(s[i]=='R'){
                a=1;
                x[b][1] = i-1;
                b++;
                x[b][0] = i;
            }
        }else{
            if(s[i]=='L'){
                a=0;
                x[b][2] = i;
            }
        }
    }
    x[b][1]=i-1;
    int l,r,tmp;
    for(int j=0;j<=b;j++){
        l=x[j][2]-1-x[j][0];
        r=x[j][1]-x[j][2];
        int max = (r>l)?r:l;
        y[x[j][2]-1]=1 + l/2 + r/2 + r%2;
        y[x[j][2]] = 1 + l/2 + r/2 + l%2;
    }
    for(int j=0;j<i;j++){
        printf("%d ",y[j]);
    }
    
}


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

using namespace std;
using ll = long long;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int N,K;cin >> N >> K;
    string s;cin >> s;
    int A = 'A'-'a';
    s.at(K-1)-=A;
    cout<<s<<endl;
}


Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=sorted(list(map(int,input().split())))
a_max=a[-1]
count=0
b=Counter(a)
count_list=[0]*(a_max)
for i in a:
  if b[i]==1:
    if count_list[i-1]==0:
      count+=1
      j=1
      while i*j<=a_max:
        count_list[i*j-1]+=1
        j+=1
  else:
    j=2
    while i*j<=a_max:
      count_list[i*j-1]+=1
      j+=1
print(count)

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

long long n, dp[305][100009], w[305], v[305], k;
long long solve(long long n, long long k)
{
    if(k == 0 || n == 0)
        return 0;
  	if(dp[n][k] != -1)
      return dp[n][k];
    dp[n][k] = solve(n - 1, k);
    if(k - w[n] >= 0)
        dp[n][k] = max(dp[n][k], v[n] + solve(n - 1, k - w[n]));
    //cout<<"n = "<<n<<" k = "<<k<<" dp = "<<dp[n][k]<<"\n";
    return dp[n][k];
}
main()
{
    cin>> n >> k;
    memset(dp, - 1, sizeof(dp));
    for(long long i = 1; i <= n; i++)
    {
        cin>>w[i]>>v[i];
    }
    cout<<solve(n, k);
}



Measured memory_bytes: 238592
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[1]
i=1
d={}
d[1]=1

while(True):
    j=a[i-1]
    try:
        d[j]+=1
        
    except:
        d[j]=1
        b.append(j)
    if(d[j]>1):
        y=b.index(j)+1
        
        break
    i=j
    
x=b.index(b[y-1])
z=len(b)-x
if(k<=x):
    print(b[k])
else:
    k-=x
    r=k%z
    print(b[x+r])


Measured memory_bytes: 35416
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<int, int>;
const int INF (1<<30);
const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

mint choose(int n, int a) {
  mint x = 1, y = 1;
  rep(i, a) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};

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

  mint ans = 0;

  mint tmp = M;
  tmp *= (mint(M-1).pow(N-1));

  ans += tmp;

  combination c(N-1);

  for (int i = 1; i <= K; i++) {
    mint tmp = M;
    tmp *= (mint(M-1).pow(N-1-i));
    tmp *= c(N-1, i);
    //tmp *= choose(N-1, i);
    ans += tmp;
  }

  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 6372
import numpy as np

def input_numbers():
    temp = list(map(int, input().split()))
    return temp

def GCD(a, b):
    if(a < b):
        temp = a
        a = b
        b = temp
    a = a % b
    if(a == 0):
        return b
    else:
        return GCD(a, b)

numbers = input_numbers()

numbers.sort()

count = 0

count += numbers[2] - numbers[1]
numbers[0] += numbers[2] - numbers[1]
numbers[1] = numbers[2]

diff = numbers[2] - numbers[0]

if(diff % 2 == 0):
    count += (diff // 2)

else:
    numbers[1] += 1
    numbers[2] += 1
    count += 1

    diff = numbers[2] - numbers[0]
    count += (diff // 2)

print(count)

Measured memory_bytes: 12504
#include<bits/stdc++.h>
#define deb cout<<"hi"<<endl;	
using namespace std;
const int N=1e5+1000;
const int M=1e9+7;
typedef int64_t ll;
typedef long double ld;
int cnt[N*2];
int main()
{
	int n,k;
	cin>>n>>k;
	int a[N*2];
	for(int i=1;i<=n;i++)
		cin>>a[i];
	for(int i=1;i<=n;i++)
		cnt[a[i]]++;
	vector<int> s(0);
	for(int i=1;i<=n;i++)
		if(cnt[i])
			s.push_back(cnt[i]);
	sort(s.begin(),s.end());
	int cnt1=0;
	for(int i=0;i<(int)s.size()-k;i++)
		cnt1+=s[i];
	cout<<cnt1<<'\n';
}


Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=998244353;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}


ll gcd(ll a, ll b) {
  if(b==0) return a;
  else return gcd(b, a%b);
}

int main(void) {
  ll N;
  cin >> N;
  ll a[MAX];
  ll i;
  ll l[MAX]={}, r[MAX]={};
  
  for(i=1; i<=N; i++) cin >> a[i];
  
  for(i=1; i<=N; i++) l[i]=gcd(l[i-1], a[i]);
  for(i=N; i>=1; i--) r[i]=gcd(r[i+1], a[i]);

  ll ans=1;
  for(i=0; i<N; i++) chmax(ans, gcd(l[i], r[i+2]));
  pt(ans);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {
		
	// }
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	vector<int> dp(n, 1e9 + 5);
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j <= i + k; j++) {
			if (j < n) {
				dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]));
			}
		}
	}
	cout << dp[n - 1] << endl;

	return 0;
}

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

int main()
{
  string s, t; cin >> s >> t;
  int a, b; cin >> a >> b;
  string u; cin >> u;

  if (s == u) cout << a - 1 << " " << b << endl;
  else cout << a << " " << b - 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N, M;
vector<int> A;
const int C[] = {0,2,5,5,4,5,6,3,7,6};

int dp[10001];
void solve(){
	rep(i, 10000){
		dp[i] = -INF;
	}
	dp[0] = 0;
	reps(i, N){
		for(auto a : A){
			if(i - C[a] < 0 or dp[i - C[a]] == -INF) continue;
			chmax(dp[i], dp[i - C[a]] + 1);
		}
	}
	sort(A.begin(), A.end(), greater<int>());
	int i = N;
	while(i != 0){
		if(dp[i] != -INF){
			for(auto a : A){
				if(i - C[a] >= 0 and dp[i] == dp[i - C[a]] + 1){
					cout << a;
					i -= C[a];
					break;
				}
			}
		}
	}
	cout << endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M;
	rep(i, M) {
		int a;
		cin >> a;
		A.pub(a);
	}
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <functional>
#include <string>
#include <cmath>  //sqrt 
#include <iomanip> //setprecision
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define MAX 1000001

void _main(){
    ll n; cin>>n;
    vector<ll> p(MAX,0); 
    set<ll> s;
    rep(i,n) {ll a;cin >> a; p[a]++;s.insert(a);}
    ll out = 0;
    for(auto i:s){
        for(ll j=2;j<MAX;j++){
            if(i*j>=MAX) break;
            p[i*j]++;
        }
    }
    for(auto i:s){
        if(p[i]==1) out++;
    }
    cout << out << endl;
    return;
}
int main() {
    cout << fixed << setprecision(10);
    _main();
    return 0;
}
    

Measured memory_bytes: 19972
def gcd(a: int, b: int)->int:
    if a < b:
        a, b = b, a

    if b == 0:
        return a

    return gcd(b, a % b)


def skip(N: int, X: int, x: list)->int:
    sorted_x = sorted([X] + x)
    dists = [sorted_x[i+1] - sorted_x[i] for i in range(len(x))]
    before = 0
    for d in dists:
        before = gcd(before, d)
    return before


if __name__ == "__main__":
    N, X = map(int, input().split())
    x = [int(s) for s in input().split()]
    ans = skip(N, X, x)
    print(ans)


Measured memory_bytes: 14480
#include <iostream>
#include <iomanip>
#include <cassert>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <sstream>
#include <istream>
#include <cmath>
#include <cstdio>

using namespace std;

#define vci vector<int>
#define vcs vector<string>
#define pb push_back
#define sz size()
#define mapii map<int, int>
#define mapci map<char, int>
#define mapsi map<string, int>
#define all(x) x.begin(), x.end()
#define minit(a, i) memset(a, i, sizeof(a));

#define for_(i, a, b) for (int i=(int)a; i<(int)b; i++)
#define for_d(i, a, b) for (int i=(int)a-1; i>=b; i--)
#define for_r(i, a, b, c) for (int i=(int)a; i<(int)b; i += c)
#define for_dr(i, a, b, c) for (int i=(int)a-1; i>=b; i -= c)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

typedef long long ll;
typedef double D;

const int iINF = 2147483647;
const ll lINF = 9223372036854775807;

template <class T> inline void dbg(T t) { cout << t << endl; }



bool solve(int c1, int c2, int c3) {
	vector<bool> use(11, 0);
	use[c1] = use[c2] = use[c3] = 1;
	int cnt = 0;
	for_(i, 1, 11) {
		if (use[i]) continue;
		if (c1 + c2 + i <= 20) cnt++;
	}
	if (cnt >= 4) return true;
	return false;
}

int main() {
	int c1, c2, c3;
	
	while (cin>>c1>>c2>>c3) {
		if (solve(c1, c2, c3)) cout << "YES" << endl;
		else cout << "NO" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
  int N, D, res = 0;
  long long x, y;
  cin >> N >> D;
  for (int i = 0; i < N; ++i) {
    cin >> x >> y;
    res += (sqrt(x*x + y*y) <= D);
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;
int a[100005];
int main()
{
    int n,x=1,ans=0;///x表示一个数出现的次数，赋值1
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    sort(a,a+n);///先排序
    for(int i=1;i<n;i++)
    {
        if(a[i]==a[i-1])///出现相同的数，x+1然后mod2
          x=(x+1)%2;
        else
        {
            ans+=x;///单独的一个数，ans+1，x重新赋值为1，进行循环
            x=1;
        }
    }
    if(x%2)///再次判断 ，若不为0，则ans+1
      ans++;
    printf("%d\n",ans);
    return 0;
}

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

int main(){
  char s[4]; cin>>s;
  if(s[1] == s[2] && (s[0] == s[1] || s[3] == s[1])){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}                

Measured memory_bytes: 256
// ConsoleApplication2.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;

int main()
{
	int N;
	cin >> N;
	int H[20];
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}
	int max = H[0];
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		if (max <= H[i]) {
			max = H[i];
			cnt++;
		}
	}
    cout << cnt << endl; 
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n=0, min, max,A=0,B=0;
	long int sum = 0;
	cin >> n;
	int a[10000] = { 0 };
	for (int i = 0; i < n; i++){
		cin >> a[i];
		sum = sum + a[i];
	}
	min = a[0];
	max = a[0];
	for (int i = 0; i < n; i++){
		if (min <= a[i]){
			B = min;
			min = a[i];
			a[i] = B;
		}
	}
	for (int i = 0; i < n; i++){
		if (max >= a[i]){
			A = max;
			max = a[i];
			a[i] = A;
		}
	}
	cout << max << " " << min << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 3112
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a, b, c;
        int count = 0;
        a = scan.nextInt();
        b = scan.nextInt();
        c = scan.nextInt();
        for (int i = a; i <= b; i++) {
            if (c % i == 0)
                count++;
        }
        System.out.println(count);
    }
}


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

int n;
vector<int> pos[100010];
int cnt[100010],l[100010],p[100010];

inline void dfs(int v)
{
	cnt[v]=1;
	for(int i=0;i<pos[v].size();i++)
	{
		int cur=pos[v][i];
		if(p[v]==cur) continue;
		l[cur]=l[v]+1;p[cur]=v;
		dfs(cur);
		cnt[v]+=cnt[cur];
	}
}

int main()
{
	cin>>n;
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		pos[a].push_back(b);
		pos[b].push_back(a);
	}
	
	dfs(1);
	int sz=(l[n]-1)/2,v=n;
	while(sz--) v=p[v];
	if(cnt[v]>=n-cnt[v]) cout<<"Snuke"; else cout<<"Fennec";
	
	return 0;
}

Measured memory_bytes: 10880
import scala.io.StdIn.readLine
import scala.collection.mutable.ArrayBuffer

object Main extends App {
  var n = 0
  while( {n=readLine.trim.toInt;n} != 0 ) {
    val b = new ArrayBuffer[String]
    var convert = for(i<-1 to n) yield readLine.trim.split(" ").toList
    val m = readLine.trim.toInt
    for(i<-1 to m) {
      val s = readLine.trim
      b += convert.find{ _(0) == s }.map{ _(1) }.getOrElse(s)
    }
    println(b.mkString)
  }
}

Measured memory_bytes: 74620
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>
#include <ios>
#include <cctype>
#include <cstdio>
#include <functional>
#include <cassert>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define FORR(i,a,b) for(int i = (a) - 1;i >=(b);--i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond,yes,no){cout <<((cond)?(yes):(no))<<endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(),(list).rend())
#define ASSERT(cond,mes) assert(cond && mes)

using namespace std;
using ll = long long;

constexpr int mod = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

template <typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >> p.second;
    return is;
}

template <typename T1, typename T2>
ostream& operator<<(ostream& os, pair<T1, T2>& p) {
    os << p.first << p.second;
    return os;
}

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())is >> v[i];
    return is;
}

template <typename T>
ostream& operator<<(ostream& os, vector<T>& v) {
    REP(i, (int)v.size())os << v[i] << endl;
    return os;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a)n = a;
    if (n > b)n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u * v / gcd(u, v);
}

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

    int N;
    cin >> N;
    map<int, int> m;
    REP(i, N) {
        int a;
        cin >> a;
        m[a]++;
    }

    int ans = 0;
    for (auto&& s : m) {
        if (s.second % 2 == 1)ans++;
}
    cout << ans << endl;
    return 0;
}

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

struct Point{ double x, y; };

Point set_p(double a, double b)
{
    Point p;
    p.x = a; p.y = b;
    return p;
}

struct Vector{ double vx, vy; };

Vector set_v(const Point &p1, const Point &p2)
{
    Vector v;
    v.vx = p2.x - p1.x;
    v.vy = p2.y - p1.y;
    return v;
}

double dot(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vx) + (v1.vy * v2.vy);
}

double cross(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vy) - (v1.vy * v2.vx);
}

double cross0(const Point &P0, const Point &P1)
{
	return (P0.x * P1.y) - (P1.x * P0.y);
}

double onenorm(const Vector &v)
{
    return abs(v.vx) + abs(v.vy);
}

double norm(const Vector &v)
{
	return sqrt(v.vx * v.vx + v.vy * v.vy);
}

int ccw(const Point &P0, const Point &P1, const Point &P2)
{
    Vector V1 = set_v(P0, P1);
    Vector V2 = set_v(P0, P2);
    double c = cross(V1, V2);
    if(c > 0){ return 1; }else if(c < 0){ return -1; }
    if(dot(V1, V2) < 0){ return -2; }
    if(onenorm(V1) < onenorm(V2)){ return 2; }
    return 0;
}

int intersect(const Point &P0, const Point &P1, const Point &P2, const Point &P3)
{
    if(ccw(P0, P1, P2) * ccw(P0, P1, P3) <= 0 && ccw(P2, P3, P0) * ccw(P2, P3, P1) <= 0){
        return 1;
    }else{
        return 0;
    }
}

double dist_seg(const Point &P0, const Point &P1, const Point &P2) // Segment P0P1 & Point P2.
{
    Vector V01 = set_v(P0, P1), V12 = set_v(P1, P2), V02 = set_v(P0, P2);
    if(dot(V01, V12) > 0) return norm(V12);
    if(dot(V01, V02) < 0) return norm(V02);
    double c_sum;
    c_sum = cross0(P0, P1) + cross0(P1, P2) + cross0(P2, P0);
    if(c_sum < 0) c_sum *= -1.0;
    return c_sum / norm(V01);
}

int main()
{
    int i, n;
    double *X, *Y;
    scanf("%d", &n);
    X = new double [n + 2];
    Y = new double [n + 2];
    for(i = 0; i < n; i++){
        scanf("%lf %lf", &X[i], &Y[i]);
    }
    X[n] = X[0], Y[n] = Y[0], X[n + 1] = X[1], Y[n + 1] = Y[1];
    Point *P;
    P = new Point [n + 2];
    for(i = 0; i < n; i++){
        P[i] = set_p(X[i], Y[i]);
    }
    int c;
    for(i = 0; i < n; i++){
        c = ccw(P[i], P[i + 1], P[i + 2]);
        if(c == -1) break;
    }
    if(i < n){ printf("0\n"); }else{ printf("1\n"); }
    delete [] X, delete [] Y, delete [] P;

    return 0;
}

Measured memory_bytes: 1200
import java.util.*;

public class Main {

	int N, Q;
	int[] as;

	void run(){
		Scanner in = new Scanner(System.in);
		for(;;){
			int S, W;
			N = in.nextInt();
			S = in.nextInt();
			W = in.nextInt();
			Q = in.nextInt();
			if(N==0) return ;
			as = new int[N];
			int g = S;
			for(int i=0; i<N; i++){
				as[i] = (g/7)%10;
				if(g%2 == 0){
					g = g/2;
				}
				else{
					g = (g/2) ^ W;
				}
			}
			System.out.println(solve());
		}
	}

	int subsolve(){
		int ans = 0;
		boolean[] oks = new boolean[10];
		if(Q==2){
			oks[0] = oks[2] = oks[4] = oks[6] = oks[8] = true;
		}
		else{
			oks[0] = oks[5] = true;
		}
		int accum = 0;
		for(int i=0; i<N; i++){
			if(as[i] > 0){
				accum++;
			}
			if(oks[as[i]]){
				ans += accum;
			}
		}
		return ans;
	}

	int solve(){
		if(Q==2 || Q==5){
			return subsolve();
		}
		int ans = 0;
		int[] accums = new int[N];
		int ten = 10 % Q;
		accums[N-1] = as[N-1]%Q;
		for(int i=N-2; i>=0; i--){
			accums[i] = (ten * as[i] + accums[i+1])%Q;
			ten = (ten * 10)%Q;
		}
		HashMap<Integer, Integer> dict = new HashMap<Integer, Integer>();
		dict.put(0, 1);
		for(int i=N-1; i>=0; i--){
			int sub = accums[i];
			sub = (sub + Q)%Q;
			if(as[i] > 0 && dict.containsKey(sub)){
				ans += dict.get(sub);
			}
			int cur = dict.containsKey(sub)?dict.get(sub):0;
			dict.put(sub, cur+1);
		}
		return ans;
	}

	public static void main(String args[]){
		new Main().run();
	}
}

Measured memory_bytes: 20000
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const ll INF = 1e9;
const long long INFL = 1LL<<60;

int main()
{
  int n;
  cin >> n;
  vector<ll> a(n+1);  // 切れ目が左から何mmの位置にあるか
  a[0] = 0;
  rep(i, n) {
    ll tmp;
    cin >> tmp;
    a[i+1] = a[i] + tmp;
  }

  ll len = a[n];
  auto lb = lower_bound(ALL(a), len / 2);
  auto ub = upper_bound(ALL(a), len / 2);
  if (*lb == *ub) lb--;

  float mid = len * 0.5;
  ll ans;
  if (mid - *lb <= *ub - mid) {
    ans = a[n] - *lb - *lb;
  } else {
    ans = *ub - (a[n] - *ub);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

struct input {
    int a;
    int b;
    int c;
    int d;

    bool operator<(const input& other) const {
        if (d < other.d) return true;
        else return false;
    }
};
int N, M, Q;

int dfs(int idx, vector<int> A, vector<input>& S) {
    int ans = 0;
    if(idx == N+1) {
        REP(i, Q) {
            if(A[S[i].b] - A[S[i].a] == S[i].c) ans += S[i].d;
        }
        return ans;
    }
    else {
        for(int a = max(1, A[idx-1]); a <= M; a++) {
            A[idx] = a;
            ans = max(ans, dfs(idx+1, A, S));
        }
    }
    return ans;
}

int main() {
    
    cin >> N >> M >> Q;
    vector<input> S(Q);
    REP(i, Q) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        S[i].a = a;
        S[i].b = b;
        S[i].c = c;
        S[i].d = d;
    }
    vector<int> A(N+1);
    int ans = dfs(1, A, S);

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
int main(){
 
 int W, H, x, y, r;
 
 scanf("%d%d%d%d%d", &W, &H, &x, &y, &r);

 if ( r <= x && x <= W - r && r <= y && y <= H - r){

 printf("Yes\n");
  
} else {

  printf("No\n");


}
 
  
    return 0;
}



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

int main(){
  int n,m;
  cin >> n >> m;
  // vector<int> p(m);
  // vector<string> s(m);
  vector<pair<string,int>> sp(m);
  // vector<pair<int,string>> ps(m);
  map<int,int> acp,wap;
  int ac = 0;
  for(int i = 0; i < m; i++){
    int tmpp;
    string tmps;
    cin >> tmpp >> tmps;
    if(tmps=="AC"&&!acp.count(tmpp)) acp[tmpp] = i;//正解はi番目
    else if(tmps=="WA")wap[tmpp] = i;

    sp.at(i) = make_pair(tmps,tmpp);
  //   ps.at(i) = make_pair(tmpp,tmps);
  ac = acp.size();
  }
  int wa = 0;
  for(auto p : acp){
    int k = p.first;//問題番号
    int v = p.second;//初めて正解する番号
    if(!wap.count(k))continue;
    //cout << k << "番目の問題は" << v+1 << "回目の提出で正解します。" << endl;
    for(int i = 0; i < v; i++){
      if(sp.at(i).second == k&&sp.at(i).first == "WA"){
        wa++;
      }
    }
  }

  cout << ac << ' ' <<wa << endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i=0;i<n;i++)

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

	ll n, k;
	cin >> n >> k;
    vl a(n);
    rep(i, n) cin >> a[i];

    vi numofone(50);

    rep(i, 50) numofone[i] = 0;

    rep(i, n){
        ll temp = a[i];
        int count = 0;
        while(temp != 0){
            if(temp % 2 == 1){
                numofone[count]++;
            }
            temp /= 2;
            count++;
        }
    }

    //rep(i, n) cout << numofone[i] << " ";
    //cout << endl;

    ll ans = 0;
    ll x = 0;

    for(int i = 49; i>=0; i--){
        if(numofone[i] >= n-numofone[i]){
            //0の方がいいので特に何もなし
        }else{
            //1の方がいいので大丈夫かチェックする
            if((x | (1ll << i)) <= k){
                x |= (1ll << i);
            }
        }
    }

    rep(i, n) ans += a[i] ^ x;

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


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

int main(int argc, const char * argv[]) {

    while (true) {
        int n;
        cin >> n;
        if(n == 0){
            break;
        }
        
        int suuretu[25] = {0};
        for(int i=0;i<n;i++){
            cin >> suuretu[i];
        }
        
        int sum = 32;
        bool ichiro = false;
        int i = 0;
        while(sum > 1){
            if(ichiro){
                sum -= suuretu[i];
                i = (i + 1) % n;
                ichiro = false;
            }
            else{
                sum -= (sum - 1) % 5;
                ichiro = true;
            }
            
            cout << sum << endl;
        }
        
        cout << 0 << endl;
    }
    
    
    
    return 0;
}

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

const int md = (int)1e9 + 7;
inline void add(int &a, int b) {
	a += b;
	if (a >= md) a -= md;
}
inline void sub(int &a, int b) {
	a -= b;
	if (a < 0) a += md;
}
inline int mul(int a, int b) {
	return (int) ((long long) a * b % md);
}
int main() {
#ifdef LOCAL_DEFINE
	// freopen("data.in", "rt", stdin);
	// freopen("data.out", "w", stdout);
	auto _start = chrono::high_resolution_clock::now();
#endif

	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	int n;
	cin >> n;
	vector<vector<int>> tree(n);
	for (int i = 1; i < n; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		tree[x].push_back(y);
		tree[y].push_back(x);
	}
	vector<vector<int>> dp(n, vector<int>(2));
	function<void(int, int)> dfs = [&](int u, int p) {
		dp[u][0] = dp[u][1] = 1;
		for (int v : tree[u]) {
			if (v == p) continue;
			dfs(v, u);
			dp[u][0] = mul(dp[u][0], (dp[v][0] + dp[v][1]) % md);
			dp[u][1] = mul(dp[u][1], dp[v][0]);
		}
	};
	dfs(0, -1);
	int ans = dp[0][0];
	add(ans, dp[0][1]);
	cout << ans << '\n';

#ifdef LOCAL_DEFINE
	auto _end = chrono::high_resolution_clock::now();
	cerr << "elapsed time: " << chrono::duration<double, milli>(_end - _start).count() << " ms\n";
#endif
	return 0;
}

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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    auto fail = [](){ cout << "NO\n"; exit(0); };

    int N;
    cin >> N;

    ll sum = N * (N + 1ll) / 2;
    ll tot = 0;

    vi a(N);
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        tot += a[i];
    }

    if (tot % sum) fail();

    ll ops = tot / sum;
    ll did = 0;

    for (int i = 0; i < N; i++) {
        int diff = a[i] - a[i == N - 1 ? 0 : i + 1];
        if ((diff + ops) % N) fail();
        if ((diff + ops) < 0) fail();
        did += (diff + ops) / N;
    }

    if (ops != did) fail();

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




Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rep1(i, n) for(ll i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  ll n;
  cin >> n;
  if(n == 1){
    cout << 0 << endl;
    return 0;
  }
  ll init = n;
  map<ll,ll> mp;
  for(ll i=2;i*i<=init;i++){
    while(n%i == 0){
      mp[i]++;
      n /= i;
    }
  }
  if(n > 1) mp[n]++;
  ll ans = 0;
  for(auto p : mp){
    ll b = p.second;
    ll cnt = 1;
    while(b-cnt >= 0){
      b -= cnt;
      cnt ++;
      ans ++;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3644
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.sql.Array;
import java.util.*;

public class Main {

    static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
    static long lcm (long a, long b) {return a*b/gcd(a,b);}

    public static void main(String[] args){
	// write your code here
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        Set<Integer> set = new HashSet<Integer>();
        int[] A= new int[n];
        for(int i=0;i<n;i++){
            A[i]=sc.nextInt();
        }
        for (int i=0; i<(Math.pow(2,n)); i++) {
            int temp = 0;
            for (int j=0; j<n; j++) {
                if ((1&i>>j) == 1) {
                    temp += A[j];
                }
            }
            set.add(temp);

        }
        int q=sc.nextInt();
        int[] m=new int[q];
        boolean[] ans=new boolean[q];
        for(int i=0;i<q;i++){
            m[i] = sc.nextInt();
            if(set.contains(m[i])){
                ans[i] = true;
            }else{
                ans[i] = false;
            }
        }
        for(int i=0;i<q;i++){
            if(ans[i]){
                System.out.println("yes");
            }else{
                System.out.println("no");
            }
        }
    }
}



Measured memory_bytes: 46668
import java.util.*;

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

        int k = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());

        int[] a = new int[n];

        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());

        }
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            int x = a[i];
            int y = a[(n - 1 + i) % n];
            int z = 0;
            if (x < y) {
                z = y - x;
            } else {
                z = y + (k - x);
            }

            if (ans > z) {
                ans = z;
            }
        }

        System.out.println(ans);

    }
}

Measured memory_bytes: 61416
#include <bits/stdc++.h>
#define ll long long int
#define FASTIO std::ios::sync_with_stdio(false);
#define pb push_back
#define mp make_pair
#define ld long double
#define F first
#define S second
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std;

int main()
{
FASTIO
//input_from_file

int n;
cin >> n;

int a[n][3];
for(int i = 0; i < n ;i++){
  for(int j = 0; j < 3; j++){
    cin >> a[i][j];
  }
}

int dp[n][3];
for(int i = 0; i < 3; i++){
  dp[0][i] = a[0][i];
}

for(int i = 1; i < n; i++){
  for(int j = 0; j < 3; j++){
    int temp;
    if(j == 0){
      temp = max(dp[i-1][1], dp[i-1][2]);
      dp[i][j] = temp + a[i][j];
    }
    else if(j == 1){
      temp = max(dp[i-1][0], dp[i-1][2]);
      dp[i][j] = temp + a[i][j];
    }
    else{
      temp = max(dp[i-1][0], dp[i-1][1]);
      dp[i][j] = temp + a[i][j];
    }
  }
}

int ans = max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
cout << ans;
}


Measured memory_bytes: 2560
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <ctime>
#include <map>
#include <stack>
#include <sstream>
#include <set>
#include <cmath>
#include <functional>
#include <memory.h>

// pi = atan(1)*4;

#define INTMAX 2100000000
const int Mod = 100000007;

using namespace std;

int main(void)
{
	long long int num, res;

	cin >> num;

	res = sqrt(num);

	cout << res*res << endl;
	return 0;
}

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

int a[22], b[22], c[22];

int main(){
	int n; scanf("%d", &n);
	for(int i=0;i<n;i++){
		scanf("%d", &a[i]);
		--a[i];
	}
	for(int i=0;i<n;i++){
		scanf("%d", &b[i]);
	}
	for(int i=0;i<n-1;i++){
		scanf("%d", &c[i]);
	}
	int ans = b[a[0]];
	for(int i=1;i<n;i++){
		ans += b[a[i]];
		if(a[i]==a[i-1]+1) ans += c[a[i-1]];
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
if __name__ == '__main__':
    n = int(input())
    a = [int(s) for s in input().split()]
    b = [int(s) for s in input().split()]
    ans = 0
    if b[0] < a[0]:
        ans += b[0]
        a[0] -= b[0]
        b[0] = 0
    else:
        ans += a[0]
        b[0] -= a[0]
        a[0] = 0
    for i in range(n - 1):
        if b[i] < a[i + 1]:
            ans += b[i]
            a[i + 1] -= b[i]
            b[i] = 0
        else:
            ans += a[i + 1]
            b[i] -= a[i + 1]
            a[i + 1] = 0
        if b[i + 1] < a[i + 1]:
            ans += b[i + 1]
            a[i + 1] -= b[i + 1]
            b[i + 1] = 0
        else:
            ans += a[i + 1]
            b[i + 1] -= a[i + 1]
            a[i + 1] = 0
    if b[n - 1] < a[n]:
        ans += b[n - 1]
        a[n] -= b[n - 1]
        b[n - 1] = 0
    else:
        ans += a[n]
        b[n - 1] -= a[n]
        a[n] = 0
    print(ans)


Measured memory_bytes: 18476
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,s=0;
	long long d,x,y;
	scanf("%d%lld",&n,&d);
	d=d*d;
	for(int i=1;i<=n;i++)
	{
		scanf("%lld%lld",&x,&y);
		if(x*x+y*y<=d)
			s++;
	}
	printf("%d\n",s);
	return 0;
}

Measured memory_bytes: 3824
import java.util.Scanner;
public class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a, b;
        for (;;) {
            a = sc.nextInt();
            b = sc.nextInt();
            for (int j = 0; j < a; j++) {
                for (int k = 0; k < b; k++) {
                    System.out.print("#");
                }
                System.out.println();
            }
            if (a == 0 && b == 0)
                break;
            System.out.println();
        }
    }
}



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

using namespace std;

#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    bool flag;
    int i,k,l,r,n,a[200005],b[200005];
    cin >> n >> k;
    for(i=1;i<=n;i++)cin >> a[i];
    while(k--)
    {
        for(i=1;i<=n;i++)b[i]=0;
        for(i=1;i<=n;i++)
        {
            l=max(1,i-a[i]);
            r=min(n+1,i+a[i]+1);
            ++b[l],--b[r];
        }
        for(i=2;i<=n;i++)b[i]+=b[i-1];
        flag=false;
        for(i=1;i<=n;i++)
        {
            if(b[i] != n)
            {
                flag=true;
                break;
            }
        }
        for(i=1;i<=n;i++)a[i]=b[i];
        if(!flag)break;
    }
    for(i=1;i<=n;i++)cout << a[i] << ' ';
    return 0;
}


Measured memory_bytes: 5184
#include <iostream>
#include <algorithm>
#define llint long long
#define inf 1e18

using namespace std;

llint h, n;
llint a[1005], b[1005];
llint dp[10005];

int main(void)
{
	cin >> h >> n;
	for(int i = 1; i <= n; i++) cin >> a[i] >> b[i];
	
	for(int i = h; i >= 0; i--) dp[i] = inf;
	dp[h] = 0;
	
	for(int i = h; i > 0; i--){
		for(int j = 1; j <= n; j++){
			dp[max(0LL, i-a[j])] = min(dp[max(0LL, i-a[j])], dp[i]+b[j]);
		}
	}
	cout << dp[0] << endl;
	
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
	int a,b,c;
	
	scanf("%d %d %d",&a,&b,&c);
	if(a==b){
		printf("%d",c);
	}else if(a==c){
		printf("%d",b);
	}else{
		printf("%d",a);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>

int main(){
  int A, B, C, D;
  std::cin >> A >> B >> C >> D;
  int t = (C+B-1)/B;
  int a = (A+D-1)/D;
  if(t <= a){
    std::cout << "Yes" << std::endl;
  }
  else{
    std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 3636
x,n=map(int,input().split())
if n==0:
    print(x)
else:
    A=list(map(int,input().split()))
    C=[]
    for i in range(n):
        C.append(abs(A[i]-x))
    C.append(0)
    B=[x for x in set(C) if C.count(x) > 1]
    s=0
    ok=0
    for i in range(len(B)):
        if B[i]-i!=0:
            s=i
            ok=1
            break
    if ok==0:
        s=B[-1]+1
    d=x-s
    for i in range(n):
        if A[i]==d:
            d=x+s
    print(d)


Measured memory_bytes: 9128
K, N = map(int, input().split())

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

Adelta = [A[i+1]-A[i] if i < (N-1) else A[0] + (K - A[N-1]) for i in range(N)]

AdeltaMax = max(Adelta)

print(K - AdeltaMax)

Measured memory_bytes: 86384
#include<iostream>
using namespace std;
int main(){
  int N, A, B;
  cin >> N >> A >> B;
  int ans = 0;
  for(int i = 1; i <= N; i++){
    int sum = 0;
    int num = i;
    while(num != 0){
      sum += num % 10;
      num /= 10;
    }
    if(sum >= A && sum <= B){
      ans += i;
    }
  }
  cout << ans << endl;
  return 0;
}


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


int main()
{
  long N, M;
  cin >> N >> M;
  vector<long> St(M);
 for(int i=0;i<M;i++)cin >> St[i];

  vector<long> dp(100100, 0);
  if(M!=0){
  int mark=0;
  for(int i=0;i<2;i++){
    if(i==St[mark]){
      mark++;
      dp[i]=0;
    }
    else dp[i]=1;
  }
for(int i=2;i<=N;i++){
    if(i==St[mark]){
        mark++;
        dp[i]=0;
    }
    else dp[i] += (dp[i-1]+dp[i-2]) % 1000000007;
  }
  //for(int i=0;i<N;i++)cout<<dp[i]<<endl;
  }else{
    dp[0]=1;
    dp[1]=1;
    for(int i=2;i<=N;i++){
  dp[i] += (dp[i-1]+dp[i-2]) % 1000000007;
  }
  }
  cout << dp[N] << endl;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef pair<int,int> pii;
typedef pair<long long, int> pli;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (x).size()

ll mod = 1000000007;

ll gcd(ll a, ll b){
  if (a%b == 0)return(b);
  else return(gcd(b, a%b));
}

ll inv(ll x){
  ll res = 1;
  ll k = mod - 2;
  ll y = x;
  while(k){
    if(k&1)res = (res*y)%mod;
    y = (y*y) % mod;
    k /= 2;
  }
  return res;
}


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

  map<int,int> cnt;
  for(int x = 1;x <= 100;x++){
    for(int y = 1;y <= 100;y++){
      for(int z = 1;z <= 100;z++){
        cnt[x*x + y*y + z*z + x*y + y*z + z*x]++;
      }
    }
  }

  int n;
  cin >> n;
  for(int i = 1;i <= n;i++){
    cout << cnt[i] << endl;
  }
}

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

long long int gcd(long long int a,long long int b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

int main(){
    int n;
    cin >> n;
    long long int c[n];
    for(int i=0;i<n;i++){
        cin >> c[i];
    }
    if(n==1){
        cout << c[0] << endl;
    }
    else{
        long long int ans =0;
        ans = 1;
        for(int i=0;i<n;i++){
            ans = ans / gcd(c[i],ans) * c[i];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <tuple>
#include <bitset>
#include <utility>
#include <climits>
#include <iomanip>
#include <queue>
 
#define push emplace_back
#define each(i, x) for (auto i=0; i < x; i++)
using ull = unsigned long long;
constexpr auto mod = 1000000007;
constexpr auto INF = ULLONG_MAX;
 
using namespace std;
template <typename T> inline void dump(const T& x) { cout << "[" << x << "]" << endl; }
template <typename T> inline void dump(const vector<T>& x) { for (const auto v : x) { cout << v << " "; } cout << endl; }
template <typename T> inline void sort_asc(vector<T>& x) { std::sort(x.begin(), x.end()); }
template <typename T> inline void sort_desc(vector<T>& x) { std::sort(x.begin(), x.end(), greater<T>()); }
template <typename T> inline T max_value(vector<T>& x) { return *max_element(x.begin(), x.end()); }
template <typename T> inline T min_value(vector<T>& x) { return *min_element(x.begin(), x.end()); }
template <typename T> inline T sum_value(vector<T>& x) { return accumulate(x.begin(), x.end(), 0ULL); }

ull gcd(ull x, ull y) {
  if (y > x)
    return gcd(y, x);

  auto r = x % y;
  if (r == 0)
    return y;
  else
    return gcd(y, r);
}

ull lcm(ull x, ull y) {
  return (x * y) / gcd(x, y);
}

int main() {
  //std::cout << std::fixed << std::setprecision(10);
  ull a, b, c, d;
  cin >> a >> b >> c >> d;

  // bb
  auto bb = b - (b / c) - (b / d) + (b / lcm(c, d));

  // aa
  auto A = a-1;
  auto aa = A - (A / c) - (A / d) + (A / lcm(c, d));

  cout << bb - aa << endl;

  return 0;
}


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

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

signed main(){

  int n;
  string s;
  cin>>n>>s;

  vector dp(n+1,vector(n+1,0));

  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
      if(s[i]==s[j]){
        dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+1);
      }
      dp[i+1][j+1] = min(dp[i+1][j+1],j-i);
    }
  }

  int ans = 0;
  for(auto vec:dp)for(auto val:vec)ans=max(ans,val);
  cout<<(ans)<<endl;

}

Measured memory_bytes: 101196
#正の場合、0の場合、負の場合で分ける
#負の数のみの場合は調整しようがない
#偶数の時は絶対値の大きい順
#奇数の時は絶対値の小さい順
#正の数のみの場合は大きい順
#大きい順

#他は調整できるので、正で大きくする方向で考える(正→0以上)
#負の数は偶数個ないと正にならないので二つ一組で先にかけて考える
#正の数も同様に先にかけて、その中で大きいものを選べば良い

#負の数が奇数個、正の数が奇数個の時(負の数が余る、正の数が余る)
#Kが偶数の時はいい感じに選んでく(N=kの時は仕方ないので全部)
#Kが奇数の時は正の中で最大のものを選ぶ
#負の数が偶数個、正の数が奇数個の時(正の数が余る)
#Kが偶数の時はいい感じに選んでく
#奇数の時は残りの正の中から選ぶ
#負の数が奇数個、正の数が偶数個の時(負の数が余る)
#N=Kの時は全部選ぶ、それ以外の場合は余った負の数はいらない
#Kが奇数の時は残りの正の中で最大のものを選べば良い
#負の数が偶数個、正の数が偶数個の時
#Kが奇数の時は残りの正の中で最大のものを選べば良い

#N=Kの時は別で分けて考えるとすると、負の数及び正の数によらず
#Kが偶数の時は大きいものからいい感じに選んでく
#Kが奇数の時は最後の残り一個は正の残りの中で最大のものを選ぶ
#と簡単に言い換えることができる

#x:配列
mod=10**9+7
def multarray(x):
    ret=1
    for i in x:
        ret*=i
        ret%=mod
    return ret

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

if n==k:
    print(multarray(a))
    exit()

ap,am=[],[]
for i in range(n):
    if a[i]>=0:
        ap.append(a[i])
    else:
        am.append(a[i])
#絶対値の順番
ap.sort(reverse=True)
am.sort()

if len(am)==0:
    print(multarray(ap[:k]))
    exit()
if len(ap)==0:
    if k%2==0:
        print(multarray(am[:k]))
    else:
        print(multarray(am[::-1][:k]))
    exit()

apm2=[]
for i in range(len(am)//2):
    apm2.append((am[2*i]*am[2*i+1],0))
for i in range(len(ap)//2):
    apm2.append((ap[2*i]*ap[2*i+1],1))
apm2.sort(reverse=True)

#+の次にどこを見るのかをチェックしておく
#まだかけない
p=0
ans=[]
for i in range(k//2):
    p+=(2*apm2[i][1])
    ans.append(apm2[i][0])

#ここで不正アクセスの可能性を避ける
#プラスが余ってない場合(一個減らして次のマイナス使う)
if k%2==0:
    print(multarray(ans))
    exit()
if p==len(ap):
    #一個減らす
    check_i=ans.index(ap[p-1]*ap[p-2])
    ans[check_i]=ap[p-2]
    ans.append(apm2[k//2][0])
    print(multarray(ans))
else:
    #余ってる場合もafter_contestで落ちる
    #その一個をとるのが最適とは限らない
    #一個減らして二個とる場合も
    ans_cand=[]
    #一個増やす場合
    ans_cand.append(multarray(ans)*ap[p]%mod)
    if p>=2:
        #一個減らして二個増やす場合
        check_i=ans.index(ap[p-1]*ap[p-2])
        #0除算を避ける
        ans[check_i]=ap[p-2]
        ans.append(apm2[k//2][0])
        ans_cand.append(multarray(ans))
    print(max(ans_cand))


Measured memory_bytes: 31996
package main

import "fmt"

func main() {
	var a, b, c, x int
	fmt.Scan(&a, &b, &c, &x)

	var count int
	for i := 0; i <= a; i++ {
		n := 500 * i
		if n > x {
			break
		}
		for j := 0; j <= b; j++ {
			m := 100 * j
			if n+m > x {
				break
			}
			for k := 0; k <= c; k++ {
				if n+m+50*k == x {
					count++
				}
			}
		}
	}

	fmt.Println(count)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep2(i,x,y) for (int i = x; i < (y); ++i)
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
int INF = 100100101;
int main()
{
  ios::sync_with_stdio(false);  cin.tie(0); cout.tie(0);
  ll n;
  cin>>n;
  string ans;
  while(n > 0) {
    n -= 1;
    ans += (n % 26) + 'a';
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define li long long
#define gc getchar()
#define pc putchar
inline li read(){
	li x = 0,y = 0,c = gc;
	while(!isdigit(c)) y = c,c = gc;
	while(isdigit(c)) x = (x << 1) + (x << 3) + (c ^ '0'),c = gc;
	return y == '-' ? -x : x;
}
inline void print(li q){
	if(q < 0){
		pc('-');
		q = -q;
	}
	if(q >= 10) print(q / 10);
	pc(q % 10 + '0');
}
li s1 = 19260817,s2 = 23333333,s3 = 998244853,srd;
inline li rd(){
	return srd = (srd * s1 + s2 + rand()) % s3;
}
int n,m;
inline void file(){
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
//const int mo = 998244353;
const int mo = 1000000007;
char c[100010];
int a[30];
int main(){
	srand(time(0));rd();
	//file();
	int i,j;
	n = read();scanf("%s",c + 1);
	for(i = 1;i <= n;++i) ++a[c[i] - 'a'];
	li as = 1;
	for(i = 0;i < 26;++i) (as *= (a[i] + 1)) %= mo;
	print((as + mo - 1) % mo);
	return 0;
}


Measured memory_bytes: 384