akhauriyash/Code-Regression huggingface dataset:
import random

def down_score(d, c, last_d, score):
    sum = 0
    for i in range(26):
        sum += c[i]*(d-last_d[i])
        
    return (score - sum)

def main():
    D = int(input())

    c = list(map(int, input().split()))

    s = [list(map(int, input().split())) for i in range(D)]

    #print(c)

    #print(s)

    last_d = [0 for i in range(26)]
    
    ans = []
    
    score = 0
    
    for i in range(D):
        max = 0
        idx = 0
        for j in range(26):
            if max < (s[i][j] + c[j] * (i-last_d[j])):
                max = s[i][j] + c[j] * (i-last_d[j])
                idx = j
            elif max == (s[i][j] + c[j] * (i-last_d[j])):
                x = random.random()
                if x < 0.5:
                    idx = j
        last_d[idx] = i+1
        score += s[i][j]
        down_score(i+1,c,last_d,score)
        
        ans.append(idx)

    for i in range(D):
        print(ans[i]+1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9868
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float("INF")

#solve
def solve():
    a, b = LI()
    print(a*b)
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 76776
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, ans = 0;
    cin>>n;
    if(n & 1 || n < 10) {
        cout<<0<<endl;
    }else{
        int mom = 10;
        while(mom <= n) {
            ans += (n / mom);
            mom *= 5;
        }
        cout<<ans<<endl;
    }
}


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

using namespace std;

#define FOR(i,n) for(int i=0; i<n; ++i)
#define FORR(i,a,n) for(int i=a; i<n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

const int INF = 0x3f3f3f3f;

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
//int in() { int x; scanf("%d", &x); return x; }
//ll lin() { ll x; scanf("%lld", &x); return x; }
void printfv(VI a){ int n = a.size(); FOR(i, n) cout << a[i] << " "; }

int main(void){

	int n;
	cin >> n;

	int a[n], b[n];
	FOR(i, n){
		cin >> a[i];
		b[i] = a[i];
	}
	
	sort(b, b+n, greater<int>());

	FOR(i, n){
		if(a[i] == b[0]){
			cout << b[1] << "\n";
		} else {
			cout << b[0] << '\n';
		}
	}

    return 0;
}


Measured memory_bytes: 3200
def main():
    n = int(input())
    counts = [[0] * 26 for _ in range(n)]
    for i in range(n):
        for c in input():
            counts[i][ord(c) - ord('a')] += 1
    counts_min = [min(counts[i][c_i] for i in range(n)) for c_i in range(26)]
    s = ''
    for c_i, c in enumerate(counts_min):
        if c > 0:
            s += chr(ord('a') + c_i) * c
    print(s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define fore(i,a) for(auto &i:a)
#define all(a) (a).begin(),(a).end()
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
using ll = long long; constexpr int inf = INT_MAX / 2; constexpr ll infl = 1LL << 60;
template<class T>void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T>void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T>void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T>void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
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; }
template<class T>T gcd(T a, T b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }

void _main() {
  int N;
  cin >> N;

  if (N == 0) {
    cout << "0" << endl;
    return;
  }

  string ans;
  while (N != 0) {
    if (N % 2 != 0) {
      N--;
      ans = "1" + ans;
    } else {
      ans = "0" + ans;
    }
    N /= -2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>

// ===============================================================

using namespace std;
using ll = long long;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using vs = vector<string>;
using vc = vector<char>;
using vcc = vector<vector<char>>;
using vm = vector<short>;
using vmm = vector<vector<short>>;
using pii = pair<int, int>;
using psi = pair<string, int>;
using ld = long double;
using ull = unsigned long long;

// ===============================================================

ll gcd(ll a, ll b) //最大公約数
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

ll lcm(ll a, ll b) //最小公倍数
{
	return a * b / gcd(a, b);
}

ll box(double a) //doubleの切り捨て
{
	ll b = a;
	return b;
}

ll fff(double a) //doubleの四捨五入
{
	ll b = a + 0.5;
	return b;
}

ll sum(ll n) { //整数sまでの合計
	if (n == 0) {
		return 0;
	}

	int s = sum(n - 1);
	return s + n;
}

bool prime(ll num)//素数判定、primeならtrue,違うならfalse
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	// 素数である
	return true;
}

// ===============================================================

int main() {
	ll a, b, c, k; cin >> a >> b >> c >> k;
	if (a > k) {
		cout << 1 * k << endl;
	}
	else {
		if (a + b >= k) {
			cout << a << endl;
		}
		else {
			if (a + b + c >= k) {
				cout << a - ((k - a - b)) << endl;
			}
			else {
				cout << a - c << endl;
			}
		}
	}
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <array>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>
#include <set>
#include <map>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repe(i, n) for(int i = 0; i <= (n); i++)
#define fo(i, a, b) for(int i = (a); i < (b); i++)
#define foe(i, a, b) for(int i = (a); i <= (b); i++)
#define NL << endl

using namespace std;
using ll = long long;
const int INTMAX = numeric_limits<int>::max();
const int INTMIN = numeric_limits<int>::min();
const ll LLMAX = numeric_limits<long long>::max();
const ll LLMIN = numeric_limits<long long>::min();
const int MOD = 1000000007;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

using namespace std;

int main() {

	int n;

	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];

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

	cout << a.back() - a.front() NL;



	return 0;

}



Measured memory_bytes: 256
#include <stdio.h>
int main()
{
	int N, i, j, d[100];
	
	scanf("%d", &N);
	for (i = 0; i < N; i++)
		scanf("%d", &d[i]);
	int temp;
	int cont = N;
	for (i = 0; i < N; i++) {
		for (j = i + 1; j < N; j++) {
			if (d[i] < d[j]) {
				int temp = d[i];
				d[i] = d[j];
				d[j] = temp;
			}
		}
		if (d[i] == d[i - 1] && i >= 1)
			cont--;
	}
	
	printf("%d", cont);
	
	return 0;
}

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

int N, A[100003];

int main(){
	int large = 0;
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		int var;
		scanf("%d", &var);
		A[var]++, A[var + 1]++, A[var + 2]++;
	}
	for(int i = 0; i < 100003; i++) large = max(large, A[i]);
	printf("%d\n", large);
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> ans(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        ans[a]++;
        ans[b]++;
    }
    for (auto a : ans) {
        cout << a << "\n";
    }
}


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

