akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3

import sys

DEBUG = False

def read(t):
    return t(sys.stdin.readline().rstrip())


def read_list(t, sep = " "):
    return [t(s) for s in sys.stdin.readline().rstrip().split(sep)]


def dprint(*args, **kwargs):
    if DEBUG:
        print(*args, **kwargs)
    return


def main():
    c = read(str)
    if c == "ABC":
        print("ARC")
    else:
        print("ABC")
    pass


if __name__ == "__main__":
    main()


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

int main(void) {
	char s;
	int count[26];
	for(int i = 0; i < 26; i++){
	    count[i] = 0;
	}
	while ((s = getchar()) != EOF) {
	    for(int j = 0; j < 26; j++){
	        if((int)s > 64){
                if((int)s % 65 == j || (int)s % 97 == j){
                    count[j]++;
                }
            }
	    }
	}
	for (int i = 0; i < 26; i++) {
		printf("%c : %d\n", 97 + i, count[i]);
	}
	return 0;
}


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

using namespace std;
#define maxn 222222
int arr[maxn];


int main(){
int n,k;
cin>>n>>k;
int cur_var = 0;
int max_val = 0;
for(int i = 0;i<n;i++)
{
	int val;
	cin>>val;
	if(val>max_val)
		max_val = val;
	if(arr[val]==0)
		cur_var++;
	arr[val]++;
}

sort(arr,arr+max_val+1);
int ans = 0;
int i = 0;
while(cur_var>k)
{
	if(arr[i]>0)
		cur_var--;
	ans += arr[i++];
}
cout<<ans;

	
}


Measured memory_bytes: 1024
using System;


public class hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        var house = new int[12, 10];
        for (int i = 0; i < n; i++)
        {
            string[] line = Console.ReadLine().Trim().Split(' ');
            var b = int.Parse(line[0]) - 1;
            var f = int.Parse(line[1]) - 1;
            var r = int.Parse(line[2]) - 1;
            var v = int.Parse(line[3]);
            house[f + b * 3, r] += v;
        }
        var igeta = "####################";
        var floorcount = 0;
        for (int i = 0; i < 12; i++)
        {
            if (floorcount ==3)
            {
                Console.WriteLine(igeta);
                floorcount = 0;
            }
            for (int j = 0; j < 10; j++)
            {
                if (j == 9) Console.WriteLine(" {0}", house[i, j]);
                else Console.Write(" {0}", house[i, j]);
            }
            floorcount += 1;
        }
    }
}

Measured memory_bytes: 9156
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        var N = Reader.String();
        int K = Reader.Int();
        var Bad = Reader.IntLine();
        Console.WriteLine(Solve(N, Bad));
    }

    string Solve(string S, int[] Bad)
    {
        int len = S.Length;
        var A = S.Select(c => c - '0').ToArray();
        var D = Enu.Range(0, 10).Where(d => !Bad.Contains(d)).ToArray();
        char min = (char)('0' + D[0]);

        int i = Array.FindIndex(A, a => !D.Contains(a));
        if (i < 0) return S;

        i = Array.FindLastIndex(A, i, a => D.Any(d => d > a));
        if (i >= 0) return S.Substring(0, i) + D.First(d => d > A[i]) + new string(min, len - i - 1);

        return D.First(d => d > 0) + new string(min, S.Length);
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { Dispose(); A = new string[0]; }
    public static void Set(TextReader r) { Init(); reader = r; }
    public static void Set(string file) { Init(); reader = new StreamReader(file); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    public static void Dispose() { reader.Dispose(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 13524
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	ll a, b;
	cin >> a >> b;

	if (a > 0 && b > 0) {
		cout << "Positive" << endl;
	}
	else if (a < 0 && b < 0) {
		if ((b - a + 1) % 2 == 0) {
			cout << "Positive" << endl;
		}
		else {
			cout << "Negative" << endl;
		}
	}
	else {
		cout << "Zero" << endl;
	}
	return 0;
}

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

int N;
vector<int> t(100001, 0);
vector<int> x(100001, 0);
vector<int> y(100001, 0);

int main(void){
    
    scanf("%d", &N);
    for(int i = 1; i <= N; ++i) scanf("%d %d %d", &t[i], &x[i], &y[i]);
    
    vector<int> ct, dis;
    for(int i = 0; i < N; ++i) ct.push_back(t[i + 1] - t[i]), dis.push_back(abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]));
    
    for(int i = 0; i < N; ++i){
        if((ct[i] - dis[i]) < 0 || (ct[i] - dis[i]) % 2 != 0) { printf("No\n"); return 0; }
    }
    printf("Yes\n");
    
    return 0;
}


Measured memory_bytes: 2428
#include <iostream>

using namespace std;

int main(int argc, const char *argv[]) {
  string n;
  cin >> n;
  for (int i = 0; i < n.size(); i++) {
    if (n[i] == '7') {
      cout << "Yes\n";
      return 0;
    }
  }
  cout << "No\n";

  return 0;
}

Measured memory_bytes: 3592
/** 
If comrades that you trust gather around you, hope can take physical form and become visible. That’s what I believe.
*/
#include <bits/stdc++.h>
using namespace std;
/**
(▀̿Ĺ̯▀̿ ̿) (ง ͠° ͟ل͜ ͡°)ง
*/
auto solve() -> void {
    int n; cin >> n;
    int64_t res = 0;
    for (int i = 1; i <= n; ++i) {
        res += n / i;
        if (n % i == 0) --res;
    }
    cout << res << '\n';
}
auto main() -> int {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int tc = 1;
    while (tc--) {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 3648
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int l = in.nextInt();
		List<String> arrayList = new ArrayList<>();
		in.nextLine();
		for(int i = 0; i < n;i++) {
			arrayList.add(in.nextLine());
		}
		in.close();
		Collections.sort(arrayList);
		for(String e : arrayList) {
			System.out.print(e);
		}

	}
}

Measured memory_bytes: 25044
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>

#define inf 0x3f3f3f3f

#define lc k << 1
#define rc k << 1 | 1

using namespace std;

typedef long long ll;

int n, k;
	char s[100005];
int main(){
	scanf("%s", s + 1);
	n = strlen (s + 1);
	for(int i = 1; i < n; i ++){
		if(s[i] == 'A' && s[i + 1] == 'C'){
			printf("Yes\n");
			return 0;
		}
	}
	printf("No\n");
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            string[] param = input.Split(' ');
            int n = int.Parse(param[0]);
            int m = int.Parse(param[1]);
            Console.WriteLine( (n-1) * (m-1) );
        }
    }
}

