akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define LAST(x) (x)[(x).size() - 1]
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(LAST(v));
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI2(K, S);
  ll ans = 0;
  for (int X = 0; X <= K; ++X) {
    for (int Y = 0; X + Y <= S && Y <= K; ++Y) {
      if (X + Y + K >= S)
        ans++;
    }
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int n;cin>>n;
    vbo color(8,false);
    int sum=0;
    rep(i,n){
        int a;cin>>a;
        bool tmp=false;
        rep(i,8){
            if(400*i<=a&&a<400*(i+1)){
                color[i]=true;
                tmp=true;
                break;
            }
        }
        if(!tmp)sum++;
    }
    int c=0;
    rep(i,8)if(color[i])c++;
    if(c==0)cout<<1<<" "<<sum<<endl;
    else cout<<c<<" "<<c+sum<<endl;
}

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

using namespace std;

int main()
{
    int n;

    while (cin >> n, n) {
        int ans = 0, s;
        int max_s, min_s;

        max_s = 0;
        min_s = 1000;
        for (int i = 0; i < n; i++) {
            cin >> s;

            ans += s;
            max_s = max(max_s, s);
            min_s = min(min_s, s);
        }

        cout << (ans - max_s - min_s) / (n - 2) << endl;
    }

    return 0;
}

Measured memory_bytes: 1160
while s=gets
  a=s.chomp.split ' '
  ls = []
  for i in 0...a.length
    c = a[i]
    if c=="+" || c=="-" || c=="*" || c=="/"
      x=ls.pop
      y=ls.pop
      if c=="+"
        ls.push y+x
      elsif c=="-"
        ls.push y-x
      elsif c=="*"
        ls.push y*x
      elsif c=="/"
        ls.push y/x
      end
    else
      ls.push c.to_f
    end
  end
  puts sprintf("%.9f",ls[0])
end

Measured memory_bytes: 8668
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <stack>
#include <queue>
#define llong long long
#define INF (__INT32_MAX__ / 2)
#define MAX_N 100000

using namespace std;
typedef pair<int, int> ipair;

int gcd(int a, int b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}


