akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(ll i = (ll)(a); i <= (ll)(b); i++)
#define NFOR(i,a,b) for(ll i = (ll)(a); i >= (ll)(b); --i)
#define rep(i, a) for (ll i = 0; i < a; i++)
#define endl "\n"
#define fi first
#define se second
#define MOD 1000000007
#define inf 1e12
#define pb push_back
#define Case cout<<"Case #"<<++cas<<": ";
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define all(v) v.begin(),v.end()

typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;

#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
template <class T> void dbs(string str, T t) {cerr << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {int idx = str.find(','); cerr << str.substr(0, idx) << " : " << t << ","; dbs(str.substr(idx + 1), s...);}
template <class S, class T>ostream& operator <<(ostream& os, const pair<S, T>& p) {return os << "(" << p.first << ", " << p.second << ")";}
template <class T>ostream& operator <<(ostream& os, const vector<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T>ostream& operator <<(ostream& os, const multiset<T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class S, class T>ostream& operator <<(ostream& os, const map<S, T>& p) {os << "[ "; for (auto& it : p) os << it << " "; return os << "]";}
template <class T> void prc(T a, T b) {cerr << "["; for (T i = a; i != b; ++i) {if (i != a) cerr << ", "; cerr << *i;} cerr << "]\n";}

void dfs(ll u, vl adj[], vector<bool> &vis, vector<ll> &topo)
{
	vis[u] = true;

	for (auto &v : adj[u])
		if (not vis[v])
			dfs(v, adj, vis, topo);

	topo.push_back(u);
}

void solve() {
	ll n, m;
	cin >> n >> m;
	vl adj[n];
	rep(i, m) {
		ll u, v;
		cin >> u >> v;
		u--,v--;
		adj[u].pb(v);
	}

	vector<bool> vis(n, false);
	vl topo;
	rep(i, n)
		if (not vis[i])
			dfs(i, adj, vis, topo);

	assert(topo.size() == n);
	// pr(topo);
	vl dp(n, 0);
	NFOR(i, n - 1, 0)
		for (auto &v : adj[topo[i]])
			dp[v] = max(dp[v], dp[topo[i]] + 1);

	cout << *max_element(all(dp)) << endl;
}

int main()
{
    fastio;
    ll t  = 1;
    // cin >> t;
    while (t--) {
        solve();
    }
}


Measured memory_bytes: 10868
#include <iostream>

using namespace std;

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a>b){
        swap(a,b);
    }
    if(b>c){
        swap(b,c);
    }
    if(a>b){
        swap(a,b);
    }
    cout << a << " " << b << " " << c << endl;
    return 0;
}



Measured memory_bytes: 3088
#include<stdio.h>
int main()
{
  int n,a[100],k,i,t,b;
  while(1){
    t=0;
  scanf("%d",&n);
  if(n==0)break;
 for(i=0;i<n;i++){
    scanf("%d",&a[i]);
 }
 for(k=0;k<n;k++){
 for(i=0;i<n-1;i++){
   if(a[i]>a[i+1]){
     t=t+1;
     b=a[i+1];
     a[i+1]=a[i];
     a[i]=b;
 }
 }
 }
 printf("%d\n",t);
  }
 return 0;
}

Measured memory_bytes: 600
import fractions
n = int(input())
a = list(map(int,input().split(" ")))
l = [0 for i in range(n+1)]
r = [0 for i in range(n+1)]
for i in range(n):
    l[i+1] = fractions.gcd(l[i],a[i])

for i in range(n-1,-1,-1):
    r[i] = fractions.gcd(r[i+1],a[i])



m = 1
for i in range(n):
    m = max(m,fractions.gcd(l[i],r[i+1]))
print(m)

Measured memory_bytes: 16068
#include <iostream>
#include <cmath>
#include <string>
#include <cstdlib>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cctype>
#include <map>
#include <cstring>
#include <typeinfo>
#define REP(i,n) for(int i = 0;i < n ;i++)
#define FOR(i,m,n) for(int i= m ;i<n;i++)
using namespace std;

int main(void){
  long long a,b,x,sum=0;
  cin >> a >> b >> x;
  sum=b/x+1;
  if(a>0)sum-=(a-1)/x+1;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll t,sum=0;
  string s;
  map<string,int> m;
  map<string, int>::iterator itr; 
  cin >> t;
  for(int i=0;i<t;i++)
  {
    cin >> s;
    sort(s.begin(),s.end());
    if(m[s]==0)  m[s]=1;
    else m[s]++;
  }
  for(itr = m.begin();itr!=m.end();itr++)
  {
    ll n = itr->second -1;
    sum +=  ((n*(n+1))/2);
  }
  cout <<sum;
}

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

int main(){
  int N;
  cin >> N;
  vector<int>H(N);
  for (int i = 0; i < N; i++){
    cin >> H[i];
  }
  int ans = 0;
  for (int i = 0; i < N; i++){
    bool is_candidate = true;
    for (int j = 0; j < i; j++){
      if (H[j] > H[i]){
        is_candidate = false;
          break;
      }
    }
    if (is_candidate){
      ans++;
    }
  }
  cout << ans << endl;      
             
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		stoneMonument();
	}
	
	public static void stoneMonument() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int cur = 0;
		int pre = 0;
		for (int i=1; i<1000; i++) {
			pre = cur;
			cur += i;
			if ((cur - b) >= 0 && (cur - b) == (pre - a)) {
				System.out.println(cur-b);
				return;
			}
		}
	}
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(void)
{
  int N;
  double k;
  scanf("%d",&N);
  if(N%2==0){
    k=(double)1/2;
  }else{
    k=(double)(N+1)/(N*2);
  }
  
  printf("%lf",k);
  
  return 0;
}

