akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
import math

N = int(input())



ans = ''
i = 0


while True:
	a = math.ceil(N/-2)
	p = N - (-2 * a)
	if p == 1:
		ans = '1' + ans 
	else:
		ans = '0' + ans 
	N = a
	if N == 0:
		break


print(ans)


Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import numpy as np
MOD = 10 ** 9 + 7

N,X = map(int,input().split())
S = [int(x) for x in input().split()]
S.sort()

# xから始めて集合S0, ..., Sk まででどうなるか

dp = np.arange(X+1, dtype=np.int64)

for i,s in enumerate(S):
    prev = dp
    dp = i * prev # sをあとまわしで使う場合
    dp += prev[np.arange(X+1) % s] # 初手sを使う
    dp %= MOD

answer = dp[-1]
print(answer)

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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

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

  int N, C, K;
  cin >> N >> C >> K;
  vector<int> T(N);
  for (int i = 0; i < N; i++) cin >> T.at(i);

  sort(T.begin(), T.end());

  int lim = -1, c = 0, ans = 0;
  for (int i = 0; i < N; i++) {
    if (lim == -1) lim = T.at(i) + K;
    if (T.at(i) <= lim && c < C) {
      c++;
      if (i == N - 1) ans++;
      continue;
    } else {
      ans++;
      lim = T.at(i) + K, c = 1;
      if (i == N - 1) ans++;
    }
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3740
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

const int M = 1e9+7;

using namespace std;

main()
{
    fast;
    int n,m,i;
    cin>>n>>m;
    if (abs(n-m)>1)
        cout<<"0\n";
    else
    {
        ll fac[max(n,m)+1];
        fac[0]=fac[1]=1;
        for (i=2;i<=max(n,m);i++)
            fac[i]=(fac[i-1]*i)%M;
        if (n==m)
            cout<<(fac[n]%M*fac[m]%M*2)%M<<endl;
        else
            cout<<(fac[n]%M*fac[m]%M)%M<<endl;
    }
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<algorithm>
#include<string.h>
#define ll long long
using namespace std;
int N;
int main(){
	scanf("%d",&N);
	int js=0;
	ll tt;
	while(N--){
		scanf("%lld",&tt);
		while(!(tt&1)){
			tt>>=1;
			js++;
		}
	}
	printf("%d",js);
	return 0;
}

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

int main() {
long N,K,sum=0;
  cin>>N>>K;
long a;  
  
  for(long i=K;i<=N+1;i++){
    
    a=(i*(N-i+1))%1000000007;
    
   
    sum+=(a+1);
    
    if(sum>=1000000007){
      sum-=1000000007;
    }
    
  }
  
  cout<<sum<<endl;

}


Measured memory_bytes: 3636
def main():
    N, M = map(int, input().split())
    d = dict()
    for _ in range(M):
        a, b = map(int, input().split())
        d[a] = d.get(a, 0) + 1
        d[b] = d.get(b, 0) + 1

    for a in range(1, N+1):
        if a in d:
            print(d[a])
        else:
            print(0)

if __name__ == '__main__':
    main()

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

static const int MAX = 100000;

vector<int> G[MAX];
int N;
bool visited[MAX];
int prenum[MAX],parent[MAX],lowest[MAX],timer;

void dfs(int current,int prev){
  // current訪問
  prenum[current] = lowest[current] = timer;
  timer++;

  visited[current] = true;

  int next;

  for(int i=0;i<G[current].size();i++){
    next = G[current][i];
    if(!visited[next]){
      // current -> nextへの行く直前の処理
      parent[next] = current;

      dfs(next,current);

      // nextの探索終了
      lowest[current] = min(lowest[current],lowest[next]);

    }else if(next != prev){
      lowest[current] = min(lowest[current],prenum[next]);
    }
  }
}

void art_points(){
  for(int i=0;i<N;i++) visited[i] = false;
  timer = 1;

  // lowest
  dfs(0,-1);

  set<int> ap;
  int np = 0;
  for(int i=1;i<N;i++){
    int p = parent[i];

    if(p == 0) np++;
    else if(prenum[p] <= lowest[i]) ap.insert(p);
  }

  // rootへ2つ以上の枝があれば関節点
  if(np > 1) ap.insert(0);
  for(set<int>::iterator it = ap.begin();it != ap.end();it++){
    cout << *it << endl;
  }
}

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

  for(int i=0;i<m;i++){
    int s,t;
    cin >> s >> t;
    G[s].push_back(t);
    G[t].push_back(s);
  }
  art_points();
  return 0;
}



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

int main() {
  int X, Y;
  cin >> X >> Y;
  
  if(Y - Y/2*2 == 1){
    cout << "No" << endl;
  }
  else if(Y/2 - X < 0){
    cout << "No" << endl;
  }
  else if(2*X - Y/2 < 0){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

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

int main() {
   int64_t A, B, C, K;
   cin >> A >> B >> C >> K;
   int64_t ttl=0;
    if(K-A>=0) ttl+=A;
    else{
        ttl+=K;
        cout << ttl << endl;
        return 0;
    } 
    K-=A;
    if(K-B>=0);
    else
    {
        cout << ttl << endl;
        return 0;
    }
    
    K-=B;

    if(K-C>=0) ttl-=C;
    else
    {
        ttl-=K;
        cout << ttl << endl;
        return 0;
    }
cout << ttl << endl;
    return 0;
}



Measured memory_bytes: 3632
import math

if __name__ == '__main__':
    N, P = list(map(int, input().split()))
    A = list(map(int, input().split()))
    zero_or_one = [(i % 2) for i in A]

    count_zero = zero_or_one.count(0)
    count_one = zero_or_one.count(1)

    if P == 0:
        sum_combination_zero = 0
        for i in range(0, count_zero + 1):
            sum_combination_zero += math.factorial(count_zero) / (math.factorial(i) * math.factorial(count_zero - i))

        sum_combination_one = 0
        for i in range(0, count_one + 1, 2):
            sum_combination_one += math.factorial(count_one) / (math.factorial(i) * math.factorial(count_one - i))

        ans = sum_combination_zero * sum_combination_one
        print(int(ans))
    else:
        sum_combination_zero = 0
        for i in range(0, count_zero + 1):
            sum_combination_zero += math.factorial(count_zero) / (math.factorial(i) * math.factorial(count_zero - i))

        sum_combination_one = 0
        for i in range(1, count_one + 1, 2):
            sum_combination_one += math.factorial(count_one) / (math.factorial(i) * math.factorial(count_one - i))

        ans = sum_combination_zero * sum_combination_one
        print(int(ans))

Measured memory_bytes: 3064
//#include <stdio.h>
#include <bits/stdc++.h>
#include <climits>
using namespace std;
int main()
{
    int ans=0;
    int n,k;
    cin >> n >> k;
    int h[100010];
    for(int i=0;i<n;i++){
        cin >>h[i];
        if(k<= h[i]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000.0



int main(){
	
	vector<pair<pair<double,double>,double>> V;
	double x,y,r;
	cin>>x>>y;
	V.emplace_back(make_pair(x,y),0);
	cin>>x>>y;
	V.emplace_back(make_pair(x,y),0);
	
	int N;
	cin>>N;
	
	for(int i=0;i<N;i++){
		cin>>x>>y>>r;
		V.emplace_back(make_pair(x,y),r);
	}
	
	vector<vector<pair<int,double>>> E(N+2,vector<pair<int,double>> ());
		
	for(int i=0;i<N+2;i++){
		for(int j=0;j<N+2;j++){
			if(i==j)continue;
			double x1 = V[i].first.first,x2 = V[j].first.first;
			double y1 = V[i].first.second,y2=V[j].first.second;
			double r1 = V[i].second,r2 = V[j].second;
			E[i].emplace_back(j,max(0.0,sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2))-(r1+r2)));
		}
	}
	
	vector<double> dis(N+2,Inf);
	vector<bool> checked(N+2,false);
	priority_queue<pair<double,int>,vector<pair<double,int>>,greater<pair<double,int>>> Q;
	Q.emplace(0.0,0);
	dis[0] = 0.0;
	while(Q.size()!=0){
		double D1 = Q.top().first;
		int from = Q.top().second;
		Q.pop();
		if(checked[from])continue;
		checked[from]=true;
		for(int i=0;i<E[from].size();i++){
			int to = E[from][i].first;
			double D2 = E[from][i].second;
			if(D1+D2<dis[to]){
				dis[to] = D1+D2;
				Q.emplace(dis[to],to);
			}
		}
	}
	
	cout<<fixed<<setprecision(20)<<dis[1]<<endl;
		
		
	
	return 0;
}


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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Graph;
const int M = 1e9 + 7;
const ll INF = 1e9;
const int MAX_V = 100000 + 5;
const int MAX_N = 1e5 + 5;

int main() {
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p;
    cin >> t;
    vector<char> formar(n, 'n');
    vector<char> latter(n, 'n');
    rep(i, n) {
        if (i - k >= 0) {
            formar[i] = t[i - k];
        }
        if (i + k < n) {
            latter[i] = t[i + k];
        }
    }
    ll ans = 0;
    rep(i, n) {
        if (formar[i] == 'n') {
            if (t[i] == 'r') {
                ans += p;
            } else if (t[i] == 's') {
                ans += r;
            } else {
                ans += s;
            }
        } else {
            if (formar[i] == t[i] && latter[i] == t[i]) {
                formar[i + k] = 'n';
            } else if (formar[i] == t[i] && latter[i] != t[i]) {
                continue;
            } else {
                if (t[i] == 'r') {
                    ans += p;
                } else if (t[i] == 's') {
                    ans += r;
                } else {
                    ans += s;
                }
            }
        }
    }
    out(ans);
}


Measured memory_bytes: 512
N = int(input())
p = list(map(int, input().split()))

w1 = None
w2 = None
cnt = 0
for i in range(N):
  if i+1 != p[i]:
    cnt += 1
    if cnt == 1:
      w1 = i
    elif cnt == 2:
      w2 = i
    else:
      break
if cnt == 3:
  print('NO')
else:
  print('YES')
  

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		while ((n | m) != 0) {
			int place[] = new int[m];
			int rank[] = new int[m];
			for (int i = 0; i < m; i++) {
				place[i] = 0;
				rank[i] = 0;
			}
			
			for (int p = 0; p < n * m; p++) {
				place[p % m] += scan.nextInt();
			}
			
			/*
			for (int i = 0; i < m; i++) {
				System.out.print(place[i]);
				if (i != m- 1) {
					System.out.print(" ");
				}else {
					System.out.println();
				}
			}
			*/
			
			int scr;
			for (int i = 0; i < m; i++) {
				int max = place[0];
				scr = 0;
				for (int j = 0; j < m; j++) {
					if (max < place[j]) {
						scr = j;
						max = place[j];
					}
				}
				rank[i] = scr + 1;
				place[scr] = -1;
			}
			for (int i = 0; i < m; i++) {
				System.out.print(rank[i]);
				if (i != m- 1) {
					System.out.print(" ");
				}else {
					System.out.println();
				}
			}
			n = scan.nextInt();
			m = scan.nextInt();
			
		}

	}

}

Measured memory_bytes: 64156
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    var N = parseInt(input[0],10);
    var Q = parseInt(input[2], 10);
    var vec_A = input[1].map(e => parseInt(e, 10));
    var v = Array.from({ length: 100000 }, () => 0);;
    for (i = 0; i < v.length; i ++){
        v[vec_A[i]- 1]++;
    }
    ary_bc = Array.from({ length: Q }, () => 0);
    for (var i = 0; i < Q; i++){
        ary_bc[i] = input[i+3].map(e => parseInt(e, 10));
    }
    var vec_S = Array.from({ length: Q }, () => 0);
    var S = sum(vec_A);
    var b, c;

    for (i = 0; i < Q; i++){
        b = ary_bc[i][0];
        c = ary_bc[i][1];
        S += v[b - 1] * (c - b); 
        v[c - 1] += v[b - 1]
        v[b - 1] = 0;
        vec_S[i] = S;
    }
	console.log(vec_S.join('\n'));
}   

var sum  = function(arr) {
    var sum = 0;
    arr.forEach(function(elm) {
        sum += elm;
    });
    return sum;
};

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 88312
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
#define in(a) scanf("%lld", &(a))
#define in2(a,b) scanf("%lld %lld",&(a),&(b))
#define in3(a,b,c) scanf("%lld %lld %lld",&(a),&(b),&(c))
#define ind(a) scanf("%lf", &(a))
#define ins(a) scanf("%s", (a))
#define put(a) printf("%lld\n", (a))
#define putd(a) printf("%.15f\n", (a))
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll N, f=0;
    in(N);
    ll n = N;
    while(N>0){
        f += N%10;
        N /= 10;
    }
    puts(n%f ? "No":"Yes");
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) fixed << setprecision(x)
//const ll p = 1e9 + 7;
//const ll p = 998244353;
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

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

	ll n;
	cin >> n;
	vll a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];

	ll sum = 0, sumsq = 0;
	for (ll i = 0; i < n; i++) {
		sum += a[i];
		sumsq += a[i] * a[i];
	}
	ll avg = sum / n;

	ll ans1 = 0, ans2 = 0;
	for (ll i = 0; i < n; i++) {
		ans1 += (a[i] - avg) * (a[i] - avg);
		ans2 += (a[i] - avg - 1) * (a[i] - avg - 1);
	}
	cout << min({sumsq, ans1, ans2}) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const int DIV = 1e9+7;

