akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, s, cnt, sum;
    int a[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};

    while (true) {
        cin >> n >> s;
        if (!n && !s) break;

        int arr[10] = {0};
        for (int i = 0; i < n; i++) { arr[9-i] = 1; }
        cnt = 0;
        do {
            sum = 0;
            for (int i = 0; i < 10; i++) {
                if(arr[i]) { sum += a[i]; }
            }
            if (sum == s) cnt++;
        } while(next_permutation(arr, arr+10));

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

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

int main()
{
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    if(s[k-1]>='A'&&s[k-1]<='Z')s[k-1]+=32;
    cout<<s<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int h = scanner.nextInt();

		System.out.println((a + b) * h/2);
		scanner.close();
	}
}

Measured memory_bytes: 24020
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdlib>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<time.h>
#include<tuple>
#include<utility>
#include<vector>

using namespace std;


int main() {

	long res = 0;
	long H, W; cin >> H >> W;
	vector<vector<bool>> visited(H, vector<bool>(W));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) { char a; cin >> a; visited[i][j] = (a == '#'); if (a == '.') res++; }

	queue<pair<long, long>> task;
	vector<vector<long>> dist(H, vector<long>(W , -1));
	task.push(make_pair(0, 0)); dist[0][0] = 1;

	long dx[4] = { 1 , 0 , -1 , 0 };
	long dy[4] = { 0 , 1 , 0 , -1 };

	while (!task.empty()) {
		long x = task.front().first, y = task.front().second;
		task.pop();
		visited[x][y] = true;

		for (int i = 0; i < 4; i++) {
			long nx = x + dx[i], ny = y + dy[i];
			if (0 <= nx && nx < H && 0 <= ny && ny < W) if (!visited[nx][ny]) {
				task.push(make_pair(nx, ny));
				visited[nx][ny] = true;
				dist[nx][ny] = dist[x][y] + 1;
			}
		}

	}

	res -= dist[H - 1][W - 1];

	if (dist[H - 1][W - 1] == -1) cout << -1 << endl; else cout << res << endl;

}

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

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;
}
struct Unionfind {
    vector<int> par;

    Unionfind(int n) : par(n) {
        for(int i = 0; i < n; ++i) par[i] = i;
    }

    int root(int x) {
        if(par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] =ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int k;
    cin >> k;

    queue<ll> q;
    for(int i = 1; i <= 9; ++i) {
        q.push(i);
    }

    rep(i, k-1) {
        ll v = q.front();
        q.pop();
        int rem_v = v % 10;
        if(rem_v == 0) {
            q.push(10 * v);
            q.push(10 * v + 1);
        }
        else if(rem_v == 9) {
            q.push(10 * v + rem_v - 1);
            q.push(10 * v + rem_v);
        }
        else {
            q.push(10 * v + rem_v - 1);
            q.push(10 * v + rem_v);
            q.push(10 * v + rem_v + 1);
        }
    }

    ll ans = q.front();
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4780
#include<cstdio>
#include<iostream>
#include<string>
#include <algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
using namespace std;
using ll = long long;



int main(){
	int n, s[100];
	while (1){
		cin >> n;
		if (n == 0) break;
		for (int i = 0; i < n; i++) cin >> s[i];
		sort(s, s + n);
		int k = 0;
		for (int i = 1; i < n - 1; i++) {
			k += s[i];
		}
		cout << k / (n-2) << endl;
	}

}



Measured memory_bytes: 3000
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;


int main()
{
	char c;
	cin >> c;
	c += 1;

	cout << c << endl;
	return 0;
} 

Measured memory_bytes: 3640
def solve():
  n = int(input())
  c = [0]*n
  s = [0]*n
  f = [0]*n
  for i in range(0, n-1):
    c[i],s[i],f[i] = map(int, input().split())
    
  for i in range(0, n):
    t = 0
    for j in range(i, n-1):
      if t < s[j]:
        t = s[j]
      if t%f[j] > 0:
        t += f[j] - (t%f[j])
      t += c[j]
    print(t)
    
solve()

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

int main(){
    int n;
    cin >> n;
    int F[50];
    F[0] = F[1] = 1;
    for(int i=2; i<=n; i++)
        F[i] = F[i-1] + F[i-2];

    cout<<F[n]<<endl;

    return 0;
}


Measured memory_bytes: 3112
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<vector>
#include<map>
#include<stack>
#include<set>
#include<cstdlib>
#include<deque>
#include<queue>
#include<bitset>
#include<functional>
#include<utility>
#include<list>
#include<iomanip>
#include<ctime>
#include<cassert>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const int INF=1e9+1;
int a[200005];
vector<int> ans;
int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int i=n;
	while(i>=2)
	{
		ans.push_back(a[i]);
		i-=2;
	}
	ans.push_back(a[1]);
	if(n%2==0) i=3;
	else i=2;
	while(i<=n)
	{
		ans.push_back(a[i]);
		i+=2;
	}
	for(int j=0;j<ans.size();j++)
	{
		cout<<ans[j]<<" ";
	}
	cout<<endl;
	return 0;
}

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


int main() {
  int n, k;
  cin >> n >> k;
  vector<int> d(k);
  rep(i,k){
    cin >> d[i];
  }
  for (int i = n; i < 100000; i++){
    int num = i;
    bool ans = true;
    while(num > 0){
      int a = num % 10;
      rep(i, k){
        if(d[i] == a){
          ans = false;
        }
      }
      num /= 10;
    }
    if(ans){
      cout << i << endl;
      return 0;
    }
  }
}

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

int main(){
  complex<double> a,b,c,r;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf",&a.real(),&a.imag(),&b.real(),&b.imag(),&c.real(),&c.imag())>0){
    r=((b-a)/abs(b-a))/(((c-a)/(abs(c-a)))/((b-a)/abs(b-a)))*abs(c-a)+a;
    printf("%.6lf %.6lf\n",r.real(),r.imag());
  }
  return 0;
}

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