Measured memory_bytes: 128
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	static PrintWriter out;
	static StringBuilder sb;
	static int inf = (int) 1e9;
	static long mod = 998244353;
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		out = new PrintWriter(System.out);
		int n=sc.nextInt();
		long h=sc.nextLong();
		long [] a=new long[n];
		long [] b=new long[n];
		long maxa=0;
		for(int i=0;i<n;i++) {
			maxa=Math.max(a[i]=sc.nextInt(),maxa);
			b[i]=sc.nextInt();
		}
		Arrays.sort(a);
		Arrays.sort(b);
		long ans=0;
		long sum=0;
	    for(int i=n-1;i>=0;i--) {
	    	if(sum>=h) {
	    		System.out.println(ans);
	    		return;
	    	}
	    	sum+=Math.max(b[i], maxa);
	    	ans++;
	    }
	    if(sum>=h) {
    		System.out.println(ans);
    		return;
    	}
	    ans+=(h-sum)/maxa;
	    if((h-sum)%maxa!=0)
	    	ans++;
		out.println(ans);
		out.close();
	}
	static int gcd(int a, int b) {

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

	static class unionfind {
		int[] p;
		int[] size;

		unionfind(int n) {
			p = new int[n];
			size = new int[n];

			for (int i = 0; i < n; i++) {
				p[i] = i;
			}
			Arrays.fill(size, 1);
		}

		int findSet(int v) {
			if (v == p[v])
				return v;
			return p[v] = findSet(p[v]);
		}

		boolean sameSet(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return true;
			return false;
		}

		int max() {
			int max = 0;
			for (int i = 0; i < size.length; i++)
				if (size[i] > max)
					max = size[i];
			return max;
		}

		void combine(int a, int b) {
			a = findSet(a);
			b = findSet(b);
			if (a == b)
				return;
			if (size[a] > size[b]) {
				p[b] = a;
				size[a] += size[b];

			} else {
				p[a] = b;
				size[b] += size[a];
			}
		}
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}

		public Scanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

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

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public char nextChar() throws IOException {
			return next().charAt(0);
		}

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

		public boolean ready() throws IOException {
			return br.ready();
		}

		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}

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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }
  
  else{
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;
const double PI=3.1415926;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	double n;

	cin>>n;

	cout<<2*n*PI<<endl;

	return 0;

}


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

int digits(int x) {
    int result = 0;
    while (x) {
        result++;
        x /= 10;
    }
    return result;
}

int main() {
    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i++) {
        if (digits(i) % 2 == 1) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3556
#include <iostream>
#include <utility>
#include <map>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <array>
#include <math.h>
#include <numeric>
#include <sstream>
#include <queue>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    ll c4 = 0ll;
    ll codd = 0ll;
    REP(i,n) {
        if (a[i]%4==0) c4++;
        else if(a[i]%2==1) codd++;
    }
    if ((c4+codd)/2 <= c4) {
        if ((c4+codd)%2==0) cout << "Yes" << std::endl;
        else {
            if (c4+codd==n) cout << "Yes" << std::endl;
            else cout << "No" << std::endl;
        }
    }
    else if (codd==0) cout << "Yes" << std::endl;
    else cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

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

int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using pLL = std::pair<long long, long long>;
using ll = long long;
#define SORT(v) std::sort(v.begin(), v.end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b, q;
    cin >> a >> b >> q;
    vector<ll> s, t;
    s.push_back(-LINF);
    t.push_back(-LINF);
    for (int i = 0; i < a; ++i) {
        ll in;
        cin >> in;
        s.push_back(in);
    }
    s.push_back(LINF);
    for (int i = 0; i < b; ++i) {
        ll in;
        cin >> in;
        t.push_back(in);
    }
    t.push_back(LINF);
    

    vector<ll> res;
    for (int i = 0; i < q; ++i) {
        ll x;
        cin >> x;
        auto shrine = lower_bound(s.begin(), s.end(), x);
        auto temple = lower_bound(t.begin(), t.end(), x);
        vector<ll> temp1, temp2;
        temp1.push_back(*(shrine - 1));
        temp1.push_back(*shrine);
        temp2.push_back(*(temple - 1));
        temp2.push_back(*temple);
        ll ans = LINF;
        for (int j = 0; j < 2; ++j) {
            for (int k = 0; k < 2; ++k) {
                ll dis1, dis2;
                dis1 = abs(temp1[j] - x) + abs(temp2[k] - temp1[j]);
                dis2 = abs(temp2[k] - x) + abs(temp1[j] - temp2[k]);
                ans = min(ans, min(dis1, dis2));
            }

        }
        res.push_back(ans);
        
    }
    for (int i = 0; i < q; ++i) {
        cout << res[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))

using namespace std;
typedef pair<llint, llint> P;

llint n;
llint a[100005], b[100005];
P p[100005];
llint pos[100005], sum[100005], S;

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

P getmax(P p, P q)
{
	if(p.first/p.second < q.first/q.second) return q;
	if(p.first/p.second > q.first/q.second) return p;
	
	llint P = p.first % p.second, Q = q.first % q.second;
	if(P*q.second <= Q*p.second) return q;
	else return p;
}

P reduce(P p)
{
	if(p.first == 0) return P(0, 1);
	llint g = gcd(p.first, p.second);
	p.first /= g, p.second /= g;
	return p;
}

P calc(llint i)
{
	llint ub = n, lb = -1, mid;
	while(ub-lb>1){
		mid = (ub+lb)/2;
		llint tmp = sum[mid];
		if(i <= mid) tmp -= p[i].first;
		if(tmp >= S-b[p[i].second]) ub = mid;
		else lb = mid;
	}
	
	llint tmp = sum[ub];
	if(i <= ub) tmp -= p[i].first, ub--;
	if(tmp >= S) return P(0, 1);
	
	llint x = n-ub, y = S-tmp;
	P ret = reduce(P(max(0LL, b[p[i].second]*x-y), b[p[i].second]));
	return ret;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> a[i] >> b[i];
		p[i] = P(max(a[i], b[i]), i);
	}
	sort(p+1, p+n+1);
	reverse(p+1, p+n+1);
	
	for(int i = 1; i <= n; i++){
		sum[i] = sum[i-1] + p[i].first;
		S += a[i];
	}
	
	P ans = P(0, 1);
	for(int i = 1; i <= n; i++) ans = getmax(ans, calc(i));
	ans.second *= n;
	ans = reduce(ans);
	cout << ans.first << " " << ans.second << endl;
	
	return 0;
}

