akhauriyash/Code-Regression huggingface dataset:
package main

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



func main() {
	stdin := bufio.NewScanner(os.Stdin)
	input :=  splitAndAtoi(nextLine(stdin))
	_,m := input[0], input[1]

	acmap := make(map[string]bool, m)

	wamap := make(map[string]int, m)

	wa := 0
	ac := 0
	for i := 0; i < m;  i++ {
		line :=	strings.Split(nextLine(stdin), " ")
		p,r := line[0], line[1]

		// is ac?
		if(r == "AC") {
			// ac count only once per progrem
			if _, ok := acmap[p]; !ok {
				ac++
				acmap[p] = true

				if val, ok := wamap[p]; ok {
					wa += val			
				}
			}
		}

		// is penalty?
		if(r == "WA"){
			wamap[p]++
		}
	}

	fmt.Printf("%d %d", ac, wa)
}

func splitAndAtoi(s string) []int {
	ss := strings.Split(s, " ")
	var r []int
	for _, s := range ss {
		i, _ := strconv.Atoi(s)
		r = append(r, i)
	}

	return r
}

func nextNumber(s *bufio.Scanner) int {
	i, _ := strconv.Atoi(nextLine(s))
	return i
}

func nextLine(s *bufio.Scanner) string {
	s.Scan()
	return s.Text()
}


Measured memory_bytes: 9216
type Vector = [Int]
type Matrix = [Vector]
trans :: Matrix->Matrix->Matrix
trans x y
 |head y==[] = x
 |otherwise = trans x2 y2
 where
 x2 = x ++ [(map head y)]
 y2 = map tail y

trans2 :: Matrix->Matrix
trans2 = trans []

vproduct :: Vector->Vector->Int
vproduct a b = sum $ zipWith (*) a b

toVector :: String -> Vector
toVector = map (read :: String->Int).words

dim :: String->Int
dim=head.toVector.head.lines

takeContent :: String->(Matrix,Matrix)
takeContent xs = splitAt (dim xs).map toVector.tail.lines $ xs

myPartition :: Int->[[a]]->[a]->[[a]]
myPartition n x [] = x
myPartition n x y = myPartition n (x++[take n y]) (drop n y) 

myPartition2 :: Int->[a]->[[a]]
myPartition2 n = myPartition n []

calc :: (Matrix,Matrix)->Matrix
calc (mat1,mat2) = myPartition2 (length $ trans2 mat2) [vproduct x y|x<-mat1,y<-trans2 mat2]

myPrint :: Matrix->IO ()
myPrint = mapM_ $ putStrLn.unwords.(map show)

main = getContents >>= myPrint.calc.takeContent

Measured memory_bytes: 15260
#include<bits/stdc++.h>
#define ll long long int 
#define ull unsigned long long int
#define mem(a) memset(a,0,sizeof(a))
#define reg register 
#define fio ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define For(i,a,b) for(int i=a;i<b;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	int ans=0;
	For(i,0,s.length()){
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C'){
			ans++;
			i+=2;
		}	
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

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

            var studentTupleList = new List<Tuple<int, int>>();
            var checkPointTupleList = new List<Tuple<int, int>>();

            for (int i = 0; i < N; i++) {
                var X = Console.ReadLine().Split().Select(int.Parse).ToArray();

                studentTupleList.Add(new Tuple<int, int>(X[0], X[1]));
            }

            for (int i = 0; i < M; i++) {
                var Y = Console.ReadLine().Split().Select(int.Parse).ToArray();

                checkPointTupleList.Add(new Tuple<int, int>(Y[0], Y[1]));
            }


            for (int i = 0; i < N; i++) {
                int minDistance = Math.Abs(checkPointTupleList[0].Item1 - studentTupleList[i].Item1) + Math.Abs(checkPointTupleList[0].Item2 - studentTupleList[i].Item2);

                int x_dist;
                int y_dist;

                int minIndex = 0;

                for (int j = 0; j < M; j++) {
                    x_dist = Math.Abs(checkPointTupleList[j].Item1 - studentTupleList[i].Item1);
                    y_dist = Math.Abs(checkPointTupleList[j].Item2 - studentTupleList[i].Item2);

                    if (x_dist + y_dist < minDistance) {
                        minDistance = x_dist + y_dist;
                        minIndex = j;
                    }
                }

                //Console.WriteLine(minDistance);
                Console.WriteLine(minIndex + 1);
            }
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
using namespace std;
int main(){
	int n, x, y;
	cin >> n >> x >> y;
	int a[n-1][n];
	int k[n];
	for(int i = 0; i < n; i++)k[i]=0;
	x--;
	y--;
	for(int i = 0; i < n-1; i++){
		for(int j = i+1; j < n; j++){
			a[i][j]=j-i;
			if(i<=x){
				if(j<=x);
				else if(j<=y)a[i][j]=min(j-i, x-i+y-j+1);
				else a[i][j]=x-i+j-y+1;
			}else if(i<=y){
				if(j<=y)a[i][j]=min(j-i, i-x+y-j+1);
				else a[i][j]=min(j-i, i-x+1+j-y);
			}
			k[a[i][j]]++;
		}
	}
	for(int i = 1; i <= n-1; i++){
		cout << k[i] << endl;
	}
  return 0;
}