#define flin            freopen("input.txt", "r", stdin); 
#define flout           freopen("output.txt", "w", stdout);
#define ll              long long
#define ull             unsigned long long
#define fastio          ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define nl              '\n'
#define nll             '\0'
#define pb              push_back
#define bdyptb          return 0;
#define sorted(x)       sort(x.begin(), x.end())
#define reversed(x)     reverse(x.begin(), x.end())
#define all(x)          x.begin(), x.end()
#define mset(a, b)      memset(a, b, sizeof(a));
#define testcase        ll t,tt; cin>>tt; for(t=1;t<=tt;t++)

#define pi acos(-1.00)   
#define mx 1000007

using namespace std;

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

	ll x=0;

	for(int i=0; i<n.size(); i++)
	{
		x+=n[i]-'0';
	} 

	if(x%9==0)
		cout<<"Yes";
	else 
		cout<<"No";

    
}

Measured memory_bytes: 3732
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <cstdint>
#include <map>
#include<iomanip>
#include<vector>

using namespace std;
typedef long long ll; 


ll ans,mx,sum,mn=1e18,flag;


int main(){
	ll n;
	cin>>n;
	ll a[n],b[n];
	for(ll i=0; i<n; i++){
		cin>>a[i];
		b[i]=a[i];
	}
	sort(b,b+n);
	ll temp=n/2;
	for(ll i=0; i<n; i++){
		if(a[i] <= b[temp-1]){
			cout<<b[temp]<<endl;
		} else cout<<b[temp-1]<<endl;
	}	
}

Measured memory_bytes: 5248
# abc173_a.py
# https://atcoder.jp/contests/abc173/tasks/abc173_a

# A - Payment /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点
# 問題文
# お店で N円の商品を買います。
# 1000円札のみを使って支払いを行う時、お釣りはいくらになりますか？
# ただし、必要最小限の枚数の 1000円札で支払いを行うものとします。
# 制約
#     1≤N≤10000
# N は整数

# 入力
# 入力は以下の形式で標準入力から与えられる。
# N

# 出力
# お釣りの金額を整数で出力せよ。

# 入力例 1
# 1900

# 出力例 1
# 100

# 1000円札 2 枚で支払いを行い、お釣りは 100円になります。

# 入力例 2
# 3000

# 出力例 2
# 0

# ちょうど支払えます。

# 解答
def abc173_a(lines):
    N = int(lines[0])
    amari = N % 1000
    if amari == 0:
        answer = 0
    else:
        answer = 1000 - amari
    return [answer]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['1900']
        lines_export = [100]
    elif pattern == 2:
        lines_input = ['3000']
        lines_export = [0]
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = abc173_a(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 9240
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}

#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 1055050

main(){
    int y,m,d;
    scanf("%d/%d/%d",&y,&m,&d);
    bool flag=true;
    if(y<2019)flag=false;
    if(y==2019&&m<4)flag=false;
    if(y==2019&&m==4&&d<=30)flag=false;
    cout<<(flag?"TBD":"Heisei");
    return 0;
}

Measured memory_bytes: 384
count = 0

n, m, c = [int(i) for i in input().split()]

b = list(map(int, input().split()))

for i in range(n):
    a = list(map(int, input().split()))
    sum = 0
    for j in range(len(b)):
        sum += a[j] * b[j]
    
    count += 1 if (sum + c > 0) else 0