int main(int argc, char **argv) {
    int N, A[MAX_N];
    cin >> N;
    for(int i = 0; i < N; ++i)
        cin >> A[i];
    
    int L[MAX_N + 1], R[MAX_N + 1];
    L[0] = R[N] = 0;

    for(int i = 0; i < N; ++i)
        L[i + 1] = gcd(L[i], A[i]);
    for(int i = N - 1; i >= 0; --i)
        R[i] = gcd(R[i + 1], A[i]);

    int res = 0;
    for(int i = 0; i < N; ++i) {
        res = max(res, gcd(L[i], R[i + 1]));
    }

    cout << res << endl;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        int N = RInt();
        var xy = new long[N][];
        for (int i = 0; i < N; i++)
        {
            xy[i] = RLongs();
        }

        long rumax = xy[0][0] + xy[0][1];
        long rumin = xy[0][0] + xy[0][1];
        long rdmax = xy[0][0] - xy[0][1];
        long rdmin = xy[0][0] - xy[0][1];
        for (int i = 0; i < N; i++)
        {
            var ru = xy[i][0] + xy[i][1];
            var rd = xy[i][0] - xy[i][1];
            rumax = Math.Max(rumax, ru);
            rumin = Math.Min(rumin, ru);

            rdmax = Math.Max(rdmax,rd);
            rdmin = Math.Min(rdmin, rd);
        }
        long ans = 0;
        ans = Max(rumax - rumin, rdmax - rdmin);
        WriteLine(ans);
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 53936
import sys
s = input()

if len(s) < 26:
    for i in range(ord('a'), ord('z')+1):
        if not chr(i) in s:
            print(s+chr(i))
            break
elif s == 'zyxwvutsrqponmlkjihgfedcba':
    print(-1)
else:
    a = set()
    for i in range(26):
        a.add(s[25-i])
        for j in sorted(a):
            if s < s[:25-i]+j:
                print(s[:25-i]+j)
                sys.exit()


Measured memory_bytes: 9136
#include <cstdio>
#include <cstring>

const int N = 500000 + 10, S = 26;

int n;
char s[N];

int m, succ[N][S + 1], mem[S][N];

int anc[N];

int find(int x) { return anc[x] == x ? x : (anc[x] = find(anc[x])); }

inline void check(int &lhs, int rhs) {
  lhs = (!lhs || (rhs && rhs < lhs) ? rhs : lhs);
}

void meld(int x, int y) {
  for (int i = 0; i <= S; ++i) check(succ[x][i], succ[y][i]);
}

int go(int x, int y) {
  for (int i = S - 1; i >= 0; --i) if (mem[i][x] && mem[i][x] <= y) x = mem[i][x];
  return mem[0][x];
}

int main() {
  scanf(" %s%d", s + 1, &m);
  n = strlen(s + 1);
  for (int i = 1; i <= n + 1; ++i) anc[i] = i;
  for (int i = 1; i <= n; ++i) succ[i][s[i] - 'a'] = i + 1;
  for (int i = n; i > 0; --i) {
    for (int j = 1; j <= S; ++j) check(succ[i][j], succ[find(succ[i][j - 1])][j - 1]);
    if (succ[i][S]) meld(i, succ[i][S]);
  }
  for (int i = 1; i <= n; ++i) mem[0][i] = succ[i][S];
  for (int i = 1; i < S; ++i)
    for (int j = 1; j <= n; ++j)
      mem[i][j] = mem[i - 1][mem[i - 1][j]];
  for (int i = 1; i <= m; ++i) {
    int l, r;
    scanf("%d%d", &l, &r);
    puts(go(l, r) == r + 1 ? "Yes" : "No");
  }
  return 0;
}


Measured memory_bytes: 106496
#include<iostream>

using namespace std;

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

    int data[4][3][10] = {0};
    int b,f,r,v;
    
    for(int i=0; i<n; ++i){
        cin >> b >> f >> r >> v;
        data[b-1][f-1][r-1] += v;
    }
    
    for(int B=0; B<4; ++B){
        for(int F=0; F<3; ++F){
            for(int R=0; R<10; ++R){
                cout << " " << data[B][F][R];
            }
                cout << endl;
        }
        if(!(B==3)){
            cout << string(20, '#') << endl;
        }
    }
    
    return 0;
    
}


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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(s.length() < 3){
        cout << 0 << endl;
        return 0;
    }
    s += "E";
    string t = "";
    for(int i = 0; i < s.length()-1; i++){
        if(s[i] == 'B' && s[i+1] == 'C'){
            t += "D";
            i++;
        }
        else t += s[i];
    }
    long long ans = 0, cnt = 0;
    for(int i = 0; i < t.length(); i++){
        if(t[i] == 'B' || t[i] == 'C') cnt = 0;
        if(t[i] == 'A') cnt++;
        if(t[i] == 'D') ans += cnt;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 916
N,M=map(int,input().split())
x=list(map(int,input().split()))
x=sorted(x)
leng=list()

if(N>M):
    N=M
if(M==1):
    print(0)
    exit()
for i in range(0,len(x)-1):
    leng.append([x[i+1]-x[i],i])
leng=sorted(leng)

n=N
max=len(leng)-1
sets=list()
while n>1:
    n-=1
    sets.append(leng[max][1]+1)
    max-=1

for i in x:
    if(x.index(i) not in sets):
        sets.append(x.index(i))
        break
sets=sorted(sets) 
ans=0
for i in range(0,len(sets)-1):
    ans+=x[sets[i+1]-1]-x[sets[i]]

ans+=x[-1]-x[sets[-1]]

print(ans)

Measured memory_bytes: 25492
import java.io.*;
import java.util.*;

class Main {
	
	public static int[] rev_array(int[] array) {
		
		int[] res = new int[array.length];
		int j = 0;
		for (int i = array.length - 1; i >= 0; i--) {
			res[j++] = array[i];
		}
		return res;
	}
	
	public static int array_to_num (int[] num) {
		
		String str = "";
		for (int n : num) {
			str += String.valueOf(n);
		}
		return Integer.parseInt(str);
		
	}
	
	public static void main(String[] args) throws IOException {
		
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		ArrayList<Integer> ans = new ArrayList<Integer>();
		
		int n = Integer.parseInt(br.readLine());
		for (int i = 0; i < n; i++) {
			
			String str = br.readLine();
			char[] c = str.toCharArray();
			int[] num  = new int[c.length];
			for (int j = 0; j < c.length; j++) {
				num[j] = c[j] - '0';
			}
			Arrays.sort(num);
			int[] num2 = rev_array(num);
			ans.add(array_to_num(num2) - array_to_num(num));
			
		}
		
		for (int a : ans)
			System.out.println(a);
		
	}
	
}

Measured memory_bytes: 9360
#include "bits/stdc++.h"
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1188&lang=jp
using namespace std;
int dfs(int &k, const string str);
int dfs2(int &k, const string str);
int get_int(int &k, const string str);

// stage k > 1
int dfs(int&k, const string str) {
	vector<int> val;
	int ans = 0;
	while (k < str.length()) {
		if (str[k] == '[') {
			if (str[k + 1] >= '0' && str[k + 1] <= '9') {
				int x = dfs2(k, str);
				val.push_back(x);
			}
			else {
				k++;
				int x = dfs(k, str);
				val.push_back(x);
				k++;
				if (k == str.length()) {
					sort(val.begin(), val.end());
					for (int i = 0; i <= val.size() / 2;i++) {
						ans += val[i];
					}
					break;
				}
			}
		}
		if (str[k] == ']') {
			sort(val.begin(), val.end());
			for (int i = 0; i <= val.size() / 2;i++) {
				ans += val[i];
			}
			break;
		}
	}
	return ans;
}
// stage 1
int dfs2(int&k, const string str) {
	vector<int> val;
	int ret = 0;
	while (k < str.length()) {
		if (str[k] == '[') {
			k++;
			val.push_back(get_int(k, str));
		}
		else if (str[k] == ']'){
			sort(val.begin(), val.end());
			for (int i = 0; i <= val.size() / 2;i++) {
				ret += (val[i] + 1) / 2;
			}
			break;
		}
	}
	return ret;
}

int get_int(int &k, const string str) {
	int ret = 0;
	while (k < str.length()) {
		if (str[k] >= '0' && str[k] <= '9') {
			ret = ret * 10 + (str[k] - '0');
			k++;
		}
		else if (str[k] == ']') {
			k++;
			break;
		}
	}
	return ret;
}

int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	int n; cin >> n;
	for (int i = 0; i < n;i++) {
		string str; cin >> str;
		int k= 0;
		cout << dfs(k, str) << endl;
	}
}