Measured memory_bytes: 7572
#include <iostream>
#include <vector>
#include <queue>

using namespace std;
typedef long long LL;

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

    vector< vector<int> > jobs(M+1);

    for (int i = 0; i < N; ++i) {
        int A, B;
        cin >> A >> B;
        if (A <= M) {
            jobs[A].push_back(B);
        }
    }

    LL ans = 0;
    priority_queue<int> payableJobs;
    for (int r = 1; r <= M; ++r) {
        for (int b : jobs[r]) {
            payableJobs.push(b);
        }
        if (!payableJobs.empty()) {
            ans += payableJobs.top();
            payableJobs.pop();
        }
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

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

  long long n;
  cin >> n;
  long long ans = 0;
  for (int i = 2; 1ll * i * i <= n; ++i) {
    if (n % i == 0) {
      int lst = 0, cur = 0;
      while (n % i == 0) {
        n /= i;
        ++cur;
        if (cur == lst + 1) {
          ++ans;
          ++lst;
          cur = 0;
        }
      }
    }
  }
  if (n > 1) {
    ++ans;
  }
  cout << ans;

  return 0;
}


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

#ifndef ONLINE_JUDGE
	#define W(x, y) cerr << "\033[31m" << #x << " = " << x << "\033[0m" << y;
#else
	#define W(x, y)
#endif

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vii vector<pii>
#define vl vector<ll>
#define vll vector<pll>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define pi acosl(-1)
#define ld long double
#define prime (1000000000 + 7)
#define INF 1000000000

using namespace std;

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

	char c;
	cin >> c;
	c++;
	cout << c << endl;
	

	return 0;
}


Measured memory_bytes: 256
def is_divisor_8(num):
  cnt = 0
  for i in range(1,num+1):
    if num%i == 0: cnt += 1
    if cnt > 8: return False
  if cnt == 8: return True
  else: return False

N = int(input())
ans = 0
for i in range(1,N+1,2):
  if is_divisor_8(i) is True:
    ans += 1
print(ans)

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int l = sc.nextInt();
		int r = sc.nextInt();
		int d = sc.nextInt();
		int multiplier = 1;
		int ans = 0;
		int temp = d;
		while(temp <= r) {
			temp = d *  multiplier;
			if(temp <= r && temp >= l) {
				ans++;
			}
			multiplier++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35172
#include<iostream>
#include<algorithm>
using namespace std;
int d[100005];
int main()
{	ios::sync_with_stdio(false);
	int i,j,n;
	cin>>n;
	for(i=1;i<=n;i++)
		cin>>d[i];
	sort(d+1,d+n+1);
	printf("%d", d[(n >> 1) + 1] - d[n >> 1]);

}

Measured memory_bytes: 640
x,n=map(int,input().split())
lp=list(map(int,input().split()))
if n==0:
    result=x
a=x
b=x
while True:
    if a not in lp and b not in lp:
        result=a
        break
    elif a not in lp:
        result=a
        break
    elif b not in lp:
        result=b
        break
    a-=1
    b+=1
print(result)


Measured memory_bytes: 9188
#include<bits/stdc++.h>
#define maxn 2010
using namespace std;
int dp[maxn][2],a[maxn];
int main()
{
    int n,z,w;
    cin>>n>>z>>w;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=0;i<n/2;i++)swap(a[i],a[n-1-i]);
    memset(dp,0x3f3f3f3f,sizeof(dp));
    if(n>1)
    {
        dp[1][0]=abs(a[1]-a[0]);
        dp[1][1]=abs(a[1]-a[0]);
    }
    for(int i=2;i<n;i++)
    {
        dp[i][0]=abs(a[i]-a[0]);
        for(int j=1;j<i;j++)dp[i][0]=max(dp[j][1],dp[i][0]);
        dp[i][1]=abs(a[i]-a[0]);
        for(int j=1;j<i;j++)dp[i][1]=min(dp[j][0],dp[i][1]);
    }
    int mx=0;
    for(int i=1;i<n;i++)mx=max(mx,dp[i][1]);
    if(abs(w-a[0])>mx)mx=abs(w-a[0]);
    cout<<mx<<endl;
return 0;
}


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

using namespace std;

const int M = 1e9+7;

int n;
string s;

long long dp[3005][3005];