using namespace std;

int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int w,h;

int saiki(int count,int j,vector< vector<int> > map,int x,int y){
    int res = 11;
    while(true){
	x += dx[j];
	y += dy[j];
	if(x<0||x>=w||y<0||y>=h){
	    return 11;
	}else if(map[y][x] == 1){
	    map[y][x] = 0;
	    break;
	}else if(map[y][x] == 3){
	    return count;
	}
    }
    if(count == 10 ) return 11;
    x -= dx[j];
    y -= dy[j];
    for(int i=0;i<4;i++){
	if(x+dx[i]>-1&&x+dx[i]<w&&y+dy[i]>-1&&y+dy[i]<h&&map[y+dy[i]][x+dx[i]] != 1){
	    res = min(res,saiki(count+1,i,map,x,y));
	}
    }
    return res;
}


int main(){

    
    int temp;
    int x,y;
    vector< vector<int> > map;
    while(true){
    cin >> w >> h;
    if(w == 0 && h==0) break;
    for(int i=0;i<h;i++){
	map.push_back(vector<int>());
	for(int j=0;j<w;j++){
	    cin >> temp;
	    map[i].push_back(temp);
	    if(temp == 2){
	       	x = j;
		y = i;
	    }
	}
    }
    int res=11;
    for(int i=0;i<4;i++){
	if(x+dx[i]>-1&&x+dx[i]<w&&y+dy[i]>-1&&y+dy[i]<h&&map[y+dy[i]][x+dx[i]] != 1){
	    res = min(res,saiki(1,i,map,x,y));
	}
    }
    if(res > 10) res = -1;
    cout << res << endl;
    map.clear();
    }

    return 0;
}

Measured memory_bytes: 1276
module Vector =
  struct
    type t = { x: float; y:float }
    let eps = 1e-10
    let set x y = {x = x; y = y}
    let add v1 v2 = {x = v1.x +. v2.x; y = v1.y +. v2.y}
    let sub v1 v2 = {x = v1.x -. v2.x; y = v1.y -. v2.y}
    let mul v a = {x = v.x *. a; y = v.y *. a}
    let div v a = {x = v.x /. a; y = v.y /. a}
    let norm v = v.x *. v.x +. v.y *. v.y
    let abs v = sqrt (norm v)
    let dot v1 v2 = v1.x *. v2.x +. v1.y *. v2.y
    let cross v1 v2 = v1.x *. v2.y -. v1.y *. v2.x
  end


let _ =
  let cp a b c = 
    let v1 = Vector.sub b a in
    let v2 = Vector.sub c a in
    Vector.cross v1 v2 in
  try
    while true do
      let p1, p2, p3, pp = Scanf.scanf "%f %f %f %f %f %f %f %f\n" (fun x1 y1 x2 y2 x3 y3 xp yp -> ((Vector.set x1 y1), (Vector.set x2 y2), (Vector.set x3 y3), (Vector.set xp yp))) in
      let cp1 = cp p1 p2 pp in
      let cp2 = cp p2 p3 pp in
      let cp3 = cp p3 p1 pp in
      if ((cp1 > 0.) && (cp2 > 0.) && (cp3 > 0.)) || ((cp1 < 0.) && (cp2 < 0.) && (cp3 < 0.)) then
        print_endline "YES"
      else
        print_endline "NO"
    done
  with
    End_of_file -> ()

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

vector<int> dx={1,0,0,-1};
vector<int> dy={0,1,-1,0};

int h,w;
bool seen[410][410];
char a[410][410];

long long countw,countb;
void dfs(int i,int j){
	seen[i][j]=true;
	if(a[i][j]=='#') countb++;
	else if(a[i][j]=='.') countw++;
	for(int k=0;k<4;k++){
		int nx=i+dx[k];
		int ny=j+dy[k];
		if(nx<0||nx>=h||ny<0||ny>=w) continue;
		if(a[i][j]==a[nx][ny]) continue;
		if(seen[nx][ny]) continue;
		dfs(nx,ny);
	}
}

int main() {
	cin >> h >> w;
	for(int i=0;i<h;i++){
		string s;
		cin >> s;
		for(int j=0;j<w;j++){
			a[i][j]=s[j];
		}
	}
	long long res=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(a[i][j]=='.') continue;
			if(seen[i][j]) continue;
			countw=0;
			countb=0;
			dfs(i,j);
			res+=countw*countb;
		}
	}
	cout << res << endl;
}


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

int main(){
  int N,Q;
  cin>>N>>Q;
  string S;
  cin>>S;
  int len=S.length();
  int AC[len+1];
  AC[0]=0;
  int flag=0;
  int cnt=0;
  for(int i=0;i<len;i++){
    if(flag==1 && S.at(i)=='C'){
      cnt++;
    }
    if(S.at(i)=='A'){
      flag=1;
    }
    else{
      flag=0;
    }

    AC[i+1]=cnt;
  }
  //cout<<AC[0]<<" "<<AC[1]<<" "<<AC[2]<<" "<<AC[3]<<endl;
  int l,r;
  for(int i=0;i<Q;i++){
    cin>>l>>r;
    cout<<AC[r]-AC[l]<<endl;
  }
  return 0;
}


