akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
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; }
//#define int long long

int n;
vector<int> g[100100];
map<pair<int, int>, int> mp;
map<pair<int, int>, int> mp1;

void dfs(int x, int p, int pnum) {
    int num = 1;
    for(auto y: g[x]) {
        if(y == p) continue;
        if(num == pnum) num ++;

        mp[make_pair(x, y)] = num;
        mp[make_pair(y, x)] = num;
        dfs(y, x, num);
        num ++;
    }
}

int cnt;

void solve() {
	cin >> n;
    int deg[100100];
    rep(i, n) deg[i] = 0;
    vector<P> p;
    //vector<pair<pair<int, int>, int>> q;
    vector<int> ans(n, 0);
    rep(i, n - 1) {
        int a, b; cin >> a >> b; --a; --b;
        g[a].pb(b);
        g[b].pb(a);
        p.pb(make_pair(a, b));
        mp1[make_pair(a, b)] = i;
        mp1[make_pair(a, b)] = i;
        deg[a] ++;
        deg[b] ++;
    }
    cnt = 0;
    rep(i, n) {
        if(cnt < deg[i]) cnt = deg[i];
    }
    cout << cnt << endl;
    dfs(0, -1, -1);
    rep(i, n - 1) {
        int a = p[i].fr, b = p[i].sc;
        //debug(a);
        //debug(b);
        cout << mp[make_pair(a, b)] << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 26356
import math

a = [list(map(int,input().split())) for _ in range(3)]#2次元配列の入力
n = int(input())
b = [int(input()) for _ in range(n)]#n回入力(行変え)
flag = [[False] * 3 for _ in range(3)]#判定のためのbool変数

for i in range(3):
    for j in range(3):
        if a[i][j] in b:
            flag[i][j] = True#aにbが含まれていたらflag[][]をTrueに
#ここから判別していく
#行
for row in flag:
    if all(row): #組み込み関数all()
        """
        組み込み関数all()は、()の中のすべての要素がTrueならTrueを返す
        """
        print('Yes')
        exit()
#列
for i in range(3):
    tmp = 0
    for j in range(3):
        if flag[j][i]:
            tmp += 1
    
    if tmp == 3:
        print('Yes')
        exit()
#斜め
if flag[0][0] and flag[1][1] and flag[2][2]:
    print('Yes')
    exit()
if flag[0][2] and flag[1][1] and flag[2][0]:
    print('Yes')
    exit()
print('No')


Measured memory_bytes: 3064
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

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

s = input()
t = s[::-1]

n = len(s)

ans = 0
for i in range(n):
    if s[i] != t[i]:
        ans += 1

print(ans//2)

Measured memory_bytes: 38384
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
ll mod = pow(10,9) + 7;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}
int main() {
	int a; cin >> a;
	cout << (a < 1200? "ABC": "ARC") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

  int n;
  cin >> n;
  vector<P> v(n);
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    v[i] = make_pair(b, a);
  }
  sort(v.begin(), v.end());
  ll cur = 0;
  rep(i, 0, n) {
    cur += v[i].second;
    if (cur > v[i].first) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
}


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

using namespace std;

int main() {
    int n,m,ans=0;
    cin >> n >> m;

    bool t[n];
    for (int i=0;i<n;i++) t[i] = true;

    long long h[n];
    for (int i=0;i<n;i++) cin >> h[i];

    int w1, w2;
    for (int i=0;i<m;i++) {
        cin >> w1 >> w2;
        if (h[w1-1] > h[w2-1]) t[w2-1] = false;
        else if (h[w1-1] < h[w2-1]) t[w1-1] = false;
        else {
            t[w1-1] = t[w2-1] = false;
        }
    }

    for (int i=0;i<n;i++) if (t[i]) ans++;

    cout << ans << endl;
}


Measured memory_bytes: 4512
#include <stdio.h>

#define N 200000


main(){
  int n,i,R[N],maxv,minv;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&R[i]);
  }
  
  maxv = R[1]-R[0];
  minv = R[0];
  for(i=1;i<n;i++){
    if(maxv<R[i]-minv) maxv = R[i]-minv;
    if(minv>R[i])   minv = R[i];
    
  }
  
  printf("%d\n",maxv);
  return 0;
}

Measured memory_bytes: 1376
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>


using namespace std;
using ll = long long;

