akhauriyash/Code-Regression huggingface dataset:
c=[]
3.times { c<< gets.chomp.split.map(&:to_i) }
a = [0]
b = c[0]
1.upto(2) {|i| a[i] = c[i][0] - b[0]}

1.upto(2) do |i|
  1.upto(2) do |j|
    if c[i][j] != a[i] + b[j]
      puts "No"
      exit
    end
  end
end

puts "Yes"

Measured memory_bytes: 1788
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main(void){
    int n,m;
    cin >> n >> m;
    vector<int> a(m),dif(m-1);
    for(int i=0; i<m; i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0; i<m-1; i++){
        dif[i]=a[i+1]-a[i];
    }
    sort(dif.begin(),dif.end());
    long long ans=0;
    for(int i=0; i<m-n; i++){
        ans+=dif[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define LL long long
#define rep(i,a,b) for(int i=a;i<=b;++i)
using namespace std;

const int mn=1e5+7;

int main()
{
	LL n,a,b;
	scanf("%lld%lld%lld",&a,&b,&n);
	LL t=min(b-1,n);
	printf("%lld",(a*t)/b-a*(t/b));
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "

int main(){
    ll n;cin>>n;
    ll sum = n*(n-1)/2;
    co(sum);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int debt = 100000.0;
	int n, r;
	cin >> n;
	while ( n-- > 0 ){
		debt *= 1.05;
		r = debt % 1000;
		if ( r != 0 ){
			debt = debt - r + 1000;
		}
	}
	cout << debt << endl;

	return 0;
}

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

int main()
{
  int64_t N, T, ans = 0;
  cin >> N >> T;
  vector<int64_t> A(N);
  for (int i = 0; i < N; i++)
  {
    cin >> A.at(i);
  }
  int64_t mi = (1LL << 62), mx = 0, p = 0;
  for (int i = 0; i < N; i++)
  {
    mi = min(mi, A.at(i));
    if (A.at(i) - mi > p)
    {
      p = A.at(i) - mi;
      ans = 1;
    }
    else if (A.at(i) - mi == p)
    {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;

class Main{
    static int mod = 1000000000+7;
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Set<String> keihin = new HashSet<>();
        for(int i=0;i<n;i++){
            keihin.add(sc.next());
        }

        System.out.println(keihin.size());
    }
}


Measured memory_bytes: 67056
import math
import itertools
import numpy as np

def solve():
    s = input()
    le = len(s)
    ans = 0
    for i in range(le):
        for j in range(i, le):
            if all("AGCT".count(k) == 1 for k in s[i:j+1]):
                ans = max(ans, j-i+1)
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 12500
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int compare_char(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;

    return strcmp( left_char, right_char );
}
int compare_char_r(const void* left, const void* right) {
    char *left_char = (char *)left;
    char *right_char = (char *)right;

    return strcmp( right_char, left_char );
}
int main(void){
    char s[100+5], t[100+5];
    scanf("%s %s", s, t);
    
    qsort(s, strlen(s), sizeof(char), compare_char);
    qsort(t, strlen(t), sizeof(char), compare_char_r);
    if(strcmp(s, t)>=0)printf("No\n");
    else printf("Yes\n");
}


Measured memory_bytes: 1600
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
const int MAXN = 100005;
char s[MAXN];
int main()
{
	scanf("%s",s+1);
	if(s[1]==s[strlen(s+1)])printf("%s\n",(strlen(s+1)&1)?"Second":"First");
	else printf("%s\n",(strlen(s+1)&1)?"First":"Second");
	return 0;
} 

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

const int N = 3e5 + 10;

int pre[N], suf[N];
char s[N];

int main(){
	int n, ans;
	scanf("%d",&n);
	scanf("%s", s + 1);
	pre[0] = 0;
	for (int i = 1; i <= n; i++){
		if (s[i] == 'W') pre[i] = pre[i - 1] + 1;
		else pre[i] = pre[i - 1];
	} 
	suf[n + 1] = 0;
	for (int i = n; i >= 1; i--){
		if (s[i] == 'E') suf[i] = suf[i + 1] + 1;
		else suf[i] = suf[i + 1];
	}
	ans = n;
	for (int i = 1; i <= n; i++) ans = min(ans, pre[i - 1] + suf[i + 1]);
	printf("%d\n", ans);
	return 0;
} 

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


using namespace std;
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define reps(i,n) for (int i = 1; i <= (int)(n); ++i)
#define repd(i,n) for (int i = (int)(n - 1); i >= 0; --i)
#define repds(i,n) for(int i = (int)(n); i > 0; --i)
#define all(f,x,...) [&](decltype(x)& whole) { return (f)(begin(x), end(x), ##__VA_ARGS__); }(x)
#define rall(f,x,...) [&](decltype(x)& whole) { return (f)(rbegin(x), rend(x), ##__VA_ARGS__); }(x)
using ll = long long;
using ld = long double;
constexpr ll inf = static_cast<ll>(1e17);
constexpr int iinf = static_cast<int>(1e9);
constexpr double dinf = 1e10;
constexpr ld ldinf = 1e17;
ll mod = static_cast<ll>(1e9 + 7);
std::ostream& endn(std::ostream& os) { return os.put(os.widen('\n')); }
template<class T>
constexpr int sz(const T& a) { return (int)a.size(); }
template<class T, class ... Args>
constexpr void mins(T& a, Args... args) { a = min<T>({ a, args... }); }
template<class T, class... Args>
constexpr void maxs(T& a, Args... args) { a = max<T>({ a,args... }); }
template<class T>
constexpr T ceiling(const T a, const T b) { return (a + b - 1) / b; }
ll plusMod(ll& a, const ll b) { return a = (a + b) % mod; }
template<typename A, size_t N, typename T>
constexpr void fillArray(A(&array)[N], const T& val) { std::fill((T*)array, (T*)(array + N), val); }

int n, k;
string s;
void solve() {
    cin >> n >> k;
    cin >> s;

    char before = '0';
    int cnt = 0;
    rep(i, n) {
        if (before != s[i])
            ++cnt;
        before = s[i];
    }

    cout << min(n - 1, n - max(0, cnt - 2 * k)) << endn;

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    solve();

    cout << flush;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;


int main(){
    ll n, k, cnt=0;   cin >> n >> k;
    for(ll a=1; a<=n; a++){
        ll b = k-a%k;
        ll c = k-b%k;
        if((a+c)%k!=0) continue;
        //cout << a <<b << c << endl;
        if(b%k==0) b = n/b;
        else b = 1+(n-b)/k;

        if(c%k==0)  c = n/c;
        else c = 1+(n-c)/k;
        cnt += b*c;

    }
    
    cout << cnt << endl;
}



Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<cstdio>
#include<map>
#include<utility>
#include<list>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define fori(i,k,n) for(int i=k;i<(int)n;i++)
using namespace std;
const int dx[4] = { 0, 1, 0, -1 }, dy[4] = { 1, 0, -1, 0 };
const int dX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }, dY[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
/*
(char)'1' - (int)48 = (int)1;


*/
int main()
{
	int n;
	cin >> n;
	while (n != 0)
	{
		int ans = 0;
		int m, h;
		m = 0; h = 0;
		int nex = 1;
		for (int i = 0; i < n; i++)
		{
			string a;
			cin >> a;
			if (a == "lu")
			{
				h = 1;
			}
			if (a == "ru")
			{
				m = 1;
			}
			if (a == "ld")
			{
				h = 0;
			}
			if (a == "rd")
			{
				m = 0;
			}
			if (h == m&&h == nex)
			{
				ans++;
				(nex == 0) ? nex = 1 : nex = 0;
			}
		}
		cout << ans << endl;





		cin >> n;
	}
	
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (998244353ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

ll memo[4444][4444];
bool done[4444][4444];

ll c(ll a, ll b){
	if(a<b){
		return 0ll;
	}
	if(done[a][b]){
		return memo[a][b];
	}
	done[a][b] = true;
	if(b == 0ll || b == a){
		memo[a][b] = 1ll;
	}else{
		memo[a][b] = (c(a-1,b)+c(a-1,b-1))%MOD;
	}
	return memo[a][b];
}

ll p(ll p){
	ll x=2ll,ret=1ll;
	while(p){
		if(p%2){
			mul_mod(ret,x);
		}
		mul_mod(x,x);
		p/=2;
	}
	return ret;
}

ll pn(ll x, ll y){
	return c(x+y-1,y);
}

int main(void){
	ll n,k,m,ans=0ll,tmp,i,j,cu;
	cin >> k >> n;
	fill(done[0],done[4444],false);
	for(i=2ll; i<=(2*k); ++i){
		ans = 0ll;
		m = ((i-1)/2)-max(1ll,i-k)+1ll;
		cu = k-m*2;
		if(!(i%2)){
			--cu;
		}
		for(j=0ll; j<=m; ++j){
			if(n<j){
				continue;
			}
			tmp = c(m,j);
			mul_mod(tmp,p(j));
			mul_mod(tmp,pn(cu+j,n-j));
			add_mod(ans,tmp);
			if(i%2 || n == j){
				continue;
			}
			tmp = c(m,j);
			mul_mod(tmp,p(j));
			mul_mod(tmp,pn(cu+j,n-j-1));
			add_mod(ans,tmp);
		}
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 160256
#include <cstring>
#include <cstdio>
#include <vector>
#define pb push_back
int lst[2005], to[4005], pre[4005], tot;
inline void add_edge(int u, int v)
{
	to[tot] = v;
	pre[tot] = lst[u];
	lst[u] = tot++;
}
template <typename T>
bool dfs(int u, int en, T &seq, int fa = -1)
{
	if (u == en)
		return true;
	for (int i = lst[u]; ~i; i = pre[i])
	{
		if (to[i] == fa)
			continue;
		seq.pb(i);
		if (dfs(to[i], en, seq, u))
			return true;
		seq.pop_back();
	}
	return false;
}
std::vector<int> path[2005], pass[2005];
int xp[2005], yp[2005], cnt[2005];
bool vis[4005], fix[2005];
int main()
{
	// freopen("AGC025-E.in", "r", stdin);
	memset(lst, -1, sizeof(lst));
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 1; i < n; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		add_edge(--u, --v);
		add_edge(v, u);
	}
	for (int i = 0; i < m; i++)
	{
		scanf("%d%d", xp + i, yp + i);
		dfs(--xp[i], --yp[i], path[i]);
		for (int e : path[i])
		{
			cnt[e >> 1]++;
			pass[e >> 1].pb(i);
		}
	}
	int ans = 0;
	for (int i = 0; i < tot >> 1; i++)
		ans += std::min(2, cnt[i]);
	printf("%d\n", ans);
	for (int t = 0; t < m; t++)
	{
		int idx = -1;
		for (int i = 0; i < tot >> 1 && -1 == idx; i++)
		{
			if (cnt[i] == 1 && vis[i << 1] != vis[i << 1 | 1])
				idx = vis[i << 1] ? i << 1 | 1 : i << 1;
		}
		for (int i = 0; i < tot >> 1 && -1 == idx; i++)
		{
			if (cnt[i])
				idx = i << 1;
		}
		int e = idx >> 1;
		while (fix[pass[e].back()])
			pass[e].pop_back();
		int x = pass[e].back();
		fix[x] = true;
		bool rev;
		for (int i : path[x])
		{
			if (i >> 1 == e)
				rev = i != idx;
		}
		if (rev)
		{
			std::swap(xp[x], yp[x]);
			for (int &i : path[x])
				i ^= 1;
		}
		for (int i : path[x])
		{
			vis[i] = true;
			cnt[i >> 1]--;
		}
	}
	for (int i = 0; i < m; i++)
		printf("%d %d\n", xp[i] + 1, yp[i] + 1);
	return 0;
}


Measured memory_bytes: 15616
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;

int main() {
	int N;
	cin >> N;
	vector<ll> A(N);
	rep(i, N) cin >> A[i];

	ll abs_min = abs(A[0]);
	int neg_num = 0;
	ll ans = 0;
	rep(i, N) {
		if(A[i]<0) {
			neg_num = (neg_num+1)%2;
		}
		abs_min = min(abs_min, abs(A[i]));
		ans += abs(A[i]);
	}

	if(neg_num==1) {
		ans -= 2*abs_min;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<map>
#include<cstdlib>
#include<cmath>
#include<numeric>
#include<iomanip>
#include<functional>
#include<cstdlib>
#include<queue>
#include<deque>
const double PI = acos(-1);
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
using ll =long long;
const int mod = 1000000007;

//map<string>a
class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% mod + mod) % mod) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint & a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator-=(const mint & a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint & operator*=(const  mint & a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint & a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint & a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint & a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint & a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint & a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream & os, const mint & m) {
		os << m.x;
		return os;
	}
};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
//組み合わせ
void recursive_comb(vector<int> indexes, int s, int rest, std::function<void(vector<int>)> f) {
	if (rest == 0) {
		f(indexes);
	}
	else {
		if (s < 0) return;
		recursive_comb(indexes, s - 1, rest, f);
		indexes[rest - 1] = s;
		recursive_comb(indexes, s - 1, rest - 1, f);
	}
}

// nCkの組み合わせに対して処理を実行する
void foreach_comb(int n, int k, std::function<void(vector<int>)> f) {
	vector<int>indexes(k);
	recursive_comb(indexes, n - 1, k, f);
}

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

int main() {
	ll A, B,V,W,T;
	cin >> A >> V;
	cin >> B >> W;
	cin >> T;
	ll speed = V - W;
	ll x = labs(A -B);
	if (x <= speed * T) {

		cout << "YES";
	}
	else {
		cout << "NO";
	}
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    int n; cin >> n;
    vector<int> a(n);
    int x[20][20], y[20][20];
    rep(i,n){
        cin >> a[i];
        rep(j,a[i]){
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        } 
    }

    int ans = 0;
    FOR(i, 1, (1 << n)){
        bool flag = true;
        rep(j,n){
            if(!(i & (1 << j))) continue;
            rep(k, a[j]) if(((i >> x[j][k]) & 1) ^ y[j][k]) flag = false;
        }
        if(flag) ans = max(ans, __builtin_popcount(i));
    }
    cout << ans << endl;
}


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

int main(){
  int N;
  std::string s;

  while(std::cin >> N >> s){
    int r = std::count(s.begin(), s.end(), 'R');
    int w = std::count(s.begin(), s.end(), 'W'); 

    int ans = std::min(r, w);

    std::vector<int> cR(N + 1), cW(N + 1);
    for(int i = 0; i < N; ++i){
      cR[i + 1] = cR[i] + (s[i] == 'R' ? 1 : 0);
      cW[i + 1] = cW[i] + (s[i] == 'W' ? 1 : 0);
    }

    ans = std::min(ans, cW[r]);

    std::cout << ans << "\n";
  }

  return 0;
}


Measured memory_bytes: 5240
#include <iostream>
using namespace std;
#define INF 1000000001
#define N 500005
int A[N];
int ans = 0;

void merge(int left, int mid, int right) {
  int n1 = mid-left;
  int n2 = right-mid;

  int L[N], R[N];
  for (int i = 0; i < n1; i++) {
    L[i] = A[left+i];
  }
  for (int i = 0; i < n2; i++) {
    R[i] = A[mid+i];
  }
  L[n1] = INF;
  R[n2] = INF;
  int i = 0, j = 0;
  for (int k = left; k < right; k++) {
    if (L[i] <= R[j]) {
      A[k] = L[i];
      i++;
    } else {
      A[k] = R[j];
      j++;
    }
    ans++;
  }
}

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

int main() {
  int n; cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> A[i];
  }
  mergeSort(0, n);
  for (int i = 0; i < n; i++) {
    cout << A[i];
    if (i != n-1) {
      cout << " ";
    } else {
      cout << endl;
    }
  }
  cout << ans << endl;
}




Measured memory_bytes: 6916
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 924844033LL;

int N, K;
int cur[2010][2], nxt[2010][2];

signed main() {
    cin >> N >> K;

    vector<int> order, state;
    for(int i=0; i<2*K; i++) {
        if(i >= N) continue;
        for(int j=i; j<N; j+=2*K) {
            order.push_back(j);

            // state について
            // 0 bit: 左が取れる
            // 1 bit: 右が取れる
            // 2 bit: 最初の要素
            bool b1 = (j - K >= 0);
            bool b2 = (j + K <  N);
            bool b3 = (i == j);
            int s = (b3 << 2) | (b2 << 1) | b1;
            state.push_back(s);
        }
    }

    cur[0][0] = 1;
    for(int i=0; i<N; i++) {
        int s = state[i];
        for(int j=0; j<=i; j++) {
            // 左を取って増やす
            // ・最初の要素なら常に可能
            // ・そうでなければ前で右を取っていないなら可能
            if(s & 1) {
                if(s & 4) (nxt[j+1][0] += cur[j][0] + cur[j][1]) %= MOD;
                else (nxt[j+1][0] += cur[j][0]) %= MOD;
            }
            // 右を取って増やす (要素があるなら常に可能)
            if(s & 2) (nxt[j+1][1] += cur[j][0] + cur[j][1]) %= MOD;
            // なにも取らない
            (nxt[j][0] += cur[j][0] + cur[j][1]) %= MOD;

            cur[j][0] = cur[j][1] = 0;
        }
        swap(cur, nxt);
    }

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

    int ans = 0;
    for(int i=0; i<=N; i++) {
        int val = (cur[i][0] + cur[i][1]) % MOD;
        (val *= fact[N-i]) %= MOD;
        if(i % 2) (ans += MOD - val) %= MOD;
        else (ans += val) %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;

int main()
{
    ll N, Q;
    cin >> N >> Q;
    string S;
    cin >> S;
    vector<ll> l(Q), r(Q);
    for (int i = 0; i < Q; ++i)
    {
        cin >> l[i] >> r[i];
        l[i]--;
        r[i]--;
    }

    vector<ll> list;
    for (int i = 0; i < N; ++i)
        if (S[i] == 'A' && S[i + 1] == 'C')
            list.push_back(i);
    list.push_back(10e8);
    int i, j, k;
    for (i = 0; i < Q; ++i)
    {
        cout << lower_bound(list.begin(), list.end(), r[i]) - lower_bound(list.begin(), list.end(), l[i]) << endl;
    }
}

Measured memory_bytes: 3064
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Scanner;

	public class Main {

		static long mod = 1000000007;

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			String[] t = sc.nextLine().split(" ");
			int  n = Integer.parseInt(t[0]);
			long m = Long.parseLong(t[1]);

			String[] r = sc.nextLine().split(" ");
			long[] list = new long[n];
			Map<Long, Long> map = new HashMap<>();
			map.put(0L, 1L);
			long sum = 0;
			for(int i = 0 ; i < n; i ++) {
				list[i] = Long.parseLong(r[i]);
				sum  = (sum + list[i]) % m;

				if(map.containsKey(sum)) {
					map.put(sum, map.get(sum) + 1);
				}else {
					map.put(sum,1L);
				}
			}

			long cnt = 0;
			for(Entry<Long, Long> e : map.entrySet()){

				long x = e.getValue();
				cnt += (x  * (x - 1)) / 2;
			}
			System.out.println(cnt);
		}
	}


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

#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define REP(i,n) for(int _n=n, i=0;i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define trav(a, x) for (auto& a : x)
using ull = uint64_t;
using ll = int64_t;
using PII = pair<int, int>;
using VI = vector<int>;
#define INF (1ll<<60)

string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string) s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B> string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")"; }
template <typename A> string to_string(A v) {
bool first = true; string res = "{";
for (const auto &x : v) { if (!first) { res += ", "; } first = false; res += to_string(x); }
res += "}"; return res; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H); debug_out(T...); }
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll maxx(ll a, ll b) {
    return a > b ? a : b;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    ll N, x;
    cin >> N >> x;
    vector<ll> V(N);
    vector<ll> V1;
    REP(i, N) {
        cin >> V[i];
    }
    V1 = V;
    ll cost = 0;
    FOR(i, 1, N-1) {
        ll sum = V[i] + V[i-1];
        if (sum > x) {
            int k = V[i];
            V[i] = maxx(0LL, V[i] - (sum - x));
            sum = V[i-1] + V[i];
            cost += k - V[i];
            if (sum > x) {
                k = V[i-1];
                V[i-1] = V[i-1] - (sum - x);
                cost += k - V[i-1];
            }
        }
    }
    V = V1;
    ll cost1 = 0;
    FORD(i, N-2, 0) {
        ll sum = V[i] + V[i+1];
        if (sum > x) {
            int k = V[i];
            V[i] = maxx(0LL, V[i] - (sum - x));
            sum = V[i+1] + V[i];
            cost1 += k - V[i];
            if (sum > x) {
                k = V[i+1];
                V[i+1] = V[i+1] - (sum - x);
                cost1 += k - V[i+1];
            }
        }
    }
    cout << min(cost, cost1) << endl;
}

Measured memory_bytes: 1792
import java.awt.Point;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
class Main{
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			List<Point> points = new ArrayList<Point>();
			for(int i=0;i<n;i++) {
				points.add(new Point(sc.nextInt(), sc.nextInt()));
			}
			points.sort((p1, p2) -> {
				int result = p1.x - p2.x;
				if(result == 0)
					result = p1.y - p2.y;
				return result;
			});
			points.forEach(point -> System.out.println(point.x + " " + point.y));
		}
	}
}


Measured memory_bytes: 106480
#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void solve() {
        string str; cin >> str;
        bool b1= 1, b2= 1;
        int n= str.size();

        for (int i= 0; i< n/ 2; i++) {
                if (str[i]!= str[n/ 2- 1- i]) b1= 0;
        }

        for (int i= n/ 2+ 1; i< n; i++) {
                if (str[i]!= str[n- 1- i]) b1= 0;
        }

        if (b1&& b2) cout << "Yes\n";
        else cout << "No\n";
}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) solve();
return 0;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int r;

int solve() {
    return 3 * r * r;
}

void input() {
    cin >> r;
}

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

    input();
    cout << solve() << endl;
}


Measured memory_bytes: 888
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
map<int,int>t;
int N,B[200005],bit[200005];

int sum(int i)
{
	int s=0;
	while(i>0)
	{
		s+=bit[i];
		i-=i&-i;
	}
	return s;
}

void add(int i,int x)
{
	while(i<=N)
	{
		bit[i]+=x;
		i+=i&-i;
	}
}
int main()
{
	long long ans=0;
	scanf("%d",&N);

	for(int i=0;i<N;i++)
	{
		scanf("%d",B+i);
		t[B[i]]=1;
	}
	int i=1;
	for(map<int,int>::iterator it=t.begin();it!=t.end();it++,i++)
		it->second=i;
	for(int i=0;i<N;i++)
		B[i]=t[B[i]];
	for(int j=0;j<N;j++)
	{
		ans+=j-sum(B[j]);
		add(B[j],1);
	}
	printf("%lld\n",ans);
}

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

using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/

#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second

#define what_is(x)     cerr << #x << " is " << x << endl;

///*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)
{
    cout << endl ;
}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
int ini()
{
    int x;
    scanf("%d",&x);
    return x;
}
long long inl()
{
    long long x;
    scanf("%lld",&x);
    return x;
}

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);

int ps[N];
int main()
{
  int n,x;

  cin>>n>>x;
  int ans=1;
  for(int i=1;i<=n;i++){
    int xx=ini();
    ps[i]=ps[i-1]+xx;
    if(ps[i]>x){
       break;
    }
    ans++;
  }
  cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
/**   Created by: Marcos Portales
          Codeforces User: marcosportales
          Country: Cuba
          Copyright                    */
#include<bits/stdc++.h>
using namespace std;
/// Pragmas:
#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2") //Enable AVX
/// Macros:
#define int long long
#define f first
#define s second
#define db(x) cerr << #x << ": " << (x) << '\n';
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define all(x) x.begin() , x.end()
#define rall(x) x.rbegin() , x.rend()
#define enl '\n'
#define vi vector<int>
#define sz(a) int((a).size())
#define rep(i,x,y) for(int i=x;i<y;i++)
typedef pair<int,int> ii;
typedef long double ld;
typedef unsigned long long ull;
/// Constraints:
const int maxn = 400010;
const int mod = 1000000007;
const ld eps = 1e-9;
const int inf = ((1ll<<31ll)-1ll);
const int INF = 2000000000000000000ll;
const ld pi = acos(-1);
/// Prime Numbers:
// 2, 173, 179, 181, 197, 311, 331, 737, 1009, 2011, 2027, 3079, 4001, 10037, 10079, 20011, 20089;
// 100003, 100019, 100043, 200003, 200017, 1000003, 1000033, 1000037, 1000081;
// 2000003, 2000029, 2000039, 1000000007, 1000000021, 2000000099;
/// Functions:
#define lg2(x) 31 - __builtin_clz(x)
#define lgx(x,b) ( log(x) / log(b) )
/// Red-Black Tree Template ---------------------------------
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree < long long ,  null_type ,  less<long long> ,  rb_tree_tag ,  tree_order_statistics_node_update > ordered_set;
/// Quick Pow------------------------------------------------
int qpow(int b,int e){
    if( !e ) return 1;
    if( e & 1 ) return qpow(b,e-1) * b % mod;
    int pwur = qpow(b,e>>1);
    return (pwur * pwur) % mod;
}
int modinv(int x){
    return qpow(x,mod-2);
}
/// My Code -------------------------------------------------

int32_t main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout.setf(ios::fixed); cout.precision(0);
    srand(time(NULL));

    //freopen("a.in","r",stdin);
    //freopen("a.in","w",stdout);
        int n;
    cin>>n;
    map<int,int> mp;
    for(int i=2;i<=n;i++){
        int m=i;
        for(int j=2;j*j<=m;j++){
            while(m%j==0){
                mp[j]++;
                m/=j;
            }
        }
        if(m>1) mp[m]++;
    }
    int ans=1;
    for(auto p:mp){
        ans*=p.second+1;
        ans%=mod;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
int main(){
 int t;
 cin>>t;
 string s="ACL";
 if(t==1)
 cout<<s;
 if(t==2)
 cout<<s<<s;
  if(t==3)
 cout<<s<<s<<s;
  if(t==4)
 cout<<s<<s<<s<<s;
  if(t==5)
 cout<<s<<s<<s<<s<<s;
}

Measured memory_bytes: 3620
// AOJ 2709 Dark Room
// 2018.3.31 bal4u

#include <stdio.h>
#include <string.h>

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

#define INF 0x10101010
#define QMAX 100000
typedef struct { int s, t; } QUE;
QUE q[QMAX+10]; int top, end;
int d[18], r[102];
int v[102][102];
int dist[1<<16];

int main()
{
	int N, M, K, i, j, k, s, e, t;

	N = in(), M = in(), K = in();
	memset(r, -1, sizeof(r));
	for (i = 0; i < M; i++) d[i] = in()-1, r[d[i]] = 1<<i;
	for (i = 0; i < N; i++) for (j = 0; j < K; j++) v[i][j] = in()-1;

	memset(dist, INF, sizeof(dist));
	q[0].s = s =(1<<M)-1, q[0].t = 0, dist[s] = 0;
	top = 0, end = 1;
	while (top != end) {
		s = q[top].s, t = q[top++].t;
	
		if (dist[s] == INF) continue;
		for (i = 0; i < K; i++) {
			e = 0;
			for (j = 0; j < M; j++) if ((s>>j)&1) {
				k = v[d[j]][i];
				if (r[k] >= 0) e |= r[k];
			}
			if (dist[e] > t+1) {
				dist[e] = t+1;
				q[end].s = e, q[end++].t = t+1;
			}
		}
	}
	printf("%d\n", dist[0]);
	return 0;
}


Measured memory_bytes: 2664
#include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;
pair<int,int> pairs[3000];

int main(void){
    int index = 0;
    while(1){
        cin >> pairs[index].first >> pairs[index].second;
        if(pairs[index].first == 0 && pairs[index].second == 0){
            break;
        }
        ++index;
    }
    
    for(int i = 0;i < index;++i){
        // 並び替え
        if(pairs[i].first > pairs[i].second){
            int tmp = pairs[i].first;
            pairs[i].first = pairs[i].second;
            pairs[i].second = tmp;
        }
        cout << pairs[i].first << " " << pairs[i].second << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3020
class LCM():
    #a、bに最小公倍数または最大公約数を求めたい二つの整数の組を入れる
    def __init__(self,a,b):
        if a < b:a,b = b,a
        self.a = a
        self.b = b

    #最大公約数
    def gcd(self):
        a,b = self.a,self.b
        def nono(a,b):
            if a < b:a,b = b,a
            if a % b == 0:return b
            else:return nono(b,a % b)
        return nono(a,b)

    #最小公倍数
    def lcm(self):
        a,b = self.a,self.b
        def nono(a,b):
            if a < b:a,b = b,a
            if a % b == 0:return b
            else:return nono(b,a % b)
        num = nono(a,b)
        return a*b//num

n = int(input())
ans = 0
dp = [[[-1 for i in range(201)] for j in range(201)] for k in range(201)]
for i in range(1,n+1):
    for j in range(1,1+n):
        for k in range(1,1+n):
            ls = [i,j,k]
            ls.sort()
            if dp[ls[0]][ls[1]][ls[2]] != -1:
                ans += dp[ls[0]][ls[1]][ls[2]]
                continue
            c = LCM(i,j)
            l = LCM(c.gcd(),k)
            a = l.gcd()
            ans += a
            dp[ls[0]][ls[1]][ls[2]] = a

print(ans)

Measured memory_bytes: 144184
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<list>

typedef long long ll;

using namespace std;

#define MAX 500000
#define SENTINRL 2000000000

int cnt;
int L[MAX/2+5],R[MAX/2+5];

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

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

int main(){
	ios::sync_with_stdio(false);
	int a[MAX+10];
	int n;	cin>>n;
	for(int i = 0 ; i<n ; i++){
		cin>>a[i];
	}
	
	mergeSort(a,0,n);
	
	
	for(int i = 0 ; i<n ; i++){
		if(i)	cout<<" ";
		cout<<a[i];
	}
	cout<<endl;
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 7008
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));

    ll cn = a[n-1];
    double cnd = a[n-1]/2.0, minv = 1'000'000'001, minans = 0;
    rep(i, n-1){
        if(abs(a[i]-cnd) <= minv){
            minv = abs(a[i]-cnd);
            minans = a[i];
        }
    }
    cout << cn << " " << (ll)minans << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
ll q,a,b,c,d,k;
bool check(ll turns)
{
    if(b<turns||a<k*turns) return false;
    ll restb=b-turns;
    ll resta=a-turns*k;
    if(restb>=k*(resta+1)) return false; else return true;
}
int main()
{
    scanf("%lld",&q);
    while(q--)
    {
        scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
        ll s=a+b;
        k=(max(a,b)-1)/(min(a,b)+1)+1;
        ll l=0,r=(a-1)/k+2;
        while(r-l>1)
        {
            ll mid=(l+r)/2;
            if(check(mid)) l=mid; else r=mid;
        }
        ll turns=l;
        a-=turns*k;b-=turns;
        ll cnta=0,cntb=0;
        cnta=a-(b-1)/k; a-=cnta;
        cntb=b-k*a; b-=cntb;
        assert(b==k*a);
        for(ll i=max(c,1LL);i<=min(d,turns*(k+1));i++)
        {
            if(i%(k+1)==0) printf("B"); else printf("A");
        }
        for(ll i=max(c,turns*(k+1)+1);i<=min(d,turns*(k+1)+cnta);i++) printf("A");
        for(ll i=max(c,turns*(k+1)+cnta+1);i<=min(d,turns*(k+1)+cnta+cntb);i++) printf("B");
        for(ll i=max(c,turns*(k+1)+cnta+cntb+1);i<=min(s,d);i++) if((s-i)%(k+1)!=k) printf("B"); else printf("A");
        puts("");
    }
    return 0;
}



Measured memory_bytes: 384
import math
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

def isprime(x):
    if x == 2:
        return True
    elif x % 2 == 0:
        return False
    i = 3
    while i <= math.sqrt(x):
        if x % i == 0:
            return False
        i += 2
    else:
        return True
   
counter = 0
for i in a:
    if isprime(i) == True:
        counter += 1
print(counter)

Measured memory_bytes: 8144
#include <iostream>

using namespace std;

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


int main(){
  int h, w;
  cin >> h >> w;
  
  rep(i, h+2){
    cout << '#';
    if(i == 0 || i == h+1){
      rep(i, w){
        cout << '#';
      }
    }else{
      string s;
      cin >> s;
      cout << s;
    }
    cout << '#' << endl;
  }
  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define crap ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long int ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::vector<ll> vll;
typedef std::vector<vi > vvi;
typedef std::vector<vll > vvll;
typedef std::pair<int,int> ii;
typedef std::pair< ll, ll > lp;
typedef std::vector<ii> vii;
typedef std::vector<vii > vvii;
 
#define pb push_back 
#define PB pop_back
#define pf push_front
#define PF pop_front
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define in1(a,n) F(i,1,n)cin>>a[i]
#define ff first
#define ss second
#define F(i,a,b) for (ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,n) F(i,0,n-1)
#define clr clear
#define rz resize
#define sqr(a) ((a) * (a))
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define len(s) (s).length()

int main()
{
	crap;
	int n;
	cin>>n;

	if (n%111!=0)
	{
		cout<<((n/111)+1)*111<<"\n";
	}
	else
	{
		cout<<n<<"\n";
	}
}

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

int main()
{
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n);
  vector<int> f(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> f[i];
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());
  ll left = -1, right = 1e12;
  while (left + 1 < right)
  {
    // std::cout << "left=" << left << " right=" << right << endl;
    ll c = (left + right) / 2;
    ll total = 0;
    for(int i=0 ; i < n ; i++){
      total += max(0ll, a[i] - c / f[i]);
    }
    if (total <= k)
    {
      right = c;
    }
    else
    {
      left = c;
    }
  }
  std::cout << right << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <utility>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1e9 + 7
#define INF 1e9
#define SENTINEL 2e9
#define PIE 3.14159265358979323

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;}
template <class T>
inline T GCD(T a, T b){if (b == 0) return a; else return GCD(b, a % b);}
template <class T>
inline T LCM(T a, T b) {return (a * b) / GCD(a, b);}

int main(){
    string s;
    cin>>s;
    if (s=="ARC")
        cout << "ABC" << endl;
    else
        cout << "ARC" << endl;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(10000)


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N, A):
    ans = 0
    return ans


def main():
    A, B, C = read_int_n()
    ans = max(A, B, C) * 10 + A + B + C - max(A, B, C)

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 7484
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, math.MaxInt64)
}

func readInt() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func div(arr []int) ([]int, bool) {
	div := []int{}
	for _, v := range arr {
		if v%2 != 0 {
			return arr, false
		}
		div = append(div, v/2)
	}
	return div, true
}

func main() {
	n := readInt()
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = readInt()
	}
	cnt := 0
	for {
		if div, ok := div(arr); ok {
			cnt++
			arr = div
			continue
		}
		break
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*Sが全ての文字を含んでいない時、Sに含まれない文字の最小の文字を
末尾に足す
num[i];num[0] = 1ならaを含む 'a'を0、'b'を1に変換
*/
int main() {
 string S;
 cin >> S;
 vector<int> num(26);
 for(int i = 0;i<S.size();i++){
     num[(int)S[i]-97] = 1;
 }
 char ad;//Sに含まれない文字のうち、辞書順最小の文字
 for(int i = 0;i<26;i++){
     if(num[i] == 0){
         ad = (char)(i+97);
         break;
     }
 }

 bool fl = false;//Sに全ての文字が含まれていないか
 for(int i = 0;i<26;i++){
     if(num[i] == 0){//含まれないない文字があればok
         fl = true;
         break;
     }
 }

 if(fl){
     S.push_back(ad);
     cout << S << endl;
 }
else{
  if(S == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 <<endl;
        return 0;
    }
  
 reverse(S.begin(),S.end());
 vector<char> v;
 int c = 0;
 for(int i = 1;i<S.size();i++){
     bool flag = false;//適当な置換文字が見つかるか
     v.push_back(S[i-1]);
     sort(v.begin(),v.end());
     for(int j = 0;j<v.size();j++){
         if(S[i] < v[j]){
             S[i] = v[j];
             c = i;
             flag = true;
             break;
         }
     }
  if(flag) break;
 }
 reverse(S.begin(),S.end());
 for(int i = 0;i<S.size()-c;i++){
     cout << S[i];
 }
 cout << endl;
}
}
 

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

int main(){
  int N;
  cin >> N;
  
  int count = 0;
  
  for(int i = 1; i <= N; ++i) {
    if(to_string(i).length() % 2 == 0) {
      continue;
    } else {
      count++;
    }
  }
  
  cout << count << endl;
}


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

int main(){
	int vnum, capacity;
	std::vector<int> vprice;

	while(std::cin >> vnum >> capacity){
		//end
		if(vnum == 0 && capacity == 0) break;

		int buf = capacity;
		std::vector<int> vprice;
		int tmp,total = 0;

		//input
		for(int i = 0; i < vnum; ++i){
			std::cin >> tmp;
			vprice.push_back(tmp);
	}

		//sort
		std::sort(vprice.begin(), vprice.end(), std::greater<int>());

		//sum price
		std::for_each(vprice.begin(),vprice.end(), [&total,buf,&capacity](int x) { capacity != 1 ? (total += x, --capacity) : capacity = buf; } );

		//output
		std::cout << total << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1228
#include <cstdio>
#include <set>
#define N_MAX 11

using namespace std;

int a[N_MAX];	// カードに書かれた数値を格納
std::set<int> S;// 生成された数を格納

// カードの数を連結する
int cat(int s, int t) {
	int pow = 1;
	while(pow <= t) pow *= 10;
	return s * pow + t;
}

int main() {

	int n, k;		// n個からk個選ぶ

	while(1) {
		scanf("%d%d", &n, &k);
		if(n == 0 && k == 0) break;

		for(int i = 0; i < n; i++)
			scanf("%d", a + i);
		// 生成される数の格納
		S.clear();

		if(k == 2) {
			for(int i = 0; i < n; i++) 
				for(int j = 0; j < n; j++)
					if(i != j) S.insert(cat(a[i], a[j]));
		} else if(k == 3) {
			for(int i = 0; i < n; i++) 
				for(int j = 0; j < n; j++)
					for(int t = 0; t < n; t++) 
						if(i != j && j != t && t != i) 
							S.insert(cat(a[i], cat(a[j], a[t])));
		} else {
			for(int i = 0; i < n; i++) 
				for(int j = 0; j < n; j++)
					for(int t = 0; t < n; t++) 
						for(int u = 0; u < n; u++)
						 	if(i != j && i != t && i != u && j != t && j != u && t != u) 
								S.insert(cat(a[i], cat(a[j], cat(a[t], a[u]))));
		}
		printf("%d\n", S.size());
	}
	return 0;
}



Measured memory_bytes: 2904
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int main()
{
	std::ios::sync_with_stdio(false);
	ll n;
  cin>>n;
  vll arr(n);
  for(ll i=0;i<n;i++){
    cin>>arr[i];
  }
  ll sum = 0;
  ll m = arr[0];
  for(ll i=0;i<n;i++){
    if(m>arr[i]){
      sum+=(m-arr[i]);
    }
    else{
      m = arr[i];
    }
  }
  cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 4748
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N;
    cin >> N ;
    if(N>=1000){
        cout <<"ABD"<<endl;
    }else{
        cout <<"ABC" <<endl;
    }

    return 0;
}

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

if a > b:
  x=a
  a=b
  b=x

if b > c:
  x=b
  b=c
  c=x

if a > b:
  x=a
  a=b
  b=x

print(str(a)+" "+str(b)+" "+str(c))


Measured memory_bytes: 5596