int main()
{
    int n;
    cin >> n;
    string ans = "ABC";
    ans += to_string(n);
    cout << ans << endl;
}


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

#define fto(i, a, b) for (int i = a; i <= b; ++i)
#define fdto(i, a, b) for (int i = a; i >= b; --i)
#define ff first
#define ss second
#define pii pair<int, int>
#define pb push_back
#define mp make_pair
#define ll long long
#define pi = 3.1415926535897
#define oo 1000000007
#define OO 1000000000000000007

using namespace std;


ll GCD(ll a, ll b) {return (!(a%b)) ? b : GCD(b, a%b);}

ll a[100005];
ll x;
int n;

int main() {
//    freopen("codef.inp", "r", stdin);
//    freopen("codef.out", "w", stdout);
    cin >> n >> x;
    fto(i, 1, n) {
        int t;
        scanf("%d", &t);
        a[i] = (ll)t;
    }
    ll ans = abs(a[1]-x);
    fto(i, 2, n) ans = GCD(ans, abs(a[i]-x));
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
 
using namespace std;
int main()
{
	int N,i,v,cnt_even[100010],cnt_odd[100010];
	int max_even=-1,max_odd=-1,tmp_even,tmp_odd,emx=-1,omx=-1;
	cin >> N;
	for(i=1; i<=100000; i++){
		cnt_even[i] = 0;
		cnt_odd[i] = 0;
	}
	for(i=0; i<N; i++){
		cin >> v;
		if(i % 2 == 0) cnt_even[v]++;
		else cnt_odd[v]++;
	}
	for(i=1; i<=100000; i++){
		if(max_even == cnt_even[i]){
			tmp_even = -2;
		}else if(max_even < cnt_even[i]){
			emx = max_even;
			max_even = cnt_even[i];
			tmp_even = i;
		}else if(emx <= cnt_even[i]){
			emx = cnt_even[i];
		}
		if(max_odd == cnt_odd[i]){
			tmp_odd = -1;
		}else if(max_odd < cnt_odd[i]){
			omx = max_odd;
			max_odd = cnt_odd[i];
			tmp_odd = i;
		}else if(omx < cnt_odd[i]){
			omx = cnt_odd[i];
		}	
	}
	if(tmp_even != tmp_odd){
		cout << N - max_even - max_odd << endl;
	}else{
		if(max_even + omx <= max_odd + emx){
			cout << N - max_odd - emx << endl;
		}else{
			cout << N - max_even - omx << endl;
		}
	}
	
	return 0;
}

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

int main(void){
  long long N;
  long long MAX = 100000;
  vector<long long> a(MAX);

  for(long long i = 0; i < MAX; i++){
    a[i] = 0;
  }
  
  cin >> N;

  for(long long i = 0;i < N; i++){
    long long tmp,dec,inc;
    cin >>  tmp;
    dec = tmp - 1;
    inc = tmp + 1;
    if(dec >= 0 && inc < MAX){
      a[dec]++;
      a[tmp]++;
      a[inc]++;
    }else if(dec < 0){
      a[tmp]++;
      a[inc]++;
    }else if(inc >= MAX){
      a[tmp]++;
      a[dec]++;
    }
  }
  long long mx = 0;
  for(long long i = 0; i < MAX; i++){
    mx = max(mx,a[i]);
  }
  cout << mx << endl;
  return 0;
}

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

using namespace std;

#define LL long long
#define DD double
#define Pb push_back
#define Bp pop_back
#define Pf push_front
#define Fp pop_front
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define X first
#define Y second
#define mx1 10
#define mx2 110
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

typedef vector<LL> Vl;
typedef vector<DD> Vd;
typedef vector<bool> Vb;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef pair<DD, DD> Pdd;
typedef vector<Pll> Vpl;
typedef vector<Pdd> Vpd;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
typedef deque<LL> Dl;

LL _set(LL N, LL pos) {return N = N | (1 << pos);}
LL _reset(LL N, LL pos) {return N = N & ~(1 << pos);}
bool _check(LL N, LL pos) {return (bool)(N & (1 << pos));}
bool _upper(char a) {return a >= 'A' && a <= 'Z';}
bool _lower(char a) {return a >= 'a' && a <= 'z';}
bool _digit(char a) {return a >= '0' && a <= '9';}

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

///**************************DONE****************************///

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

    int L = s.size();
    for(int i = 0; i < L; i += n)
        cout << s[i];
    cout << '\n';
    return 0;
}


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