template<int V>
struct MinConstFlow {
    using C = int;
    using T = int;
    const T INF = 1<<28;
    using P = pair<T, int>;
    struct Edge {
        int to, rev;
        C cap;
        T cost;
    };
    vector<Edge> g[V];
    T h[V], dist[V];
    int pv[V], pe[V];

    void add(int from, int to, C cap, T cost) {
        g[from].push_back(Edge{to, (int)g[to].size(), cap, cost});
        g[to].push_back(Edge{from, (int)g[from].size()-1, 0, -cost});
    }

    T exec(int s, int t, T mc) {
        T res = 0;
        fill_n(h, V, 0);
        while (true) {
            fill_n(dist, V, INF);
            dist[s] = 0;
            priority_queue<P, vector<P>, greater<P>> que;
            que.push(P(0, s));
            while (!que.empty()) {
                P p = que.top(); que.pop();
                int v = p.second;
                if (dist[v] < p.first) continue;
                for (int i = 0; i < (int)g[v].size(); i++) {
                    Edge &e = g[v][i];
                    if (e.cap && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to]) {
                        dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
                        pv[e.to] = v;
                        pe[e.to] = i;
                        que.push(P(dist[e.to], e.to));
                    }
                }
            }
            if (dist[t] == INF) {
                return res;
            }
            for (int v = 0; v < V; v++) {
                h[v] += dist[v];
            }

            if (mc < h[t]) return res;
            mc -= h[t];
            res++;

            for (int v = t; v != s; v = pv[v]) {
                Edge &e = g[pv[v]][pe[v]];
                e.cap--;
                g[v][e.rev].cap++;
            }
        }

    }
};


const int MN = 220;
MinConstFlow<2*MN> mcf;

int main() {
    int a, b, k;
    cin >> a >> b >> k;
    int g[a][b];
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++) {
            g[i][j] = 2;
        }
    }
    for (int i = 0; i < a; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < b; j++) {
            if (s[j] == '0') {
                g[i][j]--;
            }
        }
    }
    for (int i = 0; i < b; i++) {
        string s;
        cin >> s;
        for (int j = 0; j < a; j++) {
            if (s[j] == '0') {
                g[j][i]--;
            }
        }
    }
    // from to cap cost
    int sv = a+b, tv = a+b+1;
    for (int i = 0; i < a; i++) {
        mcf.add(sv, i, 1, 0);
    }
    for (int i = 0; i < b; i++) {
        mcf.add(a+i, tv, 1, 0);
    }
    for (int i = 0; i < a; i++) {
        for (int j = 0; j < b; j++) {
            mcf.add(i, a+j, 1, g[i][j]);
        }
    }
    cout << mcf.exec(sv, tv, k) << endl;
}

Measured memory_bytes: 4868
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

 
int main() {
   ll a,b;
   cin>>a>>b;
   if((a-b)%2)cout<<"IMPOSSIBLE"<<endl;
   else cout<<abs(b-a)/2+min(a,b)<<endl;
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    cout << setprecision(20);
    ll n;
    string s;
    cin >> n;
    cin >> s;

    unordered_set<string> d1;
    unordered_set<string> d2;
    unordered_set<string> d3;
    rep(i, s.length()){
        for(auto c : d2){
            d3.insert(c+s[i]);
        }
        for(auto c : d1){
            d2.insert(c+s[i]);
        }
        d1.insert(string{s[i]});
    }
    cout << d3.size() << endl;
}


Measured memory_bytes: 384
N = int(input())
S = list()
for i in range(N) :
	s = input()
	S.append(s)
		
while True :
	if(len(S) == 0) :
		print("YES")
		break
	elif("A" in S and "Un" in S) :
		if(S.index("A") < S.index("Un")) :
			del S[S.index("A")]
			del S[S.index("Un")]
		else :
			print("NO")
			break
	else :
		print("NO")
		break


Measured memory_bytes: 5596
using System;

public class hello
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim();
        for (int i = 0; i < s.Length; i++)
        {
            var a = Convert.ToInt32(s[i]) - 3;
            if (a < 65) a += 26;
            Console.Write(Convert.ToChar(a));
        }
        Console.WriteLine();
    }
}

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

