akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pii pair<int,int>
#define q pair<pii, int>

int N, Q;
string S;
vector<q> V;
set<int> s[30];

signed main()
{
    cin >> N >> S >> Q;

    rep(i, N)s[S[i] - 'a'].insert(i);

    while(Q--)
    {
        int k;
        cin >> k;
        if(k == 1)
        {
            int idx;
            char c;
            cin >> idx >> c;
            idx--;
            s[S[idx] - 'a'].erase(idx);
            s[c - 'a'].insert(idx);
            S[idx] = c;
        }
        else
        {
            int l, r;
            cin >> l >> r;
            l--, r--;
            int ans = 0;
            for(int i = 0; i <= 'z' - 'a'; i++)
            {
                auto it = s[i].lower_bound(l);
                if(it != s[i].end() && *it <= r)ans++;
            }
            cout << ans << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 27216
package main

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

func scanNext(sc *bufio.Scanner) int {
  sc.Scan()
  n, err := strconv.Atoi(sc.Text())
  if err != nil {
    panic(err)
  }
  return n
}

func main() {
  sc := bufio.NewScanner(os.Stdin)

  n := scanNext(sc)
  min_r := scanNext(sc)
  max_profit := -10000000000

  for i := 1; i < n; i++ {
    r := scanNext(sc)
    if r - min_r > max_profit {
      max_profit = r - min_r
    }
    if r < min_r {
      min_r = r
    }
  }

  fmt.Println(max_profit)
}


Measured memory_bytes: 4092
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
typedef pair<LL, LL> PLL;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned long long ULL;
//typedef boost::multiprecision::cpp_int bigint;

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	LL S, W;
	cin >> S >> W;
	if (W >= S)cout << "unsafe\n";
	else cout << "safe\n";
	return 0;
}

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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  ll a, b;
  cin >> a >> b;
  auto f = [&](ll x) {
    ll res;
    ll num = (x+1)/2;
    if (x % 2 == 0) {
      if (num % 2 == 0) res = 0;
      else res = 1;
      return x^res;
    }
    else {
      if (num % 2 == 0) res = 0;
      else res = 1;
      return res;
    }
  };
  ll ans = f(b) ^ f(a-1);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<iomanip>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)

int N, A, B;
int main(int argc, const char * argv[]) {
    cin >> N >> A >> B;
    
    int D = B - A - 1;
    if (D%2 != 0) {
        cout << "Alice" << endl;
    } else {
        cout << "Borys" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

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

  double t, a;
  cin >> t >> a;

  double least_diff = 1000005;
  double res = -1;
  for (int i = 0; i < n; ++i) {
    double h;
    cin >> h;

    double temp = t-h*0.006;
    if (abs(temp-a) < least_diff) {
      least_diff = abs(temp-a);
      res = i+1;
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 17.08.2019 15:17:53       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  k = min(k, 15);
  string s;
  cin >> s;
  string u = s + string(s.rbegin(), s.rend());
  string ans = s;
  for (int i = 0; i <= n; i++) {
    string t = u.substr(i, n);
    string w;
    if (k == 1) {
      w = t;
    } else {
      int cnt = 0;
      for (int j = n - 1; j >= 0; j--) {
        if (t[j] == t[n - 1]) {
          ++cnt;
        } else {
          break;
        }
      }
      int in_w = min(cnt << (k - 1), n);
      w = string(in_w, t[n - 1]);
      int rm = n - (int) w.size();
      string sub = t.substr(n - cnt - rm, rm);
      w += string(sub.rbegin(), sub.rend());
    }
    ans = min(ans, w);
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>


bool checkSentence(std::string S, std::string T, int count)
{	
	for(int i=count; i<T.length()+count; i++){
		if(S[i] == T[i-count] || S[i] == '?'){
			continue;
		}
		else if(S[i] != T[i-count]){
			return false;
		}
	}
	return true;
}

int main()
{
	std::string S, T, Scopy;
	std::cin >> S >>T;
	bool flag = false;
	for(int i=0; i<S.length(); i++){
		if(checkSentence(S, T, i)){
			flag = true;
			Scopy = S;
			for(int j=i; j<T.length()+i; j++){
				Scopy[j] = T[j-i];
			}
			for(int j=i+T.length(); j<Scopy.length(); j++){
				if(Scopy[j] == '?'){
					Scopy[j] = 'a';
				}
			}	
		}
		if(i == S.length()-1 && !flag){
			printf("UNRESTORABLE\n");
		}
		if(S[i] == '?'){
			S[i] = 'a';
		}
	}
	if(flag){
		std::cout << Scopy << std::endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,D,X;
  int ans=0;
  cin >> N >> D >> X;
  for(int i=0;i<N;i++){
    int a;
    cin >> a;
    ans += (D-1)/a+1;
  }
  cout << ans+X << endl;
  return 0;
}

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

int mod = 1e9 + 7;

int binpow(int a, int b)
{
    if (b == 0)
        return 1;
    if (b == 1)
        return a % mod;
    int c = binpow(a, b / 2);
    c = (c * c) % mod;
    if (b % 2)
        c = (c * a) % mod;
    return c;
}

signed main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, t;
    cin >> n >> m >> t;
    int r = __gcd(n, t);
    n /= __gcd(n, t);
    r *= __gcd(m, t);
    m /= __gcd(m, t);
    cout << binpow((binpow(2, n) + binpow(2, m) + binpow(2, __gcd(n, m)) - 3 + mod) % mod, r);
}


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

typedef pair<int,int> pii;

const int maxn = 1e5 + 7;

pii a[maxn][2];
vector<pii> v;
map<pii,int> M;
stack<int> S;
int r,c;

inline bool angsort(pii p, pii q) {
	return atan2(p.first - r/2.0, p.second - c/2.0) < atan2(q.first - r/2.0, q.second - c/2.0);
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin>>r>>c>>n; M.clear();
	for (int i = 1; i <= n; i++) {
		cin>>a[i][0].first>>a[i][0].second>>a[i][1].first>>a[i][1].second;
		if ((a[i][0].first == 0 || a[i][0].first == r || a[i][0].second == 0 || a[i][0].second == c) &&  
			(a[i][1].first == 0 || a[i][1].first == r || a[i][1].second == 0 || a[i][1].second == c)) {
				v.push_back(a[i][1]);
				v.push_back(a[i][0]);
				M[a[i][0]] = i; M[a[i][1]] = i;
		}

	}

	sort(v.begin(), v.end(), angsort);

	/*for (int i = 0; i < v.size(); i++) {
		cout<<v[i].first<<","<<v[i].second<<endl;
	}*/

	for (int i = 0; i < v.size(); i++) {
		int k = M[v[i]];
		if (S.size() > 0 && S.top() == k) { S.pop(); }
		else S.push(k);
	}
	
	if (S.size() > 0) cout<<"NO"<<endl;
	else cout<<"YES"<<endl;
}


Measured memory_bytes: 16112
#include<stdio.h>
int Min(int,int);

int main(){
  int n,i,j,k,l;
  int f[101],s[101][101];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d %d",&f[i-1],&f[i]);
  }
  for(i=1;i<=n;i++){
    s[i][i]=0;
  }
  for(l=2; l<=n; l++){
    for(i=1; i<=n-l+1; i++){
      j=i+l-1;
      s[i][j]=1E+9;
      for(k=i; k<=j-1;k++){
    s[i][j] = Min(s[i][j],s[i][k]+s[k+1][j]+f[i-1]*f[k]*f[j]);
      }
    }
  }
    printf("%d\n",s[1][n]);
    return 0;
}

int Min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}



Measured memory_bytes: 2100
import java.util.*;

public class Main {
    public static void main(String args[]) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String s = sc.next();
        
        Map<Character, Integer> freq = new HashMap<>();
        int max = 0;
        int cnt = 0;
        for(int i = 1; i < s.length(); i++) {
            freq.clear();
            cnt = 0;
            for(int j = 0; j < i; j++) {
                char c = s.charAt(j);
                freq.put(c, freq.getOrDefault(c, 0) + 1);
            }  
            for(int j = i; j < s.length(); j++) {
                char c = s.charAt(j);
                if(freq.containsKey(c)) {
                    cnt++;
                    freq.remove(c);
                }
            }
            max = Math.max(max, cnt);
        }
        System.out.println(max);
    }
}


Measured memory_bytes: 25172
import sys


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


sys.setrecursionlimit(10 ** 9)


def main():
    N = int(input())
    if N < 105:
        print(0)
        return

    def make_divisors(n):
        divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)
        return divisors

    cnt = 1
    for n in range(106, N + 1):
        if n % 2 == 1:
            d = make_divisors(n)
            if len(d) == 8:
                cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
S = input()
T = input()

diff = len(S) - len(T)
min_cnt = 1000
for i in range(0,diff+1):
  cnt = 0
  for j in range(len(T)):
    if T[j] != S[i+j]:
      cnt += 1
  if cnt < min_cnt:
    min_cnt = cnt
    if cnt == 0:
      break
    
print(min_cnt)


Measured memory_bytes: 9104
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = (int)1e5 + 10;

int n, sz[N], tot, par[N];
vector<int> v[N];

void dfs(int s, int p = -1, int depth = 0){
   par[s] = p;
   if(s == n)tot = depth-1;
   sz[s] = 1;
   for(auto i: v[s]){
      if(i != p){
         dfs(i, s, depth+1);
         sz[s] += sz[i];
      }
   }
}

void a(){
   cout<<"Fennec";
   exit(0);
}

void b(){
   cout<<"Snuke";
   exit(0);
}

int32_t main(){_

   cin>>n;
   for (int i = 0; i < n-1; ++i)
   {
      int x, y;
      cin>>x>>y;
      v[x].pb(y);
      swap(x, y);
      v[x].pb(y);
   } 

   dfs(1);

   int ones = n - (sz[n] + tot + 1);
   int nes = sz[n] - 1;

   int tmp = tot >> 1, nod = n, tmp2 =  tot;
   int ok = tmp;

   tot -= tmp;
   while(tmp){
      --tmp;
      nod = par[nod];
   }

   tr(tmp, nod, sz[nod]);
   nes = sz[nod] - ok;
   ones = n - sz[nod] - tot;

   tr(ones, nes, tot, sz[n]);
   tot = tmp2;
   if(tot % 2 == 1){
      if(nes > ones)b();
      else a();
   }

   else{
      if(ones > nes)a();
      else b();
   }


   #warning make sure N size is correct!
   return 0;
}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#include<boost/multiprecision/cpp_int.hpp>
using namespace std;
using namespace boost::multiprecision;
#define BEGIN ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define END return EXIT_SUCCESS
#define rep(I,N) for(auto I=0;I<(N);++I)
#define up(I,A,B) for(auto I=(A);I<=(B);++I)
#define dw(I,A,B) for(auto I=(A);I>=(B);--I)
#define all(C) (C).begin(),(C).end()
#define rall(C) (C).rbegin(),(C).rend()
#define ft first
#define sd second
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define rs resize
typedef long long ll;
typedef unsigned long long ull;
template<class T>inline void                                      in(T &p){cin>>p;}
template<class T1,class T2>inline void                            in(T1 &p1,T2 &p2){cin>>p1>>p2;}
template<class T1,class T2,class T3>inline void                   in(T1 &p1,T2 &p2,T3 &p3){cin>>p1>>p2>>p3;}
template<class T1,class T2,class T3,class T4>inline void          in(T1 &p1,T2 &p2,T3 &p3,T4 &p4){cin>>p1>>p2>>p3>>p4;}
template<class T1,class T2,class T3,class T4,class T5>inline void in(T1 &p1,T2 &p2,T3 &p3,T4 &p4,T5 &p5){cin>>p1>>p2>>p3>>p4>>p5;}
template<class T>inline void                                      ins(T &p){for_each(all(p),in<decltype(p[0])>);}
template<class T>inline void                             out(T p){cout<<p<<endl;}
template<class T1,class T2>inline void                   out(T1 p1,T2 p2){cout<<p1<<" "<<p2<<endl;}
template<class T1,class T2,class T3>inline void          out(T1 p1,T2 p2,T3 p3){cout<<p1<<" "<<p2<<" "<<p3<<endl;}
template<class T1,class T2,class T3,class T4>inline void out(T1 p1,T2 p2,T3 p3,T4 p4){cout<<p1<<" "<<p2<<" "<<p3<<" "<<p4<<endl;}
inline                                              void out(double p){printf("%.10f\n",p);}
template<class T>inline                             void outs(T p){for_each(all(p),out<decltype(p[0])>);}

inline void solve(void){
  int N;
  in(N);
  out(N%2==0?0.5:((N+1)/2.0)/N);
}
int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main()
{
	while (true) {
		int N, M, Q;

		cin >> N >> M >> Q;

		if (N == 0 && M == 0 && Q == 0) {
			break;
		}

		vector<vector<bool>> swi(Q, vector<bool>(N));
		vector<vector<bool>> bulb(Q, vector<bool>(M));
		vector<int> state(N, 0);
		vector<vector<bool>> graph(N, vector<bool>(M, true));

		rep(i, Q) {
			rep(j, N) {
				char temp;

				cin >> temp;

				if (temp == '0') {
					swi[i][j] = false;
				}
				else {
					swi[i][j] = true;
				}
			}

			rep(j, M) {
				char temp;
				
				cin >> temp;

				if (temp == '0') {
					bulb[i][j] = false;
				}
				else {
					bulb[i][j] = true;
				}
			}
		}

		rep(i, Q) {
			rep(j, N) {
				if (swi[i][j] == true) {
					state[j] = (state[j] + 1) % 2;
				}
			}

			rep(j, N) {
				rep(k, M) {
					if (state[j] != bulb[i][k]) {
						graph[j][k] = false;
					}
				}
			}
		}

		rep(i, M) {
			int count = 0;
			int s;

			rep(j, N) {
				if (graph[j][i] == true) {
					count++;
					s = j;
				}
			}

			if (count >= 2) {
				cout << '?';
			}
			else if (count == 1) {
				if (s <= 9) {
					cout << s;
				}
				else {
					char c = 'A';

					c += s - 10;

					cout << c;
				}
			}
		}

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int K;
  cin >> K;
  vector<string> mi(K, string(5010, 'z'));
  auto insert = [&](string s) {
    for (int i = 0; i < K; i++) {
      if (mi[i] == s) return;
      if (mi[i] > s) swap(mi[i], s);
    }
  };
  int N = s.length();
  for (int i = 0; i < N; i++)
    for (int j = i + 1; j <= N; j++) insert(s.substr(i, j - i));
  cout << mi.back() << '\n';
  return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	ll n, m;
	cin >> n >> m;
	ll ans = 0;
	if (2 * n >= m) {
		ans = m/2;
	}
	else {
		m -= 2 * n;
		ans = n;
		if (m / 4 > 0) {
			ans += m / 4;
		}
	}

	cout << ans << endl;

	return 0;
}
 


Measured memory_bytes: 256
from itertools import accumulate

def solve():
    MOD = 10**9 + 7

    N, K = map(int, input().split())
    As = list(map(int, input().split()))

    dp = [0] * (K+1)
    dp[0] = 1
    for A in As:
        dp = list(accumulate(dp))
        for j, d in enumerate(dp[:K-A], start=A+1):
            dp[j] -= d
        dp = [dpi % MOD for dpi in dp]

    print(dp[K])


solve()


Measured memory_bytes: 13112
#include <stdio.h>
#include <string.h>
 
  int i,j,k,l,m;
  int n,e,s,w,un,up;
  int a[7];
int t;
 
 
void input() {
 for(i=0;i<6;i++){
   
    scanf("%d",&a[i+1]);
   
  }
}
 
 void N() {
   t = a[1];
   a[1] = a[2];
   a[2] = a[6];
   a[6] = a[5];
   a[5] = t;
 }
 
 void S() {
   t = a[1];
   a[1] = a[5];
   a[5] = a[6];
   a[6] = a[2];
   a[2] = t;
}
 
 void E() {
   t = a[1];
   a[1] = a[4];
   a[4] = a[6];
   a[6] = a[3];
   a[3] = t;
 }
 
 void W() {
   t = a[1];
   a[1] = a[3];
   a[3] = a[6];
   a[6] = a[4];
   a[4] = t;
 }
 
int main() {
 
  input();
  //  strlen(?) 文字の長さ(数)を表示
 char str[110];  
 scanf("%s",str);
 
 for(i=0;i<strlen(str);i++) {
 
   if(str[i] == 'N') {
     N();
   } else if(str[i] == 'S') {
     S();
   } else if(str[i] == 'W') {
     W();
   } else if(str[i] == 'E') {
     E();
   }
 }
 
 printf("%d\n",a[1]);
 
 return 0;
}



Measured memory_bytes: 2144
#include<cstdio>
#include<cmath>
#include<string>

using namespace std;

int main()
{
	char input[99];
	string str;
	int res;
	int min = 9999;
	int cur;
	int i;

	scanf("%s", input);

	str = input;

	res = (str[0] - '0') * 100 + (str[1] - '0') * 10 + (str[2] - '0');
	
	min = abs(res - 753);

	cur = res;

	for (i = 3; i < str.size(); i++)
	{
		cur = cur * 10 % 1000 + (str[i] - '0');

		if (abs(cur - 753) < min)
		{
			min = abs(cur - 753);
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
// #define BEGIN_STACK_EXTEND(size) void * stack_extend_memory_ = malloc(size);void * stack_extend_origin_memory_;char * stack_extend_dummy_memory_ = (char*)alloca((1+(int)(((long long)stack_extend_memory_)&127))*16);*stack_extend_dummy_memory_ = 0;asm volatile("mov %%rsp, %%rbx\nmov %%rax, %%rsp":"=b"(stack_extend_origin_memory_):"a"((char*)stack_extend_memory_+(size)-1024));
// #define END_STACK_EXTEND asm volatile("mov %%rax, %%rsp"::"a"(stack_extend_origin_memory_));free(stack_extend_memory_);

#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<unordered_map>
#include<complex>
using namespace std;
const long long mod=1000000009;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-11;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 11100000;
const int UF_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	inline long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
char in[2];
int main(){
	scanf("%s",in);
	if('a'<=in[0]&&in[0]<='z')printf("a\n");else printf("A\n");
}

Measured memory_bytes: 1660
#include <stdio.h>
int main(){
char s[3];
int count=0;
for(int i=0;i<3;i++){
	scanf("%c",&s[i]);
}
if(s[0]=='R' && s[1]=='R' && s[2]=='R')count=3;
else if(s[0]=='R'&&s[1]=='R'&&s[2]=='S') count=2;
else if(s[0]=='S'&&s[1]=='R'&&s[2]=='R') count=2;
else if(s[0]=='R'&&s[1]=='S'&&s[2]=='R') count=1;
else if(s[0]=='R'&&s[1]=='S'&&s[2]=='S') count=1;
else if(s[0]=='S'&&s[1]=='R'&&s[2]=='S') count=1;
else if(s[0]=='S'&&s[1]=='S'&&s[2]=='R') count=1;
else if(s[0]=='S'&&s[1]=='S'&&s[2]=='S') count=0;



printf("%d",count);
return 0;
}

Measured memory_bytes: 1668
N=int(input())
H=list(map(int, input().split()))

if N==1:
    print('Yes')
    exit()

for ii in reversed( range(1, N) ):
    if H[ii-1] <= H[ii]:
        continue
    elif H[ii-1] - 1 == H[ii]:
        H[ii-1] -= 1
    else:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;


int main() {
int N,M,X;
cin >> N >> M >> X;
vector<int> vec(N);
for (int i = 0;i < M;i++) {
    int a;
    cin >> a;
    vec.at(a) = 1;
}
int ans = 0;
int cnt = 0;
for (int i = 1;i < X;i++) {
    if (vec.at(i) == 1) ans++;
}
for (int i = X+1;i < N;i++) {
    if (vec.at(i) == 1) cnt++;
}
cout << min(ans,cnt) << endl;


return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {

        string[] strArray = Console.ReadLine().Split(' ');
        int[] intArray = new int[strArray.Length];
        for (int i = 0; i < intArray.Length; i++)
        {
            intArray[i] = int.Parse(strArray[i]);
        }

        Array.Sort(intArray);

        Console.WriteLine("{0} {1} {2} {3} {4}", intArray[4], intArray[3], intArray[2], intArray[1], intArray[0]);

    }
}


Measured memory_bytes: 9372
#include "bits/stdc++.h"
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cerr<<(#v)<<":";for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;
#define printVS(vs) cerr<<(#vs)<<":"<<endl;for(auto(s):(vs)){cerr<<(s)<< endl;}
#define printVV(vv) cerr<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cerr<<" "<<(x);}cerr<<endl;}
#define printP(p) cerr<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cerr<<(#vp)<<":"<<endl;for(auto(p):(vp)){cerr<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cerr << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cerr << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll << 60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

  int x;
  cin>>x;
  if(x>0)
  {
    cout<<"ai1333"<<string(x/100,'3')<<endl;
  }
  else cout<<"ai1333"<<endl;
  return 0;
}



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

ll n;
using Graph = vector<vector<int>>;
Graph G(100005);
ll dist1[100005];
ll distn[100005];
void dfs1(ll v,ll p,ll d){
    dist1[v]=d;
    for(auto &nv:G[v]){
        if(nv==p) continue;
        dfs1(nv,v,d+1);
    }
}
void dfsn(ll v,ll p,ll d){
    distn[v]=d;
    for(auto &nv:G[v]){
        if(nv==p) continue;
        dfsn(nv,v,d+1);
    }
}

int main(){
    cin >> n;
    for(ll i=0;i<n-1;i++){
        ll a,b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs1(0,-1,0);
    dfsn(n-1,-1,0);
    ll count=0;
    for(ll i=0;i<n;i++){
        if(dist1[i]<=distn[i]) count++;
    }
    if(count>n-count) cout << "Fennec" << endl;
    else if(count<=n-count) cout << "Snuke" << endl;
}  


Measured memory_bytes: 14772
import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

# 5
# 3 5 2 1 4
def cum(i):
    res = 0
    while i>0:
        res += bit[i]
        i -= i&-i
    return res

def add(i, x):
    while i<=N:
        bit[i] += x
        i += i&-i

def pos(a):
    return i

def solve():
    global N,A,bit
    N = int(input())
    A = list(map(int, input().split()))
    bit = [0]*(N+1)

    B = list(set(A))
    B.sort()
    B = [-1] + B

    res = 0
    for i in range(N):
        j = bisect_left(B, A[i])
        res += cum(j)
        add(j, 1)

    print(N*(N-1)//2-res)

    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}



Measured memory_bytes: 31952
#define  _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
#pragma comment (linker, "/STACK:526000000")

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}

void init() {
	iostream::sync_with_stdio(false);
	cout << fixed << setprecision(10);
}

#define int ll
void solve() {
	while (true) {
		int e;
		cin >> e;
		if (e == 0) return;
		int m = 1e9;
		for (int i = 0; i * i * i <= e; ++i) {
			int hoge = e - i * i * i;
			for (int q = 0; q * q <= hoge; ++q) {
				int tmp = hoge - q * q;
				if (tmp >= 0) {
					m = min(m, i + q + tmp);
				}
			}
		}
		cout << m << endl;
	}
}
#undef int

int main() {
	init();
	solve();
}


Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  int x, n, a;
  cin >> x >> n;
  int dist = 1000000;
  int ans;
  vector<int> arr(101, 0);
  if(n == 0){
    cout << x <<endl;
    return 0;
  }
  if(n == 100){
    if(x > 50){
      cout << 101 << endl;
    }else{
      cout << 0 << endl;
    }
    return 0;
  } 
  for(int i=0;i<n;i++){
    cin >> a;    
    arr[a] = 1;
  } 
  for(int i=0;i<=100;i++){
    if(arr[i] != 1){
      if(abs(i - x) < dist){
        dist = abs(i - x);
        ans = i;
      }
    }
  }
  if(abs(ans - x) > abs(101 - x)){
    cout << 101 << endl;
    return 0;
  }
  cout << ans << endl;
  return 0;
}

/*
49 100
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100

100 3
98 99 100
*/

Measured memory_bytes: 3196
KX = list(map(int,input().split()))

K = KX[0]
X = KX[1]

MIN = X - (K-1)
MAX = X + (K-1)+1

lis = list(range(MIN,MAX))

for i in range(len(lis)):
    print("{}".format(lis[i]), end="")
    if i == len(lis)-1:
        # print("sss")
        continue
    else:
        print(" ", end="")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define lf long double
#define vi vector<int>
#define vl vector<long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define MOD 1000000007
#define pb push_back
#define mk make_pair
#define f first
#define s second
#define in insert
#define all(x) x.begin(),x.end()
#define apo ios::sync_with_stdio(false);cin.tie(0)
#define MAX 1000
ll add(ll x, ll y) {ll res = x + y; return (res >= MOD ? res - MOD : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= MOD ? res % MOD : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + MOD : res);}

ll power(ll x, ll y) {if (y < 0) return 1; ll res = 1; x %= MOD; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}

int main(){
	apo;
	ll i,t;
	cin>>t;
	string AC="AC";
	string WA="WA";
	string TLE="TLE";
	string RE="RE";
	string condition[t];
	for(i=0;i<t;i++){
		cin>>condition[i];
	}
	ll c_AC = count(condition,condition+t,AC);
	ll c_WA = count(condition,condition+t,WA);
	ll c_TLE = count(condition,condition+t,TLE);
	ll c_RE = count(condition,condition+t,RE);
	cout<<"AC x "<<c_AC<<endl;
	
	cout<<"WA x "<<c_WA<<endl;
	cout<<"TLE x "<<c_TLE<<endl;
	
	cout<<"RE x "<<c_RE<<endl;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
vector<l_l> drink;
ll N, M;
int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    for(int i = 1; i <= N; i++) {
        ll A, B;
        cin >> A >> B;
        drink.push_back({A, B});
    }
    sort(drink.begin(), drink.end());
    ll ans = 0;
    int index = 0;
    while(M--) {
        while(drink[index].second == 0) index++;
        ans += drink[index].first;
        drink[index].second--;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  string s;
  cin >> s;
  for (int i= 0; i < s.size()-1; i++){
    if (s.at(i) == s.at(i+1)){
      puts("Bad");
      return 0;
    }
  }
  puts("Good");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
using namespace std;
 
#define LOCAL  1
#define UPLOAD 2
 
#define ll long long
const long long INF = 1LL << 60;
 
template <class T = long long> T input(){T x;cin >> x;return x;}
template <class T> void output(T x){cout << x << endl;}
#define debug(x) cerr << #x<< ": " << x<< '\n';
#define debugBit(x,n) cerr << #x<< ": " << std::bitset<n>(x) << '\n';
#define REP(i,M) for(int i=0;i<M;i++)
 
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
 
int main()
{
#if ENVIRONMENT == LOCAL
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
  
  ll N = input();
  vector<ll> X;

  ll max = 0;
  for(int i=0;i<N;i++){
    ll l = input();
    X.push_back(l);
    chmax(max,l);
  }

  ll min = INF;
  for(int i=0;i<max;i++){
    ll sum = 0;
    for(int j=0;j<N;j++){
      sum += pow(X[j] - (i + 1), 2);
    }
    chmin(min, sum);
  }

  output(min);
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
    int n,m,i,count;
    cin >> n;
    count = 0;

    for (int j = 0; j < n ; ++j){
        cin >> m;
        if (m == 2) ++count;
        else if (m < 2 || m%2 ==0){
            continue;
        }
        else{
            i = 3;
            while(i <= sqrt(m)){
                if(m%i == 0) break;
                i = i+2;
            }
            if(i > sqrt(m)) {
                ++count;
            }
        }
    } 
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1160
import statistics
import math

n = int(input())
A = list(map(int, input().split()))

for i in range(n):
    A[i] = A[i]-i-1
A.sort()
m = statistics.median(A)

f = math.floor(m)
c = math.ceil(m)
sum_f = 0
sum_c = 0

for i in range(n):
    sum_f += abs(A[i]-f)
    sum_c += abs(A[i]-c)
    
print(min(sum_f, sum_c))

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

#define vi vector<int>
#define vvi vector<vi>

int main() {

    int N, D;
    cin >> N >> D;

    vvi x;
    int tmp;
    for (int i = 0; i < N; i++) {
        vi sx;
        for (int j = 0; j < D; j++) {
            cin >> tmp;
            sx.push_back(tmp);
        }
        x.push_back(sx);
    }

    int sum;
    int n;
    int ans = 0;
    for (int i = 0; i < N-1; i++) {
        for (int j = i+1; j < N; j++) {
            sum = 0;
            for (int k = 0; k < D; k++) {
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
            }
            n = floor(sqrt(sum));
            if (n*n == sum || (n+1)*(n+1) == sum) {
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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


int main(void)
{
	int i,j, n, num;
	int Scard[14] = { 0 }, Hcard[14] = { 0 }, Ccard[14] = { 0 }, Dcard[14] = { 0 };
	char mark = '0';

	scanf("%d", &n);
	getchar();

	for (j = 0; j < n;j++){

		scanf("%c %d", &mark, &num);
		getchar();

		if (mark == 'S'){
			Scard[num] = 1;
		}
		else if (mark == 'H'){
			Hcard[num] = 1;		
		}
		else if (mark == 'C'){
			Ccard[num] = 1;	
		}
		else if (mark == 'D'){
			Dcard[num] = 1;
		}
	}

	for (i = 1; i <= 13; i++){
		if (Scard[i] == 0){
			printf("S %d\n", i);
		}
	}
	for (i = 1; i <= 13; i++){
		if (Hcard[i] == 0){
			printf("H %d\n", i);
		}
	}
	for (i = 1; i <= 13; i++){
		if (Ccard[i] == 0){
			printf("C %d\n", i);
		}
	}
	for (i = 1; i <= 13; i++){
		if (Dcard[i] == 0){
			printf("D %d\n", i);
		}
	}

	return 0;
}

Measured memory_bytes: 1028
import java.util.*;
import java.util.stream.*;

public class Main {

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


	char t[][];
	long dp[];
	long mod = 1000000007;
	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();
		t = new char[2][n];
		dp = new long[n+1];
		for(int i=0; i<2; i++) {
			t[i] = sc.next().toCharArray();
		}

		dp[0]=1;
		int i=0;
		boolean pretate = false;
		while(i<n) {
			if(i==0) {
				//縦
				if(t[0][i] == t[1][i]) {
					dp[i+1] = 3;
					i++;
					pretate=true;
				//横
				}else {
					dp[i+1] = 6;
					dp[i+2] = 6;
					i+=2;
					pretate=false;
				}
			}else {
				//縦
				if(t[0][i] == t[1][i]) {
					if(pretate) {
						dp[i+1] = dp[i]*2;
						dp[i+1] %= mod;
					}else {
						dp[i+1] = dp[i];
						dp[i+1] %= mod;
					}
					pretate=true;
					i++;
				//横
				}else {
					if(pretate) {
						dp[i+1] = dp[i]*2;
						dp[i+1] %= mod;
						dp[i+2] = dp[i]*2;
						dp[i+2] %= mod;
					}else {
						dp[i+1] = dp[i]*3;
						dp[i+1] %= mod;
						dp[i+2] = dp[i]*3;
						dp[i+2] %= mod;
					}
					pretate=false;
					i+=2;
				}
			}

		}
		System.out.println(dp[n]);
		sc.close();
	}

}


Measured memory_bytes: 35816
#include<stdio.h>
#include<stdlib.h>
int main(){
	char date[11],ye[5],mo[3],da[3];
	int i,y,m,d,k=0;
	scanf("%s",date);
	for(i=0;i<4;i++){
		ye[i] = date[i];
	}
	for(i=0;i<3;i++){
		mo[i] = date[i + 5];
	}
	for(i=0;i<3;i++){
		da[i] = date[i + 8];
	}
	y = atoi(ye);
	m = atoi(mo);
	d = atoi(da);
	if(y <= 2019){
		if(m <= 4){
			if(d <= 30){
				k=1;
			}
		}
	}
	if(k==0){
		printf("TBD\n");
	}else{
		printf("Heisei\n");
	}
	return 0;
}

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

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

  string s;
  cin >> s;
  int n = s.size();
  string res = s[0] + to_string(n-2) + s[n-1];
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 256
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
//#define min(a, b, c) min(a, min(b, c))
//#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll pr[100000+1]={0};
	cin>>n;
	ll q;
	cin>>q;
	cin>>str;
	pr[0]=0;
	for(int i=1;i<n;i++)
	{
	    if(str[i]=='C' && str[i-1]=='A')
	    pr[i]++;
	    pr[i]+=pr[i-1];
	}
	while(q--)
	{
	    cin>>a>>b;
	    a--;
	    b--;
	   ll ans=pr[b]-pr[a];
	   cout<<ans;
	   nl;
	}
}

Measured memory_bytes: 1872
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

//typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
	
	int N;
	cin >> N;
	
	int a[2000];
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	
	for(int i = 0; i < N; i++){
		for(int j = i + 1; j < N; j++){
			if((a[i] - a[j]) % (N - 1) == 0){
				cout << a[i] << " " << a[j] << endl;
				return 0;
			}
		}
	}
	
	return 0;
}



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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

ll d[200010];
ll MOD = 1e9+7;

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

	ll a,k,b;cin>>a>>b>>k;


	if(a >= k){
		a -=k;
		k=0;
	}else {
		k -=a;
		a =0;
	}



	cout<<a<<" "<<max(0LL,b-k)<<endl;




}




Measured memory_bytes: 256
N, x = list(map(int, input().split()))
a = list(map(int, input().split()))

b = sorted(a)

ans = 0
total = 0

for i in range(len(b)):
    if i != (len(b) - 1):
        if total + b[i] <= x:
            ans += 1
            total += b[i]
    elif total + b[i] == x:
        ans += 1
    else:
        ans += 0

print(ans)

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

sys.setrecursionlimit(100000)
input = sys.stdin.readline


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


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


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


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


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


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


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


def mt(f):
    import time

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

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

    return wrap


@mt
def slv(N, XY):
    g = [[] for _ in range((10**5)*2)]
    offset = 10**5
    cs = set()
    for x, y in XY:
        x -= 1
        y = y - 1 + offset
        g[x].append(y)
        g[y].append(x)
        cs.add(x)
        cs.add(y)
    ans = 0
    while cs:
        error_print(len(cs))
        q = set([cs.pop()])
        done = set()
        done_c = set()
        while q:
            v = q.pop()
            for u in g[v]:
                if v >= offset:
                    e = (u, v)
                else:
                    e = (v, u)
                if e not in done:
                    q.add(u)
                    done.add(e)
                    done_c.add(u)
                    done_c.add(v)
        xn = set()
        yn = set()
        for v, u in done:
            for z in (v, u):
                if z >= offset:
                    yn.add(z)
                else:
                    xn.add(z)
        ans += (len(xn) * len(yn)) - len(done)
        cs -= done_c

    return ans

def main():
    N = read_int()
    XY = [read_int_n() for _ in range(N)]
    print(slv(N, XY))


if __name__ == '__main__':
    main()


Measured memory_bytes: 68272
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;

typedef enum { CARROT, DOWN, GOAL } Event;
struct event {
  int dist;
  Event ev;
  event(int d, Event e) : dist(d), ev(e) {}
  bool operator<(const event& that) const { return dist > that.dist; }
};

int main()
{
  int N, K, T, U, V, L;
  cin >> N >> K >> T >> U >> V >> L;
  priority_queue<event> q;
  q.push(event(L, GOAL));
  for (int i = 0; i < N; i++) {
    int d;
    cin >> d;
    q.push(event(d, CARROT));
  }

  bool running = false;
  int running_dist = 0;
  int prev = 0;
  int have = 0;
  int ignore = 0;
  bool goal = false;
  while (!q.empty() && !goal) {
    const Event ev = q.top().ev;
    const int dist = q.top().dist;
    q.pop();
    if (running) {
      running_dist += dist - prev;
    }
    switch (ev) {
      case CARROT:
        if (running) {
          if (have == K) {
            // over boost
            ++ignore;
            q.push(event(dist+V*T, DOWN));
          } else {
            ++have;
          }
        } else {
          q.push(event(dist+V*T, DOWN));
          running = true;
        }
        break;
      case DOWN:
        if (ignore > 0) {
          --ignore;
        } else {
          if (have > 0) {
            --have;
            q.push(event(dist+V*T, DOWN));
          } else {
            running = false;
          }
        }
        break;
      case GOAL:
        goal = true;
        break;
    }
    prev = dist;
  }

  printf("%.6f\n", running_dist/double(V) + (L-running_dist)/double(U));
  return 0;
}

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

copy_a = copy.deepcopy(a)
max_num = max(a)
a.remove(max_num)
second_num = max(a)

for i in range(n):
  if copy_a[i] >= max_num:
    print(second_num)
  else:
    print(max_num)
    

Measured memory_bytes: 14568
n,k=map(int,raw_input().split())
N=map(int,raw_input().split())
ans=0
for i in range(1,n):
    if N[i]+N[i-1]>k:
        ans+=min(N[i]+N[i-1]-k,N[i])
        N[i]-=min(N[i]+N[i-1]-k,N[i])
    if N[i]+N[i-1]>k:
        ans+=min(N[i]+N[i-1]-k,N[i-1])
        N[i-1]-=min(N[i]+N[i-1]-k,N[i-1])
print ans




Measured memory_bytes: 41708
import sys
import math
import itertools
import bisect
from copy import copy,deepcopy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(map(int,input().split()))
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
A = [i() for _ in range(N)]
C = Counter(A)
ans = 0
for c in C.values():
    if c%2 == 1:
        ans += 1
print(ans)

Measured memory_bytes: 99240