akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 4096
#define MOD 998244353LL

ll m[N][N] = {};

int main(){
	ll a, b, c, d; scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
	m[a-1][b-1] = 1;
	FOR(i, a, c){
		ll z = 0;
		FOR(j, b-1, d){
			m[i][j] = (m[i-1][j] * (j+1) + z) % MOD;
			DEBUG("m[%d][%d] = %lld (z=%lld)\n", i, j, m[i][j], z);
			z = (z + m[i-1][j]) * i % MOD;
		}
	}
	ll ans = 0, pw = 1;
	for(int j = d-1; j >= b-1; j--){
		ans = (ans + pw * m[c-1][j]) % MOD;
		pw = pw * c % MOD;
	}
	printf("%lld\n", ans);
}




Measured memory_bytes: 75544
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};
struct edge{int to,cost;};
//typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)||islower(c));}
void printvi(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printvil(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}
void printvvi(vector<vector<int>> v){
    rep(i,0,v.size()){
        rep(j,0,v[i].size()){
            if(j)cout<<" ";
            cout<<v[i][j];
        }
        cout<<endl;
    }
}
void printvstr(vector<string> v){
    rep(i,0,v.size()){
        cout<<v[i]<<endl;
    }
}

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

struct S{
    int idx,value;
};

signed main (){
    int a,b,t;
    cin>>a>>b>>t;
    cout<<(t/a)*b<<endl;

    
    

    
}
/*

*/


Measured memory_bytes: 256
n, y = map(int, input().split())

ok = False
m_10000 = y // 10000
for t in range(0, m_10000+1)[::-1]:
    r = y - (t*10000)
    m_5000 = r // 5000
    if ok:
        break
    for f in range(0, m_5000+1)[::-1]:
        c = n - t - f
        total = (10000 * t) + (5000 * f) + (1000 * c)
        if total == y:
            print(t, f, c)
            ok = True
            break
if not ok:
    print(-1, -1, -1)

Measured memory_bytes: 3064
#include <stdio.h>

int search(int w,int h,int x,int y,int *a_x,int *a_y,int map[100][100]){
  while(map[y][x] != '.'){
    int ret = map[y][x];
    map[y][x] += (1 << 10);

    if(ret == '^'){
      y--;
    }else if(ret == 'v'){
      y++;
    }else if(ret == '<'){
      x--;
    }else if(ret == '>'){
      x++;
    }else{
      return -1;
    }
  }
  
  *a_x = x;
  *a_y = y;
  return 1;
  
}

int main(int argc,char* argv[]){
  int i,j;
  int map[100][100];
  char str[100];

  for(;;){
    int w,h;

    scanf("%d %d",&h,&w);
    if(w == 0 && h == 0){break;}

    for(i = 0; i < h; i++){
      scanf("%s",&str);
      for(j = 0; j < w; j++){
	map[i][j] = str[j];
      }
    }
    
    {
      int x,y;
      int re = search(w,h,0,0,&x,&y,map);
      if(re == -1){
	printf("LOOP\n");
      }else{
	printf("%d %d\n",x,y);
      }
    }
  }

  return 0;
  
}

Measured memory_bytes: 0
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <map>
#include <string>
#include <set>
#include <math.h>
#define N 100100
#define inf 100000000
using namespace std;
int main()
{
    long long n, a[5];
    cin >> n >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    sort(a, a + 5);
    printf("%lld\n", n / a[0] + 5 - (n % a[0] == 0));
    return 0;
}


Measured memory_bytes: 256
import sys

h, w, d = map(int, input().split())
f = [list(map(int, input().split())) for _ in range(h)]

c_map = [0] * (h * w)
for i in range(h):
    for j in range(w):
        c_map[f[i][j] - 1] = (i, j)

d_map = [0] * (h * w)
for l in range(h * w - d - 1, -1, -1):
    i, j = c_map[l]
    i2, j2 = c_map[l + d]
    d_map[l] = d_map[l + d] + abs(i - i2) + abs(j - j2)

buf = []
q = int(input())
for line in sys.stdin.readlines():
    l, r = map(int, line.split())
    buf.append(d_map[l - 1] - d_map[r - 1])

print('\n'.join(map(str, buf)))


Measured memory_bytes: 29016
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpii = vector<pll>;

int main(){
  ll N, A, B;
  cin >> N >> A >> B;

  ll C = A + B;

  cout << ((N / C) * A + min(N % C, A)) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i>0;i--)
#define rep1(i,s,n) for(int i=s;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<string> svec;

int main(){
    ll k,n,m=0,ans=0;
    cin>>n>>k;
    lvec a(n);
    rep(i,n){
        cin>>a[i];
    }
    while(m<n-1){
        m+=k-1;
        ans++;
    }
    cout<<ans;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
    int n,a[100010]={},ans=0,A;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A;
        if(A>100000) ans++;
        else a[A]++;
    }
    for(int i=0;i<=100000;i++){
        if(a[i]<i) ans+=a[i];
        else if(a[i]>i) ans+=a[i]-i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
# frozen_string_literal: true

h, w, k = readline.strip.split.map(&:to_i)

grid = (0...h).map { readline.strip }

ans = 0
(0...(1 << h)).each do |i|
  (0...(1 << w)).each do |j|
    c = 0
    (0...h).each do |k|
      (0...w).each do |l|
        if grid[k][l] == '#' && ((i >> k) & 1).zero? && ((j >> l) & 1).zero?
          c += 1
        end
      end
    end
    ans += 1 if c == k
  end
end

puts ans


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

#define int long long
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

#define len(a) ((int) (a).size())
#define all(a) (a).begin(), (a).end()

const int N = 3007;
const int M = 998244353;

int dp[N][N];

int32_t main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, s;
    cin >> n >> s;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i + 1][j] += dp[i][j] * 2;
            dp[i + 1][j] %= M;
            if (j + a[i] <= s) {
                dp[i + 1][j + a[i]] += dp[i][j];
                dp[i + 1][j + a[i]] %= M;
            }
        }
    }
    cout << dp[n][s];
    return 0;
}