int main()
{
  cin >> n >> s;
  
  dp[1][1] = 1;

  for (int i = 1; i < n; i++) {
    long long sum = 0;
    if (s[i-1] == '<') {
      for (int j = 2; j <= i+1; j++) {
        sum = (sum + dp[i][j-1]) % M;
        dp[i+1][j] = sum;
      }
    } else {
      for (int j = i; j >= 1; j--) {
        sum = (sum + dp[i][j]) % M;
        dp[i+1][j] = sum;
      }
    }
  }

  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans = (ans + dp[n][i]) % M;
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 68992
#include<stdio.h>

int main() 
{
    long int a,b,c,k,sum=0;
    scanf("%ld %ld %ld %ld",&a,&b,&c,&k);
    for(int i=1;i<=a && k>0;i++,k--)
    {
        sum+=1;
    }
    for(int i=1;i<=b && k>0;i++,k--)
    {
        sum=sum+0;
    }
    for(int i=1;i<=c && k>0;i++,k--)
    {
        sum+=(-1);
    }
    printf("%ld\n",sum);
}    
    

Measured memory_bytes: 1732
import sys
input = sys.stdin.buffer.readline


def sum_of_floor(n, m, a, b):
    """sum_{i = 0..n-1} (ai + b) // m を求める。"""
    ans = 0
    if a >= m:
        ans += (n - 1) * n * (a // m) // 2
        a %= m
    if b >= m:
        ans += n * (b // m)
        b %= m

    y_max = (a * n + b) // m
    x_max = y_max * m - b
    if y_max == 0:
        return ans
    ans += (n - (x_max + a - 1) // a) * y_max
    ans += sum_of_floor(y_max, a, m, (a - x_max % a) % a)
    return ans


t = int(input())
for _ in range(t):
    n, m, a, b = map(int, input().split())

    ans = sum_of_floor(n, m, a, b)
    print(ans)

Measured memory_bytes: 78716
import sys
read = sys.stdin.read

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


def count(d, k):
  if k == 0:
    return 1
  elif k == 1:
    return d
  elif k == 2:
    return d * (d - 1) // 2
  else:
    return d * (d - 1) * (d - 2) // 6


def solve(n, k):
  if n == 0 and k > 0:
    return 0
  if k == 0:
    return 1
  digit = len(str(n))
  res = 0
  if digit > k:
    res += count(digit - 1, k) * (9 ** k)
  a = 10 ** (digit - 1)
  d, mod = n // a, n % a
  res += count(digit - 1, k - 1) * (9 ** (k - 1)) * (d - 1)
  res += solve(mod, k - 1)
  return res


print(solve(n, k))

Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const long long MAXN=1000005;
long long n,q;
long long a[MAXN],s[MAXN],c[MAXN],ans[MAXN],tot;
int main()
{
	//freopen("seq.in","r",stdin);
	//freopen("seq.out","w",stdout);
	scanf("%lld %lld",&n,&q);
	a[tot=1]=n;
	for(long long i=1;i<=q;i++)
	{
		long long x;
		scanf("%lld",&x);
		while(tot&&a[tot]>=x)
			tot--;
		a[++tot]=x;
	}
	q=tot;
	s[q]=1;
	for(long long i=q;i>=1;i--)
	{
		long long l=a[i];
		long long p=i-1;
		while(p)
		{
			s[p]+=(l/a[p])*s[i];
			l%=a[p];
			p=lower_bound(a+1,a+p,l)-a-1;
		}
		ans[l]+=s[i];
	}
	for(long long i=n;i>=1;i--)
		ans[i]+=ans[i+1];
	for(long long i=1;i<=n;i++)
		printf("%lld\n",ans[i]);
}

Measured memory_bytes: 8576
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define forin(x,y) for(ll i=x;i<y;i++)
#define vii vector<ll>
#define pii  pair<ll,ll>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define inf 1e17
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set =
    tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void evaluate()
{
    ;
}
int main()
{
    ios::sync_with_stdio(false);    cin.tie(0);     cout.tie(0);
    double n;
    cout.precision(16);
    cin>>n;
    double pi = (double)355 / (double)113;
    cout<<2*n*pi<<endl;
}


Measured memory_bytes: 3780
# -*- coding: utf-8 -*-
S = str(input())

odd_list = ["R", "U", "D"]
even_list = ["L", "U", "D"]

ans = "Yes"
for i in range(len(S)):
    if (i + 1) % 2 == 0:
        if S[i] in even_list:
            continue
        else:
            ans = "No"
    else:
        if S[i] in odd_list:
            continue
        else:
            ans = "No"

print(ans)

Measured memory_bytes: 3064
a, b, c, x = 4.times.map { |i| gets.to_i }

count = 0
(a+1).times do |d|
  (b+1).times do |e|
    (c+1).times do |f|
      count += 1 if (d * 500 + e * 100 + f * 50) == x
    end
  end
end

puts count


Measured memory_bytes: 14140
#include <iostream>
#include <cstdio>
#include <algorithm>
#define PII pair<ll, ll>

using namespace std;

typedef long long ll;

ll n, t;
PII c[3005];
ll a, b;
ll d[6005];
ll mx;

int main()
{
    scanf("%lld%lld", &n, &t);
    t--;
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld%lld", &c[i].first, &c[i].second);
    }
    sort(c, c + n);
    for(ll i = 0; i < n; i++)
    {
        a = c[i].first, b = c[i].second;
        for(ll j = t; j >= 0; j--)
        {
            d[j + a] = max(d[j + a], d[j] + b);
            mx = max(mx, d[j + a]);
        }
    }
    printf("%lld", mx);
    return 0;
}


Measured memory_bytes: 384
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;

int main() {
#ifdef DEBUG
    freopen("input.txt", "r", stdin);
#else
    //    freopen("zalupa.in","r",stdin);
    //    freopen("zalupa.out","w",stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(20);
    cout << fixed;
    int n, m, k;
    cin >> n >> m >> k;
    vector<string> s(n);
    vector<bool> det(n, false);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (int j = 0; j < m; ++j) {
            if (s[i][j] == '#') {
                det[i] = true;
            }
        }
    }
    vector<vector<int>> res(n, vector<int>(m, 0));
    int cnt = 1;
    for (int i = 0; i < n; i++) {
        if (!det[i]) {
            continue;
        }
        int j = 0;
        while (s[i][j] == '.') {
            res[i][j] = cnt;
            ++j;

        }
        res[i][j] = cnt;
        ++j;
//        cout<< j;
//        return 0;
        for (int j1 = j; j1 < m; ++j1) {
            if (s[i][j1] == '#') {
                cnt++;
            }
            res[i][j1] = cnt;
        }
        cnt++;
    }
    int j = 0;
    while (det[j] != 1) {
        ++j;
    }
    for (int i = 0; i < j; ++i) {
        res[i]= res[j];
    }
    vector<int> loc = res[j];
    for (int i = j; i < n; i++) {
        if (det[i] == 1) {
            loc = res[i];
        } else {
            res[i] = loc;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; ++j) {
            cout << res[i][j] << " ";
        }
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define repr(i, a, b) for(int i = b-1; i >= a; i--)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

////////////////////////////////////////////////////////
// 左(自分を含む)にある#の個数、右にある.の個数
ll cntl[300000], cntr[300000];

int main() {
    ll n; cin >> n;
    string s; cin >> s;

    rep(i, 0, n){
        if(s[i] == '#') cntl[i]++;
        cntl[i+1] += cntl[i];
    }
    repr(i, 1, n){
        if(s[i] == '.') cntr[i-1]++;
        if(i != 1) cntr[i-2] += cntr[i-1];
    }
    ll ans = 300000;
    rep(i, 0, n){
        chmin(ans, cntl[i]+cntr[i]);
    }
    if(s[0] == '.') cntr[0]++;
    chmin(ans, cntr[0]);
    co(ans);

    return 0;
}




Measured memory_bytes: 6872
import java.util.*;

class Main{

    public static void main(String args[]) throws Exception{
        Main main = new Main();
    }

    public Main(){
        Scanner scanner = new Scanner(System.in);
        int N,K;
        N = Integer.parseInt(scanner.next());
        K = Integer.parseInt(scanner.next());

        long[] H = new long[N];
        for(int i=0;i<N;i++){
            H[i] = scanner.nextLong();
        }

        Arrays.sort(H);

        long result = 0;

        for(int i=0;i<N-K;i++){
            result += H[i];
        }

        System.out.println(result);
    }
}


Measured memory_bytes: 87116
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))

from collections import defaultdict, deque
from sys import exit
import math
import copy
from bisect import bisect_left, bisect_right
from heapq import *
import sys
# sys.setrecursionlimit(1000000)
INF = 10 ** 17
MOD = 1000000007

from fractions import *
def inverse(f):
    # return Fraction(f.denominator,f.numerator)
    return 1/f


def combmod(n, k, mod=MOD):
    ret = 1
    for i in range(n - k + 1, n + 1):
        ret *= i
        ret %= mod

    for i in range(1, k + 1):
        ret *= pow(i, mod - 2, mod)
        ret %= mod

    return ret
def bunsu(n):
    ret = []
    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            tmp = 0
            while(True):
                if n % i == 0:
                    tmp += 1
                    n //= i
                else:
                    break
            ret.append((i, tmp))

    ret.append((n, 1))
    return ret

def solve():
    lim = 10 ** 18
    n = getN()
    nums = getList()
    if 0 in nums:
        print(0)
        return
    ans = 1
    for num in nums:
        ans *= num
        if ans > lim:
            print(-1)
            return

    print(ans)
def main():
    # n = getN()
    # for _ in range(n):
    solve()
if __name__ == "__main__":
    solve()


Measured memory_bytes: 87264
#include<iostream>
#include<string.h>
using namespace std;
int main(void){
    string str;
    cin>>str;
    int length=str.length();

    if(str[length-1]=='s'){
        cout<<str<<"es"<<endl;
    }else{
        cout<<str<<"s"<<endl;
    }

    return 0;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b){
        cout << c << endl;
    }else if(b==c){
        cout << a << endl;
    }else{
        cout << b << endl;
    }
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n,m;
  cin>>n>>m;
  int d[n*2],t[n*2];
  for(int i=0;i<n*2;i++) d[i]=i+1;
  for(int i=0,k;i<m;i++){
    cin>>k;
    if(k==0){
      for(int i=0;i<n;i++){
	t[i*2]=d[i];
	t[i*2+1]=d[n+i];
      }
    }else{
      for(int i=0;i<k;i++){
	t[n*2-k+i]=d[i];
      }
      for(int i=k;i<n*2;i++){
	t[i-k]=d[i];
      }
    }
    for(int i=0;i<n*2;i++) d[i]=t[i];
  }
  for(int i=0;i<n*2;i++) cout<<d[i]<<endl;
  return 0;
}

Measured memory_bytes: 3084
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
macro_rules! input {(source=$s:expr,$($r:tt)*) => {let mut iter=$s.split_whitespace(); let mut next=||{iter.next().unwrap()}; input_inner! {next,$($r)*}};($($r:tt)*) => {let stdin=std::io::stdin();let mut bytes=std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next=move||->String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()}; input_inner! {next,$($r)*}};}
#[allow(unused_macros)]
macro_rules! input_inner {($next:expr) => {}; ($next:expr,) => {}; ($next:expr,$var:ident:$t:tt$($r:tt)*) => {let $var=read_value!($next,$t); input_inner! {$next$($r)*}};}
#[allow(unused_macros)]
macro_rules! read_value {($next:expr,($($t:tt),*)) => {($(read_value! ($next,$t)),*)}; ($next:expr, [$t:tt; $len:expr]) => {(0..$len).map(|_|read_value! ($next,$t)).collect::<Vec<_>>()}; ($next:expr,chars) => {read_value! ($next,String).chars().collect::<Vec<char>>()}; ($next:expr,usize1) => {read_value! ($next,usize)-1}; ($next:expr,$t:ty) => {$next().parse::<$t>().expect("Parse error")};}

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> {
    fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering {
        self.0.partial_cmp(&other.0).unwrap()
    }
}

