akhauriyash/Code-Regression huggingface dataset:
Module Program
    Sub Main(args As String())
        Dim iInput As Integer = Console.ReadLine()

        If {2, 4, 5, 7, 9}.Contains(Right(iInput, 1)) Then
            Console.WriteLine("hon")
        ElseIf {0, 1, 6, 8}.Contains(Right(iInput, 1)) Then
            Console.WriteLine("pon")
        Else
            Console.WriteLine("bon")
        End If
    End Sub
End Module

Measured memory_bytes: 28720
n,q =map(int,input().split())
s = input()
resu = [0]
ans = 0
for i in range(n-1):
	if s[i] == "A" and s[i+1] == "C":
		ans +=1
		resu.append(ans)
	else:
		resu.append(ans)
for i in range(q):
	l,r = map(int,input().split())
	print(resu[r-1]-resu[l-1])

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

constexpr double pi = 3.141592653589793;

double solve(int x1, int y1, int x2, int y2, int N, const vector<pair<int, int>> & XYs){
    if (x1 > x2){
        swap(x1, x2);
        swap(y1, y2);
    }
    int maxy = max(y1, y2);
    int miny = min(y1, y2);
    vector<pair<int, int>> xys;
    for (const auto & xy : XYs){
        if (xy.first < x1 or xy.first > x2 or xy.second < miny or xy.second > maxy) continue;
        xys.push_back(xy);
    }
    sort(xys.begin(), xys.end());
    if (y1 > y2) reverse(xys.begin(), xys.end());
    vector<int> LIS = {-1};
    for (const auto & xy : xys){
        if (LIS.back() < xy.second){
            LIS.push_back(xy.second);
        }else{
            auto it = upper_bound(LIS.begin(), LIS.end(), xy.second);
            assert(*it > xy.second);
            *it = xy.second;
        }
    }
    int n = LIS.size() - 1;
    int m = min(x2 - x1, maxy - miny) + 1;
    double d = 100.0 * ((x2 - x1) + (maxy - miny)) - n * 5 * (4 - pi);
    if (n == m) d += 5 * pi;
    return d;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int N;
    cin >> N;
    vector<pair<int, int>> XYs(N);
    for (auto & xy: XYs) cin >> xy.first >> xy.second;
    cout.precision(12);
    cout << fixed << solve(x1, y1, x2, y2, N, XYs) << endl;
    return 0;
}

Measured memory_bytes: 5232
import numpy as np
n, m, q = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(q)]
# print(lst)
def point(A):
    point = 0
    for i in lst:
        if A[i[1]] - A[i[0]] == i[2]:
            point += i[3]
    return point

def solve(A):
    length = len(A) - 1
    if length == n:
        return point(A)
    o = A[length]
    ans = 0
    for i in range(o, m+1):
        ans = max(ans, solve(A + [i]))
    return ans
print(solve([1]))

Measured memory_bytes: 27024
// #include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <set>
#include <queue>
#include <cstdio>
#include <stack>
#include <list>
using namespace std;
#define rep(i, n) for(int i=0;i<n;i++)
#define irep(i, n) for(int i=n-1;i>=0;i--)
#define lrep(i, n) for(long long i=0;i<n;i++)
typedef long long ll;
typedef vector<long long> llv;
typedef vector<vector<long long> > llvv;
template <class T> T gcd(T n, T m){return m ? gcd(m, n%m):n;}

const int N = 2010;
const int MOD = 1e9+7;
int L[N][N];
int R[N][N];
int U[N][N];
int D[N][N];

int main(){
    int n,m;
    cin>>n>>m;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    ll ans=0;
    rep(i,n){
        ans+=a[i];
    }
    sort(a.begin(),a.end());
    vector<pair<ll,ll> > bc(m);
    rep(i,m){
        cin>>bc[i].second>>bc[i].first;
    }
    sort(bc.begin(), bc.end());
    reverse(bc.begin(), bc.end());
    int idx=0;
    rep(i,m){
        rep(j,bc[i].second){
            if(bc[i].first>a[idx]){
                ans-=a[idx++];
                a.push_back(bc[i].first);
                ans+=bc[i].first;
            }else break;
        }
    }
    cout << ans << endl;
}


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

int main() 
{
    int  x, ans;
    cin >> x;
	if (x==1)
	{
		cout << 1;
		return 0;
	}
    for (int i=2; i<=x; i++)
    {
		int a = i,b=i;
		for (int j=2; j*j<=b; j++)
		{
			while (a%j == 0)
				a/=j;
			if (a==1)
				ans = i;
			a=b;
		}
    }
    cout << ans;
    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

signed main(){
	int N,Q;
	scanf("%lld%lld",&N,&Q);
	string S;cin>>S;

	vint acc(N+1);
	rep(i,N){
		if(i+1<N&&S.substr(i,2)=="AC")acc[i+1]++;
		acc[i+1]+=acc[i];
	}

	while(Q--){
		int l,r;
		scanf("%lld%lld",&l,&r);
		l--;
		r--;
		printf("%lld\n",acc[r]-acc[l]);
	}
	return 0;
}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")
int box[110000];
bool flag[110000];
int main()
{
	int N, M;
	cin >> N >> M;
	fx(N) {
		box[x + 1] = 1;
	}
	flag[1] = true;
	fz(M) {
		int x, y;
		cin >> x >> y;
		if (flag[x]) {
			flag[y] = true;
			box[x]--;
			box[y]++;
			if (box[x]==0) {
				flag[x] = false;
			}
		}
		else {
			box[x]--;
			box[y]++;
		}
	}
	int ans = 0;
	fx(N) {
		ans += flag[x + 1];
	}
	ce(ans)

    return 0;
}



Measured memory_bytes: 768
import java.util.Map;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        int[] a = new int[n];
        long[] b = new long[n];
        Map<Integer, Long> map = new TreeMap<>();
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextLong();
            map.put(a[i], map.getOrDefault(a[i], 0L) + b[i]);
        }
        long sum = 0;
        for (Integer key : map.keySet()) {
            sum += map.get(key);
            if (sum >= k) {
                System.out.println(key);
                return;
            }
        }
    }

}