Measured memory_bytes: 3224
def modinv(a, mod):
    b = mod
    u = 1
    v = 0
    while(b):
        t = a // b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u

    u %= mod
    return u


def modpow(a, n, mod):
    res = 1
    while(n > 0):
        if (n & 1):
            res = res * a % mod

        a = a * a % mod
        n >>= 1
    
    return res


def modcmb(n, r, mod):
    X = 1
    for i in range(n-r+1, n+1):
        X = X * i % mod

    Y = 1
    for i in range(1, r+1):
        Y = Y * i % mod
        
    res = X * modinv(Y, mod) % mod
    return res


n, a, b = map(int, input().split())
mod = 10**9 + 7

print((modpow(2, n, mod) - 1 - modcmb(n, a, mod) - modcmb(n, b, mod)) % mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long int ll;
typedef unsigned long long int ull;
 
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a,b,c;
  cin >>a>>b;
  cout <<6-(a+b);
}

Measured memory_bytes: 3548
#include<iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <string>
#include<limits>
#include<cstdlib>
#include<functional>
#include<cassert>
#include <cstdio>
#include <stack>
#include <queue>
#define fi(p) for(int i=0;i<(p);i++)
using namespace std;
int N;
int L;
int P;
const int MAX_N = 100000;
const int MAX_W = 100000;


int A[MAX_N+1];
int B[MAX_N+1];

void solve() {
	int N;
	cin >> N;
	vector<string> str;
	while (N != 0) {
		if (N % 10 == 1) {
			str.insert(str.begin(),"9");
		}
		else {
			str.insert(str.begin(), "1");
		}
		N /= 10;
	}
	for (int i = 0; i < str.size(); i++) {
		cout << str[i];
	}
	
}

int main()
{
	solve();

	int a;//止める用
	cin >> a;
	return 0;
}

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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

typedef int Weight;
typedef int Flow;