#[allow(dead_code)]
const MAX: usize = 100006;
#[allow(dead_code)]
const INF_U32: u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32: i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64: u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64: i64 = 1 << 62;
#[allow(dead_code)]
const MOD: i64 = 1e9 as i64 + 7;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

#[allow(unused_imports)]
use std::f64;


fn main() {
    input!{n:i64, a:i64, b:i64};
    if a > b {
        println!("0");
        return();
    }
    if n == 1 {
        if a != b {
            println!("0");
        } else {
            println!("1");
        }
        return();
    }
    println!("{}", (n-2)*b - (n-2)*a + 1);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=1LL<<60;
const double EPS = 1e-10;
const ll mod=1000000007;

int main(void){
    ll k;
    cin>>k;
    queue<ll> q;
    vector<ll> v;
    for(ll i=1;i<=9;i++){
        q.push(i);
        v.push_back(i);
    }
    while(1){
        ll x=q.front();
        q.pop();
        ll y=x%10,z;
        if(y>=1){
            z=x*10+y-1;
            q.push(z);
            v.push_back(z);
        }
        z=x*10+y;
        q.push(z);
        v.push_back(z);
        if(y<=8){
            z=x*10+y+1;
            q.push(z);
            v.push_back(z);
        }
        if(v.size()>=100010) break;
    }
    cout<<v[k-1]<<endl;
}

Measured memory_bytes: 4636
import sys
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N = int(input())
    A = [0] * N
    B = [0] * N
    for i in range(N):
        A[i], B[i] = map(int, input().split())

    As = sorted(A)
    Bs = sorted(B)

    if N % 2 == 0:
        i1 = N // 2
        i2 = N // 2 - 1
        low = As[i1] + As[i2]
        up = Bs[i1] + Bs[i2]
        ans = up - low + 1
    else:
        i = (N - 1) // 2
        low = As[i]
        up = Bs[i]
        ans = up - low + 1

    print(ans)


if __name__ == '__main__':
    solve()


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

int main(){
    string S;
    cin >> S;
    char a[6];
    for(int i=0; i<6; i++){
        a[i] = S[i];
    }

    if(a[2] == a[3] && a[4] == a[5]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N, T, A;
	cin >> N >> T >> A;
	double sa = 1000000000;
	int id;
	REP(i, N) {
		int H;
		cin >> H;
		double kion = (double)T - H * 0.006;
		double tmp = abs(A - kion);
		if (tmp < sa) {
			id = i + 1;
			sa = tmp;
		}
	}
	cout << id << "\n";

	return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  long long n, a[5];
  cin >> n;
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
  }
  long long mi = *min_element(a, a + 5);
  cout << (n + mi - 1) / mi + 4 << endl;
  return 0;
}

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

using namespace std;

struct Point { int x, y; };

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

    int n;
    cin >> n;

    vector<Point> red(n), blue(n);
    for (int i = 0; i < n; ++i) cin >> red[i].x >> red[i].y;
    for (int i = 0; i < n; ++i) cin >> blue[i].x >> blue[i].y;

    sort(red.begin(), red.end(),
         [](const Point &p1, const Point &p2){ return p1.y >= p2.y; });
    sort(blue.begin(), blue.end(),
         [](const Point &p1, const Point &p2){ return p1.x <= p2.x; });

    int num = 0;
    vector<bool> used(n, false);
    for (const auto &b : blue) {
        for (int i = 0; i < n; ++i) {
            if (!used[i] && red[i].x < b.x && red[i].y < b.y) {
                ++num;
                used[i] = true;
                break;
            }
        }
    }

    cout << num << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>

const int _ = 3e3 + 5, p = 1e9 + 7;

int n, m, a[_], dp[_][_];

inline int power(int x, int k) {
    int res = 1;
    for (; k; k >>= 1, x = 1ll * x * x % p)
        if (k & 1) res = 1ll * res * x % p;
    return res % p;
}

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 1; i <= n; ++i) scanf("%d", a + i);
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= n; ++j) dp[i][j] = a[i] < a[j];
    int inv2 = power(2, p - 2);
    for (int x, y, i = 1; i <= m; ++i) {
        scanf("%d %d", &x, &y);
        dp[x][y] = dp[y][x] = 1ll * inv2 * ((dp[x][y] + dp[y][x]) % p) % p;
        for (int j = 1; j <= n; ++j) {
            if (j == x | j == y) continue ;
            dp[x][j] = dp[y][j] = 1ll * inv2 * ((dp[x][j] + dp[y][j]) % p) % p;
            dp[j][x] = dp[j][y] = 1ll * inv2 * ((dp[j][x] + dp[j][y]) % p) % p;
        }
    }
    int ans = 0;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j < i; ++j) ans = (ans + dp[i][j]) % p;
    ans = 1ll * ans * power(2, m) % p;
    printf("%d\n", ans);
    return 0;
}
//aass

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
#define N_MAX 100000
#define mod 1000000007
long long fac[N_MAX+1];

