akhauriyash/Code-Regression huggingface dataset:
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    a, b, k = i_map()

    ans_list = []

    for i in range(a,a+k):
        if i > b:
            continue
        ans_list.append(i)

    for i in range(b-k+1,b+1):
        if i < a:
            continue
        ans_list.append(i)

    ans_list = list(set(ans_list))

    for num in ans_list:
        print(num)

if __name__ == '__main__':
    main()


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

#define el '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define DEBUG cerr << "DEBUG >>> " 
#define ms(a,b) memset(a, b, sizeof(a))

typedef long long ll;

const int nax = 1e5+5;
int mark[nax];
int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cerr.tie(0);

  int n, m;
  cin >> n >> m;
  for(int i = 0; i < m; i++){
    int l, r;
    cin >> l >> r;
    mark[l]++;
    mark[r+1]--;
  }
  int ans = 0, pl = 0;
  for(int i = 0; i <= n; i++){
    pl += mark[i];
    if(pl==m) ans++;
  }
  cout << ans << el;

  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int a[200005];
int min1=0x3f3f3f3f;
int ans=0;
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(a[i]<min1)
		{
			min1=a[i];
			ans++;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#define load ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
#define ll long long
#define ull unsigned long long
#define fori(i,n) for (int i=0; i<int(n);i++)
#define srt(v) sort(v.begin(), v.end())
const int INF = 1e9;
const double PI = 3.14159265358979323846;
#define PIe 3.14159265358979323846264338327950L


ll gcd(ll a, ll b) {
    return b != 0 ? gcd(b, a % b) : a;
}

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

void solve(){

}

int main(){
	load;
	int a,b,h,m;
	cin >> a >> b >> h >> m;
	long double result =0, deg;
	deg = ((long double)h*5 + (long double)m/12)-((long double) m);
	if (deg <0) deg = -deg;
	deg *= 6;
	deg *= PIe/(long double)180; // convert to radion, bcs cos() takes rad as parameter
	result = (long double)(a*a + b*b) - (long double)(2*a*b)*cosl(deg);

	printf("%.20Lf\n", sqrtl(result));

	return 0;
}



Measured memory_bytes: 4172
/*****************************************
Author: lizi
Email: lzy960601@outlook.com
*****************************************/
  
#include<bits/stdc++.h>
  
using namespace std;
  
const double eps=1e-10;
const double pi=3.1415926535897932384626433832795;
const double eln=2.718281828459045235360287471352;
  
#define LL long long
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
#define scan(x) scanf("%d", &x)
#define mp make_pair
#define pb push_back
#define sqr(x) (x) * (x)
#define pr(x) printf("Case %d: ",x)
#define prn(x) printf("Case %d:\n",x)
#define prr(x) printf("Case #%d: ",x)
#define prrn(x) printf("Case #%d:\n",x)
#define lowbit(x) (x&(-x))
#define fi first
#define se second
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

int n,k;
int a[1005][1005];

int main()
{
    scanf("%d",&n); k=0;
    for(int i=2;true;i++)
    {
        if(i*(i-1)/2 > n)break;
        if(i*(i-1)/2 == n) {k=i;break;}
    }
    if(k==0){puts("No");return 0;}
    puts("Yes");
    printf("%d\n",k); int cnt=0;
    for(int bs=1;bs<k;bs++)
    {
        for(int i=bs;i<k;i++)a[bs][i]=cnt+i-bs+1;
        for(int i=bs;i<k;i++)a[i+1][bs]=cnt+i-bs+1;
        cnt+=k-bs;
    }
    for(int i=1;i<=k;i++)
    {
        printf("%d",k-1);
        for(int j=1;j<k;j++)printf(" %d",a[i][j]);
        puts("");
    }
    return 0;
}


Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nm = Add.ar;
        var ps = Add.ar;
        var un = new UnionFind<int>();
        for (var i = 0; i < nm[0]; i++)
            un.MakeSet(i + 1);
        for(var i = 0; i < nm[1]; i++)
        {
            var input = Add.ar;
            un.Union(input[0], input[1]);
        }
        var res = 0;
        for (var i = 0; i < nm[0]; i++)
            if (un.IsSame(i + 1, ps[i]))
                res++;
        WriteLine(res);
    }
}

public class Add
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}

public class UnionFind<T>
{
    private class Vertex
    {
        public T Key { get; set; }
        public Vertex Parent { get; set; }
        public int Rank { get; set; }

        public Vertex(T key) : this(key, null, 0)
        {

        }
        public Vertex(T key, Vertex Parent, int rank)
        {
            this.Key = key;
            this.Parent = Parent;
            this.Rank = rank;
        }
    }
    private readonly Dictionary<T, Vertex> dics;
    private readonly Vertex NIL;

    public int Count { get; private set; }

    public UnionFind()
    {
        NIL = new Vertex(default(T));
        dics = new Dictionary<T, Vertex>();
    }
    
    public T parent(T key)
        => FindSet(dics[key].Parent).Key;

    public bool IsSame(T key1, T key2)
    {
        if (!dics.ContainsKey(key1) || !dics.ContainsKey(key2))
            throw new ArgumentException("対応する頂点が存在しません");
        return ReferenceEquals(FindSet(dics[key1]),FindSet(dics[key2]));
    }