struct Edge {
  int src, dest, rev;
  Flow cap;
  Weight cost;
  bool operator < (const Edge &rhs) const {
    return cost > rhs.cost;
  }
  Edge(int s, int d) : src(s), dest(d) { ; }
  Edge(int s, int d, Weight c) : src(s), dest(d), cost(c) { ; }
  Edge(int s, int d, int r, Flow cp, Weight cst) : src(s), dest(d), rev(r), cap(cp), cost(cst) { ; }
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

vector<int> memo, res;

void dp(const Graph& g, int v, int d, int c) {
  if(memo[v] >= d || d < 0) return;
  if(memo[v] == -1) {
    res[v] = c;
  }
  memo[v] = d;
  for(Edge e: g[v]) {
    dp(g, e.dest, d - 1, c);
  }
}

int main(){
  int N, M, Q;
  cin >> N >> M;
  Graph g(N);
  REP(i,M) {
    int a, b;
    cin >> a >> b;
    --a; --b;
    g[a].push_back(Edge(a, b, 1));
    g[b].push_back(Edge(b, a, 1));
  }
  cin >> Q;
  vector<int> v(Q), d(Q), c(Q);
  REP(i,Q) {
    cin >> v[i] >> d[i] >> c[i];
    --v[i];
  }

  memo.assign(N, -1);
  res.assign(N, 0);
  for(int i = Q - 1; i >= 0; --i) {
    dp(g, v[i], d[i], c[i]);
    /*
    REP(j,N) cout << " " << memo[j];
    cout << endl;
    REP(j,N) cout << " " << res[j];
    cout << endl << endl;
    */
  }
  REP(i,N) cout << res[i] << endl;

  return 0;
}



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

int main(){
    long long a, b, c;
    cin >> a >> b >> c;
    long long cnt = 0;
    if(a == b && b == c){
        if(a % 2 == 0){
            cout << -1 << endl;
            return 0;
        }else{
            cout << 0 << endl;
            return 0;
        }
    }
    while(a % 2 == 0 && b % 2 == 0 && c % 2 == 0){
        long long ha = a / 2, hb = b / 2, hc = c / 2;
        a = hb + hc;
        b = ha + hc;
        c = ha + hb;
        cnt++;
    }
    
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define all(x) begin(x), end(x)
#define range(x) begin(x), begin(x)
#define what(x) cout << #x << ": " << x << '\n'
#define print(x) for (auto &el: x) cout << el << ' '; cout << '\n'
using namespace std;
 
template<typename S, typename T>
ostream& operator <<(ostream &os, pair<S, T> &m) { 
    os << '[' << m.first << " " << m.second << ']'; 
    return os; 
}

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

    string a, b;
    cin >> a >> b;

    int n = a.size();
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
        if (a[i] != b[i]) cnt++;
    }
    cout << cnt << endl;
    

    return 0;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  //in
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  REP(i,n) cin >> p[i];

  //
  
  int ex = 0;
  //前処理
  REP(i,k){
    int px = p[i]+1;
    ex += px;
  }
  int exmax = ex;

  REP2(i,k,n){
    ex -= p[i-k];
    ex += p[i];
    exmax = max(ex,exmax);
  }

  double ans = (double)exmax/2;

  cout << fixed << setprecision(10) << ans << endl;

  return 0;
}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
int a[45];
int main(){
  a[0]=a[1]=1;
  for(int i=2;i<45;++i){
  	a[i]=a[i-1]+a[i-2];
  }
  int n;
  cin>>n;
  cout<<a[n]<<endl;
}

Measured memory_bytes: 1160
n=int(input())
l=[['0']*10 for _ in range(n)]
for i in range(n):
        a=str(input())
        for j in range(10):
                l[i][j]=a[j]
        l[i].sort()
l.sort()

c=0
d=[]
for j in range(n-1):
        if l[j]==l[j+1] and j==n-2:
                c+=2
                d.append(c)
        elif l[j]==l[j+1]:
                c+=1
        else:
                c+=1
                d.append(c)
                c=0
aa=0
for k in range(len(d)):
        aa+=d[k]*(d[k]-1)//2
print(aa)


Measured memory_bytes: 101276
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.xise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

ll N,M,H,W,K,Q,B;
string S;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
    if (b > a) {
        a = b;
        return true;
    }
    return false;
}

bool chmn(int &a, int b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

ll f[100010];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return (((f[n] * modinv(f[r]))%mod)*modinv(f[n-r]))%mod;
}//対combination//ただしfは用意してね

/*
    f[0]=1;
    rep2(i,200005){
        f[i]=f[i-1]*i;
        f[i]%=mod;
    }
*/

ll a[100005];
vector<ll> b;
ll A[100005];

int main(){
    f[0]=1;
    rep2(i,100005){
        f[i]=f[i-1]*i;
        f[i]%=mod;
    }
    ll n,k;
    cin >> n>>k;
    rep(i,n){
        cin >> a[i];
        //a[i]%=mod;
        b.push_back(a[i]);
    }
    sort(b.begin(),b.end());
    rep(i,n){
        int c=(b[i]+mod)%mod;
        A[i]=(ll)c;
        //cerr<<A[i]<<' ';
    }
    ll ans=0;
    rep(i,n){
        ans+=A[n-1-i]*comb(n-1-i,k-1)%mod;
        ans%=mod;
        //cerr<<ans<<endl;
    }
    ll temp = 0;
    rep(i,n){

        temp+=A[i]*comb(n-i-1,k-1)%mod;

        temp%=mod;
        //cerr<<ans<<endl;
    }
    cout<<(ans - temp + mod)%mod<<endl;
    return 0;
}