Measured memory_bytes: 74152
a,b,c = map(int,input().split(" "))

k_flag = False
if a==b:
    if a!=c:
        k_flag = True
    else:
        pass
else:
    if b==c or a==c:
        k_flag = True
    else:
        pass
if k_flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 2940
import java.util.*;
import java.util.Map.Entry;

class Main {
	Scanner sc = new Scanner(System.in);

	class DLong{
		long val;
		public DLong(long _val){
			val=_val;
		}
	}
	public void run() {
		while(true){
			int n=sc.nextInt();
			if(n==0)break;
			LinkedHashMap<Integer,DLong> datalist=new LinkedHashMap<Integer,DLong>();
			for(int i=0;i<n;i++){
				int id=sc.nextInt();
				long val=sc.nextLong()*sc.nextLong();
				if(datalist.containsKey(id)){
					DLong v=datalist.get(id);
					v.val+=val;
				}else{
					datalist.put(id,new DLong(val));
				}
			}
			boolean isset=false;
			for(Entry<Integer,DLong> entry:datalist.entrySet()){
				if(entry.getValue().val>=1000000){
					ln(entry.getKey());
					isset=true;
				}
			}
			if(!isset){
				ln("NA");
			}
		}
	}
	public static void main(String[] args) {
		new Main().run();
	}
	public static void pr(Object o) {
		System.out.print(o);
	}
	public static void ln(Object o) {
		System.out.println(o);
	}
	public static void ln() {
		System.out.println();
	}
}

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

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

ll dp[2][2020];

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

#ifdef LOCAL
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	auto START = chrono::steady_clock::now();
#endif

	string s;
	cin >> s;

	ll res = 0;

	for (char c : s) {
		for (int mod = 0; mod < 2019; mod++) {
			int newMod = (10 * mod + (c - '0')) % 2019;
			dp[1][newMod] += dp[0][mod];
		}

		dp[1][c - '0']++;
		res += dp[1][0];

		for (int i = 0; i < 2020; i++) {
//			if (dp[1][i] != 0) {
//				cout << c << " " << i << " -> " << dp[1][i] << endl;
//			}
			dp[0][i] = dp[1][i];
			dp[1][i] = 0;
		}
	}

	cout << res;

#ifdef LOCAL
	cerr << "Working time: " << chrono::duration_cast<chrono::milliseconds>(chrono::steady_clock::now() - START).count()
			 << " ms.";
#endif

	return 0;
}

Measured memory_bytes: 3784
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define fio() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define MOD 1000000007
#define nl '\n'
#define pb push_back
#define mp make_pair

using namespace std;
const int N = 105;
const int K = 200005;
int t[K<<2];
void build(int a[], int v, int tl, int tr) {
    if (tl == tr) {
        t[v] = a[tl];
    } else {
        int tm = (tl + tr) / 2;
        build(a, v*2, tl, tm);
        build(a, v*2+1, tm+1, tr);
        t[v] = t[v*2] + t[v*2+1];
    }
}
int query(int v, int tl, int tr, int l, int r) {
    if (l > r) 
        return 0;
    if (l == tl && r == tr) {
        return t[v];
    }
    int tm = (tl + tr) / 2;
    return max(query(v*2, tl, tm, l, min(r, tm))
           ,query(v*2+1, tm+1, tr, max(l, tm+1), r));
}
void update(int v, int tl, int tr, int pos, int new_val) {
    if (tl == tr) {
        t[v] = new_val;
    } else {
        int tm = (tl + tr) / 2;
        if (pos <= tm)
            update(v*2, tl, tm, pos, new_val);
        else
            update(v*2+1, tm+1, tr, pos, new_val);
        t[v] = max(t[v*2] , t[v*2+1]);
    }
}
int32_t main()
{
	fio();
	int n;
	cin>>n;
	vector< pair< pair<int,int>, int> > v;
	int h[n],a[n];
	for(int i=0;i<n;i++)
		cin>>h[i];
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n;i++)
		v.push_back({{h[i],a[i]},i});
	sort(v.begin(), v.end());
	for(int i=0;i<n;i++)
	{
		int u=0;
		if(v[i].second!=0)
			u=query(1,0,n-1,0,v[i].second-1);
		//cout<<u<<endl;
		update(1,0,n-1,v[i].second,u+v[i].first.second);
		//cout<<query(1,0,n-1,1,1)<<endl;
	}
	cout<<query(1,0,n-1,0,n-1);
}



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