int main(){
  int N;
  cin >> N;
  int AC = 0, WA = 0, TLE = 0, RE = 0;
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    if(S == "AC"){
      AC += 1;
    }
    if(S == "WA"){
      WA += 1;
    }
    if(S == "TLE"){
      TLE += 1;
    }
    if(S == "RE"){
      RE += 1;
    }
  }
  cout << "AC x " << AC << endl;
  cout << "WA x " << WA << endl;
  cout << "TLE x " << TLE << endl;
  cout << "RE x " << RE << endl;
}

Measured memory_bytes: 3620
K = int(input())

from collections import deque
q = deque(list(range(1, 10)))

ans = 0
num = 0
for i in range(K):
  num = q.popleft()
  ans = num
  if num % 10 != 0:
    q.append(num * 10 + (num % 10 - 1))
  q.append(num * 10 + num % 10)
  if num % 10 != 9:
    q.append(num * 10 + (num % 10 + 1))
    
print(ans)

Measured memory_bytes: 19604
#include<bits/stdc++.h>
using namespace std;
int main(){
    vector<int> a(3);

    for(int i=0;i<3;i++)
    {
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    cout << a.at(1)-a.at(0)+a.at(2)-a.at(1) << endl;

}
    



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

using namespace std;

int case_check(int c);

int main()
{
	string in;

	getline(cin, in);
	transform(in.begin(), in.end(), in.begin(), ::case_check);
	cout << in;
	
	cout << endl;
}

int case_check(int c)
{
	if (islower(c))
		return toupper(c);
	else
		return tolower(c);
}

Measured memory_bytes: 3220
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string[] sS = System.Console.ReadLine().Trim().Split(' ');
            int iN = int.Parse(sS[0]);
            int iM = int.Parse(sS[1]);
            List<ClsTwr> lstTwr = new List<ClsTwr>();
            sS = System.Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < sS.Length; i++)
            {
                ClsTwr oneUsr = new ClsTwr();
                oneUsr.iN = i;
                oneUsr.iH = int.Parse(sS[i]);
                //oneUsr.iN = 0;
                //oneUsr.lstOh = new List<int>();
                //oneUsr.bGd = true;
                lstTwr.Add(oneUsr);
            }
            for (int i = 0; i < iM; i++)
            {
                sS = System.Console.ReadLine().Trim().Split(' ');
                int iA = int.Parse(sS[0]) - 1;
                int iB = int.Parse(sS[1]) - 1;
                //lstTwr[iA].iN += 1;
                //lstTwr[iA].lstOh.Add(iB);
                //lstTwr[iB].iN += 1;
                //lstTwr[iB].lstOh.Add(iA);
                if (lstTwr[iA].iH >= lstTwr[iB].iH) { lstTwr[iB].bGd = false; }
                if (lstTwr[iA].iH <= lstTwr[iB].iH) { lstTwr[iA].bGd = false; }
            }

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            int iOut = 0;
            for (int i = 0; i < lstTwr.Count; i++)
            {
                if (lstTwr[i].bGd) { iOut += 1; }
            }

            // 出力
            System.Console.WriteLine("{0}", iOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }

        private class ClsTwr
        {
            public int iN { get; set; } = -1;                           // No
            public int iH { get; set; } = 0;                            // 高さ
            //public int iC { get; set; } = 0;                            // 他No数
            //public List<int> lstOh { get; set; } = new List<int>();     // 他No
            public Boolean bGd { get; set; } = true;                    // いい
        }

}