Measured memory_bytes: 11220
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

int main() {
    int N, A;
    cin >> N;
    vector<int> B(100001, 0);
    rep(i, N) {
        cin >> A;
        B[A]++;
    }
    int C = 0;
    rep(i, 100001) if (B[i] > 0) C += B[i] - 1;
    cout << N - (C + 1) / 2 * 2 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

#define pb push_back
#define mp make_pair

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef unsigned long long ull;
typedef long long ll;

int main() {
	ull H, W;
	cin >> H >> W;
	
	if (H == 1 || W == 1) {
		cout << 1;
	} else {
		cout << (H*W+1)/2;
	}

	cout << endl;
  return 0;
}

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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

int main(){
	cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
	
	string str;cin >> str;
	
	stack<char> st;
	int ans = 0;
	
	REP(i, str.size()){
		if(st.size() && st.top() != str[i]){
			ans += 2;
			st.pop();
		}
		else {
			st.push(str[i]);
		}
	}
	
	cout << ans << endl;

	
	return 0;
}


Measured memory_bytes: 512
#Macで実行する時
import sys
import os
if sys.platform=="darwin":
	base = os.path.dirname(os.path.abspath(__file__))
	name = os.path.normpath(os.path.join(base, '../atcoder/input.txt'))
	#print(name)
	sys.stdin = open(name)

a = str(input())

print(chr(ord(a)+1))




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

int main()
{
int i;
int x;
int K;
int N[ 5 ];

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> N[ 0 ];
	cin >> N[ 1 ];
	cin >> N[ 2 ];
	cin >> K;

	sort( N, N + 3 );

	cout << pow( (long long) 2, K ) * N[ 2 ]
		+ N[ 0 ] + N[ 1 ] << endl;

	return 0;
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<chrono>
using namespace std;
using ll = long long;
#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++)

int main() {
    int N, P;
    cin >> N >> P;
    vector<ll> ans0(N);
    vector<ll> ans1(N);
    rep(i, N) {
        int A;
        cin >> A;
        if (i == 0) {
            if (A%2 == 0) {
                ans0[0] = 2;
                ans1[0] = 0;
            }
            else {
                ans0[0] = 1;
                ans1[0] = 1;
            }
            continue;
        }
        if (A%2 == 0) {
            ans0[i] = ans0[i-1] *= 2;
            ans1[i] = ans1[i-1] *= 2;
        }
        else if (A%2 == 1) {
            ans0[i] = ans1[i-1] + ans0[i-1];
            ans1[i] = ans1[i-1] + ans0[i-1];    
        }
    }
    if (P == 1) {
        cout << ans1[N-1] << endl;
    }
    else {
        cout << ans0[N-1] << endl;
    }
}

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

using namespace std;

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

	vector<int> b, c;
	int a;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (i % 2 == 0) {
			b.emplace_back(a);
		} else {
			c.emplace_back(a);
		}
	}
	if (n % 2 == 0) {
		for (int i = c.size() - 1; i >= 0; i--) {
			cout << c[i] << " ";
		}
		for (int i = 0; i < b.size() - 1; i++) {
			cout << b[i] << " ";
		}
		cout << b[b.size() - 1] << endl;
	} else {
		if (n == 1) {
			cout << b[0] << endl;
		} else {
			for (int i = b.size() - 1; i >= 0; i--) {
				cout << b[i] << " ";
			}
			for (int i = 0; i < c.size() - 1; i++) {
				cout << c[i] << " ";
			}
			cout << c[c.size() - 1] << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3188
#include <cmath>
#include <iostream>

using namespace std;

typedef unsigned int uint32;

namespace {
bool IsPrime(uint32 x) {
  if (x == 2) {
    return true;
  }
  if (x % 2 == 0) {
    return false;
  }

  const uint32 m = static_cast<uint32>(sqrt(x));
  for (size_t i = 3; i <= m; i += 2) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}
} // namespace

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

  uint32 c = 0;
  uint32 x;
  for (uint32 i = 0; i < n; ++i) {
    cin >> x;
    if (IsPrime(x)) {
      ++c;
    }
  }
  cout << c << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define pri 1000000007
#define ftype  long double
#define endl '\n'
#define pr pair<ll,ll>
#define debug(x) cout<<#x<<" "<<x<<endl;
using namespace std;
ll power(ll x,ll y,ll p) 
{   ll res = 1; 
    x = x % p;    
    while (y > 0) 
    { 
            if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p;   
    } 
    return res; 
} 


void masterstroke(){
	ll n,k;cin>>n>>k;
	ll fact[n+7],ifact[n+7];
	fact[0]=1;ifact[0]=1;
	for(ll i=1;i<=n+4;i++){
		fact[i]=(fact[i-1]*i)%pri;
		ifact[i]=(power(fact[i],pri-2,pri));
	}
	for(ll j=1;j<=k;j++){
		if((j>n-k+1)||((k-1)<(j-1))){cout<<0<<endl;continue;}
		ll f1=fact[n-k+1];
		f1=(f1*ifact[n-k+1-j])%pri;
		f1=(f1*ifact[j])%pri;
		ll f2=fact[k-1];
		f2=(f2*ifact[j-1])%pri;
		f2=f2*(ifact[k-j])%pri;
		f1=(f1*f2)%pri;
		cout<<f1<<endl;
	}
	
}
int main(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(NULL);
	 ll t=1;//cin>>t;
	 for(ll i=0;i<t;i++)masterstroke();
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

#define ll long long
#define vecll vector<long long>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s >= 0;s--)

int main()
{
	ll n, q;
	string s;

	cin >> n >> q;

	cin >> s;

	vecll l(q), r(q),dp(n);

	forll(i, 0, q)
		cin >> l[i] >> r[i];

	dp[0] = 0;

	forll(i, 1, n)
	{
		dp[i] = dp[i-1];
		if (s[i-1] == 'A'&&s[i] == 'C')
		{
			dp[i]++;
		}
	}

	forll(i,0,q)
		cout << dp[r[i]-1]-dp[l[i]-1] << "\n";
}

Measured memory_bytes: 3456
import re
s = input()
y = "YES"
n = "NO"
if s == "keyence":
    print(y)
elif re.fullmatch(r'[a-z]+keyence',s) != None:
    print(y)
elif re.fullmatch(r'k[a-z]+eyence',s) != None:
    print(y)
elif re.fullmatch(r'ke[a-z]+yence',s) != None:
    print(y)
elif re.fullmatch(r'key[a-z]+ence',s) != None:
    print(y)
elif re.fullmatch(r'keye[a-z]+nce',s) != None:
    print(y)
elif re.fullmatch(r'keyen[a-z]+ce',s) != None:
    print(y)
elif re.fullmatch(r'keyenc[a-z]+e',s) != None:
    print(y)
elif re.fullmatch(r'keyence[a-z]+',s) != None:
    print(y)
else:
    print(n)


Measured memory_bytes: 9868
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
int main() {
string s,t;
cin >> s >> t;
sort(s.begin(),s.end());
sort(t.begin(),t.end());
reverse(t.begin(),t.end());

cout << (t>s?"Yes":"No") << endl; 
}

Measured memory_bytes: 3604
#include <bits/stdc++.h> 
using namespace std; 
#define fori(i,n) for (int i = 0; i < (n); i++)

int main(void) {
    int N;
    scanf("%d", &N);
    map<string, int> cnt;
    fori(i,N) {
        string s; cin >> s;
        cnt[s]++;
    }
    for (auto x : {"AC", "WA", "TLE", "RE"}) {
        cout << x << " x " << cnt[x] << "\n";
    }
    return 0;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
int main(){
  string s;
  int k;
  cin>>s>>k;
  int sz=s.size();
  vector<vector<int>> v(26);
  rep(i,sz)
    v[s[i]-'a'].push_back(i);
  set<string> se;
  rep(i,26){
     rep(j,v[i].size()){
        int e=1;
        while(v[i][j]+e<=sz&&e<=k)
          se.insert(s.substr(v[i][j],e++)); 
     }
     if(se.size()>=k)
     break;
  }
  cout<<*next(se.begin(),k-1); 
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include<math.h>
#include <algorithm>
using namespace std;

int main(){
	int n,a,b,c;

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		for(int i = 0; i < n; i++){
			scanf("%d %d %d",&a,&b,&c);
			if(a == 100 || b == 100 || c == 100 || a + b >= 180 || a+b+c >= 240){
				printf("A\n");
			}else if((a + b + c >= 210) || (a+b+c>=150 && (a >= 80 || b >= 80))){
				printf("B\n");
			}else{
				printf("C\n");
			}
		}

	}
    return 0;
}

Measured memory_bytes: 2500
from collections import deque

d = deque(input())

q = int(input())

headflag = 0

for i in range(q):
    s = input()
    if len(s) == 1:
        if headflag == 0:
            headflag = 1
        else:
            headflag = 0
    else:
        l = list(s)
        if headflag == 0:
            if l[2] == '1':
                d.appendleft(l[4])
            else:
                d.append(l[4])
        else:
            if l[2] == '2':
                d.appendleft(l[4])
            else:
                d.append(l[4])

result = ''.join(d)

if headflag == 0:
    print(result)
else:
    result = result[::-1]
    print(result)

print()


Measured memory_bytes: 8436
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
typedef long long ll;
using namespace std;
ll CEIL(ll a, ll b)
{
    ll res = a / b;
    if (a % b)
    {
        res++;
    }
    return res;
}
int main()
{
    ll a, b;
    ll n;
    cin >> n;
    cin >> a >> b;
    n--;
    ll x, y;
    for(int i=1;i<=n;i++)
    {
        cin >> x >> y;
        ll num = max(CEIL(a, x), CEIL(b, y));
        a = num * x;
        b = num * y;
    }
    cout << a + b << endl;
    return 0;
}

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

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const int MOD = 1e9 + 7;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e5+5;
ll n,result, m, l, r;
vector<ll> a;

int main () {
  // ios::sync_with_stdio(false);
  // cin.tie(nullptr);
  cin >> n >> m;
  rep(i,n) {
    cin >> l;
    a.push_back(l);
  }
  VSORT(a);
  ll x0 = 0, x1 = 300000;
  while(x1-x0 > 1) {
    ll x = (x0+x1) / 2;
    ll t = 0; // x以上の組み合わせの数
    rep(i,n) t += n - Lower_bound(a, x-a[i]);
    if(t >= m) x0 = x;
    else x1 = x;
    // cout << x << endl;
  }

  vector<ll> s(n+1, 0);
  for(int i=n-1;i>=0;i--) s[i] = s[i+1] + a[i];
  ll ans = 0, mm = 0;
  rep(i,n) {
    ll i0 = Lower_bound(a,x0 - a[i]);
    mm += n - i0;
    ans += s[i0] + a[i] * (n - i0);
  }
  ans -= x0 * (mm - m);
  cout << ans << endl;
}


Measured memory_bytes: 1908
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <map>
#include <set>
#include <stdlib.h>
#include <ctype.h>
#include <stack>
#include <bitset>
#include <iterator>
using namespace std;
#define ull unsigned long long
#define ll long long
#define ls k<<1
#define rs k<<1|1
#define lson l,mid,k<<1
#define rson mid+1,r,k<<1|1
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
typedef pair<double,int> pdi;
int lowbit(int x){return x&(-x);}
const int maxn=1e5+5,P=1e9+7;
ll b[maxn],a[maxn];
int n;
int main(void){
    scanf("%d",&n);
    for(int i=1;i<=n;++i) scanf("%lld",&a[i]);
  //  if(n&1){
            for(int i=1;i<=n;++i)
                if(i&1) b[1]+=a[i];
                else b[1]-=a[i];
            b[2]=2*a[1]-b[1];
            for(int i=2;i<n;++i)
                b[i+1]=2*a[i]-b[i];
            for(int i=1;i<=n;++i) printf("%lld%c",b[i],i==n?'\n':' ');
  //  }
   // else{
             return 0;
   }


Measured memory_bytes: 2816
import java.util.ArrayDeque

fun main(args: Array<String>){
    val (N, Q) = readLine()!!.split(" ").map(String::toInt)
    val g = Array(N+1){ mutableListOf<Int>() }
    repeat(N - 1){
        val (A, B) = readLine()!!.split(" ").map(String::toInt)
        g[A].add(B)
        g[B].add(A)
    }

    val points = IntArray(N+1)
    repeat(Q) {
        val (P, X) = readLine()!!.split(" ").map(String::toInt)
        points[P] += X
    }

    val queue = ArrayDeque(listOf(1))
    val visited = BooleanArray(N+1){ false }
    while(queue.isNotEmpty()){
        val cur = queue.poll()
        visited[cur] = true
        g[cur].forEach {
            if(!visited[it]){
                points[it] += points[cur]
                queue.add(it)
            }
        }
    }
    println(points.slice(1..N).joinToString(separator = " "))
}

Measured memory_bytes: 150100
#include <bits/stdc++.h>
#define endl "\n"
#define ff first
#define ss second
#define PB push_back
#define MP make_pair
#define ll long long
#define llu unsigned long long
#define MAX(a, b)  (((a) > (b)) ? (a) : (b))
#define MIN(a, b)  (((a) < (b)) ? (a) : (b))
#define ABS(X) ((X)< 0 ? -(X): (X))
#define LCM(X, Y)  ( ( (X) / (GCD( (X)  , (Y) ))) * (Y) )
#define MEM( A,  B) memset((A), (B), sizeof(A))
#define MEM_VEC(V, FILL ) fill( V.begin(), V.end(), FILL)
#define FOR_EACH(IT, V) for (auto IT = V.begin(); IT != V.end(); IT++)
#define DEBUG_ARRAY_PRINT(A,I) cout<<"at pos "<< I <<"  value is: "<< A[I]
#define TURBO ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0)
const double EPS =1e-9 ;
const double PI = 3.1415926535897932384626433832795 ;
using namespace std ;
inline ll GCD(ll A, ll B){
      if ( B == 0 ) return A;
      return GCD( (B) ,  (A % B) );
}
inline ll POW(ll BASE, ll EXP) {
   ll RES = 1;
   for(ll I= 0; I < EXP; I++) RES *= BASE ;
   return RES;
}

inline ll BIGMOD  ( ll a, ll p, ll m ) {
   ll res = 1 % m;
   ll x = a % m;
   while ( p > 0 ) {
       if ( (p & 1) > 0 ) res = ( res * x ) % m;
       x = ( x * x ) % m; p >>= 1;
   }
   return res;
}
inline void FILE_HANDLE( ){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

}

int main()
{
            TURBO;
            //FILE_HANDLE() ;
            string str ;
            cin >> str ;
            if(str[2] == str[3] && str[4] == str[5]) cout <<"Yes\n" ;
            else cout <<"No\n" ;
}



Measured memory_bytes: 3624
n=gets.to_i
hash={}
n.times do |i|
  cha=gets.chomp
  if hash[cha]
    hash[cha]+=1
  else
    hash[cha]=1
  end
end

max=hash.values.max
hash=hash.select{|k,v| v==max}.sort
hash.map{|k,v|puts k}


Measured memory_bytes: 55232
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> n >> m;
  if (n == m)
    Cout("Yes");
  else
    Cout("No");
  return 0;
}

Measured memory_bytes: 256
# n個の点全てを含む円のうち半径が最小である円の
# 中心座標と半径を求める
class SolvCircle

    LOOP_MAX = 100

    # 移動距離がこの値以下になったら処理を終了させる
    CONVRGV = 1.0e-9

    #
    #=== 円の中心座標と半径を求める
    #
    #_pt_x_ :: n個の点のx座標の配列
    #_pt_y_ :: n個の点のy座標の配列
    # 
    #返り値::配列を返す。[中心点のx座標, 中心点のy座標, 円の半径]
    #
    def solv_circle(pt_x, pt_y)
        mv_rate  = 0.5 # 移動係数
        max_dist = 0.0 # 中心点から最遠点までの距離
        xsv      = 0.0 # 中心点のx座標
        ysv      = 0.0 # 中心点のy座標
        cx       = 0.0 # 仮中心点のx座標
        cy       = 0.0 # 仮中心点のy座標
        k        = 0
        cvgflg   = false

        while (cvgflg == false)

            LOOP_MAX.times { |t|
                # 最遠点を求める
                max_dist = 0.0
                pt_x.length.times { |i|
                    dist = distance(cx, cy, pt_x[i], pt_y[i])
                    if (dist > max_dist)
                        max_dist = dist
                        k        = i
                    end
                }

                # 仮の中心点を計算
                cx += (pt_x[k] - xsv) * mv_rate
                cy += (pt_y[k] - ysv) * mv_rate

                # 移動距離が境界値を下回っていればループを抜ける
                if (distance(cx, cy, xsv, ysv) <= CONVRGV)
                    cx     = xsv
                    cy     = ysv
                    cvgflg = true
                    break
                end

                xsv = cx
                ysv = cy
            }

            mv_rate /= 2.0

        end

        return [cx, cy, max_dist]
    end

    #
    #=== 二点の距離を求める
    #
    def distance(x1, y1, x2, y2)
        dx = x2 - x1
        dy = y2 - y1
        Math.sqrt(dx * dx + dy * dy)
    end
end

N = gets.to_i
x = Array.new(N)
y = Array.new(N)
N.times{|i| x[i],y[i] = gets.split.map(&:to_i)}

sc = SolvCircle.new
ans = sc.solv_circle(x, y)
puts ans[2]

Measured memory_bytes: 3836
import std;

void main() {
    int n, k; scan(n, k);
    auto s = new int[n + 1];
    foreach (_; 0..k) {
        readint;
        foreach (e; readints) s[e]++;
    }
    auto ans = n - s[1..$].count!(e => e > 0);
    writeln(ans);
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


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

if N == 1:
    print(0)
    exit()

Z = 10 ** 9 + 7
a = 1
b = 1
c = 1
for n in range(N):
    a *= 10
    b *= 9
    c *= 8

    a = a % Z
    b = b % Z
    c = c % Z

print((a - 2 * b + c) % Z)

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;

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

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  int r; std::cin >> r;
  std::cout << 3 * r * r << "\n";
}


Measured memory_bytes: 256
// ------------------------------------
// Date:2018/ 3/25
// Problem:_ _ _ a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(a, b, c, d);
  cout << min(a, b) + min(c, d) << endl;

  return 0;
}



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

int main() {
	int K,S,r=0;
	cin >> K >> S;

	rep(i,min(K+1, S+1))
		rep(j,min(K+1, S+1-i))
			if(S-i-j <= K)
					r++;
	
	cout << r << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			w = scanner.nextInt();
			h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			map = new boolean[h][w];
			for (int i = 0; i < h; i++) {
				char[] c = scanner.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (c[j] == '@') {
						sy = i;
						sx = j;
					} else if (c[j] == '#')
						map[i][j] = true;
				}
			}
			System.out.println(dfs(sy, sx));

		}
	}

	private int dfs(int y, int x) {
		int ans = 0;
		if (!isOK(y, x) || map[y][x])
			return ans;

		map[y][x] = true;
		ans++;
		for (int[] m : move) {
			int ny = y + m[0];
			int nx = x + m[1];
			ans += dfs(ny, nx);
		}
		return ans;
	}

	private boolean isOK(int ny, int nx) {
		return 0 <= ny && ny < h && 0 <= nx && nx < w;
	}

	int w, h, sy, sx;
	boolean[][] map;
	int[][] move = { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

}

Measured memory_bytes: 26780
// C++ implementation of the approach 
#include <bits/stdc++.h> 
using namespace std; 

// Function that returns true if n 
// is prime else returns false 
bool isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) return false; 
	if (n <= 3) return true; 
	
	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n%2 == 0 || n%3 == 0) return false; 
	
	for (int i=5; i*i<=n; i=i+6) 
		if (n%i == 0 || n%(i+2) == 0) 
		return false; 
	
	return true; 
} 