Measured memory_bytes: 4152
import java.util.Scanner;
public class Main {
    public static void main(String args[]) {
        String answer = "YES";
        Scanner s = new Scanner(System.in);
        int sum = 0;
        for(int i = 0; i < 3; i++){
            int haiku = Integer.parseInt(s.next());
          if(haiku == 7 || haiku == 5 ){
              sum = sum + haiku;
          }
          else{
              answer = "NO";
          }
        } 
        if(sum != 17){
            answer = "NO";
        }
        System.out.println(answer);
    }
}

Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

signed main() {
	IOS();
	int n;
	string s;
	cin >> n >> s;
	ll a = 0, b = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'R')
			a++;
		else
			b++;
	}
	dump(a > b ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    import collections
    input = sys.stdin.readline
    N = int(input())
    S = [input() for i in range(N)]
    c = collections.Counter(S)
    max_num = c.most_common(1)[0][1]
    ss = []
    for cc in c.most_common():
        if cc[1] == max_num:
            ss.append(cc[0])
    ss.sort()
    print("".join(ss))

if __name__ == "__main__":
    main()

Measured memory_bytes: 122152
#include <iostream>

using namespace std;

int main(){
  int a;
  cin >> a;
  int h,m,s;
  h = a / 3600;
  m = (a - h * 3600) / 60;
  s = ((a - h * 3600) - m * 60);
  cout << h << ":" << m << ":" << s << endl;
  return 0;
}


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

#define INF 1001001001
#define MAX 1e18

const int mod = 998244353;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(k), r(k);
  rep(i,k) cin >> l[i] >> r[i];
  vector<int> dp(n+1);
  dp[0] = 1, dp[1] = mod-1;
  rep(i,n) {
    if(i) dp[i]=(dp[i]+dp[i-1])%mod;
    rep(j,k) {
      if (i+l[j]<=n) dp[i+l[j]] = (dp[i+l[j]]+dp[i])%mod;
      if (i+r[j]+1<=n) dp[i+r[j]+1] = (dp[i+r[j]+1]+mod-dp[i])%mod;
    }
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 4004
#include<stdio.h>
 
#define N 8
#define free -1
#define notfree 1
#define FALSE 2
#define TRUE 3
 
int row[N],col[N],dpos[2*N-1],dneg[2*N-1];
int X[N][N];
 
void initialize(void);
void printboard(void);
void recursive(int);
 
void initialize(){
  int i;
 
  for(i=0;i<N;i++){
    row[i] = free;
    col[i] = free;
  }
 
  for(i=0;i<2*N-1;i++){
    dpos[i] = free;
    dneg[i] = free;
  }
}
 
void printboard(){
  int i,j;
 
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      if(X[i][j] == TRUE){
    if(row[i] != j)return;
      }
 
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      if(row[i] == j)printf("Q");
      else printf(".");
    }
    printf("\n");
  }
}
 
void recursive(int i){
  int j;
 
  if(i == N){
    printboard();
    return;
  }
 
  for(j=0;j<N;j++){
    if(notfree == col[j] || notfree == dpos[i+j] || notfree == dneg[i-j+N-1])continue;
    row[i] =j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = notfree;
    recursive(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = free;
  }
}
int main(){
  int i,j,k,r,c;
 
  initialize();
 
  for(i=0;i<N;i++)
    for(j=0;j<N;j++)
      X[i][j] = FALSE;
 
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d %d",&r,&c);
    X[r][c] = TRUE;
  }
 
  recursive(0);
 
  return 0;
}
 

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 998244353;

struct mint {
  ll x;
  mint(ll x=0):x((x%MOD+MOD)%MOD){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += MOD-a.x) >= MOD) x -= MOD;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= MOD; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
      mint a = pow(t>>1);
      a *= a;
    if (t&1) a *= *this;
      return a;
  }
   mint inv() const { return pow(MOD-2);}
   mint& operator/=(const mint a) { return *this *= a.inv();}
   mint operator/(const mint a) const { return mint(*this) /= a;}
};
typedef vector<mint> vm;
typedef vector<vm> vvm;
  
int main() {
  int N,K;
  cin >> N >> K;
  vi A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vm dp(K+1,0);
  dp[0]=1;
  rep(i,N) {
    vm dp2(K+1,0);
    rep(j,K+1) {
      dp2[j] += dp[j]*2;
      if(A[i]+j>K) continue;
      dp2[j+A[i]] += dp[j];
    }
    dp = dp2;
  }
  cout << dp[K].x << endl;
  return 0;
}