Measured memory_bytes: 51360
#include "bits/stdc++.h"
using namespace std;

bool isprime[100010];

void eratos() {
	for (int i = 0; i < 100010; i++) {
		isprime[i] = true;
	}
	isprime[0] = isprime[1] = false;
	for (int i = 2; i <= sqrt(100010); i++){
		if (isprime[i]) {
			int j = i + i;
			while (j < 100010) {
				isprime[j] = false;
				j = j + i;
			}
		}
	}
}

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

	eratos();
	for (int i = x; i < 100010; i++) {
		if (isprime[i]) {
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int h = 0;
  h = n/500;
  int sum = 0;
  sum = h *1000;
  int i = 0;
  i = (n - h*500)/5;
  sum += i*5;
  cout << sum;
  return 0;
  
}

Measured memory_bytes: 256
l = raw_input().split()
N = int(l[0])
M = int(l[1])

K = []
S = []
P = []

for i in range(M):
    l = raw_input().split()
    t = [int(x) for x in l]
    K.append(t[0])
    S.append(t[1:])

l = raw_input().split()
P = [int(x) for x in l]

# print(N, M, K, S, P)

def numBits(n):
    count = 0
    while n > 0:
        if n % 2 == 1:
            count += 1
        n /= 2
    return count

def solve(n, S, p):
    # print('nsp', n, S, p)
    count = 0
    for s in S:
        # print(s, n, n >> (s - 1))
        count += (n >> (s - 1)) & 1
    # print('count={}'.format(count))
    return p == (count  & 1)

ans = 0
for j in range(2**N):
    # print(j)
    ret = True
    for i in range(len(S)):
        s = S[i]
        p = P[i]
        # print(i, s, p)
        if not solve(j, s, p):
            ret = False
            break
    if ret:
        ans += 1
print(ans)


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = numeric_limits<int>::max() / 2;
const int NEG_INF = numeric_limits<int>::min() / 2;
const int MOD = 1e9 + 7;

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

	int n, v, u, m;
	cin >> n >> u >> v >> m;
	if (n == 1)
	{
		int usa, neko;
		cin >> usa >> neko;
		int usasum = 0, nekosum = 0;
		for (int i = 0; i < m; i++)
		{
			int a;
			cin >> a;
			if (a == usa)
				usasum = 1;
			if (a == neko)
				nekosum = 1;
			if (usasum >= u && nekosum >= v)
			{
				cout << "DRAW" << endl;
				return 0;
			}
			else if (usasum >= u)
			{
				cout << "USAGI" << endl;
				return 0;
			}
			else if (nekosum >= v)
			{
				cout << "NEKO" << endl;
				return 0;
			}
		}
		cout << "DRAW" << endl;
		return 0;
	}
	vector<P> usa(1000001, P(-1, -1)), neko(1000001, P(-1, -1)); //usa[i]:=usa?????§i?????????????????§?¨?
	vector<int> usatate(100000, 0), usayoko(100000, 0);
	int usasla = 0, usaback = 0;
	vector<int> nekotate(100000, 0), nekoyoko(100000, 0);
	int nekosla = 0, nekoback = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			int a;
			cin >> a;
			usa[a] = P(i, j);
		}
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n; j++)
		{
			int a;
			cin >> a;
			neko[a] = P(i, j);
		}
	}
	int usasum = 0, nekosum = 0;
	for (int i = 0; i < m; i++)
	{
		int a;
		cin >> a;
		if (usa[a] != P(-1, -1))
		{
			int x = usa[a].first, y = usa[a].second;
			//cout<<x<<" "<<y<<endl;
			usayoko[x]++;
			usatate[y]++;
			if (x == y)
				usasla++;
			if (x + y == n - 1)
				usaback++;

			//cout<<usayoko[x]<<" "<<usatate[y]<<" "<<usasla<<" "<<usaback<<endl;
			if (usayoko[x] == n)
				usasum++;
			if (usatate[y] == n)
				usasum++;
			if (x == y && usasla == n)
				usasum++;
			if (x + y == n - 1 && usaback == n)
				usasum++;
		}
		if (neko[a] != P(-1, -1))
		{
			int x = neko[a].first, y = neko[a].second;
			nekoyoko[x]++;
			nekotate[y]++;
			if (x == y)
				nekosla++;
			if (x + y == n - 1)
				nekoback++;

			if (nekoyoko[x] == n)
				nekosum++;
			if (nekotate[y] == n)
				nekosum++;
			if (x == y && nekosla == n)
				nekosum++;
			if (x + y == n - 1 && nekoback == n)
				nekosum++;
		}
		//cout<<usasum<<" "<<nekosum<<endl;
		if (usasum >= u && nekosum >= v)
		{
			cout << "DRAW" << endl;
			return 0;
		}
		else if (usasum >= u)
		{
			cout << "USAGI" << endl;
			return 0;
		}
		else if (nekosum >= v)
		{
			cout << "NEKO" << endl;
			return 0;
		}
		else
			continue;
	}
	cout << "DRAW" << endl;
}