int main(int argc, char const *argv[])
{
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long long ans = 5000 * 1e5 * 20;
    for(int c_ab = 0; c_ab <= 2 * max(x, y); c_ab+=2) {
        long long cost = c_ab * c + max(0, (x - c_ab / 2)) * a + max(0, (y - c_ab / 2)) * b;
        ans = min(ans, cost);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>

using namespace std;

int main(){
	int N, K, Q;
  	cin >> N >> K >> Q;
  	vector<string> ans(N);
  	map<int, int> m;
  	for(int i = 0; i < Q; i++){
      	int a;
    	cin >> a;
      	a--;
      	m[a]++;
    }
  	for(int i = 0; i < N; i++){
    	if((K-Q+m[i]) > 0) ans[i] = "Yes";
      	else ans[i] = "No";
    }
  	for(int i = 0; i < N; i++){
    	cout << ans[i] << endl;
    }
}

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

int main() {
  int a, b;
  cin >> a >> b;
  if(a + b == 15) {
    cout << "+" << endl;
  } else if (a * b == 15) {
    cout << "*" << endl;
  } else {
    cout << "x" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  long int sum=0;

  //cout << N <<endl;
  //sum= N*(N-1))/2;  
  sum=N;
  //cout << sum << endl;
  sum*=(N-1);
  //cout << sum << endl;
  sum/=2;
  cout << sum << endl;
  
  return 0;
} 


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n, m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x, y) memset((x),(y),sizeof (x))
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define    outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a, b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double> point;
typedef tuple<int, int, int> line;
typedef pair<point, point> segment;
typedef vector<point> polygon;
const int N = 3e3 + 5, M = 20 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;
ll memo[N][N][2];
int arr[N], n;
ll solve(int l, int r, int plyr)
{
    if(l > r)
        return 0;
    ll &ret = memo[l][r][plyr];
    if(~ret)
        return ret;
    ret = -LLMX;
    ret = ((!plyr)? max(solve(l + 1, r, 1 - plyr) + ((plyr)? -arr[l] : arr[l]), solve(l, r - 1, 1 - plyr) + ((plyr)? -arr[r] : arr[r]))
            : min(solve(l + 1, r, 1 - plyr) + ((plyr)? -arr[l] : arr[l]), solve(l, r - 1, 1 - plyr) + ((plyr)? -arr[r] : arr[r])));
    //cout << l << " " << r << " " << ret << " " << plyr << endl;
    return ret;
}
int main()
{
    MuhammedAly
    mem(memo, -1);
    cin >> n;
    for(int i = 0 ; i < n ; i++)
        cin >> arr[i];
    cout << solve(0, n - 1, 0);
    return 0;
}

Measured memory_bytes: 141568
#include<bits/stdc++.h>
using namespace std;
#define  vi vector<long long int>
#define  set1 set<long long int>
#define  pb push_back
#define  map1 map<long long int,long long int>
#define  ll long long int
#define  mp make_pair
#define  inf 1e17
#define  minf INT_MIN
#define  setbits(x) __builtin_popcountll(x)
#define  pres(x,y) fixed<<setprecision(y)<<x
#define  pair1 pair<long long int,long long int>
#define  mk(arr,n,type) type *arr=new type[n];
#define  mod 1000000007
#define  pi  3.1415926535897932384626433832
#define  ins insert
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
//find_by_order() --> returns an iterator to the k-th largest element (counting from zero)
//order_of_key()  --> the number of items in a set that are strictly smaller than our item.
#define  w(t) long long int t;t=1;while(t--)

ll dp[100005];

ll solve1(ll a[], ll id, ll k) {

	if (id == 1) {
		return 0;
	}
	if (dp[id] != -1) {
		return dp[id];
	}
	ll mn = inf;
	for (ll i = id - 1; i >= 1 && i >= id - k; i--) {
		mn = min(mn, abs(a[i] - a[id]) + solve1(a, i, k));
	}

	return dp[id] = mn;

}
void solve() {

	ll n, k;
	cin >> n >> k;
	ll a[n + 1];
	for (ll i = 1; i <= n; i++) {
		cin >> a[i];
	}
	memset(dp, -1, sizeof(dp));
	cout << solve1(a, n, k) << "\n";
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("inp.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	w(t) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 12956
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ARounding {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int x, a;
        cin >> x >> a;
        if (x < a) {
            cout << 0 << endl;
        }
        else {
            cout << 10 << endl;
        }


    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ARounding solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>

using namespace std;
int main()
{
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++)
    {
        cin >> P[i];
    }

    sort(P.begin(), P.end(), [](int a, int b) { return a > b; });

    P[0] /= 2;
    cout << accumulate(P.begin(), P.end(), 0) << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

var sc *bufio.Scanner = func() *bufio.Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	return sc
}()

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextIntsCh(n int) <-chan int {
	ints := make(chan int, n)
	go func() {
		defer close(ints)
		for i := 0; i < n; i++ {
			ints <- nextInt()
		}
	}()
	return ints
}
func main() {
	n := nextInt()
	sum := 0.0
	for i := range nextIntsCh(n) {
		v := (1 / float64(i))
		sum += v
	}
	fmt.Println(1 / sum)
}


Measured memory_bytes: 640
import bisect
n = int(input())
L = list(map(int,input().split()))

#棒の長さa,bを固定して、あとはc<a+bとなるcを2部探索で探せばよい
L.sort()
ans = 0
for i in range(n-2):
    a = L[i]
    for j in range(i+1,n):
        b = L[j]
        tmp = bisect.bisect_left(L,a+b)
        if j<tmp:
            ans+=tmp-j-1
print(ans)

Measured memory_bytes: 3316
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, k) = (v[0], v[1]);
    let mut p = read_vec::<usize>();
    p.sort();
    let ans = p.into_iter().take(k).sum::<usize>();
    println!("{}", ans);
}

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 read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2152
#include <bits/stdc++.h>
using namespace std;
int main() {
    int A, B;
    cin >> A >> B;

    int Temp1, Temp2, Temp3;

    Temp1 = A + A - 1;
    Temp2 = B + B - 1;
    Temp3 = A + B;

    int MAX;
    if(Temp1 >= Temp2 && Temp1 >= Temp3) {
        MAX = Temp1;
    } else if(Temp2 >= Temp3 && Temp2 >= Temp1) {
        MAX = Temp2;
    } else
    {
        MAX=Temp3;
    }
    cout << MAX << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int n, a;
  cin >> n >> a;
  n %= 500;
  cout << (n <= a ? "Yes" : "No") << endl;
}



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

// マクロ
// forループ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(ll)(b);i--)
// xにはvectorなどのコンテナ
#define ALL(x) (x)begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
// 出力
#define PRINT(x) cout<<(x)<<endl
#define PRINTA(x,n) REP(i,n)PRINT(x[i])
// 定数
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
// 略記
#define PB push_back
#define MP make_pair

int N, M;

int a[100009], b[100009];

int main() {
    cin >> N >> M;
    if (M % 2 == 0) {
        REP(i, M / 2) {
            a[i] = 1 + i;
            b[i] = M - i;
        }
        REP(i, M / 2) {
            a[i + M / 2] = M + 1 + i;
            b[i + M / 2] = 2 * M + 1 - i;
        }
    } else {
        REP(i, M / 2) {
            a[i] = 1 + i;
            b[i] = M - i;
        }
        REP(i, M / 2 + 1) {
            a[i + M / 2] = M + 1 + i;
            b[i + M / 2] = 2 * M + 1 - i;
        }
    }
    REP(i, M) printf("%d %d\n", a[i], b[i]);
    return 0;
}

Measured memory_bytes: 4160
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,k,a;
    std::deque<int> deq;
    cin>>n>>k;
    for (int i=0;i<n;i++) {
        cin>>a;
        deq.emplace_back(a);
    }
    sort(deq.begin(),deq.end());
    int sum=0;
    for (int i=0;i<k;i++) {
        sum+=deq[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3632
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define int long long

using namespace std;
using namespace __gnu_pbds;

template <class T> using ordered_set =
tree<T, null_type, less<T>,
rb_tree_tag, tree_order_statistics_node_update>;

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  int a, b, t;
  cin >> a >> b >> t;
  cout << t / a * b;
  return 0;
}


Measured memory_bytes: 256
use std::io;
use std::str::FromStr;

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

fn input_vec() -> Vec<i64> {
    let mut line: String = String::new();
    io::stdin().read_line(&mut line);
    line.split_whitespace().map(|s| s.parse().unwrap()).collect()
}

fn main() {
    let n: usize = input();
    let mut a_vec = input_vec();
    for i in 0..n {
        a_vec[i] = a_vec[i] - i as i64 - 1;
    }
    a_vec.sort();
    let b: i64;
    if n % 2 == 0 {
        b = (a_vec[n / 2 - 1] + a_vec[n/2])/2
    } else {
        b = a_vec[n/2];
    }
    let mut ans = 0;
    for a in a_vec {
        ans += (a - b).abs();
    }
    println!("{}", ans);
}


Measured memory_bytes: 5756
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(void){
  int n;
  scanf("%d",&n);
  char s[n][11];
  for(int i=0;i<n;i++){
	scanf("%s",s[i]);
  }
  qsort(s,n,sizeof(char)*11,strcmp);
  int count=1;
  for(int i=0;i<n-1;i++){
    	if(strcmp(s[i],s[i+1])!=0)count++;
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 5696
//ABC119B
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector <double> x(n);
	vector <string> u(n);
	double sigma = 0;
	for(int i=0;i<n;i++){
		cin >> x.at(i) >> u.at(i);
		if(u.at(i) == "JPY"){
			sigma += x.at(i);
		}else{
			sigma += 380000.0 * x.at(i);
		}
	}
	cout << sigma << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,i,b,h=0,r=0;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>b;
    if(b>=h){
      h=b;
      r++;
    }
  }
  cout<<r<<endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
h = int(input())

exp = 0
while h > 1:
    h //= 2
    exp += 1
print(2 ** (exp + 1) - 1)


Measured memory_bytes: 3312
/*********************************
*include
*********************************/
#include <stdio.h>

/*********************************
*function prototype
*********************************/


/*********************************
*function
*********************************/
int main( void )
{
	int a;
	int b;

	scanf( "%d %d", &a, &b );

	if ( a < b ) {
		printf( "a < b\n" );
	} else if ( a > b ) {
		printf( "a > b\n" );
	} else {
		printf( "a == b\n" );
	}

	return ( 0 );
}

Measured memory_bytes: 580
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int main(void){
	int r,c,i,j;cin>>r>>c;
	int ar[100][100]={0};
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){cin>>ar[i][j];}
	}
	for(i=0;i<r;i++){
		int wa=0;
		for(j=0;j<c;j++){wa+=ar[i][j];cout<<ar[i][j]<<" ";}
		cout<<wa<<endl;
	}
	int all=0;
	for(j=0;j<c;j++){
		int wa=0;
		for(i=0;i<r;i++){wa+=ar[i][j];}
		all+=wa;
		cout<<wa<<" ";
	}
	cout<<all<<endl;
	RE;
}


Measured memory_bytes: 3128
import java.util.*;
public class Main {
	public static void main(String[] args) {
		 Scanner scan = new Scanner(System.in);
		 int H;	//縦
		 int W;	//横
		 while(true){
			 H = Integer.parseInt(scan.next());
			 W = Integer.parseInt(scan.next());
			 if(H == 0 && W == 0){
				 //HとWが0の時、終了。
				 break;
			 }//if
			 //--- 出力 ---
			 for (int i = 0; i < H; i++ ){
				 for (int j = 0; j < W; j++ ){
					 if((i + j) % 2 == 0){
						 //(i+j)/2の答えが奇数だったら"#"、偶数だったら"."
						 System.out.print("#");
					 }else{
						 System.out.print(".");
					 }//if
				 }//for
				 System.out.println();
			 }//for
			 System.out.println();
		 }//while 
	}
}

Measured memory_bytes: 26848
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include <bits/stdc++.h>

using namespace std;

/**
 * main
 */
int main () {
  long long N, A, B;
  scanf("%lld %lld %lld", &N, &A, &B);

  if (A + B == 0) {
    printf("0\n");
  } else {
    long long q = N / (A + B);
    long long r = N % (A + B);

    printf("%lld\n", q * A + min(A, r));
  }
}


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



int main(){
    int n;
    string str;
    set<string> arr;
    cin >> n;

    for(int i = 0; i < n; i++){
        cin >> str;
        arr.insert(str);
    }

    printf("%lu\n", arr.size());

    return 0;

    
}

Measured memory_bytes: 19324
import sys
sys.setrecursionlimit(10**9)

N,Q = map(int,input().split())
edges = [list(map(int,input().split())) for _ in range(N-1)]
PX = [list(map(int,input().split())) for _ in range(Q)]

c = [0]*N
res = [-1]*N
for p,x in PX:
    c[p-1] += x

def BFS(start,edges,N,c):
    roots=[[] for _ in range(N)]
    for a,b in edges:
        roots[a-1]+=[(b-1,c[b-1])]
    queue=[]
    queue.append(start)
    res[start] = c[start]
    while queue:
        label = queue.pop()
        for i,c in roots[label]:
            if res[i] == -1:
                res[i]= res[label]+c
                queue += [i]
    return res
print(*BFS(0,edges,N,c))

Measured memory_bytes: 121432
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

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

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;

int main()
{
    int a,b;
    cin >> a >> b;
    if(a % b == 0){
        cout << a/b;
    }else{
        cout << a/b + 1;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(min(b,d)-max(a,c)>=0)cout<<min(b,d)-max(a,c)<<endl;
  else cout<<'0'<<endl;
  return 0;
}


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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define repll(i,n) for(ll i = 0; i < n; i++)
#define REPll(i,n) for(ll i = 1; i < n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl "\n"
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  char a;
  cin >> a;
  char ans = a + 1;
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		double r = scan.nextInt();
		double g = scan.nextInt();
		double point = g - r;
		point = r + (2 * point);
		System.out.println((int)point);
	}
}

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

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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
broken = set()
for _ in range(M):
    a = int(input())
    broken.add(a)

INF = 10 ** 9 + 7

memo = [None for _ in range(N + 1)]
memo[0] = 1
memo[1] = 0 if 1 in broken else 1
for i in range(2, N + 1):
    if i in broken:
        memo[i] = 0
    else:
        memo[i] = (memo[i - 2] + memo[i - 1]) % INF

print(memo[N])


Measured memory_bytes: 11968
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<numeric>
using namespace std;

#define R(i,s,n) for(int i=s;i<n;i++)
#define D(i,n,s) for(int i=n-1;i>=s;i--)
typedef pair<int,int> P;

const int MAX_DW = 10;
const int INF = 1e+9;

int D,W;
int ike[MAX_DW][MAX_DW];
int mn,mx,tmp;

void solve();

int main() {

  while(cin>>D>>W && (D || W)) {
    R(i,0,D) {
      R(j,0,W) cin>>ike[i][j];
    }

    solve();
  }

  return 0;
}

void solve() {
  mx = 0;

  R(high,3,D+1) { //池の縦の長さ
    R(wide,3,W+1) { //池の横の長さ
      R(shigh,0,D-high+1) { //池の始点の縦の位置
        R(swide,0,W-wide+1) { //池の始点の横の位置
          //変数初期化
          tmp = 0;
          mn = INF;

          //周りのmin算出
          R(i,0,high) {
            R(j,0,wide) {
              if(i==0 || i==high-1 || j==0 || j==wide-1) mn = min(mn,ike[shigh+i][swide+j]);
            }
          }
          if(mn == 0) continue;

          //池の中探索
          R(i,1,high-1) {
            R(j,1,wide-1) {
              if(mn>ike[shigh+i][swide+j]) tmp+=(mn-ike[shigh+i][swide+j]);
              else goto CONT;
            }
          }
          if(tmp>mx) mx = tmp;  //更新
          CONT: ;
        } //swideのループ
      } //shighのループ
    } //wideのループ
  } //highのループ

  cout<<mx<<endl;
}



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

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

  if (x=="Sunny") {
    cout << "Cloudy" << endl;
  }

  if(x=="Cloudy"){cout<<"Rainy"<<endl;}
  if(x=="Rainy"){cout<<"Sunny"<<endl;}
}

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

