akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N, x[100], y[100], h[100];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i] >> h[i];
	}

	for (int Cx = 0; Cx <= 100; Cx++) {
		for (int Cy = 0; Cy <= 100; Cy++) {
			int H = -1; // -1:未確定
			int Hmax = 2e9 ; // h[i]=0である点から要求されるHの上限、らしい
			bool success = true;
			for (int i = 0; i < N; i++) {
				int distance = abs(Cx - x[i]) + abs(Cy - y[i]);
				if (h[i] > 0) {
					int H2 = h[i] + distance; // H2は仮のH
					if (H > 0 && H != H2) {
						success = false;
						break;
					} else H = H2;
				} else Hmax = min(Hmax, distance);
			}
			if (success && H <= Hmax) {
				cout << Cx << " " << Cy << " " << H << endl;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 256
N, *X = map(int, open(0).read().split())

x_to_i = {x: i for i, x in enumerate(X, 1)}
I = sorted(range(1, N + 1), key=lambda i: X[i - 1])

T = []
for i in I:
    T += [i] * (i - 1)
for i in I:
    T += [i] * (N - i)
T = iter(T)

C = [0] * (N + 1)
A = []
for x in range(1, N * N + 1):
    if x in x_to_i:
        i = x_to_i[x]
        if C[i] + 1 != i:
            print("No")
            quit()
    else:
        i = next(T)
    C[i] += 1
    A.append(i)

print("Yes")
print(*A)

Measured memory_bytes: 12944
import java.util.*;

class Main  {
  public static void main(String[] args) {

    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();

    if(a < b){
      System.out.println("a < b");
    }
    else if(a > b){
      System.out.println("a > b");
    }
    else if(a == b){
      System.out.println("a == b");
    }
  }
}

Measured memory_bytes: 26184
import collections
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s)

cc = c.most_common()

m = cc[0][1]

l = []

for i,j in cc:
    if j == m:
        l.append(i)

ll = sorted(l)
for i in ll:
    print(i)

Measured memory_bytes: 49208
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer


object Main {
  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextLong()
    n
  }


  def solve(n: Long): Long = {
    def isFavorite(k: Long): Boolean = k > 0 && n % k == n / k
    divisor(n).map(_ - 1).filter(isFavorite).sum
  }

  def experiment(n: Long): Unit = {
    def isFavorite(k: Int): Boolean = n % k == n / k
    for(k<- 1 to n.toInt){
      println(s"k=$k, (${n/k}, ${n%k}), ${isFavorite(k)}")
    }
  }

  def divisor(n: Long): IndexedSeq[Long] = {
    val buf = ArrayBuffer.empty[Long]
    for (i <- 1 to Math.sqrt(n).toInt) {
      if (n % i == 0) {
        buf.append(i)
        if (i * i != n) {
          buf.append(n / i)
        }
      }
    }
    buf.toIndexedSeq
  }

  def experiment2(n: Long): Unit = {
    def isFavorite(k: Int): Boolean = n % k == n / k
    def printInfo(k:Int):Unit = {
      println(s"k=$k, (${n/k}, ${n%k}), ${isFavorite(k)}")
    }
    (1 to n.toInt).filter(isFavorite).foreach(printInfo)

    println("divisor")
    divisor(n).sorted.foreach(println)
  }

  def main(args: Array[String]): Unit = {
    //experiment2(200)
    val n = read()
    println(solve(n))
  }
}

Measured memory_bytes: 29388
def main ():
    n,m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(m)]
    g = [[] for _ in range(n+1)]
    for a,b in ab:
        g[a].append(b)
        g[b].append(a)
    if set(g[1]) & set(g[n]) != set([]):
        print('POSSIBLE')
    else:
        print('IMPOSSIBLE')


if __name__ == '__main__':
    main()


Measured memory_bytes: 75332
import sys
input = sys.stdin.readline

N = int(input())
S = input().rstrip('\r\n')
ans = 0
for i in range(1000):
    target = str(i).zfill(3)
    indices = [-1] * 3
    for m, c in enumerate(target):
        if m == 0:
            idx = S.find(c)
            if idx == -1:
                break
            indices[0] = idx
            continue
        for n in range(indices[m-1]+1, N):
            if c == S[n]:
                # print(target)
                indices[m] = n
                break
        if indices[0] > -1 and indices[1] > -1 and indices[2] > -1:
            ans += 1
print(ans)

Measured memory_bytes: 42204
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod;
ll dp[6666][2222];
int main()
{
	int num;
	scanf("%d%lld", &num, &mod);
	dp[0][0] = 1;
	for (int i = 0; i < num * 3; i++)
	{
		int t = num * 3 - i;
		for (int j = 0; j <= num; j++)
		{
			dp[i + 3][j + 1] = (dp[i + 3][j + 1] + dp[i][j] * (t - 1)*(t - 2)) % mod;
			dp[i + 2][j + 1] = (dp[i + 2][j + 1] + dp[i][j] * (t - 1)) % mod;
			dp[i + 1][j] = (dp[i + 1][j] + dp[i][j]) % mod;
		}
	}
	ll ans = 0;
	for (int i = 0; i <= num; i++)ans += dp[num * 3][i];
	printf("%lld\n", ans%mod);
}

Measured memory_bytes: 104576
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cctype>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<algorithm>
#include<functional>
#include<bits/stdc++.h>
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	
	int n;
	cin>>n;
	cout<<n*n*n<<endl;
	    
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

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