Measured memory_bytes: 89924
import sys
input = sys.stdin.readline
def main():
    NUM = list(input().rstrip())
    NUM_I = [int(i) for i in NUM]
    ps = [1, 1, 1]

    for i in range(8):
        for j in range(3):
            if (i >> j) & 1:
                ps[j] = -1
                # print(ps)
                # print('IN')
            else:
                ps[j] = 1
            ans = NUM_I[0] + ps[0]*NUM_I[1] + ps[1]*NUM_I[2] + ps[2]*NUM_I[3]
            if ans == 7:
                ps_s = ['+' if i>0 else '-' for i in ps]
                # print(ps_s)
                ans_s = [NUM[0]]
                for i in range(3):
                    ans_s.append(ps_s[i])
                    ans_s.append(NUM[i+1])
                ans_s.append('=7')
                print(''.join(ans_s))
                return

if __name__ == '__main__':
    main()

Measured memory_bytes: 9188
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define EXIST(c,e) ( (c).find( e ) != (c).end() )
#define INF 1<<30
#define mp make_pair
#define pb push_back

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
typedef vector<pair<int, int> > vp;
typedef map<int,int> mpii;
typedef priority_queue<int, vi, greater<int> > pqi;

typedef long long ll;


int main(){
	int n,a; cin>>n>>a;
	if(n%500 <= a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int N; cin >> N;
    int A[100100];
    rep(i, N) {
        int a;
        cin >> a;
        A[i] = (-1) * a;
    }
    int ans = 0;
    set<int> b;
    map<int, int> mp;
    b.insert(A[0]);
    mp[A[0]] ++;
    ans ++;
    rep1(i, N - 1) {
        auto ite = b.upper_bound(A[i]);
        if(ite == b.end()) {
            b.insert(A[i]);
            mp[A[i]] ++;
            ans ++;
        } else {
            if(mp[*ite] != 1) {
                mp[*ite] --;
            } else if(mp[*ite] == 1) {
                b.erase(ite);
                mp[*ite] = 0;
            }
            b.insert(A[i]);
            mp[A[i]] ++;
        }
    }
    cout << ans << endl;
	return 0;
}


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

struct P {
	int id;
	int score;
	bool operator < (const P &t) const {
		if (score != t.score) return score > t.score;
		return id < t.id;
	}
	P(int id, int score): id(id), score(score){}
};

int n;

int main()
{
	while (scanf("%d", &n), n){
		vector<P> ps;
		for (int c = 0; c < n; c++){
			int id;
			scanf("%d", &id);
			
			int score = 0;
			int t = 0;
			int sp = 0;
			int st = 0;
			while (t < 10){
				if (t == 9){
					int a[3] = {};
					int m = 2;
					for (int i = 0; i < m; i++){
						scanf("%d", &a[i]);
						score += a[i] * (1 + sp + st);
						sp = st;
						st = 0;
						if (i == 1 && a[0] + a[1] >= 10) m++;
					}
					t++;
					continue;
				}
				
				int a;
				scanf("%d", &a);
				
				score += a * (1 + sp + st);
				sp = st;
				st = 0;
				
				if (a == 10){
					st++;
					t++;
					continue;
				}
				
				int b;
				scanf("%d", &b);
				
				score += b * (1 + sp + st);
				sp = st;
				st = 0;
				
				
				if (a + b == 10) sp++;
				t++;
			}
			
			ps.push_back(P(id, score));
		}
		
		sort(ps.begin(), ps.end());
		for (int i = 0; i < n; i++){
			printf("%d %d\n", ps[i].id, ps[i].score);
		}
	}
	return 0;
}

Measured memory_bytes: 1192
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    n = f()[0]
    a = f()
    
    suma = [0] * n
    minop = 1e15

    for greater in [True, False]:
        oper = 0
        greater0 = greater
        for i in range(n):
            if i == 0:
                suma[i] = a[i]
            else:
                suma[i] = a[i] + suma[i-1]
            
            greater0 = not greater0
            
            if greater0 and suma[i]<=0:
                oper +=  1 - suma[i]
                suma[i] = 1
                continue
            
            if (not greater0) and suma[i]>=0:
                oper += 1 + suma[i]
                suma[i] = -1
                continue

        minop = min(minop, oper)
    
    print(minop)
            
solve()


Measured memory_bytes: 14468
#include<iostream>

using namespace std;

int main()
{
	string s;
	cin >> s;
	bool tes1,tes2;
	tes1 = false;
	tes2 = false;
	if(s[0] == '0')
	{
		if(s[1] != '0')
		{
		tes1 = true;
		}
	}
	else if(s[0] =='1')
	{
		if((s[1] == '0') or (s[1] == '1') or (s[1] == '2'))
		{
			tes1 = true;
		}
	}
		if(s[2] == '0')
	{
		if(s[3]!='0')
		{
		tes2 = true;
		}
	}
	else if(s[2] =='1')
	{
		if((s[3] == '0') or (s[3] == '1') or (s[3] == '2'))
		{
			tes2 = true;
		}
	}
	if((tes1) and (tes2))
	{
		cout << "AMBIGUOUS" << endl;
	}
	else if(tes1)
	{
		cout << "MMYY" << endl ;
	}
	else if(tes2)
	{
		cout << "YYMM" << endl;
	}
	else
	{
		cout << "NA" << endl;
	}
}

Measured memory_bytes: 256
# coding: utf-8
n=int(input())
data=list(map(int,input().split()))
index=0
ans=1
v=0
while index<len(data):
    if index+1<len(data):
        if data[index]==data[index+1]:
            pass
        elif data[index]<data[index+1]:
            if v==1 or v==0:
                v=1
            else:
                ans+=1
                v=0
        else:
            if v==-1 or v==0:
                v=-1
            else:
                ans+=1
                v=0
    index+=1
print(ans)

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

int main(){
  int N;
  cin>>N;
  vector<int> p(N);
  int ans=0;
  for(int i=0;i<N;i++){
    cin>>p.at(i);
    ans+=p.at(i);
  }
  sort(p.begin(),p.end());
  ans-=p.at(N-1)/2;
  cout<<ans<<endl;



  return 0;
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> a(5);
  for (int i = 0; i < 5; i++) {
    cin >> a[i];
    if (a[i] == 0) cout << i + 1 << '\n';
  }

  return 0;
}

Measured memory_bytes: 3652
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = long.Parse(Console.ReadLine());
        char[] s = Console.ReadLine().ToCharArray();

        var ans = long.MaxValue;

        long[] b = new long[n];
        long[] w = new long[n];
        if (s[0] == '.') w[0] = 1;
        if (s[0] == '#') b[0] = 1;
        for (int i = 1; i < n; i++)
        {
            if (s[i] == '.') w[i] = w[i - 1] + 1;
            else w[i] = w[i - 1];

            if (s[i] == '#') b[i] = b[i - 1] + 1;
            else b[i] = b[i - 1];
        }

        ans = Math.Min(ans, w[n - 1]);
        ans = Math.Min(ans, b[n - 1]);
        for (int i = 0; i < n; i++)
        {
            var a = (b[n - i - 1]);
            var c = (w[n - 1] - w[n - i - 1]);
            ans = Math.Min(ans, (b[n - i - 1]) + (w[n - 1] - w[n - i - 1]));
        }


        // 出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 31760
//~ while (clock()<=69*CLOCKS_PER_SEC)
//~ #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("-Ofast","-funroll-all-loops","-ffast-math")
//~ #pragma GCC target ("avx2")
//~ #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <random>
#include <cmath>
#include <chrono>
#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
using LL = long long;
#define eps 1e-8
#define fi first
#define se second
#define endl '\12'
#define eb emplace_back
#define SZ(a) int(a.size())
#define ALL(x) (x).begin(),(x).end()
#define trav(a,x) for (auto& a: x)
#define LOG(FMT...) fprintf(stderr, FMT)
#define close std::ios::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define FOR(i, x, y) for (LL i = (x), _##i = (y); i < _##i; ++i)
#define FORD(i, x, y) for (LL i = (x), _##i = (y); i > _##i; --i)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define CASET int ___T; cin>>___T; for(int __CS=1;__CS<=___T;__CS++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pii;
constexpr int mod = 1e9+7;
constexpr int Erica = 998244353;
mt19937 dlsrand(random_device{}());
mt19937 mrand(std::chrono::system_clock::now().time_since_epoch().count()); 
int rnd(int x) { return mrand() % x;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll ex_gcd(ll a, ll b, ll& x, ll& y){if(!b){x=1;y=0;return a;}int ret=ex_gcd(b,a%b,y,x);y-=a/b*x;return ret;}
LL bin(LL x, LL n, LL MOD) {LL ret = MOD != 1;for (x %= MOD; n; n >>= 1, x = x * x % MOD)if (n & 1) ret = ret * x % MOD;return ret;}
int norm(int x) { return x >= mod ? (x - mod) : x; }
inline LL get_inv(LL x, LL p) { return bin(x, p - 2, p); }
inline ll get_inv(ll a) { ll x, y; ex_gcd(a, mod, x, y); return norm(x + mod);}
template<class T>inline void umin(T &x, T y) {x = x > y ? y : x;}
template<class T>inline void umax(T &x, T y) {x = x < y ? y : x;}
template<class T>inline void dec(T &x, T y) {x -= y; if(x < 0) x += mod;}
template<class T>inline void add(T &x, T y) {x += y; if(x >= mod) x -= mod;}
const double PI = acos(-1.0);
constexpr int maxn = 1e6+10;
constexpr int INF = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3f;
constexpr ull base=2333, P_1=19260817, P_2=999998639;
bool chk(int x){
    string s = to_string(x);
    for(int i = 0; i < s.size() && 2*i <= s.size(); i++){
        if(s[i] != s[s.size() - 1 - i]) return 0;
    }
    return 1;
}
int main()
{
    int a , b , cnt = 0;
    cin >> a >> b;
    for(int i = a; i <= b; i++) if(chk(i)) cnt++;
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3740
import itertools

n = int(input())
p = input().split()
q = input().split()
a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
b = a[:n]
p2 = str(p).strip("[]\'")
p3 = p2.replace("\'", "")
q2 = str(q).strip("[]\'")
q3 = q2.replace("\'", "")

cnt = 0
cnta, cntb = 0, 0
for i in itertools.permutations(b, n):
    cnt += 1
    if str(i).strip('()') == p3:
        cnta = cnt
    if str(i).strip('()') == q3:
        cntb = cnt
print(abs(cnta - cntb))


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

#define all(v) (v).begin(),(v).end()

using namespace std ;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;




int main()
{
  int n, i ;
  cin >> n >> i ;
  
  cout << n-i+1 <<endl ;
    return 0 ;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
unsigned long xor_x=88172645463325252ULL;
unsigned long rng()
{
	xor_x^=xor_x<<7;
	return xor_x^=xor_x>>9;
}
int D;
int c[26],s[365][26];
int t[365],now;
int anst[365],ans;
void calc()
{
	int lst[26];
	for(int i=0;i<26;i++)lst[i]=-1;
	now=0;
	for(int i=0;i<D;i++)
	{
		now+=s[i][t[i]];
		lst[t[i]]=i;
		for(int j=0;j<26;j++)now-=c[j]*(i-lst[j]);
	}
}
int change(int d,int q)
{
	int ret=0;
	ret-=s[d][t[d]];
	ret+=s[d][q];
	{
		int r=d+1;
		while(r<D&&t[r]!=t[d])r++;
		int l=d-1;
		while(l>=0&&t[l]!=t[d])l--;
		ret-=c[t[d]]*(r-d)*(d-l);
	}
	{
		int r=d+1;
		while(r<D&&t[r]!=q)r++;
		int l=d-1;
		while(l>=0&&t[l]!=q)l--;
		ret+=c[q]*(r-d)*(d-l);
	}
	return ret;
}
main()
{
	cin>>D;
	for(int i=0;i<26;i++)cin>>c[i];
	for(int i=0;i<D;i++)for(int j=0;j<26;j++)cin>>s[i][j];
	for(int i=0;i<D;i++)
	{
		anst[i]=t[i]=rng()%26;
	}
	calc();
	ans=now;
	for(int tm=0;tm<3000;tm++)
	{
		while(true)
		{
			int d=rng()%D,q=rng()%26;
			int ret=change(d,q);
			if(ret>=0)
			{
				now+=ret;
				t[d]=q;
				break;
			}
		}
		for(int k=0;k<3000;k++)
		{
			int d1=rng()%(D-1)+1,d2=rng()%d1;
			int pt1=t[d1],pt2=t[d2];
			int diff=0;
			diff+=change(d1,pt2);
			t[d1]=pt2;
			diff+=change(d2,pt1);
			t[d2]=pt1;
			if(diff>=0)
			{
				now+=diff;
			}
			else
			{
				t[d1]=pt1;
				t[d2]=pt2;
			}
		}
		if(ans<=now)
		{
			ans=now;
			for(int i=0;i<D;i++)anst[i]=t[i];
		}
		else
		{
			now=ans;
			for(int i=0;i<D;i++)t[i]=anst[i];
		}
	}
	for(int i=0;i<D;i++)cout<<anst[i]+1<<endl;
	cerr<<ans<<endl;
}

Measured memory_bytes: 3644
#include<iostream>
using namespace std;
  
int main(){
int x, h, m, s;
cin >> x;
h = x / 3600;
m = (x - h * 3600) / 60;
s = x - ( m * 60 ) - ( h * 3600);
cout << h << ":" << m << ":" << s << endl;
return 0;
}

Measured memory_bytes: 1164
#include<iostream>
using namespace std;
int main()
{
  string s,ans;
  int n;
  cin>>s;
  n=s.size();
  if(s[n-1]=='s')
  {
    ans=s+"es";
  }
  else
  {
    ans=s+'s';
  }
  cout<<ans<<"\n";
}

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    ll a[x], b[y], c[z];
    rep(i, x) cin >> a[i];
    rep(i, y) cin >> b[i];
    rep(i, z) cin >> c[i];
  
    vector<ll> v_12, v;
    rep(i, x) rep(j, y) v_12.push_back(a[i] + b[j]);
    sort(v_12.rbegin(), v_12.rend());
    rep(i, min(k, x * y)) rep(j, z) v.push_back(v_12[i] + c[j]);
    sort(v.rbegin(), v.rend());
    rep(i, k) cout << v[i] << endl;
    return 0;
}

Measured memory_bytes: 43364
item = gets.chomp.split(/\s+/)
s = item[0]
t = item[1]

item = gets.chomp.split(/\s+/).map { |e| e.to_i }
a = item[0]
b = item[1]

color = gets.chomp

if color == s
  a -= 1
end
if color == t
  b -= 1
end

puts "#{a} #{b}"


Measured memory_bytes: 1916
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using M=modint998244353;
int N,K,p;
main()
{
	cin>>N>>K>>p;
	fenwick_tree<M>A(N),B(N);
	M s=0,X=M(K-1)/K;
	for(int j=1;j<N;j++)
	{
		A.add(--p,X/X.pow(max(j,K)));
		B.add(p,1);
		cin>>p;
		s+=(A.sum(0,p)-A.sum(p,N))*X.pow(max(j,K-1))/2+B.sum(p,N);
	}
	cout<<s.val();
}

Measured memory_bytes: 4880
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
  return (x*y)//gcd(x,y)

N, M=map(int, input().split())
A=list(map(int, input().split()))
B=[0 for _ in range(N)]
for i in range(N):
  tmp=A[i]
  while True:
    if tmp%2==1:
      break
    B[i]+=1
    tmp=tmp//2
flag=True
for i in range(N-1):
  if B[i]!=B[i+1]:
    flag=False
    break
ans=0
if flag:
  A=[a//2 for a in A]
  lcm=reduce(lcm_base, A, 1)
  ans=1+(M-lcm)//(2*lcm)
print(ans)

Measured memory_bytes: 16236
/*There's a possibility*/
/*but stop sucking first*/
#define dbg(...) ; 
#define db(...) ; 
#include "bits/stdc++.h"
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define f(i,a,b) for(i=a;i<b;i++)
#define fr(i,a,b) for(i=a;i>=b;i--)
#define endl '\n'
#define tst cout<<'*';
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define pf push_front
using namespace std;
 
vector<int> v[100005];
int visited[100005],dp[100005];

int fun(int x)
{
    visited[x]=1;
    for(auto y:v[x])
    {
        if(!visited[y])
            fun(y);
        dp[x]=max(dp[x],1+dp[y]);
    }
    return dp[x];
}

int main()
{
    fast;
    int n,m,x,y,i,ans=0;
    cin>>n>>m;
    f(i,0,m)
        cin>>x>>y,v[x].pb(y);

    f(i,1,n+1)
        if(!visited[i])
            ans=max(ans,fun(i));

    cout<<ans;
}

Measured memory_bytes: 12480
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(){

	string w;
	cin >> w;

	vector<int> alp(26);
	for(int i=0;i<w.size();i++){
		alp[ w[i]-'a' ]++;
	}

	for(int i=0;i<alp.size();i++){
		if( alp[i] % 2 != 0 ){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

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

#define Fast            ios_base::sync_with_stdio(false);cin.tie(nullptr);
#define LL              long long
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define all(a)          a.begin(),a.end()
#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b and b!=c) cout << "Yes";
    else if(a==c and c!=b) cout << "Yes";
    else if(b==c and a!=b) cout << "Yes";
    else cout << "No";
}



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

from typing import Tuple
from typing import List


Coordinate = Tuple[int, int, int]


def main():
    N = int(input())
    codList: List[Coordinate] = [(0, 0, 0)]
    for i in range(0, N):
        args = list(map(lambda x: int(x), input().split()))
        codList.append((args[0], args[1], args[2]))

    for i in range(1, N + 1):
        start = codList[i - 1]
        end = codList[i]
        dis = distance(start, end)
        duration = end[0] - start[0]

        if (duration - dis >= 0) and ((duration - dis) % 2 == 0):
            continue
        else:
            print("No")
            return

    print("Yes")


def distance(cod1: Coordinate, cod2: Coordinate):
    return abs(cod1[1] - cod2[1]) + abs(cod1[2] - cod2[2])


if __name__ == "__main__":
    main()


Measured memory_bytes: 23388
#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=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  string s;

  cin >> s;

  s.erase(s.size() - 1, 1);

  int ans = 0;
  REP (i, int(s.size())) {
    FOR (j, 1, int(s.size())) {
      if (i + j <= int(s.size())) {
        if (s.substr(i, j) == s.substr(i + j, j)) ans = max(ans, j);
      }
    }
  }

  printf("%d\n",ans * 2);
}


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

typedef pair<int, int> Pii;

class union_find final
{
    using data_type = int64_t;
    using size_type = uint64_t;

    static constexpr data_type none = -1;

    // data_[index]の値が親要素を表す(noneはroot)
    std::vector<data_type> data_;
    // rootの集合
    std::set<data_type> roots_;
    // そのグループの要素の数
    std::vector<size_type> size_;

    // indexのrootを求める
    data_type root(data_type index)
    {
        // グループ番号がnoneならそれがroot
        if(data_[index] == none)
            return index;
        // 親へのindexをrootに付け替える(高速化)
        data_[index] = root(data_[index]);
        return data_[index];
    }
public:

    union_find(data_type size)
        : data_(size, none), size_(size, 1)
    {
    }

    // aとbを同じグループにする
    void unite(data_type a, data_type b)
    {
        a = root(a);
        b = root(b);
        
        // aとbのrootが同じならすでに同じグループ
        if(a == b) return;
        
        // 要素の多い方に付け替える(高速化)
        if(size_[a] < size_[b]) {
            data_[b] = a;
            size_[a] = size_[a] + size_[b];
            roots_.erase(b);
            roots_.insert(a);
        } else {
            data_[a] = b;
            size_[b] = size_[a] + size_[b];
            roots_.erase(a);
            roots_.insert(b);
        }
    }

    bool is_union(data_type a, data_type b)
    {
        return root(a) == root(b);
    }
    
    // ↓あると便利なの

    const std::set<data_type>& roots() const
    {
        return roots_;
    }

    size_type maximum() const
    {
        return *std::max_element(size_.begin(), size_.end());
    }
    size_type minimum() const
    {
        return *std::min_element(size_.begin(), size_.end());
    }
};

void readline(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str());
}
void readline(int N, vector<double> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atof(s.c_str());
    }
    getline(cin, s, '\n');
    a[N - 1] = atof(s.c_str());
}
void readindex(int N, vector<int> &a){
    string s;
    for(int i = 0; i < N - 1; i++){
        getline(cin, s, ' ');
        a[i] = atoi(s.c_str()) - 1;
    }
    getline(cin, s, '\n');
    a[N - 1] = atoi(s.c_str()) - 1;
}

signed main(){

    int N, M;
    cin >> N >> M;
    vector<int> p(N);
    readindex(N, p);

    union_find t(N);

    int x, y;
    REP(i, M){
        cin >> x >> y;
        t.unite(x - 1, y - 1);
    }

    int ans = 0;

    REP(i, N){
        if(t.is_union(i, p[i])) ans++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;
    rep(i, 0, 2 * s.size()){
        string u = "";
        u += s[s.size() - 1];
        u += s.substr(0, s.size() - 1);
        s = u;
        if(u == t){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

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

signed main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; ++i)cin >> a[i];
	for (auto& x : a)x = -x;
	multiset<int> dp;
	for (int i = 0; i < n; ++i) {
		auto it = dp.upper_bound(a[i]);
		if (it == dp.end())dp.insert(a[i]);
		else {
			dp.erase(it);
			dp.insert(a[i]);
		}
	}
	cout << dp.size() << endl;
}

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

using namespace std;

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

    int n, k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i = 0; i < n; i++)
        cin >> p[i];
    sort(p.begin(), p.end());
    int minPrice = 0;
    for(int i = 0; i < k; i++)
        minPrice += p[i];
    cout << minPrice;

    return 0;
}


Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;
const int INF=1e9;

double dp[310][310][310];
int n;

double dfs (int i,int j,int k){
	if(dp[i][j][k]!=-1) return dp[i][j][k];
	double ret=n;
	if(i-1>=0) ret+=i*dfs(i-1,j,k);
	if(j-1>=0) ret+=j*dfs(i+1,j-1,k);
	if(k-1>=0) ret+=k*dfs(i,j+1,k-1);
	ret/=(double)(i+j+k);
	return dp[i][j][k]=ret;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n;
	int a=0,b=0,c=0;
	rep(i,n){
		int x;
		cin>>x;
		if(x==1) a++;
		else if(x==2) b++;
		else c++;
	}
	rep(i,310)rep(j,310)rep(k,310) dp[i][j][k]=-1;
	dp[0][0][0]=0;
	cout<<setprecision(10)<<dfs(a,b,c)<<endl;
}

Measured memory_bytes: 233088
require "prime"
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def prime_fact(n)
    ret=[]
    2.upto((n**0.5).to_i) do|x|
        while (n%x).zero?
            ret.push(x)
            n/=x
        end
    end
    ret.push(n) if n!=1
    return ret
end
N,P=get_i
prime=prime_fact(P)
kind={}
prime.each do|p|
    kind[p]=0 if kind[p].nil?
    kind[p]+=1
end
ans=1
kind.each do|key,val|
  ans*=key**(val/N) if val>=N
end
puts ans

Measured memory_bytes: 2428
import sys

n = int(input())
p = list(map(int, input().split()))
p_copy = p.copy()

def sort_hantei(p):
    for i in range(len(p)-1):
        if p[i] > p[i+1]:
            return False
    return True

if sort_hantei(p):
    print('YES')
else:
    for i in range(n):
        for j in range(i+1, n):
            p_copy[i] = p[j]
            p_copy[j] = p[i]
            if sort_hantei(p_copy):
                print('YES')
                sys.exit()
            p_copy = p.copy()
    print('NO')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)

int main(){
  int n;
  cin >> n;

  int a[n], b[n], c[n];

  REP(i, n) cin >> a[i] >> b[i] >> c[i];

  REP(i, n){
    if(
      a[i] * a[i] + b[i] * b[i] == c[i] * c[i] ||
      b[i] * b[i] + c[i] * c[i] == a[i] * a[i] ||
      c[i] * c[i] + a[i] * a[i] == b[i] * b[i]
    ) cout << "YES" << endl;
    else cout << "NO" << endl;
  }

  return 0;
}



Measured memory_bytes: 3116
#include <set>
#include <map>
#include <unordered_map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-9;
const double INF = 2147483647;
#define rep(i, n) rep3(i, 0, n)
#define rep2(i, n) rep3(i, 1, n+1)
#define rep3(i, x, n) for(ll i = x; i < (ll)(n); i++)

template<class T>
void printv(vector<T> v) {
    for(auto it = v.begin(); it != v.end(); it++){
        cout << *it << ",";
    }
    cout << endl;
}

int main(void){
    ll X,N;
    map<ll, ll> p;
    cin>>X>>N;
    rep(i, N) {int x;cin>>x;p[x]=INF;}
    rep(i,102){
        if(p[i]!=INF){
            p[i] = abs(X-i);   
        }
        //cout << p[i] << endl;
    }
    int val = INF;
    int res = INF;
    rep(i,102){
        if (p[i] < val) {val = p[i]; res = i; }
    }
    cout << res;
    
    return 0;
}


Measured memory_bytes: 3636
const [n, ...ss] = require('fs').readFileSync('/dev/stdin', 'utf8').split(/\n/)
const result = {AC: 0, WA: 0, TLE: 0, RE: 0}
for (const s of ss) {
  result[s] += 1
}
for (const k of ['AC', 'WA', 'TLE', 'RE']) {
  console.log(`${k} x ${result[k]}`)
}

Measured memory_bytes: 45092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, b, c, d;
  cin >> N;
  a = N / 1000;
  b = N % 1000 / 100;
  c = N % 1000 % 100 / 10;
  d = N % 1000 % 100 % 10;
  if ((a == b && a == c) || (b == c && b == d) || (a == b && a == c && a == d))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define int  long long
using namespace std;
int a,b,x,y;
signed main()
{
	scanf("%lld%lld",&a,&b);
	a--;
	if(a%4==0)
		x=a;
	if(a%4==1)
		x=1;
	if(a%4==2)
		x=a+1;
	if(a%4==3)
		x=0;
	if(b%4==0)
		y=b;
	if(b%4==1)
		y=1;
	if(b%4==2)
		y=b+1;
	if(b%4==3)
		y=0;
	printf("%lld",x^y);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int a, b, c, d, e, f;
	double x, y;
	while(scanf("%d %d %d %d %d %d\n", &a, &b, &c, &d, &e, &f) != EOF){
		y = (double)(a * f - c * d) / (double)(a * e - b * d);
		x = ((double)c - (double)b * y) / (double)a;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    map<ll,ll>mp1;
    map<ll,ll>mp2;
    map<ll,ll>mp3,mp4,mp5,mp6,mp7,mp8;
    ll i, j, k;
    ll ar1[5][5];
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
        {
            cin>>ar1[i][j];
        }
    }
    ll n;
    cin>>n;
    ll f1=1,f2=1;
    ll f3=1,f4=1;
    ll f5=1,f6=1;
    ll f7=1,f8=1;
    for(i=0; i<n; i++)
    {
        cin>>k;
        mp1[k]++;
        mp2[k]++;
        mp3[k]++;
        mp4[k]++;
        mp5[k]++;
        mp6[k]++;
        mp7[k]++;
        mp8[k]++;
    }
    for(i=0; i<=2; i++)
    {
        if(mp1[ar1[0][i]]>=1)mp1[ar1[0][i]]--;
        else f1=0;
    }
    for(i=0; i<=2; i++)
    {
        if(mp2[ar1[1][i]]>=1)mp2[ar1[1][i]]--;
        else f2=0;
    }
    for(i=0; i<=2; i++)
    {
        if(mp3[ar1[2][i]]>=1)mp3[ar1[2][i]]--;
        else f3=0;
    }
    for(i=0; i<=2; i++)
    {
        if(mp4[ar1[i][0]]>=1)mp4[ar1[i][0]]--;
        else f4=0;
    }
    for(i=0; i<=2; i++)
    {
        if(mp5[ar1[i][1]]>=1)mp5[ar1[i][1]]--;
        else f5=0;
    }
    for(i=0; i<=2; i++)
    {
        if(mp6[ar1[i][2]]>=1)mp6[ar1[i][2]]--;
        else f6=0;
    }
    for(i=0; i<3; i++)
    {
        for(j=0; j<3; j++)
        {
            if(i==j)
            {
                if(mp7[ar1[i][j]]>=1)mp7[ar1[i][j]]--;
                else f7=0;
            }
        }
    }
    for(i=0; i<=2; i++)
    {
        for(j=2; j>=0; j--)
        {
            if(i==0 && j==2 ||i==1 && j==1 ||i==2 && j==0)
            {
                if(mp8[ar1[i][j]]>=1)mp8[ar1[i][j]]--;
                else f8=0;
            }
        }
    }
    if((f1+f2+f3+f4+f5+f6+f7+f8)>0)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<utility>
#define PI acos(-1.0)
using namespace std;
int main(){
	int a,b;
	cin >> a >> b;
	if(a < 6) cout << 0 << endl;
	else if(a > 12) cout << b << endl;
	else cout << b/2 << endl;
	return 0;
}

Measured memory_bytes: 888
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {
	private static FastScanner sc = new FastScanner();

	public static void main(String[] args) {
		int n = sc.nextInt();
		
		Node[] nodes = new Node[n];
		for(int i=0; i<n; i++) {
			nodes[i] = new Node();
		}
		
		for(int i=0; i<n; i++) {
			int id = sc.nextInt();
			int k = sc.nextInt();
			int[] c = new int[k];
			for(int j=0; j<k; j++) {
				c[j] = sc.nextInt();
				nodes[c[j]].parent = id;
			}
			
			nodes[id].child = c;
		}
		
		for(int i=0; i<n; i++) {
			if(nodes[i].parent == -1) {
				nodes[i].writeData(nodes, 0);
				break;
			}
		}
		
		StringBuilder ans = new StringBuilder();
		for(int i=0; i<n; i++) { 
			ans.append("node ");
			ans.append(i);
			ans.append(": parent = ");
			ans.append(nodes[i].parent);
			ans.append(", depth = ");
			ans.append(nodes[i].depth);
			ans.append(", ");
			ans.append(nodes[i].type);
			ans.append(", [");
			for(int j=0; j<nodes[i].child.length; j++) {
				if(j != 0) {
					ans.append(", ");
				}
				ans.append(nodes[i].child[j]);
			}
			ans.append("]\n");
		}
		System.out.print(ans);
	}
	
	static class Node {
		int parent = -1;
		int[] child;
		int depth;
		String type;
		
		void writeData(Node[] nodes, int depth) {
			this.depth = depth;
			for(int i=0; i<child.length; i++) {
				nodes[child[i]].writeData(nodes, depth + 1);
			}
			if(this.parent == -1) {
				type = "root"; 
			} else if(child.length != 0) {
				type = "internal node";
			} else {
				type = "leaf";
			}
		}
	}

	static class FastScanner {
	    private final InputStream in = System.in;
	    private final byte[] buffer = new byte[1024];
	    private int ptr = 0;
	    private int buflen = 0;
	    private boolean hasNextByte() {
	        if (ptr < buflen) {
	            return true;
	        }else{
	            ptr = 0;
	            try {
	                buflen = in.read(buffer);
	            } catch (IOException e) {
	                e.printStackTrace();
	            }
	            if (buflen <= 0) {
	                return false;
	            }
	        }
	        return true;
	    }
	    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
	    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
	    private void skipUnprintable() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;}
	    public boolean hasNext() { skipUnprintable(); return hasNextByte();}
	    public String next() {
	        if (!hasNext()) throw new NoSuchElementException();
	        StringBuilder sb = new StringBuilder();
	        int b = readByte();
	        while(isPrintableChar(b)) {
	            sb.appendCodePoint(b);
	            b = readByte();
	        }
	        return sb.toString();
	    }
	    public long nextLong() {
	        return Long.parseLong(next());
	    }
	    public int nextInt(){
	    	return Integer.parseInt(next());
	    }
	}
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(),v.end()
#define _GLIBCXX_DEBUG

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using vvd = vector<vd>;
using vvvi = vector<vvi>;
using vvvll = vector<vvll>;
using vvvd = vector<vvd>;

const double pi=3.141592653589793;

int main() {
    ll n,m;
    cin>>n>>m;
    ll a[n];
    rep(i,n){
        cin>>a[i];
        //cout<<a[i]<<endl;
    }
    vll s;
    ll now=0;
    s.push_back(0);
    rep(i,n){
        now+=a[i];
        now%=m;
        s.push_back(now);
        //cout<<s[i+1]<<endl;
    }
    sort(s.begin(),s.end());
    ll ans=0;
    now=s[0];
    ll count=1;
    for (int i=1;i<n+1;i++){
        if (now!=s[i]){
            now=s[i];
            ans+=(count)*(count-1)/2;
            count=1;
        }
        else{
            count+=1;
        }
    }
    ans+=(count)*(count-1)/2;
    //ans%=m;
    cout<<ans<<endl;


    

    return 0;
}


Measured memory_bytes: 2168
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f3f
#define pi 3.1415926535898
using namespace std;
const int N=3005,mod=998244353;
ll dp[N][N][2];
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if(c>a) dp[c][d][0]=1;
    if(d>b) dp[c][d][1]=1;
    ll ans=0;
    for(ll i=c;i>=a;i--)
    {
        for(ll j=d;j>=b;j--)
        {
            dp[i][j-1][0]=(dp[i][j-1][0]+dp[i][j][1]*i)%mod;
            dp[i][j-1][1]=(dp[i][j-1][1]+dp[i][j][1]*i)%mod;
            dp[i-1][j][0]=(dp[i-1][j][0]+dp[i][j][0]*j)%mod;
            dp[i-1][j][1]=(dp[i-1][j][1]+dp[i][j][0])%mod;
            if(i==a&&j-1==b)
            {
                ans=(ans+dp[i][j][1]*i)%mod;
            }
             if(i-1==a&&j==b)
            {
                ans=(ans+dp[i][j][0]*j)%mod;
            }
        }
    }
    if(a==c&&b==d)
    {
        ans=1;
    }
    cout<<ans<<endl;
    return 0;
}


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

constexpr int inf = 1e9;

int main() {
    string s;
    int w;
    cin >> s >> w;
    const int n = s.size();
    for(int i = 0; i < n; i += w) {
        cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>
#include <map>

using namespace std;
using lli = long long int;
using ll = long long;

int main() {
    lli N;
    cin >> N;

    vector <lli> X(N);
    for (lli i = 0; i < N; ++i) {
        cin >> X[i];
    }

    lli sum = 0;
    for (lli i = 0; i < N; ++i) {
        sum += X[i];
    }

    lli average = sum / N;


    lli counter = 0;
    for (lli i = 0; i < N; ++i) {
        counter += (X[i] - average) * (X[i] - average);
    }

    lli counter2 = 0;
    lli average2 = average + 1;
    for (lli i = 0; i < N; ++i) {
        counter2 += (X[i] - average2) * (X[i] - average2);
    }

    if (counter < counter2) {
        cout << counter << endl;
    } else {
        cout << counter2 << endl;
    }

}


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

int main() {

	int n; cin >> n;
	map <string, ll> mp;
	for (int i = 0; i < n; i++) {
		string tmp; cin >> tmp;
		sort(tmp.begin(), tmp.end());
		mp[tmp]++;
	}
	ll ans = 0;
	for (auto u : mp) {
		ans += u.second * (u.second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11356