Measured memory_bytes: 3448
n=int(input())
ab=[list(map(int, input().split())) for _ in range(n)]
for i in range(n):
    ab[i][1]*=-1
ab.sort()

ans=0

for i in range(n-1):
    ans+=min(ab[i+1][0]-ab[i][0],ab[i+1][1]-ab[i][1])
print(ans+ab[0][0]-ab[-1][1])


Measured memory_bytes: 27680
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int MOD=1000000007;
using namespace std;
int main(){
    ll s;
    cin>>s;
    
    ll a,b,c,d; //ad-bc=s
    
    if(s%1000000000==0){
        a=s/1000000000;
        d=1000000000;
        b=0;
        c=0;
    }
    else{
        a=s/1000000000+1;
        d=1000000000;
        b=1000000000-s%1000000000;
        c=1;
    }
    
    cout<<0<<" "<<0<<" "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;

}


Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val MOD = 998244353L
  val N, M, K = in.next().toInt  

  //
  val p = MOD
  // 素数modulo `p` の世界での割り算

  // (x ^ n) % p
  def repeatSquares(x: Long, n: Long): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % p, n/2)
    else
      (x * repeatSquares(x*x % p, n/2)) % p
  }


  // a / b
  def modDiv(a: Long, b: Long): Long = {
    val numer = a % p
    val denom = repeatSquares(b, p-2)

    (numer * denom) % p
  }

  val mc = new ModComb(N, MOD)

  var base: Long =
    if (M-1 == 0 && N >= 2)
      0L
    else
      repeatSquares(M-1, N-1)
  
  base *= M
  base %= MOD

  var ans = base

  for (i <- 1 to K) {
    base = modDiv(base, M-1)

    val hoge = (base * mc.comb(N-1, i)) % MOD

    ans += hoge
    ans %= MOD
  }

  if (M == 1 && K == N-1)
    println(M)
  else
    println(ans)
}


class ModComb(maxNum: Int, mod: Long) {

  private def repeatSquares(x: Long, n: Long): Long = {
    if(n == 0)
      1
    else if(n % 2 == 0)
      repeatSquares(x*x % mod, n/2)
    else
      (x * repeatSquares(x*x % mod, n/2)) % mod
  }

  val fact = new Array[Long](maxNum + 1)

  fact(0) = 1
  for (i <- 1 to maxNum)
    fact(i) = (i * fact(i-1)) % mod

  val factInv = new Array[Long](maxNum + 1)

  factInv(maxNum) = repeatSquares(fact(maxNum), mod-2)
  for (i <- (1 to maxNum).reverse)
    factInv(i-1) = (i * factInv(i)) % mod


  // nCk
  def comb(n: Int, k: Int): Long = {
    val numer = fact(n)
    val denom = (factInv(n-k) * factInv(k)) % mod

    (numer * denom) % mod
  }

}


class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 58608
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
    tmp0 = input[0].split(" ");
    tmp1 = input[1].split(" ");
	//文字列から10進数に変換するときはparseIntを使います
    var n = parseInt(tmp0[0], 10);
    
      var X=[];
    for(i=0;i<n;i++){
           var r = parseInt(tmp1[i], 10);
            X[i]=r;}
              var min=Math.min(...X);var max = Math.max(...X);
// console.log(min,max);
  //  console.log(X);
     var XX=[];
    
       var total=0;
      for(l=min;l<=max;l++){
               for(i=0;i<n;i++){
                      var x = X[i];
                       var a=　x-l;
                      // console.log(a);
                        total=total+a*a;
                               }
                           XX[l]=total;var total=0;
        }
   //console.log(XX);
   
  XX.splice( 0, min );
  //console.log(XX);
  var ans=Math.min(...XX);
  console.log(ans);

}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));// inputに入力データ全体が入る


Measured memory_bytes: 7372
solve :: [Int] -> String
solve [m, f, r]
    | m == -1 || f == -1 = "F"
    | 80 <= s            = "A"
    | 65 <= s            = "B"
    | 50 <= s            = "C"
    | 30 <= s            = if 50 <= r then "C" else "D"
    | otherwise          = "F"
        where s = m + f

main :: IO ()
main = interact (unlines . map solve . takeWhile (\xs -> any (\x -> x /= -1) xs) . map (map read . words) . lines)

Measured memory_bytes: 4088
import java.util.Arrays;
import java.util.Scanner;

