akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
 
using namespace std;
using ll = long long;
 
const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;
 
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(4005);
 
 
void solve()
{
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
	for(int i = 2; i <= k; ++i)
	{
		// cout << k-1 << "C" << k-i << " * " << n-k+1 << "C" <<  i << endl;
		cout << c(k-1, i-1) * c(n-k+1, i) << endl;
	}
}
 
int main()
{
	fastio;
	solve();
 
	return 0;
}

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

using namespace std;

int main() {
    string s; 
    cin >> s;
    int cnt = 0;
    long long answer = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] == 'A') cnt++;
        else if (i + 1 < s.size() && s[i] == 'B' && s[i + 1] == 'C') {
            answer += cnt;
            i++;
        } else cnt = 0;
    }
    cout << answer << "\n";
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
    int f = 0, s = 0;
    int buf;
    for(int i=0; i<3; i++){
        scanf("%d", &buf);
        if(buf == 5){
            f++;
        }
        if(buf == 7){
            s++;
        }
    }
    if(f == 2 && s == 1){
        printf("YES");
    }else{
        printf("NO");
    }
    return 0;
}

Measured memory_bytes: 128
use std::collections::VecDeque;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}


fn main() {
    let n: usize = read();
    let mut v: Vec<i64> = Vec::new();
    for _ in 0..n {
        v.push(read());
    }
    v.sort();
    let mut ascend_order: VecDeque<_> = v.iter().collect();
    let mut descend_order: VecDeque<_> = v.iter().rev().collect();

    let mut array_result = std::collections::VecDeque::new();

    let mut cnt = 0;
    array_result.push_back(ascend_order.pop_front().unwrap());
    // println!("a {:?}", ascend_order);
    // println!("d {:?}", descend_order);

    loop {
        if cnt % 2 == 1 {
            array_result.push_front(ascend_order.pop_front().unwrap());
            if array_result.len() == n {
                break;
            }
            array_result.push_back(ascend_order.pop_front().unwrap());
            if array_result.len() == n {
                break;
            }
        } else {
            array_result.push_front(descend_order.pop_front().unwrap());
            if array_result.len() == n {
                break;
            }
            array_result.push_back(descend_order.pop_front().unwrap());
            if array_result.len() == n {
                break;
            }
        }
        cnt += 1
    }
    // println!("{:?}", array_result);

    let mut ans: i64 = 0;
    let mut past = array_result.pop_front().unwrap();
    while !array_result.is_empty() {
        let cur = array_result.pop_front().unwrap();
        ans += (cur - past).abs();
        past = cur;
    }
    // println!("{:?}", ans);

    let mut ascend_order: VecDeque<_> = v.iter().collect();
    let mut descend_order: VecDeque<_> = v.iter().rev().collect();

    let mut array_result = std::collections::VecDeque::new();

    let mut cnt = 0;
    array_result.push_back(descend_order.pop_front().unwrap());
    // println!("a {:?}", ascend_order);
    // println!("d {:?}", descend_order);

    loop {
        if cnt % 2 == 0 {
            array_result.push_front(ascend_order.pop_front().unwrap());
            if array_result.len() == n {
                break;
            }
            array_result.push_back(ascend_order.pop_front().unwrap());
            if array_result.len() == n {
                break;
            }
        } else {
            array_result.push_front(descend_order.pop_front().unwrap());
            if array_result.len() == n {
                break;
            }
            array_result.push_back(descend_order.pop_front().unwrap());
            if array_result.len() == n {
                break;
            }
        }
        cnt += 1
    }
    // println!("{:?}", array_result);

    let mut ans2: i64 = 0;
    let mut past = array_result.pop_front().unwrap();
    while !array_result.is_empty() {
        let cur = array_result.pop_front().unwrap();
        ans2 += (cur - past).abs();
        past = cur;
    }
    println!("{:?}", std::cmp::max(ans, ans2));
}


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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

int main(){

ll N, M;
cin >> N >> M;

ll ans;
ans = min(N, M / 2);
M -= ans * 2;

if(M >= 4){
	ans += M / 4;
}

print(ans);

}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

ans = 0
tmp = [A, B, C, D, E]
Y = []
Z = []
for i in range(5):
    Y.append([tmp[i] % 10, tmp[i]])
Y.sort()
#print(Y)
for i in range(5):
    if Y[i][0] != 0:
        Z.append(i)
if len(Z) != 0:
    for i in range(5):
        X = Y[i][1]
        #print(i)
        while X % 10 != 0:
            X += 1
        ans += X
        #print(X)
        #print(ans)
    G = Y[Z[0]][1]
    while G % 10 != 0:
        G += 1
    ans -= G
    ans += Y[Z[0]][1]
    #print(tmp[0])
else:
    ans = sum(tmp)
print(ans)


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