using namespace std;

int main() {
  long long n, p, ans = 1;
  cin >> n >> p;
  for (long long i = 2, j = p; i * i <= p; i++) {
    int cnt = 0;
    while (j % i == 0) {
      j /= i;
      cnt++;
    }
    int num = cnt / n;
    while (num--) ans *= i;
  }
  if (n == 1) ans = p;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
char max(char a, char b){return a<b?b:a;}
short n, i;
char s[101];
char l[26], r[26], now, ans;
int main(void){
	scanf("%d\n", &n);
	register char c;
	c=getchar()-'a';
	s[0]=c;
	l[c]++;
	for(i=1; i<n; i++){
		c=getchar()-'a';
		s[i]=c;
		r[c]++;
	}
	if(r[s[0]]>0){ans=now=1;}
	for(i=1; i<n; i++){
		c=s[i];
		now+=(l[c]==0);
		l[c]++;
		r[c]--;
		now-=(r[c]==0);
		ans=max(ans, now);
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include <iostream>

using namespace std;
typedef long long ll;

int main(void){
ll a,b,c;
cin >> a >> b >> c;
ll d = c - a - b;
if(d > 0 && d * d > 4 * a * b){
cout << "Yes" << endl;
} else {
cout << "No" << endl;
}

return 0;
}


Measured memory_bytes: 3620
ini=raw_input()
a=list(ini)
check=0
if "C" in a and "F" in a:
	c=a.index("C")
	f=0
	for i in range(len(a)):
		if a[i]=="F":
			f=i
	if c<f:
		check=1
if check==1:
	print "Yes"
else:
	print "No"

Measured memory_bytes: 2568
def F(x,y):
    x = str(x)
    y = str(y)
    return max(len(x),len(y))
N = int(input())
cmin = 100
for i in range(1,int(N**0.5)+1):
    if N%i==0:
        cmin = min(cmin,F(i,N//i))
print(cmin)

Measured memory_bytes: 64628
#include <cstdio>
#include <cstring>
//#include <cstdlib>
//#include <cmath>
//#include <string>
#include <algorithm>
//#include <vector>
#define INF (2000000000)
using namespace std;

//typedef vector<int> VI;
//typedef vector<int>::iterator VII;
//typedef vector<double> VD;
//typedef vector<double>::iterator VDI;

char map[2048][2048];
int dp[2048][2048];

int main()
{
	int n;
	while (scanf("%d", &n), n){
		memset(dp, 0, sizeof(dp));
		for (int i = 0; i < 1024; i++){
			for (int j = 0; j < 1024; j++){
				map[i][j] = '\0';
			}
		}
		
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				scanf(" %c", &map[i][j]);
			}
		}
		
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				if (map[i][j] == '.'){
					dp[i][j] = min(dp[i - 1][j - 1], min(dp[i - 1][j], dp[i][j - 1])) + 1;
				}
	//			printf("%d", dp[i][j]);
			}
	//		printf("\n");
		}
		
		int maxi = 0;
		for (int i = 1; i <= n; i++){
			for (int j = 1; j <= n; j++){
				maxi = max(maxi, dp[i][j]);
			}
		}
		
		printf("%d\n", maxi);
	}
	
	return 0;
}

Measured memory_bytes: 21516
//  g++ -g -std=gnu++14 -I . main.cpp -o main
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    (v).begin(), (v).end()
#define in        ([]{int n; cin>>n; return n;}())
using namespace std;
using lint = int64_t;


int main() { cin.tie(0); ios::sync_with_stdio(false);
    int N=in, X=in;
    vector<int> L(N);
    rep( i, N ) L[i] = in;

    int D = 0;
    rep( i, N ) {
        D += L[i];
        if( D > X ) {
            cout << (i+1) << endl;
            return 0;
        }
    }

    cout << (N+1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 0) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll a, b;
  std::cin >> a >> b;

  ll diff = b - a;
  ll ans = (diff - 1) * diff / 2 - a;
  print(ans);

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,x,l,tot;
int main()
{
    cin>>n>>x;
    for(int i=1;i<=n;i++){
        cin>>l;
        if(tot>=x){
            printf("%d\n",(tot==x)?i:i-1);
            return 0;
        }
        tot=tot+l;
    }
    printf("%d\n",n+1);
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    /**/
    sort(a.begin(),a.end());

    cout << abs(a[n - 1] - a[0]) << endl;
    return 0;
}

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

typedef long long ll;

int main() {
  ll k;
  cin >> k;
  ll n = 50;
  ll lim = pow(10, 16);
  ll div = k / n;
  ll mod = k % n;
  vector<ll> la(n);
  for (int i = 0; i < n; ++i) { 
    la[i] = div+n-1;
    if (i < mod) { la[i] += 1; }
    else { la[i] -= mod; }
  }
  cout << n << endl;
  for (int i = 0; i < n; ++i) { 
    cout << la[i] << " ";
  }
  cout << endl;
}



Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
c=1
d=0
for i in range(n-1):
  e=d+A[i+1]-A[i]
  if (d<e and d<0) or (d>e and d>0):
    c+=1
    e=0
  d=e
print(c)

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

int main(){
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, s.length()){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3924
#include<bits/stdc++.h>
#define int long long
using namespace std;
int a[200005],b[200005],dp[200005];
main(){
	ios::sync_with_stdio(0);cin.tie(0);
	int n;
	cin >> n;
	stack<int> q;
	q.push(0);
	for (int i = 1;  i<= n; i++){
		cin >> a[i];
		while (!q.empty() && a[q.top()] > a[i])
		{
			q.pop();
		}
		b[i] = q.top();
		q.push(i);
	}
	long long ans = 0;
	for (int i = 1; i <= n; i++){
		dp[i] = dp[b[i]] + 1ll*a[i]*(i - b[i]);
		ans += dp[i];		
	}
cout<< ans;
		
}

Measured memory_bytes: 6656
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#define debug(x) cerr << #x << ':' << x << endl
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, c) for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
using namespace std;
typedef long long ll;

int main()
{
    string s;
    cin >> s;
    int n = s.size();

    set<string> strs = {"dream", "dreamer", "erase", "eraser"};
    bool is_ok = false;

    while (1)
    {
        n=s.size();
        if (s == "")
        {
            is_ok = true;
            break;
        }
        if (s.size() < 7)
        {
            if (s.size() < 6)
            {
                if (s.size() < 5)
                {
                    break;
                }
                else
                {
                    if (s.substr(n - 5, 5) == "dream")
                        s.erase(n - 5, 5);
                    else if (s.substr(n - 5, 5) == "erase")
                        s.erase(n - 5, 5);
                    else
                        break;
                }
            }
            else
            {
                if (s.substr(n - 5, 5) == "dream")
                    s.erase(n - 5, 5);
                else if (s.substr(n - 5, 5) == "erase")
                    s.erase(n - 5, 5);
                else if (s.substr(n - 6, 6) == "eraser")
                    s.erase(n - 6, 6);
                else
                    break;
            }
        }
        else
        {
            if (s.substr(n - 5, 5) == "dream")
                s.erase(n - 5, 5);
            else if (s.substr(n - 7, 7) == "dreamer")
                s.erase(n - 7, 7);
            else if (s.substr(n - 5, 5) == "erase")
                s.erase(n - 5, 5);
            else if (s.substr(n - 6, 6) == "eraser")
                s.erase(n - 6, 6);
            else
                break;
        }
    }
    cout << (is_ok ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cmath>
#include<algorithm>
#include <iomanip> 
#include<vector>
#include<queue>
#include<set>
#define fo(i,n) for(ll i=0;i<n;i++)
#define f(i,n) for(ll i=1;i<n;i++)
#define ff(i,k,n) for(ll i=k;i<n;i++)
#define ll long long
#define  vt  vector<ll>
#define pb(x)  push_back(x)
#define   vts  vector<string>
/*Elegizip, elegizip otken sol bir shaktar-ai
 Elendeter zamanymnyn otip bara zhatkanny-ai
Umytylmas-Umytylmas Kairan esil shaktar-ai
Zamanymnyn kolyn bulgap otip bara jatkany-ai
 kairan esil , kairan esil shaktar-ai
kolyn bulgap zamanymnyn otip bara jatkany-ai;*/
using namespace std;



int main()
{ios::sync_with_stdio(0);
ll x;
ll mo=1e9+7;
cin>>x;
ll a[x];
ll sum=0;
fo(i,x){
    cin>>a[i];
    sum+=a[i];
}
ll ans=0;
fo(i,x){
    ans+=((sum-a[i])%mo)*a[i];
    sum-=a[i];
    ans%=mo;
}
cout<<ans%mo;
}





Measured memory_bytes: 5212
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int counter[31];

int main(){ _;
  int n,m,k,a;cin>>n>>m;
  REP(i,n){
    cin>>k;
    REP(j,k){
      cin>>a;
      counter[a]++;
    }
  }
  int result=0;
  for(int j=1;j<=m;j++){
    if(counter[j]==n)result++;
  }
  cout<<result<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>

using namespace std;

string s, t;
vector<vector<vector<int>>> dp;

int calc(int x, int y, bool isI) {
    int ret = 0;
    if (x < s.size() && ((s[x] == 'I') == isI)) {
        if (dp[x + 1][y][!isI] < 0) dp[x + 1][y][!isI] = calc(x + 1, y, !isI) + 1;
        ret = max(ret, dp[x + 1][y][!isI]);
    }
    if (y < t.size() && ((t[y] == 'I') == isI)) {
        if (dp[x][y + 1][!isI] < 0)dp[x][y + 1][!isI] = calc(x, y + 1, !isI) + 1;
        ret = max(ret, dp[x][y + 1][!isI]);
    }
    return ret;
}

int main() {
    int m, n;
    cin >> m >> n >> s >> t;

    int ret = 0;
    dp = vector<vector<vector<int>>>(m + 1, vector<vector<int>>(n + 1, vector<int>(2, -1)));
    for (int i = 0; i < m; i++) {
        for (int j = 0; j < n; j++) {
            ret = max(ret, (calc(i, j, true) + 1) / 2 * 2 - 1);
        }
    }

    cout << ret << endl;
    return 0;
}


Measured memory_bytes: 222464
using System;

namespace ABC166C
{
    class Program
    {
        static void Main(string[] args)
        {
            var target = Console.ReadLine().Split(' ');
            int N = int.Parse(target[0]);
            int M = int.Parse(target[1]);
            int[] x = new int[N];
            int[] height = new int[N];
            target = Console.ReadLine().Split(' ');
            for(int i=0;i<N;i++)
               height[i] = int.Parse(target[i]);
            for(int i=0;i<M;i++){
                target = Console.ReadLine().Split(' ');
                int src = int.Parse(target[0])-1;
                int dist = int.Parse(target[1])-1;
                if(height[src] < height[dist]){
                    x[src]++;
                } 
                if(height[src] > height[dist]){
                    x[dist]++;
                } 
                if(height[src] == height[dist]){
                    x[src]++; x[dist]++;
                } 
            }
            int count = 0;
            for(int i=0;i<N;i++)   if(x[i] == 0 ) count++;
            Console.WriteLine(count);
        }
    }
}


Measured memory_bytes: 46424
//package abc178;

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] ip = br.readLine().split(" ");
		
		long a = Long.parseLong(ip[0]);
		long b = Long.parseLong(ip[1]);
		long c = Long.parseLong(ip[2]);
		long d = Long.parseLong(ip[3]);
		
		long p = a*c;
		long q = a*d;
		long r = b*c;
		long s = b*d;
		
		System.out.println(Math.max(p, Math.max(r, Math.max(q,s))));	
	}
}


Measured memory_bytes: 32568
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10,mod=1e9+7;

int n,ans,nv[N],ss[N],frac;

inline int ad(int x,int y){x+=y;return x>=mod?x-mod:x;}
inline int dc(int x,int y){x-=y;return x<0?x+mod:x;}
inline int mul(int x,int y){return 1ll*x*y%mod;}

int main(){
	int i,j,x;
	scanf("%d",&n);
    nv[0]=nv[1]=ss[1]=frac=1;
    for(i=2;i<=n;++i){
    	nv[i]=mul(mod-mod/i,nv[mod%i]);
    	ss[i]=ad(ss[i-1],nv[i]);
    	frac=mul(i,frac);
    }
    for(i=1;i<=n;++i){
    	scanf("%d",&x);
    	ans=ad(ans,mul(x,ad(ss[i],dc(ss[n-i+1],1))));
    }
    printf("%d\n",mul(frac,ans));
    return 0;
}

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

int main()
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    int res1 = x * a + y * b;
    int res2;
    int res3;
    if(x >= y)
    {
        res2 = 2 * y * c + 2 * (x - y) * c;
        res3 = 2 * y * c + (x - y) * a;
    }
    else
    {
        res2 = 2 * x * c + 2 * (y - x) * c;
        res3 = 2 * x * c + (y - x) * b;
    }

    int mn = min(res1, res2);

    cout << (mn < res3 ? mn : res3);

    return 0;
}


Measured memory_bytes: 256
#a1
a1 = list(map(int, input().split()))
#a2
a2 = list(map(int, input().split()))
#a3
a3 = list(map(int, input().split()))

n = int(input())
for i in range(n):
    a=int(input())
    for j in range(len(a1)):
        if a == a1[j]:
            a1[j] = 101
        if a == a2[j]:
            a2[j] = 101
        if a == a3[j]:
            a3[j] = 101

if a1[0]+a1[1]+a1[2] == 303 \
or a2[0]+a2[1]+a2[2] == 303 \
or a3[0]+a3[1]+a3[2] == 303 \
or a1[0]+a2[0]+a3[0] == 303 \
or a1[1]+a2[1]+a3[1] == 303 \
or a1[2]+a2[2]+a3[2] == 303 \
or a1[0]+a2[1]+a3[2] == 303 \
or a1[2]+a2[1]+a3[0] == 303 :
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

int main(){

  int n, t, count, i, j;
  int num[10000];

  scanf("%d",&n);

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

  for (i = 0; i < n; i++){
    if (num[i] == 2) {
    }
    else if(num[i] % 2 == 0){
      count--; 
    }
    else{
      t = sqrt(num[i]);
      for(j=3; j<=t; j=j+2){
        if(num[i] % j == 0){
          count--;  
          break;  
        }
      }  
    }
  }

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

  return 0;
}

Measured memory_bytes: 1876
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>

using namespace std;

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

	vector<int> as(m);
	for (int i = 0; i < m; i++) {
		cin >> as[i];
	}

	int count = 0;
	for (int j = 0; j < n; j++) {
		int val = 0;
		for (int i = 0; i < m; i++) {
			int b;
			cin >> b;
			val += as[i] * b;
		}
		if (val + c > 0) count++;
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = n%10;
		if(k==3)System.out.println("bon");
		else if(k==0 || k==1 || k==6 || k==8)System.out.println("pon");
		else System.out.println("hon");
	}

}