Measured memory_bytes: 19992
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using plpii = std::pair<long long, std::pair<int, int>>;

using namespace std;

const long long _MOD = 1000000007;
const long long MOD = 998244353;

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

	ll n, minA = 1e16, a;
	cin >> n;
	rep(i, 5) {
		cin >> a;
		minA = min(minA, a);
	}

	ll t = n / minA;
	if (n % minA) ++t;

	cout << t + 4 << "\n";

	return 0;
}



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

int main(void){
    int n; cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    ll ans = 0;
    for(int i = 1; i < n; i++){
        if(a[i-1] > a[i]){
            ans += (a[i-1] - a[i]);
            a[i] = a[i-1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4824
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}

vector<int> path[100005];
int used[100005];
LL num[2];

int check(int p,int q){
	int a,b,c;
	if(used[p]!=0){
		if(used[p]==q)return 0;
		return -1;
	}
	used[p]=q;
	num[(q+1)/2]++;
	for(int i=0;i<path[p].size();i++){
		a=check(path[p][i],-q);
		if(a==-1)return -1;
	}
	return 0;
}

int main(){
	LL n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n>>m;
	for(i=0;i<m;i++){
		cin>>a>>b;
		a--,b--;
		path[a].push_back(b);
		path[b].push_back(a);
	}
	a=check(0,1);
	if(a==-1)b=n*(n-1)/2;
	else b=num[0]*num[1];
	b-=m;
	cout<<b<<endl;
}

Measured memory_bytes: 6528
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string s, t;
  cin >> s >> t;
  const int64_t LS = static_cast<int64_t>(s.length());
  const int64_t LT = static_cast<int64_t>(t.length());
  vector<vector<int64_t>> dp(LS + 1, vector<int64_t>(LT + 1, 0));
  for (int64_t i = 1; i <= LS; ++i) {
    for (int64_t j = 1; j <= LT; ++j) {
      if (s.c_str()[i - 1] == t.c_str()[j - 1]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      } else {
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
      }
    }
  }
  string result;
  int64_t i = LS;
  int64_t j = LT;
  while (i != 0 && j != 0) {
    if (dp[i - 1][j] == dp[i][j]) {
      --i;
    } else if (dp[i][j - 1] == dp[i][j]) {
      --j;
    } else {
      result += s.substr(i - 1, 1);
      --i;
      --j;
    }
  }
  reverse(result.begin(), result.end());
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 73640
#include<stdio.h>
int main(void){
  char *s="python3 -c\""
"n,m,*a=map(int,open(0).read().split())\n"
"d=[0]+[-1]*n*9\n"
"for i in range(n):d[i+1]=max(j+d[i-int('0144345265'[j])]*10for j in a)\n"
"print(d[n])\n"
"\"";
  system(s);
  return 0;
}            

Measured memory_bytes: 15436
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 998244353;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ll n ; cin >> n;
    if(n%10==3){
        cout <<"bon" << endl;
    }else if(n%10==0 || n%10==1 || n%10==6 ||n%10==8){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    return 0;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)(b); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int d, t, s;
    cin >> d >> t >> s;
    if (d <= s * t) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3564
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int main()
{
	for(int n,m;~scanf("%d%d",&n,&m);){
		int c[n],s[n][3];
		for(int i=0;i<n;i++){
			scanf("%*c%*[^\n]");
			scanf("%d",c+i);
			for(int j=0;j<3;j++)
				scanf("%d",s[i]+j);
		}
		
		int dp[m+1][3];
		memset(dp,0,sizeof dp);
		
		for(int i=0;i<n;i++)
			for(int j=c[i];j<=m;j++)
				for(int k=0;k<3;k++)
					dp[j][k]=max(dp[j][k],dp[j-c[i]][k]+s[i][k]);
		int res=0;
		for(int i=0;i<=m;i++)
			for(int j=0;j<3;j++)
				res=max(res,dp[i][j]);
		printf("%d\n",res);
	}
}

Measured memory_bytes: 1020
#include <bits/stdc++.h>
#define int long long
#define N 310
using namespace std;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}

typedef pair<int,int> P;
vector<int> G[N];
int g[N][N],can[N][N];
unordered_set<int> childs[N];

void addChild(int pos,int start,int flag = 0){
  if((!flag && childs[pos].count(start))) return;
  if(pos != start) childs[pos].insert(start);
  can[pos][start] = 1;
  can[start][pos] = -1;
  for(int to:G[pos]) addChild(to,start);
}

void merge(vector<P> &A,vector<P> &B,vector<P> &C,int c){
  if(c == 1) {
    for(P c:C) G[c.second].push_back(c.first), g[c.second][c.first] = 1;
    vector<int> used(N,0);
    for(P c:C){
      if(used[c.second]++) continue;
      addChild(c.second,c.second,1);
      for(auto to:childs[c.second]){
        if(used[to]++) continue;
        addChild(c.second,to,1);
      }
    }
  }
  
  if(c == -1){
    for(P c:C) B.push_back(c);
    for(P c:C) can[c.first][c.second] = -1;
  }
}

signed main(){
  string a,b;
  cin>>a>>b;
  map<string,int> idx;
  int num = 0; idx[a] = num++, idx[b] = num++;
  int n;
  cin>>n;

  map<P,unordered_set<int> > DB;
  vector<vector<P> > rule;
  for(int i=0;i<n;i++){
    int m;
    cin>>m;
    vector<P> g(m);
    for(int j=0;j<m;j++){
      string a,b;
      cin>>a>>b;
      if(!idx.count(a)) idx[a] = num++;
      if(!idx.count(b)) idx[b] = num++;
      int na = idx[a],nb = idx[b];
      g[j] = P(na,nb);
      DB[P(na,nb)].insert(i);
    }
    rule.push_back(g);
  }
  
  vector<P> A({P(idx[a],idx[b])}),B;
  G[idx[b]].push_back(idx[a]);
  childs[idx[a]].insert(idx[b]);
  
  int K = idx.size();
  vector<int> used(n,0);
  can[idx[a]][idx[b]] = 1;
  can[idx[b]][idx[a]] = -1;

  int update = 1;    
  while(update){
    update = 0;
    for(int i=0;i<K;i++)
      for(int j=0;j<K;j++){
        if(i == j || can[i][j] == 0 || !DB.count(P(i,j))) continue;
        unordered_set<int> &db = DB[P(i,j)];
        for(auto idx:db){
          if(used[idx]++) continue;
          update = 1;
          merge(A,B,rule[idx],can[i][j]);
        }
        DB.erase(P(i,j));
      }
  }
  int ans = 1;
  for(int k=0;k<K;k++)
    for(int i=0;i<K;i++)
      for(int j=0;j<K;j++) g[i][j] |= (g[i][k] && g[k][j]);
  
  for(int i=0;i<K;i++) ans &= (g[i][i] == 0);
  for(P b:B) ans &= !childs[b.first].count(b.second);
  cout<<(ans? "Yes":"No")<<endl;
  
  return 0;
}

Measured memory_bytes: 24636
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[100005]={0};
int main()
{
    int n;
    cin >> n;
    for(int i=0;i<n;i++)
        cin >>a[i];
    for(int i=n-1;i>0;i--){
        if(a[i]<a[i-1]){
            a[i-1]--;
            if(a[i-1]>a[i]){
                cout << "No\n";
                return 0;
            }
        }
    }
    cout << "Yes\n";
    return 0;
}


Measured memory_bytes: 640
#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>;

string fn(string x) {
  reverse(x.begin(),x.end());
  return x;
}

int main() {
  string s;
  cin >> s;
  bool ok = true;
  if(s!=fn(s)) ok = false;
  int n = s.size();
  string t = s.substr(0,(n-1)/2);
  if(t!=fn(t)) ok = false;
  string u = s.substr((n+3)/2-1);
  if(u!=fn(u)) ok = false;

  cout << (ok? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
m=1001
A=range(9)
d=[[0]*m for i in A]
for i in range(101):
  for j in A[::-1]:
    if j==0: d[j][i]=1
    else:
      for k in range(m):
        if k+i<m: d[j][k+i]+=d[j-1][k]
while 1:
  n,s=map(int,raw_input().split())
  if n==s==0: break
  print d[n-1][s]

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

#define rep(i,n) for(int (i)=0;(i)<n;++(i));
#define SORT(s) sort((s).begin(),(s).end());
#define SORTR(s) sort((s).begin(),(s).end(),greater<int>());

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

const double PI=acos(-1.0);

int N,M; vi L,R;
int input()
{  
    cin>>N>>M;
    for(int i=0;i<M;++i){
        int a,b;
        cin>>a>>b;
        L.emplace_back(a);
        R.emplace_back(b);
    }
}

int solve()
{
    SORT(L); SORT(R);
    int ans=max(*(R.begin())-*(L.end()-1)+1,0);
    cout<<ans<<endl;
}

int main(){
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}


Measured memory_bytes: 1276
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V

main = abc162b

abc162b = do
    [n] <- getIntList
    let nV = V.fromList [1..n]
    let nVfb = convFizzBuzz nV
    print $ V.sum nVfb

convFizzBuzz :: V.Vector Integer -> V.Vector Integer
convFizzBuzz = fmap (\x -> if (mod x 3 /= 0) && (mod x 5 /= 0) then x else 0) 

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

Measured memory_bytes: 4840
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 1000 * 100 + 47;
const int MOD = 1000 * 1000 * 1000 + 7;

struct Matrix
{
	LL A[3][3];
	void one()
	{
		FILL(A, 0);
		A[0][0] = A[1][1] = A[2][2] = 1;
	}

	Matrix operator *(const Matrix& T)
	{
		Matrix res;
		FOR(i, 0, 3)
		{
			FOR(j, 0, 3)
			{
				res.A[i][j] = 0;
				FOR(k, 0, 3)
				{
					res.A[i][j] = (res.A[i][j] + A[i][k] * T.A[k][j]) % MOD;
				}
			}
		}

		return res;
	}

	void print()
	{
		FOR(i, 0, 3)
		{
			FOR(j, 0, 3) cout << A[i][j] << " ";
			cout << endl;
		}
	}
};

//static VI operator *(const VI& V, const Matrix& M)
//{
//	VI R(SZ(V), 0);
//	FOR(i, 0, 3)
//	{
//		FOR(k, 0, 3)
//		{
//			R[i] = (R[i] + V[i] * M.A[k][i]) % MOD;
//		}
//	}
//
//	return R;
//}

Matrix bp(Matrix A, int n)
{
	Matrix R;
	R.one();
	while (n)
	{
		if (n & 1) R = R * A;
		
		n >>= 1;
		A = A * A;
	}

	return R;
}

int X[MAX];
Matrix A, B;
int A1[][3]{ {2, 2, 1}, {1, 1, 1}, {1, 0, 1} };
int B1[][3]{ {1, 2, 1}, {0, 1, 1}, {0, 0, 1} };

void initMatrixes()
{
	FOR(i, 0, 3)
	{
		FOR(j, 0, 3)
		{
			A.A[i][j] = A1[i][j];
			B.A[i][j] = B1[i][j];
		}
	}
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int n, m;
	cin >> n >> m;
	FOR(i, 0, m) cin >> X[i];

	initMatrixes();
	Matrix R;
	
	R.one();
	FOR(i, 0, m)
	{
		if (i == 0)
		{
			R = R * bp(A, X[i] - 1);
		}
		else
		{
			R = R * bp(A, X[i] - X[i - 1] - 1);
		}

		R = R * B;
		//R.print();
	}

	R = R * bp(A, n - X[m - 1]);

	//LL ans = R.A[0][0] + R.A[0][1] + R.A[0][2];
	//ans %= MOD;
	cout << R.A[0][2] << endl;
}

Measured memory_bytes: 640
N,K=map(int,input().split())
a=list(map(int,input().split()))
grundy=[0]*(K+1)
for j in range(K+1):
    s=set()
    for i in range(N):
        if a[i]<=j:
            s.add(grundy[j-a[i]])
    g=0
    while g in s:g+=1
    grundy[j]=g
if grundy[K]:print("First")
else:print("Second")

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

typedef long long ll;
#define ar array
#define vi vector<int>
#define vvi vector<vector<int>>
#define vll vector<long long>
#define all(x) (x).begin(), (x).end()
#define en '\n'
#define FILL(x, v) memset(x, v, sizeof(x))
#define pb push_back
#define fast                     \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(NULL);
#define F_OR(i, a, b, s) for (int i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define F_OR1(e) F_OR(i, 0, e, 1)
#define F_OR2(i, e) F_OR(i, 0, e, 1)
#define F_OR3(i, b, e) F_OR(i, b, e, 1)
#define F_OR4(i, b, e, s) F_OR(i, b, e, s)
#define GET5(a, b, c, d, e, ...) e
#define F_ORC(...) GET5(__VA_ARGS__, F_OR4, F_OR3, F_OR2, F_OR1)
#define FOR(...)       \
	F_ORC(__VA_ARGS__) \
	(__VA_ARGS__)

#define E_ACH2(x, a) for (auto &x : a)
#define E_ACH3(x, y, a) for (auto &[x, y] : a)
#define E_ACH4(x, y, z, a) for (auto &[x, y, z] : a)
#define E_ACHC(...) GET5(__VA_ARGS__, E_ACH4, E_ACH3, E_ACH2)
#define EACH(...)       \
	E_ACHC(__VA_ARGS__) \
	(__VA_ARGS__)

template <typename A, typename B>
inline void chmin(A &a, B b)
{
	if (a > b)
		a = b;
}
template <typename A, typename B>
inline void chmax(A &a, B b)
{
	if (a < b)
		a = b;
}

// const int mxN = 1e9 + 7;
const int M = 1e9 + 7;

ll pw(ll b, ll e)
{
	ll res = 1;
	while (e)
	{
		if (e % 2)
			res = (res * b) % M;
		b = (b * b) % M;
		e >>= 1; // e/=2;
	}
	return res;
}

string s[6];

int main()
{
	fast;
	int h, w, k, ans = 0;
	cin >> h >> w >> k;
	FOR(h)
	cin >> s[i];
	FOR(1 << h)
	{
		FOR(j, 1 << w)
		{
			int c = 0;
			FOR(i2, h)
			{
				FOR(j2, w)
				{
					if (i & (1 << i2) && j & (1 << j2) && s[i2][j2] == '#')
					{
						c++;
					}
				}
			}
			ans += c == k;
		}
	}
	cout << ans;
}

Measured memory_bytes: 3652
#include <cstdio>
using namespace std;
int main(){
  int n,x; auto dmy=scanf("%d %d", &n, &x);
  int d=0;
  int count=1;
  for(int i=0; i<n; i++){
    int l; dmy = scanf("%d", &l);
    d += l;
    if(d<=x) count++;
  }
  printf("%d", count);
}

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

#define ll long long
//~ #define endl '\n'

void solve(){
	int n; cin>>n;
	string s; cin>>s;
	if(n&1){
		cout<<"No"<<endl;
	}else{
		n = n / 2;
		for(int i = 0; i<n; i++){
			if(s[i] != s[i + n]){
				cout<<"No"<<endl;
				return;
			}
		}
		cout<<"Yes"<<endl;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int t = 1;// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!

    long long total_rainy=0,ans=0;
    string in_str,ans_str, tmp_str;
    
    cin >> in_str;
    
    for(int i=0;i<3;i++){
        if(in_str[i]=='R') total_rainy++;
    }
    
    if(total_rainy==0){
        ans=0;
    }else if(total_rainy==1){
        ans=1;
    }else if(total_rainy==2){
        if(in_str[1]!='R'){
            ans=1;
        }else{
            ans=2;
        }
    }else{
        ans=3;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3588
#include "bits/stdc++.h"
using namespace std;
#define INF 1000000000
#define rep(i, n) for(int i = 0; i < n; i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()  //昇順
#define RALL(x) (x).rbegin(), (x).rend() // 降順
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<int> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<char> VC; 
typedef vector<VS> VSS;
typedef vector<VC> VCC;    
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef map<int, int> MP;
typedef vector<pair<int, int> > PS;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
template<typename T>   // operator << (cout,a);
ostream& operator << (ostream& os, vector<T>& v) {
    os << "{";
    rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
    os << "}";
    return os;
}

int main(){
    ll a,b,x=0,y,d=0,n,h,w,k,m,min=1000,ans=0,ptr=0,sum=0;
    string s,s1,s2;
    bool f=true;
    cin >> x >> y;
    
    while(f){
        ans++;
        if(x*2>y)
            f=false;
        else
            x*=2;
        
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

int lower[100001];

int main()
{
    int n, k, q;
    cin >> n >> k >> q;

    vector<int> points(n, k-q);

    for (int i = 0; i < q; i++)
    {
        int x;
        cin >> x;

        points[x-1]++;
    }

    for (int i = 0; i < n; i++)
    {
        if (points[i] > 0)
            cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

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


int main()
{
	int n ;
	int m;
	int a[100000];
	int b;
	int ans = 0;
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		cin >> a[i];
	}

	for (int i = 0; i < m + 1; i++){
		if (i == 0){
			b = a[i] - 1;
		} else if (i == m){
			b = n - a[i - 1];
		}
		else{
			b = a[i] - a[i-1] - 1;
			if (b % 2 == 0){
				b /= 2;
			}
			else{
				b++;
				b /= 2;
			}
		}
		ans = max(b, ans);
	}

	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 1304
#include <bits/stdc++.h>
using namespace std;
 
long long gcd(long long a, long long b)
{
    if(b == 0)
        return a;
    return gcd(b, a % b);
}
int main()
{
    long long n;
    long long a, b;
    scanf("%lld", &n);
    for(long long i = 1;i <= n;++i)
    {
        long long x, y;
        scanf("%lld%lld", &x, &y);
        long long g = gcd(x, y);
        x /= g;
        y /= g;
        if(i == 1)
        {
            a = x;
            b = y;
        }
        else
        {
            long long t = max((a + x - 1) / x, (b + y - 1) / y);
            a = t * x;
            b = t * y;
        }
    }
    printf("%lld\n", a + b);
    return 0;
}

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

int main(){
	int n;
	int a[1000000];
	int b;
	int i, j, p;
	int c[10000][2];
	p = 1;
	while (1==1){
		scanf("%d", &c[p][0]);
		if(c[p][0]!=0)p++;
		else break;
	}
	//p--;
		b = (int)pow(1000000.0, 0.5);
		a[0] = -1;
		for (i = 2; i <= b; i++){
			for (j = 2; j <= 1000000/ i; j++){
				a[i*j - 1] = -1;
			}
		}
	//	printf("%d-%d\n",c[0][0],c[1][0]);
	for (i = 1; i < p; i++){	
		c[i][1] = 0;
		for (j = 1;c[i][0]>0; j++){
			if (a[j - 1] != -1){ 
				c[i][1]+=j; 
				c[i][0]--;
			}
		}
		printf("%d\n", c[i][1]);
	}

	return 0;
}

Measured memory_bytes: 4512
import math
inp = list(map(int,input().split()))
a = inp[0]
b = inp[1]
h = inp[2]
m = inp[3]

kakudo = min(((math.pi*h/6 + math.pi*m/360) - math.pi*m/30), 2*math.pi-((math.pi*h/6 + math.pi*m/360)-math.pi*m/30))

ans = math.sqrt(a**2+b**2-2*a*b*math.cos(kakudo))

print(ans)

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

int main(){
    string s;
    cin >> s;
    int count[256] = {};
    for(char c: s){
        count[(int)c]++;
    }
    int num = 0;
    for(int i=0; i<256; i++){
        if(count[i]%2==1) num++;
    }
    cout << num/2 << endl;
    return 0;
}



Measured memory_bytes: 3212