void init() {
    fac[0] = fac[1] = 1;
    for(int i=1; i<=N_MAX; ++i) fac[i] = (i * fac[i-1]) % mod;
}

int main() {
    init();
    long long N,M;
    cin >> N >> M;
    if(abs(N-M) > 1) cout << 0 << endl;
    else if(N == M) cout << (2 * fac[N] * fac[M]) % mod << endl;
    else cout << (fac[N] * fac[M]) % mod << endl;
}

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

#define int long long

int N, K;
using P = pair<int, int>;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N >> K;

  if ( N <= 10 ) {
    cout << N-1 << endl;    
    for ( int i = 2; i <= N; i++ ) {
      cout << i-1 << " " << i << endl;      
    }
    while ( K-- ) {
      for ( int i = 1; i <= N; i++ ) {
	cout << i << endl;
	string s;
	cin >> s;
	if ( s == "Yes" ) break;	
      }
    }    
  } else {
    vector<P> v;    
    for ( int i = 10; i <= N; i++ ) {
      for ( int j = 0; j < 9; j++ ) {
	if ( i & (1<<j) ) v.push_back(P(i, j+1));	
      }      
    }

    cout << v.size() << endl;
    for ( P p : v ) cout << p.first << " " << p.second << endl;

    while ( K-- ) {
      int ans = 0;
      bool f = false;      
      for ( int i = 0; i < 9; i++ ) {
	cout << i+1 << endl;
	string s;
	cin >> s;
	if ( s == "Yes" ) {
	  f = true;
	  break;	  
	} else if ( s == "Near" ) {
	  ans |= (1<<i);	  
	}
      }

      if ( !f ) {
	cout << ans << endl;
	string s;
	cin >> s;
	assert(s == "Yes");	
      }
    }    
  }  
  
  return 0;
}