Measured memory_bytes: 3668
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0)
    {
        if(b&1)
            res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)
        return true;
    while(d!=n-1)
    {
        x=(x*x)%n;
        d*=2;
        if(x==1)
            return false;
        if(x==n-1)
            return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)
        return false;
    if(n<=3)
        return true;
    ll d=n-1;
    while(d%2==0)
        d/=2;
    for(int i=0; i<k; i++)
    {
        if(!miller_rabin(d,n))
            return false;
    }
    return true;
}
bool p[100005];
void sieve()
{
    memset(p,true,sizeof(p));
    p[0]=p[1]=false;
    for(int i=2;i*i<=100000;i++){
        if(p[i]){
            for(int j=i*i;j<=100000;j+=i){
                p[j]=false;
            }
        }
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    sieve();
    int cnt[100001]={0};
    for(int i=2;i<=100000;i++){
        if(p[i] && p[(i+1)/2]){
            cnt[i]=1;
        }
        cnt[i]+=cnt[i-1];
    }
    int q;
    cin>>q;
    while(q-->0){
        int l,r;
        cin>>l>>r;
        cout<<cnt[r]-cnt[l-1]<<endl;
    }
}


Measured memory_bytes: 4088
package main

import (
  "fmt"
  "sort"
  "strings"
)

func main() {
  var n int
  var s string
  var ans int64
  mp := map[string]int{}

  fmt.Scan(&n)

  for i := 0; i < n; i++ {
    fmt.Scan(&s)
    slice := strings.Split(s, "")
    sort.Strings(slice)
    s = strings.Join(slice, "")
    ans += int64(mp[s])
    mp[s]++
  }

  fmt.Println(ans)
}

Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,v,n,i;
    vector<int>s;
    cin>>n;
    for(i=0;i<n;i++){
        cin>>a;
        s.push_back(a);
    }
    int c=0;
    sort(s.begin(),s.end());
    for(i=0;i<n-1;i++){
        v=abs(s[i]-s[i+1]);
        c=c+v;
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i, h) cin >> s[i];

    int ans = 0;
    rep(hmask, 1 << h) rep(wmask, 1 << w) {
        vector<string> t(s);
        rep(i, h) if (hmask >> i & 1) { rep(j, w) t[i][j] = 'R'; }
        rep(i, w) if (wmask >> i & 1) { rep(j, h) t[j][i] = 'R'; }

        int ct = 0;
        rep(i, h) rep(j, w) ct += (t[i][j] == '#');
        ans += (ct == k);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3632
N, A, B = map(int, input().split())
items = list(map(int, input().split()))

items.sort(reverse=True)

maxAvg = sum(items[:A]) / A

print(maxAvg)

fact = [1 for _ in range(N + 10)]

for i in range(1, N + 10):
    fact[i] = (fact[i - 1] * i)

def comb(n, r):
    if 0 < r < n:
        return fact[n] // fact[r] // fact[n - r]
    if r == 0 or r == n:
        return 1
    return 0


if items[0] == items[A - 1]:
    right = A - 1
    while right < N and items[right] == items[0]:
        right += 1
    ans = 0
    for take in range(A, B + 1):
        ans += comb(right, take)
    print(ans)
else:
    left = A - 1
    while left >= 0 and items[left] == items[A - 1]:
        left -= 1
    right = A - 1
    while right < N and items[right] == items[A - 1]:
        right += 1
    ans = comb(right - left - 1, A - left - 1)
    print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
struct NODE {
	int ans; int x; int y;
}a[100005];

int main()
{
	int n;
	int flag = 0;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%d %d %d", &a[i].ans, &a[i].x, &a[i].y);
	}
	for(int i = 1; i <= n; i++)
	{
		int a1 = a[i].ans - a[i - 1].ans;
		int a2 = abs(a[i].x - a[i - 1].x) + abs(a[i].y - a[i - 1].y);
		int p1 = a1 % 2;
		int p2 = a2 % 2;
		if(a1 >= a2 && p2 == p1) {
		}
		else {
			printf("No\n");
			flag = 1;
			break;
		}
	}
	if(flag == 0) printf("Yes\n");
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

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

    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d) )
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

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

bool	issmall(char c)
{
	return (c >= 'a' && c <= 'z');
}

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

	int n;
	cin >> n;
	int check;
	check = 1;
	int count;
	count = 0;
	rep(i, n)
	{
		int a;
		cin >> a;
		if (a == check)
			check++;
		else
			count++;
	}
	if (check == 1)
		count = -1;
	cout << count << endl;
}


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

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

    vector<int> a(N,0);
    for(int i=0; i < N; i++){
        cin >> a.at(i);
    }

    int point=0;

    for(int i=0; i < N; i++){
        if(i%2 == 0){
            int max=0;
            for(int j=0; j < N; j++){
                if(max <  a.at(j)){
                    max = a.at(j);
                }
            }
            for(int j=0; j < N; j++){
                if(max ==  a.at(j)){
                    a.at(j) = 0;
                    break;
                }
            }            
            point += max;
        }
        else{
            int max=0;
            for(int j=0; j < N; j++){
                if(max <  a.at(j)){
                    max = a.at(j);
                }
            }
            for(int j=0; j < N; j++){
                if(max ==  a.at(j)){
                    a.at(j) = 0;
                    break;
                }
            }  
            point -= max;
        }
    }

    cout << point << endl;
}

Measured memory_bytes: 256
import sys
import math  # noqa
import bisect  # noqa
import queue  # noqa


def input():
    return sys.stdin.readline().rstrip()


def main():
    H, W = map(int, input().split())
    C = [list(map(int, input().split())) for _ in range(10)]
    A = [list(map(int, input().split())) for _ in range(H)]

    for k in range(10):
        for i in range(10):
            for j in range(10):
                C[i][j] = min(C[i][j], C[i][k] + C[k][j])

    ans = 0
    for Ah in A:
        for a in Ah:
            if a != -1:
                ans += C[a][1]

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

#define sf scanf
#define pf printf
#define ll long long
#define fr(I,M,N) for(I=M;I<=N;I++)
#define fr_(I,M,N) for(I=M;I>=N;I--)
#define re return
#define sfn cin>>n
#define bal pf("bal\n")
#define pb push_back
#define ins insert
#define sz(X) X.size()
#define xx first
#define yy second
#define skip continue
#define memo(X,N) memset(X,N,sizeof(X))
#define all(X) X.begin(),X.end()
#define mp make_pair
#define pi acos(-1)