public class Main{
    private static int n;
    public static int a[] = new int[(int) (1e5 + 1)];
    public static int b[] = new int[(int) (1e5 + 1)];
    public static int c[] = new int[(int) (1e5 + 1)];
    public static int dp[][] = new int[(int) (1e5 + 1)][4];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        for (int i = 0;i < n;i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        for (int i = 0;i < n;i++)
            for (int j = 0;j < 4;j++)
                dp[i][j] = Integer.MIN_VALUE;
            System.out.println(dp(0,3));
    }
    private static int dp(int idx,int last){
        if(idx == n)
            return 0;
        if(dp[idx][last] != Integer.MIN_VALUE)
            return dp[idx][last];
        if(last != 0)
            dp[idx][last] = Math.max(dp[idx][last], a[idx] + dp(idx + 1,0));
        if(last != 1)
            dp[idx][last] = Math.max(dp[idx][last], b[idx] + dp(idx + 1,1));
        if(last != 2)
            dp[idx][last] = Math.max(dp[idx][last], c[idx] + dp(idx + 1,2));
        return dp[idx][last];

    }
}

Measured memory_bytes: 111832
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector<pi> vpi;
typedef long double ld;
#define pb emplace_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll)x.size()
#define f first
#define s second
#define MAXN 400010
const ll MOD = 998244353;

int main(){
	string S;
	cin>>S;
	while (SZ(S)){
		if (SZ(S) == 1){
			cout<<"No";return 0;
		}
		if (S[SZ(S) - 1] == 'i' && S[SZ(S)-2] == 'h'){
			S.pop_back();
			S.pop_back();
		}else{
			cout<<"No";return 0;
		}
	}
	cout<<"Yes";
}

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

int main()
{
        int n;
        cin >> n;
        vector<int> a;
        for (int i = 0; i < n; ++i) {
                int tmp;
                cin >> tmp;
                a.push_back(tmp);
        }
        for (int i = n-1; i >= 0; --i) {
                cout << a[i];
                if (i != 0) cout << " ";
        }
        cout << endl;


}



Measured memory_bytes: 3164
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
	int X; cin >> X;
	for (int i = 1; i <= 10000; i++) {
		int m = 100 * i;
		int n = 105 * i;
		if (m <= X && X <= n) { cout << "1" << endl; return 0; }
	}
	cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string s;
int main(){
	ios::sync_with_stdio(0);
	cin>>s;
	rep(i,sz(s))
	if(s[i]=='?')
	s[i]='D';
	cout<<s;
	re 0;
}

Measured memory_bytes: 3784
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	private static Scanner in;

    private static int n;
    private static HashMap<Integer, ArrayList<Integer>> g;

    private static final int MOD = (int)1e9+7;
    private static Long[][] dp;

    public static void main(String[] args) {
        in = new Scanner(System.in);
        n = in.nextInt();
        g = new HashMap<>();
        for(int i=0; i<n; i++) {
            g.put(i, new ArrayList<>());
        }

        for(int i=0; i<n-1; i++) {
            int p = in.nextInt()-1;
            int q = in.nextInt()-1;
            g.get(p).add(q);
            g.get(q).add(p);
        }
        
        dp = new Long[n][2];


        long ans = (dfs(0, 0, -1)+dfs(0, 1, -1))%MOD;

        System.out.println(ans);

    } 

    private static long dfs(int u, int c, int p) {
        //u is current node
        //c is parent p's color
    	
    	if (dp[u][c]!=null) return dp[u][c];

        long ans = 1;

        for(int v: g.get(u)) {
            if (v==p) continue;

            if (c==0) {
                ans = (ans*(dfs(v, 1, u)+dfs(v, 0, u)))%MOD;
            } else {
                ans = (ans*dfs(v, 0, u))%MOD;
            }
        }

        return dp[u][c]=ans;
    }

}


Measured memory_bytes: 126444
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll a, b;
  cin >> a >> b;
  cout << max(2 * a - 1, max(2 * b - 1, a + b)) << endl;
}

Measured memory_bytes: 3580
#include<stdio.h>

#define MAX 100

int main(){

  int i, j, num, count, temp;
  int data[MAX];

  count = 0;

  scanf("%d", &num);

  for(i = 0; i < num; i++){

    scanf("%d", &data[i]);

  }

  for(i = 0; i < num - 1; i++){

    for(j = num - 1; j > i; j--){

      if(data[j] < data[j - 1]){
	
	temp = data[j - 1];

	data[j - 1] =  data[j];

	data[j] = temp;
	
	count++;
	
      }
	
    }
     
  }

  for(i = 0; i < num - 1; i++){
    
    printf("%d ", data[i]);

  }

  printf("%d\n%d\n", data[i], count);
  
  return 0;
}

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

