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

using namespace std;

int main()
{
    queue<string>qp;
    queue<int>qt;

    int n,quantum,count=0;

    cin>>n;
    cin>>quantum;

    for(int i=0;i<n;i++)
    {
        int t;
        string p;

        cin>>p;
        cin>>t;

        getchar();

        qp.push(p);
        qt.push(t);


    }
   // cout<<qp.size()<<" "<<qt.size()<<endl;
    int c=qt.size();
    for(int i=0;i<c;i++)
    {

        int time=qt.front();

        if(quantum<time)
        {
            int diff=time-quantum;
            count=count+quantum;

            string process=qp.front();

            //cout<<process<<endl;

            qp.pop();
            qt.pop();
            qp.push(process);
            qt.push(diff);
            c++;
        }
        else
        {
            count=count+(qt.front());

            cout<<qp.front()<<" "<< count <<endl;

            qp.pop();
            qt.pop();
        }
    }

    return 0;
}



Measured memory_bytes: 5668
/* ex3_2
   moka223711 */

#include <stdio.h>

int main(void){
  int N;
  scanf("%d", &N);
  
  switch(N % 10){
    case 2: case 4: case 5: case 7: case 9:
      printf("hon");
      break;
    case 0: case 1: case 6: case 8:
      printf("pon");
      break;
    default:
      printf("bon");
  }
}

Measured memory_bytes: 1732
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<vector>
#include<map>
#include<queue>
#include<cmath>
#include<set>
#include<cstdlib>
#include<cctype>
#include<ctime>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll maxn = 2e5 + 5;
const ll maxm = 1e3 + 5;
template<class T>
inline T qread(T &IEE){
	register T x = 0, f = 1;
	register char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-'){
			f = -f;
		}
		ch = getchar();
	}
	while(isdigit(ch)){
		x = (x << 1) + (x << 3) + (ch ^ 48);
		ch = getchar();
	}
	return IEE = x * f;
}
template<class T>
inline void qwrite(T a){
	if(!a){
		putchar('0');
		return ;
	}
 	if(a < 0){
		putchar('-');
		a = -a;
	}
	if(a > 9) qwrite(a / 10);
	putchar(a % 10 + 48);
	return ;
}
template<class T>
inline T ab(T a){
	return (a > 0) ? a : -a;
}
template<class T>
inline void swa(T &a, T &b){
	a ^= b ^= a ^= b;
	return ;
}
ll cnt, n;
ll a[maxn];
map<ll, ll> miu;
int main(){
//	freopen("1.in", "r", stdin);
//	freopen("1.out", "w", stdout);
	qread(n);
	for(int i = 1;i <= n;i++){
		qread(a[i]);
		miu[i - a[i]]++;
	}
	for(int i = 1;i <= n;i++){
		miu[i - a[i]]--;
		cnt += miu[a[i] + i];
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 27876
import java.util.Scanner;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
        }
 
        System.out.println(execute(arr, n));
        sc.close();
    }
 
    private static int execute(int[] arr, int length) {
        int x = 0;
        int y = Math.abs(arr[1] - arr[0]);
        for (int i = 2; i < length; i++) {
            int temp = y;
            y = Math.min(x + Math.abs(arr[i] - arr[i - 2]), y + Math.abs(arr[i] - arr[i - 1]));
            x = temp;
        }
        return y;
    }
}

Measured memory_bytes: 50616
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <list>
#include <cmath>
#include <limits>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;


int main() {
    ll N, W;
    cin >> N >> W;
    vector<vector<ll>> dp(N+2, vector<ll>(W+10, 0));
    vector<ll> v(N+2), w(N+2);
    rep(i, N) cin >> w[i] >> v[i];
    for(int i = 0; i < N; i++) {
        for(int j = 0; j <= W; j++) {
            dp[i+1][j] = max(dp[i][j], dp[i+1][j]);
            if(j + w[i] <= W) dp[i+1][j+w[i]] = max(dp[i+1][j+w[i]], dp[i][j] + v[i]);
        }
    }

    ll ans = dp[N][W];
    cout << ans << endl;
}


