akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h> 
#include <string> 
#include <algorithm>
#include <numeric>
#include <cmath>
using namespace std;

int main() {

	long N; cin >> N;
	long lucas[100]; lucas[0] = 2; lucas[1] = 1;
	long res;

	for (int i = 2; i <= N; i++) lucas[i] = lucas[i - 1] + lucas[i - 2];

	res = lucas[N];

	cout << res << endl;

}

Measured memory_bytes: 256
#!/usr/bin/env python3


def main():
    N = int(input())
    X = [None] * N
    for i in range(N):
        x, l = map(int, input().split())
        X[i] = (x+l,x-l)
    X.sort()
    ans = 0
    maxT = - 10**18
    for i in range(N):
        if maxT <= X[i][1]:
            ans += 1
            maxT = X[i][0]
    print(ans) 


if __name__ == "__main__":
    main()


Measured memory_bytes: 18756
#include <iostream>
using namespace std;
int main(void){
    long a, b, c;
    long long L, W;
    cin >> a >> b >> c;
    L = 4 * a * b;
    W = a * a + b * b + c * c + 2 * a * b - 2 * a * c - 2 * b * c;
    if (L < W && c - a - b > 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define m_p			make_pair
#define rep(i,a,b)	for(int i=a;i<b;i++)
#define sz(x)       (int)x.size()
#define f			first
#define debug		cout<<"##########3"<<endl
#define mod			1000000007
#define ll			long long int
#define lMax		LLONG_MAX
// queue<int> , prefix_sum(a,a+n) , reverse(a,a+n) , priority_queue <int> max heap , priority_queue <int, vector<int>, greater<int> > min heap;
// == precedence gretaer then &
ll n,m;
ll arr[3005];
// Prefix sum calculation wala dp !!!!
ll dp[3005][3005][2];
int main() {
    ll i,j,k,c=0,ans=0,t,z,x=0,y;
	cin>>n;
	rep(i,0,n){
		cin>>arr[i];
		dp[i][i][0] = arr[i];
		dp[i][i][1] = -arr[i];
	}
	for(int len=2;len<=n;len++){
		for(i=0;i<=n-len;i++){
			j = i+len-1;
			dp[i][j][0] = max(dp[i][j-1][1] + arr[j],dp[i+1][j][1] + arr[i]);
			dp[i][j][1] = min(dp[i][j-1][0] - arr[j],dp[i+1][j][0] - arr[i]);
		//	cout<<i<<" "<<j<<" "<<dp[i][j][0]<<" "<<dp[i][j][1]<<endl;
		}
	}
	cout<<dp[0][n-1][0];
 	return 0;
}

Measured memory_bytes: 139648
#include<bits/stdc++.h>
#define ll long long int
#define MAX 1000003
#define pii pair<ll,ll>
#define VP vector< pii >
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define rep(i,a,b) for(ll (i) = (a); (i) < (b); (i)++)
#define all(v) (v).begin(),(v).end()
#define S(x) scanf("%d",&(x))
#define S2(x,y) scanf("%d%d",&(x),&(y))
#define SL(x) scanf("%lld",&(x))
#define SL2(x) scanf("%lld%lld",&(x),&(y))
#define P(x) printf("%d\n",(x))
#define FF first
#define SS second
using namespace std;

int main(){
	ll n,k;
	cin>>n>>k;
	vector<ll>v(n),dp(n);
	rep(i,0,n)
		{
			cin>>v[i];

		}
	dp[0]=0;
	dp[1]=abs(v[1]-v[0]);
	rep(i,2,n)
		{
			ll ans=INT_MAX;
			for(int j=i-1;j>=max(i-k,(ll)0);j--)
					{
						ans=min(dp[j]+abs(v[i]-v[j]),ans);
					}
			dp[i]=ans;
		}
	cout<<dp[n-1];
 
return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
using namespace std;
int main() {
	long long n, k, a, b;
	long long co[100000] = { 0 };
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a >> b;
		co[a - 1] += b;
	}
	for (int j = 0; j <= 100000; j++) {
		if (k <= co[j]) {
			cout << j+1 << endl;
			return 0;
		}
		else {
			k -= co[j];
		}
	}
}






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

template<typename T>
struct Segtree {
    int n;
    T e;
    vector<T> dat;
    typedef function<T(T a, T b)> Func;
    Func f;

    Segtree(){}
    Segtree(int n_input, Func f_input, T e_input){
        initialize(n_input, f_input, e_input);
    }
    void initialize(int n_input, Func f_input, T e_input){
        f = f_input;
        e = e_input;
        n = 1;
        while(n < n_input) n <<= 1;
        dat.resize(2*n-1, e);
    }

    void update(int k, T a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = f(dat[2*k+1], dat[2*k+2]);
        }
    }

    T get(int k){
        return dat[k+n-1];
    }

    T between(int a, int b){
        return query(a, b+1, 0, 0, n);
    }

    T query(int a, int b, int k, int l, int r){
        if(r<=a || b<=l) return e;
        if(a<=l && r<=b) return dat[k];
        T vl = query(a, b, 2*k+1, l, (l+r)/2);
        T vr = query(a, b, 2*k+2, (l+r)/2, r);
        return f(vl, vr);
    }
};

int main(){
    int N;
    cin >> N;
    vector<pair<int, int>> LR(N);
    for(int i=0; i<N; i++) {
        int l, r;
        cin >> l >> r;
        LR[i] = {l, r};
    }
    sort(LR.begin(), LR.end());

    Segtree<int> Lmax(N, [](int a, int b){ return max(a, b); }, -1e9);
    Segtree<int> Rmax(N, [](int a, int b){ return max(a, b); }, -1e9);
    Segtree<int> Lmin(N, [](int a, int b){ return min(a, b); }, 1e9);
    Segtree<int> Rmin(N, [](int a, int b){ return min(a, b); }, 1e9);
    for(int i=0; i<N; i++){
        Lmax.update(i, LR[i].first);
        Lmin.update(i, LR[i].first);
        Rmax.update(i, LR[i].second);
        Rmin.update(i, LR[i].second);
    }
    int ans = 0;
    for(int i=0; i<N; i++){
        int res1 = LR[i].second - LR[i].first + 1;
        int r2 = min(Rmin.between(0, i-1), Rmin.between(i+1, N-1));
        int l2 = max(Lmax.between(0, i-1), Lmax.between(i+1, N-1));
        int res2 = max(0, r2-l2+1);
        ans = max(ans, res1 + res2);
    }
    for(int i=1; i<N; i++){
        int res1 = Rmin.between(0, i-1) - Lmax.between(0, i-1) + 1;
        int res2 = Rmin.between(i, N-1) - Lmax.between(i, N-1) + 1;
        int res = max(0, res1) + max(0, res2);
        ans = max(ans, res);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5120
#include<stdio.h>

int search(int A[], int n, int key){

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

int main(){
	int i, n, A[10000+1], q, key, sum = 0;

	scanf("%d", &n);
	for( i = 0; i < n; i++){
	scanf("%d", &A[i]);
	}
	scanf("%d", &q);
	for( i = 0; i < q; i++){
	  scanf("%d", &key);
	if(search(A,n,key)) sum++;
	}

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

	return 0;
}

Measured memory_bytes: 636
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        String[] param = br.readLine().split(" ");
        int N = Integer.parseInt(param[0]);
        int K = Integer.parseInt(param[1]);

        String[] line = br.readLine().split(" ");
        List<Integer> list = new ArrayList<>();
        int minTime = 0;

        for (int i = 0; i < N; i++) {
            list.add(Integer.parseInt(line[i]));
        }

        for (int i = 0; i < N - (K - 1); i++) {
            int time = 0;
            int left = list.get(i);
            int right = list.get(i + (K - 1));

            if (left >= 0) { // 両方正
                time = right;
            } else if (right <= 0) { // 両方負
                time = left * (-1);
            } else { // rightが正、leftが負
                if (left * (-1) < right) {
                    time = left * (-2) + right;
                } else {
                    time = left * (-1) + right * 2;
                }
            }
            if (minTime == 0 || time < minTime) {
                minTime = time;
            }
        }
        out.println(minTime);
        out.close();
    }
}

Measured memory_bytes: 48284
local n,m=io.read("*n","*n")
local city={}
for i=1,m do
    local p,y=io.read("*n","*n")
    city[i]={p,y,i}
end

table.sort(city,function(x,y)
    if x[1]~=y[1] then
        return x[1]<y[1]
    else
        return x[2]<y[2]
    end
end)

local id={}
local x=1
local P=0
for i=1,m do
    local p=city[i][1]
    local y=city[i][2]
    local c=city[i][3]
    if P==p then
        x=x+1
    else
        x=1
    end
    id[c]=string.format("%06d",p)..string.format("%06d",x)
    P=p
end

for i=1,m do
    print(id[i])
end

Measured memory_bytes: 18468
#include<string>
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for(ll i = 0; i < (ll)n; i++)

int main() {
    string S;
    cin >> S;
    string ret = S.substr(0,3);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <cstdio>
using namespace std;
int n,sum,ans,a[105];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sum=1,ans=0;
	a[n+1]=-1;
	for(int i=2;i<=n+1;i++)
		if(a[i]==a[i-1])sum++;
		else ans+=sum/2,sum=1;
	printf("%d\n",ans);
	return 0;
} 

Measured memory_bytes: 128
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl

#define rep(i, n) REP(i, 0, n)                  // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++) // x, x + 1, ..., n-1
#define FOREACH(x, a) for(auto &(x) : (a))

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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

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

    int K, X;
    cin >> K >> X;
    Yes(500 * K >= X);
}


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

int main(){
    
    int N;
    cin >> N;
    vector<int> a(N);
    
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    
    sort(a.rbegin(), a.rend());
    
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 0) ans += a[i];
        else ans -= a[i];
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 3136
#include <stdio.h>
#include <string.h>
int main(){
  char weather[10];
  char *s1 = "Sunny";
  char *s2 = "Cloudy";
  char *s3 = "Rainy";
  
  scanf("%s",weather);
  if(strcmp(s1,weather)==0) printf("%s",s2);
  if(strcmp(s2,weather)==0) printf("%s",s3);
  if(strcmp(s3,weather)==0) printf("%s",s1);
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <math.h>
int main(void){
  long long l;
  long long max;
  scanf("%lld",&l);max=l;
  int a[20];
  for(int i=0;i<20;i++){
      a[i]=l%2;
      l=l/2;
  }
  int h;
  int hh=0;
  for(int i=0;i<20;i++){
      if(a[i]==1)h=i;
      hh+=a[i];
  }
  int b[22];
  b[0]=1;
  for(int i=1;i<22;i++){
      b[i]=b[i-1]*2;
  }
  printf("%d %d\n",h+1,2*h+hh-1);
  for(int i=0;i<h;i++){
      printf("%d %d %d\n",i+1,i+2,0);
      printf("%d %d %d\n",i+1,i+2,b[h-i-1]);
  }
  long long y=max;
  for(int i=0;i<h;i++){
      if(a[i]){
          printf("%d %d %d\n",1,h-i+1,y-b[i]);
          y=y-b[i];
      }
  }
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define SZ(x) ((int)(x).size())
#define INF 999999999
typedef long long int Int;
using ll = long long;
using VI = vector<int>;

int main(){
  Int n;cin >>n;
  Int t,a;cin >> t >> a;
  Int ans = -1;
  Int min=999999999;
  rep(i,n){
    Int h;cin >> h;
    Int kion = t*1000-(h*6);
    if(min>abs(kion-a*1000)){
      min = abs(kion-a*1000);
      ans = i+1;
    }
  }
  cout << ans << endl;
}


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

#define testcase            int t; cin>>t; while (t--)
#define sc(a)               scanf("%lld",&a)
#define sc2(a,b)            scanf("%lld %lld",&a,&b)
#define pb                  push_back
#define reversed(s)         reverse(s.begin(), s.end())
#define asort(s)            sort(s.begin(), s.end())
#define dsort(s)            sort(s.begin(), s.end(),greater<ll>())
#define gtl(x)              getline(cin, (x))
#define PI                  acos(-1)
#define CLR(x, y)           memset(x, y, sizeof(x))
#define Precision(a)        cout << fixed << setprecision(a)
#define FasterIo            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl                "\n"

template <typename T> T Sqr(T x) { T n = x * x ; return n ;}
template <typename T> T Pow(T B,T P){ if(P==0) return 1; if(P&1) return B*Pow(B,P-1);  else return Sqr(Pow(B,P/2));}
template <typename T> T Abs(T a) {if(a<0)return -a;else return a;}
template <typename T> T Gcd(T a,T b){if(a<0)return Gcd(-a,b);if(b<0)return Gcd(a,-b);return (b==0)?a:Gcd(b,a%b);}
template <typename T> T Lcm(T a,T b) {if(a<0)return Lcm(-a,b);if(b<0)return Lcm(a,-b);return a*(b/Gcd(a,b));}

int main()
{
    FasterIo
    ll n;
    cin >> n;
    int rem=n%1000;
    if(rem)
    {
        rem = 1000-(n%1000);
    }
    cout << rem << endl;
    return 0;
}


Measured memory_bytes: 3464
#include <iostream>
#include <vector>

int main() {
  unsigned N, x;
  std::cin >> N >> x;
  std::vector<unsigned> perm(2 * N - 1);
  if (x == 1 || x == 2 * N - 1) {
    std::cout << "No";
    return 0;
  }
  std::cout << "Yes" << std::endl;
  if (N == 2) {
    std::cout << 1 << std::endl;
    std::cout << 2 << std::endl;
    std::cout << 3 << std::endl;
    return 0;
  }
  unsigned min;
  unsigned max;
  if (x < N) {
    perm[N - 2] = x + 1;
    perm[N - 1] = x;
    perm[N] = x - 1;
    perm[N + 1] = x + 2;
    min = x - 1;
    max = x + 2;
  } else {
    perm[N - 2] = x - 1;
    perm[N - 1] = x;
    perm[N] = x + 1;
    perm[N + 1] = x - 2;
    min = x - 2;
    max = x + 1;
  }
  unsigned hoge = 1;
  for (unsigned i = 0; i < 2 * N - 1; ++i) {
    while (min <= hoge && hoge <= max) {
      ++hoge;
    }
    if (i < N - 2 || i > N + 1) {
      perm[i] = hoge++;
    }
  }
  for (unsigned i = 0; i < 2 * N - 2; ++i) {
    std::cout << perm[i] << std::endl;
  }
  std::cout << perm[2 * N - 2];
  return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    int n; cin >> n;
    string s, t; cin >> s >> t;
    if(s == t){
        cout << n << endl;
        return 0;
    }
    int same = 0;
    _rep(i, 1, n + 1){
        if(s.substr(n - i) == t.substr(0, i))same = i;
    }
    cout << 2 * n - same << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
//累乗(power)a^n(mod10^9+7)
int power(int a,int n){
  int count=a,sum=1;
  while(n>0){
    if(n%2==1)
      sum*=count;
    count*=count;
    n/=2;
  }
  return sum;
}

int main(){
  int n,m,i,j,l,count=0;
  scanf("%d%d",&n,&m);
  int k[m+1],s[m+1][n+1],p[m+1];
  for(i=0;i<m;i++){
    scanf("%d",&k[i]);
    for(j=0;j<k[i];j++)
      scanf("%d",&s[i][j]);
  }
  for(i=0;i<m;i++)
    scanf("%d",&p[i]);
  int nnum=power(2,n);
  int pat[n+1];
  for(i=0;i<nnum;i++){
    int b=i;
    for(j=0;j<n;j++){
      pat[j]=b%2;
      b/=2;
    }
    int num,sum=1;
    for(j=0;j<m;j++){
      int knum=k[j];
      num=0;
      for(l=0;l<knum;l++)
        num+=pat[s[j][l]-1];
      if(num%2!=p[j])
        sum=0;
    }
    count+=sum;
  }
  printf("%d\n",count);
}


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

#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

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

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
signed main(){
	int n,a,b;
	cin>>n>>a>>b;
	int x[100010];
	rep(i,n)cin>>x[i];
	int ans=0;
	rep(i,n-1){
		int d=x[i+1]-x[i];
		if(a*d<b)ans+=a*d;
		else ans+=b;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>

using namespace std;

int is_prime(int n) {
  if (n == 1) return 0;
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0) return 0;
  }
  return 1;
}

int main() {
  int Q;
  cin >> Q;
  vector<int> l(Q), r(Q);
  for (int i = 0; i < Q; i++)
    cin >> l[i] >> r[i];

  vector<int> like(1e5 / 2, 0);
  for (int i = 0; i < 1e5 / 2; i++) {
    int n = i * 2 + 1;
    if (is_prime(n) && is_prime((n+1)/2)) {
      like[i] = 1;
    }
  }

  vector<int> sum(1e5 / 2, 0);
  sum[0] = like[0];
  for (int i = 1; i < 1e5 / 2; i++) {
    sum[i] = sum[i-1] + like[i];
  }

  for (int i = 0; i < Q; i++) {
    if (l[i] == 1) {
      cout << sum[r[i]/2] << endl;
    } else {
      cout << sum[r[i]/2] - sum[l[i]/2-1] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b)  for(int i=(a),i##formax=(b);i< i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formin=(b);i>=i##formin;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max((x),(y))
#define mins(x,y) x=min((x),(y))
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define all(a) ((a).begin()),((a).end())
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define bit(n) (1LL<<(n))
typedef long long ll;
typedef __int128_t lll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>using P=pair<T,Y>;
template<class T,class Y>ostream& operator<<(ostream&o,P<T,Y>&p){return o<<"("<<p.fi<<","<<p.se<<")";}
template<class T>ostream& operator<<(ostream&o,V<T>&v){for(T&t:v)o<<t<<",";return o<<endl;}
template<class T>void uniq(V<T>&v){sort(all(v));v.erase(unique(all(v)), v.end());}

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 2e5;
int n, c[N];
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n) cin >> c[i];
  sort(c, c+n, greater<ll>());
  ll ans=0, b=modInv(2, MOD);
  FOR(i, 0, n){
    ans = (ans*2 + b*(i+2)%MOD*c[i]) % MOD;
    b = b*2%MOD;
  }
  cout << (ans*b*2%MOD) << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

class Main{

    static class Edge{
        int to;
        long cost;
        Edge(int to,long cost){
            this.to=to;
            this.cost=cost;
        }
    }
    static List<Edge>[] eList;
    static int[] size;
    static boolean[] used;

    static int dfs(int v){
        int sz = 1;
        used[v]=true;
        for(Edge e : eList[v])if(!used[e.to]){
            sz += dfs(e.to);
        }
        return size[v] = sz;
    }

    static long dfs2(int root){
        long res = 0;
        used[root]=true;
        for(Edge e : eList[root])if(!used[e.to]){
            res += e.cost*2*size[e.to] + dfs2(e.to);
        }
        return res;
    }

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        eList = new ArrayList[N];
        size = new int[N];
        used = new boolean[N];
        for(int i=0;i<N;++i)eList[i]=new ArrayList<>();
        for(int i=0;i<N-1;++i){
            int a=scan.nextInt()-1;
            int b=scan.nextInt()-1;
            long c=scan.nextLong();
            eList[a].add(new Edge(b,c));
            eList[b].add(new Edge(a,c));
        }
        dfs(0);
        int root = 0;
        Arrays.fill(used,false);
        while(true){
            if(used[root])break;
            used[root]=true;
            for(Edge e : eList[root]){

                if(!used[e.to]&&size[e.to]>N/2){
                    root = e.to;
                    break;
                }
            }
        }
        Arrays.fill(used,false);
        dfs(root);
        Arrays.fill(used,false);
        long ans = dfs2(root);
        long def = Long.MAX_VALUE;
        for(Edge e : eList[root])def=Math.min(def,e.cost);
        for(Edge e : eList[root])if(N%2==0 && size[e.to]==N/2)def=e.cost;
        System.out.println(ans-def);
    }
}

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

#define fi first
#define se second
#define all(x) x.begin(), x.end()
using namespace std;
using ull = unsigned long long;
using ll = long long;
constexpr int I_INF = INT_MAX;
constexpr ll L_INF = LLONG_MAX;
const long double PI = (acos(-1));
const ull MOD = 1000000007;


struct __INIT {
    __INIT() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(15);
    }
} __init;

int main(){
    int N;
    ll K;
    cin >> N >> K;
    vector<pair<int,int>> AB(N);
    for(int i = 0; i < N; i++) cin >> AB[i].fi >> AB[i].se;
    sort(all(AB));
    ll sum = 0;
    for(auto p : AB){
        sum += p.se;
        if(sum >= K){
            cout << p.fi << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int n,k,sum=0;	cin >> n >> k;
  vector <int> v;
  for(int i=0;i<n;i++){
        int x;    cin >> x;
        v.push_back(x);
  }
  
  sort(v.begin(),v.end());
  for(int i=0;i<k;i++) sum+=v[i];
  
  cout << sum << "\n";
}

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

using namespace std;

int main(){
	int a;
	cin >> a;
	int b;
	int x;
	for(int i = 1; i <= a; i++){
		
		if( i % 3  == 0 ){
			cout << " " << i ;
			b = 1;
		}
		
		x = i;
		
		if( x % 10 == 3 && b == 0){
			cout << " " << i;
			b = 1;
		}
		
		while( x % 10 != 3 && b == 0 && x != 0 ) {
			x = x/10;
			if( x % 10 == 3){
				cout << " " << i ;
				x = x / 10;
				b = 1;
			}
		}
		
		
		
	b = 0;
	}
	
	cout << endl;
}
	
	


Measured memory_bytes: 3044
# 入力
s,t = gets.chomp.split.map(&:to_s)
a,b = gets.chomp.split.map(&:to_i)
u = gets.chomp

# こたえ
if s == u
  print [(a-1),b].join(" ")
else
  print [a,(b-1)].join(" ")
end

Measured memory_bytes: 1788
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s_a = in.nextLine();
		String s_b = in.nextLine();
		String s_c = in.nextLine();

		int a = 0;
		int b = 0;
		int c = 0;


		char currentChar = 'a';
		while (true) {
			if (currentChar == 'a') {
				if (a == s_a.length()) {
					System.out.println('A');
					break;
				}
				currentChar = s_a.charAt(a);
				a++;

			} else if(currentChar=='b') {
				if(b==s_b.length()) {
					System.out.println('B');
					break;
				}
				currentChar = s_b.charAt(b);
				b++;

			} else if(currentChar=='c') {
				if (c == s_c.length()) {
					System.out.println('C');
					break;
				}
				currentChar = s_c.charAt(c);
				c++;
							}
		}

	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define fin '\n'
using namespace std;
typedef long long ll;

constexpr int MX = 101010;
constexpr int MOD = (int)1e9 + 7;

int f[MX], finv[MX];

inline ll sqr(ll n)
{
    return n * n;
}

inline int modPow(int n, int p)
{
    if (p <= 0) return 1;
    ll ret = sqr(modPow(n, p/2)) % MOD;
    if (p & 1) (ret *= n) %= MOD;
    return ret;
}

void preCalc()
{
    f[0] = finv[0] = 1;
    for (ll i = 1; i < MX; ++i) {
        f[i] = i * f[i-1]  % MOD;
        finv[i] = modPow(f[i], MOD-2);
    }
    return;
}

int combi(int n, int k)
{
    if (k < 0 || n < k) return 0;
    return 1LL * f[n] * finv[k] % MOD * finv[n-k] % MOD;
}

int main()
{
    int N, A[100000];
    int appear[100000];
    int i, left = -1, right = -1;

    for(i = 0; i < 100000; i++) appear[i] = 0;
    preCalc();

    scanf("%d", &N);
    ++N;
    for(i = 0; i < N; i++) {
        scanf("%d", &A[i]);
        --A[i];
        ++appear[A[i]];
    }


    for(i = 0; i < N; i++) {
        if(appear[A[i]] == 2) {
            left = i;
            break;
        }
    }
    for(i = N - 1; i >= 0; i--) {
        if(appear[A[i]] == 2) {
            right = N - i - 1;
            break;
        }
    }

    for(i = 1; i <= N; i++) {
        printf("%d\n", (combi(N, i) + MOD - combi(right + left, i - 1)) % MOD);
    }

    return (0);
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}



int distance(std::vector<int> A,std::vector<int> B){
	int ans = 0;
	for (int i = 0; i < (int)A.size(); ++i)
	{
		ans += (A[i] - B[i])*(A[i] - B[i]);
	}

	return ans;
}

bool check(int a){
	bool isAns = false;

	for (int i = 0; i < 1000; ++i)
	{
		if(a==i*i) isAns = true;
	}

	return isAns;
}

int main() {
	int n,d; cin >> n >> d;
	std::vector<std::vector<int>> v(n);
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < d; ++j)
		{
			int x; cin >> x;
			v[i].push_back(x);
		}
	}

	int ans;

	for (int i = 0; i < n - 1; ++i)
	{
		for (int j = i + 1; j < n; ++j)
		{
			if(  check( distance(v[i],v[j]) )  ) ans++;
		}
	}

	cout << ans << endl;

























}

Measured memory_bytes: 256
//17
#include<iostream>
#include<iomanip>
 
using namespace std;
 
int main(){
  double sum=0,na=0;
  double a=0;
  for(int t,s;(cin>>t).ignore()>>s;){
    sum+=t*s;
    a+=s;
    na++;
  }
  cout<<(int)sum<<endl<<(int)(a/na+0.5)<<endl;
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <string>
using namespace std;
using ll=long long;

const ll nmax=1000;
ll x[nmax+1],y[nmax+1],z[nmax+1];


int main(){
    ll N,M;
    cin>>N>>M;
    for(int i=0;i<N;i++)cin>>x[i]>>y[i]>>z[i];
    ll sl[N];
    ll ans=0;
    for(int i=0;i<=1;i++){
        for(int j=0;j<=1;j++){
            for(int k=0;k<=1;k++){
                for(int l=0;l<N;l++)sl[l]=pow(-1,i)*x[l]+pow(-1,j)*y[l]+pow(-1,k)*z[l];
                sort(sl,sl+N,greater<ll>());
                ll ct=0;
                for(int i=0;i<M;i++)ct+=sl[i];
                ans=max(ans,ct);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 512
#include <stdio.h>

int main(void)

{


    int a,b,c,tmp;

    scanf("%d %d %d",&a,&b,&c);

    if(a>b){

        tmp=a;


        a=b;


        b=tmp;


    }


    if(b>c){


        tmp=b;


        b=c;


        c=tmp;


    }


    if(a>b){


        tmp=a;


        a=b;


        b=tmp;


    }


    printf("%d %d %d\n",a,b,c);


    return 0;


}

Measured memory_bytes: 596
use proconio::input;
// use std::collections::HashMap;

#[allow(non_snake_case)]
fn main() {
    input! {
        N: i32,
    }

    if N % 2 == 0 {
        let ans = N / 2 - 1;
        println!("{}", ans);
    } else {
        let ans = (N - 1) / 2;
        println!("{}", ans);
    }

}


Measured memory_bytes: 2120
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std; 
int main(){
    int a,b;
    cin>>a>>b;
    if (a%b==0) cout<<0<<endl;
    else cout<<1<<endl; 
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>void prt(T x){cout << x << endl;}
template<class T>void prtvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} cout << a[a.size()-1] << endl;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef pair<double, double> P;
void koch(int n, P p1, P p2){
    if(n==0) return;

    P s, t, u;
    s.first = (p2.first + 2*p1.first)/3;
    s.second = (p2.second+2*p1.second)/3;
    t.first = (2*p2.first+p1.first)/3;
    t.second = (2*p2.second+p1.second)/3;
    u.first = (t.first - s.first)*cos(M_PI/3) - (t.second - s.second)*sin(M_PI/3) +s.first;
    u.second = (t.first - s.first)*sin(M_PI/3) + (t.second - s.second)*cos(M_PI/3) +s.second; 

    koch(n-1, p1, s);
    printf("%lf %lf\n", s.first, s.second);
    koch(n-1, s, u);
    printf("%lf %lf\n", u.first, u.second);
    koch(n-1, u, t);
    printf("%lf %lf\n", t.first, t.second);
    koch(n-1, t, p2);
}

int main()
{
    int n;cin>>n;
    P p1=P(0.0, 0.0), p2=P(100.0, 0);
    printf("%lf %lf\n", p1.first, p1.second);
    koch(n, p1, p2);

    printf("%lf %lf\n", p2.first, p2.second);
    return 0;
}


Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int N,M;
  cin>>N>>M;
  vector<int> cnt(N,0);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    cnt[a-1]++;
    cnt[b-1]++;
  }
  for(auto &e:cnt){
    cout<<e<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int l, n;
	cin >> l >> n;
	vi v(n);
	int sum = 0;
	rep(i, n) {
		int x, w;
		cin >> x >>w;
		sum += x * w;
	}
	if(sum == 0) {
		cout<<0<<endl;
		return 0;
	}
	for(int i = l; i >=1; i--) {
		if(abs(sum) % i == 0) {
			cout<<1<<endl;
			if(sum < 0) cout<<i<<" "<<abs(sum)/i<<endl;
			else cout<<-i<<" " << sum / i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3088
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const ll INF = LLONG_MAX;

typedef ll Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void Dijkstra(const Graph &g, int s,
              vector<Weight> &dist, vector<int> &prev) {
    int n = (int)g.size();
    dist.assign(n, INF); dist[s] = 0;
    prev.assign(n, -1);
    priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
    for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
        Edge e = Q.top(); Q.pop();
        if (prev[e.dst] != -1) continue;
        prev[e.dst] = e.src;
        for(Edge f: g[e.dst]) {
            if (dist[f.dst] > e.weight+f.weight) {
                dist[f.dst] = e.weight+f.weight;
                Q.push(Edge(f.src, f.dst, e.weight+f.weight));
            }
        }
    }
}

int main() {
  ll n,m,s,t;
  cin >> n >> m >> s >> t;
  s--;t--;
  Graph ga(n),gb(n);
  repeat(i,m){
    int u,v;
    Weight a,b;
    cin >> u >> v >> a >> b;
    u--;v--;
    ga[u].push_back(Edge(u,v,a));
    ga[v].push_back(Edge(v,u,a));
    gb[u].push_back(Edge(u,v,b));
    gb[v].push_back(Edge(v,u,b));
  }
  vector<Weight> dia,dib;
  vint pa,pb;
  Dijkstra(ga,s,dia,pa);
  Dijkstra(gb,t,dib,pb);
  vector<Weight> ans(n,INF);
  repeat(i,n){
    ans[n-i-1] = dia[n-i-1]+dib[n-i-1];
    if(i>0){
      ans[n-i-1] = min(ans[n-i-1],ans[n-i]);
    }
  }
  repeat(i,n){
    cout << (ll)1e15-ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 19780
import bisect
import sys
input = sys.stdin.readline
n = int(input())
a = list(map(int,input().split()))
d = int(input())
graph = [[0 for i in range(n+1)] for j in range(18)]
for i in range(n):
  x = bisect.bisect_right(a,a[i]+d)
  graph[0][i+1] = x
for j in range(1,18):
  for i in range(n):
    t = graph[j-1][i+1]
    graph[j][i+1] = graph[j-1][t]
q = int(input())
for _ in range(q):
  x,y = map(int,input().split())
  x,y = min(x,y),max(x,y)
  ans = 0
  for j in range(18)[::-1]:
    if graph[j][x] < y:
      ans += 2**j
      x = graph[j][x]
    if j == 0 and x < y:
      ans += 1
  print(ans)

Measured memory_bytes: 118628
#include<iostream>
using namespace std;
int main()
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	bool flag;
	if(abs(a-c) <= d) flag = true;
	else{
		if(abs(a-b) <= d && abs(b-c) < d) flag =true;
		else flag =false;
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}


Measured memory_bytes: 256
/**
 * D - Coloring Edges on Tree
 * https://atcoder.jp/contests/abc146/tasks/abc146_d
 **/
#include<iostream>
#include<vector>
#include<map>
#include<queue>

using namespace std;

/**
 * 方針
 * 幅優先探索で根から順に色をつけていく
 **/

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> vp;  // 入力の順番を管理
    vector<vector<int>> G(N);   // それぞれの頂点に連結する頂点を管理
    for(int i=1; i<N; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        vp.emplace_back(make_pair(a, b));
    }
    int K = 0;
    map<pair<int, int>, int> c; // 各辺の色を管理
    vector<int> cs(N, 0);       // 親の色を管理
    vector<int> used(N, 0);     // 既に訪れている頂点（１）

    queue<int> que;
    que.push(0);
    used[0] = 1;
    while(!que.empty()) {
        int v = que.front(); que.pop();
        if(K < G[v].size()) K = G[v].size();    // 連結する子の数より色が少なかったら更新
        int cur = 1;
        for(int u:G[v]) {
            if(used[u] == 1) continue;
            if(cs[v] == cur) cur++;
            cs[u] = c[make_pair(u, v)] = c[make_pair(v, u)] = cur++;
            used[u] = 1;
            que.push(u);
        }
    }


    // 解答出力
    cout << K << endl;
    for(auto v:vp) cout << c[v] << endl;
}

Measured memory_bytes: 20084
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
int main()
{
  int N;
  cin >> N;
  int v;

  for(int i=1; i < 10; i++){
    v = i + 10*i + 100 * i;
    if(N <= v){
      cout << v << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_7_B&lang=ja
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
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;}
int solve(){
  ll n,x; cin>>n>>x;
  if (n==0)return -1;
  ll ans=0;
  FOR(a,1,n+1){
    FOR(b,a+1,n+1) FOR(c,b+1,n+1){
      if(a+b+c==x)++ans;
    }
  }
  cout<<ans<<endl;
  return ans;
}
int main() {
  while(true){
    if (solve()<0)break;
  }
  return 0;
}


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

int main(){

  int A, B, C;
  cin >> A >> B >> C;

  if((C>=A && C<=B) || (C>=B && C<=A)){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    cin >> S;
    if(S != "AAA" and S!= "BBB"){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0;i<N;++i) cin >> A.at(i);
  int ans=0;
  for(int i=0;i<N;++i){
    for(int j=i+1;j<N;++j){
      ans=max(ans,abs(A.at(i)-A.at(j)));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    S = input()
    if N % 2 == 1:
        print("No")
        quit()
    n = N // 2
    yesno = "Yes" if S[:n] == S[n:] else "No"
    print(yesno)


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <math.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define ld long double
#define int long long
#define ii pair<int,int>
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL); clock_t beg = clock()
#define dbg(x) cerr << #x << " is " << x << endl;
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define vi vector<int >
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
const int N = 3e5+7 ;
const int INF = 1e18 ;
const int MOD = 1e9 + 7 ;
string s ;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
//const int MOD = 998244353;
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
int choose(int a, int b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	return mult(fact[a],mult(ifact[b],ifact[a-b]));
}
int inverse(int a)
{
	return modpow(a,MOD-2);
}
void init(int _n)
{
	fact.clear(); ifact.clear(); inv.clear(); pow2.clear();
	fact.resize(_n+1);
	ifact.resize(_n+1);
	inv.resize(_n+1);
	pow2.resize(_n+1);
	pow2[0]=1;
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=_n;i++)
	{
		pow2[i]=add(pow2[i-1],pow2[i-1]);
		fact[i]=mult(fact[i-1],i);
		//ifact[i]=mult(ifact[i-1],inv[i]);
	}
	ifact[_n] = inverse(fact[_n]);
	for(int i=_n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
	for(int i=1;i<=_n;i++)
	{
		inv[i] = mult(fact[i-1],ifact[i]);
	}
}


void solve(){
	int  n , m;
	cin >> n >> m ;
	init(N) ;
	int ans = 0 ;
	for(int k = 0 ; k <= min(n-1,m) ; k++){
		ans = add(ans,mult(choose(n,k), choose(n-1,k))) ;
	}
	cout << ans<< endl ;
}

int32_t main(){
	FAST_IO ;
	int t = 1 ;
//	cin >> t ;
	while(t--){
		solve() ;
	}
    cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
}


Measured memory_bytes: 10240
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for (int i=0;i<=N;i++) {
			if ((int)(i*1.08)==N) {
				System.out.println(i);
				return ;
			}
		}
		System.out.println(":(");
	}
}


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

using namespace std;

int mod, ans, N, K, dp[2009][2009], s[2009][2009];
int fac[4000009], inv[4000009];

int pow (int a, int b, int mod)
{
    int p = 1;
    for (int i=0; (1<<i) <= b; i++)
    {
        if (b & (1 << i)) p = (1LL * p * a) % mod;
        a = (1LL * a * a) % mod;
    }
    return p;
}

int comb (int n, int k)
{
    if (k > n || k < 0) return 0;
    int ans = (1LL * fac[n] * inv[k]) % mod;
    ans = (1LL * ans * inv[n - k]) % mod;
    return ans;
}

void PreProc ()
{
    fac[0] = 1;
    for (int i=1; i<=N * K; i++)
        fac[i] = (1LL * fac[i - 1] * i) % mod;
    inv[N * K] = pow (fac[N * K], mod - 2, mod);
    for (int i=N * K - 1; i>=0; i--)
        inv[i] = (1LL * inv[i + 1] * (i + 1)) % mod;
}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d", &N, &K), mod = 1e9 + 7;
if (K == 1)
{
    printf ("1\n");
    return 0;
}
PreProc ();
dp[0][0] = s[0][0] = 1;
for (int i=1; i<=N; i++)
    for (int j=1; j<=i; j++)
    {
        int coef = comb (i * K - j - 1, K - 2), sum = s[i - 1][i - 1];
        if (j > 1)
        {
            sum -= s[i - 1][j - 2];
            if (sum < 0) sum += mod;
        }
/*        for (int k=j - 1; k<i; k++)
            sum += dp[i - 1][k];
        dp[i][j] = sum * coef;*/
        dp[i][j] = (1LL * sum * coef) % mod;
        s[i][j] = s[i][j - 1] + dp[i][j];
        if (s[i][j] >= mod) s[i][j] -= mod;
    }
printf ("%d\n", (1LL * fac[N] * s[N][N]) % mod);
return 0;
}


Measured memory_bytes: 59136
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(a,b) for(int a=0;a<(b);++a)
#define REP1(i,n) for(int i=1;i<=(n);++i)
#define debug(x) cerr<<#x<<": "<<x<<'\n'
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1<<29)
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define X first
#define Y second
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;


template<class T=int>
T in(){T x;cin>>x;return (x);}
template<class T>
void print(T& x){cout<<x<<'\n';}

const int MOD =(int)1e9+7;
const int mod =(int)1e9+7;
const int MAX =510000;
ll fac[MAX],finv[MAX],inv[MAX];
void COMint(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
ll gcd(ll a,ll b){
    if(b==0)return a;
    if(a>b){
        swap(a,b);
    }
    return gcd(a,b%a);
}
ll lcm(ll a,ll b){
    ll g;g=gcd(a,b);
    return a*b/g;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

bool compare_by_a(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
    }else{
        return a.second < b.second;
    }
}
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;
}

ll RS(ll N,ll P,ll M){
    if(P==0){
        return 1;
    }else{
        if(P%2==0){
            ll t=RS(N,P/2,M);
            return t*t%M;
        }else{
            return N*RS(N,P-1,M)%M;
        }
    }
}
int N;
string S;

bool notequal(char a,char b,char c){
    if(a==b||a==c||b==c)return false;
    return true;
}
bool check(char c){
    if(c=='A'||c=='C'||c=='G'||c=='T')return true;
    return false;
}
int main() {
    ios::sync_with_stdio(false);
    string S=in<string>();
    int ans=0;
    int ans_temp=0;
    REP(i,S.size()){
        if(check(S[i])){
            ans_temp++;
        }else{
            ans=max(ans,ans_temp);
            ans_temp=0;
        }
    }
    ans=max(ans,ans_temp);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
S,T = input(),input()
str = "abcdefghijklmnopqrstuvwxyz"
dic,dic2 = [[] for _ in str],[[] for _ in str]
for i in range(len(S)):
    dic[str.index(S[i])].append(i)
for i in range(len(T)):
    dic2[str.index(T[i])].append(i)
dic.sort()
dic2.sort()
print("Yes" if dic == dic2 else "No")


Measured memory_bytes: 20400