Measured memory_bytes: 3308
n, time = map(int, input().split())
list = []
list_ok = []

for i in range(n):
    c, t = map(int, input().split())
    object = [c, t]
    list.append(object)
    
count = 0

for j in range(n):
    if list[j][1] > time:
        continue
    else:
        list_ok.append(list[j][0])
        count += 1

if count == 0:
    print("TLE")
else:
    ans = min(list_ok)
    print(ans)

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

using namespace std;

using ll = long long;

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 q;
  cin >> q;
  while (q--) {
    ll a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);
    if (a + 1 >= b) {
      cout << 2 * a - 2 << endl;
      continue;
    }
    ll lb = 0, ub = b;
    while (ub - lb > 1) {
      ll mid = (lb + ub) / 2;
      if (mid * mid < a * b) {
        lb = mid;
      } else {
        ub = mid;
      }
    }
    if (lb * (lb + 1) >= a * b) {
      cout << 2 * lb - 2 << endl;
      continue;
    }
    cout << 2 * lb - 1 << endl;
  }
}


Measured memory_bytes: 256
import sys
import re
from collections import Counter

chardict = {chr(i):0 for i in range(97, 97+26)}
str1 = sys.stdin.read()
str1 = re.sub('[^a-z]', '', str1.lower())
counter = Counter(str1)
for word in counter:
    chardict[word] = counter[word]
charlist = sorted(chardict.items())
for x in charlist:
    print(x[0] + ' : ' + str(x[1]))

Measured memory_bytes: 6784
#include <cstdio>
 
int main()
{
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);
  int x;
  scanf("%d", &x);
  
  int count = 0;
  while (a >= b) {
    b *= 2;
    count++;
  }
    while (b >= c) {
    c *= 2;
    count++;
  }
  
  if (count <= x)
    printf("Yes\n");
  else
    printf("No\n");
  
  return 0;
}

Measured memory_bytes: 1660
n = int(input())
a = list(map(int, input().split()))
sa = [0]
for ai in a:
    sa.append(sa[-1] + ai)

def binary_search(lo, hi, v):
    while hi - lo > 1:
        mid = (hi + lo) // 2
        if sa[mid] > v:
            hi = mid
        else:
            lo = mid
    return lo

def calc(m1, m2, m3):
    if m1 <= 0 or m2 - m1 <= 0 or m3 - m2 <= 0 or n - m3 <= 0:
        return sa[n]
    values = (sa[m1], sa[m2] - sa[m1], sa[m3] - sa[m2], sa[n] - sa[m3])
    return max(values) - min(values)

