akhauriyash/Code-Regression huggingface dataset:
use proconio::input;

const SZ:usize = 60;
fn main() {
    input! {
        n:usize,
        mut a:[i64;n]
    };

    a.sort();
    let a:Vec<_> = a.into_iter().rev().collect();
    let mut bases = vec![0;SZ];

    let sum = a.iter().fold(0,|acc,v|acc^v);
    let flag:Vec<_> = (0..SZ).map(|i| (sum>>i)&1==1).collect();

    let tpb = |x| {
        for i in (0..SZ).rev() {
            if flag[i] { continue; }
            if ((x>>i)&1)==1 {
                return i;
            }
        }
        return SZ;
    };
    for &v in &a {
        let mut x = v;
        for i in (0..SZ).rev() {
            if flag[i] { continue; }
            if ((x>>i)&1)==1 && bases[i]!=0 {
                x^=bases[i];
            }
        }
        if x!=0 {
            let b = tpb(x);
            if b<SZ {
                bases[b] = x;
            }
        }
    }
    // eprintln!("{:?}",bases);
    
    let mut av = 0;
    for i in (0..SZ).rev() {
        if (av>>i)&1==0 {
            av^=bases[i];
        }
    }
    let bv = sum^av;
    // eprintln!("a {} b {}",av,bv);
    println!("{}",av+bv);

}

Measured memory_bytes: 5432
#include<iostream>
#include <algorithm>
#include<queue>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<map>
#include<set>
using LL = long long;
using namespace std;
 
const int M = 2e5 + 100;
const int mod = 1e9 + 7;
 
vector<int> e[M];
int n, sz[M], ans[M];
int fac[M], inv[M], inv2[M];
 
LL mul(LL a, LL b) {
	return a * b % mod;
}
 
void init() 
{
	fac[0] = 1;
	for (int i = 1; i <= n; i++) 
		fac[i] = mul(fac[i - 1], i);
	inv[1] = 1;
	for (int i = 2; i <= n; i++) 
		//常规公式为inv[i] = mul((- mod / i), inv[mod % i])，为使得逆元为正数，分子加上mod仍有i*inv[i] = 1(mod p)
		inv[i] = mul((mod - mod / i), inv[mod % i]);
 
}
 
void dfs(int u, int fa) 
{
	sz[u] = 1;
	for (int v : e[u]) 
	{
		if (v != fa) 
		{
			dfs(v, u);
			sz[u] += sz[v];
		}
	}
}
 
void reroot(int cur, int p)
{
	ans[cur] = 1LL * ans[p] * sz[cur] % mod* inv[(n - sz[cur])] % mod;
	for (int i : e[cur])
	{
		if (i == p)
			continue;
		reroot(i,cur);
	}
}
int main() {
	cin >> n;
 	init();
	for (int i = 0; i < n - 1; i++) 
	{
		int u, v; 
		cin >> u >> v;
		e[u].push_back(v);
		e[v].push_back(u);
	}
	dfs(1, 0);
	ans[1] = fac[n];
	for (int i = 1; i <= n; i++) 
		ans[1] = mul(ans[1], inv[sz[i]]);
	for (int v : e[1]) 
		reroot(v, 1);
	for (int i = 1; i <= n; i++) 
		cout << ans[i] << "\n";
}


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