/*
#define nMX 5000000
#define pMX 500000
int pr[pMX+1],prnum[nMX+1];

int sieve()
{
    int i,j;
    for(i=1;i<=nMX;i++)
        prnum[i]=i+1;
    for(i=1;i<=nMX;i++)
        if(prnum[i]!=-1)
            for(j=2*prnum[i]-1;j<=nMX;j+=prnum[i])
                    prnum[j]=-1;
    j=0;
    for(i=1;i<=nMX;i++)
        if(prnum[i]!=-1)
            pr[++j]=prnum[i];
    re j;
}*/

/*ll m_ncr[10001][10001];
ll ncr(ll i,ll j)
{
    if(j==1) re i;
    if(i==j) re 1;
    if(m_ncr[i][j]!=-1) re m_ncr[i][j];
    re m_ncr[i][j]=ncr(i-1,j) + ncr(i-1,j-1);
}*/

/*ll m_fact[21];
ll fact(ll i)
{
    if(i==1 || i==0) re 1;
    if(m_fact[i]!=-1) re m_fact[i];
    re m_fact[i]=i*fact(i-1);
}*/

int main()
{
    ios_base::sync_with_stdio(0);
    ll int i,j,x,y,n,m,cnt=0,k,g,flg,t;
    char op[3543];
    op['A'] = 'T';
    op['T'] = 'A';
    op['C'] = 'G';
    op['G'] = 'C';
    char c;
    cin>>c;
    cout<<op[c];
}


Measured memory_bytes: 256
#include <cstdio>

int main(){
    char in[4];

    scanf("%c%c%c%c", &in[0],&in[1],&in[2],&in[3]);

    int ans = 0;
    for(int i=0; i<4; i++){
        if(in[i] == '+'){
            ans += 1;
        }else{
            ans -= 1;
        }
    }
    
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	int n,p[10000],d1[10000],d2[10000],bangou;
	while(1){
		int max=0;
		cin >> n;
		if(n==0)break;
		for(int i=0 ; i<n ; ++i){
			cin >> p[i] >> d1[i] >> d2[i];
		}
		for(int i=0 ; i<n ; ++i){
			if(max<d1[i]+d2[i]){
				max = d1[i]+d2[i];
				bangou = p[i];
			}
		}
		cout << bangou << " " << max << endl;
	}
	return 0;
}

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

using namespace std;

#define X first
#define Y second
#define eps  1e-5
#define gcd __gcd
#define pb push_back
#define PI acos(-1.0)
#define lowbit(x) (x)&(-x)
#define bug printf("!!!!!\n");
#define mem(x,y) memset(x,y,sizeof(x))

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef unsigned long long uLL;

const int maxn = 1e5+7;
const int INF  = 1<<30;
const int mod  = 1e9+7;

string s1,s2;

void solve(){
    cin>>s1>>s2;
    int ans  = 0;
    for(int i=0;i<3;i++){
        if(s1[i] == s2[i]) ++ans;
    }
    cout<<ans<<endl;
    return;
}

int main()
{
#ifndef ONLINE_JUDGE
   // freopen("in.txt","r",stdin);
#endif
//    freopen("out.txt","w",stdout);
//    ios::sync_with_stdio(false);
    int t = 1;
    scanf("%d",&t);
    while(t--){
    //    printf("Case %d: ",cas++);
        solve();
    }
#ifndef ONLINE_JUDGE
  //  printf("%.10f\n",1.0*clock()/CLOCKS_PER_SEC);
#endif
    return 0;
}

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