Measured memory_bytes: 81024
#include<algorithm>
#include<iostream>
#include<cstdio>
#include<vector>
#define MN 100000
#define ll long long
using namespace std;
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
vector<pair<int,int> > v,V;
int trans,n,L,T,x[MN+5],p[MN+5],X[MN+5],rk[MN+5],Res[MN+5],pp[MN+5];
bool cmp(int x,int y){return X[x]==X[y]?p[x]<p[y]:X[x]<X[y];}
int main()
{
	n=read();L=read();T=read();
	for(int i=1;i<=n;++i) 
	{
		x[i]=read(),p[i]=read();rk[i]=i;X[i]=((x[i]+(p[i]==1?T:-T))%L+L)%L;
		if(p[i]==1) v.push_back(make_pair(x[i],i));
	}
	sort(rk+1,rk+n+1,cmp);
	for(int i=1;i<=n;++i) pp[rk[i]]=i;
	if(!v.size()||v.size()==n)
	{
		for(int i=1;i<=n;++i) printf("%d\n",X[i]);
		return 0;	
	}
	for(;v.size()>1;v.pop_back());
	for(int i=n;i>v[0].second;--i) if(p[i]==1) v.push_back(make_pair(x[i]-L,i)); 
	for(int i=v[0].second+1;i<=n;++i) if(p[i]==2) V.push_back(make_pair(x[i],i));
	for(int i=1;i<v[0].second;++i) if(p[i]==2) V.push_back(make_pair(x[i]+L,i));
	int l=1,r=1e9,mid,res=0;
	while(l<=r)
	{
		mid=l+r>>1;
		int pos=mid/2+1; ll Lt=v[(pos-1)%v.size()].first-1LL*(pos-1)/v.size()*L;
		int Pos=mid+1>>1;ll Rt=V[(Pos-1)%V.size()].first+1LL*(Pos-1)/V.size()*L;
		if(Rt-Lt<T*2) res=mid,l=mid+1;
		else r=mid-1; 
	}
	int final=(res&1)?V[(res/2)%V.size()].second:v[(res/2)%v.size()].second;
	for(int i=0;i<n;++i) Res[(v[0].second+i-1)%n+1]=X[rk[(pp[final]+i-1)%n+1]];
	for(int i=1;i<=n;++i) printf("%d\n",Res[i]);
	return 0;
}



Measured memory_bytes: 4472
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

long long gcd(long long a, long long b){
    while (a != 0 && b != 0){
        if (a >= b) a %= b;
        else b %= a;
    }
    return a + b;
}

auto factorization(long long N){
    map<long long, long long> mp;
    long long n = N;
    for(long long i = 2; i * i <= N; i++){
        while(n % i == 0){
            mp[i]++;
            n /= i;
        }
    }
    if(n > 1) mp[n]++;
    return mp;
}

ll N, A[1000010];

signed main(){
    cin >> N;
    REP(i, N) cin >> A[i];
    sort(A, A + N);
    ll g = A[0];
    REP(i, N) g = gcd(g, A[i]);
    if(g != 1){
        PRINT("not coprime");
        return 0;
    }
    map<ll, ll> M;
    REP(i, N){
        auto mp = factorization(A[i]);
        for(auto p : mp){
            if(M[p.first] > 0){
                PRINT("setwise coprime");
                return 0;
            }
            M[p.first]++;
        }
    }
    PRINT("pairwise coprime");
    return 0;
}

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

int main(){
    int N, D;
    cin >> N >> D;
    vector<int> X[N];
    for(int i = 0; i < N; i++){
        for(int j = 0; j < D; j++){
            int x; cin >> x;
            X[i].push_back(x);
        }
    }
    int cnt = 0;
    for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
            int sum = 0;
            for(int k = 0; k < D; k++){
                sum += pow(X[i][k] - X[j][k], 2);
            }
            if( (int)sqrt(sum) * (int)sqrt(sum) == sum) cnt++;
        }
    }
    cout <<cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll MOD = (ll)1e9+7;
int n;

int main(){
    cin >> n;
    ll a[n]; for(int i=0; i<n; i++) cin >> a[i];
    ll ans = 0LL;
    for(int i=0; i<n; i++){
        ans += a[i];
        ans %= MOD;
    }
    ans *= ans; ans %= MOD;
    for(int i=0; i<n; i++){
        ans -= (a[i]*a[i])%MOD;
        ans %= MOD; ans += MOD; ans %= MOD;
    }
    if(ans%2==0) ans/=2;
    else ans = (ans+MOD)/2;
    ans %= MOD;
    cout << ans << endl;
}


Measured memory_bytes: 5156
import scala.io.StdIn

object Main extends App {

  val a = StdIn.readLine().split(" ").map(_.toInt)
  val s = Vector((a(0) - a(1)).abs, (a(1) - a(2)).abs, (a(2) - a(0)).abs)
  val r = if (s(0) >= s(1) && s(0) >= s(2)) s(1) + s(2)
  else if (s(1) >= s(0) && s(1) >= s(2)) s(0) + s(2)
  else s(0) + s(1)

  println(r)
}


Measured memory_bytes: 25408
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll n;
ll a[310][310];
ll ans;
ll check(ll x,ll y)
{
        bool f = false;
        for(ll i=1;i<=n;i++)
        {
                if(a[x][i] + a[i][y] < a[x][y]){
                        return -1;
                }
                if(i == x || i == y) continue;
                if(a[x][i] + a[i][y] == a[x][y]){
                        f = true;
                }
        }
        if(f) return 0;

        return 1;
}
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cin >> n;
        for(ll i=1;i<=n;i++)
        {
                for(ll j=1;j<=n;j++){

                        cin >> a[i][j];
                }
        }
        for(ll i=1;i<=n;i++)
        {
                for(ll j=1;j<=n;j++)
                {
                        if(check(i,j) == -1){
                                cout << "-1\n"; return 0;
                        }
                }
        }
        for(ll i=1;i<=n;i++)
        {
                for(ll j=1;j<=n;j++)
                {
                        if(check(i ,j) == 1){
                                ans += a[i][j];
                        }
                }
        }
        cout << ans / 2 << endl;
        return 0;
}