int main(void){
    int h = 0, w = 0;
    char s[51][51]; 

    scanf("%d%d", &h, &w);

    for(int i = 0; i < h; i++){
        scanf("%s", s[i]);
    }

    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int cnt = 0;
            if(s[i][j] == '#'){
                printf("#");
            }else{
                int dy[] = {-1, +1,  0,  0, -1, -1, +1, +1};
                int dx[] = { 0,  0, -1, +1, -1, +1, -1, +1};
                for (int k = 0; k < 8; k++) {
                    int h2 = i + dy[k];
                    int w2 = j + dx[k];
                    if (0 <= h2 && h2 < h && 0 <= w2 && w2 < w) {
                        if (s[h2][w2] == '#') {
                            cnt++;
                        }
                    }
                }

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

} 


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <set>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <functional>
#include <queue>
#include <deque>
#include <stack>
#include <limits>
#include <unordered_map>
#include <unordered_set>
#include <math.h>
#include <fstream>
#include <iterator>
#include <random>
#include <chrono>
 
 
#define forr(i,start,count) for (int i = (start); i < (start)+(count); ++i)
#define set_map_includes(set, elt) (set.find((elt)) != set.end())
#define readint(i) int i; cin >> i
#define readll(i) ll i; cin >> i
#define readdouble(i) double i; cin >> i
#define readstring(s) string s; cin >> s
 
typedef long long ll;
 
using namespace std;

ll modd = 1000*1000*1000+7;

 
int main()   {

    ios_base::sync_with_stdio(false);

    cout.precision(17);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    uniform_int_distribution<int> rand_gen(0, 1000);   // rand_gen(rng) gets the rand no
 
//    auto start = chrono::steady_clock::now();

//    readint(test_cases);
    int test_cases = 1;
    forr(t, 1, test_cases) {
        readint(h); readint(w); readint(a); readint(b);
        vector<string> grid(h, string(w, '0'));
        forr(i,0,b) {
            forr(j,0,a) {
                grid[i][j] = '1';
            }
        }
        for(int i = b; i < h; ++i) {
            for(int j = a; j < w; ++j) {
                grid[i][j] = '1';
            }
        }
        for (auto s : grid) {
            cout << s << endl;
        }
    }
 
//    auto end = chrono::steady_clock::now();
//    cout << chrono::duration_cast<chrono::milliseconds>(end - start).count() << endl;
 
    return 0;
}

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

int main(){
  string s,t;
  cin>>s;
  t = s;
  reverse(s.begin(),s.end());
  string u="";
  int i=0,j=0;
  bool able=1;
  s+='?';
  t+='?';
  
  while(i<s.size()||j<s.size()){
    if(i==s.size()){
      if(t[j]=='x')  u+='x',j++;
      else able=false; j++;
    }
    else if(j==s.size()){
      if(s[j]=='x')  u+='x',i++;
      else able=false; i++;
    }
      
    else if(s[i]=='x'&&t[j]!='x'){
      u+='x';
      i++;
    }
    else if(s[i]!='x'&&t[j]=='x'){
      u+='x';
      j++;
    }
    else if(s[i]=='x'&&t[j]=='x') u+='x',i++,j++;
    else if(s[i]==t[j]){
      u+=s[i];
      i++,j++;
    }
    else{
      able=false;
      break;
    }
  }
  
  if(able) cout<<u.size()-s.size()<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 896
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n, m int64
	fmt.Scan(&n, &m)
	if n >= m {
		fmt.Println(0)
		return
	}

	xs := make([]int64, m)
	for i := 0; i < int(m); i++ {
		fmt.Scan(&xs[i])
	}

	sort.Sort(int64Slices(xs))

	distances := make([]int64, len(xs)-1)
	for i, x := range xs[:len(xs)-1] {
		distances[i] = xs[i+1] - x
	}
	sort.Sort(int64Slices(distances))

	length := len(distances) - int(n) + 1
	var sum int64
	for _, d := range distances[:length] {
		sum = sum + d
	}
	fmt.Println(sum)
}

type int64Slices []int64

func (s int64Slices) Len() int {
	return len(s)
}

func (s int64Slices) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}

func (s int64Slices) Less(i, j int) bool {
	return s[i] < s[j]
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)

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

  set<int> ps;
  int cns;

  rep(i, N){
    cin >> cns;
    ps.insert(cns);
  }

  int min_val = 0;
  int min_deff = 1000;

  for(int i = 101; i > -3 ; i--){
    if(!ps.count(i)){
      if((X-i)>0){
        if((X-i)<=min_deff){
          min_val = i;
          min_deff = X-i;
        }
      }
      else{
        if((i-X)<=min_deff){
          min_val = i;
          min_deff = i-X;
        }
      }
    }
  }

  cout << min_val << endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define P pair<ll, ll>
using ll = long long;
#define ALL(v) (v).begin(),(v).end()
#define endl "\n"
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define co(x) cout << x << endl
#define coel cout << endl
#define pb push_back
#define sz(v) ((ll)(v).size())
using namespace std;  
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define pp pair<ll, pair<ll, ll>> 
#define fi first
#define se second

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

int main() {
    ll n; cin >> n;
    Vl a(n); 
    bool f = false;
    ll m = INF;
    rep(i, 0, n){ 
        cin >> a[i]; 
        if(a[i]==0) f = true;
        chmin(m, abs(a[i]));
    }
    ll cnt = 0;
    rep(i, 0, n){
        if(a[i]<0) cnt++;
    }
    if(f){
        ll ans = 0;
        rep(i, 0, n) ans += abs(a[i]);
        co(ans);
    }else{
        ll ans = 0;
        rep(i, 0, n) ans += abs(a[i]);
        if(cnt%2==0){
        }else{
            ans -= 2*m;
        }
        co(ans);
    }

    
    return 0;
}


Measured memory_bytes: 1024
import sys
from bisect import bisect_right as bsr
from collections import Counter as cnt
from collections import defaultdict as dd
from collections import deque
from fractions import gcd
from itertools import combinations as comb
from itertools import permutations as perm
from math import ceil, factorial, floor
from operator import itemgetter as ig

sys.setrecursionlimit(1000000)

# お約束
args = None
INF = float("inf")
MOD = int(1e9 + 7)


def input(*ps):
    if type(ps[0]) is list:
        return [input(*ps[0][:-1]) for _ in range(ps[0][-1])]
    elif len(ps) == 1:
        return ps[0](next(args))
    else:
        return [p(next(args)) for p in ps]


def yesno(v, yes="Yes", no="No", upper=False):
    if upper:
        print([yes.upper(), no.upper()][not v])
    else:
        print([yes, no][not v])


def main():
    """エントリーポイント"""
    N = input(int)
    print(ceil(N / 2) / N)


if __name__ == '__main__':
    args = iter(sys.stdin.read().split())
    main()