print(count)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n,c; cin >> n >> c;
	int ans=0;
	int sum=0;
	n++;
	for(int i=0;i<c;i++){
		int x; cin >> x;
		sum+=x;
	}
	ans+=sum/n;
	if(sum%n!=0)ans++;
	cout << ans << endl;
}



Measured memory_bytes: 3156
def solve():
    ans = 1
    N = int(input())
    s = input()
    ans = 0
    for i in range(1000):
        t = str(i).zfill(3)
        t_index = 0 
        for s_index in range(N):
            if s[s_index] == t[t_index]:
                t_index += 1
                if t_index == 3:
                    break
        if t_index == 3:
            ans += 1
    print(ans)
solve()

Measured memory_bytes: 40304
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

long long S(long long n) {
	long long ret = 0;
	while (n > 0) {
		ret += n % 10;
		n /= 10;
	}
	return ret;
}

ll mypow(ll b, ll n) {
	return n == 0 ? 1 : b * mypow(b, n - 1);
}

long long snuke(long long n) {
	//priority_queue<pair<double, ll>, vector<pair<double, ll>>, greater<pair<double, ll>>>val;
	GPQ<pair<double, ll>> val;
	long long dig = 0;
	while (mypow(10,dig)<=n) {
		for (long long i = 1;i<=9;++i) {//★★
			long long v = n - n % (mypow(10, dig + 1)) + i * mypow(10, dig) - 1;
			if (v >= n) {
				val.push(make_pair(v * 1.0 / S(v), v));
			}
		}
		++dig;
	}
	--dig;    
	
	// 1桁もnと一致しないものを列挙
	for (ll i = 1; i <= 100; ++i) {
		ll v = i * mypow(10, dig) - 1;
		if (v >= n) {
			val.push(make_pair(v * 1.0 / S(v), v));
		}
	}

	auto ret = val.top();
	// g(m)とmが最小となる(g(m), m)の組

	return ret.second;
}


int main() {
	long long K;
	cin >> K;
	long long pre = 1;
	for (long long i = 0;i<K;++i) {
		cout << pre <<endl;
		pre = snuke(pre+1);
	}
	return 0;
}


Measured memory_bytes: 3376
def f(a,b,c):
    global N,M,A
    X = []
    for i in range(N):
        B = A[i]
        x = B[0] if a==0 else -B[0]
        y = B[1] if b==0 else -B[1]
        z = B[2] if c==0 else -B[2]
        X.append(x+y+z)
    X.sort(reverse=True)
    return sum(X[:M])
N,M = map(int,input().split())
A = []
for i in range(N):
    x,y,z = map(int,input().split())
    A.append([x,y,z])
ans = 0
for x in [0,1]:
    for y in [0,1]:
        for z in [0,1]:
            ans = max(ans,f(x,y,z))
print(ans)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
	
using namespace std;
	