Measured memory_bytes: 1024
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a+b==c+d)cout<<"Balanced"<<endl;
	else if(a+b>c+d)cout<<"Left"<<endl;
	else cout<<"Right"<<endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
typedef long long int ll;
typedef  long double ld;
#define inc(i,a,b)  for(long long int i=a;i<=b;i++)
#define dec(i,a,b)  for(long long int i=a;i>=b;i--)
#define fast   ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define pb  push_back
#define all(c)  (c).begin(),(c).end()
#define lv  vector<ll>
#define cv  vector<char>
#define dv  vector<ld>
#define rall(c)  (c).rbegin(),(c).rend()
#define lpr pair<ll,ll>
#define mp make_pair
#define ac accumulate
#define input(c) ll c;cin>>c;
#define lmap map<ll,ll>
#define test ll t;cin>>t;
#define no_test ll t=1;
#define vinp(a,n) inc(i,1,n){ input(k); a.pb(k); }
ll d,x=2,y;
ll LIM=1000000007;
lv v;
bool is_prime(int n)
{
	//To check whether a number is prime no. or not using Sieve Of Eratosthenes Method
	//with O(nlog(logn)) complexity
	bool prime[n+1];
	memset(prime,true,sizeof(prime));
	// Create a boolean array "prime[0..n]" and initialize
    // all entries it as true. A value in prime[i] will
    // finally be false if i is Not a prime, else true.
	for(int p=2;p*p<=n;p++)
	{   //if prime[p] is not changed then it is prime
		if(prime[p])
		{
			//neglect all numbers that are multiple of p. they are marked as false
		    for(int i=p*p;i<=n;i+=p)
			prime[i]=false;
	    }
	}
	return prime[n];
}
ll bsearch(lv v,ll k)
{
	//If element is definitely present. we are just find the position.
	ll lo=0,hi=v.size()-1;
	ll mid=(lo+hi)/2;
	while(lo<=hi)
	{
		mid=(lo+hi)/2;
		if(k>v[mid])
		lo=mid+1;
		else if(k<v[mid])
		hi=mid-1;
		else
		return mid;
	}
}
ll power(ll a, ll b)
{
	//A recursive function to calculate a^b in O(log n)
	if(b==0)
	return 1;
	else if(b==1)
	return a;
	else
	{
		if(b%2==0)
		return power((a*a)%LIM,b/2);
		else
		return a*power((a*a)%LIM,(b-1)/2);
	}
}
void gcd(ll a, ll b)
{
	//This function calculates gcd og 2 numbers in O(log(max(a,b))).
	//It uses Extended Euclid Algorithm
	//It is used in calculating MMI Modulo Multiplicative Inverse of a number
	if(b==0)
	{
	d=a;
	x=1;
	y=0;
    }
	else
	{
		gcd(b,a%b);
		ll t=x;
		x=y;
		y=t-(a/b)*y;
	}
}
ll MMI(ll n)
{
	//This function calculates modulo multiplicative inverse of a number
	gcd(n,LIM);
	return (x%LIM+LIM)%LIM;
}
ll fact(ll n)
{
	ll p=1;
	inc(i,1,n)
	p=(p*(i%LIM))%LIM;
	return p;
}
ll nCr(ll n, ll r)
{
	//This function finds the possible number of combinations
	ll p=fact(n)%LIM;
	ll m1=(fact(n-r))*(fact(r));
	return(p%LIM * MMI(m1)%LIM)%LIM;
}
ll nPr(ll n, ll r)
{
	//This function calculates nPr
	ll p=fact(n);
	ll m=MMI(fact(n-r));
	return((p%LIM * m%LIM)%LIM);
}
void solve()
{
	input(n);
	input(a);
	input(b);
	cout<<min(n*a,b);
}
int main()
{
	fast
	ll t=1;
    //cin>>t;
    //if any test cases
	while(t--)
    solve();
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<unordered_map>
#include<unordered_set>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592
#define PI acos(-1.0);

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;



int main(){
    int N; cin >> N;
    string s; cin >> s;
    int q; cin >> q;
    while(q--){
        int k; cin >> k;
        int d = 0,m = 0;
        ll dm = 0;
        ll ans = 0;
        rep(i,N){
            if(s[i] == 'D') d++;
            if(s[i] == 'M'){
                m++;
                dm += d;
            }
            if(i >= k){
                if(s[i-k] == 'D'){
                    d--;
                    dm -= m;
                }
                if(s[i-k] == 'M'){
                    m--;
                }
            }
            if(s[i] == 'C'){
                ans += dm;
            }
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
int n,a[105],ans;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++)cin>>a[i];
    for(int i=1;i+1<n;i++){
		if((a[i-1]<a[i]&&a[i]<a[i+1])||(a[i-1]>a[i]&&a[i]>a[i+1]))ans++;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;
int n, ans = 0,sum = 0,h,w;
int dx[8] = { 1, 0, -1, 0 };
int dy[8] = { 0, 1, 0, -1 };
int main() {
	cin >> h >> w;char c;
	vector<vector<int>> s(h, vector<int>(w));
	for (int i = 0; i < h;i++) {
		for (int j = 0;j < w;j++) {
			cin >> c;
			if (c == '#')
				s[i][j] = 0;
			else
				s[i][j] = 1;
		}
	}
	for (int i = 0; i < h;i++) {
		for (int j = 0;j < w;j++) {
			if (!s[i][j]) {
				for (int l = 0; l < 4; l++) {
					int nextx = i + dx[l];
					int nexty = j + dy[l];
					if (nextx >= h || nextx < 0) continue;
					if (nexty >= w || nexty < 0) continue;
					if (!s[nextx][nexty]) break;
					if (l == 3) {
						cout << "No" << endl;
						return 0;
					}
				}
			}
		}
	}
	cout << "Yes" << endl;
}

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

import sys
import math
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product                # product(iter, repeat=n)
# from itertools import accumulate             # accumulate(iter[, f])
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from copy import deepcopy                    # to copy multi-dimentional matrix without reference
# from fractions import gcd                    # for Python 3.4


def main():
    mod = 1000000007                  # 10^9+7
    inf = float('inf')
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():  return int(input())
    def mi():  return map(int, input().split())
    def mi_0(): return map(lambda x: int(x)-1, input().split())
    def lmi(): return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():  return list(input())
    
    
    k = ii()
    ans = 0
    for a in range(1, k+1):
        for b in range(1, k+1):
            for c in range(1, k+1):
                ans += math.gcd(math.gcd(a, b), c)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 69724
while 0 != data = gets.to_i do
	under = Array.new(data+1){0}
	data.times do
		sum = 0
		num = gets.split(" ").map!(&:to_i)
		num.each_with_index do |x,i|
			print " " * (5 - x.to_s.length) + x.to_s
			sum = sum + x
			under[i] += x
		end
		under[data] += sum
		puts " " * (5 - sum.to_s.length) + sum.to_s
	end
	under.each do |x|
		print " " * (5 - x.to_s.length) + x.to_s
	end
	puts ""
end

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

#define F      first
#define S      second
#define pii    pair<int,int>
#define vi     vector<int>
#define mii    map<int,int>
#define pb     push_back
#define int    long long
#define nn     100005

int n,m;
vi graph[nn],odg,idg;
int dp[nn];

int solve(int nd){
    if(dp[nd] == 0)
        return 0;

    if(dp[nd] != -1)
        return dp[nd];

    else{
        int re=0;
        for(auto nbr : graph[nd]){
            re = max(re,solve(nbr));         
        }
        return dp[nd] = 1 + re;
    }
}

int32_t main() {
    cin>>n>>m;
    odg.resize(n+1,0);
    idg.resize(n+1,0);
    while(m--){
        int x,y;
        cin>>x>>y;
        graph[x].pb(y);
        odg[x]++; idg[y]++;
    }
    int ans = 0;
    memset(dp,-1,sizeof(dp));
    for(int i=1;i<=n;i++){
        if(odg[i] == 0)
            dp[i] = 0;
    }
    
    for(int i=1;i<=n;i++){
        if(idg[i] == 0)
            ans = max(ans,solve(i));
    }
    cout<<ans;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;cin >> n;
	vector<int> x(n);
	vector<int> y(n);
	vector<int> h(n);
	rep(i,n) cin >> x[i] >> y[i] >> h[i];
	rep(i,101){
		rep(j,101){
			int H;
			rep(k,n){
				if(h[k]!=0){
					H=h[k]+abs(x[k]-i)+abs(y[k]-j);
					break;
				}
			}
			bool flg=true;
			rep(k,n){
				if(h[k]==0){
					if(H>abs(x[k]-i)+abs(y[k]-j)){
						flg=false;
						break;
					}
				}
				else{
					if(H!=h[k]+abs(x[k]-i)+abs(y[k]-j)){
						flg=false;
						break;
					}
				}
			}
			if(flg){
				cout << i << " " << j << " " << H << endl;
				return 0;
			}
		}
	}
}

Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */

// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */

using namespace std;

/* ---------- Type Abbreviation ---------- */

template <typename T>
using PQ = priority_queue<T>;
template <typename T>
using GPQ = priority_queue<T, vector<T>, greater<T>>;

using ll = long long;

#define fst first
#define snd second
#define mp make_pair
#define mt make_tuple

/* ---------- conversion ---------- */

#define INT(c) static_cast<int>(c)
#define CHAR(n) static_cast<char>(n)
#define LL(n) static_cast<ll>(n)
#define DOUBLE(n) static_cast<double>(n)

/* ---------- container ---------- */

#define ALL(v) (v).begin(), (v).end()
#define SIZE(v) (LL((v).size()))

#define FIND(v, k) (v).find(k) != (v).end()
#define VFIND(v, k) find(ALL(v), k) != (v).end()

#define gsort(b, e) sort(b, e, greater<decltype(*b)>())

/* ----------- debug ---------- */

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class T>
ostream& operator<<(ostream& os, set<T> v) {
    os << "[";
    for (auto vv : v)
        os << vv << ",";
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.fst << "," << p.snd << ")";
}

/* ---------- Constants ---------- */

// const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */

template <typename T>
T sq(T a) {
    return a * a;
}

template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

ll pcnt(ll b) {
    return __builtin_popcountll(b);
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    int ans = N;
    for (int s = 0; s <= N; ++s) {
        // s円を6^nで払う

        int cnt = 0;

        int ns = s;
        while (ns > 0) {
            cnt += ns % 6;
            ns /= 6;
        }

        ns = N - s;
        while (ns > 0) {
            cnt += ns % 9;
            ns /= 9;
        }

        ans = min(ans, cnt);
    }

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


Measured memory_bytes: 256
#pragma region head
    #include <bits/stdc++.h>
    using namespace std;
    using ll = long long;
    using vi = vector<int>;
    using vll = vector<ll>;
    using pi = pair<int, int>;
    using pll = pair<ll,ll>;
    template <class T> using vv = vector<vector<T>>;
    #define rep(i,n) for(int i = 0; i < (int)(n); i++)
    #define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
    #define rrep(i,n) for(int i = (int)(n)-1; i >= 0; i--)
    #define rrepi(i,a,b) for(int i = (int)(b)-1; i >= (int)(a); i--)
    #define all(x) (x).begin(), (x).end()
    #define rall(x) (x).rbegin(), (x).rend()
    #define bit(n) (1LL<<(n))
    template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
    template<class T> inline bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
    const int INF = 1002003004;
    const ll LINF = 1002003004005006007ll;
    struct preprocess{preprocess()
    {cin.tie(nullptr);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}}____;
#pragma endregion head

#pragma region library
// Complexity: sum:O(logn), add:O(logn)
template<typename T>
struct BinaryIndexedTree{
    int sz;
    vector<T> data;
    BinaryIndexedTree(int sz): sz(sz),data(sz+1) {}
    T sum(int k){
        // [0, k]
        T res = 0;
        for(k++; k > 0; k -= k & -k) res += data[k];
        return res;
    }
    T sum(int l, int r){
        // [l, r)
        return sum(r-1)-sum(l-1);
    }
    void add(int k, T x){
        for(k++; k <= sz; k += k & -k) data[k] += x;
    }
    // sum(a1, ... , ax)>=wを満たす最小のx(0-indexed)
    // assert(all ai is non-negative)
    int lower_bound(int w){
        if(w <= 0) return 0;
        int x = 0;
        int k = 1;
        while((k<<1)<=sz) k <<= 1;
        for(;k > 0; k >>= 1){
            if(x+k <= sz && data[x+k]<w){
                w -= data[x+k];
                x += k;
            }
        }
        return x;
    }
};
#pragma endregion library

int main(){
    string s; cin >> s;
    int n = s.length();

    vi cnt(26);
    rep(i,n){
        cnt[s[i]-'a']++;
    }
    int odd = -1;
    rep(i,26){
        if(cnt[i]%2){
            if(odd!=-1){
                cout << -1 << '\n';
                return 0;
            } else {
                odd = i;
            }
        }
    }
    vector<set<int>> idxs(26);
    int idx = 0;
    rep(i,n){
        if(cnt[s[i]-'a']>=2){
            idxs[s[i]-'a'].emplace(idx);
            idxs[s[i]-'a'].emplace(n-idx-1);
            cnt[s[i]-'a']-=2;
            idx++;
        }
    }
    if(odd!=-1)
    idxs[odd].emplace(n/2);
    // make idx array
    vi from(n);
    rep(i,n){
        if(idxs[s[i]-'a'].empty()) continue;
        auto it = idxs[s[i]-'a'].begin();
        from[i] = *it;
        idxs[s[i]-'a'].erase(it);
    }

    ll ans = 0;
    BinaryIndexedTree<int> bt(n);
    rep(i,n){
        ans += i - bt.sum(from[i]);
        bt.add(from[i],1);
    }
    cout << ans << '\n';
    


}

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

using namespace std;
typedef long long int lli;
const int MAX=1e5;

int main(){
	string S;
	cin>>S;
	int l=(int)S.length();
	bool dif=true;
	rep(i,l)for(int j=i+1;j<=l;j++)if(S[i]==S[j])dif=false;
	if(dif)cout<<"yes"<<endl;
	else cout<<"no"<<endl;
}


Measured memory_bytes: 256
#include <iostream> // cin, cout
#include <algorithm> // sort
#include <vector> // vector
#include <cstdio> // printf
#include <cmath> // M_PI
#include <numeric> // accumulate
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++)

int		main(void)
{
	int h, w;
	cin >> h >> w;
	while (h || w) {
		rep(i, h) {
			rep(k, w)
				cout << '#';
			cout << endl;
		}
		cout << endl;
		cin >> h >> w;
	}
	return (0);
}



Measured memory_bytes: 3072
n=int(input())
a=list(map(int,input().split()))
L=[0]*n

ans=[]
for i in range(n-1,-1,-1):
    if i+1>n//2:
        L[i]=a[i]
    else:
        t=n//(i+1)
        el=0
        for j in range(2,t+1):
            el += L[(i+1)*j-1]
        L[i]=(el+a[i])%2
    if L[i]==1:
        ans.append(str(i+1))

print(len(ans))
if len(ans)>0:
    print(' '.join(ans))

Measured memory_bytes: 17204
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

int H, W, K;
string *c;
set<int> s;

int dfs(int i) {
    if (i == H + W) {
        int tmp = 0;
        for (int j = 0; j < H; j++) {
            for (int k = 0; k < W; k++) {
                if (c[j][k] == '#' && s.find(j) == s.end() && s.find(k+H) == s.end())
                    tmp++;
            }
        }
        if (tmp == K)
            return 1;
        else
            return 0;
    }

    int ans = 0;
    s.insert(i);
    ans += dfs(i+1);
    s.erase(i);
    ans += dfs(i+1);

    return ans;
}

int main() {
    cin >> H >> W >> K;
    c = new string[H];
    for (int i = 0; i < H; i++)
        cin >> c[i];
    cout << dfs(0) << endl;

    return 0;
}

Measured memory_bytes: 3612
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	num = 0
	var input = input.trim().split("\n");
	var listen = input[input.length - 1]
	var sleep = false

	for (i = 1; i <= input.length - 1; i++) {
		title = input[i].split(' ')[0]
		if (title === listen) {
			sleep = true;
			continue;
		}
		if (sleep) {
			num += parseInt(input[i].split(' ')[1])
		}
	}

	//出力
	console.log(num)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 21064
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#define ll long long
#define l long
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<int,int>
#define maxn 100005
using namespace std;
vector<int> v[100005];
signed main()
{
    fast;
    
    ll n,i,j,ans=0;
    cin>>n;
    ll a[n+2];
    for(i=0;i<n;i++) cin>>a[i];
    sort(a,a+n);
    for(i=0;i<n;i++)
    {
    	for(j=i+1;j<n;j++)
    	{
    		auto it = lower_bound(a+j+1,a+n,a[j] + a[i]);
    		ans += it - (a+j+1);
    	}
    }
    cout<<ans;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
struct edge{ll to,cost;};

int main() {
  string s;
  string t;
  cin >> s;
  ll k=s.size();
  rep(i,k){
    if(s[i]=='0'){
      t +='0';
    }
    else if(s[i]=='1'){
      t +='1';
    }
    else{
      if(t.size()>=1){
        t.pop_back();
      }
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Graph = vector<vector<int>>;
Graph G;
  
/*------------------------------------------------------------------*/
ll kaijou(ll l, ll m){
    ll re = 1;
    while(m > 0){
        re *= l;
        m--;
    }
    return re;
}

ll dfs(ll n, ll x){
    if(n == 0) return 1;  
    if(x == 1) return 0;

    ll layer = kaijou(2, n + 1) - 3;
    ll patty = kaijou(2, n) - 1;

    if(1 < x and x <= layer + 1) return dfs(n - 1, x - 1);
    else if(x == 2 + layer) return patty + 1;
    else if(2 + layer < x and x <= 2 * layer + 2){
        return patty + 1 + dfs(n - 1, x - layer - 2);
    }else if(x == 2 * layer + 3) return 2 * patty + 1;
}

int main(){
    ll n, x; cin >> n >> x;
    cout << dfs(n, x) << endl;
}

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

int main() {
	int A, B, K;
	cin >> A >> B >> K;
	set<int>s;
	set<int>::iterator it;
  	int n=(A+K>B)?B:A+K-1;
  	int m=(B-K<A)?A:B-K+1;
	for (int i = A;i <= n;++i) s.insert(i);
	for (int i = B;i >= m;--i)s.insert(i);
	for (it = s.begin();it != s.end();it++)cout << (*it) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    int count = 0;
    for(int i = 1;i<=n;i++){
      String s = String.valueOf(i);
      if(s.length() % 2 != 0){
        count++;
      }
    }
    System.out.println(count);
  }



}




Measured memory_bytes: 25684
#include<iostream>

int main() {

	int ninput = 0;
	int nbase = 0;
	std::cin >> ninput;
	int outbase = ninput;
	while (ninput > 0)
	{
		nbase += ninput % 10;
		ninput = ninput / 10;
	}
	if (outbase % nbase) {
		std::cout << "No" << std::endl;
	}
	else
	{
		std::cout << "Yes" << std::endl;
	}
	return 0;
}


Measured memory_bytes: 256
n=int(input())
h=[0]+list(map(int,input().split()))+[0]
ma=0
mi=float('inf')
ans=0
for i in range(n+1):
  if h[i]<=h[i+1]:
    ma=max(ma,h[i+1])
    mi=min(mi,h[i])
  else:
    ans+=ma-mi
    ma=h[i+1]
    mi=h[i+1]
print(ans)

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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
void coY() {cout <<"Yes"<<endl;}
void coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

//Write From this Line

const int mod = 1e9+7;
int main()
{
	int a , b ;
	cin>> a >> b ;
	ll ans = a^b;
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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 <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    string N;
    cin>>N;
    if(N[0]=='7' or N[1]=='7' or N[2]=='7')
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
    return 0;
}

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

int main(){
    double l, r;
    int la = 0, lb = 0, lc = 0, ld = 0;
    int ra = 0, rb = 0, rc = 0, rd = 0;
    
    while(cin >> l >> r){
        if(l >= 1.1) la++;
        else if(l >= 0.6 && l < 1.1) lb++;
        else if(l >= 0.2 && l < 0.6) lc++;
        else ld++;

        if(r >= 1.1) ra++;
        else if(r >= 0.6 && r < 1.1) rb++;
        else if(r >= 0.2 && r < 0.6) rc++;
        else rd++;
    }
    cout << la << " " << ra << endl;
    cout << lb << " " << rb << endl;
    cout << lc << " " << rc << endl;
    cout << ld << " " << rd << endl;
}



Measured memory_bytes: 3208
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,C,K;
    cin >> N >> C >> K;
    ll T[100010];
    rep(i,0,N) cin >> T[i];
    sort(T,T+N);
    ll ans = 1;
    ll cnt = 1;
    ll start = T[0];
    rep(i,1,N){
        cnt++;
        if(cnt > C){
            cnt = 1;
            start = T[i];
            ans++;
        }
        if(T[i] > start + K){
            cnt = 1;
            start = T[i];
            ans++;
        }
    }
    print(ans);

}

Measured memory_bytes: 1024
include Math

a, b, h, m = gets.to_s.split.map{|e|e.to_f}

r_k = h * 30 + 30 * (m / 60.0)
r_s = m * 6
r = (r_k - r_s).abs
r = [360, 360 - r].min

ans = ( a ** 2 + b ** 2 - 2 * a * b * cos( PI * r / 180.0) ) ** 0.5

puts ans

Measured memory_bytes: 14840
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char in[31000];
int nx[31000][10];
int to[10];
int main(){
	int a;scanf("%d",&a);
	scanf("%s",in);
	for(int i=0;i<10;i++)to[i]=-1;
	for(int i=a-1;i>=0;i--){
		for(int j=0;j<10;j++){
			nx[i+1][j]=to[j];
		}
		to[in[i]-'0']=i+1;
	}
	for(int j=0;j<10;j++)nx[0][j]=to[j];
	int ret=0;
	for(int i=0;i<10;i++)for(int j=0;j<10;j++)for(int k=0;k<10;k++){
		int at=0;
		at=nx[at][i];
		if(at==-1)continue;
		at=nx[at][j];
		if(at==-1)continue;
		at=nx[at][k];
		if(at==-1)continue;
		ret++;
	}
	printf("%d\n",ret);
}


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

const int MAXN = 200 * 1000 + 20;

int n, k, l, a, b, g[MAXN], ans[MAXN], cnt;
vector <int> adj[MAXN], adj2[MAXN], tmp;
map <int, int> mp;
bitset <MAXN> connect;
bool vis[MAXN], vis2[MAXN];

void dfs(int v) {
	vis[v] = true;
	g[v] = cnt;
	connect[v] = 1;
	for (int u: adj[v])
		if (!vis[u])
			dfs(u);
}

void dfs2(int v) {
	vis2[v] = true;
	tmp.push_back(v);
	for (int u: adj2[v])
		if (!vis2[u])
			dfs2(u);
}

int main() {
	ios:: sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
	cin >> n >> k >> l;
	for (int i = 0; i < k; i++)
		cin >> a >> b, adj[a].push_back(b), adj[b].push_back(a);
	for (int i = 0; i < l; i++)
		cin >> a >> b, adj2[a].push_back(b), adj2[b].push_back(a);
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			cnt++;
			dfs(i);
		}
	}
	for (int i = 1; i <= n; i++) {
		if (!vis2[i]) {
			dfs2(i);
			for (int a: tmp)
				mp[g[a]]++;
			for (int a: tmp)
				ans[a] = mp[g[a]];
		}
		mp.clear(), tmp.clear();
	}
	for (int i = 1; i <= n; i++)
		cout << ans[i] << ' ';
	cout << '\n';
	return 0;
}


Measured memory_bytes: 20344
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String
    }
    if s == "ABC" {
        println!("ARC");
    } else {
        println!("ABC");
    }
}


Measured memory_bytes: 2072
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  ul K;
  cin >> N >> K;
  ul all = K;
  vector<int> A(N+1, 0);
  int ans = 0;
  REP(ii, N) { cin >> A[ii+1]; }
  vector<int>  city_num(N+1,-1);
  int cur_pos = 1;
  // cout << cur_pos <<endl;
  vector<int> map_seq(N, 0);
  map_seq.clear();
  ul itr = 0;
  while (itr< K) {
    if (city_num[cur_pos] !=-1) {
      ++itr;
      int cycle_num = itr-city_num[cur_pos] -1;
      int cycle_start = city_num[cur_pos];
      int rem = (K-cycle_start) % cycle_num;
      // for(auto a: map_seq) cout <<a<<" ";
      // cout <<endl;
      // cout <<"rem "<< rem <<endl;
      // cout <<"st "<< cycle_start <<endl;
      // cout <<"num "<< cycle_num <<endl;

      cout << map_seq[cycle_start + rem ];
      return 0;
    } else {
      city_num[cur_pos] = itr;
      map_seq.emplace_back(cur_pos);
      cur_pos = A[cur_pos];
      // cout << cur_pos <<endl;
    }
    ++itr;

  }
  cout << cur_pos << endl;

  return 0;
}


Measured memory_bytes: 5572
import math
a,b,h,m = [int(i) for i in input().split()]

theta_a = (math.pi/6)*(h + m/60) % (2*math.pi)
theta_b = 2*math.pi*m/60  % (2*math.pi)
diff = abs(theta_a-theta_b)
if diff > math.pi:
    diff = 2*math.pi - diff

c = (a**2+b**2 - 2*a*b*math.cos(diff))**0.5
print(c)

Measured memory_bytes: 9532
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long
#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

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

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
ll read(){ll a;scanf("%lld",&a);return a;}

const int inf = 3 * TEN(18) + 10;
const int mod = 998244353;


signed main()
{
	vi a(3);
	rep(i, 3) cin >> a[i];
	int n; cin >> n;

	int ans = 0;
	rep(i, n + 1) rep(j, n + 1) {
		if (a[0]*i + a[1]*j > n) break;
		int zan = n - a[0] * i - a[1] * j;
		if (zan % a[2] == 0) ans++;
	}

	cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <iomanip>
#include <functional>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;


typedef long long lint, ll;
typedef long double ldouble, ld;

#ifdef LOCAL
	#define dbg(expr) cerr << "[" << __LINE__ << "] " << #expr << " = " << (expr) << '\n';
#else
	#define dbg(expr) (void) 0;
#endif


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

    int n;
    cin >> n;
    vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
        l[i]--;
    }
    int q = 0;
    for (int i = 0; i < n - 1; i++) {
        if (i != l[i])
            continue;
        swap(l[i], l[i + 1]);
        q++;
    }
    if (l[n - 1] == n - 1) {
        swap(l[n - 1], l[n - 2]);
        q++;
    }
    cout << q << endl;
}