Measured memory_bytes: 5040
#include <iostream>
#include <queue>
 
int main(){
    std::priority_queue<u_int> heights;
     
    for (u_int h, i = 0; i < 10; ++i){
        std::cin >> h;
        heights.push(h);
    }
     
    for (u_int i = 0; i < 3; ++i){
        std::cout << heights.top() << std::endl;
        heights.pop();
    }
	
    return 0;
}

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

int main(){
    bool flag=true;
    long long ans=0,sum=0;
    string s,t;
    cin >>s>>t;
    

    for (int i = 0; i < 3; i++){
        if(s[i]==t[i])ans++;
    }
    


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << ans << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
object Main {
  def main(args:Array[String]) {
    val ab = readLine().split(' ').map(_.toLong)
    var g:Long = gcd(ab(1), ab(0))
    var ans = 1
    var loop = math.sqrt(g).toLong + 1
    for(i <- 2l to loop) {
      var flag = false
      while(g % i == 0) {
        flag = true
        g /= i
      }
      if(flag) ans += 1
    }
    if(g != 1) ans += 1
    println(ans)
  }

  def gcd(a:Long, b:Long):Long ={
    if(a == 0) b
    else gcd(b % a, a)
  }
}


Measured memory_bytes: 35120
import sys

# import bisect

from collections import Counter, deque, defaultdict

# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd

# import itertools

# from operator import attrgetter, itemgetter
# import math

# import numpy as np

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)
# 普通のグラフ
from collections import defaultdict


class Graph:
    # 0-indexed

    def __init__(self, vertices=0):
        self.edges = defaultdict(list)
        self.counter = [0] * vertices
        self._vertex_count = vertices
        self._edges_count = 0

    @property
    def edges_count(self):
        return self._edges_count

    @property
    def vertices_count(self):
        return self._vertices_count

    def add_edge(self, u, v):
        self.edges[u].append(v)
        self.edges[v].append(u)
        self._edges_count += 1

    def add_counter(self, u, cnt):
        self.counter[u] += cnt

    def add_directed_edge(self, u, v):
        self.edges[u].append(v)
        self._edges_count += 1

    def del_edge(self, u, v):
        self.edges[u] = [_ for _ in self.edges[u] if _[0] != v]
        self.edges[v] = [_ for _ in self.edges[v] if _[0] != u]
        self._edges_count -= 1

    # 連結している節点を求める
    def neighbors(self, index):
        return self.edges[index]

    # 連結要素数を求める
    def neighbors_count(self, index):
        return len(self.edges[index])

    # 重そう
    def __str__(self):
        desc = ""
        for u in range(self._edges_count):
            for v in self.edges[u]:
                if u < v:
                    desc += "{} {}".format(u, v)
        return desc


def main():
    n, q = list(map(int, readline().split()))
    g = Graph(n)
    visited = [False] * n

    for _ in range(n - 1):
        a, b = list(map(int, readline().split()))
        a, b = a - 1, b - 1
        g.add_edge(a, b)

    for _ in range(q):
        p, x = list(map(int, readline().split()))
        p = p - 1
        g.add_counter(p, x)

    que = deque()
    que.append((0, 0))
    visited[0] = True

    while que:
        cur, cnt = que.popleft()
        g.add_counter(cur, cnt)
        nxtcnt = g.counter[cur]

        for nxt in g.neighbors(cur):
            if not visited[nxt]:
                visited[nxt] = True
                que.append((nxt, nxtcnt))

    print(*g.counter, sep="\n")


if __name__ == '__main__':
    main()


Measured memory_bytes: 117028
#include <algorithm>
#include <iostream>
#include <vector>
#include <sstream>
using namespace std;
template<class T=int> inline T toint(string s) { T r; istringstream iss(s); iss >> r; return r; }

int main() {
    string s; cin >> s;
    int n = s.length();
    int cnt = 0;
    auto check = [&](int p, int len) {
        int val = toint(s.substr(p, len));
        if (len > 1 && s[p] == '0') return false;
        return 0 <= val && val <= 255;
    };
    #define rep(i) for (i = 1; i <= 3; i++)
    vector<int> len(4);
    rep(len[0]) rep(len[1]) rep(len[2]) rep(len[3]) {
        if (len[0] + len[1] + len[2] + len[3] != n) continue;
        int p = 0;
        bool ok = true;
        for (int l: len) ok &= check(p, l), p += l;
        cnt += ok;
    }
    cout << cnt << endl;
    return 0;
}



Measured memory_bytes: 3216
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include<stack> 
using namespace std;



int main(){
  int x[200]={};int i=0;
  char str[20]={};
  while(cin >>str){
    if(str[0] =='+'){ x[i-1] +=x[i]; i--;}
    else if(str[0]=='-') {x[i-1] = x[i-1]-x[i]; i--;}
    else if(str[0]=='*') {x[i-1] *= x[i]; i--;}
    else{ i++; x[i] =atoi(str);}
    
  }
  cout <<x[1]<<"\n";
  return 0;
}




