akhauriyash/Code-Regression huggingface dataset:
from collections import Counter
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ac = Counter(a)
    acl = [i for i in ac if ac[i] >= 2]
    acl.sort(reverse=True)

    if len(acl) == 0:
        print(0)
    elif ac[acl[0]] >= 4:
        print(int(acl[0] * acl[0]))
    elif len(acl) <= 1:
        print(0)
    else:
        print(int(acl[0]*acl[1]))

if __name__ == '__main__':
    main()


Measured memory_bytes: 18600
# ABC118B - Foods Loved by Everyone
n, m = list(map(int, input().rstrip().split()))
lst = [list(map(int, input().rstrip().split())) for _ in range(n)]
data = [0] * m
count = 0

for i in range(n):
    for j in range(1, lst[i][0] + 1):
        data[lst[i][j] - 1] += 1

for k in range(m):
    if data[k] == n:
        count += 1

print(count)

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

int search(int [],int,int);

int main()
{
  int key,n,q,sum=0,A[100000];

  cin>>n;
  for(int i=0;i<n;i++) cin>>A[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>key;
    if(search(A,n,key)) sum++;
  }
  cout<<sum<<endl;
}

int search(int A[],int n,int key)
{
  int i=0;
  A[n]=key;
  while(A[i]!=key) i++;
  return i!=n;
}



Measured memory_bytes: 3092
n = int(input())
d = {}
li = ['AC', 'WA', 'TLE', 'RE']

for _ in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

for i in li:
    if i in d:
        print('{} x {}'.format(i, str(d[i])))
    else:
        print('{} x {}'.format(i, str(0)))


Measured memory_bytes: 74812
from collections import deque
d = deque()
N = int(input())
A = list(map(int, input().split()))

for a in range(N):
    if a % 2 == 0:
        d.append(A[a])
    else:
        d.appendleft(A[a])

if N % 2 == 0:
    print(*d)
else:
    d.reverse()
    print(*d)

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

using namespace std;

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

	int n;
	cin >> n;

	vector<int> a(n);
	for(int i = 0; i < n; ++i) {
		cin >> a[i];
	}

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

	int x = a[0];
	int y = a[n - 1];

	multiset<int> s;
	for(int i = 1; i < n - 1; ++i) {
		s.emplace(a[i]);
	}

	vector<int> b(n);
	b[0] = x;
	b[1] = y;
	for(int i = 2; i < n; ++i) {
		b[i] = x ^ y;
		if(s.find(b[i]) == s.end()) {
			cout << "No" << '\n';
			exit(0);
		}
		x = y;
		y = b[i];
		s.erase(s.find(b[i]));
	}

	for(int i = 0; i < n; ++i) {
		if((b[i] ^ b[(i + 1) % n]) != b[(i + 2) % n]) {
			cout << "No" << '\n';
			exit(0);
		}
	}

	cout << "Yes" << '\n';

	return 0;
}

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

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