int main() {
    int X;
    cin >> X;
    int a = X / 500;
    int b = X - 500 * a;
    int c = b / 5;
    int ans = 1000 * a + 5 * c;
    cout << ans << endl;
}

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

string s;
string fr="";
string e="";

long long int q;

int main() {



int rev=0;

cin>>s;
cin>>q;
for(int i=0;i<q;i++){
int temp;
cin>>temp;
if(temp==1){
if(rev==0)rev=1;
else rev=0;

}else{
int f;
cin>>f;
string c;
cin>>c;
if(f==1){


if(rev==0){
fr=c+fr;
}else{
e=e+c;
}//else rev



}else{

if(rev==0){
e=e+c;
}else{
fr=c+fr;
}//else rev



}//else f



}//else temp

}//f i

if(rev==0)
cout <<fr+s+e<<endl;
else{
s=fr+s+e;

for(int i=0;i<(int)s.size();i++){
cout <<s[(int)s.size()-1-i];
}
cout <<endl;
}

}






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

using namespace std;

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

  int n;
  string s;
  cin >> n >> s;
  for (int i = 0; i < s.size(); ++i) {
    cout << char('A'+(s[i]-'A'+n)%26);
  }
  cout << endl;

  return 0;
}



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

using namespace std;

const int N=1e5+5;
int n, m, v, p, a[N], lft[N];
bool check(int x)
{
	lint tot = ((lint) m)*v;
	int curr=a[x]+m;
	int ov=0;
	int ptrr=n+1; //first number still bigger than curr
	for(int i = x+1; i <= n; i++)
	{
		if(a[i]>curr)
		{
			ptrr=i;
			break;
		}
	}
	tot-=(n-ptrr+1)*((lint) m);
	int pos=n-ptrr+2;
	int ptrl=n+1; //first number bigger than x
	for(int i = 1; i < ptrr; i++)
	{
		if(a[i]>a[x])
		{
			ptrl=i;
			break;
		}
	}
	tot-=(ptrl-1LL)*((lint) m);
	//[ptrl, ptrr)
	//cout << ptrl << " " << ptrr << " - " << tot << endl;
	for(int i = ptrl; i < ptrr; i++)
	{
		lft[i]=m;
	}
	for(int i = ptrl; i < ptrr; i++)
	{
		lft[i]-=(curr-a[i]);
		tot-=(curr-a[i]);
	}
	for(int i = ptrr-1; i >= ptrl; i--)
	{
		if(tot<=0) break;
		tot-=lft[i];
		ov++;
	}
	if(ov+pos<=p) return true;
	else return false;
}
int main()
{
	cin >> n >> m >> v >> p;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	sort(a+1, a+n+1);
	int lo = 1, hi = n-p+1;
	while(true)
	{
		if(hi-lo<=1)
		{
			bool chk = check(lo);
			if(chk)
			{
				cout << n-lo+1;
				return 0;
			}
			cout << n-hi+1;
			return 0;
		}
		int mid=(lo+hi)/2;
		bool chk = check(mid);
		if(chk)
		{
			hi=mid;
		}
		else
		{
			lo=mid+1;
		}
	}
	//cout << check(3) << endl;
}

Measured memory_bytes: 1024
//Submitted by Amol

#include<bits/stdc++.h>
typedef long long int lld;

#define pb                    push_back
#define gspeed                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define test                  int t; cin >>t; while(t--)
#define yy                    cout <<"YES" <<endl
#define nn                    cout <<"NO" <<endl
#define endl                  "\n"
#define lcm(a,b)              (a*b)/(__gcd(a,b))

using namespace std;

int main() {gspeed;
//	{
        string s;
            cin >> s;
        int n = s.size();
            s.erase(n-8);
            cout << s << endl;

		return 0;
	}


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

using namespace std;
string a[200010];
int main()
{
    int n;
    cin>>n;
    map<string,int>mep;
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(!mep.count(a[i])){
            mep.insert({a[i],1});
        }
        else{
            mep[a[i]]++;
        }
    }
    int mex=0;
    for(auto i:mep){
        mex=max(mex,i.second);    
    }
    for(auto i:mep){
        if(i.second==mex)cout<<i.first<<endl;
    }
    return 0;
}