Measured memory_bytes: 640
import sys
x1=[int(i)for i in input().split()]
x2=[int(i)for i in input().split()]
for i in range(6):
    if x2[i]==x1[0]:
        count=i
        if x2[5-i]==x1[5]:
            break
if x2[count]==x1[0] and x2[5-count]==x1[5]:
    if count==0 or count==5:
        if count==5:
            for i in range(2):
                x2[1],x2[0]=x2[0],x2[1]
                x2[5],x2[1]=x2[1],x2[5]
                x2[4],x2[5]=x2[5],x2[4]
    else:
        if count==1 or count==4:
            while x1[0]!=x2[0] or x1[5]!=x2[5]:
                x2[1],x2[0]=x2[0],x2[1]
                x2[5],x2[1]=x2[1],x2[5]
                x2[4],x2[5]=x2[5],x2[4]
        else:
            while x1[0]!=x2[0] or x1[5]!=x2[5]:
                x2[3],x2[0]=x2[0],x2[3]
                x2[5],x2[3]=x2[3],x2[5]
                x2[2],x2[5]=x2[5],x2[2]
    for i in range(4):
        if x2[2]==x1[2] and x2[3]==x1[3] and x2[4]==x1[4] and x2[1]==x1[1] :
            print('Yes')
            break
        else:
            x2[1],x2[2]=x2[2],x2[1]
            x2[2],x2[4]=x2[4],x2[2]
            x2[4],x2[3]=x2[3],x2[4]
        if i==3:
            print('No')
else:
    print("No")

Measured memory_bytes: 7916