akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#define ll long long
#include <unordered_map>
using namespace std;
 
int main() {
  ll N, ma =  0;
  cin >> N;
  string s;
  unordered_map<string, int> mp;
  vector<string> ans;
  for(ll i = 0; i < N; i++) {
    cin >> s;
    mp[s]++;
    if(mp[s] >= ma) ma = mp[s];
  }
  for(auto& p : mp) {    
    if(p.second == ma) ans.push_back(p.first);
  }
  sort(ans.begin(), ans.end());
  for(ll i = 0; i < ans.size(); i++) cout << ans.at(i) << endl;
}

Measured memory_bytes: 27072
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(x) cout << x << endl
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define pb emplace_back
#define vii vector<int>
#define vll vector<ll>
#define vpll vector< pair <ll,ll> >
#define pll pair <ll,ll>
#define pii pair <int,int>
#define pq priority_queue< int >
#define khtm "\n"
#define F first
#define S second
#define fr(i,a,n) for(i=a;i<n;i++)
#define mem(arr,l) memset(arr,l,sizeof arr)
#define ALL(x) x.begin(), x.end()
#define frr(i,a,n) for(i=n-1;i>=a;i--)
#define mod 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase ll T; cin>>T; while(T--)
const int MAX = 1e6 +2;
const int inf = (int) 1e9;
const int N = 1010;
/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,l,m,r,n;
//ll dp[2002][2002];
ll a[MAX];
ll dp[MAX][3];
ll vis[MAX][3];

ll solve(ll pos, ll rem)
{
	if(pos > n)
		return 0 ;
	ll &ret = dp[pos][rem];
	if(vis[pos][rem])
		return ret;
	vis[pos][rem] = 1;
	if(!rem)
		ret = a[pos] + solve(pos+2,rem);
	else
		ret = max(a[pos] + solve(pos+2,rem) , solve(pos+1 , rem-1));
	return ret;
}

int main()
{
 
  #ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//cout << setprecision(15) << fixed;
fast

cin >> n >> m;
ll sum = 0;
fr(i,0,m)
{
	ll tmp;
	cin >> tmp;
	sum +=tmp;
}

cout << ( n >= sum ? n-sum: -1);

  #ifndef ONLINE_JUDGE
  cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  #endif
 
  return 0;
 
}

Measured memory_bytes: 3700
#単体変更, 区間取得