using namespace std;

int main(){
  string str,com,p;
  int q,a,b;
  cin>>str;
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>com>>a>>b;
    if(com =="print"){
      cout<<str.substr(a,b-a+1)<<endl;
  }
    else if(com =="reverse"){
      string tmp=str.substr(a,b-a+1);
      int n=tmp.size();
      for(int i=0;i<n;i++) str[i+a]=tmp[n-1-i];
    }
    else if(com=="replace"){
      cin>>p;
      str=str.replace(a,b-a+1,p);
    }
  }

  return 0;
}
    



Measured memory_bytes: 3212
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int main()
{
    she_told_me_dont_worry
    ll n, p;
    cin>>n>>p;
    ll i;
    map< ll, ll > m;
    string s;
    cin>>s;
    ll a[n+5] = {};
    ll ans = 0;
    if(p == 2 || p == 5)
    {
        FORD(i, n-1, 0)
        {
            if((s[i]-'0')%p == 0)
                ans += i+1;
        }
        cout<<ans<<endl;
        return 0;
    }
    ll base = 1;
    FORD(i, n-1, 0)
    {
        ll cur = s[i] - '0';
        cur *= base;
        cur %= p;
        if( i < n-1)
            a[i] = a[i+1];
        a[i] += cur;
        a[i] %= p;
        base *= 10;
        base %= p;
    }
    // FOR0(i, n) cout<<a[i]<<" ";
    // cout<<endl;
    m[0]++;
    FORD(i, n-1, 0)
    {
        if(m.find(a[i]) != m.end())
            ans += m[a[i]];
        m[a[i]]++;
    }
    cout<<ans<<endl;
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 2580
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  string s;
  cin >> s;
  int m;
  scanf("%d",&m);
  int n = sz(s);
  rep(i,n) {
    if (s[i] == 'a') continue;
    int x = ('z'-s[i])+1;
    if (m < x) continue;
    s[i] = 'a';
    m -= x;
  }
  m %= 26;
  s.back() = (s.back()-'a'+m)%26+'a';
  cout<<s<<endl;
  return 0;
}







Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n) for(ll i=a;i<n;i++)
#define even(x) (((x)%(2))==(0))
#define odd(x) (((x)%(2))==(1))
#define meme(x) memset(x, 0, sizeof(x))
#define mod 1000000007

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