Measured memory_bytes: 15360
#include <stdio.h>
#include <string.h>
#include <utility>
#include <algorithm>
#include <set>
#include <functional>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, m, h, w, ans = 0;
  scanf("%lld", &n);
  ll a[n], b[n];
  pair<ll, ll> d[n];
  for(i = 0; i < n; ++i) {
    scanf("%lld%lld", &a[i], &b[i]);
    d[i] = make_pair(a[i] + b[i], i);
  }
  sort(d, d + n, greater< pair<ll, ll> >());
  for(i = 0; i < n; ++i) {
    if(i & 1) ans -= b[d[i].second];
    else ans += a[d[i].second];
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 3328
n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]
c = [int(x) for x in input().split()]
ans = sum(b)
for i, j in zip(a, a[1:]):
    if i+1 == j:
        ans += c[i-1]
print(ans)


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

using namespace std;

typedef long long int ll;

int n, w, values[109], weights[109];
ll dp[109][100009];

int main() {
  ios::sync_with_stdio(0);
  cin.tie();cout.tie();
  cin >> n >> w;

  for (int i = 0; i < n; i++)
    cin >> weights[i] >> values[i];

  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= w; j++)
      dp[i][j] = 0;

  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= w; j++) {
      if (j < weights[i-1])
        dp[i][j] = dp[i-1][j];
      else
        dp[i][j] = max(dp[i-1][j-weights[i-1]] + values[i-1], dp[i-1][j]);
    }

  cout << dp[n][w] << endl;

  return 0;
}


Measured memory_bytes: 80128
(defparameter line (read-line))
(defparameter n (length line))
(defparameter k (read))
(defparameter dp (make-array (list n (1+ k) 2) :initial-element nil))