int main() {
    int A, B, C;
    while (~scanf("%d %d %d", &A, &B, &C)) {
          int MX = max({A, B, C});
          int sum = 3 * MX - A - B - C;
          int ans = sum / 2 + ((sum % 2) ? 2 : 0);
          printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>

using namespace std;

#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 = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 999999999
#define MINF -999999999
#define ALL(n) n.begin(),n.end()
int dp[242321],a[242321],ans = 0;


int main() {
	ll a, b, c,d;
	cin >> a >> b >> c;
	d = min(a + b + 1, c);

	cout << b + d <<endl;
}


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

using namespace std;

int main(){
    int n,l = 1001,r = 0;
    cin >> n;

    for(int i = 0;i < n;i++){
        int a;
        cin >> a;
        l = min(l,a);
        r = max(r,a);
    }

    cout << r-l << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> li = new ArrayList<>();
        for(int i = 0; i < n; i++){
            li.add(sc.nextInt());
        }
        Collections.sort(li, Comparator.reverseOrder());
        int ans = 0;
        int i = 0;
        for(int a: li){
            if(i % 2 == 0){
                ans += a;
            }else{
                ans -= a;
            }
            i++;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
 
typedef long long int ll; 
typedef long double ld; 
 
#define MAX 200005
#define endl endl


int main()
{
	
	std::ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	ll n, d;
	cin>>n>>d;
	
	vector< pair<ll,ll> > vec(n);
	
	for(ll i=0;i<n;i++){
		cin>>vec[i].first>>vec[i].second;
	}
	ll ans  = 0;
	for(ll i=0;i<n;i++){
		ld val = sqrt(vec[i].first*vec[i].first + vec[i].second*vec[i].second);
		if(val<=d){
			ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 6376
N = int(input())
listA = list(map(int,input().split()))

def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

L = [0]
R = [0]


for i in range(N):
	L.append(gcd(L[i],listA[i]))
	R.append(gcd(R[i],listA[N-1-i]))

ans = 0
for i in range(N):
	ans = max(ans,gcd(L[i],R[N-1-i]))

print(ans)



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

using namespace std;
int main(){
    int L,R,m=2019*2019;
    cin>>L>>R;
    int n;
    n=min(R-L,2018);
    if(n==2018) cout<<"0"<<endl;
    else{
        for(int i=L%2019;i<R%2019;i++){
            for(int j=i+1;j<=R%2019;j++){
                m=min(m,j*i%2019);
            }
        }
        cout<<m<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=1<<18;
const int mod=998244353;
const int inv2=mod+1>>1;

inline int power(int a,int b)
{
	int ans=1;
	while(b)
	{
		if(b&1)ans=(ll)ans*a%mod;
		b>>=1;
		a=(ll)a*a%mod;
	}
	return ans;
}

int A[maxn],B[maxn],C[maxn];
int n,M;

inline void FWT(int *p)
{
	for(int i=1;i<M;i<<=1)
		for(int j=0;j<M;j+=i<<1)
			for(int k=0;k<i;k++)
			{
				int x=p[j+k],y=p[i+j+k];
				p[j+k]=(x+y)%mod;
				p[i+j+k]=(x-y)%mod;
			}
}

inline void IFWT(int *p)
{
	for(int i=1;i<M;i<<=1)
		for(int j=0;j<M;j+=i<<1)
			for(int k=0;k<i;k++)
			{
				int x=p[j+k],y=p[i+j+k];
				p[j+k]=(ll)(x+y)%mod;
				p[i+j+k]=(ll)(x-y+mod)%mod;
			}
}

inline void init()
{
	n=read();M=1<<n;
	int sum=0;
	REP(i,0,M-1)A[i]=read(),sum+=A[i];
	sum=power(sum,mod-2);
	REP(i,0,M-1)A[i]=(ll)(A[i])*sum%mod;
	FWT(A); 
	REP(i,0,M-1)A[i]=(ll)power(1-A[i]+mod,mod-2)%mod;
	IFWT(A);
}

inline void doing()
{
	puts("0");
	REP(i,1,M-1)
	{
		int res=(A[0]-A[i]+mod)%mod;
		printf("%d\n",res);
	}
}

int main()
{
	init();
	doing();
	return 0;
}


Measured memory_bytes: 3840
#include <stdio.h>
int main(void){
    int a, b;
    int d, r;
    double f;
    
    scanf("%d %d\n", &a, &b);
    
    d = a / b;
    r = a % b;
    f = (double)a / (double)b;
    
    printf("%d %d %.5f\n", d, r, f);
    
    return 0;
}


Measured memory_bytes: 2128
# データ読み込み

import sys
from collections import deque

def input_data(d=""):
  t = sys.stdin.read()
  if t:
    return t
  else:
    if d[0] == "\n":
      d = d[1:]
    if d[-1] == "\n":
      d = d[:-1]    
    return d

A, *B  = map(int,input_data().split())

m = []

if 1 not in B:
  print(-1)
else:
  out = 0
  c = 1
  for i in B:
    if i == c:
      c+=1
    else:
      out+=1
  print(out)

Measured memory_bytes: 24900
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	string s, ans; cin >> s;
    ans = "";
    int ssize = s.size();
    for (int i = 0; i < ssize; i++)
    {
        if(s[i] == '0'){ ans.push_back('0'); }
        else if (s[i] == '1'){ ans.push_back('1'); }
        else
        { 
            if (ans.size() > 0)
            {
                ans.pop_back();
            }  
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := NewScanner()

	// i = 0 to (n-1) と考えて良い
	n := sc.ReadInt()

	matchToRightCounts := make([]int, n)
	matchToLeftCounts := make([]int, n)
	cnt := 0
	for i := 0; i < n; i++ {
		ai := sc.ReadInt()

		// left
		{
			pos := i - ai
			if pos >= 0 {
				matchToLeftCounts[pos]++
				cnt += matchToRightCounts[pos]
			}
		}

		// right
		{
			pos := i + ai
			if pos < n {
				matchToRightCounts[pos]++
				cnt += matchToLeftCounts[pos]
			}
		}
	}

	fmt.Println(cnt)
}

// util
// *   math/simple

func Abs(x int) int {
	if x >= 0 {
		return x
	}
	return -x
}

func Min(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	min := values[0]
	for _, v := range values {
		if v < min {
			min = v
		}
	}
	return min
}

func Max(values ...int) int {
	if len(values) == 0 {
		panic("no values")
	}
	max := values[0]
	for _, v := range values {
		if v > max {
			max = v
		}
	}
	return max
}

func Pow(base int, exponent uint) int {
	answer := 1
	for i := uint(0); i < exponent; i++ {
		answer *= base
	}
	return answer
}

// *   io

type Scanner struct {
	bufScanner *bufio.Scanner
}

func NewScanner() *Scanner {
	bufSc := bufio.NewScanner(os.Stdin)
	bufSc.Split(bufio.ScanWords)
	bufSc.Buffer(nil, 100000000)
	return &Scanner{bufSc}
}

func (sc *Scanner) ReadString() string {
	bufSc := sc.bufScanner
	bufSc.Scan()
	return bufSc.Text()
}

func (sc *Scanner) ReadInt() int {
	bufSc := sc.bufScanner
	bufSc.Scan()
	text := bufSc.Text()

	num, err := strconv.Atoi(text)
	if err != nil {
		panic(err)
	}
	return num
}


Measured memory_bytes: 6168
n = int(input())
A= list(map(int,input().split()))
i = 0
two = []
for a in A:
    if a%2 == 0:
        two.append(a/2)
        i += 1

while len(two) > 0:
    for j in range(len(two)-1,-1,-1):
        if two[j]%2 == 0:
            two[j] /= 2
            i += 1
        else:
            two.pop(j)
print(i)

Measured memory_bytes: 4148
def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    return table


N = int(input())
ans = 0
L = num_divisors_table(N)[1:]

for i in range(N):
    ans += (i+1)*L[i]
print(ans)

Measured memory_bytes: 224328
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;

int main() {
    int N, K; cin >> N >> K;
    string S; cin >> S;
    for (int i = 0; i < N; i++) {
        if (i == K - 1) {
            int c = static_cast<int>(S[i]);
            cout << static_cast<char>(c + 32);
        } else {
            cout << S[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#define L long long int

L lcm(L a,L b){
  if(a==b)
    return a;
  else if(a<b)
    return lcm(b,a);
  else
    return lcm(a-b,b);
}

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

int main(){
  L a,b;

  while(~scanf("%lld %lld",&a,&b))
    printf("%lld %lld\n",lcm(a,b),gcd(a,b));
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin >> N;
	vector<int> H(N+1);
	for(int i = 0; i < N; i++)
		cin >> H.at(i);

	bool flg = true;
	H.at(0)--;
	for(int i = 1; i < N-1; i++){
		if(H.at(i-1) <= H.at(i) && H.at(i) <= H.at(i+1)){
			if(H.at(i-1) < H.at(i))
				H.at(i)--;
			continue;
		}
		if(H.at(i-1) <= H.at(i)-1 && H.at(i)-1 <= H.at(i+1)){
			H.at(i)--;
			continue;
		}
		flg = false;
		break;
	}
		
	cout << (flg?"Yes":"No") << endl;
}	

Measured memory_bytes: 640
#include <iostream>
#include <string>

using namespace std;

int main(void){
  string in;
  int sum, len, num;

  while(true){

    cin >> in;

    if(in[0] == '0' && in.length() == 1){
      break;
    }

    sum = 0;

    len = in.length();
    for(int i = 0; i < len; i++){
      num = (int)in[i] - 48;
      sum += num;
    }

    cout << sum << endl;
  }

  return 0;
}

Measured memory_bytes: 1184
#pragma comment(linker, "/STACK:1000000000")
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<deque>
#include<cassert>
#include<ctime>
#include<unordered_map>
#include<cmath>
using namespace std;

#define sz(x) (int)(x.size())
#define fi(a,b) for(int i=a;i<b;++i)
#define fj(a,b) for(int j=a;j<b;++j)
#define fo(a,b) for(int o=a;o<b;++o)
#define fdi(a,b) for(int i=a-1;i>=b;--i)
#define fdj(a,b) for(int j=a-1;j>=b;--j)
#define fdo(a,b) for(int o=a-1;o>=b;--o)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld;
//////////////////////

int const N = 1e5 + 41;

int n, l;
int a[N];

void solve(){
	int id = -1;
	fi(0, n-1){
		if(a[i] + a[i+1] >= l){
			id = i;
		}
	}
	if(id == -1){
		printf("Impossible\n");
		return;
	}

	vector<int> ans;
	ans.pb(id);
	fdi(id, 0){
		ans.pb(i);
	}
	fi(id+1, n-1){
		ans.pb(i);
	}
	reverse(ans.begin(), ans.end());

	printf("Possible\n");
	fi(0, sz(ans)) printf("%d\n",ans[i]+1);
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	scanf("%d %d",&n,&l);
	fi(0, n) scanf("%d",&a[i]);

	solve();

	

	return 0;
}

Measured memory_bytes: 1784
#include <bits/stdc++.h>
#define MOD 998244353
/// TONI BO$$ was here
/// #MLC

using namespace std;
int dp[200001],add[200001];
int intr[11][2];
int main()
{
    int n,k,i,j;
    scanf("%d%d",&n,&k);
    dp[1]=1;
    for(i=1; i<=k; i++)
        scanf("%d%d",&intr[i][0],&intr[i][1]);
    for(i=1; i<=n; i++)
    {
        if(i>1)
        {
            add[i]=(add[i-1]+add[i])%MOD;
            dp[i]=add[i];
        }
        for(j=1; j<=k; j++)
        {
            if(intr[j][0]+i<=n)
                add[intr[j][0]+i]=(add[intr[j][0]+i]+dp[i])%MOD;
            if(intr[j][1]+i+1<=n)
            {
                add[intr[j][1]+i+1]=add[intr[j][1]+i+1]-dp[i];
                if(add[intr[j][1]+i+1]<0)
                    add[intr[j][1]+i+1]+=MOD;
                else
                    add[intr[j][1]+i+1]%=MOD;
            }
        }
    }
    printf("%d",dp[n]);

    return 0;
}


Measured memory_bytes: 5360
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=1000000;
bool p[N+10];
vector<int> primes;

int main()
{
    for (int i=2;i<=N;i++) {
        if (!p[i]) primes.pb(i);
        for (int j=0;j<primes.size()&&primes[j]*i<=N;j++) {
            p[primes[j]*i]=1;
            if (i%primes[j]==0) break;
        }
    }
    int n;
    while (~scanf("%d",&n)) {
        int ans=upper_bound(primes.begin(),primes.end(),n)-primes.begin();
        printf("%d\n",ans);
    }
}


Measured memory_bytes: 4320
// ===================================
//   author: M_sea
//   website: http://m-sea-blog.com/
// ===================================
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#define re register
using namespace std;

inline int read() {
    int X=0,w=1; char c=getchar();
    while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
    while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
    return X*w;
}

const int N=1000+10;

char a[N];

int main() {
    scanf("%s",a+1); int l=strlen(a+1);
    int e=0,s=0,w=0,n=0;
    for (re int i=1;i<=l;++i) {
        if (a[i]=='E') e=1;
        if (a[i]=='S') s=1;
        if (a[i]=='W') w=1;
        if (a[i]=='N') n=1;
    }
    if ((e^w)||(s^n)) puts("No");
    else puts("Yes");
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

struct edge {
    int from, to;
    int cost;
}; 

int n, m;
long d[1000];
bool jf[1000], jb[1000];
edge e[2000];

int main() {
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        e[i].from = a - 1;
        e[i].to = b - 1;
        e[i].cost = c;
    }
    
    jf[0] = true;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (jf[e[j].from]) jf[e[j].to] = true;
        }
    }
    jb[n - 1] = true;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (jb[e[j].to]) jb[e[j].from] = true;
        }
    }
    
    for (int i = 1; i < n; i++) d[i] = -1e18;
    bool update = true;
    int cnt = 0;
    while (update) {
        if (++cnt == n + 1) {
            printf("inf\n");
            return 0;
        }
        update = false;
        for (int i = 0; i < m; i++) {
            if (jf[e[i].from] && jb[e[i].to] && d[e[i].from] + e[i].cost > d[e[i].to]) {
                d[e[i].to] = d[e[i].from] + e[i].cost;
                update = true;
            }
        }
    }

    printf("%ld\n", d[n - 1]);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define F first 
#define S second 
#define endl "\n"
#define Endl "\n"
#define emdl "\n"
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
bool sortBy(const pair<int,int> &a,const pair<int,int> &b){
	if(a.F==b.F)
		return a.S<b.S;
	return a.F>b.F;
}

// #define MAXN 1001
// int pf[MAXN]; 
// void sieve(){
// 	long long int i,j; 
//     pf[1] = 1; 
//     for (i=2; i<MAXN; i++) 
//     pf[i] = i;   
//     for (i=2; i*i<MAXN; i++){ 
//         if (pf[i] == i){
//             for (j=i*i; j<MAXN; j+=i) 
//                 if (pf[j]==j) 
//                     pf[j] = i; 
//         } 
//     } 
// }
// vector<int> factors(int x){ 
//     vector<int> ret; 
//     while (x != 1){ 
// 		int fact=pf[x];
//         ret.push_back(pf[x]); 
// 		while(fac!=1&&x%fact==0)
//         x/=fact; 
//     } 
//     return ret; 
// } 
// set<long long int>poww;
// void init(){
// 	long long int temp=1;
// 	for(int i=1;i<43;i++){
// 		poww.insert(temp);
// 		temp*=2;
// 	}
// }  


int main() {		
	ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	int qwe=1;
	//cin>>qwe;
	//init();
	// sieve();
	while(qwe--){
       string s,t;
       int cnt=0,ans=10000;
       cin>>s>>t;
       for(int i=0;i<int(s.size());i++){
           if(i+int(t.size())>int(s.size()))
           break;
           cnt=0;
           for(int j=0;j<int(t.size());j++){
               if(s[i+j]!=t[j])
               cnt++;
           }
           ans=min(ans,cnt);
       }
       cout<<ans;



	}

	return 0;
}


Measured memory_bytes: 3644
import Data.Int
import Control.Monad
import qualified Data.Vector.Unboxed as V
import qualified Data.Vector.Unboxed.Mutable as VM

solve :: Int -> Int -> V.Vector (Int,Int) -> V.Vector Int64
solve n m edges = V.create $ do
  assocs <- VM.new n
  forM_ [0..n-1] $ \i -> VM.write assocs i i
  numberOfElements <- VM.replicate n 1
  let getRoot i xs = do
        j <- VM.read assocs i
        if i == j
          then return (i, xs)
          else getRoot j (i:xs)
      unify i j = do
        (i',xs) <- getRoot i []
        (j',ys) <- getRoot j []
        let k = min i' j'
        forM_ (i':xs) (\l -> VM.write assocs l k)
        forM_ (j':ys) (\l -> VM.write assocs l k)
        if i' == j'
          then return 0
          else do
          n1 <- VM.read numberOfElements i'
          n2 <- VM.read numberOfElements j'
          VM.write numberOfElements k (n1 + n2)
          return (n1 * n2)
  result <- VM.new m
  VM.write result (m-1) $ fromIntegral n * (fromIntegral n - 1) `quot` 2
  forM_ [m-1,m-2..1] $ \i -> do
    let (a,b) = edges V.! i
    convenience <- unify a b
    prevInconveniences <- VM.read result i
    VM.write result (i-1) (prevInconveniences - convenience)
  return result

main = do
  [n,m] <- map read . words <$> getLine -- 2 <= n <= 10^5, 1 <= m <= 10^5
  edges <- V.replicateM m $ do
    [a,b] <- map read . words <$> getLine
    return (a-1, b-1)
  -- maxIncovenience < n * (n - 1) / 2 < 10^10 (2^32 < 10^10)
  let result = solve n m edges
  V.forM_ result print


Measured memory_bytes: 6140
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a,b; cin >> a >> b;
	if(a==b){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl; 
	}
}

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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    vector<int> e(4);
    for(int i=0;i<4;i++)cin >> e[i];
    sort(All(e));
    if(e[0]==e[1]&&e[2]==e[3])cout << "yes" << endl;
    else cout << "no" << endl;
}



Measured memory_bytes: 3164
#include <iostream>

using namespace std;

int state;

int hit(int times) {
	int ret = 0;
	for (int i = 0; i < times; ++i) {
		ret += state & 1;
		state >>= 1;
	}
	return ret;
}

int main() {
	int n; cin >> n;
	for (int k = 0; k < n; ++k) {
		int out = 0, point = 0;
		state = 0;
		while (out < 3) {
			string str; cin >> str;
			if (str == "HIT") point += hit(1), state |= 4;
			else if (str == "HOMERUN") point += hit(3) + 1;
			else if (str == "OUT") ++out;
		}
		cout << point << endl;
	}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main()
{
  ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
  string s,t;
  cin>>s;
  cin>>t;
  int i,flag;
  if(t.size()>s.size())
  {
      for(i=0;i<s.size();i++)
      {
          if(s[i]!=t[i])
          {
              flag=0;
              break;
          }
          else
          flag=1;
      }
      if(flag==0)
      cout<<"No"<<"\n";
      else
      cout<<"Yes"<<"\n";
  }
  else
  {
      cout<<"No"<<"\n";
  }
}

Measured memory_bytes: 3636
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()

	fmt.Fprintln(stdout, n/2-b2i(n%2 == 0))
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int inf,n,sz[101],f[200010],ans,hh,a[200010];
int dfs(int now){
	int i,j,x,nt;
	if(!now)return 0;
	if(f[now]!=inf)return f[now];
	for(i=0;i<16;i++)if(now&(1<<i))
	 for(j=0;j<16;j++)if(j!=i&&(now&(1<<j))){
	 	x=i^j;
	 	nt=now^(1<<i)^(1<<j)^(1<<x);
	 	if(now&(1<<x))f[now]=min(f[now],dfs(nt)+2);
	 	 else f[now]=min(f[now],dfs(nt)+1);
	 }
	 return f[now];
}
int main(){
	int i,x,y,w;
	scanf("%d",&n);
	for(i=1;i<n;i++){
		scanf("%d%d%d",&x,&y,&w);
		a[x]^=w;a[y]^=w;
	}
	for(i=0;i<n;i++)sz[a[i]]++;
	for(i=1;i<16;i++)ans+=sz[i]/2,hh+=(1<<i)*(sz[i]%2);
	memset(f,44,sizeof(f));
	inf=f[0];
	printf("%d",ans+dfs(hh));
}

Measured memory_bytes: 1408
#include <cstdio>
#include <algorithm>

using namespace std;

int main()
{
	int n, x, y, a, b;

	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &x);
		scanf("%d", &y);
		scanf("%d", &a);
		scanf("%d", &b);

		if (a >= 5 && b >= 2)
		{
			printf("%d\n", a * x * 4 / 5 + b * y * 4 / 5);
		}
		else
		{
			printf("%d\n", min(x * a + y * b, max(a, 5) * x * 4 / 5 + max(b, 2) * y * 4 / 5));
		}
	}

	return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a, b;
    cin >> a >> b;
    
    int ans = a - 2 * b;
    if(ans < 0)   ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

        public char nextChar() {
            return next().charAt(0);
        }

        public float nextFloat() {
            return Float.parseFloat(next());
        }

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

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
        int q = 1;
        for (int i = 0; i < q; i++) {
            solver.solve(i + 1, in, out);
        }
        out.close();
    }

    static class Task {

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            String s = in.next();
            if (n % 2 != 0) {
                out.println("No");
                return;
            }
            if (s.substring(0, n / 2).equals(s.substring(n / 2))) {
                out.println("Yes");
            } else {
                out.println("No");
            }
        }
    }
}

Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=3003,INF=1<<30;
ll dp[MAX][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,S;cin>>N>>S;
    vector<int> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    dp[0][0]=1;
    
    ll ans=0;
    
    for(int i=0;i<N;i++){
        dp[i+1][A[i]]+=i+1;
        dp[i+1][A[i]]%=mod;
        for(int j=1;j<=S-1;j++){
            dp[i+1][j]+=dp[i][j];
            dp[i+1][j]%=mod;
            
            if(j+A[i]<=S) dp[i+1][j+A[i]]+=dp[i][j];
            dp[i+1][j+A[i]]%=mod;
        }
        ans+=dp[i+1][S]*ll((N-i));
        ans%=mod;
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 70656
def main():
    X, N = map(int, input().split())
    if N == 0:
        print(X)
        exit()
    P = set(map(int, input().split()))
    min = 1000
    ans = None
    for v in range(-100, 201):
        if v in P:
            continue
        if abs(v - X) < min:
            min = abs(v - X)
            ans = v
    print(ans)


if __name__ == '__main__':
    main()


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

int main() {
  int n;
  ll d, a;
  cin >> n >> d >> a;
  vector<P> p(n);
  rep(i,n) {
    cin >> p[i].first >> p[i].second;
  }
  sort(p.begin(), p.end());
  d = d*2;
  ll tot = 0;
  queue<pair<ll,ll>> q;
  ll ans = 0;
  rep(i,n) {
    ll x = p[i].first;
    ll h = p[i].second;
    while (q.size() && q.front().first < x) {
      tot -= q.front().second;
      q.pop();
    }
    h -= tot;
    if (h > 0) {
      ll num = (h+a-1)/a;
      ans += num;
      ll damage = num*a;
      tot += damage;
      q.emplace(x+d, damage);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3456
#include<stdio.h>

int main(void)

{ 

 int a,b,c,x,y,z;

 

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





if(a > b){


x = a;


a = b;


b = x;


}


if(b > c){


y = b;


b = c;


c = y;


}


if(a > b){


z = a;


a = b;


b = z;


}





printf("%d %d %d\n",a,b,c);





return 0;


}

Measured memory_bytes: 596
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  auto n = readln.chomp.to!int;

  auto c = new int[][][](n);
  
  foreach (i; 0..n-1) {
    auto t = readln.chomp.split.to!(int[]);
    auto cost = t[2] % 2 ? 1 : 2;
    auto a = new int[](2);
    a[0] = t[1] - 1;
    a[1] = cost;
    c[t[0]-1] ~= a;
    auto b = new int[](2);
    b[0] = t[0] - 1;
    b[1] = cost;
    c[t[1]-1] ~= b;
  }

  auto res = new int[](n);
  auto f = new bool[](n);

  void solve(int index, int cost) {
    if (f[index]) {
      return;
    }
    f[index] = true;
    res[index] = cost;
    foreach (e; c[index]) {
      solve(e[0], cost + e[1]);
    }
  }

  solve(0, 0);

  writeln("0");
  foreach (i; 1..n) {
    writeln(res[i] % 2);
  }
}


Measured memory_bytes: 28028
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

const long MOD = 1000000007;

vector<long> fact, inv_fact;

long pw(long a, long b) {
    long res = 1;
    while (b > 0) {
        if (b & 1) {
            res *= a;
            res %= MOD;
        }
        a *= a;
        a %= MOD;
        b /= 2;
    }
    return res;
}

long inv(long x) {
    return pw(x, MOD - 2);
}

long get_c(int n, int k) {
    long s = fact[n] * inv_fact[k];
    s %= MOD;
    s *= inv_fact[n - k];
    s %= MOD;
    return s;
}

int main() {
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    fact.resize(n + 1);
    fact[0] = 1;
    for (int i = 1; i <= n; i++) {
        fact[i] = fact[i - 1] * i;
        fact[i] %= MOD;
    }    
    inv_fact.resize(n + 1);
    for (int i = 0; i <= n; i++) {
        inv_fact[i] = inv(fact[i]);
    }
    
    sort(a.begin(), a.end());
    long res = 0;
    for (int i = k - 1; i < n; i++) {
        res += a[i] * get_c(i, k - 1);
        res %= MOD;
    }
    for (int i = k - 1; i < n; i++) {
        res -= a[n - 1 - i] * get_c(i, k - 1);
        res %= MOD;
    }
    if (res < 0) res += MOD;
    cout << res << "\n";
    
    return 0;
}

Measured memory_bytes: 2176
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  ll n,k;
  cin >> n >> k;
  vpii a(n);
  rep(i,n){
    int p,q;
    cin >> p >> q;
    a[i] = make_pair(p,q);
  }
  sort(ALL(a));
  ll cnt = 0;
  rep(i,n){
    cnt+=a[i].second;
    if(cnt>=k){
      cout << a[i].first << endl;
      return 0;
    }
  }
  
    
}




Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x, y;
	x = a*b;
	y = c*d;
	if (x >= y) { cout << x << endl; }
	else { cout << y; }
	return 0;
}


Measured memory_bytes: 256
// F - Playing Tag on Tree
#include <bits/stdc++.h>

using namespace std;

void tree_dist(const vector<vector<int> > &g, int root, vector<int> &dist)
{
	dist.assign(g.size(), 0);
	queue<pair<int, int> > q;
	for (q.push(make_pair(root, -1)); !q.empty(); q.pop())
		for (int i = 0, u = q.front().first; i < g[u].size(); i++)
			if (g[u][i] != q.front().second) {
				dist[g[u][i]] = dist[u] + 1;
				q.push(make_pair(g[u][i], u));
			}
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n, u, v;
	cin >> n >> u >> v;
	u--; v--;
	vector<vector<int> > g(n);
	for (int i = 0; i < n - 1; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}

	vector<int> d1, d2;
	tree_dist(g, u, d1);
	tree_dist(g, v, d2);

	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (d2[i] - d1[i] > 0)
			ans = max(ans, d2[i] - 1);
	}
	cout << ans << endl;

	return 0;
}


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



int main()
{
	string s; cin >> s;
	reverse(begin(s), end(s));
	int ok = 1;
	for (int i = 0; i < s.size(); ++i)
	{
		if (s[i] == 'r')
		{
			if (s.substr(i, 7) == "remaerd")
				i += 6;
			else if (s.substr(i, 6) == "resare")
				i += 5;
		}
		else if (s[i] == 'e' && s.substr(i, 5) == "esare")
			i += 4;
		else if (s[i] == 'm' && s.substr(i, 5) == "maerd")
			i += 4;
		else  
			ok = 0;
	}
	cout << (ok ? "YES" : "NO") << endl;
}



Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
string ans="~";
int main(){
	string s;
	cin>>s;
	string t;
	cin>>t;
	if(s.size()<t.size()){
		cout<<"UNRESTORABLE";
		return 0;
	}
	for(int i=0;i<=s.size()-t.size();i++){
		bool flag=1;
		for(int j=0;j<t.size();j++){
			if(s[i+j]!=t[j]&&s[i+j]!='?'){
				flag=0;
				break;
			}
		}
		if(flag){ 
			string s2=s;
			for(int j=0;j<t.size();j++)s2[i+j]=t[j];
			for(int j=0;j<s.size();j++)if(s2[j]=='?')s2[j]='a';
			ans=min(ans,s2);
		}
	}
	if(ans=="~"){
		cout<<"UNRESTORABLE";
		return 0; 
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define N 200000
int a[N], n, k, q;

int main() {
    //freopen("sample.in", "r", stdin);
    cin >> n >> k >> q;
    for(int i = 1; i <= q; i++) {
        int tmp; scanf("%d", &tmp);
        a[tmp]++;
    }
    for(int i = 1; i <= n; i++)
        if (k + a[i] <= q) cout << "No" << endl;
        else cout << "Yes" << endl;
}

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

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

typedef long long ll;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//これを使うときにはCOMinit();を忘れずに

int main(void){
  COMinit();
  int N; cin >> N;
  vector<int> cnt(N+1, 0);
  int dup = -1;
  ll A[N+1]; rep(i, N+1) {cin >> A[i]; cnt[A[i]]++; if(cnt[A[i]] == 2) dup = A[i];}
  int l = -1, r = -1;
  rep(i, N+1) if(A[i] == dup){if(l == -1) l = i; else r = i;}

  int lr = l + (N+1 - r - 1); //重複数字の左と右にある数字の個数

  //cout << l << " " << r << endl;
  for(int i = 1; i <= N+1; i++){
    //長さiの部分列の個数
    //重複するのはl + (N-r) 個からi-1個の数字を選んだ時
    ll res = COM(N+1, i) - COM(lr, i-1);
    if(res < 0) res += MOD;
    cout << res << endl;
  }

}

Measured memory_bytes: 16332
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<iostream>
#include<fstream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<functional>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
// #define int ll
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
const ll mod = 998244353;
const ll MAX = 1100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[4] ={1,0,-1,0} , dy[4] ={0,1,0,-1};


signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n,a[100010];
    cin>>n;
    rep(i,n){
        cin>>a[i];
    }
    ll ans=LLINF;
    rep2(x,-200,201){
        ll sum=0;
        rep(i,n){
            sum+=(x-a[i])*(x-a[i]);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

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

#include <map>
#include <set>

using namespace std;

#ifdef LOCAL
    #define debug(v) cerr<<v<<"\n"
#else
    #define debug(...) 42
#endif
#define out(v) cout<<v<<"\n"
#define _overload3(_1,_2,_3,name,...) name
#define _all1(a) (a).begin(),(a).end()
#define _all2(a,n) (a),(a)+n
#define all(...) _overload3(__VA_ARGS__,42,_all2,_all1,)(__VA_ARGS__)
#define _rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _fromto2(i,n) for(int i=0;i<=(n);++i)
#define _fromto3(i,a,b) for(int i=(a);i<=(b);++i)
#define fromto(...) _overload3(__VA_ARGS__,_fromto3,_fromto2,)(__VA_ARGS__)

#define rrep(i,n) for(int i=(n);i>=0;--i)
#define iter(it,v) for(auto it=v.begin();it!=v.end();++it)
const int MOD = 1e9+7;
const int INF = 1e9;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class T>ostream& operator<<(ostream& os, vector<T>& vec){os<<"{";for(int i=0;i<vec.size();++i)os<<(i?", ":"")<<vec[i];os<<"}";return os;}
template<class T1,class T2>ostream& operator<<(ostream& out,const pair<T1,T2>& rhs){out<<"("<<rhs.first<<", "<<rhs.second<<")";return out;}
#include<type_traits>
template<typename T,size_t SIZE,enable_if_t<!is_same<remove_cv_t<T>,char>::value,nullptr_t> = nullptr>ostream& operator<<(ostream& os,T(&arr)[SIZE]){os<<"{";for(size_t i=0;i<SIZE;++i)os<<(i?", ":"")<<arr[i];os<<"}";return os;}

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

struct SegmentTree {
  vector<ll> tree;
  int N;
  SegmentTree(int size) {
    N = 1;
    while (N < size) {
      N *= 2;
    }
    tree.resize(2 * N - 1, INF);
  }
  void update(int i, ll x) {
    i += N - 1;
    tree[i] = x;
    while (i > 0) {
      i = (i-1) / 2;
      tree[i] = tree[2 * i + 1] | tree[2 * i + 2];
    }
  }
  int query(int l, int r, int k = 0, int left = 0, int right = -1) {
    // [l, r)
    if (right == -1)
      right = N;
    if (l <= left && right <= r)
      return tree[k];
    if (right <= l || r <= left)
      return 0;
    return query(l, r, 2 * k + 1, left, (left + right) / 2) | query(l, r, 2 * k + 2, (left + right) / 2, right);
  }
};

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int N; cin >> N;
  string S; cin >> S;

  SegmentTree T(N);
  rep(i, N) {
    T.update(i, 1<<(S[i]-'0'));
  }

  int ans = 0;
  set<int> st;
  rep(i, N-2) {
    set<int> st2;
    int n = S[i]-'0';
    if (st.find(n) != st.end())
      continue;
    st.insert(n);
    rep(j, i+1, N-1) {
      int m = S[j]-'0';
      if (st2.find(m) != st2.end())
        continue;
      st2.insert(m);
      ans += __builtin_popcount(T.query(j+1, N));
    }
  }
  out(ans);

  return 0;
}


Measured memory_bytes: 896
N, K = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]
B = []
for i in range(N):
    B += [A[i]]
    for j in range(i+1,N):
        B += [B[-1] + A[j]]

ans = 0
for i in range(40, -1, -1):
    B_new = []
    for b in B:
        if b & 2 ** i:
            B_new += [b]
    if len(B_new) >= K:
        ans += 2 ** i
        B = [_ - 2 ** i for _ in B_new]
    else:
        B = [_ % 2 ** i for _ in B]
print(ans)

Measured memory_bytes: 34664
import numpy as np
N, L = [int(x) for x in input().split(" ")]
quality = [(L + i - 1) + 1 for i in range(N)]

abs_quality = [abs(q) for q in quality]
ind = np.argmin(abs_quality)

taste = np.sum([q for i, q in enumerate(quality) if i != ind])
print(taste)

Measured memory_bytes: 12428
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
N = l.shift() * 1
K = l.shift() * 1 
l = inp.shift().split(' ').map(x => x - 0)
n = []
p = []
for (i=0; i<N; i++) {
    if (l[i] < 0) {
        n.unshift(Math.abs(l[i]))
    } else {
        if (l[i] === 0) {
            K--
            N--
        } else {
            p.push(l[i])
        }
    }
}
if (K === 0) {
    console.log(0)
} else {
    min = Infinity
    if (n[K-1]) {
        if (n[K-1] < min) {
            min = n[K-1]
        }
    }
    if (p[K-1]) {
        if (p[K-1] < min) {
            min = p[K-1]
        }
    }
    c = Math.min(p.length, n.length)
    for (i=0;i<c;i++) {
        if (n[i] && p[K - i - 2]) {
            m = n[i] * 2 + p[K - i - 2]
            if (m < min) {
                min = m
            }
        }
        if (p[i] && n[K - i - 2]) {
            m = p[i] * 2 + n[K - i - 2]
            if (m < min) {
                min = m
            }
        }
    }
    console.log(min)    
}

Measured memory_bytes: 29704
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define min(a,b) a<b?a:b
int main()
{
    int n,k,i;
    long x[100001],z=11454141919,preans;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++){
        scanf("%ld",&x[i]);
    }
    for(i=0;i<=n-k;i++){
        preans=min(abs(x[i])+abs(-x[i]+x[i+k-1]),abs(x[i+k-1])+abs(x[i+k-1]-x[i]));
    if(z>preans){
        z=preans;
    }    
    }
    
    printf("%ld",z);
    
    return 0;
}


Measured memory_bytes: 896