akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int isman(string s){
  if(s=="Vacant")return -1;
  if(s=="Male")return 1;
  if(s=="Female")return 0;
}

int main(){
  int n;
  cin>>n;
  int a=0;
  int b=n;
  cout<<0<<endl;
  string s;
  cin>>s;
  int a_man=isman(s);
  if(a_man==-1)return 0;

  for(int i=0;i<21;i++){
    int c=(a+b)/2;
    cout<<c<<endl;
    cin>>s;
    int c_man=isman(s);
    if(c_man==-1)return 0;
    if((c-a)%2!=0){
      if(a_man==c_man)b=c;
      else {
        a=c;
        a_man=c_man;
      }
    }
    else{
      if(a_man!=c_man)b=c;
      else {
        a=c;
        a_man=c_man;
    }

  }
}
  return 0;
}


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

const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n"
#define rep(i,n) for(int i=0; i<(n); ++i)

typedef pair<int, int> P;
typedef pair<string, int> Psi;


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

	int n;cin>>n;

	vector<int> A(n);
	vector<int> B(n);

	rep(i,n){
		cin>>A[i];
	}
	rep(i,n){
			cin>>B[i];
		}
	int ans =0;
	rep(i,n){
		if(A[i]-B[i]>0){
			ans +=A[i]-B[i];
		}
	}

	writeln(ans);



}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAXN = (int) 1e6 + 10;
const int MOD = (int) 1e9 + 7;

int n, k, q;
int num[MAXN];

int main(){
	scanf("%d%d%d", &n, &k, &q);
	int qq = q;
	while (q --) {
		int x;
		scanf("%d", &x);
		num[x] ++;
	}
	for (int i=1; i<=n; i++) {
		if (k + num[i] - qq <= 0) puts("No");
		else puts("Yes");
	}
    return 0;
}


Measured memory_bytes: 1024
from itertools import accumulate
from collections import Counter

n = int(input())
A = [0] + list(map(int, input().split()))
ans = 0
SA = list(accumulate(A))
# print(SA)
CSA = Counter(SA[1:])
# print(CSA)
for i, num in CSA.items():
    if i == 0:
        ans += num
    ans += num * (num - 1) // 2

# for i in range(n):
#     for j in range(i + 1, n + 1):
#         goukei = SA[i] - SA[j]
#         print(goukei)
#         if goukei == 0:
#             ans += 1
print(ans)


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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

int n, m, a[1000];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  cin >> n >> m;
  for (int i = 0; i < m; i++)
    cin >> a[i];
  if (m == 1) {
    cout << a[0] << "\n";
    if (a[0] == 1)
      cout << "1\n1\n";
    else
      cout << "2\n" << 1 << " " << a[0] - 1 << "\n";
    return 0;
  }
  int cnt = 0;
  for (int i = 0; i < m; i++) {
    if (a[i] % 2 == 1) {
      swap(a[i], a[cnt]);
      cnt++;
    }
  }
  if (cnt > 2) {
    cout << "Impossible\n";
    return 0;
  }
  swap(a[1], a[m - 1]);
  for (int i = 0; i < m; i++)
    cout << a[i] << (i < m - 1 ? " " : "\n");
  cout << (a[m - 1] == 1 ? m - 1 : m) << "\n";
  cout << a[0] + 1;
  for (int i = 1; i < m - 1; i++)
    cout << " " << a[i];
  if (a[m - 1] != 1)
    cout << " " << a[m - 1] - 1;
  cout << "\n";
}


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

namespace _1_8_C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] _largeInitial = { "A","B","C","D","E","F","G",
                                       "H","I","J","K","L","M","N","O","P","Q","R",
                                       "S","T","U","V","W","X","Y","Z"};
            string[] _smallInitial = { "a","b","c","d","e","f","g",
                                       "h","i","j","k","l","m","n","o","p","q","r",
                                       "s","t","u","v","w","x","y","z"};
            int[] _count = new int[26];
            List<string> _readText = new List<string>();
            while(true)
            {
                string _readLine = Console.ReadLine();
                if (_readLine == null) break;
                _readText.Add(_readLine);
                
            }
            for (int j = 0; j < _readText.Count; j++)
            {
                char[] chars = _readText[j].ToCharArray();
                //_readText[j]を一文字ずつ_readInitialに収納
                List<string> _readInitial = new List<string>();
                for (int i = 0; i < _readText[j].Length; i++) _readInitial.Add(_readText[j].Substring(i,1));
                for (int g = 0; g < _readText[j].Length; g++)
                {
                    for (int i = 0; i < 26; i++)
                    {
                        if (_readInitial[g] == _largeInitial[i] | _readInitial[g] == _smallInitial[i])
                        {
                            _count[i]++;
                        }
                    }
                }
            }
            for(int i = 0; i < 26; i ++)
            Console.WriteLine("{0} : {1}", _smallInitial[i], _count[i]);
        }
    }
}



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

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var NY = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            var N = NY[0];
            var Y = NY[1];

            for(var x = N;0<=x;x--)
            {
                for (var y = N-x; 0 <= y; y--)
                {
                    for (var z = N - x - y; 0 <= z; z--)
                    {
                        if (x * 10000 + y * 5000 + z * 1000 == Y && x+y+z==N)
                        {
                            Console.WriteLine($"{x} {y} {z}");
                            return;
                        }
                    }
                }
            }
            Console.WriteLine("-1 -1 -1");
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int MAX = 1e6 + 10;
const int MOD = 1e9 + 7;
const int oo = 1e9;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	#define endl '\n'
	int T; cin >> T;
	while(T--){
		int n; cin >> n;
		vector<i64> A(n);
		for(int i = 0; i <n; i++)cin >> A[i];
		string p;
		cin >> p;
		vector<i64> basis;
		int ans = 0;
		for(int i = n - 1; i >= 0; i--){
			i64 c = A[i];
			for(auto b: basis) c= min(c, c ^ b);

			if(p[i] == '1'){
				if(c > 0){
					ans = 1;break;
				}
			}
			else{
				if(c > 0)basis.push_back(c);
			}
		}
		cout << ans << endl;

		
	}
}


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