ret = sa[n]
for m2 in range(2, n - 1):
    m1 = binary_search(0, m2, sa[m2] // 2)
    m3 = binary_search(m2, n, (sa[n] + sa[m2]) // 2)
    for i1 in (0, 1):
        for i2 in (0, 1):
            for i3 in (0, 1):
                ret = min(ret, calc(m1 + i1, m2 + i2, m3 + i3))
print(ret)


Measured memory_bytes: 90616
#include<stdio.h>
#include<stdlib.h>

//int型ポインタAのメモリ領域をN個確保し，int型の数をN個読み込みAを返す
int* scanArrayInt(int N){
    int* A;
    A = (int*)malloc(sizeof(A[0]) * N);
    int i;
    for(i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    return A;
}

//長さNの配列Aを，行末の空白はなし，改行ありで出力．
void printArray(int N, int* A){
    int i;
    for(i = 0; i < N - 1; i++){
        printf("%d ", A[i]);
    }
    printf("%d\n", A[N - 1]);
}

int selectionSort(int N, int* A){
    int i, j, v;
    int count = 0;
    for(i = 0; i < N - 1; i++){
        int minj = i;
        for(j = i; j < N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(A[minj] < A[i]){
            v = A[i];
            A[i] = A[minj];
            A[minj] = v;
            count++;   
        }
    }
    return count;
}

int main(){
    int N;
    scanf("%d", &N);
    int* A = scanArrayInt(N);
    int count = selectionSort(N, A);
    printArray(N, A);
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 2128
#include<iostream>
  using namespace std;
  int main()
  {
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)  {cout<<c<<endl;return 0;}
    if(b==c)  {cout<<a<<endl;return 0;}
    if(a==c)  {cout<<b<<endl;return 0;}
    return 0;
  }

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(100001);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    b[a[i]]++;
  }
  long long ans = 0;
  for(int i = 0; i <= 100000; i++){
    long long tmp = 0;
    tmp += b[i-1] + b[i] + b[i+1];
    ans = max(tmp, ans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3932
#include<bits/stdc++.h>
#define lowbit(i) ((i)&(-(i)))
#define lson(i) ((i)<<1)
#define rson(i) ((i)<<1|1)
#define sqr(x) ((x)*(x))
#define fi first
#define se second
#define mp(x,y) make_pair((x),(y))
#define pb push_back
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef pair<int,int> pii;
typedef vector<int> vii;
typedef vector<pii> vpi;
typedef queue<int> qii;

const int inf=0x3f3f3f3f;
const int maxn=100007;

int n;
long long a[maxn],b[maxn],c[2*maxn],s[2*maxn],ans;

int main(){
	scanf("%d",&n);
	long long ta=0,tb=0;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i],&b[i]);
		c[i]=a[i];
		c[i+n]=b[i];
		ta+=a[i];
		tb+=b[i];
	}
	ans=min(ta,tb);
	sort(c+1,c+2*n+1);
	for(int i=1;i<=n;i++){
		s[i]=s[i-1]+c[i];
	}
	for(int i=1;i<=n;i++){
		long long x=a[i],y=b[i];
		if(x>y){
			swap(x,y);
		}
		if(lower_bound(c+1,c+2*n+1,x)-c<=n-2){
			if(lower_bound(c+1,c+2*n+1,y)-c<=n-1){
				ans=min(ans,s[n]);
			}
			else{
				ans=min(ans,y+s[n-1]);
			}
		}
		else{
			ans=min(ans,x+y+s[n-2]);
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4096
def main():
  import sys
  b=sys.stdin.buffer
  input=b.readline
  n=int(input())
  d=[0]*n+[1<<c-97for c in input()[:n]]
  for i in range(n-1,0,-1):d[i]=d[i+i]|d[i-~i]
  r=[]
  input()
  for q,a,b in zip(*[iter(b.read().split())]*3):
    i,s=int(a)+n-1,0
    if q<b'2':
      d[i]=1<<b[0]-97
      while i:
        i//=2
        d[i]=d[i+i]|d[i-~i]
      continue
    j=int(b)+n
    while i<j:
      if i%2:
        s|=d[i]
        i+=1
      if j%2:
        j-=1
        s|=d[j]
      i//=2
      j//=2
    r+=bin(s).count('1'),
  print(' '.join(map(str,r)))
main()

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

int main(){
	int y, m, d;
  	char c1, c2;
  	cin >> y >> c1 >> m >> c2 >> d;
    	//cout<< N <<endl;
  		if(m<=4){	 
            cout << "Heisei" << endl;
        }else{
        	cout << "TBD" << endl;
        }

}

Measured memory_bytes: 256
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7


//変数
int N, M, R;
vector<int> r;
vector<vector<ll>> route;




//サブ関数
//入力
void input()
{
	cin >> N >> M >> R;
	route.resize(N, vector<ll>(N, INFL));
	REP(i, R) {
		ll tmp;
		cin >> tmp;
		tmp--;
		r.push_back(tmp);
	}
	ll a, b, c;
	REP(i, M) {
		cin >> a >> b >> c;
		a--;
		b--;
		route[a][b] = route[b][a] = c;
	}
}



//計算
void calc()
{
	REP(k, N)REP(i, N)REP(j, N)if (i != j) {
		route[i][j] = min(route[i][j], route[i][k] + route[k][j]);
	}
	
	ll res = INFL;
	vector<int> permu;
	REP(i, R)permu.push_back(i);
	do {
		ll tmp = 0;
		REP(i, R - 1) {
			tmp += route[r[permu[i]]][r[permu[i + 1]]];
		}
		res = min(res, tmp);
	} while (next_permutation(permu.begin(), permu.end()));
	cout << res << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int a,b,k; cin >> a >> b >> k;
    if(a+2*k-1 > b) for(int i=a; i<=b; i++) cout << i << endl;
    else{
        for(int i=a; i<=a+k-1; i++) cout << i << endl;
        for(int i=b-k+1; i<=b; i++) cout << i << endl;
    }
    
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long A = sc.nextLong()-1;
		long B = sc.nextLong();
		long C = sc.nextLong();
		long D = sc.nextLong();
		//最大公約数
		long plese = (C*D)/gcd(C, D);

		long n = (B-(B/C+B/D))+(B/plese);
		long m = (A-(A/C+A/D))+(A/plese);
		long anser = (n-m);
		System.out.println(anser);
	}
	private static long gcd(long a, long b) {
		if(b==0) {
			return a;
		}
		a = a%b;
		return gcd(b,a);
	}

}


Measured memory_bytes: 22996