akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define _GLIBCXX_DEBUG
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define debug(x) cout << #x << " = " << x << endl
#define print(x) cout << x << endl;
const ll MOD = 1000000007;

int main()
{
    int K;
    string S;
    cin >> K >> S;

    if (S.size() <= K)
    {
        cout << S << endl;
    }
    else
    {
        cout << S.substr(0, K) + "..." << endl;
    }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n, m, a, b; cin>>n>>m;
	vector<pair<ll, ll>> vec;
	for(int i=0; i<n; i++){
		cin>>a>>b;
		vec.push_back({a, b});
	}
	sort(vec.begin(), vec.end());
	ll ans=0;
	for(auto u: vec){
		if(m>=u.second) ans+=u.first*u.second;
		else ans+=m*u.first;
		m-=u.second;
		if(m<=0) break; 
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2420
import numpy as p;
n,m=map(int,input().split())
a=[list(map(int,input().split()))for _ in[0]*(int(n)+int(m))]
for x,y in a[:n]:
    print(1+p.argmin(list(abs(x-X)+abs(y-Y)for X,Y in a[n:])))

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

#define MAXN 112345

using namespace std;

int n, vet[MAXN], cnt;

int main(){
    scanf("%d", &n);
    for (int i=1;i<=n;i++)
        scanf("%d", &vet[i]);
    for (int i=1;i<n;i++){
        if (vet[i] == i){
            swap(vet[i], vet[i+1]);
            cnt++;
        }
    }
    if (vet[n] == n){
        cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 640
N = gets.to_i
P = N.times.map { gets.to_i }

pos = Hash.new

P.each_with_index do |v, i|
  pos[v] = i
end

cnt = 0
max = 0

list = (1..N).map { |n| pos[n] }

0.upto(N - 1) do |i|
  cnt += 1

  if i > 0 && list[i - 1] > list[i]
    cnt = 1
  end

  max = cnt if max < cnt
end

puts N - max


Measured memory_bytes: 20272
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define rep(i, n) FOR(i, 0, n - 1)
using namespace std;
typedef long long ll;
template <class T> inline bool dpmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> inline bool dpmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

void solve(string S) {
    ll ans = 0;
    ll n = S.size(), nB = 0;

    rep(i, n) {
        if (S[i] == 'B') {
            nB++;
        } else {
            ans += nB;
        }
    }

    cout << ans << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips:
// You use the default template now. You can remove this line by using your
// custom template)
int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}


Measured memory_bytes: 3900
def gcd_all(A):
    from math import gcd
    g = 0
    for a in A: g = gcd(g, a)
    return g

def is_pairwise():
    MAX_A = 10**6
    C = [0] * (MAX_A + 1)
    max_a = 0
    for a in A:
        C[a] += 1
        max_a = max(max_a, a)
    if sum(C[2::2]) > 1: return False
    for i in range(3, max_a + 1, 2):
        if sum(C[i::i]) > 1: return False
    return True

def solve():
    if is_pairwise(): return 0
    if gcd_all(A) == 1: return 1
    return 2

n = int(input())
A = [*map(int, input().split())]
print(['pairwise','setwise','not'][solve()], 'coprime')


Measured memory_bytes: 127468
import queue
H, W = list(map(int, input().split()))
S = list()
for i in range(H) :
    t = input()
    S.append(t)
dist = [[3000 for j in range(W)] for i in range(H)]
dx = [-1, 0, 1, 0]
dy = [0, -1, 0, 1]
q = queue.Queue()
dist[0][0] = 0
q.put([0, 0])
while q.empty() == False:
    x, y = q.get()
    for i in range(4) :
        nx = x + dx[i]
        ny = y + dy[i]
        if nx >= 0 and ny >= 0 and nx < W and ny < H :
            if S[ny][nx] == '.' and dist[ny][nx] > dist[y][x] + 1 :
                dist[ny][nx] = dist[y][x] + 1
                q.put([nx, ny])
cnt = 0
for i in range(H) :
    for j in range(W) :
        if S[i][j] == '.' :
            cnt += 1
print(-1 if dist[H-1][W-1] == 3000 else cnt - dist[H-1][W-1] - 1)



Measured memory_bytes: 3952
s=input()
l=len(s)

res=0
cnt=0

for i in range(l):
	t=s[i]
	if t=="A" or t=="T" or t=="C" or t=="G":
		cnt+=1
	else:
		res=max(res,cnt)
		cnt=0

res=max(res,cnt)
print(res)	

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;

const int kMaxN = 105;
int n, a[kMaxN];

int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", a + i);
  }
  long long ans = 1LL << 60;
  for (int val = -100; val <= 100; ++val) {
    long long tmp = 0;
    for (int j = 1; j <= n; ++j) {
      tmp = tmp + 1LL * (val - a[j]) * (val - a[j]);
    }
    ans = min(ans, tmp);
  }
  printf("%lld\n", ans);
  return 0;
}

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

int W,H,N;
int res[110][110] = {};

int main(){
  cin >> W >> H >> N;
  int x,y,a;
  for(int i=0;i<N;i++){
    cin >> x >> y >> a;
    if(a==1) for(int i=1;i<=x;i++) for(int j=1;j<=H;j++) res[i][j] = 1;
    if(a==2) for(int i=x+1;i<=W;i++) for(int j=1;j<=H;j++) res[i][j] = 1;
    if(a==3) for(int i=1;i<=W;i++) for(int j=1;j<=y;j++) res[i][j] = 1;
    if(a==4) for(int i=1;i<=W;i++) for(int j=y+1;j<=H;j++) res[i][j] = 1;
  }
  int ans = 0;
  for(int i=1;i<=W;i++) for(int j=1;j<=H;j++) ans += (1-res[i][j]);
  cout << ans << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
X = {}
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if not a in X:
        X[a] = [b]
    else:
        X[a].append(b)

    if not b in X:
        X[b] = [a]
    else:
        X[b].append(a)

ans = 0
for k, vs in X.items():
    temp = 0
    for v in vs:
        temp = max(temp, H[v])
    if H[k] > temp:
        ans += 1

print(ans + N - len(X))

Measured memory_bytes: 31848
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, k, ans = 0;
    cin >> n >> k;
    for(ll i = 1; i <= n; i++)
    {
        ll x;
        cin >> x;
        if(x >= k)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, K = map(int,input().split())
X = list(map(int,input().split()))

left = []
right = []
for x in X:
    if x<0:
        left.append(abs(x))
    else:
        right.append(x)
left.reverse()

# from math import inf
ans = 10**18

#i=>right
for i in range(K+1):
    if len(right)!=0 and right[0]==0 and i==0:
        continue;
    temp = 0
    if len(left)==0:
        temp = right[K-1]
    elif len(right)==0:
        temp = left[K-1]
    elif len(left)>=(K-i):
        if len(right)>=i:
            temp0 = left[K-i-1] if not i==K else 0
            temp1 = right[i-1] if not i==0 else 0
            temp  = temp0+temp1 + min(temp0, temp1)
        else:
            temp0 = right[-1]
            temp1 = left[K-len(right)-1]
            temp  = temp0+temp1 + min(temp0, temp1)
    else:
        temp0 = left[-1]
        temp1 = right[K-len(left)-1]
        temp  = temp0+temp1 + min(temp0, temp1)
    ans = min(ans, temp)

print(ans)


Measured memory_bytes: 14252
n = int(input())
s = [1 if c == '#' else 0 for c in input()]
l = [0] * (n + 1)
l2 = [0] * (n + 1)
for i in range(n):
    l[i + 1] = s[i] + l[i]
s = s[::-1]
for i in range(n):
    l2[i + 1] = 1-s[i] + l2[i]
l2 = l2[::-1]
ans = float('inf')
for i in range(n + 1):
    ans = min(ans, l[i] + l2[i])
print(ans)

Measured memory_bytes: 21916
#include <iostream>
#include <vector>
using namespace std;
#define ll long long
#define maxn 100005

ll mix (ll a, ll b) {
	return a < b ? a : b;
}

int main()
{
	ll x, k, d, Mix;
	cin >> x >> k >> d;
	x = abs(x);
	Mix = x / d;
	
	if (k <= Mix) {
		cout << x - k * d << endl;
	} else {
		k -= Mix;	
		x -= Mix * d;
		if (k % 2) {
			cout << abs(x - d) << endl;
		} else {
			cout << x << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0){
		printf("Possible\n");
	}
	else printf("Impossible\n");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<ll>>;
using P = pair<int,int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define MOD 1000000007
#define INF 1000000
#define PI 3.14159265358979323846264338327950L
#define MAX_N 200010
#define lb lower_bound //[2,4)=lb(4)-lb(2)

int main()
{
  ll k;cin>>k;
  
  ll b[100010];
  
  queue<ll> q;
  ll count=0;
  for (ll i=1;i<=9;i++){
    q.push(i);
    count++;
    b[count]=i;
  }
  
  while (!q.empty())
  {
    ll v = q.front();
    q.pop();
    for (ll i=-1;i<=1;i++){
      if (v%10+i>=0 && v%10+i<=9)
      {
        q.push(v*10+v%10+i);
        count++;
        b[count]=v*10+v%10+i;
      }
    }
    if (count>k) break;
  }
  cout<<b[k]<<endl;
}

Measured memory_bytes: 4848
import sys
readline = sys.stdin.readline

N, A, B = map(int, readline().split())

ans = None
if (B - A) % 2 == 0:
    ans = (B-A)//2
else:
    ans = A + (B - A - 1)//2
    ans = min(ans, N-B+1 + (-A+B-1)//2)    
print(ans)

Measured memory_bytes: 38384
#include<iostream>
#include<cstdio>
#include<cstring>
//#include<>

//A

using namespace std;


int main()
{
    char mm[20];

    for (int i = 0; i < 12; i++) {
        scanf("%c", &mm[i]);

    }
    for (int i = 0; i < 4; i++) {
        cout << mm[i];
    }
    printf(" ");
    for (int i = 4; i < 12; i++)
        printf("%c", mm[i]);

    cout << endl;

    return 0;

}

Measured memory_bytes: 256
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public string via { get; set; }
    public string via2 { get; set; }
}

public class hello
{
    public static void Main()
    {
        var d = new Dictionary<char, int>()
        { { 'R', 1 }, { 'r', -1 }, { 'G', 2 }, { 'g', -2 }, { 'B', 3 }, { 'b', -3 }, { 'W', 4 }, { 'w', -4 } };
        var n = int.Parse(Console.ReadLine().Trim());
        var z = 0;
        while (z++ < n)
        {
            var ps = new int[9, 4, 4];
            string[] line = Console.ReadLine().Trim().Split(' ');
            for (int i = 0; i < 9; i++)
            {
                var t = line[i];
                for (int j = 0; j < 4; j++) ps[i, 0, j] = d[t[j]];
            }
            getPs(ps);
            getAns(ps);
        }
    }
    static void getAns(int[,,] ps)
    {
        var ans = 0;
        var q = new Queue<P>();
        for (int i = 0; i < 9; i++)
            for (int j = 0; j < 4; j++)
                q.Enqueue(new P { via = i.ToString(), via2 = j.ToString() });
        while (q.Count() > 0)
        {
            var w = q.Dequeue();
            if (w.via.Length == 9) { ans++; continue; }
            for (int i = 0; i < 9; i++)
                for (int j = 0; j < 4; j++)
                    if (!w.via.Contains(i.ToString()) && check(ps, w.via, w.via2, i, j))
                        q.Enqueue(new P { via = w.via + i.ToString(), via2 = w.via2 + j.ToString() });
        }
        Console.WriteLine(ans);
    }
    static bool check(int[,,] ps, string via, string via2, int i, int j)
    {
        var vL = via.Length;
        if (vL == 1 | vL == 2)
        {
            var t = ps[via[vL - 1] - '0', via2[vL - 1] - '0', 1];
            return ps[i, j, 3] + t == 0;
        }
        else if (vL == 3)
        {
            var t = ps[via[0] - '0', via2[0] - '0', 2];
            return ps[i, j, 0] + t == 0;
        }
        else if (vL == 6)
        {
            var t = ps[via[3] - '0', via2[3] - '0', 2];
            return ps[i, j, 0] + t == 0;
        }
        else
        {
            var t = ps[via[vL - 3] - '0', via2[vL - 3] - '0', 2];
            var t2 = ps[via[vL - 1] - '0', via2[vL - 1] - '0', 1];
            return (ps[i, j, 0] + t == 0) && (ps[i, j, 3] + t2 == 0);
        }
    }
    static void getPs(int[,,] ps)
    {
        for (int i = 0; i < 9; i++)
        {
            ps[i, 1, 0] = ps[i, 0, 3];
            ps[i, 1, 1] = ps[i, 0, 0];
            ps[i, 1, 2] = ps[i, 0, 1];
            ps[i, 1, 3] = ps[i, 0, 2];

            ps[i, 2, 0] = ps[i, 0, 2];
            ps[i, 2, 1] = ps[i, 0, 3];
            ps[i, 2, 2] = ps[i, 0, 0];
            ps[i, 2, 3] = ps[i, 0, 1];

            ps[i, 3, 0] = ps[i, 0, 1];
            ps[i, 3, 1] = ps[i, 0, 2];
            ps[i, 3, 2] = ps[i, 0, 3];
            ps[i, 3, 3] = ps[i, 0, 0];
        }
    }
}


Measured memory_bytes: 35020
n = int(input())
a = [int(x) for x in input().split()]

maxval = 10 ** 18
ans = 1


for i in range(n):
    ans *= a[i]
    if ans > maxval:
        ans = -1
        break
    
if 0 in a:
    ans = 0
    
print(ans)

Measured memory_bytes: 21584
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace Tasks
{
    public class D
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var S = Console.ReadLine();
            var dict = new Dictionary<char, int>();
            var l = -1;
            var r = -1;
            for (var i = 0; i < S.Length - 1; i++)
            {
                if (S[i] == S[i + 1])
                {
                    l = i + 1;
                    r = i + 2;
                    break;
                }

                if (i + 2 < S.Length && S[i] == S[i + 2])
                {
                    l = i + 1;
                    r = i + 3;
                    break;
                }
            }

            Console.WriteLine($"{l} {r}");
        }
    }
}


Measured memory_bytes: 28004
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    var N = parseInt(input[0], 10);
    var ary_xy = [];
    var sumWay = 0;
    var xDiff, yDiff, ans;
    for (var i = 1; i <= N; i++){
    	ary_xy.push(input[i].map(e => parseInt(e, 10)));
    }
    for (var i = 0; i < N; i++){
    	for (var j = i + 1; j < N; j++){
    		xDiff = ary_xy[j][0] - ary_xy[i][0];
    		yDiff = ary_xy[j][1] - ary_xy[i][1];
    		sumWay += Math.sqrt(Math.pow(xDiff, 2) + Math.pow(yDiff, 2));	
    	}
    }
    ans = sumWay * 2 / N;
	console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9668
#include<cstdio>
char s[100001];
int psum[100001];
int main(){
    int n,q;
    scanf("%d%d%s",&n,&q,s);
    psum[0]=0;
    for(int i=1;i<n;i++){
        if(s[i-1]=='A'&&s[i]=='C')psum[i]=psum[i-1]+1;
        else psum[i]=psum[i-1];
    }
    for(int i=0;i<q;i++){
        int l,r;
        scanf("%d%d",&l,&r);
        if(l==1)printf("%d\n",psum[r-1]);
        else printf("%d\n",psum[r-1]-psum[l-1]);
    }
    return 0;
}

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

class dice {
public:
    int getTopFace(void);
    int getBottomFace(void);
    void rotate(char dir);
    void setFaceNumber(int *number);
    bool compareDice(dice d2);
private:
    int face[6];
    int getFaceIndex(int number);
    bool compareDiceFace(dice d2);
};

int dice::getTopFace(void) {
    return face[0];
}

int dice::getBottomFace(void) {
    return face[5];
}

int dice::getFaceIndex(int number) {
    int i;
    for(i=0; i<6; ++i) {
        if (face[i]==number) {
            return i;
        }
    }
    return -1;
}

void dice::rotate(char dir) {
    int temp;
    switch(dir) {
    case 'N' :
        temp=face[0];
        face[0]=face[1];
        face[1]=face[5];
        face[5]=face[4];
        face[4]=temp;
        break;
    case 'S' :
        temp=face[0];
        face[0]=face[4];
        face[4]=face[5];
        face[5]=face[1];
        face[1]=temp;
        break;
    case 'W' :
        temp=face[0];
        face[0]=face[2];
        face[2]=face[5];
        face[5]=face[3];
        face[3]=temp;
        break;
    case 'E' :
        temp=face[0];
        face[0]=face[3];
        face[3]=face[5];
        face[5]=face[2];
        face[2]=temp;
        break;
    }
}

void dice::setFaceNumber(int *number) {
    for(int i=0; i<6; ++i) {
        face[i]=*(number+i);
    }
}

bool dice::compareDiceFace(dice d2) {
    for(int i=0;i<6;++i) {
        if(d2.face[i]!=face[i]) {
            return false;
        }
    }
    return true;
}

bool dice::compareDice(dice d2) {
    for(int j=0;j<3;++j) {
        if(compareDiceFace(d2)) return true;
        for(int i=0;i<3;++i) {
            d2.rotate('E');
            if(compareDiceFace(d2)) return true;
        }
        d2.rotate('E');
        d2.rotate('N');
        d2.rotate('N');
        if(compareDiceFace(d2)) return true;
        for(int i=0;i<3;++i) {
            d2.rotate('E');
            if(compareDiceFace(d2)) return true;
        }
        d2.rotate('N');
    }
    return false;
}

int main() {
    int num[6];
    dice d[2];
    string str[2];

    for(int i=0;i<2;++i) {
        for(int j=0;j<6;++j) {
            cin >> num[j];
        }
        d[i].setFaceNumber(num);
    }
    cout << (d[0].compareDice(d[1])?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3092
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

a = LIST()
print('bust' if sum(a) >= 22 else 'win')

Measured memory_bytes: 60396
n,m = map(int,input().split())
ansl = 0
ansr = n+1
for i in range(m):
    l,r = map(int,input().split())
    ansl = max(ansl,l)
    ansr = min(ansr,r)
print(0 if ansl > ansr else ansr-ansl+1)

Measured memory_bytes: 3060
package main

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

var H, W int

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 1024)
	fmt.Scan(&H, &W)

	q := make([][]int, 0)
	m := make([][]bool, H)

	for i := 0; i < H; i++ {
		line, _, _ := reader.ReadLine()
		m[i] = make([]bool, W) // Falseで初期化されている

		for j, v := range line {
			if string(v) == "#" {
				q = append(q, []int{i, j})
				m[i][j] = true
			}
		}
	}
	fmt.Println(bfs(q, m))
}

func bfs(q [][]int, m [][]bool) int {
	var ans int

	for len(q) != 0 {
		ans++
		len := len(q)

		for i := 0; i < len; i++ {
			var y, x int = q[0][0], q[0][1]
			q = append(q[1:])

			if 0 <= y+1 && y+1 < H && m[y+1][x] == false {
				m[y+1][x] = true
				q = append(q, []int{y + 1, x})
			}
			if 0 <= y-1 && y-1 < H && m[y-1][x] == false {
				m[y-1][x] = true
				q = append(q, []int{y - 1, x})
			}
			if 0 <= x+1 && x+1 < W && m[y][x+1] == false {
				m[y][x+1] = true
				q = append(q, []int{y, x + 1})
			}
			if 0 <= x-1 && x-1 < W && m[y][x-1] == false {
				m[y][x-1] = true
				q = append(q, []int{y, x - 1})
			}
		}
	}
	return ans - 1
}


Measured memory_bytes: 116864
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 500
typedef pair<int,int> P;
typedef pair<int,P> Q;
 
int main(){
    int N,H,a,b;
    string str;
 
    while(cin >> N >> H, (N | H)){
	set<Q> st;
	for(int i = 0 ; i < H ; i++){
	    cin >> str >> a >> b; a--, b--;
	    if(str == "xy"){
		for(int j = 0 ; j < N ; j++){
		    st.insert(Q(a,P(b,j)));
		}
	    }else if(str == "yz"){
		for(int j = 0 ; j < N ; j++){
		    st.insert(Q(j,P(a,b)));
		}
	    }else{
		for(int j = 0 ; j < N ; j++){
		    st.insert(Q(a,P(j,b)));
		}
	    }
	}
	cout << N*N*N-st.size() << endl;
    }
    return 0;
}

Measured memory_bytes: 6284
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int x = 0;
    int N; cin >> N;
    int ans = 0;
    string s; cin >> s;

    for(auto c:s){
        if(c == 'I'){
            ++x;
            chmax(ans, x);
        }
        else {
            --x;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define each(e,c) for(auto&e:c)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define lb lower_bound
#define ub upper_bound
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<(DUMP(),__VA_ARGS__).str()<<" ["<<__LINE__<<"]"<<endl)
struct DUMP:ostringstream{template<class T>DUMP &operator,(const T&t){if(this->tellp())*this<<", ";*this<<t;return *this;}};
#else
#define dump(...)
#endif
template<class T> ostream& operator<<(ostream& os, vector<T> const& v){
    rep(i,v.size()) os << v[i] << (i+1==v.size()?"":" ");
    return os;
}

typedef pair<string,string> range;

range parse(string s){
    string l = s.substr(0,5), r = s.substr(6,5);
    return mp(l,r);
}

int main(){
    int N;
    while(cin >> N){
        vector<range> rs(N);
        string s;
        rep(i,N){
            cin >> s;
            rs[i] = parse(s);
        }
        int n; cin >> n;
        vector<range> tea;
        rep(i,n){
            int k; cin >> k;
            rep(j,k){
                cin >> s;
                tea.pb(parse(s));
            }
        }
        int m;
        cin >> m;
        vector<range> stu;
        rep(i,m){
            int k; cin >> k;
            rep(j,k){
                cin >> s;
                stu.pb(parse(s));
            }
        }

        int ans = 0;
        rep(i,N){
            int a = 0, b = 0;
            string L = rs[i].first;
            string R = rs[i].second;
            for(auto & p : tea) if(p.first <= L && R <= p.second) a++;
            for(auto & p : stu) if(p.first <= L && R <= p.second) b++;
            ans += min(a,b);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3392
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    int d;
    for(int i = 0; i < 10; i++){
        d = a * c - b;
        cout << d <<'\n';
        c = d;
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

	int diceo[6];
	int dicet[6];
	int i, j, k, a;
	int tatea[7] = { 0, 1, 5, 4, 0, 1, 5 };
	int tateb[7] = { 0, 4, 5, 1, 0, 4, 5 };
	int yokoa[7] = { 1, 2, 4, 3, 1, 2, 4 };
	int yokob[7] = { 1, 3, 4, 2, 1, 3, 4 };
	int hokaa[7] = { 0, 2, 5, 3, 0, 2, 5 };
	int hokab[7] = { 0, 3, 5, 2, 0, 3, 5 };
	int ue[6] = { 2, 3, 0, 5, 4, 1 };
	int ty[7];
	int idice[4];
	int co = 0;

	for (i = 0; i < 6; i++) {
		scanf("%d", &diceo[i]);
	}

	for (i = 0; i < 6; i++) {
		scanf("%d", &dicet[i]);
	}

	for (i = 0; i < 6; i++) {
		for (j = 0; j < 7; j++) {
			switch (i) {
			case 0:
				ty[j] = tatea[j];
				break;
			case 1:
				ty[j] = tateb[j];
				break;
			case 2:
				ty[j] = yokoa[j];
				break;
			case 3:
				ty[j] = yokob[j];
				break;
			case 4:
				ty[j] = hokaa[j];
				break;
			case 5:
				ty[j] = hokab[j];
				break;
			}
		}
		for (j = 0; j < 4; j++) {
			for (k = 0; k < 4; k++) {
				idice[k] = dicet[ty[k + j]];
			}
			for (k = 0; k < 4; k++) {
				if (idice[k] != diceo[yokoa[k]]) break;
				if ((idice[3] == diceo[yokoa[3]]) && (k = 3)) co++;
			}
			if (co == 1) break;
		}
		if (co == 1) break;
	}
	if (dicet[ue[i]] == diceo[0]) co++;
	if (co == 2) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
    int a[3][3];
    rep(i, 3)rep(j, 3) cin >> a[i][j];
    int n;
    cin >> n;
    vector<int> b(n);
    rep(i, n) cin >> b[i];
    rep(i, 3)rep(j, 3) {
        rep(k, n) {
            if (a[i][j]==b[k]) {
                a[i][j] = -1;
            }
        }
    }
    
    rep(i, 3) {
        if (a[i][1]==-1 && a[i][2]==-1 && a[i][0]==-1) {
            puts("Yes");
            return 0;
        }
        if (a[1][i]==-1 && a[2][i]==-1 && a[0][i]==-1) {
            puts("Yes");
            return 0;
        }
    }
    if (a[1][1]==-1 && a[2][2]==-1 && a[0][0]==-1) {
        puts("Yes");
        return 0;
    }
    if (a[0][2]==-1 && a[1][1]==-1 && a[2][0]==-1) {
        puts("Yes");
        return 0;
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
s = str(input())
x = int(s[0:2])
y = int(s[2:])
a = ((1<=x)and(x<=12))
b = ((1<=y)and(y<=12))
if a and b:
  print("AMBIGUOUS")
elif a and (not b):
  print("MMYY")
elif (not a) and b:
  print("YYMM")
else:
  print("NA")
  

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int l,r,d;
  cin>>l>>r>>d;
  int ans=0;
  for(int i=l;l<=i && i<=r;++i){
    if(i%d==0) ans++;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3620
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
    if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
    }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



//————————BFS迷路の最短経路————————————————

// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};



int main() {
    int r,c;
    cin >> r >> c;

    // 盤面入力受取 
    vector<string> p(r);
    rep(i,r) {
      cin >> p[i];
    }

    // BFS のためのデータ構造
    vector<vector<int>> dist(r,vector<int>(c,-1)); // 全マスを「未訪問」に初期化
    queue<pair<int,int>> que;

    // 初期条件  黒を全て初期ノードとする)
    rep(i,r){
      rep(j,c){
        if(p[i][j]=='#') {
          dist[i][j] = 0;
          pair<int,int> q=mp(i,j);
          que.push(q);
        }
      }  
    }

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        pair<int,int> v = que.front(); // キューから先頭頂点を取り出す
        que.pop();
      
        //vの上下左右をすべて調べる
        rep(i,4) {
          int nh = v.fi + dx[i];
          int nw = v.se + dy[i];

          // 場外アウトしたり、移動先が壁の場合はスルー
          if (nh < 0 || nh >= r || nw < 0 || nw >= c) continue;
          if (p[nh][nw] == '#') continue;
          
          if (dist[nh][nw] != -1) continue; // すでに発見済みのマスは探索しない

          // 新たなマスについて距離情報を更新してキューに追加する
          dist[nh][nw] = dist[v.fi][v.se] + 1;
          pair<int,int> r=mp(nh,nw);
          que.push(r);
        }
    }

    // 結果出力 (最長距離を見る)
    int ans=0;
    rep(i,r){
      rep(j,c){
        ans=max(ans,dist[i][j]);
      }
    }
  
  cout << ans << endl;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int N;
	string S;
	cin >> N >> S;
	string T;
	for (int i = 0; i < N/2; i++){
		T += S[i];
	}
	string ans;
	for (int i = N/2; i < N; i++){
		ans += S[i];
	}
	if (ans != T) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}

	return 0;
}

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

int main(){

string s;
int q;
cin >> s >> q;
deque <char> deq;
for (char x: s) deq.push_back(x);

bool flip=false;

rep(i,q){
    int t; cin >> t;
    if(t==1) flip=!flip;
    else {
        int f; char c;
        cin >> f >> c;
        if(flip) f=3-f;
        if(f==1) deq.push_front(c);  
        if(f==2) deq.push_back(c);  
    }
}

string ans;
for (char x: deq) ans += x;
if (flip) reverse(ans.begin(), ans.end());
cout << ans << endl;







}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
int main() {
	int n;
	string s;
	cin >> n >> s;

	int res = 0;
	for (int i = 0; i < n - 1; i++)
	{
		int cnt = 0;
		for (int j = 0; j < 26; j++)
		{
			char ch = 'a' + j;
			bool x = false, y = false;
			for (int k = 0; k < n; k++)
			{
				if(s[k] == ch) {
					if(k <= i) x = true;
					else y = true;
				}
			}
			if(x && y) cnt++;
		}
		res = max(res, cnt);
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3592
N,K,S = map(int,input().split())
if S != 10**9:
    for _ in range(K):
        print(S,end=' ')
    for _ in range(N - K):
        print(10**9,end = ' ')
    print()
else:
    for _ in range(K):
        print(10**9,end = ' ')
    for _ in range(N - K):
        print(1,end=' ')


Measured memory_bytes: 75752
import random

N = int(input())
num = list(map(int, input().split()))
count = 0

for i in num:
    if i%4==0:
        N -= 2
    elif i%2==0:
        count += 1
if count>1:
    N = N - count + 1

if N > 1:
    print('No')
else:
    print('Yes') 

Measured memory_bytes: 15404
#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>;

bool compArray(int a[], int b[], int num){
    rep(i, num){
        if(a[i] != b[i]) return false;
    }  
    return true;
}

int main() {
    int n;
    cin >> n;
    int p[n], q[n];
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    
    int r[n];
    rep(i, n) r[i] = i+1;
    bool f_p = true;
    bool f_q = true;
    int res = 0;
    int count = 1;
    do{
        if(f_p && compArray(p, r, n)){
            f_p = false;
            res += count;
        }
        if(f_q && compArray(q, r, n)){
            f_q = false;
            res -= count;
        }
        if(!f_p && !f_q) break;
        ++count;
    }while(next_permutation(r, r+n));
    
    cout << abs(res) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define For(i,a,b) for (int i=a;i<=b;i++)
#define fi first
#define se second
#define pb push_back
#define dscan(x) scanf("%d", &x)
#define lldscan(x) scanf("%lld", &x)
#define task "B"
using namespace std;

/*~~~~~~~~~~~~~~~~~~~~SET YOUR MAXIMUM N VALUE HERE~~~~~~~~~~~~~~~~~~~~*/

const ll maxn = 55;
const ll inf = 1000000007;

/*~~~~~~~~~~~~~~~~~~~~VARIABLES~~~~~~~~~~~~~~~~~~~~*/

int n, p[maxn];

/*~~~~~~~~~~~~~~~~~~~~FUNCTIONS & PROCEDURES~~~~~~~~~~~~~~~~~~~~*/

void open() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen(task".inp","r",stdin);
    //freopen(task".out","w",stdout);
}

void read() {
    open();
    dscan(n);
    For(i,1,n) dscan(p[i]);
}

void solve() {
    bool ok=true;
    For(i,1,n-1) if (p[i+1]<p[i]) {ok=false; break;}
    if (ok==false) For(i,1,n-1) {
        For(j,i+1,n) {
            int ds[maxn];
            ok=true;
            For(k,1,n) {
                ds[k]=p[k];
                if (k==i) ds[k]=p[j];
                else if (k==j) ds[k]=p[i];
            }
            For(k,1,n-1) if (ds[k+1]<ds[k]) {ok=false; break;}
            if (ok==true) break;
        }
        if (ok==true) break;
    }
    if (ok==true) printf("YES\n"); else printf("NO\n");
}

/*~~~~~~~~~~~~~~~~~~~~MAIN~~~~~~~~~~~~~~~~~~~~*/

int main()
{
    read();
    solve();
    return 0;
}

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

#define PI 3.14159265359
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}
ll LCM(int a, int b){
    return a*b/gcd(a,b);
}
int counterBit(int x){
    if(x==0)return 0;
    return counterBit(x>>1)+(x&1);
}
int main(void)
{
    int n;
    cin>>n;
    vector<int> x(n);
    rep(i,0,n)cin>>x[i];

    int ans=INF;
    rep(i,0,100){
        int sum=0;
        rep(j,0,n){
            sum+=abs(i-x[j])*abs(i-x[j]);
        }
        ans=min(ans,sum);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
import math
from fractions import gcd

a,b=map(int,input().split())

def pf(x):
  x2=x
  y = int(math.sqrt(x))+1
  l=[1]
  if x%2==0:
    l.append(2)
    while x%2==0:
      x=x//2
  for i in range(3,y,2):
    if x%i==0:
      l.append(i)
    while x%i==0:
      x=x//i
    if x==1:
      break
  if x>=y:
    if x!=1:
      l.append(x)
  return(l)

count=0
n=gcd(a,b)

l=pf(n)

len=len(l)
for i in range(len):
  if  a%l[i]==0:
        count+=1
print(count)


Measured memory_bytes: 5176
X, Y, Z, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
A.sort(reverse=True); B.sort(reverse=True); C.sort(reverse=True)
a = []; b = []; c = []

candidate = []
for i in range(1, X + 1):
    for j in range(1, Y + 1):
        if i * j <= K:
            for k in range(1, Z + 1):
                if i * j * k <= K:
                    candidate.append((i, j, k))
                else:
                    break
        else:
            break


answer = []
for i, j, k in candidate:
    answer.append(A[i - 1] + B[j - 1] + C[k - 1])

answer.sort(reverse=True)
for i in range(K):
    print(answer[i])

Measured memory_bytes: 17552
n,m,x,y = map(int,input().split())
xs = list(map(int,input().split()))
ys = list(map(int,input().split()))

war = True

for z in range(-100,101):
    new_xs = xs + [z]
    new_ys = ys + [z]
    new_xs.sort()
    new_ys.sort()
    if new_xs[-1] == z and new_xs[-2] != z and new_ys[0] == z and x<z<=y:
        war = False
        
if war:
    print('War')
else:
    print('No War')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 1e9;
 
struct SegtreeRMQ {
    ll n;
    ll inf;
    vector<ll> dat;
 
    void init(ll n_input, ll inf_input){
        inf = inf_input;
        n = 1;
        while(n < n_input)n <<= 1;
        dat.resize(2*n+10);
        for(int i = 0; i<2*n-1; i++) dat[i] = inf;
    }
 
    void update(ll k, ll a){
        k += n - 1;
        dat[k] = a;
        while(k > 0){
            k = (k - 1)/2;
            dat[k] = min(dat[2*k+1], dat[2*k+2]);
        }
    }
 
    ll query(ll a, ll b, ll k, ll l, ll r){
        if(r<=a || b<=l)return inf;
        if(a<=l && r<=b)return dat[k];
        ll vl = query(a, b, 2*k+1, l, (l+r)/2);
        ll vr = query(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
    }
};

int main()
{
    int n;
    cin >> n;
    vector<int> p(n+1);
    vector<int> pos(n+1);
    for(int i = 0; i < n; i++)
    {
        cin >> p[i];
        pos[p[i]] = i;
    }
    SegtreeRMQ st[2];
    st[0].init(n, INF);
    st[1].init(n, INF);

    for(int i = 0; i < n; i++)
    {
        if(i % 2 == 0)
        {
            st[0].update(i, p[i]);
            st[1].update(i, INF);
        }
        else
        {
            st[1].update(i, p[i]);
            st[0].update(i, INF);
        }
    }
    set<vector<ll>> cand;

    function<void(ll, ll)> process = [&](ll l, ll r)
    {
        if(r <= l) return;
        ll lmi = st[l%2].query(l, r, 0, 0, st[0].n);
        ll lpos = pos[lmi];
        ll rmi = st[(l+1)%2].query(lpos+1, r, 0, 0, st[0].n);
        ll rpos = pos[rmi];
        cand.insert({lmi, rmi, l, lpos, rpos, r});
    };

    process(0, n);
    vector<ll> ans;
    while(cand.size() > 0)
    {
        vector<ll> ret = *cand.begin();
        cand.erase(cand.begin());
        ans.push_back(ret[0]);
        ans.push_back(ret[1]);
        process(ret[2], ret[3]);
        process(ret[3]+1, ret[4]);
        process(ret[4]+1, ret[5]);
    }
    for(int i = 0; i < n; i++)
    {
        cout << ans[i] << " ";
    }
}




Measured memory_bytes: 18032
using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Contexts;
using System.Text;
using System.Threading;
using System.Xml.Schema;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;

        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }

            var res = line[index];
            index++;
            return res;
        }

        public int NextInt()
        {
            return int.Parse(Next());
        }

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

        public ulong NextUlong()
        {
            return ulong.Parse(Next());
        }

        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }

        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }

        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private int N;
        private int[] P;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            P = new int[N];
            for (int i = 0; i < N; i++)
            {
                P[i] = sc.NextInt();
            }
        }

        public void Solve()
        {
            Scan();
            int max = P.Max();
            int sum = P.Sum();
            Console.WriteLine(sum-max/2);
        }

        static void Main() => new Program().Solve();
    }


}

Measured memory_bytes: 13268
import java.util.ArrayDeque;
import java.util.Queue;
import java.util.Scanner;

public class Main {

    private static final int[] cornersX = { -1, 0, 1, 0 };
    private static final int[] cornersY = { 0, 1, 0, -1 };

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        sc.nextLine();

        Character[][] s = new Character[H][W];

        for (int i = 0; i < H; i++) {
            char[] line = sc.nextLine().toCharArray();
            for (int j = 0; j < line.length; j++) {
                s[i][j] = line[j];
            }
        }

        int maxDistance = 0;
        for (int i = 0; i < W; i++) {
            int startX = i;
            for (int j = 0; j < H; j++) {
                if (s[j][i] == '#') { continue; }

                int[][] distances = new int[W][H];
                Queue<Pair> queue = new ArrayDeque<>();

                int startY = j;
                update(i, j, distances, queue, 0);

                while (!queue.isEmpty()) {
                    int x = queue.peek().getFirst();
                    int y = queue.peek().getSecound();
                    queue.remove();
                    maxDistance = Math.max(maxDistance, distances[x][y]);

                    for (int k = 0; k < 4; k++) {
                        int xx = x + cornersX[k];
                        int yy = y + cornersY[k];

                        if (xx < 0 || xx >= W || yy < 0 || yy >= H) {
                            continue;
                        }
                        if (distances[xx][yy] != 0 || xx == startX && yy == startY) {
                            continue;
                        }
                        if (s[yy][xx] == '#') {
                            continue;
                        }
                        update(xx, yy, distances, queue, distances[x][y] + 1);
                    }
                }
            }
        }
        System.out.println(maxDistance);

    }

    public static void update(final int i, final int j, int[][] array, Queue<Pair> queue, final int x) {
        array[i][j] = x;
        queue.add(new Pair(i, j));
    }

    static class Pair<F, S> {
        public final F first;
        public final S secound;

        Pair(F first, S secound) {
            this.first = first;
            this.secound = secound;
        }

        public int getFirst() {
            return Integer.valueOf(String.valueOf(first));
        }

        public int getSecound() {
            return Integer.valueOf(String.valueOf(secound));
        }
    }

}

Measured memory_bytes: 38844
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoderSolve.Tool;

namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var input = cin.SplitReaderL();
            long N = input[0];
            long K = input[1];
            long Q = input[2];

            long[] co = new long[N];
            bool[] ok = new bool[N];
            Initialize(ref co, 0);
            Initialize(ref ok, false);

            for(var i = 0; i < Q; i++)
            {
                long A = long.Parse(Console.ReadLine());
                co[A - 1]++;
            }

            for(var i = 0; i < N; i++)
            {
                ok[i] = K - (Q - co[i]) > 0;
            }

            for(var i = 0; i < N; i++)
            {
                Console.WriteLine(ok[i] ? "Yes" : "No");
            }

            //Console.Out.Flush();
        }

    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for(var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long ModuloP(long value,long mod)
        {
            long r = value % mod;
            
            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }

    }

    struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
    {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
    }



}






Measured memory_bytes: 18396
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A: Cookie Exchanges
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

struct Stat {
  int a, b, c;
  Stat() {}
  Stat(int _a, int _b, int _c): a(_a), b(_b), c(_c) {}

  bool good() {
    return (a & 1) == 0 && (b & 1) == 0 && (c & 1) == 0;
  }

  bool operator<(const Stat &s) const {
    return a < s.a || (a == s.a && (b < s.b || (b == s.b && c < s.c)));
  }
};

typedef set<Stat> ss;

/* global variables */

ss stset;

/* subroutines */

/* main */

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

  int cnt = 0;
  Stat s(a, b, c);
  while (s.good()) {
    if (stset.find(s) != stset.end()) {
      puts("-1");
      return 0;
    }
    cnt++;
    stset.insert(s);

    int ah = (s.a >> 1), bh = (s.b >> 1), ch = (s.c >> 1);
    s = Stat(bh + ch, ch + ah, ah + bh);
  }

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


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

#define PI 3.141592653589793

int main(void) {
	
	char s;

	scanf("%c", &s);

	if ('A' <= s && s <= 'Z')
	{
		printf("A\n");
	}
	if ('a' <= s && s<= 'z')
	{
		printf("a\n");
	}
	return 0;
}

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

#define MAX_N 100

using namespace std;

int num[MAX_N];

void printNum(int n)
{
    int i;
    printf("%d", num[0]);
    for (i = 1; i < n; i++) {
        printf(" %d", num[i]);
    }
    printf("\n");
}

int main()
{
    int i, j, n, flag = 1, swapTime = 0;;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d", &num[i]);
    }
    for (i = 0; flag; i++) {
        flag = 0;
        for (j = n - 1; j > i; j--) {
            if (num[j] < num[j - 1]) {
                swap(num[j], num[j - 1]);
                swapTime++;
                flag = 1;
            }
        }
    }
    printNum(n);
    printf("%d\n", swapTime);
    return 0;
}

Measured memory_bytes: 2724
#include <iostream>

using namespace std;

int main(){
  long long a, b, x;
  cin >> a >> b >> x;
  //ここまで入力

  long long s, g;

  if(a%x ==0)  
    s = a/x;
  else
    s = (a+x)/x;

    g = b/x;

  cout << g-s+1 << endl;
  



  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

int N, M, s[100000], t[100000], p[100000];
ll sum[100002];
int main()
{
	cin >> N >> M;
	for (int i = 0; i < N; ++i)
		cin >> s[i] >> t[i];
	for (int i = 0; i < M; ++i)
		cin >> p[i];
	sort(p, p+M);
	for (int i = 1; i < M; ++i)
		sum[i+2] += (sum[i] += p[i] - p[i-1]);

#define seg_sum(a, b) (sum[b-(b-a+1)%2] - sum[a-1 < 0 ? 0 : a-1])

	ll ans = 0;
	for (int i = 0; i < N; ++i)
	{
		int a = s[i];
		int b = t[i];
		if (a > b)
			swap(a, b);

		int l = lower_bound(p, p+M, a) - p;
		int r = lower_bound(p, p+M, b) - p - 1;
		ll len = b-a;
		if (r > l)
			len -= seg_sum(l, r);
		if (r < M && (r-l) % 2 == 0)
			len -= b - p[r];
		if (s[i] > t[i] && (r-l) % 2 == 0)
			len = b - a - len;

		ans += len;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 0