// Function to return the smallest 
// prime number greater than N 
int nextPrime(int N) 
{ 

	// Base case 
	if (N <= 1) 
		return 2; 

	int prime = N; 
	bool found = false; 

	// Loop continuously until isPrime returns 
	// true for a number greater than n 
	while (!found) { 
		prime++; 

		if (isPrime(prime)) 
			found = true; 
	} 

	return prime; 
} 

// Driver code 
int main() 
{ 
	int N;
    cin>>N; 
    if(isPrime(N)){
        cout<<N<<endl;
    }
    else{
	cout << nextPrime(N); 
    }
	return 0; 
} 


Measured memory_bytes: 256
// Author -- Frame

#include<bits/stdc++.h>

#define lowbit(x) ((x)&(-(x)))
#define Finline __inline__ __attribute__ ((always_inline))
#define DEBUG fprintf(stderr,"Running on Line %d in Function %s\n",__LINE__,__FUNCTION__)
#define SZ(x) ((int)x.size())
#define mkpr std::make_pair
#define pb push_back

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef std::pair<int,int> pi;
typedef std::pair<ll,ll> pl;

const int inf=0x3f3f3f3f,Inf=0x7fffffff;
const ll INF=0x3f3f3f3f3f3f3f3f;

Finline uint rnd()
{
	static uint seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
template <typename _Tp>_Tp gcd(const _Tp &a,const _Tp &b){return (!b)?a:gcd(b,a%b);}
template <typename _Tp>Finline _Tp abs(const _Tp &a){return a>=0?a:-a;}
template <typename _Tp>Finline _Tp max(const _Tp &a,const _Tp &b){return a<b?b:a;}
template <typename _Tp>Finline _Tp min(const _Tp &a,const _Tp &b){return a<b?a:b;}
template <typename _Tp>Finline void chmax(_Tp &a,const _Tp &b){(a<b)&&(a=b);}
template <typename _Tp>Finline void chmin(_Tp &a,const _Tp &b){(b<a)&&(a=b);}
template <typename _Tp>Finline void read(_Tp &x)
{
	char ch(getchar());
	bool f(false);
	while(ch<48||ch>57) f|=ch==45,ch=getchar();
	x=ch&15,ch=getchar();
	while(ch>=48&&ch<=57) x=(((x<<2)+x)<<1)+(ch&15),ch=getchar();
	if(f) x=-x;
}
template <typename _Tp,typename... Args>Finline void read(_Tp &t,Args &...args){read(t);read(args...);}
template <typename _Tp,typename... Args>Finline _Tp min(const _Tp &a,const _Tp &b,const Args &...args){return a<b?min(a,args...):min(b,args...);}
template <typename _Tp,typename... Args>Finline _Tp max(const _Tp &a,const _Tp &b,const Args &...args){return a<b?max(b,args...):max(a,args...);}
Finline int read_str(char *s)
{
	char ch(getchar());
	while(ch==' '||ch=='\r'||ch=='\n') ch=getchar();
	char *tar=s;
	*tar=ch,ch=getchar();
	while(ch!=' '&&ch!='\r'&&ch!='\n'&&ch!=EOF) *(++tar)=ch,ch=getchar();
	return tar-s+1;
}

const int N=100005;
int cnt[65][65];
int main()
{
	int n;read(n);
	double y;
	ll ans=0;
	for(int i=1;i<=n;++i)
	{
		scanf("%lf",&y);
		ll x=y*1000000000.0+0.5;
		int c1=-9,c2=-9;
		while(!(x%2)) ++c1,x>>=1;
		while(!(x%5)) ++c2,x/=5;
		if(c1>=0&&c2>=0) --ans;
		++cnt[c1+9][c2+9];
	}
	for(int i=0;i<=50;++i)
	{
		for(int j=0;j<=50;++j)
		{
			for(int x=0;x<=50;++x)
			{
				for(int y=0;y<=50;++y)
				{
					if(i+x>=18&&j+y>=18)
					{
						ans+=1ll*cnt[i][j]*cnt[x][y];
					}
				}
			}
		}
	}
	printf("%lld\n",ans>>1);
	return 0;
}


Measured memory_bytes: 3744
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

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


const int INF = 100000000;
const int MAX_N = 100;
const int MAX_M = 100;
const int dy[4] = {-1, 0, 1, 0 };
const int dx[4] = { 0, 1, 0,-1 };

char maze[MAX_N][MAX_M+1];
int N, M;
int sy, sx;
int cost[MAX_N][MAX_M];

int bfs (void ){
	rep (i, N ) rep (j, M ) cost[i][j] = INF;
	queue<P> que;
	que.push (P (sy, sx ) );
	cost[sy][sx] = 0;
	while (!que.empty() ){
		P cur = que.front(); que.pop();
		int cy = cur.first;
		int cx = cur.second;
		int cc = cost[cy][cx];
		rep (k, 4 ){
			int ny = cy + dy[k];
			int nx = cx + dx[k];
			if (ny < 0 || ny >= N || nx < 0 || nx >= M ) continue;
			int next_cost = cost[cy][cx] + ((maze[ny][nx] == '#' && maze[cy][cx] != '#') ? 1 : 0 );
			if (next_cost >= cost[ny][nx] ) continue;
			cost[ny][nx] = next_cost;
			que.push (P (ny, nx ) );
		} // end rep
	} // end rep

	int res = INF;
	rep (i, N ) res = min (res, cost[i][0] );
	rep (i, N ) res = min (res, cost[i][M-1] );
	rep (j, M ) res = min (res, cost[0][j] );
	rep (j, M ) res = min (res, cost[N-1][j] );

	return res;	
}

int main()
{
	ios_base::sync_with_stdio(0);
	while (cin >> M >> N, M ){
		memset (maze, 0, sizeof (maze ) );
		memset (cost, 0, sizeof (cost ) );
		rep (i, N ) rep (j, M ) cin >> maze[i][j];
		rep (i, N ) rep (j, M ) if (maze[i][j] == '&' ){ sy = i, sx = j; }
		int res = bfs ();
		cout << res << endl;
	} // end while
	
	return 0;
}

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


def solve(N: int, K: int):
    k = K
    power2 = 1
    n = N
    total = 0
    while k > 0:
        if n < k:
            k = int(math.ceil(k / 2))
            power2 *= 0.5
            continue
        total += (n - k + 1) * power2
        n = k - 1
        power2 *= 0.5
        if k == 1:
            break
        k = int(math.ceil(k / 2))
    print(total / N)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


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

int main() {
  int N;
  cin >> N;
  ll ans = 0;
  for (int i = 1; i <= N; ++i) {
    if (i % 3 == 0 && i % 5 == 0) {
    } else if (i % 3 == 0) {
    } else if (i % 5 == 0) {
    } else {
        ans += i;
    }
  }
  printf("%lld\n", ans);
  return 0;
}

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

#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n)  for(int i=0;i<(n);++i)
#define REPr(i, n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m, n) for(int i = (n);i >=(m);--i)
#define PB push_back
#define MP make_pair
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x, S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x, y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

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

template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
///////////////////////////////////////////////
/*（๑•﹏•๑｀) */

int main() {
	ll R,G,B,N;
	ll ans = 0;
	cin >> R >> G >> B >> N;
	FORq(x,0,3000){
		FORq(y,0,3000){
			ll XY = x * R + y * G;
			if (XY > N) continue;
			if ((N - XY) % B == 0) ans++;
		}
	}

	cout << ans << "\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll  long long int 
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define F first
#define S second
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
int main()
{
  ll i,j,k,t;
  ll arr[32]={1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
  cin>>j;
  cout<<arr[j-1];
}

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

int main(){
  int n;
  cin >> n;
  vector<int> score(n);
  
  for(int i=0; i<n; i++){
    cin >> score.at(i);
  }
  
  for(int i=1 ; i < n ; i++){
    int v = score.at(i);
    int j=i-1;
    while( j >= 0 && score.at(j) > v ){
      score.at(j+1) = score.at(j);
      j--;
    }
    score.at(j+1) = v;
  }
  
  int ans = 0;
  
  if(n%2==0){
    for(int i=n-1; i >= 0; i--){
      if(i%2==1){
        ans += score.at(i);
      }else{
        ans -= score.at(i);
      }
    }
  }else{
    for(int i=n-1; i>=0; i--){
      if(i%2==0){
        ans += score.at(i);
      }else{
        ans -= score.at(i);
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
	int a,b,c;
	int ans;
	
	string cunning="7767555555555555555555555555555555555555545555555555555";
	
	for(int i=0;i<104;i++){
		cin>>a>>b;c=a+b;
		//-----test-----
		if(i<cunning.size()){
			cout<<cunning[i]<<endl;
			continue;
		}
		//--------------
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1204
#include <cstdio>
#include <string.h>
using namespace std;

int main (void)
{
	int ta=0, ha=0, i, n;
	char t[101], h[101];

	scanf("%d", &n);

	for (i=0; i<n; i++){
		scanf("%s %s", t, h);
		if (strcmp(t, h) < 0)
			ha += 3;
		else if (strcmp(t, h) > 0)
			ta += 3;
		else{
			ta++;
			ha++;
		}
	}

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

Measured memory_bytes: 1032
s = list(map(int, input()))
ans = abs(753-(int(s[0]*100 + s[1]*10 + s[2])))

for i in range(1, len(s)-2):
    tmp = abs(753-(int(s[i]*100 + s[i+1]*10 + s[i+2])))
    if tmp < ans:
        ans = tmp

print(ans)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}

long long com(long long n,long long k){
	
}
long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}

class Point{
public:
	long long x;
	long long y;
};


int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string s;
	cin>>s;
	long long anum=INF;
	int znum=0;
	for(int i=0;i<s.length();i++){
		if(s[i]=='A')anum=min(i,anum);
		if(s[i]=='Z')znum=max(i,znum);
	}
	cout<<znum-anum+1<<endl;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;

int N, K;
vector<int> u, v;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
    cin >> N >> K;
    for (int i = 0; i < N; i++)
    {
        int a;
        cin >> a;
        v.push_back(a);
    }
    int ans = 0;
    sort(v.begin(), v.end());
    for (int i = 0; i < N - 1; i++)
    {
        if (v[i] > K)
            break;
        else
            K -= v[i], ans++;
    }
    if (v[N - 1] == K)
        ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a,b,c,d,e,f;
scanf("%d%d%d%d",&a,&b,&c,&d);
if(a>=1 && a<=100 && b>=1 && b<=100 && c>=1 && c<=100 && d>=1 && d<=100 )   
{e=c;
 f=a;
while(e>0 && f>0)
{e=e-b;
 f=f-d;}                     
if(e<=0)        
{printf("Yes\n");}                
else if(f<=0)                                  
{printf("No\n");}                            
}   
return 0;   
}

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

int main(){
    int n; cin>>n;
    vector<int>d(n);
    for(int i=0;i<n;i++){cin>>d.at(i);}
    sort(d.begin(),d.end(),greater<int>());
    int a=0,b=0;
    for(int i=0;i<n;i++){
        if(i%2==0){
            a+=d.at(i);
        }else{b+=d.at(i);
        }
    }
    cout<<a-b<<endl;
    return 0;
    }


Measured memory_bytes: 256
N = int(input())
numbers = list(map(int, input().split()))
Alice_point = 0
Bob_point = 0

numbers.sort(reverse=True)

while True:
    try:
        Alice_point += numbers[0]
        Bob_point += numbers[1]
        numbers.remove(numbers[0])
        numbers.remove(numbers[0])
    except IndexError:
        break

print(Alice_point - Bob_point)


Measured memory_bytes: 3060
program integer_of_the_s
  implicit none
  integer :: n, k, a, c(-1:31), i, j
  integer(8) :: m(-1:31), b
  c = -1
  m = 0_8
  read(*,*) n, k
  c(-1) = k
  do i = 0, 31
    if (btest(k,i)) then
      c(i) = ibclr(k,i)
      do j = 0, i-1
        c(i) = ibset(c(i),j)
      end do
    end if
  end do
  do i = 1, n
    read(*,*) a, b
    do j = -1, 31
      if (c(j).lt.0) cycle
      if (or(c(j),a).eq.c(j)) then
        m(j) = m(j)+b
      end if
    end do
  end do
  write(*,'(i0)') maxval(m)
  stop
end program integer_of_the_s

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

Measured memory_bytes: 4420