akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

class AtCoder_xab{
  public static void Main(){

    string s = Console.ReadLine();
    char[] chars = s.ToCharArray();
    char[] alph = new char[26]{'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

    bool b = true;
    bool c = false;
    char ans = ' ';
    for (int i = 0; i < 26; i++){
        b = true;
        for (int j = 0; j < s.Length; j++){
            if(alph[i] == chars[j]){
                b = false;
                break;
            }
        }
        if(b){
            ans = alph[i];
            c = true;
            break;
        }
    }
    if(c) Console.WriteLine(ans);
    else Console.WriteLine("None");  
  }
}

Measured memory_bytes: 11488
#include "bits/stdc++.h"

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

vector<ll> enum_prime(ll N){
	deque<bool> is_prime(N+1,true);
	vector<ll> P;
	for(ll i=2;i<=N;i++){
		if(is_prime[i]){
			for(ll j=i*i;j<=N;j+=i){
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}

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

	auto P = enum_prime(100000);
	vector<int> IP(100000,0),IS(100000,0);
	for(auto& x:P){
		IP[x-1] = 1;
	}
	for(int i=1;i<=100000;i++){
		if(IP[i-1] && IP[((i+1)/2)-1]){
			IS[i-1] = 1;
		}
	}
	for(int i=1;i<100000;i++){
		IS[i] += IS[i-1];
	}

	auto Q=in();
	LOOP(Q){
		int L=in()-1,R=in()-1;
		int num = IS[R]-(L>1 ? IS[L-1] : 0);
		out(num);
	}
	
	return 0;
}

Measured memory_bytes: 1688
package main

import (
	"bufio"
	"fmt"
	"log"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)
	log.SetFlags(log.Lshortfile)
	var s string
	fmt.Scan(&s)
	switch s {
	case "A":
		fmt.Println("T")
	case "T":
		fmt.Println("A")
	case "C":
		fmt.Println("G")
	case "G":
		fmt.Println("C")
	}
}

func nextString() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

var dy = []int{0, 1, 0, -1}
var dx = []int{1, 0, -1, 0}
var MAX = math.MaxInt32

func pow(a, b int) int {
	return int(math.Pow(float64(a), float64(b)))
}

func lcm(a, b int) int {
	return a * b / gcd(a, b)
}
func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return p[i].a < p[j].a
}


Measured memory_bytes: 640
import numpy as np

a, b, c, k = map(int, input().split())
# b = [int(input()) for i in range(n)]
# c = [list(map(int, input().split())) for i in range(n)]

res = "res"


# a = 1
# b = 9
# c = 89

# k = 20

s = a if k - a >= 0 else k

action = k - a - b

if action >= 0:
  s -= action
# s += k - a
print(s)

Measured memory_bytes: 27148
n = int(input())
d = list(map(int,input().split()))

for b in range(2**n):
    a = bin(b)[2:]
    a = a[::-1]
    ans = []
    for i in range(len(a)):
        if a[i] == "1":
            ans.append(i)
    ans.sort()
    flag = True
    for i in d[1:]:
        if i not in ans:
            flag = False
            break
    if flag:
        print(str(b)+":",*ans)


Measured memory_bytes: 6172
#ifdef loc
    #include "loc_debug.h"
#else
    #include <bits/stdc++.h>
    #define pr(...)
    #define pra(a,n)
    #define praa(a,n,m)
    #define prl()
#endif
using namespace std;

typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define sz(a) int(a.size())
const int N = 200005;
ll h[N], a[N];

struct node {
    node *l, *r;
    ll mx;
    node() {
        l = r = 0;
        mx = 0;
    }
};

void upd(node *root, int l, int r, int x, ll v) {
    if(l == r) {
        root->mx = max(root->mx, v);
        return;
    }
    int m = (l + r) >> 1;
    if(l <= x && x <= m) {
        upd(root->l, l, m, x, v);
    } else if(m + 1 <= x && x <= r) {
        upd(root->r, m + 1, r, x, v);
    }
    root->mx = max(root->l->mx, root->r->mx);
}

void make(node *root, int l, int r) {
    if(l == r) {
        return;
    }
    int m = (l + r) >> 1;
    root->l = new node();
    root->r = new node();
    make(root->l, l, m);
    make(root->r, m + 1, r);
}

ll get(node *root, int l, int r, int gl, int gr) {
    if(l == gl && r == gr) {
        return root->mx;
    }
    int m = (l + r) >> 1;
    ll ans = 0;
    if(gr >= l && gl <= m) {
        ans = max(ans, get(root->l, l, m, max(l, gl), min(gr, m)));
    }
    if(gr >= m + 1 && gl <= r) {
        ans = max(ans, get(root->r, m + 1, r, max(m + 1, gl), min(gr, r)));
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    rep(i, 1, n + 1) {
        cin >> h[i];
    }
    rep(i, 1, n + 1) {
        cin >> a[i];
    }
    node *root = new node();
    make(root, 1, n);
    ll ans = 0;
    rep(i, 1, n + 1) {
        ll f = get(root, 1, n, 1, h[i] - 1) + a[i];
        upd(root, 1, n, h[i], f);
        ans = max(ans, f);
    }
    cout << ans << endl;
}

Measured memory_bytes: 15872
from fractions import gcd
N = int(input())
an = list(map(int, input().split()))


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


temp = lcm(an[0], an[1])
for i in range(2, N):
    temp = lcm(temp, an[i])
ans = 0
for a in an:
    ans += (temp-1) % a
print(ans)


Measured memory_bytes: 5372
program main
	implicit none
	character(100) S
	read(*, *) S
	if(S(3:4) > "00" .AND. S(1:2) > "00" .AND. S(1:2) <="12" .AND. S(3:4) <= "12") then
		write(*, *) "AMBIGUOUS"
	else if(S(1:2) > "00" .AND. S(1:2) <="12") then
		write(*, *) "MMYY"
	else if(S(3:4) > "00" .AND. S(3:4) <="12") then
		write(*, *) "YYMM"
	else
		write(*, *) "NA"
	end if
end program main

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

using namespace std;

int main(void){
    int n, m;
    cin >> n >> m;
    vector<int> h(n);
    vector<stack<int> > bro(n);
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    for(int i = 0; i < m; i++){
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        bro[s].push(t);
        bro[t].push(s);
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        bool ok = true;
        while(bro[i].size()){
            int b = bro[i].top();
            bro[i].pop();
            if(h[i] <= h[b])ok = false;
        }
        if(ok)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 71108
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DEBUG 0
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define dump(o) if(DEBUG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DEBUG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
using ll = long long; using ull = unsigned long long; using pii = pair<int, int>;
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
static const int MOD = 1e9 + 7;

signed main() {
	int t; cin >> t;
	rep(i, 0, t) {
		int X, Y, W, H; cin >> X >> Y >> W >> H;
		int N; cin >> N;
		int ans = 0;
		rep(i, 0, N) {
			int x, y; cin >> x >> y;
			if (X <= x&&x <= X + W&&Y <= y&&y <= Y + H)ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3012
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    ll h, w;
    cin >> h >> w;
    vector<string> a(h);
    REP(i, h){
        cin >> a[i];
    }
    vector<vector<ll>> dp(h, vector<ll>(w));
    dp[0][0] = 1;
    REP(i, h){
        REP(j, w){
            if(i < h - 1){
                if(a[i + 1][j] != '#'){
                    dp[i + 1][j] += dp[i][j];
                    dp[i + 1][j] %= MOD;
                }
            }
            if(j < w - 1){
                if(a[i][j + 1] != '#'){
                    dp[i][j + 1] += dp[i][j];
                    dp[i][j + 1] %= MOD;
                }
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}


Measured memory_bytes: 9216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int ans = 0;
    FOR(i,1,N+1){
        string s = to_string(i);
        if(s.length()%2 == 1) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
/*
 © 2020-09-26 07:00:12 Franco1010 All Rights Reserved
*/

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
// #include <atcoder/all>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
using namespace std;
// using namespace atcoder;
typedef long double ld;
typedef long long lli;
typedef pair<lli,lli> ii;
typedef vector<lli> vi;
#define deb(x) cout << #x": " << (x) << endl;
struct segtree{
  #define mid (l + r) / 2
  #define left(u) (u + 1)
  #define right(u) (u + ((mid - l + 1) << 1))
  struct node{
    lli s;
    node(lli s = 0): s(s) {}
    node operator + (const node & n){
      return node(max(s, n.s));
    }
  };
  vector<node> st;
  segtree(int n): st(2 * n) {}
  void update(int u, int l, int r, int kth, lli val){
    if(l == r){
      st[u] = val;
      return;
    }
    if(kth <= mid) update(left(u), l, mid, kth, val);
    else update(right(u), mid + 1, r, kth, val);
    st[u] = st[left(u)] + st[right(u)];
  }
  lli query(int u, int l, int r, int ll, int rr){
    if(l > r or r < ll or l > rr) return 0;
    if(ll <= l and r <= rr) return st[u].s;
    return max(query(left(u), l, mid, ll, rr), query(right(u), mid + 1, r, ll, rr));
  }
};
const lli N = 3e5;
int main(){ _
  lli n, k; cin >> n >> k;
  vector<lli> v(n);
  segtree st(N + 1);
  lli res = 0;
  fore(i, 0, n){
    cin >> v[i];
    lli foo = st.query(0, 0, N, max(v[i] - k, 0ll), min(v[i] + k, lli(3e5))) + 1ll;
    res = max(res, foo);
    st.update(0, 0, N, v[i], foo);
  }
  cout << res << ENDL;
  return 0;
}


Measured memory_bytes: 10308
//感觉AT的题在不断刷新着我对它红题的观念，不过我喜欢哈哈哈哈哈哈哈
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b;
	if(a>0) cout<<"Positive"<<endl;
	else if((b-a)&1) cout<<"Positive"<<endl;
	else if(b>=0) cout<<"Zero"<<endl; 
	else cout<<"Negative"<<endl;
	return 0;
} 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


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

	string res = "No";
	for (int i = 1; i <= 9; i++)
	{
		for (int j = 1; j <= 9; j++)
		{
			if (n == i * j)
			{
				res = "Yes";
			}
		}
	}

	println(res);
}


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

using namespace std;

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

    bool can = true;

    for (int i = 0; i < a; i++)
    {
        int x; cin >> x;
        if (x%2 == 0 && x%5 != 0 && x%3 != 0)
            can = false;
    }

    cout << (can ? "APPROVED" : "DENIED") << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define ll long long
using namespace std;

const ll mod = 1e9 + 7;

ll C[2005][2005];
ll dp[100005][13];

int main(){
    int K,N,M_dist=0;
    cin >> K >> N;
    vector<int> S(N);
    for (int i = 0; i < N; i++){
        cin >> S[i];
        if(i > 0){
            M_dist = max(M_dist, S[i] - S[i-1]);
            // cout << M_dist;
        }
    }
    M_dist = max(M_dist, S[0]+K - S[N-1]);
    cout << K - M_dist << endl;
}

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

int main(){
  string s;
  cin>>s;
  int cnt[30]={0};
  int ans=0;
  for(int i=0;i<s.size();i++){
    int a=s[i]-'0';
    if((++cnt[a])%2) ans++;
    else ans--;
  }
  if(!ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
n,k = [int(i) for i in input().split()]
mod = 10**9+7

ans = 0
for i in range(k,n+2):
    max_num = (n + n -i+1) * i //2 
    min_num = (i-1)*i//2
    ans += max_num - min_num + 1
    ans %= mod
    
print(ans)

Measured memory_bytes: 9192
/*
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd
#define prev asdgSHJsfgsdfhdsh

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 998244353

const int N = 120031;

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

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

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main() {
  int n,m; cin >> n >> m;
  vector<int> v[n];
  rep(i,m){
    int a,b; cin >> a >> b; a--; b--;
    v[a].emplace_back(b);
    v[b].emplace_back(a);
  }
  
  vector<int> nxt;
  for(auto to:v[0]){
    nxt.emplace_back(to);
  }
  for(auto to:nxt){
    for(auto dis:v[to]){
      if(dis==n-1){ cout << "POSSIBLE" << endl; return 0; }
    }
  }
  cout << "IMPOSSIBLE" << endl; return 0;
}


Measured memory_bytes: 12784
n=int(input())
y=[]
t=[]
l=[]
for i in range(n):
    x,u=input().split()
    y.append(float(x))
    t.append(u)
for i in range(n):
    if t[i]=='JPY':
        l.append(y[i])
    else:
        l.append(y[i]*380000.0)
print(sum(l))

Measured memory_bytes: 3064
#include<stdio.h>
#define N 100
int main()
{
  int i,j,k=0,count=0,A[N],n;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  for(i=0;i<n;i++){
    for(j=n-1;j>i;j--){
      if(A[j]<A[j-1]){
	k=A[j];
	A[j]=A[j-1];
	A[j-1]=k;
	count++;
      }
    }
  }
  for(i=0;i<n-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main(){
   int n,a[210],sum=0;
   scanf("%d",&n);
   for (int i=1;i<=2*n;i++)
   scanf("%d",&a[i]);
   sort(a+1,a+1+2*n);
   for (int i=1;i<=2*n;i+=2)
      sum+=a[i];
      printf("%d\n",sum);
   return 0;
}


Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int n = s.nextInt();
		for (int i = 0; i < n; ++i) {
			ArrayList<Integer> l = new ArrayList<Integer>();
			for (int j = 0; j < 3; ++j) {
				l.add(s.nextInt());
			}
			Collections.sort(l);
			System.out.println(Math.pow(l.get(0), 2) + Math.pow(l.get(1), 2) == Math.pow(l.get(2), 2) ? "YES" : "NO");
		}
	}
}

Measured memory_bytes: 23560
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
//ll primes[] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 110};
ll n;
ll removed[110];
ll val[110];
ll sum, ans;
void recurse(ll p)
{
	//printf("%lld \n", sum);
	ans = max(ans, sum);
	if (p > n/2) return;
	if (p > n/3)
	{
		ll x2 = p*2;
		if (x2 % 3 == 0 && x2/3 > n/4)
		{
			recurse(p+1);
		}
		else
		{
		//	printf("hi\n");
			ll v = 0;
			if (!removed[p]) v -= val[p];
			if (!removed[x2]) v-=val[x2];
			if (v > 0) sum+=v;
		//	if (sum == 6) printf(" %lld \n", v);
			recurse(p+1);
			if (v > 0) sum-=v;
		}
		return;
	}
	if (p > n/4)
	{
		//printf("%lld \n", p);
		ll x2 = p*2;
		ll x3 = p*3;
		ll op1 = 0;
		if (!removed[p]) op1-=val[p];
		if (!removed[x2]) op1-=val[x2];
		if (!removed[x3]) op1-=val[x3];
		ll op2 = 0;
		ll op3 = op1;
		if (x3 % 2 == 0 && x3/2 > n/3)
		{
			if (!removed[x3/2]) { op2 -= val[x3/2]; op3-= val[x3/2]; }
			if (!removed[x3]) op2 -= val[x3];
		}
		removed[p]++;
		sum+=max(max(op1, op3), max(op2, (ll)0));
		recurse(p+1);
		sum-=max(max(op1, op3), max(op2, (ll)0));
		removed[p]--;
		return;
	}
	recurse(p+1);
	if (removed[p]) return;
	for (ll i = p; i <= n; i+=p)
	{
		if (!removed[i])
		{
			sum-=val[i];
		}
		removed[i]++;
	}
	recurse(p+1);
	for (ll i = p; i <= n; i+=p)
	{
		removed[i]--;
		if (!removed[i])
		{
			sum+=val[i];
		}
	}
}
int main()
{
	scanf("%lld ", &n);
	for (ll i = 1; i <= n; i++) { scanf("%lld", &val[i]); sum+=val[i]; 
		if (i > n/2 && val[i] < 0) { sum-=val[i]; removed[i] = 1; }
	}
	recurse(1);
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
	if (s.equals("AAA")||s.equals("BBB")){
    
    	System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}




Measured memory_bytes: 20948
#include<iostream>
#include<map>
#include<atcoder/all>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long li;
#define rep(i,n) for(int i=0;i<(n);i++)
#define df 0
template<class T> void print(const T& t){ cout << t << "\n"; }
template<class T, class... Ts> void print(const T& t, const Ts&... ts) { cout << t; if (sizeof...(ts)) cout << " "; print(ts...); }

// Container コンテナ型, map以外
template< template<class ...> class Ctn,class T>
std::ostream& operator<<(std::ostream& os,const Ctn<T>& v){
  auto itr=v.begin();
  while(itr!=v.end()){
    if(itr!=v.begin())cout << " ";
    cout << *(itr++);
  }
  return os;
}

// map 型
template<class S,class T>
std::ostream& operator<<(std::ostream& os, const map<S,T>& mp){
  for(const pair<S,T>& x: mp){
    cout << "[" << x.first << "]=" << x.second << " ";
  }
  return os;
}

struct deta{
  int a,b,i;
  deta(int x=0,int y=0,int z=0){a=x;b=y;i=z;};
};

const int operator<(const deta& p1, const deta& p2){
  return p1.a<p2.a;
}

struct less1 {
  bool operator()(const deta& p1, const deta& p2) const{
    return p1.i<p2.i;
  }
};



int main(){
  int n; cin >>n;
  vector<deta> v(n);
  rep(i,n){
    int a,b; cin >>a >>b;
    v[i]={a,b,i};
  }
  sort(v.begin(),v.end());
  atcoder::dsu d(n);
  map<int,int> mp;
  rep(i,n){
    int b=v[i].b;
    auto itr=mp.lower_bound(b);
    if(itr==mp.begin()){
      mp[b]=v[i].i;
    }else{
      while(itr!=mp.begin()){
        itr--;
        d.merge(v[i].i,itr->second);
        if(itr!=mp.begin())itr=mp.erase(itr);
      }
    }
  }
  rep(i,n){
    print(d.size(i));
  }
}


Measured memory_bytes: 11124
#include<iostream>
using namespace std;
int main(){
    int m, f, r;
    while(true){
        cin >> m >> f >> r;
        if (m != -1 || f != -1 || r != -1){
            if(m == -1 || f == -1){
                cout << 'F' << endl;
            } else if(m + f >= 80){
                cout << 'A' << endl;
            } else if(m + f >= 65){
                cout << 'B' << endl;
            } else if(m + f >= 50 || r >= 50){
                cout << 'C' << endl;
            } else if(m + f >= 30){
                cout << 'D' << endl;
            } else {
                cout << 'F' << endl;
            }
        } else {
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
using namespace std;
int main(){
  int a,b,c;
  while(cin>>a>>b>>c){
    int k=0;
    for(int i=1;i<11;i++){
      if(i!=c&&i!=a&&i!=b&&i+a+b<21)k++;
    }
    if(k>3)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 3084
# -*- coding:utf-8 -*-
n, a, b = map(int, input().split())
ans = 0
for tmp in range(1, n+1):
    c = sum(list(map(int, list(str(tmp)))))
    if c >= a and c <= b:
        ans += tmp
    else:
        pass
else:
    print(ans)

Measured memory_bytes: 3060
use std::io;

fn main() {
    let mut S = String::new();
    let mut T = String::new();
    io::stdin().read_line(&mut S);
    io::stdin().read_line(&mut T);
    S = S.trim().to_string();
    T = T.trim().to_string();
    T.pop();
    if S == T {
        println!("Yes")
    }else{
        println!("No")
    }
}


Measured memory_bytes: 2104
#include <stdio.h>
#include <algorithm>

using namespace std;
using ll = long long;

void solve();
int main() {
	solve();
#ifdef DBG
	while (true);
#endif
}

void solve() {
	int n, x[200000], s[200000];
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", x + i), s[i] = x[i];
	sort(s, s + n);
	for (int i = 0; i < n; i++) {
		if (x[i] <= s[n / 2 - 1])
			printf("%d\n", s[n / 2]);
		else
			printf("%d\n", s[n / 2 - 1]);
	}
}

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


int main(){

  char symbol[100];
  int  num[99],x=0;

  while(scanf("%s",symbol)!=EOF){
  if(symbol[0]=='+'){
    num[x-2]=num[x-2]+num[x-1];
    x--;
  }
  else if(symbol[0]=='-'){
    num[x-2]=num[x-2]-num[x-1];
    x--;
  }
  else if(symbol[0]=='*'){
    num[x-2]=num[x-2]*num[x-1];
    x--;
  }
  else{
    
    num[x]=atoi(symbol);
    x++;
  }
  }
  printf("%d\n",num[0]);

  return 0;
}

  

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

long ncr(long n,long r) {
  long re=1;
  for(long i=1;i<=r;i++) {
    re*=n-i+1;
    re/=i;
  }
  return re;
}

int main() {
  long double n,a,b,ans1=0,ans2=0;
  cin >> n >> a >> b;
  vector<long double> v(n);
  map<long double,long double> aaa;
  for(long i=0;i<n;i++) {
    cin >> v[i];
    aaa[v[i]]++;
  }

  sort(v.begin(),v.end());
  reverse(v.begin(),v.end());
  for(long i=0;i<a;i++) ans1+=v[i];
  ans1/=a;
  if(aaa[v[0]]>a) {
    for(long i=a;i<=min(b,aaa[v[0]]);i++) ans2+=ncr(aaa[v[0]],i);
  } else {
    for(long i=0;true;i++) {
      if(v[i]==v[a-1]) {
        ans2=ncr(aaa[v[a-1]],a-i);
        break;
      }
    }
  }
  cout << fixed << setprecision(10);
  cout << ans1 << endl;
  cout << fixed << setprecision(0);
  cout << ans2 << endl;
}

Measured memory_bytes: 256
S = input()
N = len(S)

a = 0
ans = 0
nowB = False
for i in range(N):
    if S[i] == 'A':
        if nowB:
            a = 0
        a += 1
        nowB = False
    elif S[i] == 'B':
        if nowB:
            a = 0
        nowB = True
    else:
        if nowB:
            ans += a
            nowB = False
        else:
            a = 0
print(ans)

Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    double dis;
    ll cnt=0,n,d,x,y,i;
    cin>>n>>d;
    while(n--)
    {
        cin>>x>>y;
        dis=sqrt(x*x+y*y*1.0);
        if(dis<=d)cnt++;
    }
    cout<<cnt<<endl;


    return 0;
}







Measured memory_bytes: 3692
#include<stdio.h>
#include <string.h>
#define N 100
#define LIMIT 11

int main(void)
{
	char s[N][LIMIT];
	int n;

	scanf("%d", &n);

	for (int i = 0; i < n; i++) {
		scanf("%s", s[i]);
	}

	for (int j = 0; j < n; j++) {
		for (int k = j + 1; k < n; k++) {
			if (strcmp(s[j], s[k]) == 0) {
				printf("No\n");
				return 0;
			}
		}
	}

	for (int x = 1; x < n; x++) {
		if (s[x][0] != s[x - 1][strlen(s[x - 1]) - 1]) {
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int A,B,C,D,E,F;
set<int>water;
set<int>sugar;
int main(void)
{
    cin>>A>>B>>C>>D>>E>>F;
    for(int a=0;100*a<=F;a+=A)
    {
        for(int b=0;100*b+100*a<=F;b+=B)
        {
            water.insert(100*a+100*b);
        }
    }
    water.erase(0);
    for(int c=0;c<=F;c+=C)
    {
        for(int d=0;d+c<=F;d+=D)
        {
            sugar.insert(c+d);
        }
    }
    int perfact_water=0;
    int perfact_sugar=0;
    for(auto wa:water)
    {
        for(auto su:sugar)
        {
            if(wa+su<=F)
            {
                if((100*su<=wa*E)&&(su*(perfact_sugar+perfact_water)>=(wa+su)*perfact_sugar))
                {
                     perfact_water=wa;
                     perfact_sugar=su;
                }
            }
        }
    }
    assert(perfact_sugar!=0||perfact_water!=0);
    cout <<perfact_water+perfact_sugar<<" "<<perfact_sugar<<endl;
    return 0;
    }




















//#include <bits/stdc++.h>
//using namespace std;
//int A,B,C,D,E,F;
//set<int>water;
//set<int>sugar;
//int main(void)
//{
//    cin>>A>>B>>C>>D>>E>>F;
//    for(int a=0;100*a<=F;++a)
//    {
//        for(int b=0;100*b+100*a<=F;++b)
//        {
//            water.insert(100*a+100*b);
//        }
//    }
//    water.erase(0);
//    for(int c=0;c<=F;c+=C)
//    {
//        for(int d=0;d<=F;d+=D)
//        {
//            sugar.insert(c+d);
//        }
//    }
//    int perfact_water;
//    int perfact_sugar;
//    double perfact_density=0.0;
//    for(auto wa:water)
//    {
//        for(auto su:sugar)
//        {
//            if(wa+su<=F)
//            {
//                double density=su*1.0/wa;
//                if(100*density<=E&&density>perfact_density)
//                {
//                     perfact_density=density;
//                     perfact_water=wa;
//                     perfact_sugar=su;
//                }
//            }
//        }
//    }
//    cout <<perfact_water+perfact_sugar<<" "<<perfact_sugar<<endl;
//    return 0;
//    }


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define RREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const long long INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll dp[100010][3];
int v[100010][3];
int solve(){
  int n;
  cin>>n;
  rep(i,n)rep(j,3)cin>>v[i][j];
  rep(i,3)dp[0][i] = v[0][i]; 
  REP(i,1,n){
    rep(j,3){
      rep(k,3){
        if(j == k)continue;
        dp[i][k] = max(dp[i][k],dp[i - 1][j] + v[i][k]);
      }
    }
  }
  ll ans = 0;
  rep(i,3)ans = max(ans,dp[n - 1][i]);
  cout << ans << endl;
  return 0;
}
int main(){
  ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16);
  solve();
  return 0;
}

Measured memory_bytes: 3840
'use strict';
(function(stdin) {
    var inputs = stdin.toString();
    (function(S) {
        //????????????????????????


        function h1(S) {
            return S / (60 * 60);
        }

        function m1(S) {
            return (S % (60 * 60)) / 60;
        }

        function s1(S) {
            return S % 60;
        }
        var h = Math.floor(h1(S));
        var m = Math.floor(m1(S));
        var s = Math.floor(s1(S));


        console.log(h + ':' + m +':' + s);

    }(parseInt(inputs.trim(), 10))); //????°??????????????¶?????????°?????????
}(require('fs').readFileSync('/dev/stdin', 'utf8')));

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

#define MAX (0xaaaaa)

char color[MAX + 1];

int change_worm(char *color, int len)
{
    int i;
    int change;
    int code;
    int j;
    int flag;
    
// printf("====\n", code);

    flag = 0;
    for (i = 0; i <= MAX; i++){
        if (color[i] == 1){
            color[i] = 2;
// printf("-> %x(%d)\n", i, len);
            for (j = 0; j < len - 1; j++){
//printf("[%x <> %x]\n", (i >> (j * 2)) & 3, (i >> (j * 2 + 2)) & 3);
                // ツ療猟づィツ債つ、ツ色ツつェツ暗。ツつ、ツつゥツ？
                if (((i >> (j * 2)) & 3) != ((i >> (j * 2 + 2)) & 3)){
                    change = 3 - ((i >> (j * 2)) & 3) - ((i >> (j * 2 + 2)) & 3);
                    code = (i & ~(0xf << (j * 2))) | (change << (j * 2)) | (change << (j * 2 + 2));
// printf("%x", code);
                    if (color[code] == 0){
// printf("  <== NEW");
                        color[code] = -1;
                        flag = 1;
                    }
// printf("\n", code);
                }
            }
        }
    }
    for (i = 0; i <= MAX; i++){
        if (color[i] == -1){
            color[i] = 1;
        }
    }
    return (flag);
}

int color_code(char *worm)
{
	int code;
	int i;
	
	code = 0;
	i = 0;
	while (worm[i] != '\0'){
		code <<= 2;
		switch (worm[i]){
		  case 'r':
		    break;
			
		  case 'g':
		    code += 1;
			break;
			
		  case 'b':
			code += 2;
			break;
		}
		i++;
	}
	return (code);
}


int main(void)
{
    char worm[11];
    int worm_len;
	int time;
    int all_red, all_green, all_blue;
    int i;
    int change_flg;
    
	while (1){
		scanf("%s", worm);
		
		if (worm[0] == '0'){
			break;
		}
        
        memset(color, 0, sizeof(color));
        color[color_code(worm)] = 1;
        worm_len = strlen(worm);

        all_red = all_green = all_blue = 0;
        for (i = 0; i < worm_len; i++){
            all_green = (all_green << 2) + 1;
            all_blue = (all_blue << 2) + 2;
        }

// printf("<%x %x %x>\n", all_red, all_green, all_blue);

        time = 0;
        while (1){
            if (color[all_red] + color[all_green] + color[all_blue] != 0){
                printf("%d\n", time);
                break;
            }
            time++;
    		change_flg = change_worm(color, worm_len);
            if (change_flg == 0){
			    printf("NA\n");
                break;
    		}
 		}
	}
	return (0);
}

Measured memory_bytes: 1096
#include <stdio.h>

int main()
{
	int d;	/* 入力一つ目 */
	int n;	/* 入力二つ目 */
	scanf("%d %d", &d, &n);

	/* 100のn乗で割ると割り切れる数を探索する	*/
	/* 例えば0乗であれば整数であればすべて		*/
	/* 1乗なら100の倍数2乗なら10000の倍数となる	*/

	int result;	/* 結果の格納用 */
	if(d == 0){
		/* 100は100で一回割り切れてしまうので特殊処理を用意しておく */
		result = 1 * n;
		if(n == 100)
			result = 101;
	} else if(d == 1) {
		result = 100 * n;
		if(n == 100)
			result = 10100;
	} else {
		result = 10000 * n;
		if(n == 100)
			result = 1010000;
	}

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

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <list>

using namespace std;

int main()
{
	int n;
	while(1){
		cin >> n;
		if(n == 0) break;
		int a[21][21] = {0}, x, y;
		for(int i = 0; i < n; i++){
			cin >> x >> y;
			a[x][y] = 1;
		}
		int m, X=10, Y=10, cnt=0;
		char d;
		int l;
		cin >> m;
		for(int j = 0; j < m; j++){
				cin >> d >> l;
				for(int k = 0; k < l; k++){
				if(d == 'N') Y++;
				else if(d == 'E') X++;
				else if(d == 'S') Y--;
				else if(d == 'W') X--;
				if(a[X][Y] == 1){
					cnt++;
					a[X][Y] = 0;
				}
			}
		}
		if(cnt == n) cout << "Yes" <<endl;
		else cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<unordered_map>
using namespace std;
string s;
int d[200001];
unordered_map<int,int> best;
int main()
{
	cin>>s;
	int n=s.size(),x=0;s=' '+s;
	best[0]=0;
	for(int i=1;i<=n;i++)
	{
		d[i]=i;
		x^=1<<(s[i]-'a');
		for(int j=0;j<26;j++)
			if(best.count(x^(1<<j)))d[i]=min(d[i],best[x^(1<<j)]+1);
		if(best.count(x))d[i]=min(d[i],best[x]),best[x]=min(best[x],d[i]);
		else best[x]=d[i];
	}
	cout<<max(1,d[n])<<endl;
	return 0;
}


Measured memory_bytes: 9984
S = list(input())
A = [i for i in range(len(S)-1)]
ans = 0
for i in range(1 << len(A)):
    tmp = S.copy()
    idx = []
    k = 0
    for j in range(len(A)):
        if ((i >> j) & 1) == 1:
            idx.append(A[j])
    for j in range(len(idx)):
        tmp.insert(idx[j]+1+k, '+')
        k += 1
    
    str = ''.join(tmp)
    n = str.split('+')
    n = [int(i) for i in n]
    ans += sum(n)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <stack>
#include <vector>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long int ll;
int main()
{
    ll n;
    ll a[60];
    ll mx=1;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        if(abs(a[mx])<abs(a[i]))mx=i;
    }
    cout<<2*n<<endl;
    if(a[mx]>=0)
    {
        cout<<mx<<" "<<n<<endl;
        cout<<mx<<" "<<n<<endl;
        for(int i=1;i<n;i++)
        {
            cout<<n<<" "<<i<<endl;
            cout<<n<<" "<<n<<endl;
        }
    }
    if(a[mx]<0)
    {
        cout<<mx<<" "<<1<<endl;
        cout<<mx<<" "<<1<<endl;
        for(int i=n;i>1;i--)
        {
            cout<<1<<" "<<i<<endl;
            cout<<1<<" "<<1<<endl;
        }
    }
    
    return 0;
}


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

int main(){
    int K,X;
    cin >> K >> X;
    
    X += 1000000;

    for(int i=X-K+1; i<X+K;i++){
        cout << i - 1000000 << " ";
    }

    cout << endl;

}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%s', $s);
fscanf(STDIN, '%s', $t);
$ans = 0;
for($i = 0; $i < 3; $i++) {
    $ans += ($s[$i] == $t[$i]) ? 1 : 0;
}
echo $ans, PHP_EOL;

Measured memory_bytes: 4732
#include <bits/stdc++.h>
#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++)

using namespace std;

int main() {
  long long a, b, x;
  cin >> a >> b >> x;

  auto f = [](long long n, long long x) {
    long long ini = 0;
    if (n < 0)
      return ini;

    // a以上対象なので、その分を含める
    // (a % x == 0) のときは+1するのでその分ということ
    return n / x + 1;
  };

  cout << (f(b, x) - f(a-1, x)) << "\n";
  return (0);
}


Measured memory_bytes: 384
import sys
import numpy as np

N=int(input())
A=np.arange(N+1)
count = 0

for i in range(N+1):
    if A[i]%3 != 0 and A[i]%5 != 0 and A[i]%15 != 0:
        count = count + A[i]
print(count)


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

int main()
{
    int a[55],t[55],n,c=0; 
    cin>>n;
    for(int i=0;i<n;i++){ 
        cin>>a[i];
        t[i]=a[i];
    } 
    sort(a,a+n);
    for(int i=0;i<n;i++){ 
        if(a[i]!=t[i])c++;
    } 
    cout<<(c<=2?"YES":"NO")<<endl; 
    
    
    
    

    return 0;
}


Measured memory_bytes: 256
//#include <sstream>
//#include <fstream>
//#include <deque>
//#include <queue>
//#include <stack>
//#include <set>
//#include <list>
//#include <map>
//#include <unordered_map>
//#include <functional>
//#include <utility>
//#include <bitset>
//#include <cstdlib>
//#include <ctime>
//#include <cstdio>
 
 
#include <stdlib.h>
#include <iostream>
//#include <chrono> //clock
#include <vector>
#include <string>
//#include <iomanip>  //setprecision function
//#include <cmath>	//math
//#include <cstdio>
//#include <vector>	//vector array
//#include <algorithm>	//STL algorithm
//#include <set> //STL library set
//#include <sstream> // for stringstream
 
 
using namespace std;
//using namespace std::chrono; 
 
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
 
 
int main() {
	//stringstream ss;
	//ss<<"akhil";
	//cout<<ss.str()<<endl;
	//cout<<setprecision(16);
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	
	 // TESTCASE KO DEKH KA BHAUT SARA CONDITION GENERATE MAT KRO 
	 // PAPER PD CONFIRM HO JAO THORA JADA TIME HI KYU NA LGA
	
	int K;
	cin>>K;
	int sum=0;
	for(int i=1;i<=K;i++){
		for(int j=1;j<=K;j++){
			for(int l=1;l<=K;l++){
				int tgcd=gcd(i,j);
				sum+=gcd(tgcd,l);
			}
		}
	}
		
	cout<<sum<<endl;
	return 0;
}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Measured memory_bytes: 3696
#include<bits/stdc++.h>
 
#define REP(i,s,n) for(int (i)=s; (i)<(int)(n);(i)++)
#define RIT(it,c) for(__typeof(c.begin()) it = c.begin();it!=c.end();it++)
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)(x).size()
#define MSET(m,v) memset(m,v,sizeof(m))
 
 
using namespace std;
 
 
typedef long long LL;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<LL> vL;
typedef vector<bool> vb;
typedef pair<int,vi> iv;
typedef pair<LL,LL> pLL; 
typedef long double LD;
typedef unordered_set<int> ui;



int main(){
	std::ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	int N, ans = 1, cnt = 1;
	cin>>N;
	for(int i=0;i<N;++i){
		int x;
		cin>>x;
		ans *= 3;
		if(x%2==0) cnt*=2;
	}
	cout<<ans-cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
#ABC126B-YYMMorMMYY.py

from sys import stdin

S = stdin.readline()

YorM = int(S[:2])
MorY = int(S[2:])

if YorM <= 12 and YorM >= 1:
    if MorY <= 12 and MorY >= 1:
        print("AMBIGUOUS")
    else:
        print("MMYY")
else:
    if MorY <= 12 and MorY >= 1:
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 2940
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

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

	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());

	int amax = a[0];
	int ans = 0;

	for (int i = 0; i < n; i++) {
		if (b[i] > amax) {
			h -= b[i];
			ans++;
		}

		if (h <= 0) {
			cout << ans << endl;
			return 0;
		}
	}

	ans += (h+amax-1) / amax;

	cout << ans << endl;


	
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        final int N = sc.nextInt(), W = sc.nextInt();
        int[] w = new int[N];
        long[] v = new long[N];
        for(int i=0;i<N;i++){
            w[i] = sc.nextInt();
            v[i] = sc.nextLong();
        }
        long[][] maxValue = new long[N][W+1];   //N行目はNを入れるか入れないか、W列目は重さWまでの時の最大値
        for(int j=0;j<W+1;j++){
            maxValue[0][j] = j >= w[0] ? v[0] : 0;
        }
        for(int i=1;i<N;i++){
            for(int j=0;j<W+1;j++){
                if(j >= w[i]){
                    maxValue[i][j] = Math.max(maxValue[i-1][j], maxValue[i-1][j-w[i]] + v[i]);  //入れられる重さなら入れてみる
                }else{
                    maxValue[i][j] = maxValue[i-1][j];      //入れられない
                }
            }
        }
        System.out.println(maxValue[N-1][W]);

    }
}


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

int main() {
    long a, b, m, temp = LONG_MAX, ans = LONG_MAX;
    cin >> a >> b >> m;
    vector<long> va(a), vb(b);
    rep(i, a) {
        cin >> va.at(i);
        if(ans > va.at(i)) ans = va.at(i);
    }
    rep(i, b) {
        cin >> vb.at(i);
        if(temp > vb.at(i)) temp = vb.at(i);
    }
    ans += temp;
    rep(i, m) {
        long x, y, c;
        cin >> x >> y >> c;
        ans = min(ans, va.at(x - 1) + vb.at(y - 1) - c);
    }
    cout << ans << endl;
}

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<double> E;
	for (int i = 0; i < N; i++) {
		int pi;
		cin >> pi;
		E.push_back((double) (1 + pi) / 2);
	}
	vector<double> S = vector<double>(N - K + 1, 0);
	for (int i = 0; i < K; i++) {
		S.at(0) += E.at(i);
	}
	for (int i = 1; i < N - K + 1; i++) {
		S.at(i) = S.at(i - 1);
		S.at(i) -= E.at(i - 1);
		S.at(i) += E.at(i + K - 1);
	}
	sort(S.begin(), S.end());
	cout << fixed << setprecision(15) << S[N - K] << endl;
	return 0;
}


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

int n,m,maxv=-1;
char a[25][25];
int GA[25][25][25][25];

int main()
{
	cin>>n>>m;
	memset(a,' ',sizeof(a));
	memset(GA,inf,sizeof(GA));
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)  cin>>a[i][j];
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)
		{
			if (a[i][j]==a[i][j-1]&&a[i][j]=='.')  GA[i][j][i][j-1]=GA[i][j-1][i][j]=1;
			if (a[i][j]==a[i][j+1]&&a[i][j]=='.')  GA[i][j][i][j+1]=GA[i][j+1][i][j]=1;
			if (a[i][j]==a[i+1][j]&&a[i][j]=='.')  GA[i][j][i+1][j]=GA[i+1][j][i][j]=1;
			if (a[i][j]==a[i-1][j]&&a[i][j]=='.')  GA[i][j][i-1][j]=GA[i-1][j][i][j]=1;
		}
	}
	for (int i=1;i<=n;i++)
	{
		for (int j=1;j<=m;j++)  GA[i][j][i][j]=0;
	}
	for (int ki=1;ki<=n;ki++)
	{
		for (int kj=1;kj<=m;kj++)
		{
			if (a[ki][kj]=='#')  continue;
			for (int ii=1;ii<=n;ii++)
			{
				for (int ij=1;ij<=m;ij++)
				{
					if (a[ii][ij]=='#')  continue;
					for (int ji=1;ji<=n;ji++)
					{
						for (int jj=1;jj<=m;jj++)
						{
							if (a[ji][jj]=='#')  continue;
							if (GA[ii][ij][ji][jj]>GA[ii][ij][ki][kj]+GA[ki][kj][ji][jj])
							{
								GA[ii][ij][ji][jj]=GA[ii][ij][ki][kj]+GA[ki][kj][ji][jj];
								GA[ji][jj][ii][ij]=GA[ii][ij][ki][kj]+GA[ki][kj][ji][jj];
							}
						}
					}
				}
			}
		}
	}
	for (int ii=1;ii<=n;ii++)
	{
		for (int ij=1;ij<=m;ij++)
		{
			for (int ji=1;ji<=n;ji++)
			{
				for (int jj=1;jj<=m;jj++)
				{
					if (GA[ii][ij][ji][jj]>n*m)  continue;
					else maxv=max(maxv,GA[ii][ij][ji][jj]);
				}
			}
		}
	}
	cout<<maxv<<endl;
	return 0;
}

Measured memory_bytes: 1792
n, m = map(int, input().split())
a = {i for i in range(1,m+1)}
for _ in range(n):
    li = list(map(int, input().split()))
    b = {li[i] for i in range(1,li[0]+1)}
    a = a.intersection(b)
    b = {}
    li = []
print(len(a))

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

using namespace std;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    long long res=0;
    auto s=[](long long a)->long long
    {
        return a*(a-1)/2;
    };
    vector<long long> a(n);
    vector<long long> cnt(n+1,0);
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        cnt[a[i]]++;
    }
    for(int i=1;i<=n;i++) res+=s(cnt[i]);
    for(int i=0;i<n;i++)
    {
        res-=s(cnt[a[i]]);
        cnt[a[i]]--;
        res+=s(cnt[a[i]]);
        cout << res << "\n";
        res-=s(cnt[a[i]]);
        cnt[a[i]]++;
        res+=s(cnt[a[i]]);
    }
    return 0;
}


Measured memory_bytes: 5760
sx,sy,tx,ty = map(int,input().split())
fx,bx = 'RL' if sx < tx else 'LR'
fy,by = 'UD' if sy < ty else 'DU'
dx,dy = abs(sx-tx),abs(sy-ty)
ans = ''
ans += fy*dy + fx*dx
ans += by*dy + bx*(dx+1)
ans += fy*(dy+1) + fx*(dx+1) + by
ans += fx + by*(dy+1) + bx*(dx+1) + fy
print(ans)


Measured memory_bytes: 3060