Measured memory_bytes: 3096
/* 
   stO BZM Orz
   stO WJC Orz
   stO LHY Orz
   stO ZZX Orz
*/

#include<bits/stdc++.h>
using namespace std;
int main()
{
	int x,y;
	cin>>x>>y;
	int sum=0;
	if(x==1)sum+=3;
	if(x==2)sum+=2;
	if(x==3)sum+=1;
	if(y==1)sum+=3;
	if(y==2)sum+=2;
	if(y==3)sum+=1;
	if(x==1&&y==1)sum+=4;
	cout<<sum*100000<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
res = ""
char = dict(enumerate("zabcdefghijklmnopqrstuvwxy"))
#N -= 1
while N > 0:
    #res = chr(N % 26 + 0x61) + res
    res = char[N % 26] + res
    if N % 26 == 0:
        N = N // 26 - 1
    else:
        N //= 26

print(res)

Measured memory_bytes: 8976
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main(){	
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n;
	cin >> n;
	int h, h_max=0, res = 0;
	REP(i, n){
		cin >> h;
		if(h >= h_max){
			h_max = h;
			res++;
		}
	}
	
	cout << res << '\n';

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <string>
using namespace std;
int main(){

  int n,x,i;
  list <int> a;
  list<int>::iterator it;
  string com;

  cin>>n;
  for(i=0;i<n;i++){
    cin>>com;
    if(com=="deleteFirst") a.pop_front();
    else if(com=="deleteLast") a.pop_back();
    else{
      cin>>x;
      if(com=="insert") a.push_front(x);
      else for(it=a.begin();it!=a.end();it++) if(*it==x){
	    a.erase(it);
	    break; 
	  }
    }
  }
  i=0;
  for(it=a.begin();it!=a.end();it++){
    if(i++) cout<<" ";
    cout<<*it;
  }
  cout<<endl;

  return 0;

}
	



Measured memory_bytes: 34412
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()


int main(){
    vector<vector<int>> A(3, vector<int>(3));
    for(int i = 0; i < 3; i++) for(int j = 0; j < 3; j++) cin >> A[i][j];
    int N;
    cin >> N;
    vector<vector<bool>> B(3, vector<bool>(3, false));
    for(int i = 0; i < N; i++){
        int b;
        cin >> b;
        for(int j = 0; j < 3; j++){
            for(int k = 0; k < 3; k++){
                if(A[j][k] == b) B[j][k] = true;
            }
        }
    }
    bool bingo = false;
    for(int i = 0; i < 3; i++){
        if(B[i][0] and B[i][1] and B[i][2]) bingo = true;
    }
    for(int i = 0; i < 3; i++){
        if(B[0][i] and B[1][i] and B[2][i]) bingo = true;
    }
    if(B[0][0] and B[1][1] and B[2][2]) bingo = true;
    if(B[2][0] and B[1][1] and B[0][2]) bingo = true;
    if(bingo) puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <math.h>
 
int main(void) {
	int n,l, max = 0, sum = 0;
	scanf("%d", &n);
 
	for (int i = 0; i < n; ++i) {
		scanf("%d", &l);
		sum += l;
		max = fmaxf(max, l);
	}
	if (sum > 2 * max) {
		printf("Yes");
	}
	else {
		printf("No");
	}
 
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Text;

namespace ABC136
{
    class Program2
    {
        static void Main()
        {
            var N = int.Parse(Console.ReadLine());
            var len = N.ToString().Length;
            var ans = 0;
            for (int i = 0; i < len - 1; i += 2)
                ans += (int)(Math.Pow(10, i + 1) - Math.Max(Math.Pow(10, i), 0));

            if (len % 2 == 1)
                ans += N - ((int)Math.Pow(10, len - 1) - 1);

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11220
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n, a, b;
	cin >> n >> a >> b;
	if (n + 1 < a + b || a * b < n) {
		cout << -1 << endl;
		return 0;
	}
	vl ans(n);

	REP(i, n)ans[i] = i + 1;
	if (a != 1) {
		ll sum = a * b;
		vl tmp(a + 1, b - (sum - n) / (a - 1));
		REP(i, (sum - n) % (a - 1))tmp[a - i]--;
		tmp[0] = 0;
		tmp[1] = b;
		REP(i, a)tmp[i + 1] += tmp[i];
		assert(tmp[a] == n);
		REP(i, a) {
			reverse(ans.begin() + tmp[i], ans.begin() + tmp[i + 1]);
		}
	}
	else {
		reverse(ALL(ans));
	}
	REP(i, n) {
		if (i)cout << " ";
		cout << ans[i];
	}
	cout << endl;

}


Measured memory_bytes: 4588
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> wa(n, 0);
  vector<bool> ac(n, false);
  
  int ok = 0, pnt = 0;
  rep(i, m) {
    int p;
    string s;
    cin >> p >> s;
    p--;
    if (s == "AC" && !ac[p]) {
      ac[p] = true;
      ok++;
      pnt += wa[p];
    }
    else if (s == "WA") wa[p]++;
  }
  printf("%d %d", ok, pnt);
  return 0;
}

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

int n,k,kekka = 10000000;
char d[10];
void dfs(int i,string s){
  int num = 0;
  for(int j = 0;j < s.size();j++){
    num = num*10 + (s.at(j) - '0');
  }
  if(num >= n){
    kekka = min(kekka,num);
    return;
  }
  for(char j = '0';j <= '9';j++){
    bool p = true;
    for(int l = 0;l < k;l++){
      if(j == d[l] || (i == 0 && j == '0')){
        p = false;
      }
    }
    if(p != false){
      s += j;
      dfs(i+1,s);
      s.erase(s.size()-1,1);
    }
  }
  return;
}
int main(){
  cin >> n >> k;
  for(int i = 0;i < k;i++){
    cin >> d[i];
  }
  dfs(0,"");
  cout << kekka << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> X(N);
  for(int i = 0; i < N; ++i) cin >> X[i];
  long long ans = 1e18;
  for(int p = 0; p < 101; ++p){
    long long cost = 0;
    for(auto x : X){
      cost += (x-p)*(x-p);
    }
    ans = min(ans,cost);
  }
  cout << ans << endl;
}


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

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;

int main(int argc, char* argv[]){
	int N, M;
	cin >> N >> M;
	vector<int> v;
	vector<long long> dist;

	if(N >= M){
		cout << 0 << endl;
		return 0;
	}

	for(int i = 1; i <= M; i++){
		int x;
		cin >> x;
		v.push_back(x);
	}

	sort(v.begin(), v.end());

	for(int i = 0; i < v.size() - 1; i++){
		long long d = v[i + 1] - v[i];
		dist.push_back(d);
	}

	sort(dist.begin(), dist.end());

	for(int i=1; i<=N-1; i++){
		dist.pop_back();
	}

	long long ans = 0;
	for(int i=0; i<dist.size(); i++){
		ans += dist[i];
	}

	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 1784
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<functional>
#include<map>
#include<unordered_set>
using namespace std;
/*int p = 998244353;*/
int p = 1000000007;
#define int long long
#define vel vector<long long>
#define vvel vector<vel>
#define rep(i,n) for(int i=0;i<n;i++)
#define sor(v) sort(v.begin(),v.end())
#define mmax(a,b) a=max(a,b)
#define mmin(a,b) a=min(a,b)
#define mkp make_pair
#define pin pair<int,int>
#define qin pair<int,pin>
#define V vector
#define Endl endl
#define veb vector<bool>
#define sq(a) (a)*(a)
#define rev(s) reverse(s.begin(),s.end())
#define end_pr(s) cout << s <<endl;return 0
#define itn int
int RE() {
	vel v(3, 2);
	return v.at(4);
}
int ru(int a, int r) {
	if (r == 0) { return 1; }
	int ans = ru(a, r / 2);
	ans *= ans; ans %= p;
	if (r % 2 == 1) { ans *= a; }
	return ans % p;
}
int inv(int a) {
	return ru(a,p - 2);
}
vel dis(int mid1, vvel &way) {
	int n = way.size();
	vel dist(n, -1); dist[mid1] = 0;
	queue<int> q;
	q.push(mid1);
	while (!q.empty()) {
		int st = q.front(); q.pop();
		rep(i, way[st].size()) {
			int to = way[st][i];
			if (dist[to] == -1) {
				dist[to] = dist[st] + 1;
				q.push(to);
			}
		}
	}
	return dist;
}
pin most_far(int now, int n, vvel &way) {
	vel dist1 = dis(now, way);
	pin ans = mkp(-1, 0);
	rep(i, n) {
		if (dist1[i] > ans.first) { ans = mkp(dist1[i], i); }
	}
	return ans;
}

template<typename T>
V<T> uni(V<T> &v) {
	if (v.size() == 0) { return v; }
	sor(v);
	V<T> ans(1, v[0]);
	for (int i = 1; i < v.size(); i++) {
		if (v[i] != v[i - 1]) { ans.push_back(v[i]); }
	}
	v = ans;
	return v;
}
int s_gcd(int a, int b) {
	if (b == 0) { return a; }
	return s_gcd(b, a%b);
}
int gcd(int a, int b) {
	if (a < b) { swap(a, b); }
	return s_gcd(a, b);
}
int dist(vel &x, vel &u) {
	int ans = x[0] - u[0];
	rep(i, 3) { mmax(ans, x[i] - u[i]); }
	return ans;
}
signed main() {
	string s; cin >> s;
	s = 'x'+s;
	int n = s.size();
	vel dp(n + 1,0);
	vel next(26, n);
	V<pin> next1(n);//val,pot
	for (int i = n - 1; i >= 0; i--) {
		int mn = n + 1;
		rep(j, 26) {mmin(mn, dp[next[j]]);}
		dp[i] = mn + 1;
		rep(j, 26) {
			if (mn == dp[next[j]]) { 
				next1[i] = mkp(j,next[j]);
				break;
			}
		}
		int val = s[i] - 'a';
		next[val] = i;
	}
	int i = 0;
	string t;
	while (i < n) {
		t += ('a'+next1[i].first);
		i = next1[i].second;
	}
	cout << t << endl;
}

Measured memory_bytes: 5312
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll gcd(ll a,ll b){lll x=0,y=0;return gcd(a,b,x,y);}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
int n, k, a=1;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> k;
  FOR(i, 0, n){
    if(a < k){
      a*=2;
    }else{
      a+=k;
    }
  }
  cout << a << endl;
}

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


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, typ=int):
    return [typ(input()) for _ in range(n)]


def main():
    n, x = read_h()
    a = sorted(read_h())

    cnt = 0
    rem = x
    for ai in a:
        rem -= ai
        if rem < 0:
            break
        cnt += 1

    if rem > 0:
        cnt -= 1

    print(cnt)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
import sys
input = lambda: sys.stdin.readline().rstrip()
N = int(input())
C = [int(a) - 1 for a in input().split()]
X = [[] for i in range(N)]
for i in range(N-1):
    x, y = map(int, input().split())
    x, y = x-1, y-1
    X[x].append(y)
    X[y].append(x)

def EulerTour(n, X, i0):
    def f(k):
        return k * (k + 1) // 2
    USED = [0] * n
    USEDORG = [0] * n
    USEDTMP = [0] * n
    P = [-1] * n
    Q = [~i0, i0]
    ct = -1
    ET = []
    ET1 = [0] * n
    ET2 = [0] * n
    DE = [0] * n
    ANS = [0] * n
    de = -1
    while Q:
        i = Q.pop()
        if i < 0:
            ET2[~i] = ct
            de -= 1
            USED[C[~i]] += 1 + USEDTMP[~i]
            USEDTMP[~i] = 0
            if ~i:
                p = P[~i]
                pc = C[p]
                k = ET2[~i] - ET1[~i] + 1 - USED[pc] + USEDORG[~i]
                ANS[pc] += f(k)
                USEDTMP[p] += k
            continue
        if i >= 0:
            if i:
                USEDORG[i] = USED[C[P[i]]]
            ET.append(i)
            ct += 1
            if ET1[i] == 0: ET1[i] = ct
            de += 1
            DE[i] = de
        for a in X[i][::-1]:
            if a != P[i]:
                P[a] = i
                for k in range(len(X[a])):
                    if X[a][k] == i:
                        del X[a][k]
                        break
                Q.append(~a)
                Q.append(a)
    for i in range(n):
        ANS[i] = f(n) - f(n - USED[i]) - ANS[i]
    return ANS

ANS = EulerTour(N, X, 0)
print(*ANS, sep = "\n")

Measured memory_bytes: 158544
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int n = sc.nextInt();
  int k = sc.nextInt();
  long[] a = new long[n];
  for(int i = 0;i < n;i++){
    long b = sc.nextLong();
    a[i] = b;
  }
  Arrays.sort(a);
  long min = 1000000000;
  for(int i = 0;i < n-k+1;i++){
    min = Math.min(min,a[i+k-1]-a[i]);
  }
  System.out.println(min);
}}


Measured memory_bytes: 50400
// lcmとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define double long double
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    cin>>str;
    rep(i,str.length()){
        if(i%2==0)cout<<str[i];
    }
    return 0;
}


Measured memory_bytes: 592
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll MOD=(ll)998244353;
//}}}

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

int A[100000];
int main(){
  int N, K;
  cin >> N >> K;
  rep(i, N){
    cin >> A[i];
  }
  sort(A, A + N);
  int l = A[0];
  rep(i, N){
    l = gcd(l, A[i]);
  }
  bool ans = K <= A[N - 1] && K % l == 0;
  puts(ans ? "POSSIBLE" : "IMPOSSIBLE");
  return 0;
}


Measured memory_bytes: 640
K, S = map(int, input().split())
count = 0
for i in range(max(0, S - 2 * K), min(K, S) + 1):
  for j in range(max(0, S - 2 * K), min(K, S) + 1):
      if i + j <= S and i + j >= S - K:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef DEBBY
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

#define ll long long
#define rep(i,a,b) for(int i=int(a); i<=int(b); i++)
#define sz(v)  (int)(v).size()
#define all(v) (v).begin(), (v).end()
#define pi pair<int,int>
#define vi vector<int>
#define vpi vector<pi>
#define fs first
#define sd second
#define pb push_back


void solve(){
   int w,s; cin >> s >> w;
   if(w>=s)
    cout << "unsafe";
    else 
    cout << "safe";
} 

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





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

int main(){
  int N;
  cin >> N;
  
  vector<int>kari(N);
  int s=0;
  
  for (int i=0; i<N; i++){
    cin >> kari.at(i); //数値を入れた
    if( kari.at(i)%2 == 0) s++;
  }
  
  vector<int>num(s);
  int count=0;
  
  for (int j=0; j<N; j++){
    if( kari.at(j)%2 == 0){
      num.at(count) = kari.at(j);
      count++;
    }
  }
  int z = 0;
  for (int k=0; k<s; k++){
    if( num.at(k)%3 == 0 || num.at(k)%5 == 0) z++;
  }
  if( z == s ) cout << "APPROVED" << endl;
  else cout << "DENIED" << endl;
}


Measured memory_bytes: 256
// AOJ 3125 Today's Random Number
// 2020.1.14 bal4u

#include <stdio.h>

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int main()
{
	int N, a, A, ans;
	
	N = in(), a = in();
	ans = 0;
	while (--N) {
		A = in();
		if (A > a) ++ans;
		a = A;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 2056
#include <stdio.h>

/* 配列の要素を順番に出力 */
void trace(int A[],int N) {
	int i;
	for(i=0;i<N;i++) {
		/* 隣接する要素の間に1つの空白を出力 */
		if(i>0) printf(" ");
		printf("%d",A[i]);
	}
	printf("\n");
}

/* 挿入ソート(0オリジン配列) */
void insertionSort(int A[], int N) {
	int i,j,v;
	for(i=1;i<N;i++) {
		v=A[i];
		j=i-1;
		while(j>=0 && A[j] > v) {
			A[j+1] = A[j];
			j--;
		}
		A[j+1]=v;
		trace(A,N);
	}
}

int main(void)
{
	int N, i, j;
	int A[100];
	scanf("%d",&N);
	for(i=0;i<N;i++) scanf("%d",&A[i]);
	
	trace(A,N);
	insertionSort(A,N);
	return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
#define N 500005
#define oo (1<<30)
using namespace std;
int n,m,q,a[N],b[N],d[N];
int main()
{
	int i;
	scanf("%d %d",&n,&m),a[0]=m;
	for(i=1;i<=n;i++)
		scanf("%d",&d[i]),a[i]=min(a[i-1],abs(a[i-1]-d[i]));
	b[n]=1;
	for(i=n;i>=1;i--) 
		if(b[i]<=d[i]/2) b[i-1]=b[i];
		else b[i-1]=b[i]+d[i];
	cin>>q;
	while(q--){
		scanf("%d",&i);
		if(a[i-1]>=b[i]) printf("YES\n");
		else printf("NO\n");
	  }
	return 0;
}


Measured memory_bytes: 7808
n,m = map(int,input().split())
s,c = [0]*m,[0]*m
for i in range(m):
    s[i],c[i] = map(int,input().split())
    s[i] -= 1
number = ['0']*n
for j in range(m):
    if number[s[j]] != '0' and number[s[j]] != str(c[j]):
        print('-1')
        quit()
    elif s[j] == 0 and c[j] == 0 and n != 1:
        print('-1')
        quit()
    else:
        number[s[j]] = str(c[j])
else:
    if number[0]  == '0' and  n != 1:
        number[0] = '1'

print(''.join(number))

Measured memory_bytes: 9140
package main

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

func main() {
	sc := NewScanner()

	n := sc.NextInt()
	m := sc.NextInt()
	c := sc.NextInt()

	b := make([]int, m)
	ans := 0
	for i := 0; i < m; i++ {
		b[i] = sc.NextInt()
	}
	for i := 0; i < n; i++ {
		sum := c
		for j := 0; j < m; j++ {
			tmp := sc.NextInt()
			sum += (tmp) * b[j]
		}
		if sum > 0 {
			ans++
		}
	}

	fmt.Printf("%v\n", ans)
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
void solve(){
    int d, n;
    cin >> d >> n;
    if(n == 100)
    n = 101;
    int ans = 1;
    for(int i = 0; i < d; i++){
        ans *= 100;
    }
    cout << ans * n << endl;
}
int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
/**
 * @author torith
 * @date 2019-02-03
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

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

    int N; cin >> N;
    int sum = 0;
    int max_hen = 0;
    for (int i = 0; i < N; ++i) {
        int t; cin >> t;
        sum += t;
        max_hen = max(t, max_hen);
    }

    if(max_hen < sum - max_hen) cout << "Yes" << "\n";
    else cout << "No" << "\n";

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int main(void){
    int y,m,d;

    while(cin>>y>>m>>d){
        if(0);
        else if(y<1868 || y==1868 && (m<9  || (m==9  && d<8 )))cout<<"pre-meiji"<<endl;
        else if(y<1912 || y==1912 && (m<7  || (m==7  && d<30)))cout<<"meiji "   <<y-1867<<" "<<m<<" "<<d<<endl;
        else if(y<1926 || y==1926 && (m<12 || (m==12 && d<25)))cout<<"taisho "  <<y-1911<<" "<<m<<" "<<d<<endl;
        else if(y<1989 || y==1989 && (m<1  || (m==1  && d<8 )))cout<<"showa "   <<y-1925<<" "<<m<<" "<<d<<endl;
        else cout<<"heisei "<<y-1988<<" "<<m<<" "<<d<<endl;
    }


    return 0;
}

Measured memory_bytes: 1164
#define _CRT_SECURE_NO_WARNINGS

#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds

#define eps 1e-6
#define M_PI 3.141592653589793
#define bs 1000000007
#define bsize 350

using namespace std;

const int INF = 1e9;
const int N = 110000;

int n, T, mx, mn, cnt;
int ar[N];
int bst;

int main(){
	//freopen("fabro.in","r",stdin);
	//freopen("fabro.out","w",stdout);
	//freopen("F:/in.txt", "r", stdin);
	//freopen("F:/output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
	//cin.tie(0);
	
	mn = 1e9;

	cin >> n >> T;
	for (int i = 1; i <= n; i++)
	{
		cin >> ar[i];
		if (ar[i] < mn)
		{
			mn = ar[i];
		}
		if (ar[i]>mx)
		{
			mx = ar[i];
		}
		if (ar[i] - mn >= bst)
		{
			if (ar[i] - mn > bst)
				cnt = 0;
			++cnt;
			bst = ar[i] - mn;
		}
	}
	//cout << bst << endl;

	cout << cnt << endl;

	cin.get(); cin.get();
	return 0;
}

Measured memory_bytes: 1148
import math
import copy
import sys
import fractions
import numpy as np
from functools import reduce

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

def getInputStr():
    inputNum = str(input())
    return inputNum

s = getInputStr()
t = getInputStr()


listS = []
listS = list(s)
listT = []
listT = list(t)

lim = len(listS)

onedic = {}
twodic = {}

flg = True

for i in range(lim):
    keyone = listS[i]
    keytwo = listT[i]

    if keyone not in onedic:
        onedic[keyone] = keytwo
    else:
        if onedic[keyone] != keytwo:
            flg = False
            break

    if keytwo not in twodic:
        twodic[keytwo] = keyone
    else:
        if twodic[keytwo] != keyone:
            flg = False
            break

if flg:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 17180
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

int main() {
  int A, B, T;
  std::cin >> A >> B >> T;

  std::cout << T / A * B << std::endl;
}


Measured memory_bytes: 888
#include <iostream>

using std::cin;
using std::cout;
using std::endl;

static int
solve(int N, int R)
{
  return 10 <= N ? R : R + 100 * (10 - N);
}

int
main()
{
  int N, R;
  cin >> N >> R;
  cout << solve(N, R) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,(n)-1,0)
#define all(v) v.begin(), v.end()
#define endk '\n'
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b){if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b){if(a<b) a=b;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t; cin >> s >> t;
  int ans = inf;
  rep(i, s.size()) {
    if(i+t.size()>s.size()) continue;
    int cnt = 0;
    rep(j, t.size()) {
      if(s[i+j] != t[j]) cnt++;
    }
    chmin(ans, cnt);
  }
  cout << ans << endk;
  return 0;
}


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

using namespace std;

#define PI 3.141592653589

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int A, B, H, M;
  cin >> A >> B >> H >> M;
  double deg = abs((H * 60.0 + M) / (60.0 * 12) - M / 60.0) * 360;
  double res = A * A + B * B - 2 * A * B * cos(deg * PI / 180.0);
  cout << setprecision(15) << sqrt(res) << endl;
  return 0;
}


Measured memory_bytes: 4148
#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>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
	int n;
	cin>>n;
	string s,t;
	cin>>s>>t;
	rep(i,n+1){
		if(s.substr(i)==t.substr(0,n-i)){
			cout<<n+i<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
#include<iostream> 
#include<cstdio>
#include<algorithm>
using namespace std;
const int M = 100 + 5;
int main(){
	int a[M][M] = {0},b[M]={0},d[M]={0};
	char c;
	int h,w,x,y;
	cin>>h>>w;
	y=0;
	x=w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>c;
			if(c=='#'){
				a[i][j]=1;
				b[i]=1;
				x=min(x,j);
				y=max(y,j);
			} 
			else
				a[i][j]=0;
		}
	}
	for(int i=0;i<w;i++){
		for(int j=0;j<h;j++){
			if(a[j][i]!=0){
				d[i]=1;
				break;
			}
		} 
	}
	for(int i=0;i<h;i++){
		if(b[i]==0)continue;
		for(int j=x;j<=y;j++){
			if(d[j]==0)continue;
			if(a[i][j]==0)
				cout<<'.';
			else
				cout<<'#';
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
stdin = sys.stdin

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,k = li()
xs = []
ys = []
points = []
for _ in range(n):
    x,y = li()
    xs.append(x)
    ys.append(y)
    points.append((x,y))
    
xs.sort()
ys.sort()

ans = float("inf")
for xst in range(n):
    for xed in range(xst+1,n):
        for yst in range(n):
            for yed in range(yst+1, n):
                cnt = 0
                for px,py in points:
                    if xs[xst] <= px <= xs[xed] and ys[yst] <= py <= ys[yed]:
                        cnt += 1
                        
                if cnt >= k:
                    ans = min(ans, (xs[xed]-xs[xst])*(ys[yed]-ys[yst]))
                    
print(ans)

Measured memory_bytes: 48220
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.PriorityQueue;
import java.util.StringTokenizer;
import java.util.TreeSet;

public class Main {
	
	public static void main(String[] args) throws IOException {
		try(final Scanner sc = new Scanner(System.in)){
			final String S = sc.next();
			
			System.out.println(S.matches("A[a-z]+C[a-z]+") ? "AC" : "WA");
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 23124