#define endl "\n"
#define ll long long
#define vi vector <int >
#define vii vectir < pii >
#define vll vector <ll >
#define pii pair <int, int>
#define pdd pair< double, double>
#define piii pair < pii, int > 
#define pll pair<ll, ll >
#define umap unordered_map
#define pb push_back
#define pq priority_queue
#define forn(i, n) for(int i = 0; i < (int)n; i++)
#define rep(i,b,c) for(int i = (int)b; i < (int)c; i++)
#define a first
#define b second
 
 
int main(){
	ios::sync_with_stdio(0),cin.tie(0);

    int n, k, s;
    cin >> n >> k >> s;
    int aux;
    if(s == 1)
        aux = 50;
    else aux = s - 1;

    forn(i, k - (k == n)){
        cout << s << " ";
    }
    if(k == n){
        cout << s << endl;
    }else if(k < n){
        rep(i, k, n - 1){
            cout << aux<<" ";
        }
        cout << aux << endl;
    }


   
    return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define MN 100
#define S 0
#define T 201
#define INF 2000000000
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
bool b[MN+5][MN+5];
int n,m,a[MN+5][MN+5],top,A[MN+5][MN+5],cnt=1,head[T+5],c[T+5],q[T+5],d[T+5];
struct edge{int to,next,w;}e[MN*MN*5+5];
inline void ins(int f,int t,int w)
{
    e[++cnt]=(edge){t,head[f],w};head[f]=cnt;
    e[++cnt]=(edge){f,head[t],0};head[t]=cnt;
}
int dfs(int x,int f)
{
    if(x==T) return f;int used=0;
    for(int&i=c[x];i;i=e[i].next)
        if(e[i].w&&d[e[i].to]==d[x]+1)
        {
            int w=dfs(e[i].to,min(f-used,e[i].w));
            used+=w;e[i].w-=w;e[i^1].w+=w;
            if(used==f) return f;
        }
    return used;
}
bool bfs()
{
    memset(d,0,sizeof(d));d[q[top=1]=S]=1;
    for(int i=1,j;i<=top;++i)
        for(j=c[q[i]]=head[q[i]];j;j=e[j].next)
            if(e[j].w&&!d[e[j].to]) d[q[++top]=e[j].to]=d[q[i]]+1;
    return d[T];
}
void Solve(int tms)
{
    memset(head,0,sizeof(head));cnt=1;
    for(int i=1;i<=n;++i) ins(S,i,1);
    for(int i=1;i<=n;++i) ins(i+n,T,1);
    for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) 
        if(!b[i][j]) ins(i,(a[i][j]+m-1)/m+n,1);
    int rr=0;
    while(bfs()) rr+=dfs(S,INF);
    for(int i=1;i<=n;++i)
        for(int j=head[i];j;j=e[j].next)
            if(e[j].to!=S&&!e[j].w)
            {
                for(int k=1;k<=m;++k)
                    if(!b[i][k]&&(a[i][k]+m-1)/m==e[j].to-n)
                    {
                        A[i][tms]=a[i][k];
                        b[i][k]=1;
                        break;
                    }
                break;
            }
}
int main()
{
    n=read();m=read();
    for(int i=1;i<=n;++i) for(int j=1;j<=m;++j) a[i][j]=read();
    for(int i=1;i<=m;++i) Solve(i);
    for(int i=1;i<=n;++i,puts(""))
        for(int j=1;j<=m;++j) printf("%d ",A[i][j]);
    for(int i=1;i<=m;++i)
    {
        for(int j=1;j<=n;++j) for(int k=j+1;k<=n;++k)
            if(A[j][i]>A[k][i]) swap(A[j][i],A[k][i]);
    }
    for(int i=1;i<=n;++i,puts(""))
        for(int j=1;j<=m;++j) printf("%d ",A[i][j]);
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std; 

int main()
{
    string name;
    int a, b, c;
    
    cin >> a >> b >> c;
    if(a < b){
        if(b < c){
            cout << a << " " << b << " " << c << endl;
        }else if(c < a){
            cout << c << " " << a << " " << b << endl;
        }else{
            cout << a << " " << c << " " << b << endl;
        }
    }else{  // b < a
        if(a < c){
            cout << b << " " << a << " " << c << endl;
        }else if(c < b){
            cout << c << " " << b << " " << a << endl;
        }else{
            cout << b << " " << c << " " << a << endl;
        }
    }
}


Measured memory_bytes: 3104
// G - Longest Path
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
#define chmax(x,y) x=max(x,y)
int in(){int x;cin>>x;return x;}

vvi edges(100'000);
vi dp(100'000, -1);

int dfs(int p){
	if(0 <= dp[p]) return dp[p];
	dp[p] = 0;
	for(int c:edges[p]) chmax(dp[p], dfs(c)+1);
	return dp[p];
}

int main(){
	int N, M; cin>>N>>M;

	while(M--) edges[in()-1].push_back(in()-1);

	int ans = 0;
	while(N--) chmax(ans, dfs(N));
	cout<< ans <<endl;
}


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

int main(void)
{
    int N,n,K,X,Y;
    cin >> N >> K >> X >> Y;

    if (N > K)
    {
        n = N - K;
        N = K;
    }
    else {
        n = 0;
    }
    cout << N * X + n * Y << endl;

    return 0;
}

Measured memory_bytes: 764
while True:
    m,f,r=map(int,input().split())
    if m==f and f==r and r==-1:
        break
    if m==-1 or f==-1:
        print("F")
    elif (m+f)>=80:
        print("A")
    elif 65<=(m+f):
        print("B")
    elif 50<=(m+f) or r>=50:
        print("C")
    elif 30<=(m+f):
        print("D")
    else:
        print("F")


Measured memory_bytes: 5596
use whiteread::parse_line;

fn main() {
    let (_n, m): (usize, usize) = parse_line().unwrap();
    let mut min_i: usize = 0;
    let mut max_i: usize = 10_usize.pow(5);
    for _ in 0..m {
        let (li, ri): (usize, usize) = parse_line().unwrap();
        min_i = min_i.max(li);
        max_i = max_i.min(ri);
    }
    if max_i >= min_i {
        println!("{}", max_i - min_i + 1);
    } else {
        println!("0");
    }
}


Measured memory_bytes: 2184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
// --------------------------------------------------------
#define FOR(i,l,r) for (int i = (l); i < (r); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define MIN(c) *min_element(ALL(c))
#define MAX(c) *max_element(ALL(c))
#define SUM(c) accumulate(ALL(c), 0)
#define SUMLL(c) accumulate(ALL(c), 0LL)
#define SZ(c) ((int)(c).size())
#define debug(x) cerr << #x << " = " << (x) << '\n';
using P = pair<int,int>;
using VS = vector<string>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<ll>;
using VVLL = vector<VLL>;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll MOD = 1000000007;
// const ll MOD = 998244353;
// const int INF = 1 << 30;
const ll INF = 1LL << 62;
// --------------------------------------------------------


const int MAX_N = 1e+2;
const int MAX_V = 1e+3;
VVLL dp(MAX_N + 1, VLL(MAX_V * MAX_N + 1, INF));

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

    int N, W; cin >> N >> W;
    VLL w(N), v(N); REP(i,N) cin >> w[i] >> v[i];

    int V = SUM(v);
    dp[0][0] = 0;
    FOR(i,0,N) FOR(j,0,V+1) {
        if (j - v[i] >= 0) {
            dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
        } else {
            dp[i + 1][j] = dp[i][j];
        }
    }

    int ans = 0;
    FOR(i,0,V+1) {
        if (dp[N][i] <= W) ans = max(ans, i);
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 83068
#include<stdio.h>

int main(void){
	int K,N;
	scanf("%d %d\n",&K,&N);
	int A[N];
	for(int i=0;i<N;i++){
		scanf("%d \n",&A[i]);
	}

	int tem=0;
	for(int i=0;i<N-1;i++){

		int L = A[i+1]-A[i];
		if(L > tem)tem = L;
	}
	int M = K-A[N-1]+A[0];
	if(M>tem)tem = M;

	printf("%d",K-tem);

    return 0;
}


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

int main() {
	int a,b,k;cin>>a>>b>>k;
	for(int i=a;i<=b;i++){
		if(i<a+k){
			cout<<i<<endl;
		}else if(i>b-k){
			cout<<i<<endl;
		}
	}
	return 0;
}


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

int main(){
	char a,b,c,d,e,f;
	scanf(" %c %c %c",&a,&b,&c);
	scanf(" %c %c %c",&d,&e,&f);
	if((a==f)&&(b==e)&&(c==d)) printf("YES\n");
	else printf("NO\n");
return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
 
int dy[5] = { 0,0,1,-1,0 };
int dx[5] = { 1,-1,0,0,0 };
 
 
int main(void) {
    bool flag=false;
	string a,b,c;
	cin>>a>>b>>c;

	if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}



	return 0;
}

Measured memory_bytes: 256
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    for i in 1..10 {
        if n % i == 0 && n / i < 10 {
            println!("Yes");
            return;
        }
    }
    println!("No");
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main()
{
    int r,D,x2000;
    cin>>r>>D>>x2000;
    
    for (int i=0; i<10; i++){
        x2000=r*x2000-D;
       
        cout<<x2000<<endl;
        }
return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define BE(c) c.begin(),c.end()
using namespace std;
int DP[201][201][201];
typedef int ut;
typedef pair<ut,ut> pr;
typedef pair<ut,pr> ppr;
typedef vector<ppr> Vppr;
Vppr v;
const int INF=1<<30;
int main() {
	int D,N,a,e,r;
	cin.tie(0);
while(cin >> D >> N && N){
	
	REP(i,N){
		cin >> a >> e >> r;
		v.push_back(ppr(r,pr(a,e)));
	}
	REP(i,101) REP(j,101) REP(k,101) DP[i][j][k]=INF;
	DP[0][0][0]=0;
	sort(BE(v));
	REP(i,N){
		REP(j,D+1){
			REP(k,101){
				if(k>=v[i].first)
					DP[i][min(j+v[i].second.first,D)][min(100,k+v[i].second.second)]
					=min(DP[i][min(j+v[i].second.first,D)][min(100,k+v[i].second.second)],DP[i][j][k]+1);
				DP[i+1][j][k]=DP[i][j][k];
			}
		}
	}
	int minium=INF;
	REP(i,101)
		minium=min(minium,DP[N][D][i]);
	if(minium==INF) cout << "NA" << endl;
	else cout << minium << endl;
	v.clear();
}
	// your code goes here
	return 0;
}

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

	int X[10000];

	int isprime(int x);

int main(void)
{
	int N;
	int i;

	int ans;

	scanf("%d", &N);
	for ( i = 0 ; i < N ; i++ ) {
		scanf("%d", &X[i]);
	}

	ans = 0;
	for ( i = 0 ; i < N ; i++ ) {
		if (isprime(X[i])) {
			ans++;
		}
	}

	printf("%d\n", ans);
	return 0;
}

int isprime(int x)
{
	int i;
	int work;
	if (x == 2) {
		return 1;
	}

	if ( x < 2 || x%2 == 0 ) {
		return 0;
	}

	i = 3;
	work = (int)sqrt((double)x);
	while (i <= work ) {
		if ( x%i == 0 ) {
			return 0;
		}
		i = i + 2;
	}

	return 1;
}

Measured memory_bytes: 624
#include <algorithm>
#include <cassert>
#include <climits>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

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;
}

const int INF = 1e9;
const long long LINF = 1e18;

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

    if (S == "ABC") {
        cout << "ARC" << endl;
    } else {
        cout << "ABC" << endl;
    }

    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long 
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define REPI(i, a, b) for (ll i = b - 1; i >= a; i--)
#define i_os ios::sync_with_stdio(0);  cin.tie(0);  cout.tie(0);
#define INF (ll)1e18 + 100
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define MAX 1e6
/*SOME BITMASK KNOWLEDGE
1)x & (x - 1):sets the last one bit of x to zero
power of two exactly when x & (x − 1) = 0.
2)x & -x:sets all the one bits to zero, except last one bit
3)x | (x - 1):inverts all the bits after the last one bit*/
#define o_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define o_setll tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
typedef tree<pair<ll, ll>,null_type,less<pair<ll, ll>>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set

bool ispalin(string s){
	string s1 = s;
	reverse(s.begin(),s.end());
	if(s == s1) return 1;
	else return 0;
}
int main() 
{
	string s;
	cin>>s;
	ll n = s.size();
	if(ispalin(s.substr(0,(n-1)/2)) && ispalin(s.substr((n+3)/2 - 1)) && ispalin(s)){
		cout<<"Yes"<<endl;
	}
	else cout<<"No"<<endl;
	return 0;
}  


Measured memory_bytes: 256
#define f(I)(p[I]+h[I]*(h[I]-2*h[i]))
long C,h[2<<17],p[2<<17],X,a;P[2<<17];s,t,x,y;main(i){for(scanf("%*d%ld%d",&C,h);~scanf("%d",&a);P[++t]=i-1){for(h[i]=a;X=f(P[s]),s<t&&X>f(P[s+1]);s++);for(p[i++]=X+=a*a+C;s<t&&(h[y=P[t]]-h[x=P[t-1]])*(f(y)-X-a*a)>(a-h[y])*(f(x)-f(y));t--);}printf("%ld",X);}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#include <iostream>
#include <functional>
#include <vector>
#include <stdio.h>
#include <queue>
#include <string.h>
#include <math.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define rep1(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=a;i>=n;i--)
#define per1(i,a,n) for (int i=a;i>n;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define pi 3.14159265358979323846264338327950288419716939937510
#define IOS cin.sync_with_stdio(false);cin.tie(0);cout.tie(0);
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll mod=1000000007;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
ll qpow(ll a,ll b){ll s=1;while(b>0){if(b%2==1){s=s*a;}a=a*a;b=b>>1;}return s;}
ll qpowmod(ll a, ll b, ll c){ll res, t;res=1;t=a%c;while(b){if(b & 1){res=res*t%c;}t=t*t%c;b>>=1;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline long long read(){long long k=0,f=1;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){k=k*10+ch-'0';ch=getchar();}return k*f;}
inline void write(long long x){if(x<0)x=-x,putchar('-');if(x>9)write(x/10);putchar(x%10+'0');}
// head
//ll t,n,a[100005];
ll s,w;
int main()
{
    //IOS;
    /*cin>>t;
    while(t--)
    {
        cin>>n;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
        }
    }*/
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe"<<endl;
    }
    else
    {
        cout<<"safe"<<endl;
    }
    return 0;
}
/*

*/


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define N 200005
#define ll long long

using namespace std;

ll n,cnt;
ll a[N];
ll ans,b[N];
bool flag = false;

int main(){
	scanf("%lld",&n);
	for(int i = 1; i <= n; ++i)
		scanf("%lld",a + i);
	sort(a + 1, a + 1 + n);
	if(a[1] >= 0){
		ans = -a[1];
		for(int i = 2; i <= n; ++i)
			ans += a[i];
		cout << ans << endl;
		ll tmp = a[1];
		for(int i = 3; i <= n; ++i){
			printf("%lld %lld\n",tmp, a[i]);
			tmp -= a[i];
		}
		printf("%lld %lld\n",a[2] ,tmp);
		return 0;
	}
	if(a[n] <= 0){
		ans = a[n];
		for(int i = 1; i < n; ++i)
			ans -= a[i];
		cout << ans << endl;
		ll tmp = a[n];
		for(int i = n - 1; i >= 1; --i){
			printf("%lld %lld\n",tmp, a[i]);
			tmp -= a[i];
		}
		return 0;
	}
	else{
		for(int i = 1; i <= n; ++i)
			ans += (a[i] < 0) ? -a[i] : a[i];
		cout << ans << endl;
		ll tmp = a[1];
		int pos = 1;
		while(a[pos] <= 0) ++pos;
		for(int i = pos + 1; i <= n; ++i){
			printf("%lld %lld\n",tmp, a[i]);
			tmp -= a[i];
		}
		printf("%lld %lld\n",a[pos] , tmp);
		tmp = a[pos] - tmp;
		for(int i = 2; i < pos; ++i)
			printf("%lld %lld\n",tmp,a[i]),tmp -= a[i];
		return 0;
	}
}


Measured memory_bytes: 2688
n, k = map(int, input().split())
P = list(map(int, input().split()))
ans = 0
for i in P[:k]:
  ans += (i+1)/2
temp = ans
for i in range(k, n):
  temp -= (P[i-k]+1)/2
  temp += (P[i]+1)/2
  ans = max(ans, temp)
print(ans)

Measured memory_bytes: 25060
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
using namespace std;

vector<vector<pair<int,int> > > g;   // to,edge
vector<int> col;

void dfs( int par, int paredge, int curr)
{
    int siz=(int)g[curr].size();
    int i;
    int coltmp=0;
    for(i=0; i<siz; i++) {
        int next=g[curr][i].first;
        int edge=g[curr][i].second;
        if(next==par) continue;

        if(paredge>=0 && coltmp==col[paredge]) {
            coltmp++;
        }
        col[edge]=coltmp;
        coltmp++;
        dfs(curr, edge, next);
    }
    
    return;
}

int main(int argc, char* argv[])
{
    int n;
    scanf("%d", &n);
    g.resize(n);
    col.resize(n-1);
    int i;
    for(i=0; i<n-1; i++) {
        int a,b;
        scanf("%d%d", &a, &b); a--; b--;
        g[a].push_back(make_pair(b,i));
        g[b].push_back(make_pair(a,i));
    }

    dfs(-1, -1, 0);

    int max=0;
    for(i=0; i<n-1; i++) {
        max=MAX(max,col[i]);
    }
    printf("%d\n", max+1);
    for(i=0; i<n-1; i++) {
        printf("%d\n", col[i]+1);
    }
    return 0;
}


Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

struct Event{
    int time;
    int type; // 0 - custermer on, 1 - custermer off, 2 - operation end, 
    int id;
};
bool operator < (const Event& e, const Event& f) { // !!! reversed !!!
    if(e.time != f.time) return e.time > f.time;
    if(e.type != f.type) return e.type > f.type;
    return e.id > f.id;
}

bool check(int OPE, int T, const vector<int>& M, const vector<int>& L, const vector<int>& K) {
    int N = M.size();
    priority_queue<Event> que;
    //priority_queue<int, vector<int>, greater<int>> wait;
    set<int> wait;

    vector<int> state(N);
    REP(i, N) {
        wait.insert(i);
        if(K[i] != 1) que.push({L[i] + 1, 1, i});
    }

    int rest = N;

    for(int t = 0; t <= T; t++) {
        while(!que.empty() && que.top().time == t) {
            auto e = que.top(); que.pop();
            //printf("{time:%d, type:%d, id:%d}\n", e.time, e.type, e.id);
            if(e.type == 0) {
                //wait.push(e.id);
                wait.insert(e.id);
                que.push({t + L[e.id] + 1, 1, e.id});
                state[e.id] = 0;
            } else if(e.type == 1 && state[e.id] == 0) {
                wait.erase(wait.find(e.id));
                que.push({t + K[e.id] - 1, 0, e.id});
                state[e.id] = 1;
            } else if(e.type == 2) {
                rest--;
                OPE++;
            }
        }

        while(OPE > 0 && !wait.empty()){
            auto it = wait.begin();
            int id = *it;
            wait.erase(it);
            //int id = wait.top(); wait.pop();
            if(state[id] != 0) continue;
            state[id] = 2;
            que.push({t + M[id], 2, id});
            OPE--;
        }
    }

    //cout << rest << endl;
    return rest == 0;
}

int main(){
    int N, T;
    while(cin >> N >> T && (N > 0)) {
        vector<int> M(N), L(N), K(N);
        REP(i, N) cin >> M[i] >> L[i] >> K[i];

        for(int i = 1; i <= N; i++) {
            if(check(i, T, M, L, K)) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1312
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          Console.WriteLine(a[0]+a[1]/2);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


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

struct SegmentTree{
	vector<int> data;
	int sz;

	SegmentTree(int n){
		sz = getsize(n);
		data.assign(4*sz, 0);
	}

	int getsize(int n){
		int i = 0;
		while((1<<i)<=n) i++;
		return (1<<i);
	}

	int add(int k,int x){
		k+=sz-1;
		data[k]+=x;
		while(k){
			k=(k-1)/2;
			data[k] = data[2*k+1] + data[2*k+2];
		}
		
		return 0;
	}

	long long get(int a,int b){
		return _get(a,b,0,0,sz);
	}

	long long _get(int a,int b,int k,int l,int r){
		if(r<=a||b<=l) return 0;
		if(a<=l&&r<=b) return data[k];

		return _get(a,b,2*k+1,l,(l+r)/2) + _get(a,b,2*k+2,(l+r)/2,r);
	}
};

int main(){
	int n, q; cin >> n >> q;
	SegmentTree seg(n);
	
	for(int i=0;i<q;i++){
		int a;
		cin >> a;
		if(a==1){
			int b,c;
			cin >> b >> c;
			cout << seg.get(b-1,c) << endl;
		}else if(a==0){
			int b,c;
			cin >> b >> c;
			seg.add(b-1,c);
		}
	}

	return 0;
}


Measured memory_bytes: 4960
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<long> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    if (!A.at(i)) return cout << 0 << "\n", 0;
  }
  long ans = 1;
  for (int i = 0; i < N; i++) {
    if ((long double) ans * A.at(i) > 1e18) return cout << -1 << "\n", 0;
    ans *= A.at(i);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 4052
#include <cstdio>

#define LEN 3

int main() {
  char s[LEN + 1], t[LEN + 1];
  scanf("%s", s);
  scanf("%s", t);

  int cnt = 0;
  for (int i = 0; i < LEN; ++i) {
    if (s[i] == t[i]) {
      cnt++;
    }
  }
  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 128
from itertools import accumulate

n,k=map(int,input().split())
p=list(map(int,input().split()))

x=[]
for i in p:
 x.append((i+1)/2)

b=[0]+list(accumulate(x))

'''
bb=[0]
for i in range(1,n+1):
 bb.append(bb[i-1]+x[i-1])

print(b)
print(bb)
'''

ans=0
for i in range(n-k+1):
 ans=max(ans,b[i+k]-b[i])

print(ans)

Measured memory_bytes: 26364
#include<bits/stdc++.h>
using namespace std;
int stone[100000+5];
int dp[100000+5];

int main(int argc, char const *argv[])
{
	int N;
	while(cin >> N) {
		memset(stone, 0, sizeof(stone));
		memset(dp, 0, sizeof(dp));
		for(int i=1; i<=N; i++){
			cin >> stone[i];
		}
		dp[1] = 0;
		dp[2] = abs(stone[2] - stone[1]);
		for(int i=3; i<=N; i++){
			dp[i] = min(dp[i-2] + abs(stone[i] - stone[i-2]), dp[i-1] + abs(stone[i] - stone[i-1]));
		}
		cout << dp[N] << endl;
	}
	return 0;
}

Measured memory_bytes: 4384
import java.util.Scanner;

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

        int p = stdIn.nextInt();
        int q = stdIn.nextInt();
        int r = stdIn.nextInt();

        if(p>=q && p >= r){
            System.out.println(q+r);
        }else if(q >= p && q >= r){
            System.out.println(p+r);
        }else{
            System.out.println(p+q);
        }
    }
}

Measured memory_bytes: 23252
#include <iostream>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	int n,en[3];
	cin>>n;
	string s[n];
	for(int i=0;i<3;i++){
		cin>>en[i];
	}
	for(int i=0;i<n;i++){
		cin>>s[i];
	}
	int la[n+1][3];
	la[n][0]=la[n][1]=la[n][2]=n;
	char res[n];
	for(int i=n-1;i>=0;i--){
		for(int j = 0;j<3;j++)la[i][j] = la[i+1][j];
		la[i][s[i][0]-'A']=i;
		la[i][s[i][1]-'A']=i;
	}
	for(int i=0;i<n;i++){
		int i1 = s[i][0]-'A';
		int i2 = s[i][1]-'A';
		int i3;
		for(i3=0;i3==i1||i3==i2;i3++);
		if(en[i1]==0&&en[i2]==0){
			cout<<"No\n";
			return 0;
		}
		if(en[i1]==1&&en[i2]==1){
			if(la[i][i3]<n){
				int wa;
				if(s[la[i][i3]][0]=='A'+i3)wa = s[la[i][i3]][1] - 'A';
				else wa = s[la[i][i3]][0] - 'A';
				res[i] = 'A'+wa;
				en[wa]++;
				if(i1!=wa)en[i1]--;
				else en[i2]--;
			}
			else {
				res[i] = 'A'+i2;
				en[i2]++;
				en[i1]--;
			}
		}
		else if(en[i1]>en[i2]){
			res[i] = 'A'+i2;
			en[i2]++;
			en[i1]--;
		}
		else{
			res[i] = 'A'+i1;
			en[i1]++;
			en[i2]--;
		}
	}
	cout<<"Yes\n";
	for(int i=0;i<n;i++)cout<<res[i]<<endl;
	
	return 0;
}

Measured memory_bytes: 6740
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,i;
    cin>>N;
    bool ans=true,flag=false;
    vector<int> num(N);
    for(i=0;i<N;i++){
        cin>>num.at(i);
    }
    for(i=0;i<N;i++){
        if(num.at(i)%2==0){
            if(num.at(i)%3==0||num.at(i)%5==0);
            else {
                ans=false;
                flag=true;
                break;
            }
        }
        if(flag) break;
    }
    if(ans) cout<<"APPROVED"<<endl;
    else cout<<"DENIED"<<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int x = 0, ans = 0;
    rep(i, n) x ^= a[i];
    for (int k = 30; k > 0; k--)
    {
        int num = (1 << k) - 1, bit = 1 << (k - 1);
        bool f = false;
        rep(i, n) if ((a[i] ^ (a[i] - 1)) == num) f = true;
        //cout << f << " " << !(!(x & bit)) << endl;
        if (f && (x & bit))
            ans++, x ^= num;
    }
    if (x != 0)
        ans = -1;
    cout << ans << endl;
}

Measured memory_bytes: 1024