int main() {
    string S, T;
    cin >> S >> T;

    int ans = T.size();

    for (int start = 0; start <= S.size() - T.size(); start++) {
        int diff = 0;
        for (int i = 0; i < T.size(); i++) {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll power(ll a,ll b,ll mod)
{
	a%=mod;
	ll res=1;
	while(b>0)
	{
		if(b%2) res=(res*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}
ll getop(ll x,ll mod)
{
	if(x!=0) return 1+getop(x%mod,__builtin_popcountll(x%mod));
	else return 0;
}
void solve()
{
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll mod=0;
	for(ll i=n-1;i>=0;i--)
	{
		if(s[i]=='1') mod++;
	}
	ll umod=0,lmod=0;
	ll um=mod+1,lm=mod-1;
	for(ll i=0,j=n-1;i<n;i++,j--)
	{
		if(s[i]=='1')
		{
			umod=(umod+power(2,j,um))%um;
			if(mod>1) lmod=(lmod+power(2,j,lm))%lm;
		}
	}
	//cout<<um<<" "<<lm<<"\n";
	//cout<<umod<<" "<<lmod<<"\n";
	for(ll i=0,j=n-1;i<n;i++,j--)
	{
		if(s[i]=='1')
		{
			if(mod==1)
			{
				cout<<0<<"\n";
				continue;
			}
			ll x=(lmod-power(2,j,lm)+lm)%lm;
			cout<<1+getop(x,__builtin_popcountll(x))<<"\n";
		}
		else
		{
			ll x=(umod+power(2,j,um)+um)%um;
			cout<<1+getop(x,__builtin_popcountll(x))<<"\n";
		}
	}

}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll T=1;
	//cin>>T;
	while(T--)
	{
		solve();
	}
	return 0;
}

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

bool is_integer(double x){
    return floor(x)==x;
}

int main(){
    int X;
    cin >> X;

    ll A, B;
    int flag=0;
    for(int i=-200; i<200; i++){
        for(int j=-200; j<200; j++){
            if((i*i*i*i*i) - (j*j*j*j*j) == X){
                A=i;
                B=j;
                flag=1;
                break;
            }
        }
        if(flag==1) break;
    }
    if(X==1) cout << "0 -1" << endl; 
    else cout << A << " " << B << endl;
    return 0;
}

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

int main(){
  char a[3];
  cin>>a[0]>>a[1]>>a[2];
  int flagA=-1,flagB=-1,flagC=-1;
  for(int i=0;i<3;i++){
    if(a[i]=='a')
      flagA=1;
    if(a[i]=='b')
      flagB=1;
    if(a[i]=='c')
      flagC=1;
    }
  if(flagA>0&&flagB>0&&flagC>0)
    cout<<"Yes";
  else
    cout<<"No";

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {

	int n;

	scanf("%d", &n);

	if (n % 1000 != 0) {
		printf("%d", 1000 - (n % 1000));
	}

	else
	{
		printf("%d", 0);
	}

	return 0;
}

Measured memory_bytes: 1732
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
//#include<unordered_map>//イテレータあるけど順序保持しないmap
//#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<valarray>//なんとなく追加
//メモ：表示桁数を大きくする　　cout << fixed << setprecision(20) << cm << endl;
using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define PI acos(-1.0)
#define answer(ans) cout<<ans<<endl;
#define input(N) cin >> N ;

ll power(ll po,int i){
    ll ret;
if(i==0){
    return 1;
}
else {
    return power(po,i-1)*po;
}
}

signed main() {
ll N,K,ans=0;
cin >> N;
if(N%2 !=0){
    cout << "0" <<endl;
    return 0;
}
K = N/2;
REP(i,27){
ans += K /(power(5,i+1));
}
answer(ans);
return 0;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

typedef long long ll;
const int mod = 1e9+7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;

typedef pair<int, int> ii;

void solve()
{
  int n; cin>>n;
  vector<ii> a(n);
  vector<ii> b(n);
  vector<int> used(n, 0);
  for (int i=0; i<n; i++) {
    cin>>a[i].first>>a[i].second;
  }
  for (int i=0; i<n; i++) {
    cin>>b[i].first>>b[i].second;
  }
  SORT(a);
  SORT(b);
  int ans=0;
  for (int i=0; i<n; i++) {
    int maxb = -1;
    int maxj = -1;
    for (int j=n-1; j>=0; j--) {
      if (b[i].first<=a[j].first || used[j]==1) continue;
      if (maxb < a[j].second && b[i].second > a[j].second) {
        maxb = a[j].second;
        maxj = j;
      }
    }
    if (maxj >= 0) {
      used[maxj] = 1;
      ans++;
    }
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())

aji = []
for i in range(1, N+1):
    l = L + i - 1
    aji.append(l)

aji_n = sum(aji)
diff_min = 9999
ans = 0
for li in aji:
    aji_n1 = aji_n - li
    diff = abs(aji_n - aji_n1)
    if diff < diff_min:
        ans = aji_n1
        diff_min = diff

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
    ll h;
    cin>>h;
    int count=0;
    for(;;){
        if(h==1){
            break;
        }else{
            h=h/2;
            count++;
        }
    }
    ll sum=0;
    ll add=1;
    for(int i=0;i<=count;i++){
        sum+=add;
        add*=2;
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    x1, y1, x2, y2 = list(map(int, input().split(" ")))
    m = x2 - x1
    n = y2 - y1
    x3 = x2 - n
    y3 = y2 + m
    x4 = x1 - n
    y4 = y1 + m
    print(x3, y3, x4, y4)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
main(){
	long long int a,b,c,m;cin>>a>>b>>c;
	if(a%2==0||b%2==0||c%2==0)cout<<0<<endl;
	else
	{
		m=a*b;
		m>b*c?m=b*c:0;
		m>c*a?m=c*a:0;
		cout<<m<<endl;
	}
}

Measured memory_bytes: 256
//from PKU1125
double dist[1001][1001],d;
next[1001][1001],x[1001],y[1001];
main(){
	int a,b,k,n,i,j;
	for(;scanf("%d",&n),n;){
		/*initialize*/
		for(i=1;i<=n;i++)scanf("%d",&a),scanf("%d%d",x+a,y+a);
		for(i=1;i<=n;i++)for(j=1;j<=n;next[i][j]=j,j++)
			dist[i][j]=(d=hypot(x[i]-x[j],y[i]-y[j]))<50.1?d:9999;

		{/*warshall-floyd*/
			int k,i,j;
			for(k=1;k<=n;k++)
				for(i=1;i<=n;i++)
					for(j=1;j<=n;j++){
						if(dist[i][j]>dist[i][k]+dist[k][j])
							dist[i][j]=dist[i][k]+dist[k][j],next[i][j]=next[i][k];
					}
		}

		{/*query*/
			for(scanf("%d",&k);k;k--){
				scanf("%d%d",&a,&b);
				if(dist[a][b]>9990)puts("NA");
				else{
					for(j=a;j!=b;j=next[j][b])printf("%d ",j);
					printf("%d\n",b);
				}
			}
		}
	}exit(0);
}

Measured memory_bytes: 5112
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

constexpr int MOD = 1e9+7;
struct mint
{
	int v;
	mint():v(0){}
	mint(int v):v((v+MOD)%MOD){}
	mint operator-()const{ return mint(0) - *this; }
	mint& operator+=(const mint& a){ if((v+=a.v)>=MOD) v-=MOD; return *this; }
	mint& operator-=(const mint& a){ if((v+=MOD-a.v)>=MOD) v-=MOD; return *this; }
	mint& operator*=(const mint& a){ (v*=a.v)%=MOD; return *this; }
	mint& operator/=(const mint& a){ (*this) *= a.inv(); return *this; }
	mint operator+(const mint& a)const{ return mint(*this) += a; }
	mint operator-(const mint& a)const{ return mint(*this) -= a; }
	mint operator*(const mint& a)const{ return mint(*this) *= a; }
	mint operator/(const mint& a)const{ return mint(*this) /= a; }
	bool operator<(const mint& a)const{ return v < a.v; }
	bool operator==(const mint& a)const{ return v == a.v; }
	mint pow(int k)const{ mint r(1),t(v); while(k){ if(k&1) r*=t; t*=t; k>>=1; } return r; }
	mint inv()const{ return pow(MOD-2); }
	static mint comb(int n, int k) {
		if(n-k<k) k=n-k;
		mint num(1), dom(1);
		for(int i=0;i<k;i++) { num*=n-i; dom*=i+1; }
		return num/dom;
	}
};
std::istream& operator>>(std::istream&i,mint&a){ int t; i>>t; a=mint(t); return i; }
std::ostream& operator<<(std::ostream&o,const mint&a){ o<<a.v; return o; }


signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n+1);
	rep(i,n) std::cin >> a[i+1];
	// for i+j < n
	mint nxfact = 1; // (n-1)!
	for(int i=1;i<n;i++) nxfact*=mint(i);
	std::vector<mint> len_j(n-1); // 1<=j<=n-2
	len_j[1]=mint(a[n-1]-a[1]);
	for(int j=2;j<n-1;j++) {
		len_j[j]=len_j[j-1]+mint(a[n-j]-a[j]);
	}
	mint sum = 0; // final ans
	for(int j=1;j<n-1;j++) {
		sum+=nxfact/(mint(j)*mint(j+1))*len_j[j];
	}
	// for i+j==n
	for(int i=1;i<n;i++) {
		sum+=nxfact/mint(n-i)*mint(a[n]-a[i]);
	}
	print(sum);
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(){
  
   int W,H,x,y,r;
  
   scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  
    if(W < x+r || x-r < 0) printf("No\n");
    else if(H < y+r || y-r < 0) printf("No\n");
    else printf("Yes\n");
      
    return 0;
}

Measured memory_bytes: 584
#include <stdio.h>
#include <limits.h>

int main(void){
  int a,b,k;
  scanf("%d %d",&a,&b);
  if(a%2==b%2){
    k=(a+b)/2;
    printf("%d\n" ,k);
  }else{
    printf("IMPOSSIBLE\n");
  }
  return 0;
}

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

int main(){
  long long int n,d;
  cin >> n >> d;
  vector<long long int> x(n),y(n);
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> x.at(i) >> y.at(i);
    if(x.at(i)*x.at(i)+y.at(i)*y.at(i)<=d*d){
      ans++;
    }
  }
  cout << ans << endl;
}

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

string to_string(string s) {
	return '"' + 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...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

void test_case() {
	int n;
	cin >> n;
	vector<int> D(n + 1);
	for (int i = 1; i <= n; ++i) {
		cin >> D[i];
	}
	sort(D.begin() + 1, D.end());
	int lo = D[n / 2] + 1, hi = D[n / 2 + 1];
	cout << max(0, hi - lo + 1) << "\n";
}

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	return 0;
}

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

//Compiler version g++ 6.3.0

int main()
{
   /* int tt;
    cin >> tt;
    while (tt--){
      int N;
      cin >> N;
      int B[N];
      int sum = 0;
      int zero = 0;
      for(int i = 0; i < N; i++){
        cin >> B[i];
        sum += B[i];
        if(B[i]==0)zero++;
       
        
      }
      if(sum < 100){
        cout << "NO\n";
      }
      else{
        
        float diff = (float) sum - 100;
        N = N - zero;
        float check = 0.9*N;
        if(diff <= check)cout << "YES\n";
        else cout << "NO\n"; 
      }
      
    }*/
   // if(2 < 2.0)cout<<"jsis";
    //else cout<<"uwuw";
    
    int N;
    cin >> N;
    vector<long long> V(N);
    int cnt = 0;
    for(int i = 0; i < N; i++){
      long long x;
      cin >> x;
      V[i] = x;
     
      
    }
    for(long long x: V){
    //  int i = 2;
      if(x % 2 == 1) continue;
      
      while(x % 2 == 0){
        cnt++;
        x /= 2;
        
        
      }
    }
    cout << cnt;
}

Measured memory_bytes: 3708
# -*- coding: utf-8 -*-


def main():
    from collections import Counter

    n = int(input())
    s = [input() for _ in range(n)]
    c = sorted(Counter(s).items(), key=lambda x: x[1], reverse=True)
    max_value = c[0][1]
    ans = list()

    for key, value in c:
        if value == max_value:
            ans.append(key)

    for a in sorted(ans):
        print(a)


if __name__ == '__main__':
    main()


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

typedef long long ll;
ll dp[305][305];
ll carry[305][305];
ll binom[305][305];


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

    dp[0][0] = 1;
    carry[0][0] = 1;
    for(ll i=0; i<305; i++){
        binom[i][0] = 1;
    }
    for(ll i=1; i<305; i++){
        for(ll j=0; j<=i; j++){
            binom[i][j] = (binom[i-1][j] + binom[i-1][j-1])%M;
        }
    }

    for(ll i=1; i<K+1; i++){
        dp[1][i] = i%M;
        carry[1][i] = (i*(i+1)/2)%M;
        dp[0][i] = 1;
        carry[0][i] = (i+1)%M;
    }
    for(ll i=2; i<N+1; i++){
        for(ll j=1; j<K+1; j++){

            for(ll c=0; c<i; c++){
                ll x = (binom[i-1][c]*carry[c][j-1])%M;
                x = (x*dp[i-c-1][j])%M;
                dp[i][j] = (dp[i][j]+x)%M;
            }

        }
        carry[i][1] = dp[i][1];
        for(ll j=2; j<K+1; j++){
            carry[i][j] = (carry[i][j-1]+dp[i][j])%M;
        }
    }


    cout<<dp[N][K]<<endl;


    return 0;
}


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

using namespace std;

void solve()
{
	string ans, inquire;
	while(cin >> ans >> inquire)
	{
		if(ans == "0" && inquire == "0")
		{
			break;
		}
		int hit = 0, blow = 0;
		for(int i = 0; i < ans.size(); ++i)
		{
			if(ans[i] == inquire[i])
			{
				++hit;
			}
		}
		for(int i = 0; i < ans.size(); ++i)
		{
			for(int j = 0; j < inquire.size(); ++j)
			{
				if(ans[i] == inquire[j])
				{
					++blow;
				}
			}
		}
		cout << hit << " " << blow - hit << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;

//定数
//円周率
const double pi = 3.141592653589793238462643383279;
//天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
//ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
//よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7

//データ構造
//隣接リスト用構造体（有向グラフ向け）
struct edge {
  ll to; // E.toでその辺の終点へアクセスできる
  ll cost; // e.costでその辺の重みにアクセスできる
};
//Union_Find木
struct UnionFind {
  vector<int> UF; // UF.at(i) : iの親の番号
  vector<int> SIZE; // SIZE.at(root(i)) : iと連結されてる要素の数
  UnionFind(int N) : UF(N), SIZE(N, 1) { // 最初は全てが根であるとして初期化
    for(int i = 0; i < N; i++) {
      UF.at(i) = i;
    }
  }
  int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
    if (UF.at(x) == x) {
      return x;
    }
    return UF.at(x) = root(UF.at(x));
  }
  void unite(int x, int y) { // xとyの木を併合
    int rx = root(x); // xの根をrx
    int ry = root(y); // yの根をry
    if (rx == ry) {
      return; // xとyの根が同じ(=同じ木にある)時はそのまま
    }
    // xとyの根が同じでない(=同じ木にない)時：小さい方の根を大きい方の根につける
    if (SIZE.at(rx) < SIZE.at(ry)) {
      UF.at(rx) = ry;
      SIZE.at(ry) += SIZE.at(rx);
      SIZE.at(rx) = 0;
    }
    else {
      UF.at(ry) = rx;
      SIZE.at(rx) += SIZE.at(ry);
      SIZE.at(ry) = 0;
    }
  }
  bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
  int size(int x) { // xと連結されてる要素の数を返す
    return SIZE.at(root(x));
  }
};

//関数 (計算量)
//ctoi (O(1))
int ctoi(char c){
  if (c == '0') return 0;
  if (c == '1') return 1;
  if (c == '2') return 2;
  if (c == '3') return 3;
  if (c == '4') return 4;
  if (c == '5') return 5; 
  if (c == '6') return 6;
  if (c == '7') return 7;
  if (c == '8') return 8;
  if (c == '9') return 9;
  return -1;  
}
//to_char (O(1))
char to_char(int i){
  if (i == 0) return '0';
  if (i == 1) return '1';
  if (i == 2) return '2';
  if (i == 3) return '3';
  if (i == 4) return '4';
  if (i == 5) return '5';
  if (i == 6) return '6';
  if (i == 7) return '7';
  if (i == 8) return '8'; 
  if (i == 9) return '9';
  return ' ';  
}
//素数判定 
//一つ一つの判定ではこっちの方が速い(一つ当たりO(√N))
//一方100までに何個あるかなどはEratosthenesの篩の方が良い（O(NlogN))
bool PN(int x) {
  if (x <= 1) return false; // 1や0,-1は素数ではない
  if (x == 2) return true; // √2 + 1 > 2 なので下でやると 2 ％ 2 = 0 となり判定できない
  for (int i = 2; i < sqrt(x) + 1; i++) {
    if (x % i == 0) return false; // 割れたら素数じゃない
  }
  return true;
}
// A^N mod M を計算する。modしたくなかったらM = LINFとかにすればよい。(O(√N))
ll modpow(ll A, ll N, ll M) {
  long long ans = 1;
  while (N > 0) {
    if (N & 1) ans = ans * A % M;
      A = A * A % M;
      N >>= 1;
   }
  return ans;
}
  
//メイン処理
int main() {
  cout << fixed << setprecision(16); //精度向上
  //ここまでテンプレ
  int A, B, C;
  cin >> A >> B >> C;
  if (A + B < C) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    ll n;  cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++)
    {
        if(i%3==0||i%5==0)
            continue;
        sum+=i;
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3628