(defun get-num (place)
  (- (char-code (aref line place)) (char-code #\0)))

(defun func2 (place use touch)
  (if (= place n)
    (if (= use k)
      1
      0)
    (if (aref dp place use touch)
      (aref dp place use touch)
      (let ((ans (func place use touch)))
        (setf (aref dp place use touch) ans)
        ans))))

(defun func (place use touch)
  (if (= use k)
    1
    (if (zerop touch)
      (+ (if (= use k) 0
           (* 9 (func2 (1+ place) (1+ use) 0)))
         (func2 (1+ place) use 0))
      (if (zerop (get-num place))
        (func2 (1+ place) use touch)
        (+ (func2 (1+ place) use 0)
           (* (1- (get-num place)) (func2 (1+ place) (1+ use) 0))
           (func2 (1+ place) (1+ use) 1))))))

(princ (func2 0 0 1))


Measured memory_bytes: 17124
def main():
    N = int(input())
    L = list(map(int, input().split()))
    L = sorted(L)
    count = 0

    for i in range(N-2):
        for j in range(i+1, N):
            for k in range(j+1, N):
                if L[i] + L[j] > L[k] and L[i] != L[j] != L[k]:
                    count += 1

    print(count)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

vector<ll> tmp(1005, 0);
vector<ll> cnt(1005, 0);
ll a;

void solve(){
    for (ll i = 2; i < 1005; i++) {
        tmp[i] = 0;
        while(a % i == 0){
            tmp[i]++;
            a = a / i;
        }
        cnt[i] = max(cnt[i], tmp[i]);
    }
}


int main(){
    ll N;
    cin >> N;
    vector<ll> A(N);
    for(ll i = 0; i < N; i++) cin >> A.at(i);
    ll LCM = 1;
    map<ll, bool> used;

    for (ll i = 0; i < N; i++) {
        a = A[i];
        solve();
        if(!used.count(a)){
            LCM = LCM * a % MOD;
            used[a] = true;
        }
    }

    for (ll i = 2; i < 1005; i++) {
        for (ll j = 0; j < cnt[i]; j++) {
            LCM = LCM * i % MOD;
        }
    }

    vector<ll> inv(1000005); inv[1] = 1;
    for (int i = 2; i < 1000005; i++) {
        inv[i] = MOD - (MOD / i) * inv[MOD % i] % MOD;
    }   

    ll ans = 0;

    for (ll i = 0; i < N; i++) {
        ans += (LCM * inv[A[i]]) % MOD;
    }

    ans = ans % MOD;
    printf("%lld\n", ans);

}




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

//関数プロトライプ宣言ってやつね
void calc(int, int, int, int);

int pattern=0;
int i=0, j=0;

int main(){
    int price, a, b, c;
    cin >> a >> b >> c;
    cin >> price;
    while(price>=0){
        calc(price, a, b, c);
        price -= 500;
        j++;
        if(j>a) break;
    }
    cout << pattern << endl;
}

void calc(int price, int a, int b, int c){
    while(price>=0){
        if(price/50<=c && i<=b){
            pattern++;
        }
        price -= 100;
        i++;
    }
    i=0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 200005;

int n;
int a[N];

void solv()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    long long ans = 0;
    long long yans = 0;
    stack<pair<int, int> > s;
    for (int i = 1; i <= n; ++i)
    {
        int q = 1;
        while (!s.empty() && a[i] <= s.top().first)
        {
            yans -= (s.top().first * 1LL * s.top().second);
            q += s.top().second;
            s.pop();
        }
        yans += (q * 1LL * a[i]);
        s.push(m_p(a[i], q));
        ans += yans;
    }
    printf("%lld\n", ans);
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    solv();
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


Measured memory_bytes: 2688
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include <cstdint>
#include <stdlib.h> 
#include <time.h>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rrep(i,n) REP(i,1,n+1)
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define RNG(x, a, n) &((x)[a]), &((x)[n])
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> PII;
typedef vector<ll> Vl;
typedef vector<int> VI;
typedef tuple<int, int, int> TT;
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define dmt(x, y, z) make_tuple(x, y, z)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
const int MAX = 500000;
const int inf = 1000000007;
const ll mod = 1000000007;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;

int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };


ll n;
ll a[200005];
ll total;
ll ans;

int main() {

	cin >> n;
	rep(i, n){
		cin >> a[i];
		total = (total + a[i]) % mod;
	}

	rep(i, n){
		total -= a[i];
		if (total < 0)total += mod;
		ans = (ans + (total * a[i]) % mod) % mod;
	}



	cout << ans << endl;

	return 0;
}



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

#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(c) ((int)((c).size()))
#define st first
#define nd second
#define pb push_back

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

void solve(){
    int n,m,a,r=0;
    cin>>n>>m;
    unordered_map<int,int> M;
    M[0] = 1;
    ll ans = 0;
    REP(i,n) {
        cin>>a;
        r = (r+a)%m;
        ans += M[r]++;
    }
    cout<<ans<<'\n';
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
int main(){
    int i; cin>>i;
    if(i==25)
        cout<<"Christmas";
    else if(i==24)
        cout<<"Christmas Eve";
    else if(i==23)
        cout<<"Christmas Eve Eve";
    else if(i==22)
        cout<<"Christmas Eve Eve Eve";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ



//-------------------------------------------------


int main()
{
  int n ;
  cin >> n ;
  vector<ll> a(n) ;
  vector<ll> b(n) ;
  REP(i,n){
    cin >> a.at(i) ;
  }
  REP(i,n){
    cin >> b.at(i) ;
  }
  
  ll minc = 0 ;
  ll pluc = 0 ;
  
  REP(i,n){
    if(a.at(i)>=b.at(i)){
      pluc += (a.at(i)-b.at(i)) ;
    }
    else{
      minc += (b.at(i)-a.at(i))/2 ;
    }
  }
  
  if(minc>=pluc){
    cout <<"Yes"<<endl ;
  }
  else{
    cout <<"No"<<endl ;
  }

  return 0 ;
}


Measured memory_bytes: 384
/*
    ThunderClap and Flash.
    Raunaq Singh
*/
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define ThunderClap ios::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL);
#define debugg(something)   cout<<#something<<" - "<<something<<"\n";
#define vi vector
#define umap unordered_map
#define uset unordered_set
#define mset multiset
#define LB lower_bound
#define UB upper_bound
#define mp make_pair
#define pb push_back
#define in insert
#define s second
#define f first
#define pQueue priority_queue
#define maxElement *max_element
#define minElement *min_element
#define MAX 100000LL
#define mod 1000000007LL
#define inf 1000000000000000000LL
#define mI2 500000004LL
inline ll add(ll a, ll b){ return ((a%mod)+(b%mod))%mod;}
inline ll mul(ll a, ll b){ return ((a%mod)*(b%mod))%mod;}
inline ll sub(ll a, ll b){ return ((a%mod)-(b%mod)+mod)%mod;}

void Flash(){
    ll a,b,m;
    cin>>a>>b>>m;
    ll fridge[a];
    ll micro[b];
    pair<pll,ll>discount[m];
    ll ans;
    ll mnFridge=inf;
    ll mnMicro=inf;
    for(ll i=0;i<a;i++){
        cin>>fridge[i];
        mnFridge=min(fridge[i],mnFridge);
    }
    for(ll i=0;i<b;i++){
        cin>>micro[i];
        mnMicro=min(mnMicro,micro[i]);
    }
    ans=mnFridge+mnMicro;
    ll tempPrice;
    for(ll i=0;i<m;i++){
        cin>>discount[i].f.f>>discount[i].f.s>>discount[i].s;
        tempPrice=(fridge[discount[i].f.f-1]+micro[discount[i].f.s-1]-discount[i].s);
        tempPrice=max(0LL,tempPrice);
        ans=min(ans,tempPrice);
    }
    cout<<ans<<"\n";
}

int main(int argc, char const *argv[]){
    ThunderClap;
    ll t=1;
    //cin>>t;
    for(ll i=1;i<=t;i++){
        //cout<<"Case #"<<i<<": ";
        Flash();
    }
    return 0;
}

Measured memory_bytes: 4224
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
        int n = Cin.Ni();
        int m = Cin.Ni();
        int ans = (m * 1900 + ((n - m) * 100)) * (int)Math.Pow(2, m);

        Console.WriteLine(ans);
    }
}
public struct Parts {
    public int Size;
    public int Count;

    public Parts(int size, int count) {
        Size = size;
        Count = count;
    }
}

public class Cin {
    private static string[] s = new string[0];
    private static int i = 0;

    private static char[] cs = new char[] { ' ' };

    public static string Next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return Next();
    }

    public static int Ni() {
        return int.Parse(Next());
    }

    public static long NextLong() {
        return long.Parse(Next());
    }

    public static double NextDouble() {
        return double.Parse(Next());
    }

}


Measured memory_bytes: 11092
n=int(input())
a={}
temp=n
for i in range(2,int(n**0.5)+1):
    if temp % i ==0:
        count=0
        while temp % (i**(count+1)) ==0:
            count+=1
        temp= temp/(i**count)
        a[i]=count
if temp !=1:
    a[temp]=1

sum=0
for i in a:
  jisu= a[i]
  temp=1
  while temp*(temp+1)/2<= jisu:
          temp+=1
  sum+= temp-1
print(sum)

Measured memory_bytes: 9468
N,M=map(int,input().split())
xyz=[list(map(int,input().split())) for i in range(N)]

ans=0
for i in range(2**3):
  F=[1]*3
  for j in range(3):
    if (i>>j)&1:
      F[j]=-1
  xyz.sort(reverse=True, key=lambda x:F[0]*x[0]+F[1]*x[1]+F[2]*x[2])
  x=0
  y=0
  z=0
  val=0
  for k in range(M):
    x+=xyz[k][0]
    y+=xyz[k][1]
    z+=xyz[k][2]
  val=abs(x)+abs(y)+abs(z)
  ans=max(ans,val)
print(ans)

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

int main() {
	int m,d,c=0;
	cin>>m>>d;
	for(int i=22;i<=d;i++){
	    if(i%10>=2){
	        if((i/10)*(i%10)<=m)
	        c++;
	    }
	}
	cout<<c;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;

#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(ll (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define opf(i) cout<<fixed<<setprecision(10)<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define matC(name,fnum,snum); vector<vector<char>> name((fnum),vector<char>((snum),0));
#define debugP int debug_point; cin>>debug_point;
#define FI first
#define SE second
const ll MOD= 1e9 + 7;

////const long long MOD = 1000000007;
//
void solve(long long N, long long K, std::vector<long long> A){
 vector<pair<ll,ll>> B(N);
 ll ans=0;
 
 ll cnt=0;
 ll tmp=0;
 
 rep(i,N){
     rep(j,N){
         if(A[i]>A[j])cnt++;
     }
 }
 //op(cnt)
 ans=(cnt);
 ans%=MOD;
 ans*=((K*(K-1)/2)%MOD);
 cnt=0;
 ans%=MOD;
 rep(i,N){
     repf(j,i+1,N){
         if(A[i]>A[j])cnt++;
     }
 }
 //op(cnt)
 ans+=(cnt*K)%MOD;
 ans%=MOD;
 op(ans)
}

// 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)
int main(){
    long long N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> A(N-1-0+1);
    for(int i = 0 ; i < N-1-0+1 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, K, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,k,j,i=0,sum=0;
    int ara[1000];
    scanf("%d %d",&n,&k);
    for(i=0; i<n; i++)
    {
        scanf("%d",&ara[i]);
    }
    int temp;
    for(i=0; i<n-1; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(ara[i]>ara[j])
            {
                temp=ara[i];
                ara[i]=ara[j];
                ara[j]=temp;
            }
        }
    }
    for(i=0; i<k; i++)
    {
        sum=sum+ara[i];
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 1720
// Aizu Vol-0 0097: Sum of Integers II
// 2017.9.1 bal4u@uu

#include <stdio.h>

int p[10][101][902];

int main()
{
	int n, s;
	int i, j, k, min, max;
	long long ans;

	for (i = 0; i <= 100; i++) p[1][i][i] = 1;
	for (min = 0, max = 100, n = 1; n < 9; n++, min++, max+=100)
		for (i = 0; i <= 100; i++)
			for (j = min; j <= max; j++)
				for (k = 1; k + i <= 100; k++) p[n+1][i+k][i+j+k] += p[n][i][j];

	while (scanf("%d%d", &n, &s) && n) {
		if (s > 864) puts("0");
		else {
			for (ans = i = 0; i <= 100; i++) ans += p[n][i][s];
			printf("%lld\n", ans);
		}
	}
	return 0;
}

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

using namespace std;

int main(){
    int a, b;
    cin>>a>>b;
    if(a<=5){
        cout<<0<<endl;
    }else if(a<=12){
        cout<<b/2<<endl;
    }else{
        cout<<b<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
package main
import (
  "fmt"
  "bufio"
  "os"
  "strconv"
  "strings"
  "sort"
)

func main() {
  solve()
}

func solve() {
  input := bufio.NewScanner(os.Stdin)
  input.Scan()
  N, _ := strconv.Atoi(strings.Split(input.Text(), " ")[0])
  input.Scan()
  
  var a []int
  for _, v := range strings.Split(input.Text(), " ") {
    p, _ := strconv.Atoi(string(v))
    a = append(a, p)
  }
  
  sort.Sort(sort.IntSlice(a))
  for i:=N; i <= 10*N; i++ {
    var f bool
    for _, v := range strconv.Itoa(i) {
      p, _ := strconv.Atoi(string(v))
      f = bSearch(a, p)
      if f {
        break
      }
    }
    
    if !f {
      fmt.Println(i)
      break 
    }
  }
}

func bSearch(a []int, n int) bool {
	if len(a) == 0 {
		return false
	}

	l := 0
	r := len(a) - 1
	m := (l + r) / 2

	for r >= l {
		if a[m] == n {
			return true
		} else if a[m] > n {
			r = m - 1
			m = (l + r) / 2
		} else {
			l = m + 1
			m = (l + r) / 2
		}
	}
	return false
}
  

Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define PROB "b"
using namespace std;
int x1,y11,x2,y2;
void init()
{
    freopen(PROB".inp","r",stdin);
    freopen(PROB".out","w",stdout);
}

void Nhap()
{
    scanf("%d %d %d %d",&x1,&y11,&x2,&y2);
}

void XuLi()
{
    int x3,y3,x4,y4,xu,yu;
    yu=(x2-x1); xu=-(y2-y11);
    x3=x2+xu; y3=y2+yu;
    x4=x1+xu; y4=y11+yu;
    printf("%d %d %d %d",x3,y3,x4,y4);
}

int main()
{

    Nhap();
    XuLi();
}


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

int main () {
    int H, W;
    cin >> H >> W;
    
    while(!(H == 0 && W == 0)) {
        for(int j = 0; j < W; j++)
            cout << '#';
        cout << endl;
        for(int i = 1; i < H - 1; i++) {
            cout << '#';
            for(int j = 1; j < W - 1; j++)
                cout << '.';
            cout << "#\n";
        }
        for(int j = 0; j < W; j++)
            cout << '#';
        cout << "\n\n";
        cin >> H >> W;
    }
    return 0;
}


Measured memory_bytes: 3020
import java.util.*;
public class Main{
public static void main(String arg[]){
	Scanner sc=new Scanner(System.in);
	int a[]=new int[5];
	int b[]=new int[5];
	int c=0,s=0;
	for(int i=0;i<5;i++){
		 a[i]=sc.nextInt();
		s=s+a[i];
		if(a[i]%10!=0){
			b[c]=10-(a[i]%10);
		c++;
		}
	}
	Arrays.sort(b);
	for(int i=0;i<4;i++){
	if(b[i]!=0)
	s=s+b[i];
	}
	System.out.println(s);
}
}

Measured memory_bytes: 21972
#include<iostream>
#include<string>
using namespace std;
int main(){
  string s;
  cin >> s;
  long long size=s.size();
  long long cnt=0,i=size-1,b_cnt=1;
  while(i>=0){
    if(s[i]=='B'){
      cnt += size-i-b_cnt;
      b_cnt++;
    }
    i--;
  }
  cout << cnt << "\n";

  return 0;
}


Measured memory_bytes: 640
//Heaplax
#include<bits/stdc++.h>
#define N 200005
#define int long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
char s[N];
int n,ans,cnt[233];
main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	ans=n*(n-1)/2+1;
	for(int i=1;i<=n;++i)
	{
		ans-=cnt[s[i]];
		++cnt[s[i]];
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 384
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
import numpy as np
#======================================================#
MOD=10**9+7
def main():
    n = II()
    aa = np.array(MII())
    ans = 0
    for i in range(60):
        cnt1 = int((aa&1).sum())
        ans += (cnt1*(n-cnt1)*(2**i))%MOD
        aa >>= 1
    print(ans%MOD)

if __name__ == '__main__':
    main()

Measured memory_bytes: 48792
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
bool war(const vector <int >& x, const vector <int >& y) {
	for (int Z = -100; Z <= 100; ++Z) {
		bool is_ok = true;
		for (int i = 0; i < x.size(); ++i) {
			if (x[i] >= Z) is_ok = false;
		}
		for (int i = 0; i < y.size(); ++i) {
			if (y[i] < Z) is_ok = false;
		}
		if (is_ok) return false;
	}
	return true;
}
int main() {
	int N, M;
	cin >> N >> M;
	vector<int>x(N + 1), y(M + 1);
	cin >> x[0] >> y[0];
	rep(i, N)cin >> x[i + 1];
	rep(i, M)cin >> y[i + 1];
	if (war(x,y)) {
		cout << "War" << endl;
	}
	else {
		cout << "No War" << endl;
	}
	return 0;
}

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

#define ll long long int
#define ull unsigned long long int

#define INF 100000000000L

using namespace std;
int A,B,K,ans;

int main(){
    cin >> A >> B >> K;
    int count = 0;
    int MAX = max(A,B);
    for(int i=MAX;i >= 0;i--){
        if(A%i == 0 && B%i == 0){
            count++;
            if(count == K){
                ans = i;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define ff first
#define ss second
#define MOD 1000000007
#define pb push_back
 
int main(){
	fast;
	string s;
	cin>>s;
	if(s=="AAA" || s=="BBB") cout<<"No"<<"\n";
	else cout<<"Yes"<<"\n";
	return 0;
}

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

using namespace std;
using ll = long long;

int main()
{
    ll n;
    cin >> n;
    ll ret = 0;
    ll tmp;
    vector<ll> a(n, 0);
    for (ll i = 0; i < n; i++)
    {
        cin >> tmp;
        ret += tmp - 1;
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 256
//Number of Multiples

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define irep(i,a) for(auto i = a.begin(); i != a.end(); ++i)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll, string>;
using garph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    int a,b,c;cin>>a>>b>>c;
    int ans = 0;
    rep(i,a,b+1){
        if(i%c==0)ans++;
    }
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3632
/**
*    author:  boutarou
*    created: 28.06.2020 21:45:02
**/

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define fcout cout << fixed << setprecision(15)
using lint = long long;
using P = pair<int, int>;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const double PI = 3.1415926535897932;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int d;
    cin >> d;
    rep(i, d) cout << i % 26 + 1 << endl;
    
    return 0;
}

Measured memory_bytes: 3664
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
long long gcd(long long a, long long b) {
	// gratest common divisor
	while (b != 0) {
		long long r = a%b;
		a = b;
		b = r;
	}
	return a;
}
long long lcm(long long a, long long b) {
	return (a / gcd(a, b))*b;
}
int main() {
	int n;
	cin >> n;
	vector<ll> t(n);
	rep(i, n)cin >> t[i];
	ll l = 1LL;
	rep(i, n) {
		l = lcm(l, t[i]);
	}
	cout << l;

	return 0;
}





Measured memory_bytes: 256
def f(n):
    ret = 0
    if n % 4 == 1 or n % 4 == 2:
        ret += 1
        
    for i in range(1, 50):
        t = n % (1<<i+1)
        if t+1 > (1<<i):
            ret += ((t+1)%2) * (1<<i)
    return ret

A, B = map(int, input().split())
A = max(A, 0)
print(f(B)^f(A-1))

Measured memory_bytes: 38384
n = int(input())
s = input()
ans = 0
for i in range(n):
    a = list(set(s[:i]))
    b = list(set(s[i:]))
    sum = 0
    dict = {}
    for j in a:
        if j in dict:
            dict[j] += 1
        else:
            dict[j] = 1
    for j in b:
        if j in dict:
            dict[j] += 1
        else:
            dict[j] = 1
    for j in dict.values():
        if j >= 2:
            sum += 1
    ans = max(ans,sum)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>


int main(){
  int n; cin >> n;
  set<string> s;
  string com, ss;
  rep(i,n){
    cin >> com >> ss;
    if (com=="insert") s.insert(ss);
    else if (com=="find") cout << (s.count(ss) ? "yes" : "no") << endl;
  }
  
  // cout << fixed << setprecision(6);
  return 0;
}



Measured memory_bytes: 32584
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List

main :: IO ()
main = do
  n <- getl toInt
  unless (n == (-1)) $ do
    solve <$> replicateM n (getl toInt) >>= mapM_ putStrLn
    main

solve :: [Int] -> [String]
solve xs = zipWith h (10:xs) xs
  where
    ms = ["0111111","0000110","1011011","1001111","1100110",
          "1101101","1111101","0100111","1111111","1101111","0000000"]
    f x y
      | x == y = '0'
      | otherwise = '1'
    g x y = zipWith f x y
    h x y = g (ms !! x) (ms !! y)
    
toInt :: String -> Int
toInt = read

getl :: (String -> a) -> IO a
getl f = f <$> getLine

Measured memory_bytes: 4084
n, m = map(lambda x: int(x), input().split(' '))
l = []
r = []
for i in range(m):
    l_tmp, r_tmp = map(lambda x: int(x), input().split(' '))
    l.append(l_tmp)
    r.append(r_tmp)

l_max = max(l)
r_min = min(r)

result = 0
if l_max <= r_min:
    result = r_min - l_max + 1
print(result)


Measured memory_bytes: 11016
"""
カードの中から値がC未満のものをB枚までCに変更していく。これを高速に行えばよい。
heapqにぶち込めばよさそう?いや、それだとO(NMlogN)かかる
BIT使えばよいのか？いや、それもダメO(10**9log10**9)かかる
1クエリに対して、logN以下で処理しなくてはいけない。
Aを昇順に並べ替えておいて、常に昇順が保たれるようにしておけば二分探索できる。
あーでも途中で値を更新する作業があるから結局O(MN)かかるな
そもそも値を配列で管理してはいけないんだな。
どの値がいくつある。という管理の仕方をしないといけない。
ってなると、座標圧縮してBITだな。これはムズイわ。
"""
class BIT:
    def __init__(self,n):
        self.tree = [0]*(n+1)
        self.size = n

    def sum(self,i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i&-i
    
    def add(self,i,x):
        while i <= self.size:
            self.tree[i] += x
            i += i&-i

import heapq
N,M = map(int,input().split())
A = list(map(int,input().split()))
heapq.heapify(A)
BC = [list(map(int,input().split())) for _ in range(M)]
BC.sort(key=lambda x: -x[1])

for b,c in BC:
    while b > 0:
        b -= 1
        a = heapq.heappop(A)
        if a < c:
            heapq.heappush(A,c)
        else:
            heapq.heappush(A,a)
            break
    else:
        continue
    break
print(sum(A))


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

int main()
{
    int H, W;
    char mas[55][55];

    cin >> H >> W;
    for ( int i = 0; i < H; i++ ) {
        for ( int j = 0; j < W; j++ ) {
            bool flag;
            cin >> mas[i][j];
        }
    }
    bool isdraw = true;
    for ( int i = 0; i < H; i++ ) {
        for ( int j = 0; j < W; j++ ) {
            bool flag = (mas[i][j] == '.');
            flag |= i > 0 && mas[i - 1][j] == '#';
            flag |= j > 0 && mas[i][j - 1] == '#';
            flag |= i < H - 1 && mas[i + 1][j] == '#';
            flag |= j < W - 1 && mas[i][j + 1] == '#';
            isdraw &= flag;
        }
    }

    if ( isdraw ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return (0);
}


Measured memory_bytes: 256
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
from heapq import heapify, heappop, heappush
import math
import random
import string
from copy import deepcopy
from itertools import combinations, permutations, product
from operator import mul, itemgetter
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

class UnionFind:
    def __init__(self, N):
        """
        N:要素数
        root:各要素の親要素の番号を格納するリスト.
             ただし, root[x] < 0 ならその頂点が根で-root[x]が木の要素数.
        rank:ランク
        """
        self.N = N
        self.root = [-1] * N
        self.rank = [0] * N

    def __repr__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

    def find(self, x):
        """頂点xの根を見つける"""
        if self.root[x] < 0:
            return x
        else:
            while self.root[x] >= 0:
                x = self.root[x]
            return x

    def union(self, x, y):
        """x,yが属する木をunion"""
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        elif self.rank[x] > self.rank[y]:
            self.root[x] += self.root[y]
            self.root[y] = x
        else:
            self.root[y] += self.root[x]
            self.root[x] = y
            if self.rank[x] == self.rank[y]:
                self.rank[y] += 1

    def same(self, x, y):
        """xとyが同じグループに属するかどうか"""
        return self.find(x) == self.find(y)

    def count(self, x):
        """頂点xが属する木のサイズを返す"""
        return - self.root[self.find(x)]

    def members(self, x):
        """xが属する木の要素を列挙"""
        _root = self.find(x)
        return [i for i in range(self.N) if self.find == _root]

    def roots(self):
        """森の根を列挙"""
        return [i for i, x in enumerate(self.root) if x < 0]

    def group_count(self):
        """連結成分の数"""
        return len(self.roots())

    def all_group_members(self):
        """{ルート要素: [そのグループに含まれる要素のリスト], ...}の辞書を返す"""
        return {r: self.members(r) for r in self.roots()}

n, q = getNM()

uf = UnionFind(n)
for i in range(q):
    t, u, v = map(int, input().split())
    if t:
        print(int(uf.same(u, v)))
    else:
        uf.union(u, v)

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    ll n;
    cin >> n;
    ll a[n];
    rep(i, n) { cin >> a[i]; }
    map<ll, ll> m;
    ll ans = 0;
    rep(i, n) {
        ans += m[i - a[i]];
        m[a[i] + i]++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 27720
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 17;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;

ll n,a[100010];
int main(){
    int t,a,b;
    scanf("%d%d%d",&a,&b,&t);
    printf("%d\n",t/a*b);
    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++)

int main(){
  int N,K,out=1;
  cin >> N >> K;
  rep(i,N){
    if(out*2 <= out+K)
      out *= 2;
    else
      out += K;
  }
  cout << out << endl;
}
  


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 1e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;

void solve()
{
    int N; cin >> N;
    vi n(100001, 0);
    REP(i, N)
    {
        int a; cin >> a;
        n[a]++;
    }

    int ans = 0;;
    REP1(i, 100000-1)
    {
        int count = n[i-1] + n[i] + n[i+1];
        ans = max(ans, count);
    }
    
    cout << ans << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    solve();

    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    REP(i,n) cin >> a[i];
    REP(i,m) cin >> b[i];
    bool f = 0;
    REP(i,n-m+1){
        REP(j,n-m+1){
            bool g = 1;
            REP(k,m) REP(l,m) if (a[i+k][j+l] != b[k][l]) g = false;
            f |= g;
        }
    }
    cout << (f ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int A,B,C;
  cin>>A>>B>>C;
  int count=0;
  while(A%2==0&&B%2==0&&C%2==0){
    if(A==B&&B==C){cout<<-1<<endl;return 0;}
    int a=A;int b=B;int c=C;
   A=(b+c)/2;B=(a+c)/2;C=(a+b)/2;count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
n = gets.to_i

S = n.times.map do
  gets.chomp
end

alphabets = Array.new(26) { Array.new(n) {0} }

S.each_with_index do |s, i|
  s.chars.each do |c|
    alphabets[c.ord - 'a'.ord][i] += 1
  end
end

ans = ''
alphabets.each_with_index do |alphabet, i|
  num = alphabet.min
  ans += ('a'.ord + i).chr * num
end

puts ans


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

#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;

using namespace std;



ll solve(string s){
	int n = sz(s);
	ll ans = 1ll * n * (n + 1) / 2;
	vector<vi> v('z' + 1);
	rep(i , n){
		v[s[i]].pb(i);
	}
	repf(i , 'a' , 'z' + 1){
		rep(j , sz(v[i])){
			ans -= sz(v[i]) - j - 1;
		}
	}
	return ans - sz(s) + 1;
}

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

	string s;
	cin >> s;

	
	cout  << solve(s) << nl;

	return 0;
}

Measured memory_bytes: 2192
k, n = map(int, input().split())
housePosition = list(map(int, input().split()))
housePosition.append(k + housePosition[0])
biggestDistance = 0
for i in range(0, n):
  currentDistance = housePosition[i + 1] - housePosition[i]
  if(biggestDistance < currentDistance):
    biggestDistance = currentDistance
print(k - biggestDistance)

Measured memory_bytes: 26060
/*
Cerberus97
Hanit Banga
*/

#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 10000;

inline int get(ll a, ll k);

int main() {
	// int k; cin >> k;
	// for (int i = 0; i < k; ++i) {
	// 	g[i] = 0;
	// }
	// for (int i = k; i < N; ++i) {
	// 	int l = i - i / k, r = i - 1;
	// 	set<int> s;
	// 	for (int j = l; j <= r; ++j) {
	// 		s.insert(g[j]);
	// 	}
	// 	while (s.find(g[i]) != s.end()) {
	// 		++g[i];
	// 	}
	// }
	// for (int i = 0; i < N; ++i) {
	// 	if (get(i, k) != g[i]) {
	// 		cout << i << ' ' << g[i] << ' ' << get(i, k) << endl;
	// 		break;
	// 	}
	// }
	int n;
	cin >> n;
	int x = 0;
	for (int i = 1; i <= n; ++i) {
		int a, k;
		cin >> a >> k;
		x ^= get(a, k);
	}
	if (x) {
		cout << "Takahashi";
	} else {
		cout << "Aoki";
	}
}

inline int get(ll a, ll k) {
	while (true) {
		if (a < k) {
			return 0;
		} else if (a % k == 0) {
			return a / k;
		}
		ll d = (a / k), i = (a - d * (k - 1)) / (d + 1);
		a -= i * (d + 1);
	}
}

Measured memory_bytes: 256
program exam
  implicit none
  integer :: n, c, i
  integer(8),allocatable :: a(:), b(:), p(:)
  integer(8) :: pmax, d, y
  read(*,*) n
  allocate(a(n), b(n), p(n))
  read(*,*) a
  read(*,*) b
  if (sum(a) < sum(b)) then
     write(*,*) -1
     stop
  end if

  p = a - b
  c = 0

  do i = 1, n
     if (p(i) < 0) then
        c = c + 1
        d = d + abs(p(i))
     end if
  end do

  if (c == 0) then
     write(*,*) 0
     stop
  end if

  call heapsort(p)

  do i = n, 1, -1
     c = c + 1
     d = d - p(i)
     if (d <= 0) then
        exit
     end if
  end do
  write(*,*) c

  stop

contains
  
  subroutine heapsort(array)
    implicit none
    integer(8):: array(:)
    integer ::i,k,j,l
    integer(8) :: t

    n=size(array)

    if (n==1) then
       return
    end if
    
    l=n/2+1
    k=n
    do while(k.ne.1)
       if(l.gt.1)then
          l=l-1
          t=array(L)
       else
          t=array(k)
          array(k)=array(1)
          k=k-1
          if(k == 1) then
             array(1)=t
             exit
          endif
       endif
       i=l
       j=l+l
       do while(j.le.k)
          if(j.lt.k)then
             if(array(j).lt.array(j+1))j=j+1
          endif
          if (t.lt.array(j))then
             array(i)=array(j)
             i=j
             j=j+j
          else
             j=k+1
          endif
       end do
       array(i)=t
    end do
    return
  end subroutine heapsort

end program


Measured memory_bytes: 3200
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))),(c).end())
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int n, m;
int a[101010];
vector<int> G[101010];
bool used[101010];


int minl, minpos;

void serch(int pos) {
	queue<int> rue;
	rue.push(pos);
	while (rue.size()) {
		int que = rue.front();
		rue.pop();
		used[que] = true;
		if (minl > a[que]) {
			minl = a[que];
			minpos = que;
		}
		REP(i, G[que].size()) {
			if (!used[G[que][i]])rue.push(G[que][i]);
		}
	}
}


int main() {
	cin >> n >> m;
	REP(i, n)cin >> a[i];
	REP(i, m) {
		int x, y;
		cin >> x >> y;
		G[x].emplace_back(y);
		G[y].emplace_back(x);
	}
	if (n == 1) {
		cout << 0 << endl;
		return 0;
	}
	LL ans = 0;
	int cnt = 0;
	REP(i, n) {
		if (!used[i]) {
			cnt++;
			minl = INF;
			minpos = -1;
			serch(i);
			ans += a[minpos];
			a[minpos] = INF;
		}
	}
	if (cnt == 1) {
		cout << 0 << endl;
		return 0;
	}
	sort(a, a + n);
	REP(i, cnt - 2) {
		if (a[i] == INF) {
			cout << "Impossible" << endl;
			return 0;
		}
		ans += a[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 6272