int main(){
int n,sd=0;
cin>>n;
int t = n;
while(t>0)
{
      sd+=t%10;
      t/=10;
}
if(n%sd==0)
cout<<"Yes"<<endl;
else
{
  cout<<"No"<<endl;
}
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

const MOD = 1000000007

func ModAdd(a, b int64) int64 {
	return (a + b) % MOD
}

func ModMul(a, b int64) int64 {
	return a * b % MOD
}

func ModSub(a, b int64) int64 {
	r := (a%MOD - b%MOD) % MOD
	if r < 0 {
		r += MOD
	}
	return r
}

func ModDiv(a, b int64) int64 {
	return a % MOD * ModInv(b) % MOD
}

func ModPow(a, n int64) int64 {
	var r int64 = 1
	for n > 0 {
		if n&1 == 1 {
			r = r * a % MOD
		}
		a = a * a % MOD
		n >>= 1
	}
	return r
}

func ModInv(a int64) int64 {
	var b, u, v int64 = MOD, 1, 0
	for b > 0 {
		t := a / b
		a -= t * b
		a, b = b, a
		u -= t * v
		u, v = v, u
	}
	u %= MOD
	if u < 0 {
		u += MOD
	}
	return u
}

type Q struct {
	idx, value int
	index      int
}

type QS []*Q

func (p QS) Len() int           { return len(p) }
func (p QS) Less(i, j int) bool { return p[i].value > p[j].value }
func (pq QS) Swap(i, j int) {
	pq[i], pq[j] = pq[j], pq[i]
	pq[i].index = i
	pq[j].index = j
}

func (pq *QS) Push(x interface{}) {
	n := len(*pq)
	item := x.(*Q)
	item.index = n
	*pq = append(*pq, item)
}

func (pq *QS) Pop() interface{} {
	old := *pq
	n := len(old)
	item := old[n-1]
	old[n-1] = nil  // avoid memory leak
	item.index = -1 // for safety
	*pq = old[0 : n-1]
	return item
}

func main() {
	var A, B int
	fmt.Scanf("%d %d\n", &A, &B)

	left := B - (A - 1)
	if left < -1000000 {
		left = -1000000
	}
	right := B + (A - 1)
	if right > 1000000 {
		right = 1000000
	}
	for i := left; i <= right; i++ {
		fmt.Print(i)
		fmt.Print(" ")
	}
	fmt.Println()
}


Measured memory_bytes: 512
#!/user/bin/env python
#pythonプログラムであることを示している

# -*- coding: utf-8 -*-
"""
このプログラムはPythonを書く際のテンプレとなっています。これをコピペしてコーディングを行なってください。
なお字下げしないこと！！
"""

__author_ = 'Maruta Yuzuha'
__version_ = '1.0.0'
__date__ = '2019/12/25'

def main():
    """
    ここでプログラムの解説を行う
     >>main()
    Hello world.
    0
    """
    s = input().split()
    a = 0
    b = int(s[0])
    c = int(s[1])
    while b > 0:
        b = b - c
        a += 1
    print(a)
    return 0

if __name__ == '__main__':
    #上記のifの記述によってこのスクリプトファイルが起動された時だけ実行する部分になる。
    #ちなみにスクリプトが "モジュールとして"インポートされた時には実行されない、

    #単体テスト:モジュールのdocstring(ドキュメンテーション文字列)に記載された全ての対話実行例が書かれている通りに動作するかを確認
    #python ファイル名 -v
    import doctest
    doctest.testmod()

    #実際にmain()を呼び出して、結果を得て、その結果でPythonシステムを終える
    import sys
    sys.exit(main())

Measured memory_bytes: 7772
#include <iostream>

using namespace std;
int dp[100010] = {},a[100010];
int main(){
	int i,j,n,k;
	cin >> n >> k;
	for(i=0;i<n;i++){
		cin >> a[i];
	}
	for(i=0;i<=k;i++) dp[i] = -1;
	for(i=0;i<=k;i++){
		if(dp[i]==-1){
			dp[i] = 0;
			for(j=0;j<n;j++){
				if(i + a[j]>k) continue;
				dp[i+a[j]] = 1;
			}
		}
	}
	if(dp[k]) cout << "First" << endl;
	else cout << "Second" << endl;
}

Measured memory_bytes: 640
import sys
input = sys.stdin.readline
INF = float("inf")

def main():
    N, W = map(int, input().split())
    weight = [0]*N
    value = [0]*N
    for i in range(N):
        weight[i], value[i] = map(int, input().split())
    
    V = 100010
    dp = [[INF]*V for _ in range(N+1)]
    dp[0][0] = 0
    for i in range(N):
        for j in range(V):
            if j - value[i] >= 0:
                dp[i+1][j] = min(dp[i+1][j], dp[i][j - value[i]] + weight[i])
            dp[i+1][j] = min(dp[i+1][j], dp[i][j])
    
    ans = 0
    for j in range(V):
        if dp[N][j] <= W:
            ans = j
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 311192
///
// File:  d.cpp
// Author: ymiyamoto
//
// Created on Sun Dec  3 21:29:12 2017
//

#include <algorithm>
#include <array>
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

array<int32_t, 200010> cs;

int32_t main()
{
  uint32_t N, C;
  cin >> N >> C;

  vector<vector<pair<uint32_t, uint32_t>>> channels(C + 1);
  for (uint32_t i = 0; i < N; i++) {
    uint32_t s, t, c;
    cin >> s >> t >> c;
    channels[c].push_back({2 * s, 2 * t});
  }

  for (uint32_t i = 0; i < channels.size(); i++) {
    sort(channels[i].begin(), channels[i].end());
  }

  for (uint32_t i = 0; i < channels.size(); i++) {
    for (uint32_t j = 0; j < channels[i].size(); j++) {
      cs[channels[i][j].first - 1]++;
      while (j + 1 < channels[i].size() && channels[i][j].second == channels[i][j + 1].first) {
        j++;
      }
      cs[channels[i][j].second]--;
    }
  }

  int32_t maxval = 0;
  for (uint32_t i = 0; i < cs.size() - 1; i++) {
    cs[i + 1] += cs[i];
    maxval = max(maxval, cs[i + 1]);
  }

  cout << maxval << endl;
  return 0;
}


Measured memory_bytes: 2304
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, m = map(int, input().split())
    AB = [list(map(int, input().split())) for _ in range(n)]
    CD = [list(map(int, input().split())) for _ in range(m)]

    for a, b in AB:
        min_dist = f_inf
        res = 0
        for i in range(m):
            c, d = CD[i]
            dist = abs(a - c) + abs(b - d)
            if min_dist > dist:
                min_dist = dist
                res = i + 1
        print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

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

int main(){
	int n;
	cin >> n;
	int h[n];
	rep(i, n) cin >> h[i];
	int ans = 0;
	int num = 0;
	rep(i, n-1){
		if(h[i] >= h[i+1]){
			num++;
		}else{
			if(num > ans){
				ans = num;
			}
			num = 0;
		}
		if(num > ans){
			ans = num;	
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt(), sy = sc.nextInt(), tx = sc.nextInt(), ty = sc.nextInt();
		
		StringBuilder sb = new StringBuilder();
		for(int i = sx;i<tx;i++) {
			sb.append("R");
		}
		for(int i = sy;i<=ty;i++) {
			sb.append("U");
		}//1回目のゴール+上に1つ
		for(int i=tx;i>=sx;i--) {
			sb.append("L");
		}
		for(int i=ty+1;i>sy;i--) {
			sb.append("D");
		} //1回目の戻ってきて、下に1つ
		sb.append("R");
		sb.append("D");
		
		for(int i = sx;i<=tx;i++) {
			sb.append("R");
		} //r右にはみでる

		for(int i = sy-1;i<ty;i++) {
			sb.append("U");
		}//2回目のゴール
		
		for(int i=tx+1;i>sx;i--) {
			sb.append("L");
		}

		for(int i=ty;i>sy;i--) {
			sb.append("D");
		}
	
		
		System.out.println(sb.toString());
		
	}
}



Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define OUT(x) cout << (x) << endl;
#define OUTA(a, n) \
    REP(i, n) { cout << (a[i]) << (i == n - 1 ? "\n" : " "); }
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    ll N;
    cin >> N;
    vi a(N);
    REP(i, N) { cin >> a[i]; }
    RSORT(a);
    ll ans = 0;
    REP(i, N)
    {
        if (i & 1)
        {
            ans -= a[i];
        }
        else
        {
            ans += a[i];
        }
    }
    OUT(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
	char a[52][52];
	int b,c,d=0;
	cin>>b>>c;
	for(int i=0;i<b+2;i++){
		for(int j=0;j<c+2;j++){
			a[i][j]=='0';
		}
	}
	for(int i=1;i<b+1;i++){
		for(int j=1;j<c+1;j++){
			cin>>a[i][j];
		}
	}
	for(int i=1;i<b+1;i++){
		for(int j=1;j<c+1;j++){
			if(a[i][j]=='.'){
				for(int k=-1;k<=1;k++){
					if(a[i-1][j+k]=='#'){
						d++;
					}
					if(a[i+1][j+k]=='#'){
						d++;
					}
				}
				if(a[i][j-1]=='#'){
					d++;
				}
				if(a[i][j+1]=='#'){
					d++;
				}
				cout<<d;
				d=0;
			}else{
				cout<<'#';
			}
		}
		cout<<endl;
	}
}

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

long long int gcd(long long int m, long long int n) {
  return (n == 0 ? m : gcd(n, m % n));
}

long long int lcm(long long int m, long long int n) {
  return m * n / gcd(m, n);
}

int main(){
    long long int a, b;
    while(scanf("%lld %lld", &a, &b) != EOF){
        cout << gcd(a,b) << " " << lcm(a,b) << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    REP(i, N) {
        cin >> V[i];
    }
    int R = min(N, K);
    int res = 0;
    REP(a, R + 1) {
        REP(b, R - a + 1) {
            int sum = 0;
            priority_queue<int, vector<int>, greater<int>> que;
            REP(i, a) {
                sum += V[i];
                que.push(V[i]);
            }
            REP(i, b) {
                sum += V[N - 1 - i];
                que.push(V[N - 1 - i]);
            }
            if (que.empty()) {
                continue;
            }
            REP(i, K - a - b) {
                if (que.empty()) {
                    break;
                }
                int v = que.top();
                que.pop();
                if (v >= 0) {
                    break;
                }
                sum -= v;
            }
            amax(res, sum);
        }
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

typedef long long int ll;
typedef vector< pair<int, int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int, int> pii;

const ll INF = 1e18;
const ll inf = 1e9;
const ll MOD = 1e9 + 7;
const ll nax = 1000000 + 10;

ll n;
pair<ll, ll> arr[nax];
priority_queue<ll> p1, p2;
ll x, y, z;
bool cmp(pii p1, pii p2)
{
    return(p1.ff - p1.ss < p2.ff - p2.ss);
}
ll ans1[nax], ans2[nax];
int main()
{
    ios::sync_with_stdio(0);
    cin >> x >> y >> z;
    n = x + y + z;
    ll mainans = 0;
    for(ll i = 1; i <= n; i++)
    {
        ll g, s, b;
        cin >> g >> s >> b;
        g -= b, s -= b;
        arr[i] = {g, s};
        mainans += b;
    }
    sort(arr + 1, arr + n + 1, cmp);
    ll lo = y, hi = y + z;
    ll ptr1 = 0;
    ll sum = 0;
    for(ll i = 1; i <= lo; i++)
    {
        p1.push(-arr[i].ss);
        sum += arr[i].ss;
    }
    ans1[++ptr1] = sum;
    for(ll i = lo + 1; i <= hi; i++)
    {
        p1.push(-arr[i].ss);
        sum += arr[i].ss;
        ll topi = -(p1.top());
        p1.pop();
        sum -= topi;
        ans1[++ptr1] = sum;
    }
    ll ptr2 = 0;
    sum = 0;
    for(ll i = n; i >= n - x + 1; i--)
    {
        p2.push(-arr[i].ff);
        sum += arr[i].ff;
    }
    ans2[++ptr2] = sum;
    for(ll i = n - x; i > lo; i--)
    {
        p2.push(-arr[i].ff);
        sum += arr[i].ff;
        ll topi = -(p2.top());
        p2.pop();
        sum -= topi;
        ans2[++ptr2] = sum;
    }
    ll maxi = -INF;
    ptr1 = 1;
    while(ptr2)
    {
        ll cur = ans2[ptr2] + ans1[ptr1];
        maxi = max(maxi, cur);
        ptr2--, ptr1++;
    }
    cout << mainans + maxi;
    return 0;
}


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

int main() {
	int f,c;
	long long ans,b,e,n,m,k,j;
	while(cin >> n && n!=0) {
		if (n<0) { f=1; m=-n;} else { f=0; m=n;}
        ans=b=c=0; k=j=1; 
		while (b!=n) {
		 if (f==1) { e=(10-(m % 10 + c)) % 10; if (m % 10 +c==10 || e!=0) c=1; else c=0;} else 
		 { e=(m % 10)+c; if (e==10) {c=1; e= e % 10;} else c=0;}
		 ans+=e*j; b+=e*k;
		 j*=10; k*=-10;
		 m/=10; f=1-f;
		 }
	 cout << ans << endl;
  } 		    	
	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N)cin >> A[i];
    vector<ll> C(N);
    vector<ll> D(N);
    vector<ll> E(1000000);
    REPS(i,N){
        C[i-1] = A[i-1] + i;
        D[i-1] = i - A[i-1];
    }
    REP(i,N){
        if(D[i] >= 0){
            E[D[i]]++;
        }
    }
    ll answer = 0;
    REP(i,N){
        if(C[i] >= 0&&C[i] <= 800000){
            answer += E[C[i]];
        }
        if(D[i] >= 0){
            E[D[i]]--;
        }
    }
    cout << answer << "\n";
}

Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
long long n,m,a[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51},b,c;
int main()
{
	cin>>n;
	cout<<a[n-1]<<endl; 
} 

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

#define mk make_pair
#define pb push_back

typedef long long lld;
typedef pair<lld,lld> pr;
typedef priority_queue <lld> max_heap;
typedef priority_queue <lld, vector<lld>, greater<lld> > min_heap;
lld const mod = 1e9+7;

lld power(lld x, lld y)
{
    lld res = 1;
    while (y > 0) {
        if (y & 1)
            res = res * x;
        y = y >> 1;
        x = x * x;
    }
    return res;
}

lld power_mod(lld base, lld y)
{
    lld t = 1;
    while (y > 0)
    {

        if (y % 2 != 0)
            t = (t * base) % mod;
        base = (base * base) % mod;
        y /= 2;
    }
    return t % mod;
}

lld nCrModp(lld n, lld r, lld p)
{
    if (r > n - r)
        r = n - r;
    lld C[r + 1]={0};
    C[0] = 1;

    for (lld i = 1; i <= n; i++)
    {
      for (lld j = min(i, r); j > 0; j--)
      {
        C[j] = (C[j] + C[j - 1]) % p;

      }
    }
    return C[r];
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  lld n;
  cin>>n;
  lld i;
  lld a;
  lld hash[100005]={0};
  lld sum = 0;

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

  lld q;
  cin>>q;
  lld b,c;
  lld cnt;
  for(i=0;i<q;i++)
  {
    cin>>b>>c;
    cnt = hash[b];
    sum = sum - cnt*b + cnt*c;
    hash[b]=0;
    hash[c]+=cnt;
    cout<<sum<<'\n';
  }

}


Measured memory_bytes: 4428
n,x = list(map(int, input().split()))
lst = [0]+list(map(int, input().split()))
ans = 0

for i in range(n):
    if lst[i]+lst[i+1]>x:
        ans+=(lst[i]+lst[i+1]-x)
        lst[i+1]-=(lst[i]+lst[i+1]-x)
print(ans)


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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, m;
  unordered_map<string, int> mp(n + m);
  cin >> n;
  string s;
  rep(i, n) {
    cin >> s;
    if (mp.find(s) == mp.end())
      mp.emplace(s, 1);
    else
      mp.emplace(s, mp.at(s)++);
  }
  cin >> m;
  rep(i, m) {
    cin >> s;
    if (mp.find(s) == mp.end())
      mp.emplace(s, -1);
    else
      mp.emplace(s, mp.at(s)--);
  }
  int ans = INF * (-1);

  for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
    ans = max(ans, itr->second);
  }
  if (ans < 0) ans = 0;

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


Measured memory_bytes: 34304
import java.util.*

class Scanner(`in`: java.io.InputStream) {
    private val reader = java.io.BufferedReader(java.io.InputStreamReader(`in`))
    private var tokenizer: StringTokenizer? = null

    fun next(): String {
        if (tokenizer?.hasMoreTokens() != true) {
            tokenizer = StringTokenizer(reader.readLine())
        }
        return tokenizer!!.nextToken()
    }

    fun nextLine(): String {
        return if (tokenizer?.hasMoreTokens() != true) {
            reader.readLine()
        } else tokenizer!!.nextToken("\n")
    }
}

fun main(args: Array<String>) {
    val pw = java.io.PrintWriter(System.out)
    Problem.solve(Scanner(System.`in`), pw)
    pw.flush()
}

////////////////////////////////////////////////////////////////////////

object Problem {
    fun solve(sc: Scanner, pw: java.io.PrintWriter) {
        val N = sc.next().toInt()
        val A = Array(N) { sc.next().toInt() }
        val m = mutableMapOf(Pair(A[0], 1))
        var ans = 0L
        for (i in 1 until N) {
            ans += m[i - A[i]] ?: 0
            m[A[i] + i] = (m[A[i] + i] ?: 0) + 1
        }
        pw.println(ans)
    }
}


Measured memory_bytes: 70800
N, K = gets.split.map(&:to_i)
ints = []
N.times do
  a, b = gets.split.map(&:to_i)
  ints << [a, b]
end

S = K.to_s(2)
L = K.to_s(2).size
result = 0

(L+1).times do |n|
  next if n != 0 && n != L && S[n] == "0"
  k = n == L ? K : (S[0...n] + "0" + ("1" * (L - n - 1))).to_i(2)
  kouho = 0
  ints.each do |xs|
    if (k | xs[0]) == k
      kouho += xs[1]
    end
  end
  # pp [kouho, k.to_s(2)].join(" ")
  result = [result, kouho].max
end
puts result

Measured memory_bytes: 11644
import java.util.*;
import java.io.*;
import java.math.BigInteger;

public class Main{
	
	static boolean visited[];
	static ArrayList<Integer> g[];
	static long arr[];
	static void dfs(int u , long sum)				
	{
		visited[u] = true;

		arr[u] += sum;
		for(int v: g[u])
			if(!visited[v])
			{
				dfs(v , arr[u]);
			}
	}


	
	public static void main(String[] args)throws IOException
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		PrintWriter out = new PrintWriter(System.out);
		
		StringTokenizer st1 = new StringTokenizer(br.readLine());
		
		int n = Integer.parseInt(st1.nextToken());
		int q = Integer.parseInt(st1.nextToken());
		
		arr = new long [n];
		
		g = new ArrayList[n];
		visited = new boolean[n];
		for(int i = 0 ; i < n ; i++)
			g[i] = new ArrayList<>();
		
		for(int i = 1 ; i <= n-1 ; i++)
		{
			st1 = new StringTokenizer(br.readLine());
			int x = Integer.parseInt(st1.nextToken())-1;
			int y = Integer.parseInt(st1.nextToken())-1;
			
			g[x].add(y);
			g[y].add(x);
		}
		
		while(q-- > 0)
		{
			st1 = new StringTokenizer(br.readLine());
			
			int x = Integer.parseInt(st1.nextToken())-1;
			int w = Integer.parseInt(st1.nextToken());
			
			arr[x] += w;
		}
		
		dfs(0 , 0l);
		
		for(int i = 0 ; i < n ; i++)
			out.print(arr[i] + " ");
		
		
		
		out.flush();
		out.close();
	}
	
	
	


}


Measured memory_bytes: 139500
n, k = map(int, input().split())

sunuke = [0 for i in range(n)]
for idx in range(k):
    d = int(input())
    a = map(int, input().split())
    for idx2 in a:
        sunuke[idx2 - 1] += 1

ans = 0
for su in sunuke:
    if su == 0:
        ans += 1

print(ans)


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

int main() {
    long long n;
    cin >> n;
    long long sum = 0;
    vector<long long> a(n), b(n), c(n);
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i] >> c[i];
    vector<long long> dp_a(n + 1, 0), dp_b(n + 1, 0), dp_c(n + 1, 0);
    for (int i = 0; i < n; i++) {
        dp_a[i + 1] = max(dp_a[i], a[i] + max(dp_b[i], dp_c[i]));
        dp_b[i + 1] = max(dp_b[i], b[i] + max(dp_c[i], dp_a[i]));
        dp_c[i + 1] = max(dp_c[i], c[i] + max(dp_a[i], dp_b[i]));
    }
    cout << max(dp_a[n], max(dp_b[n], dp_c[n])) << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
const int maxn=1e6+1;
#define p 1000000007
ll modpow(ll a,ll b){
	ll res=1;
	while(b){
		if(b%2){
			res=(res*a)%p;
			--b;
		}
		a=(a*a)%p;
		b/=2;
	}
	return res;
}
int main(){
	fast;
	ll n,t; cin>>n;
	if(n==1){
		cout<<0<<'\n';
		return 0;
	}
	ll ans=((modpow(10,n)-modpow(9,n)-modpow(9,n)+modpow(8,n))%p+p)%p;
	cout<<ans<<'\n';
	return 0;
}
//period of a string(prefix-function) with KMP
//prime func
//subset production
//factorization
//modpow
//modinv ( a^(p-2)=a^(-1) (mod p) )
//sieve
//ncr
//euler totien func (co prime divisiors upto n)
//matrix exponentation(fast fibonacci)
//dsu
//Trees
//Graphs(dfs,bfs,shortes path etc.)
//DP-Recursion

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

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); ++i)


