akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp87 {
    class Program {
        static void Main(string[] args) {
            var st = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int N = st[0];
            int M = st[1];

            var k = new int[M];

            var s = new int[M][];
            for (int i = 0; i < M; i++) {
                var x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                k[i] = x[0];
                s[i] = new int[k[i]];
                for (int j = 0; j < k[i]; j++) {
                    s[i][j] = x[j + 1] - 1;
                }
            }

            var p = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int ans = 0;
            int cnt = 0;

            for (int bit = 0; bit < (1 << N); bit++) {
                for (int lb = 0; lb < M; lb++) {
                    cnt = 0;
                    foreach(var element in s[lb]) {
                        if ((bit & (1 << element)) != 0) {
                            cnt++;
                        }
                    }

                    if (cnt % 2 == p[lb]) {
                        //OKなので何もせずスルーする
                    } else {
                        goto skip;
                    }
                }
                ans++;

                skip:;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

const int N = 10;
bool visited[N];
vector<ll> vals;
ll cost[N][N];
int n, j;

void dfs(int i, ll s) {
	visited[i] = true;
	int outs = 0;
	for (int t = 0; t < n; ++t) {
		if (! visited[t]) {
			++outs;
			dfs(t, s + cost[i][t]);
		}
	}
	if (outs == 0 && i >= j) vals.push_back(s);
	visited[i] = false;
}

ll works() {
	for (j = 0; j < n; ++j) dfs(j, 0);
	sort(vals.begin(), vals.end());
	ll ans = vals.back();

	for (int i = 0; i+1 < vals.size(); ++i) {
		if (vals[i] == vals[i+1]) return -1;
	}
	vals.clear();
	return ans;
}

int main() {
	vector<vector<int>> xr = {
	{1},
	{1,2},
	{1,2,4},
	{1,2,4,7},
	{1,2,4,7,12},
	{1,2,4,8,13,18},
	{1,2,4,8,14,19,24},
	{1,2,4,8,15,24,29,34},
	{1,7,10,13,21,26,41,43,45}
	};

	int m;
	cin >> m;
	for (int i = 1; i < m; ++i) {
		n = i;
		ll b = works() + 1;
		if (b == -1) return 1;

		for (j = 0; j < n; ++j) {
			cost[i][j] = b * xr[i-1][j];
			cost[j][i] = cost[i][j];
		}
	}

	n = m;
	ll res = works();
	if (res == -1) return 1;
	cerr << res << '\n';

	for (int i = 0; i < n; ++i) {
		for (j = 0; j < n; ++j) {
			cout << cost[i][j] << ' ';
		}
		cout << '\n';
	}
}


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

using namespace std;

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

int main() {
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    string res = s;
    int k;
    cin >> k;
    for (int i = 0; i < s.length(); i++) {
        int to_go = (26 - (s[i] - 'a')) % 26;
        if (to_go <= k) {
            k -= to_go;
            res[i] = 'a';
        }
    }
    res.back() = (res.back() - 'a' + k) % 26 + 'a';
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
L = int(input())
N = L.bit_length()
Ans = []
for i in range(1, N):
    Ans.append((i, i+1, 0))
    Ans.append((i, i+1, 2**(i-1)))
for i in range(1, N):
    if 2**(i-1) & L:
        L -= 2**(i-1)
        Ans.append((i, N, L))
print(N, len(Ans))
for a in Ans:
    print(*a)


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

int main() {
    long long  N, W;
    vector <long long> w(101), v(101);
    vector < vector <long long > > dp(101, vector <long long> (100001, 0));        cin >> N >> W;
        for (int i=1; i<=N; i++){
                cin >> w[i];
                cin >> v[i];
        }
        for (int i=1; i<=N; i++){
            for (int j=1; j<=W; j++){
                if (j<w[i]){dp[i][j] = dp[i-1][j];}
                else{
                    dp[i][j] = max(dp[i-1][j], v[i] + dp[i-1][j-w[i]]);
                }
            }
        }
    
    
        cout << dp[N][W] << "\n";

    return 0;
}

Measured memory_bytes: 83056
#include <bits/stdc++.h>
using namespace std;
long long a[100'000];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a, a + n);
    vector<long long> sides;
    for(int i = n-1; i > 0 && sides.size() < 2; ) {
        if(a[i] == a[i-1]) {
            sides.push_back(a[i]);
            i -= 2;
        } else {
            i--;
        }
    }
    if(sides.size() < 2) {
        cout << 0 << endl;
    } else {
        cout << sides[0] * sides[1] << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
#include <map>
using namespace std;

int main(void) {
    int N; cin >> N;
    int ans = 0;
    if (1000 - N % 1000 == 1000) {
        ans = 0;
    } else {
        ans = 1000 - N % 1000;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan= new Scanner(System.in);
		
		int x=scan.nextInt();
		int y=scan.nextInt();
		int[] a= {0 , 1 , 3 , 1 , 2 , 1 , 2 , 1 , 1 , 2 , 1 , 2 , 1};
		System.out.println(a[x]==a[y]?"Yes":"No");
	}

}


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

#define INF 1e9
#define PI 3.141592653589793238
typedef long long ll;

int main() {
    int a[3][3], n, b, flag=0;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin>>a[i][j];
        }
    }
    cin>>n;
    for(int k=0; k<n; k++){
        cin>>b;
        for(int i=0; i<3; i++){
            for(int j=0; j<3; j++){
                if(a[i][j]==b) a[i][j]=0;
            }
        }
    }

    if(a[0][0]+a[0][1]+a[0][2]==0) flag=1;
    else if(a[1][0]+a[1][1]+a[1][2]==0) flag=1;
    else if(a[2][0]+a[2][1]+a[2][2]==0) flag=1;
    else if(a[0][0]+a[1][0]+a[2][0]==0) flag=1;
    else if(a[0][1]+a[1][1]+a[2][1]==0) flag=1;
    else if(a[0][2]+a[1][2]+a[2][2]==0) flag=1;
    else if(a[0][0]+a[1][1]+a[2][2]==0) flag=1;
    else if(a[0][2]+a[1][1]+a[2][0]==0) flag=1;

    if(flag==1) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 3576
#include <stdio.h>
int main(){
  int h,w,a[101];
  scanf("%d%d",&h,&w);
  for(int i=0;i<w+2;i++)printf("#");
  printf("\n");
  for(int i=0;i<h;i++){
    scanf("%s",a);
    printf("#");
    printf("%s",a);
    printf("#\n");
  }
  for(int i=0;i<w+2;i++)printf("#");
  printf("\n");
  return 0;
}

Measured memory_bytes: 128
/**
 * @brief  : c++ code for AtCoder
 * @author : rk222
 * @created: 2019.05.19 20:58:46
 */

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

#define disp(x) cout << #x << ": " << x << endl
#define disp_vec(v)                                                                           \
    cout << #v << ":";                                                                        \
    rep(i, v.size()) cout << " " << v[i];                                                     \
    cout << endl

const int INF = 1000000007;
const int M = 100000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0}, {1, 1}, {0, 1}, {-1, 1}, {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/* ------------------------------------- */

// 頂点fromから頂点toへのコストcostの辺
struct edge {
    int to;
    ll cost;
};

int v, e;
ll costs[100010];

vector<edge> G[100010];

void dfs(int from, int to, ll cost, ll sumcost) {
    costs[to] = sumcost + cost;
    rep(i, G[to].size()) {
        if (G[to][i].to != from) {
            dfs(to, G[to][i].to, G[to][i].cost, costs[to]);
        }
    }
}

int main() {
    // vは頂点数、eは辺の数
    scanf("%d", &v);
    int ut, vt, wt;
    rep(i, v - 1) {
        scanf("%d%d%d", &ut, &vt, &wt);
        G[ut - 1].pb({vt - 1, wt});
        G[vt - 1].pb({ut - 1, wt});
    }
    costs[0] = 0;
    rep(i, G[0].size()) {
        dfs(0, G[0][i].to, G[0][i].cost, costs[0]);
    }
    rep(i, v) {
        // printf("i: %d, cost:%lld\n", i, costs[i]);
        if (i == 0) {
            printf("%d\n", 0);
            continue;
        }
        if (costs[i] % 2 == 0) {
            printf("%d\n", 0);
        } else {
            printf("%d\n", 1);
        }
    }

    /* --------------------------------- */
    return 0;
}

Measured memory_bytes: 11008
a = int(input())
list1 = []
dict1 = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0,}
for x in range(a):
    b = input()
    list1.append(b)

for x in list1:
    dict1[x] += 1

for x in dict1:
    print(f'{x} x {dict1[x]}')

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

#define rep(i,a,b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define fill(x,v) memset(x,v,sizeof(x))
#define all(x) (x).begin(), (x).end()
#define trace(x) cerr << #x <<": " << x << endl

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef long double C;

const int MAX = 1e5+5;
const ll MOD = 1e9+7;

ll dp[13][MAX];

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    fill(dp, 0);
    dp[0][0] = 1;
    ll rest;
    rep(i,0,s.size()){
        rep(j,0,13){
            rest = (j*10)%13;
            if(s[i] == '?'){
                rep(k,0,10){
                    ll ind = (rest+k)%13; 
                    //trace(ind);
                    dp[ind][i+1] = (dp[ind][i+1] + dp[j][i])%MOD;
                }
            }
            else{
                ll dig = s[i] - '0';
                ll ind = (rest+dig)%13; 
                dp[ind][i+1] = (dp[ind][i+1] + dp[j][i])%MOD;
            }
        }
    }
    cout << dp[5][s.size()] << endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
//typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

void print_line(vector<ll> &line) {
    if (line.size() == 0ll) {
        cout << endl;
        return;
    }
    for (ll i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}


typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

typedef pair<ll, ll> P;

bool check(vector<int> &a, int n, int m) {
    for (int j = 0; j < (1 << n); j++) {
        int sum = 0;
        for (int k = 0; k < n; k++) {
            if ((j >> k) & 1) {
                sum += a[k];
            }
        }
        if (sum == m) {
            return true;
        }
    }
    return false;
}

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

    set<int> can;

    for (int j = 0; j < (1 << n); j++) {
        int sum = 0;
        for (int k = 0; k < n; k++) {
            if ((j >> k) & 1) {
                sum += a[k];
            }
        }
        can.insert(sum);
    }

    int q;
    cin >> q;
    rep(i, q) {
        int m;
        cin >> m;

        bool b = can.find(m) != can.end();
        if (b) cout << "yes" << endl;
        else cout << "no" << endl;
    }
}



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

int main(){
  int n,m;
  cin>>n>>m;
  int a[105];
  int sum=0;
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  sort(a,a+n);
  reverse(a,a+n);
  if(a[m-1]<sum/(float)(4*m)) puts("No");
  else puts("Yes");
  return 0;
}

Measured memory_bytes: 256
N = int(input())
robot = []
ans = 0
for i in range(N):
    x,l = map(int,input().split())
    robot.append([x+l,x-l])
robot.sort()

cur = -float('inf')

for i in range(N):
    if cur <= robot[i][1]:
        ans += 1
        cur = robot[i][0]

print(ans)

Measured memory_bytes: 20104
"use strict";

function main(arg){
  const input = arg.trim().split('\n').map(_=>parseInt(_, 10));
  const a = input[0];
  const b = input[1];
  const h = input[2];
  
  console.log((a+b)*h / 2)
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));  

Measured memory_bytes: 11468
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	b=1;
	const LL INF=pow((LL)10,(LL)18);
	vector<LL> v1;
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(a);
		if(a==0){
			cout<<0<<endl;
			return 0;
		}
	}
	for(i=0;i<n;i++){
		a=v1[i];
		if(INF/b<a){
			b=-1;
			break;
		}
		b*=a;
		if(b>INF){
			b=-1;
			break;
		}
	}
	cout<<b<<endl;
}

Measured memory_bytes: 4316
#include <iostream>


int main() {

    int N, M, X;
    std::cin >> N >> M >> X;

    int costs[N+1] = {};
    for (int i=0; i<M; i++) {
        int pos;
        std::cin >> pos;
        costs[pos] = 1;
    }

    int cost_l = 0;
    int cost_r = 0;

    for (int pos=X; pos>=0; pos--) cost_l += costs[pos];
    for (int pos=X; pos<=N; pos++) cost_r += costs[pos];

    const int smaller_cost = cost_l < cost_r ? cost_l : cost_r;

    std::cout << smaller_cost << std::endl;

    return 0;

}


Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979;
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int n) { return n & 1; }
constexpr bool even(const int n) { return ~n & 1; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  string s;
  cin >> s;
  forever {
    if (s.size() <= 3) break;
    bool updated = false;
    loop(i, 1, s.size() - 3) {
      if (s.substr(i, 3) == "mew") {
        s.replace(i, 3, "");
        updated = true;
      }
    }
    if (!updated) break;
  }
  cout << (s == "mew" ? "Cat" : "Rabbit") << endl;
}

Measured memory_bytes: 3208
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner in = new Scanner(System.in);
		int k = in.nextInt();
		int x = in.nextInt();
		
		int min = -1000000;
		int max = 1000000;

		for (int i = Math.max(x - k  + 1, min); i <= Math.min(x + k - 1, max); ++i)
			System.out.print(i + " ");
		System.out.println();
	}
}

Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  1000000007;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}