const int m  = 2019;
int main() {
    string s;
    cin >> s;

    reverse(s.begin(), s.end());

    int n = s.size();
    int x = 1, tot = 0;
    vector<int> cnt(m);
    ll ans = 0;

    rep(i,n) {
        cnt[tot]++;
        tot += (s[i] - '0') * x;
        tot %= m;
        ans += cnt[tot];
        x = x*10%m;
    }


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

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

using namespace std;

int main(){
    int n,a[1000];
    scanf("%d",&n);
    for (int i = 0; i < n; i++){
        scanf("%d",&a[i]);
    }
    int i = n;
    while(i--) {
       if(i > 0){printf("%d ", a[i]);}
       if(i == 0){printf("%d", a[i]);}
    }
    cout<<endl;
}



Measured memory_bytes: 3228
from itertools import permutations
N = int(input())
P = tuple(map(int, input().split()))
Q = tuple(map(int, input().split()))
r = 0
for i, x in enumerate(permutations([j for j in range(1,N+1)])):
    if x == P:
        r = abs(r-i)
    if x == Q:
        r = abs(r-i)
print(r)


Measured memory_bytes: 9188
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using ll=long long;
using ld=long double;
//#define int long long
//#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for (int i = 0; i < n; i++)
#define _GLIBCXX_DEBUG
const int MOD = 1e9 + 7;
const int INF = 1e18 + 9;
constexpr long double pi = 3.141592653589793238462643383279;
int fact(int i) {
    if (i == 0) return 1;
    return (fact(i - 1)) * i;
}
int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
int keta(int n) {
    if (n == 0) return 1;
    int count = 0;
    while (n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
int ketasum(int n) {
    int sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
string n;
int main(void) {
    cin >> n;
    (n[0] == n[2] ? cout << "Yes" << endl : cout << "No" << endl);
    return 0;
}

Measured memory_bytes: 3556
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<numeric>
#include<utility>

using namespace std;

typedef long long int ll;
const int INF = 1<<30;
const long long LINF = 1LL<<60;

int main(){
    ll n, ans = 0;
    cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            ll t = n / i - 1;
            if(n / t == n % t){
                ans += t;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

struct Point{
	int v, d, c;
};

vector <int> from[100010];
vector <Point> a;
int ans[100010], max_d[100010];

inline void paint(int x, int dis, int num, int c){
	if (dis + max_d[x] >= num) return ;
	max_d[x] = max(max_d[x], num - dis);
	if (ans[x] == 0) ans[x] = c;
	for (int i = 0; i < from[x].size(); i++){
		int v = from[x][i];
		paint(v, dis + 1, num, c);
	}
}

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++){
		int u, v;
		scanf("%d%d", &u, &v);
		from[u].push_back(v);
		from[v].push_back(u);
	}
	int q;
	scanf("%d", &q);
	a.resize(q);
	for (int i = 0; i < q; i++){
		scanf("%d%d%d", &a[i].v, &a[i].d, &a[i].c);
	}
	reverse(a.begin(), a.end());
	memset(max_d, -1, sizeof(max_d));
	for (int i = 0; i < q; i++){
//		cout << i << endl;
		paint(a[i].v, 0, a[i].d, a[i].c);
	}
	for (int i = 1; i <= n; i++){
		printf("%d\n", ans[i]);
	}
	return 0;
}


Measured memory_bytes: 8440
N = int(input())
S = input()

left = ''
right = ''

skip_idx = []
for idx, s in enumerate(S):
    if idx in skip_idx:
        continue
    if s == ')':
        left += '('
    else:
        # print(j)
        skip_flag = 0
        for n in range(idx+1, N):
            if n in skip_idx:
                continue
            if S[n] == ')':
                skip_idx.append(n)
                skip_flag = 1
                break
        if not skip_flag:
            right += ')'
    # print(idx, s, left, right, skip_idx)

print(left+S+right)

Measured memory_bytes: 63232
N = int(input())
A = list(map(int, input().split()))
base = 10 ** 9 + 7
X = 0
Y = 0
for i in A:
  X += i * i
  Y += i
  X %= base
  Y %= base
Y = (Y * Y) % base
ans_ = ( Y - X ) % base

m = pow(2, base-2, base)
#print(m)
print( (ans_ * m) % base )

Measured memory_bytes: 31432
from collections import Counter

n = int(input())
v = list(map(int, input().split()))

list0 = []
list1 = []
for i, a in enumerate(v):
    if i % 2 == 0:
        list0.append(a)
    else:
        list1.append(a)

c0 = Counter(list0)
c1 = Counter(list1)

c0_most_common = c0.most_common(2)
c1_most_common = c1.most_common(2)

if c0_most_common[0][0] != c1_most_common[0][0]:
    print(n - (c0_most_common[0][1] + c1_most_common[0][1]))
else:
    if len(c0_most_common) >= 2 and len(c1_most_common) >= 2:
        print(min(n - (c0_most_common[0][1] + c1_most_common[1][1]), n - (c0_most_common[1][1] + c1_most_common[0][1])))
    elif len(c0_most_common) == 1 and len(c1_most_common) >= 2:
        print(n - (c0_most_common[0][1]) + c1_most_common[1][1])
    elif len(c1_most_common) == 1 and len(c0_most_common) >= 2:
        print(n - (c1_most_common[0][1]) + c0_most_common[1][1])
    else:
        print(n - (c1_most_common[0][1]))
        


Measured memory_bytes: 19040
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}
int main()
{
	int n,k;
	read(n);read(k);
	for (int x,i=1;i<=n;i++) read(x),ans+=x>=k;
	cout<<ans;
	return 0;
}









Measured memory_bytes: 2304
#include<stdio.h>
#include<iostream>
#include<stdlib.h>
using namespace std;

//int key=0;


int linearSearch(int A[], int n,int key){
  int i=0;
  A[n]=key;
  while(A[i]!=key){
    i++;
  }
  //if(i!=n)return 1;
  return i!=n;
}

int main(){
  int n=0,q=0;
  int S[100000];
  int T[100000];
  //int search[100000];
  int count=0;
  int key=0;
  cin>>n;
  for(int i=0;i<n;i++)cin>>S[i];
  cin>>q;
  //for(int i=0;i<q;i++)cin>>T[i];
  for(int i=0;i<q;i++){
    //key=T[i];
    cin>>key;
    if(linearSearch(S,n,key))count++;
  }
  cout<<count<<endl;
  return 0;
}



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

using namespace std;

int main()
{

   string s; cin >> s;

   for(int i=0;i<s.length();i=i+2)
   {
       if(s[i]=='L') { cout << "No\n"; return 0; }
   }
    for(int i=1;i<s.length();i=i+2)
   {
       if(s[i]=='R') { cout << "No\n"; return 0; }
   }

   cout << "Yes\n" ;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MAXN 200005

#define INF 0x3f3f3f3f
#define ld long double
using namespace std;
ll a[MAXN];
ll x[MAXN]={0};
int main(){
    ios::sync_with_stdio(false);
    #define int ll
    int n;
    cin>>n;
    for(int i=2;i<=n;i++){
        cin>>a[i];
        x[a[i]]+=1;
    }
    for(int i=1;i<=n;i++){
        cout<<x[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 6780
#include <iostream>
using namespace std;
int main(){
	int n,result=0;
	string  str;
	cin>>n>>str;
	char tmp='0';
	for(int i=0;i<n;i++){
		result++;
		if(str[i]==tmp)result--;
		tmp=str[i];
	}
	cout<<result<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<cstdio>

int main() {
    char s[1201];
    scanf("%[^\n]",s);
    for(int i = 0;s[i] !='\0';i++) {
        char c = s[i];
        if(c >= 65 && c <= 90) {
            s[i] = c + 32;
        }
        else if(c >= 97 && c <= 122) {
            s[i] = c - 32;
        }
    }
    printf("%s\n",s);
    return 0;
}


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

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

int eat = 1000;
int sign = 1;
for (int i = 0; i < N; i++) {
    if (eat > abs(L + i)) {
        eat = abs(L + i);
        if(L + i < 0) {
            sign = -1; 
        }
    }
    eat = min(eat, abs(L + i));
} 
cout << N*(L - 1) + N*(N + 1)/2 - sign*eat << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;

int main() {
	string S;
	cin >> S;
	int l = (int)S.length();
	if (l<26) {
		char t;
		for (int i = 'a';i <= 'z';i++) {
			bool ex = false;
			rep(j, l) {
				int x = (int)S[j];
				if (x == i)ex = true;
			}
			if (!ex) {
				t = (char)i;
				break;
			}
		}
		S.push_back(t);
		cout << S;
	}
	else {
		bool end = true;

		for (int i = 25;i >= 1;i--) {
			int p = (int)S[i - 1], q = (int)S[i];
			if (p>q) {
				S.pop_back();
			}
			else {
				end = false;
				S.pop_back();
				break;
			}
		}
		if (end)cout << -1;
		else {
			char t;
			char u = S.back();
			int v = (int)u;
			for (int i = 'a';i <= 'z';i++) {
				bool ex = false;
				if (i < v)ex = true;
				rep(j, l) {
					int x = (int)S[j];
					if (x == i)ex = true;
				}
				if (!ex) {
					t = (char)i;
					break;
				}
			}
			S.pop_back();
			S.push_back(t);
			cout << S;
		}
	}
}

Measured memory_bytes: 256
def is_square(N):
    i = 0
    while i**2 < N:
        i += 1
    if i**2 == N:
        return i
    return None


N = int(input())
r = is_square(8*N+1)
if r is None:
    print("No")
else:
    print("Yes")
    k = (r-1)//2
    size = k+1
    print(size)
    length = k
    ans = [[-1]*length for _ in range(size)]
    used = set()
    cur_max = 0
    for i in range(0, size):
        for j in range(i):
            ans[i][j] = ans[j][i-1]
        for k in range(i, length):
            ans[i][k] = cur_max+1
            cur_max += 1
    for a in ans:
        print("{} {}".format(length, " ".join(map(str, a))))


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

int main() {
	int n; cin >> n;
	vector<pair<int, int>>s(n), t(n);
	for (auto&& x : s)cin >> x.first >> x.second;
	for (auto&& y : t)cin >> y.first >> y.second;
	sort(s.begin(), s.end()); sort(t.begin(), t.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int cur = -1;
		for (int j = 0; j < n; j++) {
			if (s[j].first > t[i].first)break;
			if (t[i].second < s[j].second)continue;
			if (cur == -1) { cur = j; ans++; }
			else {
				if (s[cur].second < s[j].second)cur = j;
			}
		}
		if (cur != -1)s[cur].second = 100000;
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int x, y;
  cin >> x >> y;
  bool ans = [&]() -> bool {
    if (y % 2) return false;
    return 2 * x <= y && y <= 4 * x;
  }();
  cout << (ans ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3608
#include<iostream>
#include<unordered_map>
#include<bitset>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>
#include<map>
#include<stack>
#include<iterator>
#include<cstring>
 
#include<deque>
#define pi 3.141592653589793238
#include<chrono>
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#define MOD 1000000007
#define INF 999999999999999999 
#define pb push_back
#define ff first
#define ss second
 
#define mt make_tuple
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
 
 
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    fast;
    ll T = 1, i, j;
    
    //cin >> T;
    while (T--) {
        ll n, k;
        cin >> n >> k;
        vector<ll> v(n);
        for(i = 0; i < n; i++){
            cin >> v[i];
        }
        for(i = k ; i < n; i++){
            if(v[i - k] >= v[i]){
                cout << "No\n";
            }
            else{
                cout <<"Yes\n";
            }
        }
    }
    return 0;
}

Measured memory_bytes: 4784
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int h,w,k;
    cin >> h >> w >> k;
    vs a(h);
    cin >> a;
    int si,sj;
    rep(i,h) rep(j,w) if(a[i][j] == 'S') {
        si = i;
        sj = j;
    }
    vvi dist(h,vi(w,inf));
    queue<P> q;
    dist[si][sj] = 0;
    q.emplace(si,sj);
    while(!q.empty()) {
        auto [i,j] = q.front();
        q.pop();
        rep(K,4) {
            int ni = i+dx[K],nj = j+dy[K];
            if(ni < 0 or ni >= h or nj < 0 or nj >= w) continue;
            if(a[ni][nj] == '#') continue;
            if(chmin(dist[ni][nj],dist[i][j]+1)) {
                q.emplace(ni,nj);
            }
        }
    }
    int mn = inf;
    rep(i,h) rep(j,w) if(dist[i][j] <= k) {
        chmin(mn,min({i,j,h-1-i,w-1-j}));
    }
    cout << (mn+k-1)/k+1 << endl;
}


Measured memory_bytes: 6888
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<math.h>
using namespace std;
#define MAX 200005
#define MOD 998244353
#define EPS 0.00000000001
#define INF 998244353

int main()
{
    int n,m;
    scanf("%d",&n);
    m=(n/1000)+(n%1000>0);
    m=m*1000-n;
    printf("%d",m);
    return 0;
}


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

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗する

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) の絶対値

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//配列の受け取り

main(){
  int n=in(),a=in(),b=in(),one=0,two=0,thr=0,num;
  for (int i=0;i<n;i++){
    cin >> num;
    if (num<=a) one++;
    else if (a<num && num<=b) two++;
    else thr++;
  }
  cout << min({one,two,thr}) << endl;
}


Measured memory_bytes: 256
import math
def fact(n):
    ans = 1
    for i in range(2, n+1):
        ans*= i
    return ans
def comb(n, c):
    return fact(n)//(fact(n-c)*c)

n = int(input())
c = {}
for i in range(n):
    s = str(input())
    if(s in c):
        c[s]+=1
    else:
        c[s] = 0
print(len(c))


Measured memory_bytes: 125632
#include<stdio.h>

 int main(){
 	
 	int b[10];
 	int counts = 0;
 	scanf("%d %d %d", &b[0],&b[1],&b[2]);
 	scanf("%d %d %d", &b[3],&b[4],&b[5]);
 	scanf("%d %d %d", &b[6],&b[7],&b[8]);
 	int times;
 	int num[50] = {0};
 	scanf("%d", &times);
 	for(int i = 0; i<times;i++){
 		scanf("%d", &num[i]);
	 }
	 for(int i = 0; i<times;i++){
	 	for(int j=0;j<9;j++){
	 		if(num[i] == b[j]){
	 			b[j] = 777;
			 }
		 }
	 }
	if(b[0] == 777 && b[1] == 777 && b[2] == 777){
		counts++;
	}else if(b[3] == 777 && b[4] == 777 && b[5] == 777){
		counts++;
	}else if(b[6] == 777 && b[7] == 777 && b[8] == 777){
		counts++;
	}else if(b[3] == 777 && b[4] == 777 && b[5] == 777){
		counts++;
	}else if(b[0] == 777 && b[3] == 777 && b[6] == 777){
		counts++;
	}else if(b[1] == 777 && b[4] == 777 && b[7] == 777){
		counts++;
	}else if(b[2] == 777 && b[5] == 777 && b[8] == 777){
		counts++;
	}else if(b[0] == 777 && b[4] == 777 && b[8] == 777){
		counts++;
	}else if(b[2] == 777 && b[4] == 777 && b[6] == 777){
		counts++;
	}
	
	if(counts > 0){
		printf("Yes");
	}else{
		printf("No");
	} 	
 return 0;
 }

Measured memory_bytes: 1728
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<string>
#include<queue>
#include<utility>
#include<cmath>

using namespace std;


int main()
{

  int N, Q;
  cin >> N >> Q;

  vector<pair<int, int> > Node(N);

  long long int sum[N] = {};

  Node[0] = make_pair(1, 0);
  for(int i = 1; i < N; i++){
    int p, c;
    cin >> p >> c;
    Node[i] = make_pair(c, p);
  }

  for(int i = 0; i < Q; i++){
    int p, x;
    cin >> p >> x;

    sum[p-1] += x;
  }

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

  cout << sum[0] << " ";
  for(int i = 1; i < N; i++){
    sum[Node[i].first-1] = (sum[Node[i].first-1] + sum[Node[i].second-1]);

    cout << sum[Node[i].first-1] << " ";
  }

  return 0;
}


Measured memory_bytes: 5504
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
using namespace std;
int A[101];
int N,M;
int D;

int main() {
	cin>>N>>M;
	for(int i=0;i<N;i++){
		cin>>A[i];
	}

	for(int j=1;j<M+1;j++){
		for(int i=0;i<N-1;i++){
			if(A[i]%j>A[i+1]%j){
				D=A[i];
				A[i]=A[i+1];
				A[i+1]=D;
			}
		}
	}


	for(int i=0;i<N;i++){
		cout<<A[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 3076
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptor/reversed.hpp>
#include<boost/operators.hpp>
#include<boost/dynamic_bitset.hpp>
namespace adaptor = boost::adaptors;
template<class T>using p_queue = std::priority_queue<T, std::vector<T>, std::greater<>>;
namespace lib
{
	template<class T>constexpr T pow(T val, std::uint64_t p)
	{
		auto ret = T(1);
		for (auto i : boost::irange(0, 63))
		{
			if (p & (1ULL << i))
			{
				ret *= val;
			}
			val *= val;
		}
		return ret;
	}
	template<std::uint64_t Mod>class modnum :
		private boost::addable<modnum<Mod>>,
		private boost::subtractable<modnum<Mod>>,
		private boost::multipliable<modnum<Mod>>,
		private boost::dividable<modnum<Mod>>
	{
		std::uint64_t val;
		void clamp()
		{
			val %= Mod;
		}
	public:
		modnum() = default;
		modnum(std::int64_t v) :val()
		{
			if (v < 0)
			{
				v += (std::abs(v) / Mod + 1) * Mod;
			}
			val = v;
			clamp();
		}
		modnum(std::uint64_t v) :val(v)
		{
			clamp();
		}
		modnum(std::int32_t v) :modnum(static_cast<std::int64_t>(v))
		{

		}
		modnum(std::uint32_t v) :modnum(static_cast<std::uint64_t>(v))
		{

		}
		friend std::ostream& operator<<(std::ostream& os, modnum const& num)
		{
			return os << num.val;
		}
		auto& operator+=(modnum const& rhs)
		{
			val += rhs.val;
			clamp();
			return *this;
		}
		auto& operator-=(modnum const& rhs)
		{
			val += Mod - rhs.val;
			clamp();
			return *this;
		}
		auto& operator*=(modnum const& rhs)
		{
			val *= rhs.val;
			clamp();
			return *this;
		}
		auto& operator/=(modnum const& rhs)
		{
			val *= pow(rhs, Mod - 2).val;
			clamp();
			return *this;
		}
		auto const& operator*()const
		{
			return val;
		}
	};
}
using mod_t = lib::modnum<1000000007>;

void Main()
{
	std::string str;
	std::cin >> str;
	mod_t answer = 0;
	mod_t now = 1;
	auto N = str.size();
	for (auto i : boost::irange<std::size_t>(0, N))
	{
		if (str[i] == '1')
		{
			answer += now * lib::pow(mod_t(3), (N - 1) - i);
			now *= 2;
		}
	}
	std::cout << answer + now << std::endl;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MAX = 1000000;
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;
}

int main(){
    long long x, y, i, tmp=0, ans=0, n, m;
    cin >> x >> y;
    if((x+y)%3 != 0){
        ans=0;
        cout << ans <<endl;
        return 0;
    }
    m=(2*x-y)/3;n=(2*y-x)/3;
    if(m<0 || n<0) ans=0;
    else{
        COMinit();
    ans=COM(m+n, n);
    }
    cout << ans <<endl;

    return 0;
}

Measured memory_bytes: 23680
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
using ll = long long int;
using graph = vector<vector<int>>;
using wgraph = vector<vector<pair<int, lint>>>;
const lint INF = 1001001001001001LL;
const lint MOD = 1000000007LL;
const double PI = 3.1415926535897932;
int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

void yes(){ cout << "yes" << endl; }
void Yes(){ cout << "Yes" << endl; }
void YES(){ cout << "YES" << endl; }
void no(){ cout << "no" << endl; }
void No(){ cout << "No" << endl; }
void NO(){ cout << "NO" << endl; }
void possible(){ cout << "possible" << endl; }
void Possible(){ cout << "Possible" << endl; }
void POSSIBLE(){ cout << "POSSIBLE" << endl; }
void impossible(){ cout << "impossible" << endl; }
void Impossible(){ cout << "Impossible" << endl; }
void IMPOSSIBLE(){ cout << "IMPOSSIBLE" << endl; }

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for(int i = s; i < t; i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()


int main(){
  
  string s, t; cin >> s >> t;
  lint n = (lint)s.size();
  s = s + s + s + s + s;

  rep(i, n){
    if(s.substr(i, n) == t){
      Yes();
      return 0;
    }
  }
  No();
  return 0;
}


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

const int N = 12, M = 1000;
const int INF = 1e9;

int n, m, a[M], b[M], c[M][N];

int dp[1<<N];

// bitを買うための最小コスト
int rec(int bit) {
  if (dp[bit] != -1) return dp[bit];

  int res = INF;
  rep(i, m) {
    int bi = 0;
    rep(j, b[i]) bi |= 1<<c[i][j];
    if ((bit | bi) == bi) res = min(res, a[i]);
  }

  rep(bi1, 1<<n) {
    if (bi1 == bit) continue;
    if (bi1 == 0) continue;
    if ((bi1 | bit) != bit) continue;
    int bi2 = bit - bi1;
    res = min((ll)res, (ll)rec(bi1) + rec(bi2));
  }
  return dp[bit] = res;
}

int main() {
  cin >> n >> m;
  rep(i, m) {
    cin >> a[i] >> b[i];
    rep(j, b[i]) cin >> c[i][j];
    rep(j, b[i]) c[i][j]--;
  }

  rep(i, 1<<n) dp[i] = -1;
  int ans = rec((1<<n)-1);
  if (ans == INF) ans = -1;
  cout << ans << endl;
  return 0;
} 

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

int main()
{
	string S;
	cin >> S;
	int ans = 1000;
	for (int i = 0; i < S.size()-2; ++i)
	{
		int a = 0;
		a += (S[i] - '0') * 100;
		a += (S[i+1] - '0') * 10;
		a += S[i+2] - '0';
		ans = min(ans,abs(753-a));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;
using ll = long long;

int main() {
	string s, t;
	cin >> s >> t;

	for (int i = 0; i < 3; ++i) {
		if (s[i] != t[2 - i]) {
			cout << "NO" << endl;
			return 0;
		}
	}

	cout << "YES" << endl;

	return 0;
}


Measured memory_bytes: 768
import std.stdio;

int h, w, x, y;
string[100] field;
bool[100*100] memo;

void main(){
	while (1) {
		readf("%d %d\n", &h, &w);
		if(h == 0 && w == 0) break;
		for (int i = 0; i < h; i++) {
			field[i] = readln();
		}
		x = y = 0;
		memo[] = false;
		move();
	}
}

void move(){
	if(memo[y*100+x]) {
		writeln("LOOP");
		return;
	}
	memo[y*100+x] = true;
	switch (field[y][x]) {
		case '>':
			x++;
			break;
		case '<':
			x--;;
			break;
		case 'v':
			y++;
			break;
		case '^':
			y--;
			break;
		case '.':
			writeln(x ," ", y);
			return;
			break;
		default:
	}
	move();
}

Measured memory_bytes: 1072
import numpy as np
s = np.array([int(i) for i in input()])
a = np.array([i%2 for i in range(len(s))])
b = np.array([1]+[i%2 for i in range(len(s)-1)])

print(min(np.sum(np.abs(s-a)),np.sum(np.abs(s-b))))

Measured memory_bytes: 16332
class Combi
  def initialize(max_n, mod = 10**9+7)
      @mod = mod
      @max_n = max_n

      @fac = Array.new(@max_n+1)
      @inv = Array.new(@max_n+1)
      @finv = Array.new(@max_n+1)

      @fac[0] = @fac[1] = 1
      @finv[0] = @finv[1] = 1
      @inv[1] = 1
      2.upto(@max_n) do |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
      end
  end

  def nCk(n,k)
      @fac[n] * @finv[n - k] * @finv[k] % @mod
  end

  def f(x,y)
    return 1 if(x==0 && y==0)
    return 0 if(x < y || y < 1)

    nCk(x-1,y-1)
  end
end

MOD=10**9+7
combi = Combi.new(1000000)

N,K=gets.chomp.split.map(&:to_i)


1.upto(K) do |i|
  ans=0
  ans = combi.f(K,i) * combi.f(N-K,i-1)
  ans += combi.f(K,i) * combi.f(N-K,i) * 2
  ans += combi.f(K,i) * combi.f(N-K,i+1)
  puts ans % MOD
end

Measured memory_bytes: 25212
#include <iostream>
using namespace std;
int main(){
  string S;int K;
  cin >> S >> K;
  for(int i = 0; K > i; i++){
    if(S.at(i) != '1'){
      cout << S.at(i) << endl;
      return 0;
    }
  }
  cout << 1 << endl;
}

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

typedef long long ll;
ll N, K;
const ll MAX_N = 200000;
ll P[MAX_N];
set<ll> S;
ll KAsc;
ll R = 1;

int main() {
  cin >> N >> K;
  for (ll i = 0; i < N; ++i) {
    cin >> P[i];
  }

  ll asc_cont = 0;
  for (ll i = 0; i < N - 1; ++i) {
    if (P[i] < P[i + 1]) {
      ++asc_cont;
      if (asc_cont == K - 1) ++KAsc;
    } else {
      asc_cont = 0;
    }
  }

  for (ll i = 0; i < K - 1; ++i) {
    S.insert(P[i]);
  }
  for (ll i = 0; i < N - K; ++i) {
    S.erase(P[i]);
    S.insert(P[i + K - 1]);
    if (!(P[i] < *S.begin() && *S.rbegin() < P[i + K])) {
      ++R;
    }
  }
  cout << R - (KAsc == 0 ? 0 : KAsc - 1) << endl;
  return 0;
}


Measured memory_bytes: 11136
#include<stdio.h>
#include<string.h>

int main(){
  char str[201],tmp[201];
  int i,j,n,h,len;

  while(1){
    scanf("%s",str);
    if(str[0] == '-') break;
    len=strlen(str);
    scanf("%d",&n);
    for(i=0;i<n;i++){
      scanf("%d", &h);
      for(j=0;j<len;j++) tmp[j] = str[j];
      for(j=0;j<len-h;j++){
	str[j] = str[j+h];
      }
      for(j=0;j<h;j++){
	str[j+len-h] = tmp[j];
      }
    }
    printf("%s\n",str);
  }
  return 0;
}

Measured memory_bytes: 584
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int> p(N,0);
  for(int i=0;i<N;i++) cin>>p[i];
  int counter = 0;
  for(int i=0;i<N;i++){
    if(p[i] != i+1) counter +=1;
  }
  if(counter<=2) cout << "YES"<<endl;
  else cout << "NO" << endl;

}




Measured memory_bytes: 384
#include <stdio.h>
int main(void)
{
    int a[100][100],b[100],c[100];
    int i,j,n,m;
    
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d",&a[i][j]);
        }
    }
    
    for(j=0;j<m;j++)
        scanf("%d",&b[j]);
    
    for(i=0;i<n;i++){
        c[i]=0;
        for(j=0;j<m;j++){
            c[i]+=a[i][j]*b[j];
        }
    }
    
    for(i=0;i<n;i++){
        printf("%d\n",c[i]);
    }
    
    return 0;
}



Measured memory_bytes: 2140
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

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

    cout << min({ N % K, abs((K - (N % K))), N }) << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long LL;
int main(int argc, char* argv[])
{
	LL A,B;
	cin>>A>>B;
	LL N=(B-A)+1;
	if (N%2==0 && A%2==0){
		if (N/2%2==0){
			cout<<0<<endl;
		}else{
			cout<<1<<endl;
		}
		return 0;
	}
	if (N%2==0 && A%2==1){
		LL x;
		if (((N-2)/2)%2==0){
			x=0;
		}else{
			x=1;
		}
		LL y=A^x;
		y^=B;
		cout<<y<<endl;
		return 0;
	}
	if (N%2==1 && A%2==0){
		if (((N-1)/2)%2==0){
			cout<<B<<endl;
		}else{
			LL y=1^B;
			cout<<y<<endl;
		}
		return 0;
	}	
	if (N%2==1 && A%2==1){
		if (((N-1)/2)%2==0){
			cout<<A<<endl;
		}else{
			LL y=A^1;
			cout<<y<<endl;
		}
		return 0;
	}
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define dbl(k, x) fixed << setprecision(k) << (x)

template <typename _T>
inline void _DBG(const char *s, _T x) {
  cerr << s << " = " << x << "\n";
}
template <typename _T, typename... args>
void _DBG(const char *s, _T x, args... a) {
  while (*s != ',') cerr << *s++;
  cerr << " = " << x << ',';
  _DBG(s + 1, a...);
}

#define _upgrade                \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define DBG(...) _DBG(#__VA_ARGS__, __VA_ARGS__)

// ********************** CODE ********************** //

int main() {
  _upgrade;
  int k, n;
  cin >> n >> k;
  vector<long long> price(n);
  for (auto &p : price) {
    cin >> p;
  }
  sort(price.begin(), price.end());
  cout << accumulate(price.begin(), price.begin() + k, 0LL) << "\n";
  return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;

int32_t main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a * c, a * d), max(b * c, b * d)) << '\n';

	return 0;
}

Measured memory_bytes: 3664
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
std::vector<ll> G[200010];
ll dp[200010][2];

void dfs( ll v, ll p = -1 ) {
  for( auto u : G[v] ) if( u != p ) {
    dfs( u, v );
    
  }

  return;
}

int main()
{
  std::cin >> N;

  ll ans = 0;

  repi( i, 1, N+1 )
    ans += (N-i+1)*(N-i+2)/2;

  rep( i, N-1 ) {
    ll u, v;
    std::cin >> u >> v;
    --u; --v;

    G[u].emplace_back( v );
    G[v].emplace_back( u );

    if( u > v )
      std::swap(u,v);

    ans -= (u+1)*(N-v);
  }

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

  return 0;
}

Measured memory_bytes: 15792
# coding:utf-8

import sys
# from collections import Counter, defaultdict

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()


# mathを使わない切り上げ
def ceil(n, m):
    return -(-n//m)


N = I()
H = I()
W = I()

print((N - H + 1) * (N - W + 1))


Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse4")
#include <cassert>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <bitset>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <math.h>
#include <random>
using namespace std;
typedef long long ll;
typedef unsigned long long  ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef long double ld;
mt19937 rnd(random_device{}());
#define all(a) a.begin(), a.end()
#define fr(i, n) for (ll i = 0; i < n; ++i)
#define fr1(i, n) for (ll i = 1; i <= n; ++i)
const int N = 3001;
ll v[N][N];
ll dp[N][N][4];
ll inf = 100000000000000000ll;
void solve() {
    int n, m; cin >> n >> m;
    int k; cin >> k;
    fr(i, k) {
        int r, c; cin >> r >> c;
        cin >> v[r][c];
    }
    fr(i, N) fr(j, N) fr(k, 4) dp[i][j][k] = -inf;
    dp[0][0][0] = 0;
    dp[0][1][0] = 0;
    dp[1][0][0] = 0;
    fr1(i, n) fr1(j, m) {
        ll t = -inf;
        fr(k, 4) t = max(t, dp[i-1][j][k]);
        dp[i][j][0] = max(dp[i][j][0], t);
        dp[i][j][1] = max(dp[i][j][1], t + v[i][j]);
        for (int k = 0; k <= 3; ++k) dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k]);
        for (int k = 1; k <= 3; ++k) dp[i][j][k] = max(dp[i][j][k], dp[i][j - 1][k - 1] + v[i][j]);
    }
    ll t = -inf;
    fr(i, 4) t = max(t, dp[n][m][i]);
    cout << t;
}
void pre_calc() {
}
int main() {
    pre_calc();
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifdef ABCD
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
#endif
    int tst = 1;
    if (tst != 1) cin >> tst;
    while (tst--)
        solve();
}

Measured memory_bytes: 355364
gets
$<.map{|e|n,*a,d=e.split.map &:to_i
h={0=>0,1=>d}
f=->x{h[x]||=a.zip([2,3,5]).map{|a,b|[x%b*d+f[x/b]+a,-x%b*d+f[0--x/b]+a,x*d].min}.min}
p f[n]}

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

#define ll long long
#define INF 1<<31-1
#define LNF 9223372036854775807
#define PI 3.14159265358979
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define FOR(i,a,n) for(i=a;i<n;i++)
#define MOD 1000000007
//#define MOD 998244353
#define NUM 200010
 
void swap(int* a,int* b){int tmp=*a;*a=*b;*b=tmp;}
int abs(int a){if(a<0)return -a;return a;}
int dup(int a,int d){if(a%d==0)return a/d;else return a/d+1;}
int mod(int a,int m){if(a<0)return a%m+m;else return a%m;}

void swapl(ll* a,ll* b){ll tmp=*a;*a=*b;*b=tmp;}
ll absl(ll a){if(a<0)return -a;return a;}
ll dupl(ll a,ll d){if(a%d==0)return a/d;else return a/d+1;}
ll modl(ll a,ll m){if(a<0)return a%m+m;else return a%m;}

ll GCD(ll a,ll b){ll c=1,tmp=MAX(a,b);b=MIN(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
ll LCM(ll a,ll b){return a*b/GCD(a,b);}

ll factorial(ll n, ll m) {return n < m ? 1 : n*factorial(n-1, m);}

int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

// ll dp[]

int main(){
    ll A[3][3];
    ll n, b[10];
    ll check=0;

    for (int i = 0; i < 3; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            scanf("%lld", &A[i][j]);
        }        
    }
    scanf("%lld", &n);
    for (int i = 0; i < n; i++)
    {
        scanf("%lld", b+i);
    }
    
    for (int k = 0; k < n; k++)
    {
        for (int i = 0; i < 3; i++)
        {
            for (int j = 0; j < 3; j++)
            {
                if (A[i][j] == b[k]) A[i][j] = -1;
            }   
        }
    }
    
    for (int i = 0; i < 3; i++)
    {
        if ((A[i][0] & A[i][1] & A[i][2]) == -1) check++;
        if ((A[0][i] & A[1][i] & A[2][i]) == -1) check++;
    }
    if ((A[0][0] & A[1][1] & A[2][2]) == -1) check++;
    if ((A[2][0] & A[1][1] & A[0][2]) == -1) check++;

    if (check != 0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
       
    
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);++i)
int N,D,ans=0;
double dis=0;
signed main(){
  cin >> N >> D;
  double x[N][D];
  rep(i,N) rep(j,D) cin >> x[i][j];
  rep(i,N-1){
    for(int j=i+1;j<N;j++){
      dis=0;
      rep(k,D) dis+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
      dis=sqrt(dis);
      if(ceil(dis) == floor(dis)) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256