string numToChar(int num){
    if(num == 0) return "A";
    else if(num == 1) return "B";
    else return "C";
}

int main()
{
    int N;
    vector<int> num(3);
    cin >> N >> num[0] >> num[1] >> num[2];
    vector<string> s(N);
    REP(i, N) cin >> s[i];


    vector<char> ans;
    REP(i, N){
        // 選ばれているものを数字に変換
        int c1 = s[i][0] - 'A';
        int c2 = s[i][1] - 'A';
        int c3 = 3-c1-c2;
        if(num[c1]+num[c2] == 0){
            cout << "No" << endl;
            return 0;
        }
        if(num[0]+num[1]+num[2] == 1){
            // 0の方に足す
            int small = (num[c1] > num[c2])? c2: c1;
            int large = (num[c1] > num[c2])? c1: c2;
            ans.push_back(char(small+'A'));
            ++num[small];
            --num[large];
        }else{
            bool flag = true;
            for(auto c: s[i]){
                int idx = c-'A';
                if((num[idx] == 0) or (i+1 < N and num[idx] == 1 and num[c3] == 0 and (s[i+1] == numToChar(idx)+numToChar(c3) or s[i+1] == numToChar(c3)+numToChar(idx)))){
                    ans.push_back(c);
                    ++num[idx];
                    --num[(idx == c1)? c2: c1];
                    flag = false;
                    break;
                }
            }
            if(flag){
                ans.push_back(s[i][0]);
                ++num[c1];
                --num[c2];
            }
        }
    }
    cout << "Yes" << endl;
    for(auto c: ans) cout << c << endl;

    return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,v;
  cin>>n;
  ll sum=0;
  rep(i,n){
    cin>>v;
    sum+=v;
  }
  cout<<sum/n<<endl;
}

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
int n, x;
priority_queue<double> pq;
int main() {
	cin >> n;
	while (n--)
		cin >> x, pq.push(-x);

	while (pq.size() > 1) {
		double p1 = pq.top();
		pq.pop();
		double p2 = pq.top();
		pq.pop();

		pq.push((p1 + p2) / 2);
	}

	cout << fixed << setprecision(12) << -pq.top();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>
#include <numeric>

int main()
{
	int H, W, h, w;

	std::cin >> H >> W >> h >> w;

	std::cout << ((H-h)*(W-w)) << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------
//組み合わせ nCr
vector<vector<ll>> nCr_v(5010, vector<ll>());
bool nCr_maekeisan = false;
void nCr_Calculater()
{
    for (int i = 0; i < 5010; i++)
    {
        nCr_v[i][0] = 1;
        nCr_v[i][i] = 1;
    }
    for (int k = 1; k < 5010; k++)
    {
        for (int j = 1; j < k; j++)
        {
            nCr_v[k][j] = (nCr_v[k - 1][j - 1] + nCr_v[k - 1][j]);
        }
    }
}
ll nCr(ll n, ll r)
{
    if (n > 5010 || r > 5010)
    {
        cout << "ERROR! over range" << endl;
        return 0;
    }
    if (n < 0 || r < 0)
    {
        return 0;
    }
    else
    {
        if (nCr_maekeisan == false)
        {
            for (ll i = 0; i < 5010; i++)
            {
                nCr_v[i].resize(5010);
            }
            nCr_Calculater();
            nCr_maekeisan = true;
        }
        return nCr_v[n][r];
    }
}

int main()
{
    ll n, m;
    cin >> n >> m;
    ll a[n];
    for (ll i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    map<ll, ll> rensou;
    ll ruiseki[n + 1];
    ruiseki[0] = a[0] % m;
    rensou[ruiseki[0]]++;
    for (ll i = 0; i < n; i++)
    {
        ruiseki[i + 1] = ruiseki[i] + a[i];
        ruiseki[i + 1] %= m;
        rensou[ruiseki[i + 1]]++;
    }
    ll ans = 0;
    for (auto f : rensou)
    {
        ans += ((f.second) * (f.second - 1)) / 2;
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898

//------------------------------------------------------

struct edge {
    int to;
    ll cost;
};

int n, m;
vector<edge> E[100002];
ll V[100002];
bool used[100002] = {};

bool check() {
    int i = 1;
    while (i <= n) {
        if (!used[i]) {

            queue<int> que;
            que.push(i);
            used[i] = true;

            while (!que.empty()) {

                for (auto e : E[que.front()]) {
                    if (!used[e.to]) {
                        used[e.to] = true;
                        V[e.to] = V[que.front()] + e.cost;
                        que.push(e.to);
                    } else if (V[e.to] != V[que.front()] + e.cost) {
                        return false;
                    }
                }

                que.pop();
            }
        }

        i++;
    }
    return true;
}

int main() {

    cin >> n >> m;

    rep(i, m) {
        int l, r;
        ll d;
        cin >> l >> r >> d;
        E[l].push_back({r, d});
        E[r].push_back({l, -d});
    }

    rep2(i, n) {
        V[i] = 0;
    }

    Yes(check());

    return 0;
}



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

int L,R,i,j,minv = 2020;

int main ()
{
	cin >> L >> R;
	
	if ( abs ( L - R ) >= 2019 )
	{
		cout << 0 << endl;
		
		return 0;
		
	}
	
	L %= 2019;
	R %= 2019;
	
	for ( i = L ; i <= R ; ++ i )
		for ( j = i + 1 ; j <= R ; ++ j )
			if ( i * j % 2019 < minv )
			   minv = i * j % 2019;
	
	cout << minv << endl;
	
	return 0;
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
int n,x,y,A[20000];
int main()
{
    scanf("%d%d%d",&n,&x,&y);
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++)
            {
                int s=j-i;
                if(j<=x||i>=y)
                    A[s]++;
                else
                {
                    s=min(abs(i-x)+abs(j-y)+1,s);
                     s=min(abs(i-y)+abs(j-x)+1,s);
                     A[s]++;

                }
            }

    }
    for(int i=1;i<n;i++)
        printf("%d\n",A[i]);
}


Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_takoyaki_festival2019(void) {
	int n;
	cin >> n;
	vector<int> d(n);
	int d_sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
		d_sum += d[i];
	}

	int recovery_val = 0;
	for (int i = 0; i < n - 1; i++) {
		d_sum -= d[i];
		recovery_val += (d_sum * d[i]);
	}

	cout << recovery_val << endl;
}

int main()
{
    b_takoyaki_festival2019();

    return 0;
}

Measured memory_bytes: 3580
import sys

S_ = input()
T = input()

ans = 'UNRESTORABLE'
if len(S_) < len(T):
    print(ans)
    sys.exit()

S = []
for i in range(len(S_) - len(T) + 1):
    for j in range(len(T)):
        if S_[i + j] == '?' or S_[i + j] == T[j]:
            continue
        else: break
    else:
        tmp = S_[0:i] + T + S_[i + len(T):len(S_)]
        S.append(tmp.replace('?', 'a'))

if len(S) > 0:
    sort = sorted(S)
    ans = sort[0]

print(ans)

Measured memory_bytes: 61992
n = int(input())
a = list(map(int, input().split()))
from collections import Counter
c = Counter(a)
ans = 0
for i in c:
    if ans < c[i] + c[i - 1] + c[i + 1]:
        ans = c[i] + c[i - 1] + c[i + 1]
print(ans)

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

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

using namespace std;

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int N;
string S;

char rot(char c) {
    char z = 'Z';
    if (c + N > z) {
        c -= 26;
    }
    return c + N;
}

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

    for (int i = 0; i < S.length(); i++) {
        printf("%c", rot(S[i]));
    }
    cout << endl;
}



Measured memory_bytes: 256
//
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <array>
#include <numeric>
#include <functional>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<utility>
#include<complex>

using namespace std;

int main(){

	int a,b,c;
	cin >> a >> b >>c;
	if(a != b && b != c && c != a)
		printf("3\n");
	else{
		if(a == b && b == c)
			printf("1\n");
		else{
			printf("2\n");
		}
	}
	return 0;
}


Measured memory_bytes: 888
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n, m, x;
    cin >> n >> m >> x;
    vector <int> cost(n);
    vector <vector <int>> a(n, vector <int> (m));
    forn (i, 0, n)
        cin >> cost[i] >> a[i];
    int ans = 1e9;
    forn (mask, 0, 1 << n) {
        int sum = 0;
        vector <int> cur(m);
        forn (i, 0, n) {
            if (((mask >> i) & 1) == 0)
                continue;
            sum += cost[i];
            forn (j, 0, m)
                cur[j] += a[i][j];
        }
        bool ok = true;
        forn (j, 0, m)
            if (cur[j] < x)
                ok = false;
        if (ok)
            chkmin(ans, sum);
    }
    if (ans == 1e9) 
        cout << -1;
    else
        cout << ans;
    return 0;
}

Measured memory_bytes: 3596
n=int(input())
a=sorted(list(map(int,input().split())))

b=[0,0,0,0,0,0,0,0]
cnt=0

for i in range(n):
    if a[i]//400==0:
        b[0]+=1
    if a[i]//400==1:
        b[1]+=1
    if a[i]//400==2:
        b[2]+=1
    if a[i]//400==3:
        b[3]+=1
    if a[i]//400==4:
        b[4]+=1
    if a[i]//400==5:
        b[5]+=1
    if a[i]//400==6:
        b[6]+=1
    if a[i]//400==7:
        b[7]+=1
    if a[i]//400>=8:
        cnt+=1
if cnt>0:
    print(max(1,len(b)-b.count(0)),len(b)-b.count(0)+cnt)
else:
    print(len(b)-b.count(0),len(b)-b.count(0)+cnt)


    
    


            
        

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LEN 13 

typedef struct _list list;
struct _list {
   int key;
   struct _list *prev, *next;
} ;

void insert(int key);
void delete(int key);
void deleteFirst(void);
void deleteLast(void);
void print_list(void);
void destroy_list(void);

list *head, *tail;

int main(){
   int i, n, key;
   char cmd[LEN];
   head=NULL;
   tail=NULL;
   scanf("%d",&n);
   for(i=0;i<n;i++){
      scanf("%s",cmd);
      if(strcmp(cmd,"insert")==0){
         scanf("%d",&key);
         insert(key);
      } else if(strcmp(cmd,"delete")==0){
         scanf("%d",&key);
         delete(key);
      } else if(strcmp(cmd,"deleteFirst")==0){
         deleteFirst();
      } else if(strcmp(cmd,"deleteLast")==0){
         deleteLast();
      }
//      print_list();
//      printf("head=%p tail=%p\n",head,tail);
   }
   print_list();
   //destroy_list();
   return 0;
}

void insert(int key){
   list *p;
   p=malloc(sizeof(list));
   p->key=key;
   p->next=head;
   p->prev=NULL;
   if(head==NULL){
      tail=p;
   } else {
      head->prev=p;
   }
   head=p;
}

void delete(int key){
   list *p;
   p=head;
   while(p!=NULL){
      if(p->key==key){
         if(p==head) deleteFirst();
         else if(p==tail) deleteLast();
         else {
            (p->prev)->next=p->next;
            (p->next)->prev=p->prev;
            free(p);
         }
         break;
      }
      p=p->next;
   }
}

void deleteFirst(void){
   list *new_head;
   if((new_head=head->next)!=NULL) new_head->prev=NULL;
   else tail=NULL;
   free(head);
   head=new_head;
}

void deleteLast(void){
   list *new_tail;
   if((new_tail=tail->prev)!=NULL) new_tail->next=NULL;
   else head=NULL;
   free(tail);
   tail=new_tail;
}

void print_list(void){
   list *p;
   printf("%d",head->key);
   p=head->next;
   while(p!=NULL){
      printf(" %d",p->key);
      p=p->next;
   }
   printf("\n");
}

void destroy_list(void){
   while(head!=NULL){
      deleteFirst();
   }
}

Measured memory_bytes: 31788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>//小数点以下表示
#include<map>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    double a,b;
    cin>>a>>b;
    bool c=false;
    for(int i=1;i<=1250;i++){
        if(floor(i*0.08)==a){
            if(floor(i*0.1)==b){
                cout<<i<<endl;
                c=true;
                break;
            }
        }
    }
    if(!c){
        cout<<-1<<endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>

bool is_prime(int x)
{
	int i;

	for (i = 2; i * i <= x; i++)
		if (x % i == 0)
			return false;
	return true;
}

int main(void)
{
	int x, i;

	scanf("%d" ,&x);

	for (i = x; ; i++)
		if (is_prime(i))
		{
			printf("%d" ,i);
			return 0;
		}
	return 0;
}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;

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

  std::vector<std::map<int, int>> cnt(10);

  auto top = [](int k) {
    int ret = k;
    while(k > 0) {
      ret = k;
      k /= 10;
    }
    return ret;
  };

  auto bot = [](int k) {
    return k % 10;
  };

  for(int k = 1; k <= N; ++k) {
    ++cnt[top(k)][bot(k)];
  }

  int ans = 0;
  rep(i, 10) {
    rep(j, 10) {
      ans += cnt[i][j] * cnt[j][i];
    }
  }

  std::cout << ans << '\n';
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_b() {
	ll n, m;
	ll x, y;
	//ll a, b, c;
	ll k;
	string s;
	//ll ans = 0;
	//float ans = 0;
	string ans;

	cin >> n >> m;

	vector<string> a(n), b(m);
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, m) {
		cin >> b[i];
	}

	string tmp;
	bool same;
	ll cnt = 0;
	rep(h, n) {
		rep(w, n) {
			same = true;
			rep(i, m) {
				if (h + i >= n) {
					same = false;
					break;
				}

				tmp = a[h + i].substr(w, m);
				if (tmp != b[i]) {
					same = false;
					break;
				}
			}
			if (same) {
				cout << "Yes" << "\n";
				return;
			}
		}
	}
	
	cout << "No" << "\n";
}

int main(void) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed;
	//cout << setprecision(7);

	solve_abc_b();

	return 0;
}

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

int main()
{
	ios::sync_with_stdio(false);
	long num, i,dif;
	cin >> num;
	num *= 3;
	int a[num];
	for (i = 0; i < num; i++) cin >> a[i];
	sort(a, a + num, greater<int>());
	dif = 0;
	/*for (i = 0; i < num*2/3; i++) {
		if (i % 2 == 1) dif += a[i];
	}*/
	num /= 3;
	for (i = 0; i < num; i++) {
		dif += a[2 * i + 1];
	}
	cout << dif;
	return 0;
}


Measured memory_bytes: 1408