Measured memory_bytes: 27040
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n, m;
    cin >> n >> m;
    int time = m * 1900 + (n - m) * 100;
    time *= pow(2, m);
    cout << time << endl;
}


Measured memory_bytes: 4100
t, x, y = 0, 0, 0
for i in range(int(input())):
    next_t, next_x, next_y = map(int, input().split())
    diff = abs(x - next_x) + abs(y - next_y)
    if diff > (next_t - t):
        print("No")
        exit(0)
    if (diff - (next_t - t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y, = next_t, next_x, next_y
print("Yes")


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

int gcd(int a, int b);

void swap(int *a, int *b);

int main()
{
    int a, b;
    cin>>a>>b;
    
    if(a < b)
        swap(a, b);

    cout<<gcd(a, b)<<endl;
}

void swap(int *a, int *b)
{
    int temp = *a;
    *a = *b;
    *b = temp;
}

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

Measured memory_bytes: 3100
from sys import exit, stderr, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect
from math import atan2, pi

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

p = []

N = read()

for _ in range(N):
  (x, y) = reads()
  p.append((x, y))

for i in range(N):
  (x, y) = p[i]
  (b1, e1) = (0, pi)
  (b2, e2) = (pi, 2*pi)

  for j in range(N):
    if j == i:
      continue

    (z, w) = p[j]
    th = (atan2(w - y, z - x) + pi / 2) % (2*pi)

    if th <= pi:
      b1 = max(b1, th)
      e2 = min(e2, th + pi)
    else:
      e1 = min(e1, th - pi)
      b2 = max(b2, th)
  result = (max(0, e1-b1) + max(0, e2-b2)) / 2 / pi
  print("{:.20f}".format(result))


Measured memory_bytes: 3812
import math
A, B = map(int, input().split(' '))
for n in range(1, 1001):
    a = int(math.floor(n * 0.08))
    b = int(math.floor(n * 0.1))
    # print(n, a, b)
    if a == A and b == B:
        print(n)
        exit()

print(-1)


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

#define ll long long

int main()
{
    ll n, x, m;
    cin >> n >> x >> m;

    vector<ll> remainderIndices(m, -1);

    vector<ll> beforeCycle;
    ll beforeCycleSum = 0, beforeCycleSize = 0;
    while (remainderIndices[x] == -1)
    {
        beforeCycle.push_back(x);

        remainderIndices[x] = beforeCycleSize++;
        beforeCycleSum += x;
        x = x * x % m;
    }

    ll cycleSize = beforeCycleSize - remainderIndices[x];

    ll totalSum = 0;
    if (n <= cycleSize)
        for (ll i = 0; i < n; i++)
            totalSum += beforeCycle[i];
    else
    {
        ll cycleSum = 0;

        for (ll i = remainderIndices[x]; i < beforeCycleSize; i++)
            cycleSum += beforeCycle[i];

        totalSum = beforeCycleSum;
        n -= beforeCycleSize;
        totalSum += (n / cycleSize) * cycleSum;
        n %= cycleSize;

        for (ll i = 0; i < n; i++)
            totalSum += beforeCycle[remainderIndices[x] + i];
    }

    cout << totalSum << endl;

    return 0;
}


Measured memory_bytes: 4692
// Don't Lose Hope, Nor Be Sad 

#include <bits/stdc++.h>
using namespace std;

  #define lp(start,finish) for(int i=start; i<finish; i++)
  #define read freopen("input.txt","r",stdin);
  #define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

int main(){
	//read
	int cities,road;
	cin >> cities >> road;
	int makeRoad[cities];
	memset(makeRoad, 0, sizeof makeRoad);
	int city1,city2;
	for(int i=0; i<road; i++){
		cin >> city1 >> city2;
		makeRoad[city1-1]++;
		makeRoad[city2-1]++;
	}
	for(int i=0; i<cities; i++){
		cout << makeRoad[i] <<endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }


int n;
string str;
int main() {
  while (cin >> n >> str) {
	int cur = 0;
	int res = 0;
	for (int i = 0; i < n; ++i) {
	  if (str[i] == 'I') ++cur;
	  else --cur;
	  chmax(res, cur);
	}
	cout << res << endl;
  }
}









Measured memory_bytes: 256
N = int(input())

P = [int(input()) for _ in range(N)]

idxs = [0] * N
for i in range(N):
    idxs[P[i]-1] = i



max_cnt = 0
curr = 0
for i in range(N):
    if i == 0:
        max_cnt = 1
        curr = 1
    else:
        
        if idxs[i] > idxs[i-1]:
            curr += 1
            max_cnt = max(max_cnt, curr)
        else:
            curr = 1
    

print(N - max_cnt)


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

int main()
{
	int n;

	cin>>n;
	n--;
	// unsigned long long int sum = n*(n+1);
	unsigned long long int sum = 0;
	// if(n%2==0)
	// {
	// 	sum = (n/2)*(n+1);
	// }
	// else
	// {
	// 	sum = n*((n+1)/2); 
	// }

	for(int i=1;i<=n;++i)	sum+=i;

	cout<<sum<<"\n";

	return 0;
}

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

#define y1 aklsdja
#define ii pair < int , int >
#define iii pair < int , ii >
#define iv pair < ii , ii >

#define fi first
#define se second
#define pb push_back
#define t top()
#define fr front()

#define FOR(i , x , n) for(int i = x ; i <= n ; ++i)
#define REP(i , x) for(int i = 0 ; i < x ; ++i)
#define FORD(i , x , n) for(int i = x ; i >= n ; --i)

#define oo 1e9
#define ll long long
#define int long long

const int N = 1e5 + 5;
int n , mod;
int dp[N] , suffix[N] , prefix[N] , ans[N];
vector < int > g[N];

/// dp[i] là số cách để tổ cho cây con gốc i thỏa mãn đề và đỉnh i màu đen.

void DFS1(int i , int j)
{
    dp[i] = 1;
    REP(s , g[i].size())
    {
        int u = g[i][s];
        if(u != j)
        {
            DFS1(u , i);
            dp[i] = (dp[i] * (dp[u] + 1)) % mod;
        }
    }
}

int getpre(int u , int v , int s)
{
    if(s >= 1 && g[u].size() >= 1 && g[u][s - 1] != v)
        return g[u][s - 1];
    if(s >= 2 && g[u].size() >= 2 && g[u][s - 2] != v)
        return g[u][s - 2];
    return 0;
}

int getsuf(int u , int v , int s)
{
    int x = g[u].size();
    x -= 2;
    if(s <= x && g[u].size() >= 1 && g[u][s + 1] != v)
        return g[u][s + 1];
    if(s <= x - 1 && g[u].size() >= 2 && g[u][s + 2] != v)
        return g[u][s + 2];
    return 0;
}

void DFS2(int i , int j , int val)
{
    ans[i] = (dp[i] * val) % mod;
    REP(s , g[i].size())
    {
        int u = g[i][s];
        if(u != j)
        {
            int v = getpre(i , j , s);
            prefix[u] = (prefix[v] * (dp[u] + 1)) % mod;
        }
    }
    int x = g[i].size();
    FORD(s , x - 1 , 0)
    {
        int u = g[i][s];
        if(u != j)
        {
            int v = getsuf(i , j , s);
            suffix[u] = (suffix[v] * (dp[u] + 1)) % mod;
        }
    }
    REP(s , g[i].size())
    {
        int u = g[i][s];
        if(u != j)
        {
            int x = getpre(i , j , s) , y = getsuf(i , j , s);
            DFS2(u , i , (((prefix[x] * suffix[y]) % mod) * val + 1) % mod);
        }
    }
}

main()
{
    //freopen("V.inp","r",stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> mod;
    FOR(i , 1 , n - 1)
    {
        int x , y;
        cin >> x >> y;
        g[x].pb(y);
        g[y].pb(x);
    }
    prefix[0] = 1;
    suffix[0] = 1;
    DFS1(1 , -1);
    DFS2(1 , -1 , 1);
    FOR(i , 1 , n)
        cout << ans[i] << "\n";
}


Measured memory_bytes: 16768
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from collections import deque
# queueとして使う場合 push, popleftを使う
from bisect import bisect_left, bisect_right
# bisect_left: 配列の順序関係が崩れない条件で挿入することができる一番左の点
# bisect_right: 配列の順序関係が崩れない条件で挿入することができる一番右の点
# A = [1, 1, 1, 2, 2, 2, 4]
# print(bisect_left(A, 2))  # 3
# print(bisect_right(A, 2))  # 6
# print(bisect_left(A, 3))  # 6
# print(bisect_right(A, 3))  # 6


def main():
    N = int(input())
    S = input()
    most_left = {i: -1 for i in range(10)}
    for i in range(len(S)):
        s = int(S[i])
        if most_left[s] == -1:
            most_left[s] = i
    
    wholes = [False] * 1000
    sum_ = 0
    
    for i, first_idx in most_left.items():
        if first_idx == -1:
            continue
        alreadys = [False] * 10
        for second_idx in range(first_idx + 1, N):
            if alreadys[int(S[second_idx])]:
                continue
            alreadys[int(S[second_idx])] = True
            for third_idx in range(second_idx + 1, N):
                number = int(S[first_idx] + S[second_idx] + S[third_idx])
                if wholes[number] is False:
                    wholes[number] = True
                    sum_ += 1
    print(sum_)



        




if __name__ == '__main__':
    main()


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;

    if (a == b)
        cout << c << endl;
    else if (a == c)
        cout << b << endl;
    else
        cout << a << endl;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#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 ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    ll N,M,d; cin >> N >> M >> d;

    ll num = d ? (N-d)*2 : N;
    double ans = double(num)/N/N*(M-1);

    cout << fixed << setprecision(10) << ans << ln;
}

Measured memory_bytes: 256
"""
セグメント木
"""

INF = 10 ** 20

def main():
  n, q = map(int, input().split())
  
  size = 1
  while size < n:
    size *= 2
  size = size * 2 - 1
  
  seg_tree = [(INF, 0) for _ in range(size)]
  
  def update(a, v):
    ind = (size - 1) // 2 + a
    prea, prev = seg_tree[ind]
    seg_tree[ind] = (a + 1, prev + v)

    while ind > 0:
      ind = (ind - 1) // 2
      ca1, cv1 = seg_tree[ind * 2 + 1]
      ca2, cv2 = seg_tree[ind * 2 + 2]
      if cv1 >= cv2:
        seg_tree[ind] = (ca1, cv1)
      else:
        seg_tree[ind] = (ca2, cv2)
        
  
  for i in range(q):
    a, v = map(int, input().split())
    update(a - 1, v)
    print(seg_tree[0][0], seg_tree[0][1])

main()


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

const double pi = acos(-1);
const double eps = 0.000000001;

double a, b, x;

double func(double theta) {
    if (theta > pi / 2.0) {
        return 0.0;
    }
    double r;
    if (b / tan(theta) > a) {
        r = a * a * b - a * a * a * tan(theta) / 2.0;
    } else {
        r = a * b * b / tan(theta) / 2.0;
    }
    return r;
}

int main() {
    cout << fixed << setprecision(10);
    cin >> a >> b >> x;
    double ok =  0.0;
    double ng = pi / 2.0;
    rep(i, (int)1e6) {
        double mid = (ok + ng) / 2.0;
        if (func(mid) >= x) ok = mid;
        else ng = mid;
    }
    cout << ok / pi * 180 << endl;
}

Measured memory_bytes: 4140
#include<iostream>  
#include<cstring>  
#include<string>  
#include<cstdio>  
#include<cmath>  
#include<vector>  
#include<queue>  
#include<algorithm>  
using namespace std;
#define inf 0x3f3f3f3f  
#define ll long long  
const int maxn = 1e5 + 500;
int main()
{
	ll a[5],k;
	cin >> a[0] >> a[1] >> a[2] >> k;
	ll sum = 0;
	sort(a, a + 3);
	sum += a[0] + a[1];
	ll tmp = a[2];
	while (k--) 
		tmp <<=1;
	cout << sum + tmp;
	return 0;
}

Measured memory_bytes: 256
def input_from_console():
    a, p = map(int, input().split())
    return a, p


def solve(a, p):
    import math
    total_slice = a * 3 + p
    result = math.floor(total_slice / 2)
    return result


def main():
    a, p = input_from_console()
    print(solve(a, p))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()


Measured memory_bytes: 2940
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,m,k,a[200005],b[200005];
int32_t main(){
CODE_START;
cin>>n>>m>>k;
for(ll i=1;i<=n;i++)
{
    ll x;
  cin>>a[i];
  a[i]+=a[i-1];
}
for(ll i=1;i<=m;i++)
{
    cin>>b[i];
    b[i]+=b[i-1];
}
ll ans=0;
for(ll i=0;i<=n;i++)
{
ll sum=a[i];
if(sum>k){
    break;
}
ll l=0,r=m,rs=0;
while(l<=r){
    ll mid=(l+r)/2;
    if(sum+b[mid]<=k){
        rs=max(rs,mid);
        l=mid+1;
    }else r=mid-1;
}
ans=max(ans,rs+i);
}
cout<<ans<<endl;
}


Measured memory_bytes: 6736
def div(x):
    D = set()
    d = 1
    while d*d <= x:
        if x % d == 0:
            D.add(d)
            D.add(x//d)
        d += 1
    return D


n = int(input())
cnt = 0
for d in div(n) | div(n-1):
    if d == 1:
        continue
    tmp = n
    while tmp % d == 0:
        tmp = tmp // d
    if tmp % d == 1:
        cnt += 1
print(cnt)


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

int main(){long long X, Y;
cin >> X >> Y;
int cnt = 0;
while(X < Y){
    X *= 2;
    cnt++;
}
if(X == Y) cnt++;

cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 256
/* Dsingh_24 */

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define	endl		'\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define rep(i,a,b)	for(ll int i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define ios	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

#define N  100005

int main()
{
	ios
	string a="ABC",b="ARC",s;
	cin>>s;
	if(s==a)cout<<b;else cout<<a;
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v)
{
    int sz = v.size();
    for (int i = 0; i < sz; i++)
    {
        cout << v[i] << " \n"[i == sz - 1];
    }
}

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << a * b / 2 << endl;
}


Measured memory_bytes: 256