class RMQ:
    #INF = int(1e18)
    INF = int((1<<31)-1)
    n = 0
    n_ = 0
    val = []
    def __init__(self, n_):
        n = 1
        while n < n_:
            n = n * 2
        self.n = n
        self.n_ = n_
        self.val = [self.INF] * (2 * n - 1)

    @staticmethod
    def merge(a, b):
        return min(a, b)
        
    def update(self,k, x):
        k = k + self.n - 1
        self.val[k] = x
        while k:
            k = (k-1)//2
            self.val[k] = self.merge(self.val[k*2+1], self.val[k*2+2])

    def dfs(self, a, b, k, l, r):
        if r <= a or b <= l:
            return self.INF
        if a <= l and r <= b:
            return self.val[k]
        vl = self.dfs(a, b, k * 2 + 1, l, (l+r)//2)
        vr = self.dfs(a, b, k * 2 + 2, (l+r)//2, r)
        return self.merge(vl, vr)
    

    def query(self, a, b):
        return self.dfs(a, b, 0, 0, self.n)

    
n, q = list(map(int, input().split()))
rmq = RMQ(n)

while q:
    q = q - 1
    com, x, y = list(map(int, input().split()))
    if com == 0:
        rmq.update(x, y)
    else:
        print (rmq.query(x, y + 1))



Measured memory_bytes: 8696
a,b = map(int, input().split())
ans = 0
if a>b:
    ans+=a
    if a-1>b:
        ans += a-1
    else:
        ans += b
else:
    ans += b
    if b-1>a:
        ans += b-1
    else:
        ans +=a
print(ans)

Measured memory_bytes: 3060
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
satisfaction = 0
for i in range(n):
    b_number = a[i]
    satisfaction += b[b_number - 1]
    if i == 0:
        j = i
    else:
        if a[i] == a[j] + 1:
            c_number = a[j]
            satisfaction += c[c_number - 1]
        j = i
print(satisfaction)


Measured memory_bytes: 3064
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Fri Mar  1 19:29:34 2019

@author: nakamuratakayuki
"""
N = int(input())
S = []
for i in range(N):
    S.append(input())

m = 0
f = 0
b = 0
t = 0
for s in S:
    if s.startswith('B'):
        m += 1
    if s.endswith('A'):
        f += 1
    if s.startswith('B')*s.endswith('A'):
        m -= 1
        f -= 1
        b += 1
    t += s.count('AB')
if f == 0 and m == 0:
    b -= 1
ans = min(f,m)+max(b,0)+t

print(max(ans,0))

Measured memory_bytes: 3700
N = int(input())
XYList = []
for i in range(N):
    A = int(input())
    XY = []
    for j in range(A):
        XY.append(list(map(int, input().split())))
    XYList.append(XY)
maxSum = 0
for i in range(2**N):
    sum = 0
    for j in range(N):
        if i >> j & 1:
            honest = True
            for XY in XYList[j]:
                if ((i >> (XY[0]-1)) & 1) != XY[1]:
                    honest = False
                    break
            if honest:
                sum += 1
            else:
                sum = 0
                break
    if maxSum < sum:
        maxSum = sum
print(maxSum)

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

int main(){
  int N;
  long long A, B;
  cin >> N >> A >> B;
  vector<long long> X(N);
  for(int i=0; i<N; i++) cin >> X.at(i);
  long long ans=0;
  for(int i=0; i<N-1; i++){
    ans+=min((X.at(i+1)-X.at(i))*A, B);
  }
  cout << ans << endl;
}

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

//Coding below.
int main (){
    int r,D,x,next;
    cin >> r >> D >> x;
    next = x;
    for( int i = 0; i < 10; i = i+1){
        next = (next * r) - D; 
        cout << next << endl;
    }
}

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

typedef long long ll;

using namespace std;
ll mod = 1000000007;
int n, m;

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;

    if (a <= 5) {
        cout<< 0;
    } else if (a <= 12) {
        cout << b/2;
    } else {
        cout << b;
    }
    return 0;
}


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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

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

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

	int reds = 0;
	for(char c: s){
		if(c == 'R') ++reds;
	}

	int ans = 0;
	for(int i = 0; i<reds; ++i)
		if(s[i] == 'W') ++ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3752
fun main(args:Array<String>) {
    val n = readLine()!!.toInt()
    val monsterList = readLine()!!.split(" ").map { it.toLong() }.toMutableList()
    val yusha = readLine()!!.split(" ").map { it.toLong() }
    var ans = 0L
    for(i in (0 until n)) {
        var minus = Math.min(yusha[i], monsterList[i])
        ans += minus
        if(minus < yusha[i]) {
            minus = yusha[i] - minus
            minus = Math.min(minus, monsterList[i+1])
            ans += minus
            monsterList[i+1] -= minus
        }
    }
    println(ans)
}


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

int main() {
  int a,b=0;
  cin >> a;
  for(int i=0;i<26;i++){
    for(int j=0;j<15;j++){
      if(i*4 + j*7 == a){
        b++;
      }
    }
  }
 if(b ==0){
 cout << "No" << endl;
 }
 else{
 cout << "Yes" << endl;
 }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
using ll = int64_t;
#define rep(i, j, n) for (int i = j; i < (int)n; ++i)

ll dp[3003][3003][4];
ll gs[3003][3003];
int main() {
  int r, c, k, y, x, v;
  cin >> r >> c >> k;

  rep(i, 0, k) {
    cin >> y >> x >> v;
    --y, --x;
    gs[y][x] = v;
  }

  rep(i, 0, r) rep(j, 0, c) rep(a, 0, 4) {
    // 拾って右、拾ってした、拾わないで右、拾ってした
    if (a + 1 < 4) {
      dp[i][j + 1][a + 1] = max(dp[i][j + 1][a + 1], dp[i][j][a] + gs[i][j]);
      dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][a] + gs[i][j]);
    }
    dp[i][j + 1][a] = max(dp[i][j + 1][a], dp[i][j][a]);
    dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][a]);
  }

  ll ans = 0;
  rep(a, 0, 4) {
    if (a + 1 < 4)
      ans = max(ans, dp[r - 1][c - 1][a] + gs[r - 1][c - 1]);
    else
      ans = max(ans, dp[r - 1][c - 1][a]);
  }
  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 355288
package main

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

type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func main() {
	sc := NewScanner()
	A, B := sc.nextInt(), sc.nextInt()
	count := 0
	c := 1
	for {
		if c >= B {
			break
		}
		c = c - 1 + A
		count++
	}
	fmt.Println(count)
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e9;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vector<vector<ll>> dp(20,vector<ll>(10,0));
    rep(i,10) dp[1][i] = 1;
    rep(i,1,19){
        rep(j,10){
            if (j == 0){
                dp[i+1][1] += dp[i][0];
            }
            else if (j == 9){
                dp[i+1][8] += dp[i][9];
            }
            else{
                dp[i+1][j+1] += dp[i][j];
                dp[i+1][j-1] += dp[i][j];
            }
            dp[i+1][j] += dp[i][j];
        }
    }
    ll cnt = 0,pre = 0,k,c = 0;
    cin >> k;
    while(cnt < k){
        c++;
        pre = cnt;
        rep(i,1,10){
            cnt += dp[c][i];
        }
    }
    ll m = k;
    k -= pre;
    pre = 0;
    int p = 0;
    string ans = "";
    for (int i = c;i > 0;i--){
        int s;
        if (i == c){
            s = 1;
            while(pre+dp[i][s] < k){
                pre += dp[i][s];
                s++;
            }
        }
        else{
            if (p != 0) s = p-1;
            else s = p;
            while(pre+dp[i][s] < k){
                pre += dp[i][s];
                if ((p == 9 && s == p) || s == p+1) break;
                s++;
            }
        }
        ans += to_string(s);
        p = s;
    }
    PRINT(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const int MOD = (int)1e9 + 7;
const double PI = 3.14159265358979323846;
template <class T, class U>
void chmin(T& t, const U& u) {
  if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
  if (t < u) t = u;
}

int main(void) {
  bool ans = false;
  string s;
  cin >> s;
  int tmp = 0;
  rep(i, s.size()) {
    tmp += s[i] - '0';
    tmp = tmp % 9;
  }
  if (tmp == 0) ans = true;
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

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

#define PB emplace_back

using namespace std;

const int N = 1e5+100;

int n;

vector<int> v[N];

bool ok = 1, dp[N][3];

void dfs(int x, int px = -1) {
    for(int u: v[x]) {
        if(u != px) dfs(u, x);
    }
    int zero=0, one=0;
    for(int u: v[x]) {
        if(u != px) {
            if(dp[u][0]) zero++;
            if(dp[u][1]) one++;
        }
    }
    if(zero + one != (int)v[x].size() - (px != -1)) return;
    if(zero == 1) {
        dp[x][1] = 1;
    }
    if(zero == 0) {
        dp[x][0] = 1;
    }
}

int main () {
    ios::sync_with_stdio(0);
    cin >> n;
    for(int i = 0, u1, u2 ; i < n - 1 ; i++ ) {
        cin >> u1 >> u2;
        u1--;
        u2--;
        v[u1].PB(u2);
        v[u2].PB(u1);
    }
    dfs(0);
    cout << ((dp[0][1]) ? "Second" : "First") << '\n';
}


Measured memory_bytes: 9508
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":"\n");return os;}
//------------------------------------------------------------------------------

signed main() {
    int n,m;
    cin>>n>>m;
    vector<int> card(2*n);
    REP(i,2*n) card[i]=i+1;

    REP(i,m) {
        int k;
        cin>>k;
        vector<int> c;
        c=card;
        if(k==0) {
            REP(j,n) {
                card[j*2]=c[j];
                card[j*2+1]=c[n+j];
            }
        }
        else {
            rotate(begin(card),begin(card)+k,end(card));
        }
    }
    cout<<card<<endl;
    return 0;
}

Measured memory_bytes: 3172
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		
		// 電球ごとのスイッチパターンを作成
		int[] switchPatterns = new int[m];		
		for ( int i = 0; i < m; i++ ) {
			int k = in.nextInt();
			for ( int j = 0; j < k; j++ ) {
				switchPatterns[i] += 1<< (in.nextInt() - 1);
			}
		}
		
		// pの受け取り
		int[] p = new int[m];		
		for ( int i = 0; i < m; i++ ) {
			p[i] = in.nextInt();
		}

		int Allpatterns = 2 << (n - 1); // 2のn乗
		int cnt = Allpatterns;

		// スイッチのパターンを上限まで列挙
		for ( int ptr = 0; ptr < Allpatterns; ptr++ ) {
			// 電球ごとのパターンと照らし合わせる
			for ( int i = 0; i < m; i++ ) {
				if ( Integer.bitCount(ptr & switchPatterns[i]) % 2 != p[i] ) {
					cnt--;
					break;
				}
			}
		}
		System.out.println(cnt);
		in.close();
	}
}


Measured memory_bytes: 21844
n=int(input())
a = list(map(int, input().split( )))
q=int(input())
for _ in range(q):
    b,e,t = map(int, input().split( ))
    for k in range(e-b):
        tmp = a[b+k]
        a[b+k] = a[t+k]
        a[t+k] = tmp
print(*a)



Measured memory_bytes: 5832
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

int main() {
    ll N, W;
    cin >> N >> W;
    vector<pll> P(N);
    
    map<ll, ll> cnt;
    vector<ll> acc1(1), acc2(1), acc3(1), acc4(1);
    
    for(int i = 0; i < N; i++) {
        ll w, v;
        cin >> w >> v;
        P[i] = {w, -v};
        cnt[w]++;
    }
    vector<ll> ws;
    for(auto e : cnt) {
        ws.push_back(e.first);
    }
    
    sort(all(P));
    for(int i = 0; i < N; i++) {
        P[i].second *= -1;
        if (P[i].first == ws[0]) acc1.push_back(acc1.back() + P[i].second);
        if (ws.size() >= 2 && P[i].first == ws[1]) acc2.push_back(acc2.back() + P[i].second);
        if (ws.size() >= 3 && P[i].first == ws[2]) acc3.push_back(acc3.back() + P[i].second);
        if (ws.size() >= 4 && P[i].first == ws[3]) acc4.push_back(acc4.back() + P[i].second);
    }
    
    ll ans = 0;
    if (ws.size() == 1) {
        int i = min({(ll)acc1.size() - 1, W / ws[0]});
        ans = max(ans, acc1[i]);
    } else if (ws.size() == 2) {
        for(int i = 0; i <= N && i < acc1.size(); i++) {
            if (i * ws[0] > W) continue;
            int j = min({N - i, (ll)acc2.size() - 1, (W - i * ws[0]) / ws[1]});
            ans = max(ans, acc1[i] + acc2[j]);
        }
    } else if (ws.size() == 3) {
        for(int i = 0; i <= N && i < acc1.size(); i++) {
            for(int j = 0; i + j <= N && j < acc2.size(); j++) {
                if (i * ws[0] + j * ws[1] > W) continue;
                int k = min({(ll)acc3.size() - 1, N - i - j, (W - i * ws[0] - j * ws[1]) / ws[2]});
                ans = max(ans, acc1[i] + acc2[j] + acc3[k]);
            }
        }
    } else {
        for(int i = 0; i <= N && i < acc1.size(); i++) {
            for(int j = 0; i + j <= N && j < acc2.size(); j++) {
                for(int k = 0; i + j + k <= N && k < acc3.size(); k++) {
                    if (i * ws[0] + j * ws[1] + k * ws[2] > W) continue;
                    int l = min({(ll)acc4.size() - 1, N - i - j - k, (W - (i * ws[0] + j * ws[1] + k * ws[2])) / ws[3]});
                    ans = max(ans, acc1[i] + acc2[j] + acc3[k] + acc4[l]);
                }
            }
        }
    }
    
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define int long long
signed main(){
  int a,b,c[10000000],d,e;
  cin>>a>>b;
  for(int i=0;i<a;i++) cin>>c[i];
  sort(c,c+a);
  d=abs(c[0]-c[b-1]);
  e=d;
  for(int i=b;i<a;i++){
    d=abs(c[i-b+1]-c[i]);
    e=min(d,e);
  }
  cout<<e<<"\n";
}

Measured memory_bytes: 3072
#include<stdio.h>

int main(){

	int i,j,a[4],b[4],hit,blow;

	while(scanf("%d %d %d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1],&b[2],&b[3])!=EOF){
		hit=0;
		blow=0;
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(i==j && a[i]==b[j]) hit++;
				else if(i!=j && a[i]==b[j]) blow++;

			}
		}

		printf("%d %d\n",hit,blow);
	}





	return 0;

}

Measured memory_bytes: 596
#include<bits/stdc++.h>
   using namespace std;
   #define bolt ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   #define text_wali_bakchodi freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
   #define F first
   #define S second
   #define pb push_back
   #define lb lower_bound
   #define ub upper_bound
   #define endl "\n"
   typedef long long ll;
   typedef long double ld;
   const ll mod = 998244353 ;
   const ld pi=3.1415926535897932384626433;
   const ll inf = 1e18;
   bool isprime(ll n){for(ll i=2;i*i<=n;++i){if(n%i==0){return false;}}return true;}
   ll factorial(ll n){return (n==1 || n==0) ? 1:n*factorial(n-1);}
   ll power(ll x,ll y){ll res=1;x=x%mod;while(y>0){if(y&1)res=((res%mod)*(x%mod))%mod;y=y>>1;x=((x%mod)*(x%mod))%mod;}return res;}
   ll gcd(ll a,ll b){if (a==0)return b;return gcd(b%a,a);}
   ll lcm(ll a,ll b){return (a/gcd(a,b)*b);}
   ll max(ll a,ll b){ll sol=a>b?a:b;return sol;}
   ll min(ll a,ll b){ll sol=a<b?a:b;return sol;}
   ll mul(ll a,ll b){return ((a%mod)*(b%mod))%mod;}
   ll add(ll a,ll b){return ((a%mod)+(b%mod))%mod;}
   int main()
   {
      bolt;
      string s;
      cin>>s;
      if (s[2]==s[3] and s[4]==s[5])
         cout<<"Yes";
      else
         cout<<"No";
   }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MS(x, i) memset(x, i, sizeof x)
#define debug(x) cout << #x << ": " << x << endl
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define NOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const int maxn = 1e5 + 10;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double eps = 1e-5;
char F[200];

inline ll read() {
    ll ret = 0, sgn = 1;
    char ch = getchar();
    while(ch < '0' || ch > '9'){
        if(ch == '-') sgn = -1;
        ch = getchar();
    }
    while (ch >= '0' && ch <= '9'){
        ret = ret*10 + ch - '0';
        ch = getchar();
    } 
    return ret*sgn;
}

inline void write( ll x ) {
    ll tmp = x > 0 ? x : -x;
    if(x < 0) putchar('-');
    int cnt = 0;
    while(tmp > 0) {
       F[cnt++] = tmp % 10 + '0';
       tmp /= 10;
    }
    while(cnt > 0) putchar(F[--cnt]);
}

int maxans[maxn];
int ans = -1;

int main()
{
    NOS
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    
    int cnt = 0;
    string s, t;
    cin >> s >> t;

    for(int i = 0; i < s.length(); i++)
    {
        if(s[i] != t[i])
            cnt++;
    }
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
 
using namespace std;
 
#define debug(a) cerr << #a << ": " << a << endl
 
typedef long long ll;
typedef pair<int, int> ii;
 
#define x first
#define y second
 
const int N = 1e5 + 10;
const int MOD = 1e9 + 7;

int n, a[N];
int fact[N], suff_fact[N];
int dp[N], dp_pref[N];
int ans;

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif
 
	cin >> n;
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}

	fact[0] = 1;
	for (int i = 1; i < N; i++) {
		fact[i] = fact[i - 1] * 1LL * i % MOD;
	}

	suff_fact[0] = 1;
	for (int i = 1; i <= n; i++) {
		suff_fact[i] = suff_fact[i - 1] * 1LL * (n - (i - 1)) % MOD;
	}

	for (int i = 0; i < n; i++) {
		dp[i] = fact[i] * 1LL * suff_fact[n - (i + 1)] % MOD;
	}

	dp_pref[1] = dp[1];
	for (int i = 2; i < n; i++) {
		dp_pref[i] = (dp_pref[i - 1] + dp[i]) % MOD;
	}

	for (int i = 1; i <= n; i++) {
		ans = (ans + a[i] * 1LL * dp_pref[i - 1]) % MOD;
		ans = (ans + a[i] * 1LL * dp_pref[n - i]) % MOD;
		ans = (ans + a[i] * 1LL * fact[n]) % MOD;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 2176
import sys
input = sys.stdin.readline


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


A, B, C, D = map(int, input().split())
while True:
    C -= B
    if C <= 0:
        print('Yes')
        exit(0)
    A -= D
    if A <= 0:
        print('No')
        exit(0)


Measured memory_bytes: 9176
#include<bits/stdc++.h>
using namespace std;
string ans[]={"SAT","FRI","THU","WED","TUE","MON","SUN"};
int main(){
	string s;
	cin>>s;
	for(int i=0;i<7;i++){
		if(s==ans[i]){
			printf("%d\n",i+1);
			break;
		}
	}	
	return 0;
}

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

int main() {
	long long N, Q;
	static long long A[100000], SUM[2][100010] = {};
	cin >> N >> Q;
	for (int i = 0; i < N; i++) cin >> A[i];
	for (int i = 0; i < N; i++) {
		SUM[i % 2][i + 1] = SUM[i % 2][i] + A[i];
		SUM[(i + 1) % 2][i + 1] = SUM[(i + 1) % 2][i];
	}
	for (int i = 0; i < Q; i++) {
		long long X;
		cin >> X;
		long long L = 1, R = N + 1;
		while (R - L > 1) {
			long long MID = (L + R) / 2;
			if (abs(A[N - (MID + 1) / 2] - X) < abs(A[N - MID] - X)) R = MID;
			else L = MID;
		}
		long long B1 = N - L, B2 = N - (L + 1) / 2;
		long long ANS = (SUM[0][N] + SUM[1][N]) - (SUM[0][B2] + SUM[1][B2]);
		ANS += SUM[(N + 1) % 2][B1];
		cout << ANS << endl;
	}
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B;
    cin >> A >> B;
    cout << (A + B) % 24 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b; 
    if(a == b)cout << "Draw" <<endl;
    else if(a == 1)cout << "Alice" << endl;
    else if(b == 1)cout << "Bob" << endl;
    
    else if(a>b)cout << "Alice" << endl;
   
    else cout << "Bob" << endl;
}

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

int main(){
    int a1, a2, a3, a4;
    int b1, b2, b3, b4;
    while(cin >> a1 >> a2 >> a3 >> a4 >> b1 >> b2 >> b3 >> b4){
        vector<int> a, b;
        a.push_back(a1);
        a.push_back(a2);
        a.push_back(a3);
        a.push_back(a4);
        b.push_back(b1);
        b.push_back(b2);
        b.push_back(b3);
        b.push_back(b4);
        int hit = 0;
        int blow = 0;
        
        for(int i=0;i<4;i++){
            if(a[i] == b[i]){
                hit++;
            } else {
                if(find(a.begin(), a.end(), b[i]) != a.end())blow++;
            }
        }
        
        cout << hit << " " << blow << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <unordered_map>
#include <map>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using lint = long long;
using namespace std;

const int MOD = 1000000007;
const int INF = 1 << 20;

int main() {
    int K, T;
    cin >> K >> T;
    vector<int> a(T);
    rep(i, T) cin >> a[i];

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

    cout << max(0, a[0] - 1 - (K - a[0])) << endl;

    return 0;
}


Measured memory_bytes: 256
use strict;
use warnings;
use utf8;
use Data::Dumper;

use feature qw(say);

my $k = <STDIN>;
chomp $k;

my $num = 7;
for (my $i = 0; $i < $k; $i++) {
    my $extra = $num % $k;
    if ($extra == 0) {
        say $i+1;
        exit 0;
    }

    $num = 10 * $extra + 7;
}
say -1;

Measured memory_bytes: 6464
transpose ([]:_) = []
transpose matrix =
  let row  = map (head) matrix
      rows = transpose $ map (drop 1) matrix
  in
    row:rows

chk b s =
  let t = transpose b 
      e = replicate 3 s
  in
    if (b!!0) == e || (b!!1) == e || (b!!2) == e
    then True
    else if (t!!0) == e || (t!!1) == e || (t!!2) == e
         then True
         else if ((t!!0)!!0) == s && ((t!!1)!!1) == s && ((t!!2)!!2) == s
              then True
              else if ((t!!0)!!2) == s && ((t!!1)!!1) == s && ((t!!2)!!0) == s
                   then True
                   else False

ans' b =
  let c = map (chk b) ['b','w']
  in
    case c of
      [True,False] -> "b"
      [False,True] -> "w"
      otherwise    -> "NA"

ans ("0":_) = []
ans x =
  let d = take 3 x
      r = drop 3 x
  in
    (ans' d):(ans r)

main = do
  c <- getContents
  let i = lines c
      o = ans i
  mapM_ putStrLn o
  

Measured memory_bytes: 3784
read A B K
if [ $A -eq $K ] ; then 
    echo 0 $B
elif [ $A -lt $K ] ; then
    K=$(($K-$A))
    #echo $K
    A=0
    B=$(($B-$K))
    if [ $B -lt 0 ] ; then
        echo $A 0
    else
        echo $A $B
    fi
else
	A=$(($A-$K))
    echo $A $B
fi

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

int main (int argc, char **argv) {
  int a, b, c;
  string Ans;
  cin >> a >> b >> c;
  if ((a < b) && (b < c)) {
    Ans = "Yes";
  } else {
    Ans = "No";
  }
  cout << Ans << endl;
}

Measured memory_bytes: 1192
#include<stdio.h>
int main(void){
  int a, b, sum = 0;
  int i;
  
  while(scanf("%d %d", &a, &b) != EOF){
    sum = a + b;
    
    for(i = 0 ; sum > 0 ; i++){
      sum /= 10;
    }
    
    printf("%d\n", i);
  }

  return 0;
}


Measured memory_bytes: 600
s=input()
n=len(s)
ans=[1 for i in range(n)]

for i in range(n-1):
    if s[i] =="R" and s[i+1]=="R":
        ans[i+2]+=ans[i]
        ans[i]=0

for i in range(n-1,0,-1):
    if s[i]=="L" and s[i-1]=="L":
        ans[i-2]+=ans[i]
        ans[i]=0

print(" ".join(map(str,ans)))

Measured memory_bytes: 10484
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define CMAX(m, x)  m = max(m,x)
#define CMIN(m, x)  m = min(m,x)
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int max = 0;
    if(k > a){
        max = a;
        k -= a;
    }else{
        max = k;
        cout << max << endl;
        return 0;
    }
    if(k > b){
        k -= b;
    }else{
        cout << max << endl;
        return 0;
    }
    cout << max - k << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B;
	while(cin>>A>>B) {
		ll ans = max({A+A-1, A+B, B+B-1});
		cout<<ans<<endl;
	}
	
	return 0;
}


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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

template <typename T>
class SegTree
{
public:
    SegTree(const int n, const T &unity) : _unity(unity)
    {
        _n = 1 << __lg(2 * n - 1);
        _data.resize(2 * _n, unity);
    }

    SegTree(const vector<T> &v, const T &unity) : _unity(unity)
    {
        int n = v.size();
        _n = 1 << __lg(2 * n - 1);
        _data.resize(2 * _n, unity);

        // 最下段に要素をセット
        for (int i = 0; i < n; i++) _data[i + n] = v[i];
        // セグメント木を構築
        for (int i = n - 1; i > 0; i--) _data[i] = f(_data[2 * i], _data[2 * i + 1]);
    }

    // k番目の値をxに更新する
    void update(int k, const T &x)
    {
        k += _n; // 葉の節点に変換
        _data[k] = x;
        while (k >>= 1) _data[k] = f(_data[2 * k], _data[2 * k + 1]);
    }

    // 区間[a, b)に対してクエリ処理した結果を返す
    T query(int a, int b)
    {
        T left = _unity, right = _unity;
        a += _n, b += _n; // 葉の節点に変換
        for (; a < b; a >>= 1, b >>= 1) {
            if (a & 1) left  = f(left, _data[a++]);
            if (b & 1) right = f(_data[--b], right);
        }
        return f(left, right);
    }

    const T &operator[](size_t i) const { return _data[i + _n]; }
    T &operator[](size_t i) { return _data[i + _n]; }

private:
    int _n;          // 要素数
    vector<T> _data; // データを格納する配列
    T _unity;        // 単位元

    // クエリ処理用の関数
    T f(const T &a, const T &b) { return max(a, b); }
};

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

    int n; cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];

    // 座圧
    vector<int> b(a);
    sort(b.begin(), b.end());
    b.erase(unique(b.begin(), b.end()), b.end());

    int sz = b.size();

    SegTree<int> seg(sz, 0);
    for (int i = 0; i < n; i++) {
        int ai = lower_bound(b.begin(), b.end(), a[i]) - b.begin();

        // a[0], ..., a[i - 1]の増加部分列で，最大要素がa[i]未満となるもののうち最長の長さ
        int num = seg.query(0, ai);

        if (seg[ai] <= num) seg.update(ai, num + 1);
    }

    int ans = seg.query(0, sz);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4684
N,X = map(int,input().split())
L = list(map(int,input().split()))
D = [0]*(N+1)
ans = 1
for i in range(1,N+1):
    D[i] = D[i-1] + L[i-1]
    if X>=D[i]:
        ans += 1

print(ans)

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
#define mod 100000

int dp[101][101][4];
int H,W;

void make_table(){
  for(int i=0;i<=100;i++){
    dp[i][0][0]=1;
    dp[0][i][2]=1;
  }
  for(int i=1;i<=100;i++){
    for(int j=1;j<=100;j++){
      dp[i][j][0]=(dp[i-1][j][0]+dp[i-1][j][1])%mod;
      dp[i][j][1]=dp[i-1][j][2];
      dp[i][j][2]=(dp[i][j-1][2]+dp[i][j-1][3])%mod;
      dp[i][j][3]=dp[i][j-1][0];
    }
  }
}

int main(){
  make_table();
  while(cin>>H>>W&&H&&W){
    H--,W--;
    cout<<(dp[H][W][0]+dp[H][W][1]+dp[H][W][2]+dp[H][W][3])%mod<<endl;
  }
  return 0;
}

Measured memory_bytes: 1320
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define gg return 0
const int N=105;
int a[N],b[N];
int main (){
	int n,L=0;scanf ("%d",&n);
	for (int i=1;i<=n;i++) scanf ("%d",&a[i]),L=max(L,a[i]),b[a[i]]++;
	if (L&1){
		int l=(L+1)/2;
		for (int i=1;i<l;i++) if (b[i]) {puts("Impossible");gg;}
		if (b[l]!=2) {puts("Impossible");gg;}
		for (int i=l+1;i<=L;i++) if (b[i]<2) {puts("Impossible");gg;} 
	}else{
		int l=L/2;
		for (int i=1;i<l;i++) if (b[i]) {puts("Impossible");gg;}
		if (b[l]!=1) {puts("Impossible");gg;}
		for (int i=l+1;i<=L;i++) if (b[i]<2) {puts("Impossible");gg;}
	}
	puts("Possible");
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws NumberFormatException, IOException {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long result = 0;
		for (int i = 1; i <= N; i++) {
			result = result + compute(i, N);
		}
		System.out.println(result);
	}

	private static long compute(int i, int N) {
		Integer[] tensi = base10(i);
		int len = tensi.length;
		if (tensi[0] == 0) {
			return 0;
		}

		int first = tensi[len - 1];
		int last = tensi[0];

		Integer[] tensN = base10(N);
		int lenN = tensN.length;

		if (first == last) {
			long res = 0;
			for (int jlen = 1; jlen <= lenN; jlen++) {
				if (jlen == 1) {
					res = res + 1;
				} else if (jlen == 2) {
					int x = last * 10 + first;
					if (x <= N) {
						res = res + 1;
					}
				} else if (jlen < lenN) {
					res = res + (long) Math.pow(10, (jlen - 2));
				} else {
					int tmp = (int) Math.pow(10, lenN - 1) * last + first;

					if (tmp <= N) {
						if( tensN[lenN-1] > last ) {
							res = res + (int)Math.pow(10, jlen-2);
						}
						else if( tensN[lenN-1] == last) {
							int z =  0;
							for (int p=1,base=1;p<=lenN-2;p++) {
								z = z +  tensN[p]*base;
								base = base * 10;
							}
							res = res + z + 1 - ((tensN[0] < first)?1:0);
						}else {
							res = res + 0;
						}
						
					}
				}
			}
			return res;
		}

		int res = 0;

		for (int jlen = 1; jlen <= lenN; jlen++) {

			if (jlen == 1) {
				res = res + 0;
			} else if (jlen == 2) {
				int x = last * 10 + first;
				if (x <= N) {
					res = res + 1;
				}
			} else if (jlen < lenN) {
				res = res + (int) Math.pow(10, (jlen - 2));
			} else {
				int tmp = (int) Math.pow(10, lenN - 1) * last + first;

				if (tmp <= N) {
					if( tensN[lenN-1] > last ) {
						res = res + (int)Math.pow(10, lenN-2);
					}
					else if( tensN[lenN-1] == last) {
						int z =  0;
						for (int p=1,base=1;p<=lenN-2;p++) {
							z = z +  tensN[p]*base;
							base = base * 10;
						}
						res = res + z + 1 - ((tensN[0] < first)?1:0);
					}else {
						res = res + 0;
					}
				}
			}

		}

		return res;

	}

	private static Integer[] base10(int N) {
		LinkedList<Integer> list = new LinkedList<Integer>();
		int n = N;
		while (n != 0) {
			int d = n % 10;
			n = n / 10;
			list.addLast(d);
		}
		Integer[] tens = new Integer[list.size()];
		for (int i = 0, size = list.size(); i < size; i++) {
			tens[i] = list.get(i);
		}

		return tens;
	}

}


Measured memory_bytes: 59204
#include <iostream>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

// const int MAX = 200000;
// int a[MAX];
// int b[2019] = {0};

int modpow(int x, int n, int p) {
  if (n == 0) return 1;
  if (n % 2 == 0)
    return modpow(x * x % p, n / 2, p);
  else
    return modpow(x * x % p, n / 2, p) * x % p;
}

// int assignMod(int n, std::string s, int k) {
//   if (k == n) {
//     b[a[k]]++;
//     return a[k] = 0;
//   }
//   if (a[k] != -1) {
//     b[a[k]]++;
//     return a[k];
//   }
//   int p = modpow(10, n - k - 1, 2019);
//   a[k] = (assignMod(n, s, k + 1) + ((p * (s[k] - '0')) % 2019)) % 2019;
//   b[a[k]]++;
//   return a[k];
// }

int main() {
  std::string s;
  std::cin >> s;

  int n = s.length();
  int a[n + 1], b[2019] = {0};
  // rep(i, n) a[i] = -1;
  // assignMod(n, s, 0);

  a[n] = 0;
  b[0]++;
  for (int i = n - 1; i >= 0; --i) {
    // std::cout << "i: " << i << '\n';

    a[i] =
        (a[i + 1] + modpow(10, n - i - 1, 2019) * (s[i] - '0') % 2019) % 2019;
    b[a[i]]++;
  }

  // rep(i, n + 1) { std::cout << a[i] << ' '; }
  // std::cout << '\n';

  // rep(i, 2019) {
  //   if (b[i] >= 1) printf("b[%d] = %d\n", i, b[i]);
  // }

  int sum = 0;
  rep(i, 2019) {
    int m = b[i];
    sum += m * (m - 1) / 2;
  }

  std::cout << sum << '\n';

  return 0;
}


Measured memory_bytes: 4512
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> s[M];
  REP(i,M){
    int k;
    cin>>k;
    REP(j,k){
      int si;
      cin>>si;
      si--;
      s[i].push_back(si);
    }
  }
  int p[M];
  REP(i,M)cin>>p[i];
  int ans=0;
  REP(i,1<<N){
    bool f=true;
    REP(j,M){
      int sum=0;
      for(auto si:s[j])sum+=(i>>si)%2;
      if(sum%2!=p[j])f=false;
    }
    if(f)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;

int main() {

	int INF = 50001;

	int n, m;
	scanf("%d %d", &n, &m);

	int T[n + 1];
	int C[m];
	for (int i = 0; i < m; ++i) {
		int coin;
		scanf("%d", &coin);
		C[i] = coin;
	}
//15 6
//1 2 7 8 12 50
	for (int i = 1; i <= n; ++i) {
		T[i] = INF;
	}

	T[0] = 0;
	for (int i = 0; i < m; ++i) {
		for (int j = C[i]; j <= n; ++j) {
			T[j] = min(T[j], T[j - C[i]] + 1);
		}
	}

	cout << T[n] << endl;

	return 0;
}

Measured memory_bytes: 3348
#include <stdio.h>

int main(){
	int a, b, c;
	scanf("%d%d",&a,&b);
	if (a > b){
		c = a;
		a = b;
		b = c;
	}

	while (a%b != 0)
	{
		c = a%b;
		a = b;
		b = c;
	}

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

	return 0;
}

Measured memory_bytes: 592
#include<stdio.h>
#include<string.h>
int main(void)
{
	int cnt,x;
	char s[4];
	scanf("%s",s);
	cnt=0;
	if(s[0]=='o'){
		cnt++;
	}
	if(s[1]=='o'){
		cnt++;
	}
	if(s[2]=='o'){
		cnt++;
	}
	x=700+cnt*100;
	printf("%d\n",x);
	return 0;
}

Measured memory_bytes: 128
k = int(input())
a = 0
import queue
q = queue.Queue()
for i in range(1,10):
  q.put(i)
while True:
  x = q.get()
  a += 1
  if a == k:
    break
  elif x % 10 != 9 and x % 10 != 0:
      q.put(10*x + x%10 - 1)
      q.put(10*x + x%10)
      q.put(10*x + x%10 + 1)
  elif x % 10 == 9:
    q.put(10*x + x%10 - 1)
    q.put(10*x + x%10)
  else:
    q.put(10*x + x%10)
    q.put(10*x + x%10 + 1)
print(x)

Measured memory_bytes: 12456
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int cnt = 0;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        if(a % 2 == 1){
            cnt++;
        }
    }
    if(cnt % 2 == 0){
        cout << "YES";
    }else{
        cout << "NO";
    }
}

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

using namespace std;


#ifdef zxc

#include <sys/resource.h>
#include "debug.h"
#include "profile.h"

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define profile(X) LOG_DURATION(X)
#else
#define debug(...) 42
#define profile(...) 42
#endif

using ll = int64_t;
using ld = double;
const ld EPS = 1e-9;
//const ll MOD = 924844033;
const ld PI = 3.141592653589793;
const int maxn = 600001;
const int MOD = 1e9 + 7;
using cd = complex<double>;

void fast_io() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
}

int dp[301][301][301]; // rgb
int used[301][301][301]; // rgb
signed main() {
#ifdef zxc
    struct rlimit rl;
    const rlim_t kStackSize = 512L * 1024L * 1024L;
    assert(!getrlimit(RLIMIT_STACK, &rl));
    rl.rlim_cur = kStackSize;
    assert(!setrlimit(RLIMIT_STACK, &rl));
    freopen("../input.txt", "r", stdin);
//    freopen("../kolya_output.txt", "w", stdout);
#else
    //    mt19937 mt(std::chrono::high_resolution_clock::now().time_since_epoch().count());
    //            freopen("", "r", stdin);
    //        freopen("hack.out", "w", stdout);
#endif
    profile("all");

    auto solve = [](int _) {
        int h, w;
        cin >> h >> w;
        int n;
        cin >> n;
        vector<int> a(n + 1);
        for (int i = 1; i <= n; ++i) {
            cin >> a[i];
        }
        vector<vector<int>> ans(h + 1, vector<int>(w + 1));
        int y = 1;
        int x = 1;
        int dx = 1;
        int cur = 1;
        while (true) {
            if (!a[cur]) {
                ++cur;
                if (cur == n + 1) {
                    break;
                }
                continue;
            }
            --a[cur];
            ans[y][x] = cur;
            x += dx;
            if (x == w + 1) {
                x = w;
                dx = -dx;
                ++y;
            } else if (x == 0) {
                x = 1;
                dx = -dx;
                ++y;
            }
        }
        for (int i = 1; i <= h; ++i) {
            for (int j = 1; j <= w; ++j) {
                cout << ans[i][j] << " ";
            }
            cout << "\n";
        }
    };


    fast_io();
    cout.precision(9);
    cout << fixed;

    solve(1);


}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <stddef.h>
#include <stack>
#include <queue>
#include <cctype>
#include <stdio.h>

using namespace std;


int main() {
	string s;
	int sum;
	while (1) {
		cin >> s;
		if (s == "0") break;
		sum = 0;
		for (int i = 0; i < s.size(); i++) {
			sum += s[i] - '0';
		}
		cout << sum << endl;
	}
	
}

Measured memory_bytes: 1188
import sys


def resolve(in_):
    N = int(next(in_))
    # A * B + C = N
    # 

    ans = 0
    for a in range(1, N + 1):
        b, m = divmod(N, a)
        if m == 0:
            b -= 1
        ans += b

    return ans



def main():
    answer = resolve(sys.stdin)
    print(answer)

if __name__ == '__main__':
    main()


Measured memory_bytes: 9176
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		    Scanner sc = new Scanner(System.in);

		    int n = sc.nextInt();
		    int[] h = new int[n];
		    int cnt = 0;
		    int ans = 0;
		    for(int i=0;i<n;i++) {
		    	h[i] = sc.nextInt();
		    	if(i>=1) {
		    		if(h[i-1]-h[i]>=0) {
		    			cnt +=1;
		    			if(ans<cnt) {
		    				ans = cnt;
		    			}
		    		}else {
		    			cnt = 0;
		    		}
		    	}
		    }
		    System.out.println(ans);

		    sc.close();
	}
}


Measured memory_bytes: 50244
import math

str = input()
ans = 0
l = len(str)
#print(l)
if l % 2 == 1:  #奇数
  t = math.floor(l/2)
  d = str[0:t]
  dd = list(d)
  e = str[t+1:l]
  ee = list(reversed(e))
  #print(dd,ee)
  for i in range(t):
    if dd[i] != ee[i]:
      ans += 1
  print(ans)
  
else:  #偶数
  t = math.floor(l/2)
  d = str[0:t]
  dd = list(d)
  e = str[t:l]
  ee = list(reversed(e))
  #print(dd,ee)
  for i in range(t):
    if dd[i] != ee[i]:
      ans += 1
  print(ans)

Measured memory_bytes: 3064