void solve() {
    ll N;
    cin >> N;
    Vl A(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    Vl Acpy = A;
    sort(A.begin(), A.end());

    ll m1 = A[N / 2 - 1];
    ll m2 = A[N / 2];

    for (ll i = 0; i < N; i++) {
        if (Acpy[i] <= m1) {
            cout << m2 << "\n";
        }
        else {
            cout << m1 << "\n";
        }
    }
}

//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

int main() {
#ifdef FASTIO
    cin.tie(0), cout.tie(0);
    ios::sync_with_stdio(false);
#endif
#ifdef FILEINPUT
    ifstream ifs("./in_out/input.txt");
    cin.rdbuf(ifs.rdbuf());
#endif
#ifdef FILEOUTPUT
    ofstream ofs("./in_out/output.txt");
    cout.rdbuf(ofs.rdbuf());
#endif
    solve();
    cout << flush;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  set<string> memo;
  char p = '_';
  for (int i = 0; i < n; i++) {
    string s; cin >> s;
    if (p != '_' && p != s[0]) {
      cout << "No" << endl;
      return 0;
    }
    if (memo.find(s) != memo.end()) {
      cout << "No" << endl;
      return 0;
    }
    memo.insert(s);
    p = s[s.length() - 1];
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    bool ok = false;
    if (S[0] != 'A') {cout << "WA" << endl; return 0;}

    REP(i, 2, S.length() - 2) {
        if (S[i] == 'C' && !ok) ok = true;
        else if (S[i] == 'C' && ok) {cout << "WA" << endl; return 0;}

    }
    if (!ok) {cout << "WA" << endl; return 0;}
    rep(i, S.length()) {
        if (S[i] == 'A') continue;
        if (S[i] == 'C') continue;
        if (S[i] >= 'a' && S[i] <= 'z') continue;
        cout << "WA" << endl;
        return 0;
    }
    cout << "AC" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll mpow(ll x, ll n){ //x^n(mod M)
    ll ans = 1;
    while(n != 0){
        if(n&1) ans = ans*x % MOD;
        x = x*x % MOD;
        n = n >> 1;
    }
    return ans;
}

void solve()
{
    int n;
    scanf("%d", &n);
    int i;
    int cnt0 = 0;
    map<pair<ll, ll>, pair<int, int> > z;
    for (i = 0; i < n; i++) {
        ll x, y;
        scanf("%lld%lld", &x, &y);
        if (x == 0 && y == 0) {
            cnt0++;
        }
        else {
            if (y == 0) {
                z[make_pair(1, 0)].first++;
            }
            else if (x == 0) {
                z[make_pair(1, 0)].second++;
            }
            else {
                if (x < 0) {
                    x = -x; y = -y;
                }
                int flag = 0;
                if (y < 0) {
                    flag = 1;
                    y = -y;
                }
                ll d = gcd(x, y);
                x /= d; y /= d;
                if (flag == 0) {
                    z[make_pair(x, y)].first++;
                }
                else {
                    z[make_pair(y, x)].second++;
                }
            }
        }
    }

    ll ans = 1;
    auto it = z.begin();
    for (; it != z.end(); ++it) {
        int a = it->second.first;
        int b = it->second.second;
        
        ll tmp = (mpow(2, a) + mpow(2, b) - 1 + MOD) % MOD;
        ans = ans * tmp % MOD;
    }
    ans = (ans + cnt0 - 1 +MOD) % MOD;
    printf("%lld\n", ans);

    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


Measured memory_bytes: 15784
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
U = max(A)+1
L = 0


def can(x, K):
    ct = 0
    for i in range(N):
        ct += (A[i]-1)//x
    if ct <= K:
        return True
    else:
        return False


while U-L > 1:
    x = (U+L+1)//2
    if can(x, K):
        U = x
    else:
        L = x

print(U)


Measured memory_bytes: 104184
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    long n = scan.nextLong();
    long m = scan.nextLong();
    long limit = (long) m/n;
    long max = 1;
    int start = (int) Math.sqrt(m);
    for (int i=start;i>=1;i--){
      if (m%i == 0){
        int m1 = i;
        long m2 = (long) m/i;
        if (m2 > limit){
          m2 = -1;
        }
        if (m1 > limit){
          m1 = -1;
        }
        max = Math.max(max,m1);
        max = Math.max(max,m2);
      }
    }
    System.out.println(max);

  }

}


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

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

using namespace std;

inline int max(int a, int b) {
	if (b > a) swap(a, b);
	return a;
}

inline int min(int a, int b) {
	if (a > b) swap(a, b);
	return a;
}


int main() {
	int n, m;
	long long int sum = 0;
	cin >> n >> m;
	vector<long long int> card(n);
	vector<vector<long long int>> bc(m, vector<long long int>(2));
	rep(i, n) {
		cin >> card[i];
	}

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

	rep(i, m) {
		cin >> bc[i][0] >> bc[i][1];
	}

	sort(bc.begin(), bc.end(), [](auto& x, auto& y) {return x[1] > y[1]; });

	int j = 0;
	rep(i, m) {
		int change = 0;
		while ((j < n) && (change < bc[i][0])) {
			if (card[j] >= bc[i][1]) {
				j++;
				continue;
			}
			else {
				card[j] = bc[i][1];
				change++;
				j++;
			}
		}
		if (j >= n) {
			break;
		}
	}

	rep(i, n) {
		sum += card[i];
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 6528
import numpy as np
import sys
 
n = int(input())
l = np.array([int(x) for x in input().split()])
ans = 0
if 0 in l:
  for i in range(n):
    ans += abs(l[i])
  print(ans)
  sys.exit()
m = abs(l[0])
p = 0
for i in range(n):
  if l[i] < 0:
    p += 1
  if m > abs(l[i]):
    m = abs(l[i])
for i in range(n):
  ans += abs(l[i])
if p % 2 == 0:
  print(ans)
else:
  print(ans - m*2)

Measured memory_bytes: 23344
#include <queue>
#include <iostream>
using namespace std;
int main() {
    int n; cin >> n;
    int dist[n];
    fill(dist, dist+n, 100);
    priority_queue<pair<int, int> > pq;
    for (int i = 1; i < min(10, n); i++)
        if (dist[i] > i) {
            dist[i] = i;
            pq.push({-i, i});
        }
    while (!pq.empty()) {
        int d = -pq.top().first, r = pq.top().second;
        pq.pop();
        if (dist[r] < d) continue;
        for (int i = 0; i < 10; i++) {
            int r1 = (r * 10 + i) % n, d1 = d + i;
            if (dist[r1] > d1) {
                dist[r1] = d1;
                pq.push({-d1, r1});
            }
        }
    }
    cout << dist[0] << endl;
}


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

#define ran 111

char s[ran];

bool chk(int l, int r) {
	for(; l<r; l++, r--)
		if(s[l]!=s[r]) return false;
	return true;
}

int main() {
	scanf("%s", s);
	int n = strlen(s);
	puts(chk(0, n-1) && chk(0, n/2-1) ? "Yes" : "No");
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s=new Scanner(System.in);
		int a,b,c,n,i,temp,x,y;
		n=s.nextInt();
		for(i=0;i<n;i++){
			a=s.nextInt();
			b=s.nextInt();
			if(b>a){
				temp=a;
				a=b;
				b=temp;
			}
			c=s.nextInt();
			if(c>a){
				temp=a;
				a=c;
				c=temp;
			}
			x=a*a;y=b*b+c*c;
			if(x!=y)
				System.out.println("NO");
			else
				System.out.println("YES");
		}

	}

}

Measured memory_bytes: 12000
import java.util.*;

class Main{
    public static void main(String[] args){
        
        Scanner sc = new Scanner(System.in);

        String s = sc.next();
        int l = s.length();
        String ans = "";

        for(int i=0; i<l; i++){
            if(s.charAt(i)!='B'){
                ans += "" + s.charAt(i);
            }
            else if(s.charAt(i)=='B' && ans.length()>0){
                ans = ans.substring(0, ans.length() - 1);
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
int main(){
    int k;
    cin >> k;
    string str;
    cin >> str;
    int sz;
    sz = str.size();
    if(sz<=k){
        cout << str << endl;
    }else{
        for(int i=0; i<k; i++){
            cout << str[i];
        }
        cout << "..." << endl;
    }
}




Measured memory_bytes: 3624
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    long a;
    cin >> a;
    long minv = a;
    long maxv = a;
    for (int i = 1; i < n; i++) {
        cin >> a;
        if (a < minv) {
            minv = a;
        } else if (a > maxv) {
            maxv = a;
        }
    }
    cout << maxv - minv << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
ans = n
b = {}
c = {}
for i in range(0,len(a)):
    if i%2 == 0:
        b[a[i]] = b.get(a[i],0) + 1
    else:
        c[a[i]] = c.get(a[i],0) + 1
b = sorted(b.items(), key=lambda x: x[1])
c = sorted(c.items(), key=lambda x: x[1])

bk,bv = b[-1]
ck,cv = c[-1]
if ck != bk:
    ans = n-cv-bv
else:
    if bv > cv:
        ans -= bv
        cv = 0
        if len(c) > 1:
            ck,cv= c[-2]
        ans -= cv
    if bv < cv:
        ans -= cv
        bv = 0
        if len(b) > 1:
            bk,bv= b[-2]
        ans -= bv
    if bv == cv:
        ans -= cv
        if len(b) > 1 and len(c) > 1:
            bk,bv = b[-2]
            ck,cv = c[-2]
            ans -= max(bv,cv)
        else:
            if len(b) > 1:
                bk,bv = b[-2]
                ans -= bv
            elif len(c) > 1:
                ck,cv = c[-2]
                ans -= cv
print(ans)






#


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<bool> dislike(10, false);
    rep(i,k){
        int d;
        cin >> d;
        dislike[d] = true;
    }
    for(int i = n; i <= 999999; i++){
        int num = i;
        bool ok = true;
        while(num > 0){
            if(dislike[num%10]){
                ok = false;
                break;
            }
            num /= 10;
        }
        if(ok){
            cout << i << endl;
            return 0;
        }
    }
	return 0;
}

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

dp = [0]*N
dp[1] = abs(h[0]-h[1])

for i in range(N-2):
    dp[i+2] = min(dp[i]+abs(h[i]-h[i+2]), dp[i+1]+abs(h[i+1]-h[i+2]))

print(dp[N-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
long int n,a[100010],m=-1;
int main(){
	std::cin>>n;
	for(int i=0;i<n;i++)std::cin>>a[i];
	std::sort(a,a+n);
	for(int i=0;i<n-1;i++){a[i+1]+=a[i];if(a[i]*3<a[i+1])m=i;}
	std::cout<<n-m-1;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++)
        {
            cout<<i<<"x"<<j<<"="<<i*j<<"\n";
            
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int n; cin >> n;
	int p[1005];
	int M = 10007;
	for (int i = 1;i <= n;i++){
		char tmp; cin >> tmp;
		if(tmp == 'J') p[i] = 0;
		else if(tmp == 'O') p[i] = 1;
		else p[i] = 2;
	}

	int dp[1005][1<<3]; //日数, 出席者
	memset(dp,0,sizeof(dp));

	dp[0][1] = 1;

	for (int i = 0;i < n;i++){
		for (int j = 1;j < 1<<3;j++){
			for (int k = 1;k < 1<<3;k++){
				if((k>>p[i+1] & 1) == 0) continue;
				if((j&k) == 0) continue;
				dp[i+1][k] += dp[i][j];
				dp[i+1][k] %= M;
			}
		}
	}

	int ans = 0;

	for (int i = 0;i < 1<<3;i++){
		ans += dp[n][i];
		ans %= M;
	}

	cout << ans << endl;

	return 0;

}



Measured memory_bytes: 3196
//
/*==========================================================*/
/*    Template ver 2017-0720    |    Created by JollyBee    */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
const double EPS=(double)1e-9;
const double PI=(double)acos(-1.0);
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define FOR(i,n) for(int i=0;i<n;i++)
#define REPP(i,l,r,c) for(int i=l;i<=r;i+=c)
#define REP(i,l,r) REPP(i,l,r,1)
#define FORD(i,n) for(int i=n-1;i>=0;i--)
#define REVV(i,l,r,c) for(int i=l;i>=r;i-=c)
#define REV(i,l,r) REVV(i,l,r,1)
//random
int irand(int lo, int hi){
    return (((double)rand())/(RAND_MAX+1.0)) * (hi-lo+1) + lo;
}
//ll to string
string toString(ll x) {
    stringstream ss;
    ss << x;
    return ss.str();
}
//string to ll
ll toNumber(string S) {
    ll ret;
    sscanf(S.c_str(),"%lld",&ret);
    return ret;
}
// std::fill(start, end, value);
// for(auto it: DS){}

const int INF=(int)2e9;
const ll MOD=(ll)1e9+7;
/*==========================================================*/
/*                     END OF TEMPLATE                      */
/* DOMINUS pascit me, et nihil mihi deerit (Psalmorum 23:1) */
/*==========================================================*/

const int N = (int)1e5;

char s[N+5];

int main(){
    scanf("%s", s);
    int res = 0;
    for(int i=1; s[i]; i++) res += (s[i-1] != s[i]);
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>

#define MAX_N 101000

int isPrime[ MAX_N + 1 ] = { 0, 0, 1 };

void quickSort( int *, int, int );
int median( int, int, int );
void insertionSort( int *, int );

int main( void ) {
	int i, j, N, P, cnt, p[ 22 ], sum[ 253 ];

	for ( i = 3; i <= MAX_N; i += 2 )
		isPrime[ i ] = 1;

	for ( i = 3; i * i <= MAX_N; i += 2 )
		if ( isPrime[ i ] )
			for ( j = i * 2; j <= MAX_N; j += i )
				isPrime[ j ] = 0;

	for ( ; scanf( "%d %d", &N, &P ), N != -1; printf( "%d\n", sum[ P - 1 ] ) ) {
		cnt = 0;
		for ( i = N + 1; cnt < 22; i++ )
			if ( isPrime[ i ] )
				p[ cnt++ ] = i;

		cnt = 0;
		for ( i = 0; i < 22; i++ )
			for ( j = i; j < 22; j++ )
				sum[ cnt++ ] = p[ i ] + p[ j ];

		quickSort( sum, 0, 179 );
	}

	return 0;
}

void quickSort( int *data, int l, int r ) {
	if ( l < r ) {
		int i = l, j = r, pivot = median( data[ i ], data[ ( i + j ) / 2 ], data[ j ] ), tmp;

		while ( 1 ) {
			for ( ; data[ i ] < pivot; i++ ) ;
			for ( ; pivot < data [ j ]; j-- ) ;
			if ( i >= j )
				break;

			tmp = data[ i ];
			data[ i ] = data[ j ];
			data[ j ] = tmp;

			i++;
			j--;
		}

		if ( i - l < 20 )
			insertionSort( data + l, i - l );
		else
			quickSort( data, l, i - 1 );

		if ( r - j < 20 )
			insertionSort( data + j + 1, r - j );
		else
			quickSort( data, j + 1, r );
	}
}

int median( int x, int y, int z ) {
	if ( x < y )
		if ( y < z )
			return y;
		else if ( z < x )
			return x;
		else
			return z;
	else if ( z < y )
		return y;
	else if ( x < z )
		return x;
	else
		return z;
}

void insertionSort( int *data, int n ) {
	int i, j, tmp;

	for ( i = 1; i < n; i++ ) {
		tmp = data[ i ];

		for ( j = i; j && data[ j - 1 ] > tmp; j-- )
			data[ j ] = data[ j - 1 ];

		data[ j ] = tmp;
	}
}

Measured memory_bytes: 988
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
typedef vector<int> vi;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define Sort(a) sort(a.begin(), a.end())
const int INF = 1 << 30;
const ll MOD = 1000000007;
int K, S;
int main(void) {
  cin >> K >> S;
  int count = 0;
  for (int i = 0; i <= K; i++) {
    for (int j = 0; j <= K; j++) {
      if (S - i - j <= K && S - i - j >= 0) count++;
    }
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "2 3 9" ].parse.expand.solve == "No" );
	assert( [ "2 3 10" ].parse.expand.solve == "Yes" );
	
	assert( [ "249999999 250000000 999999998" ].parse.expand.solve == "Yes" );		// 追加ケース
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto abc = input.front.split.to!( long[] );
	return tuple( abc[ 0 ], abc[ 1 ], abc[ 2 ] );
}

auto solve( long a, long b, long c )
{
	// 小数点以下の誤差で死なないように、式変形して整数で計算する
	// √a + √b < √c
	// ( √a + √b ) ^^ 2 < √c ^^ 2
	// ( √a + √b )( √a + √b ) < c
	// a + 2√ab + b < c
	// 2√ab < c - a - b
	// 0 < ( c - a - b ) && 2√ab ^^ 2 < ( c - a - b ) ^^ 2
	// 0 < ( c - a - b ) && 4ab < ( c - a - b ) ^^ 2
	return ( 0 < ( c - a - b ) && 4 * a * b < ( c - a - b ) ^^ 2 ) ? "Yes" : "No";
}


Measured memory_bytes: 256
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var W = Number.parseInt(inputStr[0]);
  var H = Number.parseInt(inputStr[1]);
  var x = Number.parseInt(inputStr[2]);
  var y = Number.parseInt(inputStr[3]);
  var S = W  *  H / 2;
  //x,yが中心か否か
  if( x === W/2 && y === H/2){
   console.log(S, 1);	
  } else {
   console.log(S, 0);
  }
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7628
s = input()
t = input()


vals = []
for i in range(0, len(s) - len(t) + 1):
    q = s[i:i + len(t)]
    # print(t)

    cnt = 0
    for j in range(len(t)):
        # print(q[j])
        # print(t[j])
        if q[j] != t[j]:
            cnt += 1
        # print(cnt)

        # print(' --- ')

    vals.append(cnt)
    
print(min(vals))

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

using namespace std;
using ll = long long;

int main() {
    int N = 0;
    cin >> N;
    int K = 0;
    cin >> K;

    int ans = 0;
    int temp;
    for (size_t i = 0; i < N; i++)
    {
        cin >> temp;
        ans += min(abs(K-temp),abs(temp));
    }
    cout << ans*2 << endl;
    

    return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[100010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	int cnt=0;
	int m=0;
	REP(i,N-1){
		if(A[i]<A[i+1]){
			cnt=0;
		}
		else{
			cnt++;
			m=max(m,cnt);
		}
	}
	cout<<m<<endl;
	return 0;
}


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

const long long MAXN = 100100;
long long w[MAXN];
long long c[MAXN];
long long dp[110][100100];

int main() {
	long long n,x;
	cin>>n>>x;
    for(long long i=0;i<n;i++){
        cin>>w[i]>>c[i];
    }
    for(long long i=0;i<=n;i++){
        for(long long j=0;j<=x;j++){
            if(i==0||j==0){
                dp[i][j] = 0;
            }
            else if(w[i-1]<=j){
                dp[i][j] = max(dp[i-1][j],c[i-1]+dp[i-1][j-w[i-1]]);
            }else{
                dp[i][j] = dp[i-1][j];
            }
           // cout<<i<<" "<<j<<" "<<w[i-1]<<" "<<c[i-1]<<endl;
        }
    }
    cout<<dp[n][x];
	
}


Measured memory_bytes: 80128
#include<stdio.h>
int main() {

	int i, k, length, width;
	while (1) {
		scanf("%d %d", &length, &width);
		if (length == 0 && width == 0) {
			break;
		}
		for (i = 1; i <= length; i++) {
			if (i % 2 == 1) {
				for (k = 1; k <= width; k++) {
					if (k % 2 == 1) {
						printf("#");
					}
					else {
						printf(".");
					}
				}
				printf("\n");
			}
			else {
				for (k = 1; k <= width; k++) {
					if (k % 2 == 1) {
						printf(".");
					}
					else {
						printf("#");
					}
				}
				printf("\n");
			}
		}
         printf("\n");
	}
	return 0;
}


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

// エイリアス
using  ll = long signed long;
using ull = long unsigned long;
using  ld = long double;
using   P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;

// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
//const int mod = 1000000007;
const int mod = 998244353;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};

ll modpow(ll a, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int main()
{
  int n; cin >> n;
  vector<int> d(n);
  rep(i, n) cin >> d[i];
  vector<int> count(n);
  rep(i, n) ++count[d[i]];

  if(d[0] != 0 || count[0] != 1) {
    cout << 0 << endl;
    return 0;
  }

  int max_d = *max_element(ALL(d));
  for(int i = 1; i <= max_d; ++i) {
    if(count[i] == 0) {
      cout << 0 << endl;
      return 0;
    }
  }
  mint ans = 1;
  for(int i = 1; i <= max_d; ++i) {
    ans *= modpow(count[i-1], count[i]);
  }
  cout << ans.x << endl;
}


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

int main(){
    int N;
    cin >> N;
    int ans;
    ans = (N % 10);
    if (ans == 2 || ans == 4 || ans == 5 || ans == 7 || ans == 9)
    {
        cout << "hon";
    }
    else if (ans == 0 || ans == 1 || ans == 6 || ans == 8)
    {
        cout << "pon";
    }else
    {
        cout << "bon";
    }
}

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#define INF (long)1e9
#define MAX_N 10000000
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int t, d, l;
	while(cin >> t >> d >> l, t | d | l)
	{
		int cnt = 0;
		int b = -MAX_N;
		for(int i = 0; i < t; i++)
		{
			int x;
			cin >> x;
			if(i + 1 == t)
				continue;
			if(x >= l){
				b = i;
			}
			cnt += i - b<d;
		}
		cout << cnt << endl;
	}
	return 0;
}




Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
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; }

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 0; i < N; ++i) {
        chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
        chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#define ed cout<<"\n";
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

using namespace std;
int main(){
     SPEED;
     string s;
     cin>>s;
     s.insert(s.begin()+4,'8');
     s.erase(s.begin()+3);
     cout<<s;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define EPS 0.00000000001
#define INF 1000000000
int cnt[MAX];
int main()
{
    int n,i,q,b,c,d;
    scanf("%d",&n);
    long long temp,sum=0;
    int input=0;
    for(i=0;i<n;i++)
    {
        scanf("%d",&input);
        sum=sum+input;
        cnt[input]++;
    }
    scanf("%d",&q);
    for(i=0;i<q;i++)
    {
        scanf("%d %d",&b,&c);
        temp=c-b;
        temp=temp*cnt[b];
        sum=sum+temp;
        d=cnt[b];
        cnt[c]+=d;
        cnt[b]=0;
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 4140
import numpy as np

N, T = map(int, input().split())
data = []
for i in range(N):
  a, b = map(int, input().split())
  data.append((a,b))
data.sort()
data = np.array(data)

#print(data)

dp = np.zeros(T)
ans = 0
for a, b in data:
  ans = max(ans, dp[-1]+b)
  if a < T:
    newtable = dp[:T-a] + b
    dp[a:] = np.maximum(dp[a:], newtable)
print(int(ans))

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

int main(){
	int n, m; // n:purchase number, m:capacity of the bag
	std::cin >> n >> m;
	
	while(n != 0 || m != 0){
		std::vector<int> price; // price:the price of vegetable
		price.resize(n);
		for(int i = 0; i < n; ++i){
			std::cin >> price[i]; // input price
		}

		// sort in descending order
		std::sort(price.begin(), price.end(), std::greater<int>());

		int sum = 0; // sum:total amount
		for(int i = 0; i < n; ++i){
			if((i+1) % m != 0){ sum += price[i];}
		}

		std::cout << sum << std::endl; // output sum

		std::cin >> n >> m; 
	}
	return 0;
}

Measured memory_bytes: 1216
#include <iostream>
#include <map> 
using namespace std;
typedef long long ll;

int main()
{
	int n;
	cin>>n;
	map<string,int> mp;
	string ans[]={"AC","WA","TLE","RE"};
	
	for(int i=0; i<4; i++)
		mp[ans[i]]=0;
	for(int i=1; i<=n; i++)
	{
		string s;
		cin>>s;
		mp[s]++;
	}
	
	for(int i=0; i<4; i++)
		cout<<ans[i]<<" x "<<mp[ans[i]]<< endl;
	
	return 0;
}

Measured memory_bytes: 3620
n=int(input())
A=list(map(int,input().split()))
r=[]
def f(s,k):
    if k>=0:
        global r
        r+=[s]
        f(s+A[k-1],k-1)
        f(s,k-1)
f(0,n)
input()
for e in map(int,input().split()):print(['no','yes'][e in r])


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

int main() {
  int N, M, X, Y;
  cin >> N >> M >> X >> Y;
  int x[N], y[M];
  for (int i = 0; i < N; i++) cin >> x[i];
  for (int i = 0; i < M; i++) cin >> y[i];
  sort(x, x + N);
  sort(y, y + M);
  int Z = y[0];
  
  if (!(X < Z && Z <= Y)) {
    cout << "War" << endl;
    return 0;
  }
  
  for (int i : x) {
    if (!(i < Z)) {
      cout << "War" << endl;
      return 0;
    }
  }
  
  for (int i : y) {
    if(!(i >= Z)) {
      cout << "War" << endl;
      return 0;
    }
  }
  
  cout << "No War" << endl;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using namespace std;
long long f[100][10];
long long p[100][11];
long long d[10];
long long n;

int main() {
	string s, t;
	cin >> s >> t;
	int cnt = 0;
	string res = "";
	for (int i = s.size() - t.size(); i >= 0; i--) {
		for (int k = 0; k < i; k++) {
			if (s[k] == '?') {
				res += "a";
			}
			else {
				res += s[k];
			}
		}
		for (int j = 0; j < t.size(); j++) {
			if (s[j + i] == '?') {
				res += t[j];
			}
			else if (s[j + i] == t[j]) {
				res += t[j];
			}
			else {
				res = "";
				goto B;
			}
		}
		for (int k = i + t.size(); k < s.size(); k++) {
			if (s[k] == '?') {
				res += "a";
			}
			else {
				res += s[k];
			}
		}
		cout << res << endl;
		return 0;
	B:;
	}
	cout << "UNRESTORABLE" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
ll a[N],b[N];
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int n,m,k;
    scanf("%d %d %d",&n,&m,&k);
    range(i,1,n){
        scanf("%lld",&a[i]);
        a[i]+=a[i-1];
    }
    range(i,1,m){
        scanf("%lld",&b[i]);
        b[i]+=b[i-1];
    }
    int ans =0;
    range(i,1,n){
        if(a[i]>k)break;
        ll rem = k-a[i];
        int idx = upper_bound(b+1,b+m+1,rem)-b-1;
        ans = max(ans,i+idx);
    }
    range(i,1,m){
        if(b[i]>k)break;
        ll rem = k-b[i];
        int idx = upper_bound(a+1,a+n+1,rem)-a-1;
        ans = max(ans,i+idx);
    }
    printf("%d",ans);
    
    return 0;
}

Measured memory_bytes: 6940
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;

int main(void){
   string S;
   cin>>S;
   int N=S.size();
   vector<int> ans(N);
   for(int i=0;i<N;i++){
      if(S[i]=='R'&&S[i+1]=='L'){
         int rcnt=0,lcnt=0;
         int j=i;
         while(j>=0&&S[j]=='R'){
            j--;
            rcnt++;
         }
         j=i+1;
         while(j<N&&S[j]=='L'){
            j++;
            lcnt++;
         }
         ans[i]+=(rcnt+1)/2+lcnt/2;
         ans[i+1]+=(lcnt+1)/2+rcnt/2;
      }
   }
   for(int i=0;i<N;i++){
      if(i==N-1){
         cout<<ans[i]<<endl;
      }else{
         cout<<ans[i]<<" ";
      }
   }
   return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  string S; cin >> S;
  map<char, int> m{};
  for (const auto& c : S) {
    ++m[c];
  }
  for (const auto& p : m) {
    if (p.second % 2) {
      cout << "No" << CRLF;
      return;
    }
  }
  cout << "Yes" << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

using namespace std ;

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

    long long sum = 0 ;
    for( int i = 0 ; i < s.size() ; i++ )
        sum += ( s[ i ] - '0' ) ;

    if( sum % 9 == 0 )
        cout << "Yes" ;
    else
        cout << "No" ;
}



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

int main() {
  int n;
  cin >> n;
  vector<int> vec(n);
  for (int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  
  int sum = 0;
  
  for (int i = 1; i < n-1; i ++){
    if (vec.at(i-1) < vec.at(i) && vec.at(i) < vec.at(i+1)){
      sum++;
    }
    else if (vec.at(i+1) < vec.at(i) && vec.at(i) < vec.at(i-1)){
      sum++;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline #文字列入力のときは注意

n = int(input())
s = [input() for i in range(n)]

d = {}

ans = 0
for i in s:
    a = [c for c in i]
    a.sort()
    a = "".join(a)
    
    if a in d:
        ans += d[a]
        d[a] += 1
    else:
        d[a] = 1

print(ans)




Measured memory_bytes: 24980
package main

import (
	f "fmt"
)

func main() {

	var num int
	f.Scan(&num)
	array := map[int]int{}

	//arrayのkeyにtmpを指定する
	//その長さを求めれば良い
	for i := 0; i < num; i++ {
		var tmp int
		f.Scan(&tmp)
		array[tmp] = 1
	}

	f.Println(len(array))

}


Measured memory_bytes: 512
fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val (t,a) = readLine()!!.split(" ").map { it.toInt() }
    val h = readLine()!!.split(" ").map { t -  it.toInt() * 0.006 }.map { Math.abs(it - a) }
    val ans = h.indices.minBy { h[it] }!! +1
    println(ans)
}




Measured memory_bytes: 38252
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase

/*
cout<<fixed<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int A,B,C,X,Y,Z;cin>>A>>B>>C>>X>>Y;
	Z=min(X,Y);
	C*=2;
	mineq(A,C);
	mineq(B,C);
	mineq(C,A+B);
	cout<<(X-Z)*A+(Y-Z)*B+Z*C<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
cnt4 = 0
cnt2= 0
for x in a:
    if x%4 == 0:cnt4 +=1
    elif x%2 == 0:cnt2 +=1
odd = n-cnt4 - cnt2
ok = cnt4+1 >= odd
if cnt4+1 == odd:
    if cnt2 >0:ok = False
    
 

if ok:print('Yes')
else:print('No')

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  llong ans=0;
  llong h, w; cin >> h >> w;

  llong smax, smin;
  smax = 0;
  smin = 0;

  llong a, b, c;
  llong ah, bh, ch;
  llong aw, bw, cw;

  ah = h/3; aw = w;
  bh = (h-ah)/2; bw = w;
  ch = h-ah-bh; cw = w;
  a = ah*aw; b = bh*bw; c = ch*cw;
  smax = max(max(a, b), c);
  smin = min(min(a, b), c);
  ans = smax-smin;

  ah = h/3+1; aw = w;
  bh = (h-ah)/2; bw = w;
  ch = h-ah-bh; cw = w;
  a = ah*aw; b = bh*bw; c = ch*cw;
  smax = max(max(a, b), c);
  smin = min(min(a, b), c);
  ans = min(ans, smax-smin);

  ah = h/3; aw = w;
  bh = h-ah; bw = w/2;
  ch = bh; cw = w-bw;
  a = ah*aw; b = bh*bw; c = ch*cw;
  smax = max(max(a, b), c);
  smin = min(min(a, b), c);
  ans = min(ans, smax-smin);

  ah = h/3+1; aw = w;
  bh = h-ah; bw = w/2;
  ch = bh; cw = w-bw;
  a = ah*aw; b = bh*bw; c = ch*cw;
  smax = max(max(a, b), c);
  smin = min(min(a, b), c);
  ans = min(ans, smax-smin);

  ah = h; aw = w/3;
  bh = h; bw = (w-aw)/2;
  ch = h; cw = w-aw-bw;
  a = ah*aw; b = bh*bw; c = ch*cw;
  smax = max(max(a, b), c);
  smin = min(min(a, b), c);
  ans = min(ans, smax-smin);

  ah = h; aw = w/3+1;
  bh = h; bw = (w-aw)/2;
  ch = h; cw = w-aw-bw;
  a = ah*aw; b = bh*bw; c = ch*cw;
  smax = max(max(a, b), c);
  smin = min(min(a, b), c);
  ans = min(ans, smax-smin);

  ah = h; aw = w/3;
  bh = h/2; bw = w-aw;
  ch = h-bh; cw = bw;
  a = ah*aw; b = bh*bw; c = ch*cw;
  smax = max(max(a, b), c);
  smin = min(min(a, b), c);
  ans = min(ans, smax-smin);

  ah = h; aw = w/3+1;
  bh = h/2; bw = w-aw;
  ch = h-bh; cw = bw;
  a = ah*aw; b = bh*bw; c = ch*cw;
  smax = max(max(a, b), c);
  smin = min(min(a, b), c);
  ans = min(ans, smax-smin);

  cout << ans << endl;
}

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


Measured memory_bytes: 256
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define EACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<class Value>using vec = vector< Value >;
using ll = long long;
using P = pair< long long, long long >;
#define fi first
#define se second
#define el endl
#pragma endregion


void Main();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    ll N, K;
    cin >> N >> K;
    ll sum = 0;
    REP(i, N){
        ll x;
        cin >> x;
        sum += 2*min(x, K-x);
    }
    cout << sum << el;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fr first
#define se second
#define r_0 return 0
#define ll long long
#define pb push_back
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long INF = 1e7;
const long long N = 1e6 + 7;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;

ll T = 1, n, q, m, b, ans, a, cnt;
string s;
char c, g;
vector < ll > v, v1;
set< char > st;
deque<char> D;
int main(){
    TIME
    cin >> s;
    for( ll i = 0; i < s.size(); i ++ )
    {
        D.pb( s[i] );
    }
    cin >> T;
    while ( T -- ){
        cin >> n;
        if ( n == 2 ){
            cin >> m >> c;
            if ( q % 2 == 0 ){
                if ( m == 1 ){
                    D.push_front( c );
                }
                else{
                    D.pb( c );
                }
            }
            else if ( q % 2 == 1 ){
                if ( m == 1 ){
                    D.pb( c );
                }
                else{
                    D.push_front( c );
                }
            }
        }
        if ( n == 1 )
            q ++;
    }
    if ( q % 2 == 1 )
        for ( int i=D.size() - 1; i>=0; i-- )
            cout << D[i];
    else {
        for ( auto it:D )
            cout << it;
    }
}


Measured memory_bytes: 976