Measured memory_bytes: 26752
$<.each{|line|
  n = line.to_i
  ret = 0
  (0..9).each{|a|
    (0..9).each{|b|
      (0..9).each{|c|
        (0..9).each{|d|
          ret+=1 if n == a + b + c + d
        }
      }
    }
  }
  puts ret
}

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

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

   vector<vector<pair<int, int>>> A(N);

   rep(i, 0, N) {
     int t;
     cin >> t;
     rep(j, 0, t) {
       int x, y;
       cin >> x >> y;
       A.at(i).push_back({x - 1, y});
     }
   }

   int ans = 0;

   for (int i = 0; i < (1 << N); i++) {
     bool ok = true;
     for (int j = 0; j < N; j++) {
       if (i & (1 << j)) {
         for (auto a : A.at(j)) {
           if (a.second == 1 && !(i & (1 << a.first))) ok = false;
           if (a.second == 0 && (i & (1 << a.first))) ok = false;
         }
       }
     }
     if (ok) ans = max(ans, __builtin_popcount(i));
   }

   cout << ans << endl;
 }


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

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

    int prevHeight; cin >> prevHeight;

    string ans = "Yes";
    for(int i = 1; i < N; i++){
        int height; cin >> height;

        if(height > prevHeight){
            prevHeight = height - 1;
        }
        else if (height == prevHeight)
        {
            prevHeight = height;
        }
        else
        {
            ans = "No";
            break;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MAXN 100010
#define pii pair<int,int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x<n and y >=0 and y<n)
using namespace std;
const int mod = 1e9 + 7;

int main (){
    int n, m, mat[11][11], count = 0;

    cin >> n >> m;

    for (int i=0; i<n; i++){
        for (int j=0; j<m; j++){
            cin >> mat[i][j];
        }
    }

    for (int i=0; i<n; i++){
        for (int k=i+1; k<n; k++){
            int sum = 0;
            for (int j=0; j<m; j++){
                int v = mat[i][j] - mat[k][j];
                sum += v*v;
            }
            int raiz = pow(sum, 0.5);
            sum == raiz*raiz? count++ : count;
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

bool f[105][11] = {};
int p[105][12] = {};


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

    rep(i,0,n)rep(j,0,10)cin >> f[i][j];
    rep(i,0,n)rep(j,0,11)cin >> p[i][j];

    ll ans = -linf;
	
    rep(i,1,1024){
        ll t = 0;
        rep(k,0,n){
            int b = i,num = 0;
            rep(j,0,10){
                if(f[k][9-j] == 1 && (b&0x01) == 1){
                    num++;    
                }
                b/=2;
            }
            t += p[k][num];
        }
        ans = max(ans,t);
    }

    P(ans);
	return  0;
}

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

int main(void){
	int N;
	cin >> N;
	
	int X=N,fX=0;
	while(X>0){
		fX+=X%10;
		X/=10;
	}
	
	if(N%fX==0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,m,x;
	cin >> n >> m >> x;
	vi c(n);
	vector<vi> books(n, vi(m));
	rep(i,0,n){
		cin >> c[i];
		rep(j,0,m){
			cin >> books[i][j];
		}
	}
	int ans = 1e9;
	rep(msk,0,1 << n){
		vi cnt(m,0);
		int tmp = 0;
		rep(i,0,n){
			if((msk>>i)&1){
				tmp+=c[i];
				rep(j,0,m){
					cnt[j] += books[i][j];
				}
			}
		}
		bool val = true;
		rep(j,0,m){
			if(cnt[j] < x){
				val = false;
				break;
			}
		}
		if(val)gmin(ans,tmp);
	}
	if(ans == (int)1e9)ans = -1;
	cout << ans << '\n';
}


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

#define rep(i, a, b) for(int i = (a); i < (b); ++i)
#define per(i, a, b) for(int i = (b)-1; i >= (a); --i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pii> vii;

int n, m, q;
vector<tuple<int,int,int,int>> qs;
vi a;
ll ans = 0;

void solve() {
  if (sz(a)==n) {
    ll t = 0;
    for (auto [ai, bi, ci, di] : qs) {
      if (a[bi-1]-a[ai-1] == ci) t += di;
    }
    ckmax(ans,t);
  } else {
    int l = sz(a) ? a.back() : 1;
    rep(i,l,m+1) {
      a.pb(i);
      solve();
      a.pop_back();
    }
  }
}

int main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);

  cin >> n >> m >> q;

  qs.resize(q);
  for (auto &[ai,bi,ci,di] : qs) cin >> ai >> bi >> ci >> di;
  
  solve();
  cout << ans << '\n';


}


Measured memory_bytes: 3656
import math

a, b, x = map(int, input().split())

s = a * a
v_max = s * b
v_space = v_max - x

answer = 0

if v_space <= v_max // 2:
    height = v_space * 2 / s
    tan_theta = height / a
else:
    aa = x * 2 / (a * b)
    tan_theta = b / aa

answer = math.degrees(math.atan(tan_theta))
print(answer)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    cout << (S == "abc" ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256