template<typename T> vector<ll> cum(const vector<ll>& a, int n, priority_queue<ll, vector<ll>, T> q) {
  vector<ll> ans(n+1);
  ll sum = accumulate(a.begin(), a.begin()+n, 0ll);
  REP(i, n) {
    q.push(a[i]);
  }
  ans[0] = sum;
  REP(i, n) {
    q.push(a[n+i]);
    sum += a[n+i] - q.top();
    q.pop();
    ans[i+1] = sum;
  }
  return ans;
}

signed main() {
  ios::sync_with_stdio(false);
  ll n;
  cin >> n;
  vector<ll> a(3*n);
  REP(i, n*3) cin >> a[i];
  vector<ll> l = cum(a, n, priority_queue<ll, vector<ll>, greater<ll>>());
  reverse(all(a));
  vector<ll> r = cum(a, n, priority_queue<ll, vector<ll>, less<ll>>());
  ll ans = -inf;
  REP(i, n+1) {
    // cout << l[i] - r[n-i] << endl;
    ans = max(ans, l[i] - r[n-i]);
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5996
///Water Hyacinth
///Hakuna Matata
///WAKE THE FUCK UP SAMURAI;WE HAVE A CODE TO RUN <3
///Any Verdict
///(Aes)  Dekhe (Tic) lagche = Aesthetic <3
///**********************************************************///

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r;
    cin >> r;
    cout << 3*(r*r) << endl;
    return 0;
}


Measured memory_bytes: 256
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=2e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

ll d[MAXn];
multiset<ll> st;

int main()
{
    IOS();
    ll n;
    cin>>n;
    REP(i,n)cin>>d[i], st.insert(d[i]);
    ll tt = 0;
    while(SZ(st) >= 2)
    {
        ll x = *prev(st.end());
        st.erase(prev(st.end()));
        for(ll i = 30; i > 0;i --)
        {
            auto it = st.find((1LL<<i) - x);
            if(it != st.end())
            {
                tt ++, st.erase(it);
                break;
            }
        }
        debug(x, tt, SZ(st));
    }
    cout<<tt<<endl;
}


Measured memory_bytes: 11264
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x;
    cin>>n>>x;
    for(int a=0;a<=2000;a++)
    {
        for(int b=0;b<=2000;b++)
        {
            int c=n-a-b;
            if(a>n || b>n || c>n || c<0)
                continue;
            if(a*10000+b*5000+c*1000==x)
            {
                cout<<a<<" "<<b<<" "<<c<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    return 0;
}


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

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

    int A, B, C;
    cin >> A >> B >> C;
    cout << max(C+B-A, 0) << endl;
}

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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

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

  int n; read(n);
  vector<ll> v(n), ps(n);
  rep(i, 0, n) read(v[i]);
  sort(all(v));
  reverse(all(v));
  ps[n - 1] = v[n - 1];
  for (int i = n - 2; i >= 0; i--)
    ps[i] = ps[i + 1] + v[i];

  int i = 0;
  while (i + 1 < n && ps[i + 1] * 2 >= v[i]) {
    ++i;
  }
  write(i + 1);
}


Measured memory_bytes: 4752
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int[] x = new int[4];
		char[] y = new char[3];

		x[0] = Integer.parseInt(s.substring(0,1));
		x[1] = Integer.parseInt(s.substring(1,2));
		x[2] = Integer.parseInt(s.substring(2,3));
		x[3] = Integer.parseInt(s.substring(3,4));


		for(int i = 0 ; i < 8 ; i++) {
			int sum = x[0];    
			for(int j = 0 ; j < 3 ; j++) {
				if((1 & (i>>j)) == 1) {
					sum += x[3-j];
					y[2-j] = '+';

				} else {
					sum -= x[3-j];
					y[2-j] = '-';
				}
			}
			if(sum == 7) {
				System.out.print(x[0]);
				System.out.print(y[0]);
				System.out.print(x[1]);
				System.out.print(y[1]);
				System.out.print(x[2]);
				System.out.print(y[2]);
				System.out.print(x[3]);
				System.out.print("=7");
				return;
			}
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define sorta(V) sort(V.begin(), V.end())
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end() 

using namespace std;



int main(){

    //(n-1)!にたいしてnをかけると約数がふえる。
    //ある数xの約数の数は素因数分解したときの各素数の(乗数+1)を掛け合わせたもの
    //120 = 2^3*3^1*5^1より(3+1)*(1+1)*(1+1) = 16個
    //1,2,3,4,5,6,8,10,12,15,20,24,30,40,60,120


    int n;
    cin >> n;

    vector<int> primes(1000 + 1, 1);
    vector<int> count(1001, 1);

    primes[0] = 0;
    primes[1] = 0;

    for(int i = 2; i <= 1000; i++){
        if(primes[i] == 1){
            for(int j = i * i; j <= 1000; j = j + i) primes[j] = 0;
        }
    }

    ll ans = 1;

    for(int i = 2; i <= n;i++){

        int tmp = i;
        rep(j,1001){
            while(primes[j] == 1 && tmp % j == 0){
                tmp = tmp / j;
                count[j]++;
            }
        }

    }

    rep(i,1001){
        if(primes[i] == 1){
            ans = ans * count[i] % 1000000007;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main(){
    long long n,a,b; cin>>n >>a >>b;
    if(a>b){
        cout<<0<<endl;
    }else if(n==1){
        if(a==b){
            cout<<1<<endl;
        }else{
            cout<<0<<endl;
        }
    }else{
        cout<<(b-a)*(n-2)+1<<endl;
    }
    return 0;
}

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

const int MAX_N = 1382;
int n;
int lp[MAX_N];
int pr[MAX_N];
int ind;

int main() {
	scanf("%d", &n);
	for (int i = 2; i < MAX_N; i++) {
		if (lp[i] == 0) {
			lp[i] = i;
			pr[ind++] = i;

			if (i % 5 == 1) {
				printf("%d ", i);
				n--;

				if (!n)
					return 0;
			}
		}

		for (int j = 0; j < ind && pr[j] <= lp[i] && i * pr[j] < MAX_N; j++)
			lp[i * pr[j]] = pr[j];
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}


map<int, int> prime_factor(int n){
    map<int, int> res;
    for(int i=2; i*i<=n; i++){
        while(n%i==0){
            ++res[i];
            n/=i;
        }
    }
    if(n!=1) res[n]=1;
    return res;
}

vector<ll> divisor(ll n){
    vector<ll> res;
    for(ll i=1; i*i<=n; i++){
        if(n%i==0){
            res.push_back(i);
            if(i!=n/i && n/i!=n) res.push_back(n/i);
        }
    }
    return res;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    map<ll, ll> a;
    for (long long i = 0; i < N; i++) {
        a[A[i]]++;
    }
    ll cnt=0;
    for (long long i = 0; i < N; i++) {
        if(a[A[i]]>1) continue;
        if(A[i]==1 && a[A[i]]==1){
            cnt++;
            continue;
        }
        vector<ll> v = divisor(A[i]);
        // vout(v);
        bool f=false;
        for (auto& e: v) {
            // debg(e);
            if(a.count(e)){
                f=true;
                break;
            }
        }
        if(f==false){
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 17152
//「Train Ticket」(https://beta.atcoder.jp/contests/abc079/tasks/abc079_c)

#include<iostream>
#include<stack>
#include<vector>

int main(){
	//標準入力
	const int numCount=4;
	int inp[numCount];
	for(size_t i=0;i<numCount;i++){
		char a;
		std::cin>>a;
		inp[i]=a-'0';
	}

	//処理
	//stackによる深さ優先探索で行う
	//どんな探索をしたかはvector<int>で調べる。符号は+を1,-を-1で記録。
	std::stack<std::vector<int>> sti;//stack
	std::vector<int> ans;//解答
	sti.push({});//一番基底のものを積む。
	while(!sti.empty()){
		std::vector<int> vec=sti.top();
		sti.pop();
		if(vec.size()>=numCount-1){
			//vecのサイズが3以上ならこれより深くは探索しない
			int calc=inp[0];//計算結果を格納
			for(size_t i=0;i<numCount-1;i++){
				calc+=vec[i]*inp[i+1];
			}
			//答えだったら探索終了
			if(calc==7){
				ans=vec;
				break;
			}
		} else{
			//vecのサイズが3未満なら深く探索
			vec.push_back(1);
			sti.push(vec);
			vec.pop_back();
			vec.push_back(-1);
			sti.push(vec);
		}
	}

	//出力
	if(ans.size()==numCount-1){
		std::cout<<inp[0];
		for(size_t i=0;i<numCount-1;i++){
			std::cout<<(ans[i]>0?'+':'-')<<inp[i+1];//+,-の出力の形式を変更するのを忘れない
		}
		std::cout<<"=7"<<std::endl;
	}

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double


struct RollingHash {
	//string text; // text
	int n; // number of characters
	int base1 = 1009;
	//int base2 = 1007;
	ll mod1 = (ll)1e9 + 9;
	//ll mod2 = (ll)1e9 + 7;
	ll* pow1;
	//ll* pow2;
	ll* hash1;
	//ll* hash2;
	/* constructor */
	RollingHash(vector<int>* a) {
		//text = s;
		n = (*a).size();
		hash1 = new ll[n + 1];
		//hash2 = new ll[n + 1];
		pow1 = new ll[n + 1];
		//pow2 = new ll[n + 1];
		hash1[0] = 0;//hash2[0] = 0;
		pow1[0] = 1; //pow2[0] = 1;
		for (int i = 0; i < n; ++i) {
			hash1[i + 1] = (hash1[i] + (*a)[i]) * base1 % mod1;
			//hash2[i + 1] = (hash2[i] + a[i]) * base2 % mod2;
			pow1[i + 1] = pow1[i] * base1 % mod1;
			//pow2[i + 1] = pow2[i] * base2 % mod2;
		}
	}
	/* text[l,l+1,...,r-1]のハッシュ値を計算 */
	ll get(int l, int r) {
		//pair<ll, ll> p;
		return ((hash1[r] - hash1[l] * pow1[r - l] % mod1) + mod1) % mod1;
		//p.second = ((hash2[r] - hash2[l] * pow2[r - l] % mod2) + mod2) % mod2;
		//return p;
	}
};


vector<int> XOR(vector<int> a, int b) {
	int n = a.size();
	vector<int> res(n);
	for (int i = 0; i < n; ++i) res[i] = a[i] ^ b;
	return res;
}

string VecToStr(vector<int>* a) {
	string res = ""; int sz = (*a).size();
	for (int i = 0; i < sz; ++i)
		res += '0' + (*a)[i];
	return res;
}

vector<int> cyclic(vector<int>* s1, vector<int>* s2) {
	vector<int> s22(2 * (*s1).size());
	for (int i = 0; i < 2 * (*s1).size(); ++i)
		s22[i] = (*s2)[i % (*s1).size()];
	RollingHash r1(s1), r2(&s22);
	vector<int> res;
	int sz = (*s1).size();
	for (int i = 0; i < sz; ++i) {
		if (r1.get(0, sz) == r2.get(i, i + sz))
			res.push_back(i);
	}
	return res;
}

int ok[200000][30][2];

signed main() {
	int n; cin >> n;
	vector<ll> a(n), b(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) cin >> b[i];

	for (int i = 0; i < 30; ++i) {
		vector<int> a_bit(n), b_bit(n);
		for (int j = 0; j < n; ++j) {
			a_bit[j] = (a[j] & (1LL << i)) ? 1 : 0;
			b_bit[j] = (b[j] & (1LL << i)) ? 1 : 0;
		}
		vector<int> b0 = XOR(b_bit, 0);
		vector<int> b1 = XOR(b_bit, 1);
		set<pair<int, int>> tmp;
		auto res0 = cyclic(&a_bit, &b0);
		for (auto ki : res0) ok[(2 * n - ki) % n][i][0] = 1;
		auto res1 = cyclic(&a_bit, &b1);
		for (auto ki : res1) ok[(2 * n - ki) % n][i][1] = 1;
		/*
		cout << "i = " << i << endl;
		cout << "---res0---" << endl;
		for (auto ri : res0) cout << ri << " ";
		cout << endl;
		cout << "---res1---" << endl;
		for (auto ri : res1) cout << ri << " ";
		cout << endl;
		*/
	}

	for (int k = 0; k < n; ++k) {
		vector<ll> x;
		if (ok[k][0][0]) x.push_back(0);
		if (ok[k][0][1]) x.push_back(1);
		for (int i = 1; i < 30; ++i) {
			vector<ll> tmp;
			if (ok[k][i][0])
				for (auto xi : x)
					tmp.push_back(xi);
			if (ok[k][i][1])
				for (auto xi : x)
					tmp.push_back(xi | (1LL << i));
			x = tmp;
		}
		sort(x.begin(), x.end());
		for (auto xi : x)
			cout << k << " " << xi << endl;
	}

	return 0;
}

Measured memory_bytes: 624020
from collections import defaultdict
import heapq

N, M = map(int, input().split())
works = defaultdict(list)
for i in range(N):
    A, B = map(int, input().split())
    works[A].append(B)

ans = 0
min_A = min(works.keys())
if min_A < M:
    a = min_A
    bag = []
    heapq.heapify(bag)
    while a <= M:
        d = M - a
        for w in works[a]:
            heapq.heappush(bag, -w)
        if len(bag) >= 1:
            ans -= heapq.heappop(bag)
        a += 1
print(ans)


Measured memory_bytes: 27812
from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math


def get_int():
    return int(stdin.readline().strip())


def get_tuple():
    return map(int, stdin.readline().split())


def get_list():
    return list(map(int, stdin.readline().split()))


def solve():
    return

def main():
    n,k = get_tuple()
    ls = get_list()
    ls.sort()
    ans = 0
    for i in range(k):
        ans += ls[i]
    print(ans)


TestCases = False

if TestCases:
    for i in range(get_int()):
        main()
else:
    main()


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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    string s, t;
    cin >> t >> s;
    cout << s + t;
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3664
use proconio::input;
use proconio::marker::Usize1;

#[allow(dead_code)]
struct UFT {
    par: Vec<usize>,
    size: Vec<usize>,
    n: usize,
}

#[allow(dead_code)]
impl UFT {
    fn new(n: usize) -> Self {
        let par = (0..n).collect();
        let size = vec![1; n];
        Self { par, size, n }
    }
    fn find(&mut self, a: usize) -> usize {
        if self.par[a] == a {
            a
        } else {
            self.par[a] = self.find(self.par[a]);
            self.par[a]
        }
    }
    fn unite(&mut self, a: usize, b: usize) -> usize {
        let mut x = self.find(a);
        let mut y = self.find(b);
        if x == y {
            x
        } else {
            if self.size[x] < self.size[y] {
                std::mem::swap(&mut x, &mut y);
            }
            self.size[x] += self.size[y];
            self.par[y] = x;
            x
        }
    }
    fn same(&mut self, a: usize, b: usize) -> bool {
        self.find(a) == self.find(b)
    }
}

#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        M: usize,
        AB: [(Usize1, Usize1); M]
    }

    let mut ans = 0;

    for i in 0..M {
        let mut uft = UFT::new(N);
        for j in 0..M {
            if i == j {
                continue;
            }
            let (a, b) = AB[j];
            uft.unite(a, b);
        }

        ans += if *uft.size.iter().max().unwrap() != N {
            1
        } else {
            0
        };
    }

    println!("{}", ans);
}

Measured memory_bytes: 2160
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    vector<ll> offsets(m, -1);
    vector<int> idxs(m+1), inv(m+1);
    offsets[x] = x;
    idxs[0] = x;
    inv[x] = 0;
    ll ai = x, sum = x;
    for (int i=1; i<=m; i++) {
        ai = (ai * ai) % m;
        // cerr << ai << ' '  << sum << '\n';
        sum += ai;
        if (i+1 == n) {
            cout << sum << '\n';
            break;
        }
        if (offsets[ai] >= 0) {
            ll loop_len = i - inv[ai];
            ll loop_sum = sum - offsets[ai];
            ll rest_idx = (n - inv[ai] - 1) % loop_len;
            ll rest_sum = offsets[idxs[inv[ai] + rest_idx]] - offsets[ai];
            // cerr << ai << ' ' << loop_len << ' ' << loop_sum << '\n';
            sum += ((n - inv[ai] - 1) / loop_len - 1) * loop_sum + rest_sum;
            cout << sum << '\n';
            break;
        }
        idxs[i] = ai;
        inv[ai] = i;
        offsets[ai] = sum;
    }
    return 0;
}

Measured memory_bytes: 4836
#include "bits/stdc++.h"
#define int long long
#define range(i, a, b) for(auto i = a; i < b; i++)
#define rep(i, a) range(i, 0, a)
#define all(a) (a).begin(),(a).end()
using namespace std;
const int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
const int MOD = 1000000007;
const long double EPS = 1e-9;
using vi = vector <int>;
using vvi = vector <vi>;

int combination(int n, int k)
{
  if(k < 0 || n < k) return (0);
  int ret = 1;
  for(int i = 1; i <= k; ++i) {
    ret *= n--;
    ret /= i;
  }
  return (ret);
}

signed main() {
	int n, a, b;
	cin >> n >> a >> b;
	int v[n];
	map <int, int> mp;
	rep(i, n) {
		cin >> v[i];
		mp[v[i]]++;
	}

	sort(v, v + n);
	reverse(v, v + n);

	long double ans = 0;
	int combi = 0;
	for (int i = a; i <= b; i++) {
		long double sum = 0;
		int cnt = 1;
		for(int j = 0; j < i; j++) {
			sum += v[j];
			if(j != 0 && v[j - 1] == v[j]) {
				cnt++;
			} else {
				cnt = 1;
			}
		}
		if(ans <= sum / i) {
			if(abs(ans - sum / i) > EPS) {
				combi = 0;
			}
			ans = sum / i;
			combi += combination(mp[v[i - 1]], cnt);
		}
	}
	printf("%.10Lf\n%lld\n", ans, combi);
}

Measured memory_bytes: 256
ans=[]
anskouho=[]
A,B=map(int,input().split())
for i in range(1,1009):
    if int(i*8/100)==A and int(i*0.1)==B:
        ans.append(i)
        anskouho.append(min(ans))
    else:
        anskouho.append(-1)
print(max(anskouho))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <list>
using namespace std;
static const int MAX=100000;
static const int INFTY=(1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s){
    queue<int> q;
    q.push(s);
    V[s]=true;
    while(!q.empty()){
        int u=q.front();q.pop();
        out.push_back(u);
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            indeg[v]--;
            if(indeg[v]==0&&!V[v]){
                V[v]=true;
                q.push(v);
            }
        }
    }
}

void tsort(){
    for(int i=0;i<N;i++){
        indeg[i]=0;
    }
    
    for(int u=0;u<N;u++){
        for(int i=0;i<G[u].size();i++){
            int v=G[u][i];
            indeg[v]++;
        }
    }
    
    for(int u=0;u<N;u++){
        if(indeg[u]==0&&!V[u])bfs(u);
    }
    for(list<int>::iterator it=out.begin();it!=out.end();it++){
        cout<<*it<<endl;
    }
}

int main(void){
    int s,t,M;
    cin>>N>>M;
    
    for(int i=0;i<N;i++){
        V[i]=false;
    }
    for(int i=0;i<M;i++){
        cin>>s>>t;
        G[s].push_back(t);
    }
    tsort();
    return 0;
}



Measured memory_bytes: 6172
N = int(input())

ans = 0
L = list(map(int, input().split()))
for i in range(N):
  for j in range(i+1, N):
    if L[i] == L[j]:
      continue
    for k in range(j+1, N):
      if L[i] == L[k] or L[j] == L[k]:
        continue
      if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
        ans += 1
print(ans)


Measured memory_bytes: 9028
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{

    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            int K = int.Parse(s[1]);

            int ans = (N - 2) / (K - 1) + 1;

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
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; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

template<int MOD> struct Fp {  
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;


signed main(){
	//cout << fixed << setprecision(10);
	int n; cin >> n;
	vl a(n);
	mint sum = 0;
	rep(i,0,n){
		ll b; cin >> b;
		a[i] = b;
		sum += b;
	}
	mint ans = 0;
	rep(i,0,n){
		mint g = sum;
		g -= a[i];
		ans += g * a[i];
	}
	cout << ans / 2<< endl;


	return 0;
}

Measured memory_bytes: 4852
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;
const int MaxN = 100005;
const int MaxM = 1000;

int n, k;
int M;
struct Point {
    int x, y;
    char c;
    Point () {}
    Point (int _x, int _y, char _c) {
        x = _x; y = _y; c = _c;
    }
}PP[MaxN + 5];
int sum[4 * MaxM + 5][4 * MaxM + 5];

void init() {
    M = 2 * k;
    memset(sum, 0, sizeof(sum));
    for(int i = 1; i <= n; i++)
        scanf("%d %d %c", &PP[i].x, &PP[i].y, &PP[i].c);
}

int cal(int lx, int ly, int ux, int uy) {   //计算某个矩阵和
    return sum[lx][ly] - sum[lx][uy + 1] - sum[ux + 1][ly]
               + sum[ux + 1][uy + 1];
}

void change() {
    for(int i = 1; i <= n; i++) {    //转化
        if(PP[i].c == 'B') {
            int tx = PP[i].x % M;
            int ty = PP[i].y % M;
            sum[tx][ty]++;
        }
        else if(PP[i].c == 'W') {
            int tx = (PP[i].x) % M;
            int ty = (PP[i].y + k) % M;
            sum[tx][ty]++;
        }
    }
    for(int i = 0; i < M; i++) {    //扩充矩阵
        for(int j = 0; j < M; j++) {
            sum[i + M][j] = sum[i][j];
            sum[i][j + M] = sum[i][j];
            sum[i + M][j + M] = sum[i][j];
        }
    }
    for(int i = 2 * M - 1; i >= 0; i--) {    //计算后缀和
        for(int j = 2 * M - 1; j >= 0; j--) {
            sum[i][j] = sum[i][j] + sum[i + 1][j] + 
                            sum[i][j + 1] - sum[i + 1][j + 1];
        }
    }
}

void solve() {
    int best = 0;
    for(int i = 0; i < M; i++) {
        for(int j = 0; j < M; j++) {
            int tmp = cal(i, j, i + k - 1, j + k - 1)
                         + cal(i + k, j + k, i + M - 1, j + M - 1);
            best = max(best, tmp);
        }
    }
    printf("%d\n", best);
}

int main()
{
    while(scanf("%d %d", &n, &k) != EOF)
    {
        init();
        change();
        solve();
    }
    return 0;
}

Measured memory_bytes: 64000
#!/usr/bin/env python3
import sys


def solve(S: str):
    a = {'SUN':7,'MON':6,'TUE':5,'WED':4,'THU':3,'FRI':2,'SAT':1}
    print(a[S])
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940