    public bool MakeSet(T key)
    {
        if (dics.ContainsKey(key))
            throw new ArgumentException($"{key}をキーとして持つ頂点が既に存在します");
        dics[key] = new Vertex(key, NIL, 0);
        dics[key].Parent = dics[key];
        Count++;
        return true;
    }

    public bool Union(T key1, T key2)
    {
        if (!dics.ContainsKey(key1) || !dics.ContainsKey(key2))
            throw new ArgumentException("対応する頂点が存在しません");
        if (IsSame(key1, key2)) return false;
        Link(FindSet(dics[key1]), FindSet(dics[key2]));
        Count--;
        return true;
    }

    private bool Link(Vertex vex1, Vertex vex2)
    {
        if (vex1.Rank > vex2.Rank)
            vex2.Parent = vex1;
        else
        {
            vex1.Parent = vex2;
            if (vex1.Rank == vex2.Rank)
                vex2.Rank++;
        }
        return true;
    }

    private Vertex FindSet(Vertex vex)
    {
        if (!ReferenceEquals(vex.Parent, vex))
            vex.Parent = FindSet(vex.Parent);
        return vex.Parent;
    }
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;


int main() {
    int n;
    cin >> n;
    char s;
    for(int i = 0; i < n; i++){
        cin >> s;
        if(s=='Y'){
            cout << "Four" << endl;
            return 0;
        }
    }
    cout << "Three" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <tuple>

int main() {
  size_t n;
  scanf("%zu", &n);

  std::vector<intmax_t> a(n);
  for (auto& ai: a) scanf("%jd", &ai);

  a.insert(a.begin(), 0);
  for (size_t i = 1; i <= n; ++i) a[i] += a[i-1];

  std::vector<std::tuple<size_t, size_t, size_t>> cand;
  for (size_t j = 2; j+1 < n; ++j) {
    size_t i = std::lower_bound(a.begin(), a.begin()+j, a[j]/2) - a.begin();
    size_t k = std::lower_bound(a.begin()+j, a.end(), a[j]+(a[n]-a[j])/2) - a.begin();

    for (int di = -2; di <= 2; ++di)
      for (int dk = -2; dk <= 2; ++dk) {
        cand.emplace_back(i+di, j, k+dk);
        // cand.emplace_back(j-di, j, k+dk);
        // cand.emplace_back(i+di, j, j+dk);
        // cand.emplace_back(j-di, j, j+dk);
      }
  }

  intmax_t res = a[n];
  for (auto const& t: cand) {
    size_t i, j, k;
    std::tie(i, j, k) = t;
    if (!(0 < i && i < j && j < k && k < n)) continue;
    intmax_t min, max;
    std::tie(min, max) = std::minmax({a[i], a[j]-a[i], a[k]-a[j], a[n]-a[k]});
    res = std::min(res, max-min);
  }

  printf("%jd\n", res);
}


Measured memory_bytes: 202064
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans,n,m;
vector<bool>ar(11);
vector<vector<int>>vc(11);
vector<ll>p(11);
bool chk()
{
    for(int i=1;i<=m;i++)
    {
        ll temp=0;
        for(auto it:vc[i])
        {
            if(ar[it])
                temp++;
        }
        if(temp%2!=p[i])
            return 0;
    }
    return 1;
}
void fun(int i)
{
    if(i>n)
    {
        if(chk())
            ans++;
        return;
    }
    ar[i]=0;    fun(i+1);   ar[i]=1;    fun(i+1);
}
void solve()
{
    cin>>n>>m;
    for(ll i=1;i<=m;i++)
    {
        ll l;cin>>l;
        vector<int>vcc(l);
        for(int j=0;j<l;j++)
            cin>>vcc[j];
        vc[i]=(vcc);
    }
    for(ll i=1;i<=m;i++)
        cin>>p[i];
    fun(1);
    cout<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

MOD = 10**9 + 7

def main(K, N, MOD):
    def fact_table(N, MOD):
        inv = np.empty(N, np.int64)
        inv[0] = 0
        inv[1] = 1
        for n in range(2, N):
            q, r = divmod(MOD, n)
            inv[n] = inv[r] * (-q) % MOD
        fact = np.empty(N, np.int64)
        fact[0] = 1
        for n in range(1, N):
            fact[n] = n * fact[n - 1] % MOD
        fact_inv = np.empty(N, np.int64)
        fact_inv[0] = 1
        for n in range(1, N):
            fact_inv[n] = fact_inv[n - 1] * inv[n] % MOD
        return fact, fact_inv, inv

    fact, fact_inv, inv = fact_table(2_000_010, MOD)
    f = np.zeros(K + 1, np.int64)
    f = fact[N - 1:K + N] * fact_inv[N - 1] % MOD * fact_inv[0:K + 1] % MOD

    x = 1
    for i in range(1, K + 1):
        x = (x * 25) % MOD
        f[i] = f[i] * x % MOD
    for i in range(1, K + 1):
        f[i] += f[i - 1] * 26
        f[i] %= MOD
    return f[-1]

if sys.argv[-1] == 'ONLINE_JUDGE':  #　なにそれ
    import numba
    from numba.pycc import CC
    i8 = numba.from_dtype(np.int64)
    signature = (i8, i8, i8)

    cc = CC('my_module')
    cc.export('main', signature)(main)
    cc.compile()


from my_module import main
K = int(readline())
N = len(read().rstrip())

print(main(K, N, MOD))


Measured memory_bytes: 73944
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	if(s=="SSS")
		cout<<"0\n";
	if(s=="RSS"||s=="SRS"||s=="SSR"||s=="RSR")
		cout<<"1\n";
	if(s=="RRS"||s=="SRR")
		cout<<"2\n";
	if(s=="RRR")
		cout<<"3"; 
	return 0;
}

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

int main(){
	int a, b, d, r;
	double f;

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

	d = a / b;
	r = a % b;
	f = (double) a / b;

	printf("%d %d %f\n", d, r, f);

	return 0;
}


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

using namespace std;

int main()
{
    double w;
    while (cin >> w) {
        if (w <= 48) {
            cout << "light fly" << endl;
        } else if (w <= 51) {
            cout << "fly" << endl;
        } else if (w <= 54) {
            cout << "bantam" << endl;
        } else if (w <= 57) {
            cout << "feather" << endl;
        } else if (w <= 60) {
            cout << "light" << endl;
        } else if (w <= 64) {
            cout << "light welter" << endl;
        } else if (w <= 69) {
            cout << "welter" << endl;
        } else if (w <= 75) {
            cout << "light middle" << endl;
        } else if (w <= 81) {
            cout << "middle" << endl;
        } else if (w <= 91) {
            cout << "light heavy" << endl;
        } else {
            cout << "heavy" << endl;
        }            
    }
    return 0;
}

Measured memory_bytes: 3160
#include <iostream>
using namespace std;
using ll = long long;
#define in(v) v; cin >> v;
#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)

int main() {
  int in(M);

  ll sum = 0, keta = 0;
  rep(i, M) {
    ll d, c; cin >> d >> c;
    sum += d * c;
    keta += c;
  }
  cout << (sum-1) / 9 + keta - 1 << endl;

  return 0;
}


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

int main(){
    int n;
    cin >> n;
    char t[10];
    string s[n];
    rep(i,n) {
        rep(j,10) cin >> t[j];
        sort(t,t+10);
        s[i] = t;
    }
    sort(s,s+n);
    ll ans = 0;
    ll c = 1;
    for(int i = 1; i < n; i++){
        if(s[i] == s[i-1]) c++;
        else {
            ans += (c*(c-1))/2;
            c = 1;
        }
    }
    if(c >= 2) ans += (c*(c-1))/2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
h,w=map(int,input().split())
l=[]
for i in range(h):
  l.append(input())
a=[]
for i in range(h):
  if list(set(l[i]))!=list('.'):
    a.append(l[i])
for i in range(w):
  c=True
  for j in range(len(a)):
    if a[j][i]=='#':
      c=False
  if c:
    for j in range(len(a)):
      a[j]=a[j][:i]+'a'+a[j][i+1:]
    w-=1
for i in range(len(a)):
  a[i]=a[i].replace('a','')
for i in range(len(a)):
  print(a[i])

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
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 print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int t[105];

int main(){
	int n;
	int i,j,k;
	int a,b,c;
	int s=0;
	cin>>n;
	for(i=0,a=0;i<n;i++){
		cin>>t[i];
		a+=t[i];
	}
	s=a;
	for(i=0,c=0;i<n;i++){
		c+=t[i];
		b=abs(a-2*c);
		s=min(b,s);
	}
	cout<<s<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int bubble_sort(int a[],int n)
{
    int cnt=0;
    bool flag=true;
    for(int i=0;i<n-1&&flag;i++)
    {
        flag=false;
        for(int j=0;j<n-1-i;j++)
        {
            if(a[j]>a[j+1])
            {
                swap(a[j],a[j+1]);
                cnt++;
                flag=true;
            }
        }
    }
    return cnt;
}

int main()
{
    int n;
    int a[101];

    cin>>n;

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

    int cnt=bubble_sort(a,n);

    for(int i=0;i<n;i++)
    {
        if(i)
        {
            cout<<" ";
        }
        cout<<a[i];
    }

    cout<<endl<<cnt<<endl;

    return 0;
}



Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n,i,j,m,c=0,ca=0,cb=0,cab=0;
  cin>>n;
  string s;
  for(i=0;i<n;i++){
	cin>>s;
    m=s.size();
    for(j=0;j<m-1;j++){
		if(s[j]=='A'&&s[j+1]=='B'){
          c++;
        }
    }
    if(s[0]=='B'&&s[m-1]!='A'){
	   cb++;
    }else if(s[m-1]=='A'&&s[0]!='B'){
       ca++;
    }else if(s[0]='B'&&s[m-1]=='A'){
	   cab++;
    }
  }

  if(cab==0){
    cout<<c+min(ca,cb)<<endl;
  }else{
    if(ca==0&&cb==0){
    cout<<c+cab-1<<endl;
    }else{
     cout<<c+cab+1+min(ca-1,cb-1)<<endl;
    }
  }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

int cmp(const void *a,const void *b){
  return *(int *)a-*(int *)b;
}

void run(void){
  int n,c,k;
  scanf("%d%d%d",&n,&c,&k);
  int *t=(int *)calloc(n,sizeof(int));
  int i;
  for(i=0;i<n;i++) scanf("%d",t+i);
  qsort(t,n,sizeof(int),cmp);
  int ans=0;
  i=0;
  while(i<n){
    int j=i;
    while(j<n && t[j]-t[i]<=k && j-i<c) j++;
    ans++;
    i=j;
  }
  printf("%d\n",ans);
}

int main(void){
  run();
  return 0;
}


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





int main() {
  int r,g,b;
  cin>>r>>g>>b;
  
  if ((100*r+10*g+b)%4==0){
    cout<<"YES"<<endl;
  }
  else {
    cout<<"NO"<<endl;
  }
  
    
    
  
  
}













Measured memory_bytes: 256
#include <bits/stdc++.h>
// For policy based data structure
/*#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> */
using namespace std;
/*using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    new_data_set;*/
 
#define MD 1000000007
#define X first
#define Y second
#define pb push_back
#define debug(val, ch) cout <<val <<ch
 
typedef long long int ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<int, bool> pib;
typedef pair<bool, int> pbi;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
int find(vector<int>&par,int a)
{
	if(par[a]==a)
	{
		return a;
	}
	par[a]=find(par,par[a]);
	return par[a];
}
/*********************************************************************/
void test(int r)
{
	int n,m;
	cin>>n>>m;
	vector<int>par(n+1,0),cn(n+1,0);
	int i,j;
	for(i=1;i<=n;i++)
	{
		par[i]=i;
		cn[i]=1;
	}
	for(i=1;i<=m;i++)
	{
		int a,b;
		cin>>a>>b;
		int p1,p2;
		p1=find(par,a);
		p2=find(par,b);
		if(p1!=p2)
		{
			par[p1]=p2;
			cn[p2]+=cn[p1];
		}

	}
	int mx=0;
	for(i=1;i<=n;i++)
		mx=max(mx,cn[i]);
	cout<<mx<<endl;
	

}
/***********************************************************************/
int main()
{
	fast();
    int t=1,r;
    // cin>>t;
    for(r=1;r<=t;r++)
        test(r);
    return 0;
}

Measured memory_bytes: 4772
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

typedef long long ll;

int max(int a, int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

  ll n;

void func(ll cur, int use, ll *counter){

  if(cur > n) return;
  if(use == 0b111) ++(*counter);

  func(cur*10 + 3, use | 0b001, counter);
  func(cur*10 + 5, use | 0b010, counter);
  func(cur*10 + 7, use | 0b100, counter);

}

int main(){

  scanf("%d",&n);
  ll *res_ptr;
  ll res = 0;
  res_ptr = &res;
  func(0, 0, res_ptr);
  printf("%d",res);
  return 0;

}


Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;

int main(){
    
    ll N;
    cin >> N;
    vector<ll>vec(1010, 1);
    for(ll i = 2; i <= N; i++){
        for(ll j = i, k = 2; j > 1;){
            if(j % k == 0){
                vec[k]++;
                j /= k;
            }
            else{
                k++;
            }
        }
    }
    ll ans = 1;
    for(ll i = 1; i <= 1000; i++)ans = (ans * vec[i]) % MOD;
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from collections import deque



def main():
    H, W, K = [int(x) for x in input().split()]

    S = [[0 for i in range(W)] for j in range(H)]

    ichigo = []
    for j in range(H):
        s = input().strip()
        list(s)
        for i in range(W):
            S[j][i] = s[i]
            if s[i] == '#':
                ichigo.append([j, i])

    ans = [[0 for i in range(W)] for j in range(H)]

    q = deque()
    k = 1
    for j, i in ichigo:
        q.append(j)
        while q:
            qj = q.pop()
            ans[qj][i] = k
            if qj != 0:
                if ans[qj - 1][i] == 0 and S[qj - 1][i] != '#':
                    q.append(qj - 1)
            if qj != H - 1:
                if ans[qj + 1][i] == 0 and S[qj + 1][i] != '#':
                    q.append(qj + 1)
        
        k += 1
    

    for i in range(1, W):
        if ans[0][i] == 0:
            for j in range(H):
                ans[j][i] = ans[j][i - 1]

    for i in range(W - 2, -1, -1):
        if ans[0][i] == 0:
            for j in range(H):
                ans[j][i] = ans[j][i + 1]





    for s in ans:
        print(*s)








if __name__ == '__main__':
    main()



Measured memory_bytes: 18180
#include<stdio.h>
 int main()
 {
 	int a,b,c;
 	scanf("%d",&a);
 	scanf("%d",&b);
 	scanf("%d",&c);
 	if (a+b==c||a+c==b||c+b==a)
 	{
 	printf("Yes");
 }
   else {
   	printf("No");
   }
   return 0;
 }

Measured memory_bytes: 128
from functools import reduce
from operator import add
from collections import Counter

H, W = list(map(int, input().split()))
C = [list(map(int, input().split())) for _ in range(10)]
A = [list(map(int, input().split())) for _ in range(H)]
A = reduce(add, A)
c = Counter(A)

class WarshallFloyd():
  def __init__(self, matrix):
    self.inf = 1e12
    self.v = len(matrix)
    self.e = matrix
    self.K = [[self.inf]*self.v for _ in range(self.v)]
    self.newK = self.K.copy()
    self.calculated = False
    
  def calc(self):
    for k in range(self.v):
      for i in range(self.v):
        self.newK[i][k] = min([self.K[i][k], self.e[i][k]])
        self.newK[k][i] = min([self.K[k][i], self.e[k][i]])

      for i in range(self.v):
        for j in range(self.v):
          if i!=j and i!=k and j!=k:
            self.newK[i][j] = min([self.K[i][j], self.newK[i][k]+self.newK[k][j]])
      self.K = self.newK.copy()
    self.calculated = True
    return self.K
  
  def shortest_way(self,a,b):
    if not self.calculated:
      self.calc()
    return self.K[a][b]

wf = WarshallFloyd(C)
wf.calc()

answer = 0
for k,v in c.items():
  if k!=-1:
    answer += v * wf.shortest_way(k,1)
print(answer)

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

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

    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }

    map<int, int> mp;
    for(int i = 0; i < N; i++){
        mp[A.at(i)]++;
    }

    int val = mp.size();
    vector<int> amount_v(val);
    int mynum = 0;
    for(auto i = mp.begin(); i != mp.end(); i++){
        amount_v.at(mynum) = i->second;
        mynum++;
    }

    sort(amount_v.begin(), amount_v.end());
     //for(int i = 0; i < val; i++){
       //  cout << amount_v.at(i) << endl;
     //}

    int changeamount = mp.size() - K;
    int ans = 0;

    if (changeamount <= 0){
        cout << 0 << endl;
    }else{
        //cout << changeamount << endl;
        for(int i = 0; i < changeamount; i++){
          	//cout << amount_v.at(i) << endl;
            ans += amount_v.at(i);
        }
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 11136
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] arr = new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    long sum=0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
        sum=sum+arr[i]*arr[j];
      }
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 23892
use proconio::input;
use std::collections::HashMap;

fn main() {
    input! {
        n: usize,
        x: usize,
        m: usize,
    }

    let mut hm = HashMap::new();
    let mut ss = vec![0];
    let mut a = x;
    let mut s = 0;

    for i in 1..=n {
        if let Some(j) = hm.get(&a) {
            let loop_size = i - j;
            let s_offset = ss.get(j - 1).unwrap();
            let mut ans = (s - s_offset) * ((n - (j - 1)) / loop_size);
            ans += s_offset;
            let r = (n - (j - 1)) % loop_size;
            ans += ss.get(j - 1 + r).unwrap() - s_offset;
            println!("{}", ans);
            return;
        }
        s += a;
        hm.insert(a, i);
        ss.push(s);
        a = (a * a) % m;
    }
    println!("{}", s);
}


Measured memory_bytes: 3840
require "pp"
def sget; gets.chomp; end
def iget; sget.to_i; end
def saget; gets.chomp.split; end
def iaget; saget.map {|a| a.to_i }; end

vs = iaget;
vs.sort!

if vs.any? {|x| x % 2 == 0 }
    puts 0
else
    puts vs[0] * vs[1]
end

Measured memory_bytes: 2044
package main

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

func readInts(stdin *bufio.Scanner) []int {
	stdin.Scan()
	text := stdin.Text()
	ss := strings.Split(text, " ")
	ii := make([]int, len(ss))
	for j, s := range ss {
		i, _ := strconv.Atoi(s)
		ii[j] = i
	}
	return ii
}

func main() {
	stdin := bufio.NewScanner(os.Stdin)
	var z []int
	z = readInts(stdin)
	a, b := z[0], z[1]
	if a <= b*2 {
		fmt.Println(0)
	} else {
		fmt.Println(a - b*2)
	}
}

Measured memory_bytes: 640
from bisect import bisect_left

N = int(input())
L = sorted(list(map(int,input().split())))
cnt = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        tmp = bisect_left(L,L[i]+L[j])
        cnt += tmp - j - 1

print(cnt)


Measured memory_bytes: 9268
n,m,x = map(int,input().split())
book_cost = [0]*n
book_skill = [[0]*m for _ in range(n)]
for i in range(n):
    li = list(map(int,input().split()))
    book_cost[i] = li[0]
    for j in range(m):
        book_skill[i][j] = li[j+1]
max_cost = 10000000
for i in range(2**n):
    cost = 0
    skill = [0]*m
    for j in range(n):
        if i >> j & 1:
            cost += book_cost[j]
            for k in range(m):
                skill[k] += book_skill[j][k]
    for j in range(m):
        if skill[j] < x:
            break
    else:
        max_cost = min(max_cost,cost)
if max_cost == 10000000:
    print(-1)
else:
    print(max_cost)

Measured memory_bytes: 68736
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    final Scanner scanner = new Scanner(System.in);

    scanner.nextLine();
    final int[] a = Arrays.stream(scanner.nextLine().split(" "))
        .mapToInt(Integer::parseInt)
        .toArray();
    final int q = scanner.nextInt();
    final int[][] bc = new int[q][2];
    for (int i = 0; i < q; i++) {
      bc[i][0] = scanner.nextInt();
      bc[i][1] = scanner.nextInt();
    }

    Map<Integer, Long> counts = new HashMap<>();
    for (int i = 0; i < a.length; i++) {
      counts.put(
          a[i],
          counts.getOrDefault(a[i], 0L) + 1
      );
    }

    long sum = counts
        .entrySet()
        .stream()
        .mapToLong(entry -> entry.getKey() * entry.getValue())
        .sum();

    for (int i = 0; i < q; i++) {
      final long replaceCount = counts.getOrDefault(bc[i][0], 0L);
      counts.put(
          bc[i][1],
          counts.getOrDefault(bc[i][1], 0L) + replaceCount
      );
      counts.remove(bc[i][0]);

      sum += replaceCount * (bc[i][1] - bc[i][0]);

      System.out.println(sum);
    }
  }
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    int2(n, x);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    
    sort(all(data));
    reverse(all(data));

    vvi dp(data.size()+1, vi(x+1, 0));
    dp[0][x] = 1;

    rep(i, n) {
        rep(j, x+1) {
            dp[i+1][j % data[i]] = (dp[i+1][j % data[i]] + dp[i][j]) % MOD;
            dp[i+1][j] = (dp[i+1][j] + (dp[i][j] * (n-i-1))) % MOD;
        }
    }

    /*
    rep(i, x+1) {
        std::cout << dp[n][i] << " ";
    }cout << endl;
    */

    int ans = 0;
    rep(i, x+1) {
        ans = (ans + (dp[n][i] * i) % MOD) % MOD;
    }

    std::cout << ans << std::endl;

    return 0;
}


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

int main() {
  long long N, a, b, c, d, e, g;
  int X, M,j, f, l;
  a = 0;
  c = 0;
  e = 0;
  f = 0;
  cin >> N >> X >> M;
  vector<long long> v(M + 1);
  v.at(0) = X;
  for (int i = 0;i < M; i++){
    v.at(i + 1) =  (v.at(i) * v.at(i)) % M;
  }
  for (int i = 0;i < M + 1; i++){
    j = i;
    for (int k = 0;k < i; k++){
      l = k;
      if (v.at(i) == v.at(k)){
        f = 1;
        break;
      }
    }
    if (f == 1){
      break;
    }
  }
  g = j - l;
  if (v.at(M) == 0){
    for (int i = 0;i < M; i++){
      j = i;
      if (v.at(i) == 0){
        break;
      }
    }
    for (int i = 0;i < j; i++){
      a += v.at(i);
    }
    cout << a << endl;
  }
    
  else if (j >= N){
  for (int i = 0;i < N; i++){
    a += v.at(i);
  }
  cout << a << endl;
  }
  else{
    for (int i = l;i < j; i++){
      a += v.at(i);
    }
    b = (N  - l) % g;
    for (int i = l;i < l + b; i++){
      c += v.at(i);
    }
    d = (N - l) / g;
    for (int i = 0;i < l; i++){
      e += v.at(i);
    }
    cout << a * d + c + e << endl;
  }
}

Measured memory_bytes: 3976
import java.util.Scanner;

public class Main {

	static int ans;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int x = sc.nextInt();
		int t = sc.nextInt();
		int a = 0;
		if(n%x ==0) {
			a = n/x;
		}
		else {
			a = n/x+1;
		}
		int ans = a*t;
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 35736
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int k, s;
    cin >> k >> s;
    int res = 0;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            if (i + j > s) continue;
            if (i + j + k >= s) res++;
        }
    }
    cout << res << endl;
}


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