int main() {
    
    int n;
    cin>>n;
    int x=n%10;
    
    if(x==3)cout<<"bon";
    else if(x==0 || x==1 || x==6 || x==8)cout<<"pon";
    else cout<<"hon";
    
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>


 long long int max(long long int a ,long long int b){
  if(a<b){
    return b;
  }
  return a;
}

int compare(const void *p0,const void *p1){
  long long int *P0=(long long int*)p0;
  long long int *P1=(long long int*)p1;
  if(*P0>*P1)return 1;
  if(*P0<*P1)return -1;
  return 0;
}


int main(){
  long long int p=0,q=0,r=0;
  int i,n=0,m=0,w;
  scanf("%d %d",&n,&m);
  long long int x[n];
  long long int y[n];
  long long int z[n];
  for (i = 0; i <n; i++) {
    scanf("%lld %lld %lld",&x[i],&y[i],&z[i]);
  }

  for (int i=-1;i<=1;i+=2){
    for(int j=-1;j<=1;j+=2){
      for(int k=-1;k<=1;k+=2){
        p=0;
        long long int a[n];
        for (int l = 0; l < n; l++) {
          a[l]=i*x[l]+j*y[l]+k*z[l];
        }
        qsort(a,n,sizeof(long long int),compare);
    /*    for (int l = n-1; l>=0; l--) {
           printf("%lld ",a[l]);
         }
         printf("\n");*/
        for (int l = n-1; l >n-m-1; l--) {
          p+=a[l];
        }
        q=max(p,q);
      }
    }
  }

  printf("%lld",q);
  return 0;
}


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

int main() {
    int N;
    string S;
    cin >> N >> S;
    int count = 0;
    for (int i = 0;i < N;i++){
        if (S[i] == 'A'){
            if(S[i+1] == 'B'){
                if(S[i+2] == 'C'){
                    count++;
                }
            }
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

int main()
{
    // freopen("filename.in","r",stdin);
    // freopen("filename.out","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;

    ll pattern = 7;
    ll cnt = 1;
    ll ans = -1;
    for(ll i=1; i<=n; i++){
        if(pattern % n == 0){
            ans = cnt;
            break;
        }else{
            pattern = (pattern*10 + 7)%n;
            cnt++;
        }
    }
    cout<<ans<<"\n";

    return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;
int e[15][15];
int main() {
	while (1) {
		int d, w; cin >> d >> w;
		if (d == 0 && w == 0)break;
		for (int i = 0; i < d; i++) {
			for (int j = 0; j < w; j++) {
				cin >> e[i][j];
			}
		}
		int Max = 0;
		for (int i = 1; i < d - 1; i++) {
			for (int j = 1; j < w - 1; j++) {
				for (int k = i; k < d - 1; k++) {
					for (int l = j; l < w - 1; l++) {
						int Min = 100;
						for (int a = i - 1; a <= k + 1; a++) {
							Min = min(Min, e[a][j - 1]);
							Min = min(Min, e[a][l + 1]);
						}
						for (int b = j - 1; b <= l + 1; b++) {
							Min = min(Min, e[i - 1][b]);
							Min = min(Min, e[k + 1][b]);
						}
						int cnt = 0;
						bool flag = true;
						for (int c = i; c <= k; c++) {
							for (int d = j; d <= l; d++) {
								cnt += (Min - e[c][d]);
								if (e[c][d] >= Min) {
									flag = false;
									break;
								}
							}
						}
						if (flag == true)Max = max(Max, cnt);
					}
				}
			}
		}
		cout << Max << endl;
	}
}



Measured memory_bytes: 3080
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

string S[200009];

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

	int N; cin >> N;
	for (int i = 0; i < N; i++) cin >> S[i];
	sort(S, S + N);
	int m = 0;
	for (int i = 0; i < N; i++) {
		int cnt = 1;
		while (i < N - 1 && S[i] == S[i + 1]) {
			cnt++;
			i++;
		}
		m = max(m, cnt);
	}
	vector<string> V;
	for (int i = 0; i < N; i++) {
		int cnt = 1;
		while (i < N - 1 && S[i] == S[i + 1]) {
			cnt++;
			i++;
		}
		if (cnt == m) V.push_back(S[i]);
	}
	sort(V.begin(), V.end());
	for (int i = 0; i < V.size(); i++) cout << V[i] << endl;


	return 0;
}

Measured memory_bytes: 14576
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <array>
#include <set>
#include <map>
#include <queue>
#include <tuple>
#include <unordered_set>
#include <unordered_map>
#include <functional>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
using namespace std;
template <class T> inline void setmax(T & a, T const & b) { a = max(a, b); }
template <class T> inline void setmin(T & a, T const & b) { a = min(a, b); }

const double eps = 1e-10;
typedef complex<double> point;
struct line { point s, t; };
double cross(point p, point q) { return imag(conj(p) * q); }
int ccw(point a, point b, point c) { double z = cross(b - a, c - a); return z > eps ? 1 : z < - eps ? -1 : 0; }
point intersection(line a, line b) {
    double p = cross(a.t - a.s, b.t - b.s);
    double q = cross(a.t - a.s, a.t - b.s);
    return (q / p) * (b.t - b.s) + b.s;
}

int main() {
    while (true) {
        // input
        int w, h, n; scanf("%d%d%d", &w, &h, &n);
        if (w == 0 and h == 0 and n == 0) break;
        vector<point> p(2*n);
        repeat (i, 2*n) {
            int x, y; scanf("%d%d", &x, &y);
            p[i] = point(x, y);
        }
        p.push_back(point(0, 0));
        p.push_back(point(0, h));
        p.push_back(point(w, 0));
        p.push_back(point(w, h));
        // solve
        auto x = [&](complex<double> const & p) { return real(p); };
        auto y = [&](complex<double> const & p) { return imag(p); };
        line left  = { point(0, 0), point(0, h) };
        line right = { point(w, 0), point(w, h) };
        auto does_split = [&](line l) {
            array<int, 3> cnt = {};
            repeat (i, 2*n) {
                cnt[ccw(l.s, l.t, p[i]) + 1] += 1;
            }
            return cnt[0] + cnt[1] >= n and cnt[1] + cnt[2] >= n;
        };
        vector<double> events;
        repeat (j, p.size()) repeat (i, j) {
            if (x(p[i]) == x(p[j])) continue;
            line l = { p[i], p[j] };
            if (does_split(l)) {
                double y_left = y(intersection(l, left));
                if (- eps < y_left and y_left < h + eps) events.push_back(y_left);
            }
        }
        whole(sort, events);
        double result = 0;
        double yl = 0;
        repeat (i, events.size()) {
            double dy = events[i] - yl;
            if (dy < eps) continue;
            double yrr = 0;
            double yrl = h;
            repeat (j, p.size()) {
                if (x(p[j]) < eps) continue;
                line l = { point(0, yl + dy/2), p[j] };
                if (does_split(l)) {
                    double yj = y(intersection(l, right));
                    if (yj < h + eps) setmax(yrr, yj);
                    if (yj >   - eps) setmin(yrl, yj);
                }
            }
            if (yrl < yrr) {
                result += dy * (yrr - yrl);
            }
            yl = events[i];
        }
        // output
        printf("%.10lf\n", result / pow(h, 2));
    }
    return 0;
}

Measured memory_bytes: 2660
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
using ll = long long;
int main(){
    int m,d,cnt=0;
    cin >> m >> d;
    rep(i,m+1)rep(j,d+1){
        if(i==0||j%10<=1||j/10<=1)continue;
        if(i==(j/10)*(j%10))++cnt;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256