akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VV(T, a, b, c) vector<vector<T>>(a, vector<T>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define VVV(T, a, b, c, d)                                                     \
  vector<vector<vector<T>>>(a, vector<vector<T>>(b, vector<T>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, K;
  cin >> N >> K;

  vl A(N);
  REP(i, N) cin >> A[i];

  vl ADD(N + 1, 0);

  REP(k, K) {
    REP(i, N + 1) ADD[i] = 0;
    REP(i, N) {
      ADD[max(i - A[i], 0LL)]++;
      ADD[min(i + A[i] + 1, N)]--;
    }
    ll mi = llINF;
    ll now = 0;
    REP(i, N) {
      now += ADD[i];
      A[i] = now;
      mi = min(mi, A[i]);
    }
    if (mi >= N)
      break;
  }
  REP(i, N) cout << A[i] << " ";
  cout << endl;

  return 0;
}


Measured memory_bytes: 6332
#include<stdio.h>

int main(){
		int n,i,j,c=0,ans[75000][2];
		scanf("%d",&n);
		for(i=1;i<=n;i++){
				for(j=i+1;j<=n;j++){
						if(n%2==0){
								if(i+j!=n+1){
										ans[c][0]=i;
										ans[c][1]=j;
										c++;
								}
						}if(n%2==1){
								if(i+j!=n){
										ans[c][0]=i;
										ans[c][1]=j;
										c++;
								}
						}
				}
		}
		printf("%d\n",c);
		for(i=0;i<c;i++)printf("%d %d\n",ans[i][0],ans[i][1]);
		return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define clr(x) memset(x,-1,sizeof(x))
using namespace std;


int main()
{
    long long i,j,k,ans,tc,ca=1,x,a,b;
    cin>>a>>b>>x;
    a=a+b;
    if(x<=a)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;

}


Measured memory_bytes: 256
mod=10**9+7
n,m=map(int,input().split())
def fib_dynamic(n):
  cal_result={}
  
  cal_result[0]=1
  cal_result[1]=1
  
  if n==0 or n==1:
    return 1
  
  for i in range(2,n+1):
    cal_result[i]=cal_result[i-1]+cal_result[i-2]
    
  return cal_result[n]


if m==0:
  print(fib_dynamic(n)%mod)
  
else:
  ans=1
  ch=0
  for x in range(m):
    a=int(input())
    if a-ch==1 and ch!=0:
      ans=ans*0
      break
     
    
    if x==0:
      ans=ans*fib_dynamic(a-1)
      ch=a
    else:
      ans=ans*fib_dynamic((a-1)-ch-1)
      ch=a
      
    if x==m-1:
      ans=ans*fib_dynamic(n-a-1)
      
  print(ans%mod)
      
    
  

Measured memory_bytes: 473520
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>

using namespace std;

int main(){
	vector<int> vc;
	int n;

	while(cin >> n){
		vc.push_back(n);
	}

	sort(vc.begin(), vc.end(), greater<int>());

	for(int i = 0; i < 3; i++)
		cout << vc[i] << endl;
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pb push_back
#define ll long long
#define pi pair<int,ll>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int n,k;
double po(double x,int y)
{
    if(y==0)
        return 1;
    if(y&1)
        return x*(po(x,y-1));
    double t=po(x,y/2);
    return t*t;
}
int solve(int x,int y)
{
    int sum=0;
    while(x<y)
    {
        sum++;
        x+=x;
    }
    return sum;
}
int main()
{
    go;
    double ans=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        ans+=(1.0/n)*po(0.5,solve(i,k));
    cout<<fixed<<setprecision(10);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-5;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;

struct SegT {
private:
	int sz; vector<ll> node;
	const ll init_c = INF;
public:
	SegT(int n) {
		sz = 1;
		while (sz < n)sz *= 2;
		node.resize(2 * sz - 1, init_c);
	}
	ll f(ll a, ll b) {
		return min(a, b);
	}
	void update(int k, ll a) {
		k += sz - 1;
		node[k] = min(node[k],a);
		while (k > 0) {
			k = (k - 1) / 2;
			node[k] = f(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = sz;
		if (r <= a || b <= l)return init_c;
		else if (a <= l && r <= b)return node[k];
		else {
			ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return f(vl, vr);
		}
	}
};

void solve() {
	int n, m; cin >> n >> m;
	SegT st(n);
	vector<pair<P, ll>> v(m);
	rep(i, m) {
		cin >> v[i].first.first >> v[i].first.second >> v[i].second;
		v[i].first.first--;
		v[i].first.second--;
	}
	st.update(0, 0);
	//cout << st.query(0, 1) << endl;
	sort(v.begin(), v.end());
	rep(i, v.size()) {
		int l = v[i].first.first;
		int r = v[i].first.second;
		ll cost = v[i].second;
		ll z = st.query(l, r + 1);
		//cout << l << " " << r << " " << cost << " "<<z<<endl;
		st.update(r, z + cost);
	}
	ll ans = st.query(n - 1, n);
	if (ans >= INF)ans = -1;
	cout << ans << endl;
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	solve();
	//stop
		return 0;
}



Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int n, a[200005], b[200005], t[400005], u[400005];

int que(int l, int r) {
    int z = 890328;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
        if (l & 1) z = min(z, t[l++]);
        if (r & 1) z = min(z, t[--r]);
    }
    return z;
}

int que2(int l, int r) {
    int z = 890328;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
        if (l & 1) z = min(z, u[l++]);
        if (r & 1) z = min(z, u[--r]);
    }
    return z;
}

int main() {
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i], a[i]--, b[a[i]] = i;
    for (int i = 0; i < n; i++, i++) t[i + n] = a[i], u[i + n + 1] = a[i + 1], t[i + n + 1] = u[i + n] = 890328;
    for (int i = n - 1; i; i--) t[i] = min(t[i << 1], t[i << 1 | 1]), u[i] = min(u[i << 1], u[i << 1 | 1]);
    priority_queue<pair<pii, pii>, vector<pair<pii, pii>>, greater<pair<pii, pii>>> q;
    int x = que(0, n), y = que2(b[x], n);
    q.push({{x, y}, {0, n}});
    while (!q.empty()) {
        x = q.top().first.first, y = q.top().first.second;
        int l = q.top().second.first, r = q.top().second.second, u, v;
        q.pop();
        cout << x + 1 << ' ' << y + 1 << ' ';
        if (b[x] != l) {
            if (l & 1) u = que2(l, b[x]), v = que(b[u], b[x]);
            else u = que(l, b[x]), v = que2(b[u], b[x]);
            q.push({{u, v}, {l, b[x]}});
        }
        if (b[x] + 1 != b[y]) {
            if (b[x] & 1) u = que(b[x] + 1, b[y]), v = que2(b[u], b[y]);
            else u = que2(b[x] + 1, b[y]), v = que(b[u], b[y]);
            q.push({{u, v}, {b[x] + 1, b[y]}});
        }
        if (b[y] + 1 != r) {
            if (b[y] & 1) u = que(b[y] + 1, r), v = que2(b[u], r);
            else u = que2(b[y] + 1, r), v = que(b[u], r);
            q.push({{u, v}, {b[y] + 1, r}});
        }
    }
}


Measured memory_bytes: 7028
//--- pB ---//
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Scanner scanner;
	public Solution() {
		scanner = new Scanner(System.in);

		// scanner.nextLine();
		while (scanner.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		// scanner.nextLine();
		String line = scanner.nextLine();

		// int A = Integer.parseInt(line.split("\\s+")[0]);
		// int B = Integer.parseInt(line.split("\\s+")[1]);

		String a = line.split("\\s+")[0];
		String b = line.split("\\s+")[1];

		StringBuilder str_a = new StringBuilder();
		for (int i=0; i<Integer.parseInt(b); i++) {
			str_a.append(a);
		}

		StringBuilder str_b = new StringBuilder();
		for (int i=0; i<Integer.parseInt(a); i++) {
			str_b.append(b);
		}

		int res = str_a.toString().compareTo(str_b.toString());
		if (res < 0) {
			System.out.println(str_a);
		} else {
			System.out.println(str_b);
		}
	}

	private int[] strToIntArray(String str) {
	    String[] vals = str.split("\\s+");
	    int sz = vals.length;
	    int[] res = new int[sz];
	    for (int i=0; i<sz; i++) {
	        res[i] = Integer.parseInt(vals[i]);
	    }
	    return res;
	}

}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define numrep(i,p,n) for(int i=p;i<=n;i++)
#define ll int64_t
#define all(v) v.begin(), v.end()
#define bitrep(n) for(int bit=0;bit<(1<<n);bit++)

int main() {

  string S,T,U; cin >> S >> T;

  int A,B; cin >> A >> B >> U;

  if(S==U) cout << --A << ' ' << B << endl;
  else cout << A << ' ' << --B << endl;

  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20180502_pra
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var l = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();

            l.Sort();
            l.Reverse();

            var sum = 0;

            for (int i = 0; i < input[1]; i++)
            {
                sum += l[i];
            }

            Console.WriteLine(sum);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
int n, sum, a[25], b[25], c[25];
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n;
    for(int i = 1;i <= n;++i)
        cin >> a[i];
    for(int i = 1;i <= n;++i)
        cin >> b[i];
    for(int i = 2;i <= n;++i)
        cin >> c[i];
    for(int i = 1;i <= n;++i)
        sum += b[a[i]] + (i > 1 && a[i] == a[i - 1] + 1 ? c[a[i]] : 0);
    cout << sum;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;

void solve() {
	int n, a, b;
	cin >> n >> a >> b;
	int ans = 0;
	ans = (n * a) < b ? (n * a) : b;
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 256
n = gets.strip.to_i

arr = gets.strip.split(' ').map(&:to_i)
arr.length.times do |i|
  next if i == 0
  puts arr.join(' ')
  e = arr[i]
  j = i - 1
  while 0 <= j && e < arr[j]
    arr[j+1] = arr[j]
    arr[j] = e
    j -= 1
  end
end
puts arr.join(' ')

Measured memory_bytes: 8772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const int INF=1e+09;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    int minus=0;
    int A_min=INF;
    ll ans=0;
    rep(i,N){
        cin >> A[i];
        A_min = min(A_min,abs(A[i]));
        ans+=abs(A[i]);
        if(A[i]<0) minus++;
    }
    if(minus%2==1) ans-=((ll)A_min*2);

    cout << ans << endl;
    
}

Measured memory_bytes: 640
import sys
H, W, M = map(int, input().split())
hList = {i+1: 0 for i in range(H)}
wList = {i+1: 0 for i in range(W)}
pList = set()
#print(hList, wList, pList)
for _ in range(M):
  h, w = list(map(int, input().split()))
  #print(h, w)
  hList[h] += 1
  wList[w] += 1
  pList.add((h, w))
#print(hList, wList, pList)

maxHCount = max(hList.values())
maxHList = [h for h, count in hList.items() if count==maxHCount]


maxWCount = max(wList.values())
maxWList = [w for w, count in wList.items() if count==maxWCount]

#counterList = []
#for maxH in maxHList:
#  for maxW in maxWList:
#    counterList.append(hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0))
#print(max(counterList))
#print(max(((hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0)) for maxH in maxHList for maxW in maxWList)))
#print(max(((hList[maxH] + wList[maxW] - (1 if ((maxH, maxW) in pList) else 0)) for maxH in maxHList for maxW in maxWList)))

#if M < len(maxHList)*len(maxWList):
#	print(maxHCount + maxWCount)
#	sys.exit(0)

for maxH in maxHList:
  for maxW in maxWList:
    if (maxH, maxW) not in pList:
      print(maxHCount + maxWCount)
      sys.exit(0)

print(maxHCount + maxWCount - 1)


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

int main(){

  int n,w,h,s,t;
  int x,y;
  bool kaki[100][100];
  int sum;
  int max;

  while(cin >> n){
    if(n==0){ break; }
    cin >> w >> h;
    for(int i=0; i<w; i++){
      for(int j=0; j<h; j++){
        kaki[i][j]=false;
      }
    }

    for(int i=0; i<n; i++){
        cin >> x >> y;
        kaki[x-1][y-1]=true;
    }

    cin >> s >> t;

    max = 0;

    for(int i=0; i<=w-s; i++){
        for(int j=0; j<=h-t; j++){

            sum = 0;
            for(int k=0; k<s; k++){
                for(int l=0; l<t; l++){
                  if(kaki[i+k][j+l]==true)
                    sum++;
                }
            }

            if(sum > max)
              max = sum;

        }
    }

    cout << max << endl;

  }

  return 0;
}

Measured memory_bytes: 1164
def is_month(s):
    if s[0] == "1":
        if s[1] == "0" or s[1] == "1" or s[1] == "2":
            return True
    elif s[0] == "0":
        if s[1] == "0":
            return False
        else:
            return True
    return False


def is_year(s):
    return True


S = input()

s0 = S[:2]
s1 = S[2:]

is_mmyy = False
is_yymm = False
if is_month(s0) and is_year(s1):
    is_mmyy = True
if is_year(s0) and is_month(s1):
    is_yymm = True

if is_mmyy:
    if is_yymm:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if is_yymm:
        print("YYMM")
    else:
        print("NA")

Measured memory_bytes: 3064
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    s = str(input().rstrip('\n'))
    s = collections.Counter(s).most_common()
    t = 1
    for k, v in s:
        t = (t * (v + 1)) % (10 ** 9 + 7)
    print(t - 1)


if __name__ == '__main__':
    slove()


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

int main(){
    string X;
    cin >> X;
    int count = 0;
    size_t ans = X.size();
    for(int i = 0; i < X.size(); i++){
        if(X[i] == 'S'){
            count++;
        }else if(count > 0){
            count--;
            ans -= 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>

int main() {
	int m; std::cin >> m;
	for (auto i = 0; i < m; ++i) {
		std::vector<std::vector<int>> state(5, std::vector<int>(5)); for (auto& line : state) for (auto& cell : line) std::cin >> cell;
		int max = 0;
		for (auto lower = 0; lower < 5; ++lower) for (auto higher = lower; higher < 5; ++higher) {
			auto height = higher - lower + 1;
			for (auto left = 0; left < 5; ++left) for (auto right = left; right < 5; ++right) {
				auto width = right - left + 1;
				int count = 0;
				for (auto h = 0; h < height; ++h) for (auto w = 0; w < width; ++w) {
					if (state[lower + h][left + w] == 1) {
						++count;
					}
				}
				if (count == height * width) max = std::max(max, count);
			}
		}
		std::cout << max << std::endl;
	}
}



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

int main() {
	string s;
	int cnt[26] = {};
	while (cin >> s) {
		for (int i = 0; i < s.size(); i++) {
			if (isupper(s[i])) s[i] = tolower(s[i]);
			if (s[i] >= 'a' && s[i] <= 'z') {
				cnt[s[i] - 'a']++;
			}
		}
	}
	for (int i = 0; i < 26; i++)
		cout << (char)('a' + i) << " : " << cnt[i] << endl;
}


Measured memory_bytes: 3132
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		boolean[] primes = new boolean[50001];
		Arrays.fill(primes, true);

		for (int i = 2; i < 50001; i++) {
			if (primes[i]) {
				for (int j = 2; j <= 50000 / i; j++) {
					if (primes[i * j]) {
						primes[i * j] = false;
					}
				}
			}
		}

		while (!(line = br.readLine()).equals("0")) {

			int n = Integer.parseInt(line);
			int c = 0;

			for (int i = 2; i <= n / 2; i++) {
				if (primes[i] && primes[n - i]) {
					c++;
				}
			}
			System.out.println(c);
		}

	}

}

Measured memory_bytes: 25928
#include<iostream>
#include<algorithm>
#include<cstring>

using namespace std;

int main(void){
    static const int MAX = 200000;
    static const int INIT_PRICE = -2000000000;
    int p[MAX],n=0;
    memset(p,INIT_PRICE,sizeof(int)*MAX);
    cin>>n;
    for(int i=0;i<n;++i){
        cin>>p[i];
    }
    
    int maxv = INIT_PRICE;
    int minv = p[0];
    
    for(int i=1;i<n;++i){
        maxv = max(maxv, p[i]-minv);
        minv = min(minv, p[i]);
    }
    
    cout<<maxv<<endl;
    return 0;
}


Measured memory_bytes: 3884
//#pragma GCC optimize("-O3")
/*
				C++
				encoding: UTF-8
				Last Modified: 12/Apr/20 05:36:45 PM
*/

#include <bits/stdc++.h>
#ifdef H4wk3ye
#	include <prettypr.hpp>
#endif

using namespace std;

// clang-format off

#define		int                    long long
#define		ve                     vector
#define		pb                     push_back
#define		endl                   "\n"
#define		ff                     first
#define		ss                     second
#define		pii                    pair<int, int>
#define		len(v)                 (int)v.size()
#define		all(v)                 v.begin(), v.end()
#define		reset(a, b)            memset(a, b, sizeof(a));
#define		fr(i, s, n)            for (int i = s ; i < n ; ++i)
#define		dfr(i, s, n)           for (int i = s ; i > n ; --i)

template < typename T > void pr (const T& t) {
    cout << t << "\n";
}

template < typename T, typename U, typename... ARGS >
void pr (const T& t, const U& u, const ARGS&... args) {
    cout << t << " ";
    pr (u, args...);
}

// clang-format on


signed main () {
	ios_base::sync_with_stdio (false), cin.tie (nullptr);
	string s;
	cin >> s;
	bool flag = 0;
	fr (i, 0, 3) if (s[i] == '7') flag = 1;
	pr (flag ? "Yes" : "No");
	return 0;
}

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

int N, M;
int mod = 1e9 + 7;

int main() {
    cin >> N >> M;
    vector<int> A(N + 1), B(M + 1);
    for (int i = 1; i <= N; i++) {
        cin >> A[i];
    }
    for (int i = 1; i <= M; i++) {
        cin >> B[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    
    long long ans = 1;
    int i = N, j = M;
    for (int k = N * M; k > 0; k--) {
        if(A[i] == k + 1 || B[j] == k + 1) {
            ans = 0;
            break;
        }
        
        if (A[i] == k && B[j] == k) {
            i--;
            j--;
            continue;
        } else if (A[i] == k) {
            ans *= M - j;
            i--;
        } else if (B[j] == k) {
            ans *= N - i;
            j--;
        }  else {
            ans *= (N - i) * (M - j) - (N * M - k);
        }
        ans %= mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < 19; i++) {
    if (s[i] == ',') {
      cout << ' ';
    } else {
      cout << s[i];
    }
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3020
def roll(die, d):
    if d == "E":
        return [die[3], die[1], die[0], die[5], die[4], die[2]]
    if d == "N":
        return [die[1], die[5], die[2], die[3], die[0], die[4]]
    if d == "S":
        return [die[4], die[0], die[2], die[3], die[5], die[1]]
    if d == "W":
        return [die[2], die[1], die[5], die[0], die[4], die[3]]
    if d == "L":
        return [die[0], die[3], die[1], die[4], die[2], die[5]]
    if d == "R":
        return [die[0], die[2], die[4], die[1], die[3], die[5]]

def checkdice(die1, die2):
    ans = False
    for d in "RRRNRRRNRRRSRRRSRRRNRRRR":
        if die1 == die2:
            ans = True
            break
        die2 = roll(die2, d)
    return ans

dice = []
msg = "Yes"
n = int(input())
for _ in range(n):
    dice.append(list(map(int, input().split())))
for i in range(n):
    for j in range(i + 1, n):
        if checkdice(dice[i], dice[j]):
            msg = "No"
            break
    if msg == "No":
        break
print(msg)

Measured memory_bytes: 7832
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;

const ll INF = 1LL << 60;

void chmin(ll &a, ll b) {
  a = min(a, b);
}

int main() {
  int N, M, L, S, T;
  while(1) {
    scanf("%d%d%d%d%d", &N, &M, &L, &S, &T);
    if(N == 0) break;
    
    S--;
    vector<ll> siro(L), time(L);
    vector< vector<ll> > dist(N, vector<ll>(N, INF)), dp(1<<L, vector<ll>(L, INF));

    for(int i=0; i<N; i++) {
      dist[i][i] = 0;
    }

    for(int i=0; i<M; i++) {
      int a, b, c; scanf("%d%d%d", &a, &b, &c);
      a--; b--;
      chmin(dist[a][b], c);
      chmin(dist[b][a], c);
    }
    for(int i=0; i<L; i++) {
      scanf("%lld%lld", &siro[i], &time[i]);
      siro[i]--;
    }

    for(int k=0; k<N; k++) {
      for(int i=0; i<N; i++) {
        for(int j=0; j<N; j++) {
          chmin(dist[i][j], dist[i][k] + dist[k][j]);
        }
      }
    }

    dp[0][0] = 0;
    for(int bit=0; bit<(1<<L); bit++) {
      for(int k=0; k<L; k++) {
        for(int i=0; i<L; i++) {
          if(bit >> i & 1) continue;

          int nbit = bit | (1 << i);
          
          int u = (bit == 0 ? S : siro[k]);
          int v = siro[i];
          ll cost = dist[u][v] + time[i];

          // printf("u = %d, v = %d, cost = %lld\n", u+1, v+1, cost);
          chmin(dp[nbit][i], dp[bit][k] + cost);
        }
      }
    }

    ll ans = 0;
    for(int bit=0; bit<(1<<L); bit++) {
      for(int k=0; k<L; k++) {
        ll cost = dp[bit][k] + dist[ siro[k] ][S];
        // printf("bit = %d, k = %d, cost = %lld\n", bit, k, cost);
        if(cost > T) continue;
        ans = max(ans, (ll)__builtin_popcount(bit));
      }
    }

    printf("%lld\n", ans);
  }

  return 0;
}



Measured memory_bytes: 13860
#include <iostream>
#include <algorithm>
#include <cmath>
#define MAX 100010
#define VMAX 200000000000LL

using namespace std;
typedef long long ll;

ll n,dmin,ans;
ll a[MAX];

int main()
{
    cin>>n; for(ll i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+n+1);
    cout<<a[n]<<" ";
    dmin=VMAX;
    for(ll i=1;i<n;i++){
      if(abs(a[n]/2+a[n]%2-a[i])<dmin){
        dmin=a[n]/2+1-a[i];
        ans=a[i];
      }
    }
    cout<<ans<<'\n';
    return 0;
}


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

using bellman_cost = int;
template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

template<class T>
struct Vertex_Cost
{
	T cost;
	bool valid = false;
	Vertex_Cost(T v1) : cost(v1) {}
	Vertex_Cost() {}
};
using vertex = Vertex_Cost<bellman_cost>;

template<class T>
struct Edge_Cost
{
	int to;
	T cost;
	Edge_Cost(int t, T c) : to(t), cost(c) {}
	Edge_Cost() {}
};
using edge = Edge_Cost<bellman_cost>;
using graph = Graph<vertex, edge>;

template<class T, class V, class E>
void Bellmanford(Graph<V, E>& G, int s, T INF_COST)
{
	auto &v = G.v;
	auto &e = G.e;
	for (auto& vv : v) vv.cost = INF_COST;
	v[s].cost = 0;
	v[s].valid = true;
	for (int i = 0; i + 1 < (int) v.size(); i++) {
		for (int j = 0; j < (int) v.size(); j++) {
			for (auto& x: e[j]) {
				if (v[j].cost == INF_COST) continue;
				v[x.to].cost = min(v[x.to].cost, v[j].cost + x.cost);
				v[x.to].valid = true;
			}
		}
	}
	stack<int> not_valid;
	for (int i = 0; i < (int) v.size(); i++) {
		for (auto& x: e[i]) {
			if (v[i].cost == INF_COST) continue;
			if (v[x.to].cost > v[i].cost + x.cost) {
				v[x.to].valid = false;
				not_valid.push(x.to);
			}
		}
	}
	while (!not_valid.empty()) {
		int pos = not_valid.top();
		not_valid.pop();
		for (auto& x: e[pos]) {
			if (v[x.to].valid) {
				v[x.to].valid = false;
				not_valid.push(x.to);
			}
		}
	}
}


void solve(long long N, long long M, long long P, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C) {
	graph g(N);
	for (int i = 0; i < M; i++) {
		g.add_edge(A[i]-1, B[i]-1, -(C[i] - P));
	}
	Bellmanford(g, 0, INT_MAX);
	if (!g.v[N-1].valid) cout << -1 << endl;
	else cout << max(-g.v[N-1].cost , 0) << endl;
}

signed main() {
	long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	long long P;
	scanf("%lld",&P);
	std::vector<long long> A(M);
	std::vector<long long> B(M);
	std::vector<long long> C(M);
	for(int i = 0 ; i < M ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
		scanf("%lld",&C[i]);
	}
	solve(N, M, P, std::move(A), std::move(B), std::move(C));
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	char  data1[4], data2[4];
    int   ret_scanf;

    // フォーマットに従って標準入力から入力
    ret_scanf = scanf("%s", &data1[0]);
    ret_scanf = scanf("%s", &data2[0]);
    
    int count;
    count = 0;
    for (int i = 0; i < 3; i++) {
    	if (data1[i] == data2[i]) { 
    		count = count + 1;
    	}
    }
    printf("%d", count);
    return 0;
}

Measured memory_bytes: 128
//
// Created by 李青坪 on 2018/10/5.
//


#include <cstdio>
#include <set>
#include "cstring"

using namespace std;

int main(){
    int n, q;
    int S[10000];
    int T[500];
    memset(S, -1, sizeof(S));
    memset(T, -1, sizeof(T));
    scanf("%d", &n);
    for (int k = 0; k < n; ++k) {
        scanf("%d", &S[k]);
    }
    scanf("%d", &q);
    for (int l = 0; l < q; ++l) {
        scanf("%d", &T[l]);
    }
    set<int > flag;
    for (int j = 0; j < 10000; ++j) {
        if (S[j] < 0) break;
        flag.insert(S[j]);
    }
    int count = 0;
    for (int i = 0; i < 500; ++i) {
        if (T[i] < 0) break;
        if (flag.find(T[i]) != flag.end()) ++count;
    }
    printf("%d\n", count);
}


Measured memory_bytes: 2864
#include<bits/stdc++.h>
#define mk make_pair
using namespace std;
const int N=1010;
const int mod=1e9+7;
typedef long long ll;
void test(){
    printf("  ***////   \n");
}
int main() {
    int n;
    scanf("%d",&n);
    printf("%d\n",n/2+(n%2?0:-1));
    return 0;
}
/*
3
8 5
11011010
7 9
1111100
7 10
1111100

*/


Measured memory_bytes: 256
s = input()
a,f = "AKIHABARA",1
while len(s)<9 and f:
	for i in range(len(s)):
		if a[i]!=s[i]:
			s = s[:i]+"A"+s[i:]
			break
		elif i==len(s)-1 and a[:i+1]==s: s+="A"
		elif i==len(s)-1: f = 0
if s==a: print("YES")
else: print("NO")

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <utility>
#include <algorithm>
using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    int n;
	string s;
	cin>>n>>s;
	if(n%2!=0)
    {
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=0;i<n/2;i++)
    {
		if(s[i]!=s[i+n/2])
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define M 5005
#define mod 1000000007
int n,D[M];
long long fac[M],inv[M],fac_inv[M],F[M][M][2],ans;
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=ans*10+c-'0',c=getchar();
	return ans;
}
void Write(long long x){
	if (x<10) putchar(x^48);
	else Write(x/10),putchar((x%10)^48);
	return;
}
int main(){
	n=read();bool flag=1;fac[0]=fac[1]=inv[1]=fac_inv[0]=fac_inv[1]=1;
	for (register int i=2;i<=n;i++)
		fac[i]=fac[i-1]*i%mod,inv[i]=(mod-mod/i)*inv[mod%i]%mod,fac_inv[i]=fac_inv[i-1]*inv[i]%mod;
	for (register int i=1;i<=n;i++) D[i]=read(),flag&=(D[i]==2);
	if (flag){Write(fac[n-1]*inv[2]%mod);return 0;}
	F[0][0][0]=1;
	for (register int i=0;i<n;i++)
		for (register int j=0;j<=i;j++)
			for (register int k=0;k<2;k++){
				if (D[i+1]>0) F[i+1][j][k]=(F[i+1][j][k]+F[i][j][k]*fac_inv[D[i+1]-1])%mod;
				if (D[i+1]>1) F[i+1][j+1][k]=(F[i+1][j+1][k]+F[i][j][k]*fac_inv[D[i+1]-2])%mod;
				if (D[i+1]>2&&!k) F[i+1][j+1][1]=(F[i+1][j+1][1]+F[i][j][k]*fac_inv[D[i+1]-3])%mod;
			}
	for (register int i=3;i<n;i++) ans=(ans+F[n][i][1]*fac[n-i-1]%mod*fac[i-1]%mod*inv[2])%mod;
	Write(ans);
	return 0;
}


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

int main(){
	int H,W;
	while(1){
		cin>>H>>W;
		if(H==0&&W==0)break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(i==0||i==H-1){
					cout<<"#";
				}else{
					if(j==0||j==W-1){
						cout<<"#";
					}else{
						cout<<".";
					}
				}
			}
				cout<<endl;
		}
		cout<<endl;
	}
	return 0;
}

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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 2097162
#define inf 1e9
#define MOD 1000000007

int main()
{

    ll n, m, ans = 0;
    cin >> n >> m;
    ll mx = 100000;
    ll mn = 0;
    for(ll i = 0; i < m; i++)
    {

        ll x, y;
        cin >> x >> y;
        if(x > mn) mn = x;
        if(y < mx) mx = y;
    }
    if(mx < mn) cout << 0;
    else cout << mx-mn+1;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>

using namespace std;

typedef complex<double> Point;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, PP> PPP;
typedef pair<double, Point> P2;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF= 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;

double dis(Point p1, Point p2){
	return sqrt((p1.real() - p2.real())*(p1.real()-p2.real()) + (p1.imag() - p2.imag())*(p1.imag() - p2.imag()));
}

int main(){
	int n;
	while(cin >> n && n){
		map<int, vector<P> > mp;
		for(int i = 0; i < n; i++){
			
			char c;
			cin >> c;
			int id, num;
			if(c == 'R'){
				cin >> num;
				bool ok = false;
				for(map<int, vector<P> >::iterator iter = mp.begin(); iter != mp.end(); iter++){
					for(int j = 0; j < (int)(*iter).second.size(); j++){
						if((*iter).second[j].first <= num && num < (*iter).second[j].second){
							cout << (*iter).first << endl;
							ok = true;
							break;
						}
					}
					if(ok) break;
				}
				if(!ok) cout << -1 << endl;
			}else if(c == 'D'){
				cin >> id;
				mp[id].clear();
			}else{
				cin >> id >> num;
				vector<P> vp;
				for(map<int, vector<P> >::iterator iter = mp.begin(); iter != mp.end(); iter++){
					for(int i = 0; i < (int)(*iter).second.size(); i++){
						vp.push_back((*iter).second[i]);
					}
				}
				vp.push_back(P(0, 0));
				sort(vp.begin(), vp.end());
				vp.push_back(P(1000000001, 1000000001));
				for(int j = 0; j < (int)vp.size() - 1; j++){
					
					if(vp[j].second < vp[j+1].first){
						if(num >= vp[j+1].first - vp[j].second){
							num-=vp[j+1].first - vp[j].second;
							mp[id].push_back(P(vp[j].second, vp[j+1].first));
						}else{
							if(num > 0){
								mp[id].push_back(P(vp[j].second, vp[j].second + num));
								num = 0;
							}
						}
						if(num == 0) break;
					}
				}
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 17000
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

ll factrial_mod(ll x){
	ll ans = 1LL;
	for(ll i = 2; i<=x; ++i){
		ans *= i;
		ans %= MOD;
	}
	return ans;
}

int main(){
	ll N,M;
	cin>>N>>M;
	if(abs(N-M)>1LL){cout<<0<<endl; return 0;}
	ll ans = factrial_mod(N);
	ans *= factrial_mod(M);
	ans %= MOD;
	if(N==M)ans *= 2LL;
	ans %= MOD;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<set>
#include<cmath>
#include<cstdio> 
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

set<string> q;

int main()
{
	string a;
	int k;
	cin>>a>>k;
	for(int i=0;i<a.size();++i)
	{
  		string tmp="";
  		for (int j=i;j<a.size();++j)
		{
    		tmp.push_back(a[j]);
    		q.insert(tmp);
    		if (q.size()>k)
			{
				q.erase(--q.end());
			} 
    	} 
  	}
	cout<<*q.rbegin();
}


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

int main(){
    int s; cin >> s;
    map<int,int> num;
    int i=1;
    for(;;){
        if(num[s]){
            cout << i << endl;
            return 0;
        }
        num[s]++;
        if(s%2==0) s/=2;
        else s=s*3+1;
        i++;
    }
return 0;
}


Measured memory_bytes: 256
// Enjoy your stay. Code by evima on 2018/06/10

#include <iostream>
using namespace std;

int memo[100010];

int f(int n){
    int& ret = memo[n];
    if(ret != -1) return ret;
    if(n == 0) return 0;
    ret = 1e9;
    for(int b: {6, 9}){
        for(int x = 1; x <= n; x *= b){
            ret = min(ret, 1 + f(n - x));
        }
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    fill(memo, memo+N+1, -1);
    cout << f(N) << endl;
}


Measured memory_bytes: 3712
#include<stdio.h>
#include<string.h>
int main(void){
    int i,j,k;
    char input[100],cpyinput[100],key[3][5]={"the","this","that"};
    while(gets(input)!=NULL){
        for(i=0;i<26;i++){
            for(j=0;j<strlen(input);j++){
                if('a'<=input[j] && input[j]<='z'){
                    input[j]+=1;
                    if(input[j]>'z')
                        input[j]-=26;
                }
                //printf("%c",input[j]);
            }
            //puts("");
            //printf("%s\n",input);
            //puts("test");
            for(j=0;j<3;j++){
                if(strstr(input,key[j])!=NULL){
                    //printf("test");
                    goto next;
                }
            }
        }
        next:
        printf("%s\n",input);
    }
    return 0;
}

Measured memory_bytes: 928
//2018.09.21 4min

#include <iostream>
using namespace std;

int main() {

    int n,k;
    cin >> n >>k;
    int a[n];
    int i;

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

    int ans;
    int diff = k-1;

    if(n==k) ans = 1;
    else{
        int n_after1 = n-k;
        if(n_after1%diff==0) ans = n_after1/diff+1;
        else ans = n_after1/diff + 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

ll D, c[33], s[444][33], t[444], last[33] = {};
set<ll> s1[33], s2[33];

// vector<ll> score(ll t[]) {
//     ll i, j, sc = 0;
//     vector<ll> v;
//     v.pb(0);
//     for (i = 1; i <= D; i++){
//         sc += s[i][t[i]];
//         last[t[i]] = i;
//         for (j = 1; j <= 26;j++)
//             sc -= c[j] * (i - last[j]);
//         v.pb(sc);
//     }
//     return v;
// }

ll cost(ll k, ll dis){
    return k * dis * (dis - 1) / 2;
}

ll eval(ll d, ll q){
    ll bq = t[d];
    ll b = *s1[bq].upper_bound(d);
    ll a = *s2[bq].upper_bound(-d);
    ll sc = 0;
    sc -= s[d][bq];
    sc += s[d][q];
    ll l = d + a, r = b - d;
    sc += cost(c[bq], l);
    sc += cost(c[bq], r);
    sc -= cost(c[bq], l + r);
    b = *s1[q].upper_bound(d);
    a = *s2[q].upper_bound(-d);
    l = d + a, r = b - d;
    sc -= cost(c[q], l);
    sc -= cost(c[q], r);
    sc += cost(c[q], l + r);
    return sc;
}

int main(){
    ll i, j;
    cin >> D;
    for (i = 1; i <= 26;i++)
        cin >> c[i];
    for (i = 1; i <= D;i++)
        for (j = 1; j <= 26;j++)
            cin >> s[i][j];
    for (i = 1; i <= 26; i++){
        s1[i].insert(D + 1);
        s2[i].insert(0);
    }
    for (i = 1; i <= D;i++){
        ll ma = -1e15, p;
        for (j = 1; j <= 26; j++){
            if(c[j]*(i-last[j])+s[i][j]>ma){
                ma = c[j] * (i - last[j]) + s[i][j];
                p = j;
            }
        }
        t[i] = p;
        last[p] = i;
    }
    for (i = 1; i <= D;i++){
        s1[t[i]].insert(i);
        s2[t[i]].insert(-i);
    }
    random_device rnd;
    mt19937 mt(rnd());
    uniform_int_distribution<> rand365(1, 365);
    ll Q = -1e18;
    for (i = 0; i < 100000; i++){
        ll ma = -1e15, p;
        ll d = rand365(mt);
        for (j = 1; j <= 26; j++){
            if(j!=t[d]){
                ll sc = eval(d, j);
                if(sc > ma){
                    ma = sc;
                    p = j;
                }
            }
        }
        if(ma > Q){
            s1[t[d]].erase(d);
            s2[t[d]].erase(-d);
            s1[p].insert(d);
            s2[p].insert(-d);
            t[d] = p;
        }
        Q /= 10;
        Q *= 9;
    }
    for (i = 1; i <= D;i++)
        cout << t[i] << endl;
}

Measured memory_bytes: 3780
loop {
    n = gets.to_i
    break if n == 0
    gets
    str = gets.chomp
    chunks = str.scan(/((IO)+I)/).map{|s, _| (s.size - 1) / 2}
    count = 0
    chunks.each{|c|
        count += c - n + 1 if c >= n
    }
    p count
}

Measured memory_bytes: 10284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
const int N=100001;
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll n,a[N],k,ans=0;
	cin >> n;
	CLR(a);
	for(ll i=0;i<n;i++){
		cin >> k;
		if(k>=N){
			ans++;
		}else{
			a[k]++;
		}
	}
	for(ll i=0;i<N;i++){
		if(a[i]>i){
			ans += a[i]-i;
		}else if(a[i]<i){
			ans += a[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
fn main() {
    let (n, a, b): (i32, i32, i32) = readln();
    let d = (b - a).abs();
    let ans = if d % 2 == 1 {
        "Borys"
    } else {
        "Alice"
    };
    println!("{}", ans);
}

// --- template ---
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashSet;

pub trait FromLn {
    fn fromln(s: &str) -> Self;
}
pub fn readln<T: FromLn>() -> T {
    let mut buf = String::new();
    let _ = ::std::io::stdin().read_line(&mut buf).unwrap();
    T::fromln(buf.trim())
}
pub fn readlns<T: FromLn>(n: usize) -> Vec<T> {
    let mut vs = vec![];
    for _ in 0..n { vs.push(readln()); }
    vs
}
macro_rules! fromln_primitives {
    ($($t:ty),*) => { $(
        impl FromLn for $t {
            fn fromln(s: &str) -> $t {
                s.parse().unwrap()
            }
        }
    )* }
}
fromln_primitives!(String, bool, f32, f64, isize, i8, i16, i32, i64, usize, u8, u16, u32, u64);
impl<T> FromLn for Vec<T> where T: FromLn {
    fn fromln(s: &str) -> Vec<T> {
        s.split_whitespace().map(T::fromln).collect()
    }
}
impl FromLn for Vec<char> {
    fn fromln(s: &str) -> Vec<char> {
        s.chars().collect()
    }
}
macro_rules! fromln_tuple {
    ($($t:ident),*) => {
        impl<$($t),*> FromLn for ($($t),*) where $($t: FromLn),* {
            fn fromln(s: &str) -> ($($t),*) {
                let mut it = s.split_whitespace();
                let t = ($($t::fromln(it.next().unwrap())),*);
                assert_eq!(it.next(), None);
                t
            }
        }
    }
}
fromln_tuple!(A, B);
fromln_tuple!(A, B, C);
fromln_tuple!(A, B, C, D);
fromln_tuple!(A, B, C, D, E);
fromln_tuple!(A, B, C, D, E, F);


Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = Eratos(1000000);
		int q = sc.nextInt();
		for (int i = 1; i <= q; i++) {
			int l = sc.nextInt();
			int r = sc.nextInt();
			int anss, ansg;
			anss = 1;
			ansg = 2;
			for (int o = 1; o <= a.length; o++) {
				if (a[o] < l && l <= a[o + 1]) {
					anss = o + 1;
				}
				if (a[o] <= r && r < a[o + 1]) {
					ansg = o;
					break;
				}
			}
			System.out.println(ansg - anss + 1);
		}

	}

	static public int[] Eratos(int n) {

		int num[] = new int[n + 1];
		Arrays.fill(num, 0);

		ArrayList<Integer> sosu = new ArrayList<Integer>();
		for (int i = 2; i <= n; i++) {
			if (num[i] == 0) {
				for (int j = i + i; j <= n; j = j + i) {
					if (j % i == 0) {
						num[j] = 1;
					}
				}
			}
		}

		for (int i = 1; i <= n; i++) {
			if (num[i] == 0 && num[(i + 1) / 2] == 0 && i != 2) {
				sosu.add(i);
			}
		}

		int[] so = new int[sosu.size()];

		for (int i = 0; i < sosu.size(); i++) {
			so[i] = sosu.get(i);
		}

		return so;
	}

}

Measured memory_bytes: 46436
N, M = map(int, input().split())

l = [list(input().split()) for _ in range(M)]

answers = {}
wrongs = {}

for a in l:
    if a[1] == "AC":
        answers[a[0]] = a[1]
    elif a[1] == "WA":
        # 正解後は数えない
        if not a[0] in answers and not a[0] in wrongs:
            wrongs[a[0]] = 1
        elif not a[0] in answers and a[0] in wrongs:
            wrongs[a[0]] = wrongs[a[0]] + 1

# 集計
wc = 0
for k, v in wrongs.items():
    if k in answers.keys():
        wc += v
result = [len(answers.keys()), wc]

print(result[0], result[1])



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

lll gcd(lll a,lll b,lll&x,lll&y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return(x%m+m)%m;}
ll modPow(lll a,lll n,ll m){lll p=1;for(;n;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return p;}
//V<ll>F,R;void setF(int n,int mod){F=R=V<ll>(++n);F[0]=1;FOR(i,1,n)F[i]=F[i-1]*i%mod;R[n-1]=modInv(F[n-1],mod);FORR(i,n-1,1)R[i-1]=R[i]*i%mod;}
//ll comb(int a,int b,int m){return a<b||b<0?0:F[a]*R[b]%m*R[a-b]%m;}

const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7; //998244353;
const int N = 50;
const int M = 1<<20;
int n, m;
ll DP[M];
V<int> v[N][N], e[N];
bool dfs(int a, int p, int t, int k){
  if(a==t) return true;
  for(int b:e[a]) if(p!=b) if(dfs(b, a, t, k)) return v[a][b].pb(k), v[b][a].pb(k), true;
  return false;
}
void dfs2(int a, int p){
  if(p>=0){
    int z = 0;
    for(int c:v[a][p]) z |= 1<<c;
    FORR(i, (1<<m)-1, 0) DP[i|z] += DP[i];
  }
  for(int b:e[a]) if(p!=b) dfs2(b, a);
}
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n;
  FOR(i, 0, n-1){
    int a, b;
    cin >> a >> b;
    a--; b--;
    e[a].pb(b);
    e[b].pb(a);
  }
  cin >> m;
  FOR(i, 0, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    dfs(a, -1, b, i);
  }
  DP[0] = 1;
  dfs2(0, -1);
  cout << DP[(1<<m)-1] << endl;
}

Measured memory_bytes: 8576