int N, W;
int w[110], v[110];

long long dp[110][100010];

// i 番目の品物を見ている
// 残り使える重さが j
long long solve(int i, int j) {
    if(i >= N) return 0;
    if(dp[i][j] != -1) return dp[i][j];
    long long ret = solve(i + 1, j); // i 番目を使わない遷移
    if(j - w[i] >= 0)
        ret = max(ret, solve(i + 1, j - w[i]) + v[i]); // i番目を使う遷移
    return dp[i][j] = ret;
}

int main() {
    cin >> N >> W;
    for(int i = 0; i < N; i++)
        cin >> w[i] >> v[i];

    for(int i = 0; i < 110; i++)
        for(int j = 0; j < 100010; j++)
            dp[i][j] = -1;

    cout << solve(0, W) << endl;

    return 0;
}

Measured memory_bytes: 86144
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define MM <<" "<<
#define Endl endl

signed main(void){
    int A,B,C;
    cin >> A >> B >> C;
    cout << max(0ll,B+C-A) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int n, k;
struct T {
	int to, nxt;
} way[maxn << 1];
int h[maxn], num;
inline void link(int x,int y) {
	way[++num] = {y, h[x]}, h[x] = num;
	way[++num] = {x, h[y]}, h[y] = num;
}
int c[maxn], tag[maxn], neg[maxn];
inline void dfs0(int x,int fa = 0) {
	for(int i = h[x];i;i = way[i].nxt) if(way[i].to != fa) {
		neg[way[i].to] = neg[x] ^ 1;
		dfs0(way[i].to, x);
	}
}
int min[maxn], max[maxn];
inline void dfs1(int x,int fa = 0) {
	if(tag[x]) {
		min[x] = max[x] = c[x];
	} else {
		min[x] = -1e9, max[x] = 1e9;
	}
	for(int i = h[x];i;i = way[i].nxt) if(way[i].to != fa) {
		dfs1(way[i].to, x);
		min[x] = std::max(min[x], min[way[i].to] - 1);
		max[x] = std::min(max[x], max[way[i].to] + 1);
	}
	if(min[x] + neg[x] & 1) ++ min[x];
	if(max[x] + neg[x] & 1) -- max[x];
	if(min[x] > max[x]) {
		cout << "No" << '\n';
		exit(0);
	}
}
inline void dfs2(int x,int fc,int fa = 0) {
	if(!tag[x]) {
		if(min[x] <= fc - 1 && fc - 1 <= max[x]) {
			c[x] = fc - 1;
		} else {
			c[x] = fc + 1;
		}
	}
	for(int i = h[x];i;i = way[i].nxt) if(way[i].to != fa){ 
		dfs2(way[i].to, c[x], x);
	}
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n;
	rep(i, 2, n) {
		int x, y;
		cin >> x >> y;
		link(x, y);
	}
	int root = 0;
	cin >> k;
	rep(i, 1, k) {
		int v, p;
		cin >> v >> p;
		c[v] = p;
		tag[v] = 1;
		root = v;
	}
	neg[root] = c[root] & 1;
	dfs0(root);
	rep(i, 1, n) if(tag[i] && (c[i] + neg[i]) % 2) {
		cout << "No" << '\n';
		return 0;
	}
	dfs1(root);
	dfs2(root, min[root] - 1);
	cout << "Yes" << '\n';
	rep(i, 1, n) {
		cout << c[i] << '\n';
	}
}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
main()
{
    queue<char>s;
    string ss,sss;
    int n,i,j,l;
    cin>>ss;

    cin>>n;
    l=ss.size();
    //cout<<l<<endl;
    for(i=0;i<l;i++)
    {
        s.push(ss[i]);
    }

    for(i=0;i<l;i+=n)
    {
        j=0;
        while(j<n&&!s.empty())
        {//cout<<s.front();

         if(j==0){sss+=s.front();}
         s.pop();
         j++;
        }

    }
     cout<<sss<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include<vector>
#include<queue>
#define ll long long
#define inf INT_MAX
int d[3100][3100];
/*int solve(string s1,string s2,int i1,int i2)
{
	if(i1<0||i2<0)
	return 0;
	else
	{
		if(a[i1][i2]!=0)
		{
			return a[i1][i2];
		}
		else
		{
		if(s1[i1]==s2[i2])
		{
		  a[i1][i2]=1+solve(s1,s2,i1-1,i2-1);
		  return a[i1][i2];}
		else
		{
			int p1=solve(s1,s2,i1-1,i2);
			int p2=solve(s1,s2,i1,i2-1);
			a[i1][i2]=max(p1,p2);
			return max(p1,p2);
		}
	}

}}*/

main()
{
	memset(d,0,sizeof(d));
	string s1,s2;
	cin>>s1>>s2;
	s1='0'+s1;
	s2='0'+s2;
	//int b=solve(s1,s2,s1.size()-1,s2.size()-1);
	//cout<<b<<endl;
	int c1=1;
    for(int i=1;i<s1.size();i++)
    {
    	for(int j=1;j<s2.size();j++)
    	{
    		if(s1[i]==s2[j])
    		d[i][j]=d[i-1][j-1]+1;
    		else
    		{
    			d[i][j]=max(d[i-1][j],d[i][j-1]);
			}
		}
	}
	int b=0;
    for(int i=1;i<s2.size();i++)
    {
    	b=max(b,d[s1.size()-1][i]);
	}
	int i=s1.size()-1;
	int j=s2.size()-1;
	char lcs[b+1];
	int b1=b;
	while(i>0&&j>0)
	{
		if(s1[i]==s2[j])
		{
			lcs[b]=s1[i];
			i--;
			j--;
			b--;
		}
		else
		{
			if(d[i-1][j]>d[i][j-1])
			i--;
			else
			j--;
		}
	}
	
  for(int i=1;i<=b1;i++)
  cout<<lcs[i];
	   	
}

Measured memory_bytes: 37760
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>

using namespace std;

bool is_prime[55556];

void eratos(int N){
    for(int i = 2; i <= N; i++){
        is_prime[i] = true;
    }

    for(int i = 2; i <= N; i++){
        if(!is_prime[i]){
            continue;
        }
        for(int j = 2 * i; j <= N; j += i){
            is_prime[j] = false;
        }
    }
}

int main(){
    int N;
    cin >> N;
    eratos(55555);
    vector <int> ans;
    int tmp = 2;
    while(ans.size() < N){
        if(is_prime[tmp] && tmp % 5 == 1){
            ans.push_back(tmp);
        }
        tmp++;
    }
    for(int i = 0; i < ans.size(); i++){
        if(i != ans.size() - 1){
            cout << ans[i] << " ";
        } else {
            cout << ans[i] << endl;
        }
    }
    return 0;
}


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

int a[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 };

int main(void)
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);

	int t;
	cin >> t;
	cout << a[t-1];

	return 0;
}

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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define isin(a, b, c) (b <= a && a <= c)
#define println cout << "\n";
#define sz(v) (int)v.size()
#define bin(x) static_cast<bitset<16> >(x)


/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef tuple<int, int, int> ti;
typedef map<int, int> mi;
typedef set<int> si;


/* constant */
const int inf = 1LL << 62;
const int mod = 1e9 + 7;
const int dx[8]={1,0,-1,0,-1,1,-1,1};
const int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alphabet = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T, class U, class V> void printx(tuple<T, U, V> t){cout << "{" << get<0>(t) << "," << get<1>(t) <<"," << get<2>(t) << "}" << endl;}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}
template<class T> void printans(vec<T> v){rep(i,0,sz(v)){cout << v[i] << (i == sz(v) - 1 ? "" : " ");}cout << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>T cut(T &a, int l, int r){return T(a.begin()+l, a.begin()+r);}


/* math_method */
int ceil(int a, int b){return a / b + (a % b > 0);}


/* main */

int n, m;
vi arr;
vec<pi> tmp;
void in(){
    cin >> n >> m;
    rep(i,0,n) arr.push_back(input());
    sort(all(arr));

    rep(i,0,m){
        int b, c;
        cin >> b >> c;
        tmp.push_back(pi(c, b));
    }
    sort(all(tmp));
    reverse(all(tmp));

}

void solve(){

    int j = 0;
    rep(i,0,n){
        if(j == m) break;
        if(chmax(arr[i], tmp[j].first)){
            tmp[j].second--;
            if(tmp[j].second == 0) j++;
        }else{
            break;
        }
    }

    print(sum(arr));



}

signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    in();
    solve();
    
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    ll n,t;
    cin>>n>>t;
    vector<ll> ts(n+1);
    rep(i,0,n) cin>>ts.at(i);
    ts.at(n)=LINF;
    
    ll ans=0;
    rep(i,0,n){
        ans+=min(t,ts.at(i+1)-ts.at(i));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#ifndef bhartiya
    #pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    // #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif


typedef long long ll;
typedef pair<ll, ll> pll;
typedef gp_hash_table<long long, long long> umap;
typedef tree<int, null_type, less<int>, rb_tree_tag,
		tree_order_statistics_node_update> oset;
// not that imp
typedef pair<pll, ll> plll;
typedef vector<ll> vl;
typedef vector<pll> vll;

#define inf 200000000000000ll
#define mod 1000000007ll
#define eps 1e-7
#define PI 3.1415926535897932385
// #define PI acos(-1)

#define pb push_back
#define bitc  __builtin_popcountll
#define mp make_pair
#define ff first
#define ss second
#define all(ar) ar.begin(), ar.end()

#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define foreach(it,ar) for (auto it = ar.begin(); it != ar.end(); it++)
#define fill(ar,val) memset(ar, val, sizeof(ar))

#ifdef bhartiya
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; return 0;
#else
#define endl '\n'
#define trace(...)
#define end_routine() return 0;
#endif

mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
inline bool equals(double a, double b) {return fabs(a - b) < 1e-9;}
ll gcd(ll a, ll b){ return b==0 ? a : gcd(b, a%b); }

const ll maxn = 500005;

void solve(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    a--;
    ll ans = 0;
    ll lcm = (c*d)/gcd(c,d);
    ans += (b/c) + (b/d) ;
    ans -= (a/c) + (a/d) ;
    ans -= (b/lcm) - (a/lcm);
    cout<<b-a-ans;
}

int main() 
{ 
	ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0), cout.precision(10); //cout<<fixed;
    cin.exceptions(cin.failbit);
    #ifdef bhartiya
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    solve();
    end_routine();
}

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

using namespace std;
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define INF INT_MAX
typedef vector<int> VI;

int n, k;
VI d(11);

bool check(int n) {
	bool flag = true;
	int keta = 0;
	for (int i = n; i > 0; i = i / 10)keta = keta + 1;
	FOR(i, 1, keta + 1) {
		int x = n / (int)(pow(10, i - 1)) % 10;
		REP(j, k) {
			if (x == d[j])flag = false;
		}
	}
	return flag;
}

int main() {
	cin >> n >> k;
	REP(i, k)cin >> d[i];

	int ans;
	FOR(i, n, INF) {
		if (check(i)) { ans = i; break; }
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var H, W int
	for {
		fmt.Scan(&H)
		fmt.Scan(&W)

		if H == 0 && W == 0 {
			break
		}
		for h := 0; h < H; h++ {
			for w := 0; w < W; w++ {
				fmt.Print("#")
			}
			fmt.Println()
		}
		fmt.Println()
	}

}



Measured memory_bytes: 1120
#include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main() {
  string s;
  cin >> s;
  int N = s.size();

  bool c1 = true, c2 = true, c3 = true;
  rep(i, N / 2) { c1 = c1 && (s[i] == s[N - 1 - i]); }
  rep(i, N / 4) { c2 = c2 && (s[i] == s[N / 2 - 1 - i]); }
  rep(i, N / 4) { c3 = c3 && (s[i + N / 2 + 1] == s[N - 1 - i]); }

  cout << (c1 && c2 && c3 ? "Yes" : "No") << endl;
  return 0;
}

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

using namespace std;

using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    string s;cin>>s;
    if(s == "AAA" or s == "BBB")cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(c: "List[List[int]]"):
    from itertools import product
    for a1, b1 in product(range(101), repeat=2):
        a2 = c[1][0] - b1
        a3 = c[2][0] - b1
        b2 = c[0][1] - a1
        b3 = c[0][2] - a1
        if a2 < 0 or a3 < 0 or b2 < 0 or b3 < 0:
            continue
        a = [a1, a2, a3]
        b = [b1, b2, b3]
        if all((a[i]+b[j])==c[i][j] for i, j in product(range(3), repeat=2)):
            return YES
    return NO

# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    c = [[int(next(tokens)) for _ in range(3)] for _ in range(3)]  # type: "List[List[int]]"
    print(solve(c))

def test():
    import doctest
    doctest.testmod()

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


Measured memory_bytes: 9176