akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node { int p, l, r; };
struct Node T[MAX];
int n;

/* Preorder */
void preParse(int u) {
  if ( u == NIL ) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

/* Inorder */
void inParse(int u) {
  if (u == NIL ) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

/* Postorder */
void postParse(int u) {
  if ( u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d",u);
}

int main() {
  int i, v, l, r, root;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    T[i].p = NIL;
  }

  for ( i = 0; i < n; i++ ) {
    scanf("%d %d %d", &v, &l ,&r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL) T[l].p = v;
    if ( r != NIL) T[r].p = v;
  }

  for ( i = 0; i < n; i++) if ( T[i].p == NIL) root = i;

  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}



Measured memory_bytes: 2104
package main

import (
  "fmt"
)

func main() {
  var n, m int 
  fmt.Scan(&n, &m)
  board := make([]string, n)
  target := make([]string, m)
  for i := 0; i < n; i++ {
    fmt.Scan(&board[i])
  }
  for i := 0; i < m; i++ {
    fmt.Scan(&target[i])
  }

  for i := 0; i < n - m + 1; i++ {
    for j := 0; j < n - m + 1; j++ {
      flag := false 
      for dy := 0; dy < m; dy++ {
        for dx := 0; dx < m; dx++ {
          if board[i+dy][j+dx] != target[dy][dx] {
            flag = true
            break
          }
        }
        if flag {break}
      }
      if flag {continue}
      fmt.Println("Yes")
      return
    }
  }
  fmt.Println("No")
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
     
#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair
     
using namespace std;
     
typedef long long ll;
typedef pair <int, int> pii;
typedef vector <int> vi;
typedef vector <ll> vll;

int n;
vi v, c;

int backtrack (int pos, int x, int y) {
  if (pos == n) return x - y;
  return max(backtrack(pos + 1, x + v[pos], y + c[pos]), backtrack(pos + 1, x, y));
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  v.resize(n);
  c.resize(n);
  for (int& elem: v) cin >> elem;
  for (int& elem: c) cin >> elem;
  cout << backtrack(0, 0, 0) << '\n';
  return (0);
}

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

#define ll      long long
#define MAX     1000007
#define inf     99999999999999
#define MOD     1000000007
#define pii     pair<int,int>
#define FIN     freopen("input.txt","r",stdin);
#define FOUT    freopen("output.txt","w",stdout);

ll k,temp;
vector<ll> v;

ll func(ll val)
{
    ll tt = val;
    for(int i=0; i<k; i++)
    {
        ll temp = val%v[i];
        val = val - temp;
    }
    return val;
}

int main ()
{
    cin>>k;
    ll tt = k;
    while(tt--)
    {
        scanf("%lld",&temp);
        v.push_back(temp);
    }
    ll mn=-1,mx=-1;
    ll lo=1,hi = 1e16,mid;
    while(lo<=hi)
    {
        mid = (lo+hi)>>1;
        temp = func(mid);
        if(temp ==2)
        {
            mn = mid;
            hi = mid - 1;
        }
        else if(temp>2)
        {
            hi = mid -1;
        }
        else
        {
            lo = mid + 1;
        }
    }
    lo=1,hi = 1e16;
    while(lo<=hi)
    {
        mid = (lo+hi)>>1;
        temp = func(mid);
        if(temp ==2)
        {
            mx = mid;
            lo = mid + 1;
        }
        else if(temp>2)
        {
            hi = mid -1;
        }
        else
        {
            lo = mid + 1;
        }
    }
    if(mx==-1 && mn==-1)
        printf("-1\n");
    else
        printf("%lld %lld\n",mn,mx);
    return 0;
}



Measured memory_bytes: 1400
def cmb(n,r,mod):
    if r<0 or r>n:return 0
    r=min(r,n-r)
    return g1[n]*g2[r]*g2[n-r]%mod


mod=10**9+7
x,y=map(int,input().split())
g1=[1,1]
g2=[1,1]
inverse=[0,1]

n,m=(2*y-x)//3,(2*x-y)//3
if (x+y)%3!=0 or n<0 or m<0:print(0);exit()

for i in range(2,n+m+1):
    g1.append((g1[-1]*i)%mod)
    inverse.append((-inverse[mod%i]*(mod//i))%mod)
    g2.append((g2[-1]*inverse[-1]%mod))

print(cmb(n+m,n,mod))

Measured memory_bytes: 118764
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<ll,pll> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

ll n;

int main(){
	cin>>n;
	cout<<n*(n-1)/2<<endl;
}

Measured memory_bytes: 256
s = input().rstrip()
dp = [0] * 4
dp[0] = 1

for i in range(len(s)):
    if s[i] == 'A':
        dp[1] += dp[0]
    elif s[i] == 'B':
        dp[2] += dp[1]
    elif s[i] == 'C':
        dp[3] += dp[2]
    else:
        dp = [dp[0]*3, dp[1]*3+dp[0], dp[2]*3+dp[1], dp[3]*3+dp[2]]
    dp = list(map(lambda x: x % (10**9+7), dp))
print(dp[3])


Measured memory_bytes: 9204
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=(1LL<<61);
const int inf=(1<<30);
const int nmax=1e5+50;
using namespace std;
int n,i;
ll x[nmax],v[nmax],mxb[nmax],mxf[nmax],ans,sum,c;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>c;
	for(i=1;i<=n;i++)cin>>x[i]>>v[i];
	for(i=1;i<=n;i++)
	{
		sum+=v[i];
		mxf[i]=max(mxf[i-1],sum-x[i]);
		ans=max(ans,mxf[i]);
	}
	sum=0;
	for(i=n;i>=1;i--)
	{
		sum+=v[i];
		mxb[i]=max(mxb[i+1],sum-(c-x[i]));
		ans=max(ans,mxb[i]);
	}
	sum=0;
	for(i=1;i<=n;i++)
	{
		sum+=v[i];
		ans=max(ans,sum-2*x[i]+mxb[i+1]);
	}
	sum=0;
	for(i=n;i>=1;i--)
	{
		sum+=v[i];
		ans=max(ans,sum-2*(c-x[i])+mxf[i-1]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
import java.util.*;

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

        int n = sc.nextInt();
        int m = sc.nextInt();

        if(n==m){
            System.out.println("Yes");
        }
        if(n!=m){
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 23892
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

N = i()
print(N//3)

Measured memory_bytes: 10052
#include<iostream>

using namespace std;

int main()
{
    int a,b,c;
    
    cin >> a >> b >> c;
    
    int num = 0;
    for(int i=a;i<=b;i++)
    {
        if (c%i==0) num++;
    }
    
    cout << num << endl;
    
    return 0;
}


Measured memory_bytes: 3116
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>

using ll = long long;

using namespace std;

long long x = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= x;
	if (n % 2 == 1)t *= a;
	return t % x;
}

const int INF = 1001001001;

int main() {
	string s, t;
	cin >> s >> t;
	int a, b;
	cin >> a >> b;
	string x;
	cin >> x;
	if (x == s)a--;
	else if (x == t)b--;
	cout << a << " " << b << endl;
	return 0;
}

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

#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
typedef long long ll;

using namespace std;

int n;
double x;
double ans=0;
string s;

int main() {
    cin>>n;
    REP(i,n){
        cin>>x>>s;
        if(s=="JPY"){
            ans=ans+x;
        }else{
            ans=ans+x*380000;
        }
    }
    cout<<ans;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    long a[n];
    priority_queue<int>q;
    for(int i=0;i<n;i++)
    cin>>a[i];
    int count=0;
    for(int i=0;i<n-1;i++){
        int temp;
        if(a[i]>=a[i+1]){
            count++;
            q.push(count);
        }
        else
        count=0;
        
    }
    if(q.empty())
    cout<<"0"<<endl;
    else
    cout<<q.top()<<endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef map<ll,ll>::iterator itll;
typedef long double ld;
typedef map<ll,ll> mapll;

#define con continue
#define pb push_back
#define fi first
#define se second
#define fr front()
#define INF 1000000000000000000
#define all(vl) vl.begin(),vl.end()
#define m_p make_pair 
#define sz(a) sizeof(a)
#define forn(mp,it) for(it = mp.begin();it!=mp.end();it++)
#define FOR(i,a,n) for(int i=a;i<n;i++) 
#define FORE(i,a,n) FOR(i,a,n+1)
#define Endl endl
#define eNdl endl
#define enDl endl
#define endL endl

int main()
{
	ll n;
	cin>>n;
	vector<ll> vl(n);
	FOR(i,0,n){
		cin>>vl[i];
	}
	ll mi = INF;
	FORE(i,1,100)
	{
		ll points = 0;
		FOR(j,0,n)
		{
			points+=(vl[j]-i)*(vl[j]-i);
		}
		mi = min(mi,points);
	}
	cout<<mi<<endl;
	return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll INFF = 1e18;

 
int N;
ll a[300];
 
int main(void) {
	cin >> N;
	rep(i, N) cin >> a[i];
	int ans = 0;
	while(1) {
		bool f = true;
		rep(i, N) if(a[i] % 2) f = false;
		if(f) ans++;
		else break;
		rep(i, N) a[i] /= 2;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
h, w, k = list(map(int, input().split()))
m = [list(input()) for _ in range(h)]
ans = 0

for bh in range(1 << h):
    for bw in range(1 << w):
        B = 0
        for H in range(h):
            for W in range(w):
                if ((bh >> H) & 1) == 0 and ((bw >> W) & 1) == 0 and m[H][W] == "#":
                    B += 1
        if B == k:
            ans += 1
print(ans)


Measured memory_bytes: 9188
#include <iostream>
#include <sstream>
#include <string>
using namespace std;
int main(void){
    bool flag=true;
    string str,voc;
    getline(cin,str);
    for(int i=0;i<str.size();i++){
        if(str[i]=='.'||str[i]==',')str[i]=' ';
    }
    stringstream sstr(str);
    while(sstr>>voc){
        if(3<=voc.size()&&voc.size()<=6){
            if(flag){
                cout<<voc;
                flag=false;
            }
            else cout<<" "<<voc;
        }
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 1196
n, m = gets.split.map(&:to_i)

P = Struct.new(:a, :b)
l = []
n.times do |i|
  a, b = gets.split.map(&:to_i)
  l[i] = P.new(a, b)
end

# 配列lをa(価格)で昇順ソート
l = l.sort{
  |l1, l2| l1.a <=> l2.a
}

ans = 0
l.each do |x|
  if m <= x.b
    ans += m * x.a
    break
  else
    ans += x.b * x.a
    m -= x.b
  end
  # puts ans
end
puts ans

Measured memory_bytes: 11128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>

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

using namespace std;
typedef long long int ll;
const int INF = 100000000;

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

    int ans = -1;
    rep(i, 1300) {
        int n = floor(i * 0.08);
        int m = floor(i * 0.1);
        if (n == a && m == b) {
            if (ans == -1) ans = i;
            else ans = min(ans, i);
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  string S;
  ll K;
  cin >> S >> K;
  ll i = 0;
  int num;
  while (K) {
    char c = S[i];
    num = c - '0';
    K -= pow(num,5*pow(10,12));
    if (K < 0) break;
    i++;
  }
  cout << num << endl;
  return 0;
}

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

template <typename T>
struct UnionFind{
    std::vector<T> par, rank, sz;
    UnionFind(T n) : par(n), rank(n, 0), sz(n, 1){
        for(T i=0; i<n; i++) par[i] = i;
    }
    void init(T n){
        par.resize(n);
        rank.resize(n);
        sz.resize(n);
        for(T i=0; i<n; i++){
            par[i] = i;
            rank[i] = 0;
            sz[i] = 1;
        }
    }
    
    int root(T x){
        if(par[x] == x) return x;
        else  return par[x] = root(par[x]);
    }
    
    bool is_same(T x, T y){
        return root(x)==root(y);
    }
    
    int size(T x) {
        return sz[root(x)];
    }
    
    bool unite(T x, T y){
        x = root(x);
        y = root(y);
        if(x==y) return false;
        
        if(rank[x] < rank[y]) std::swap(x, y);
        if(rank[x]==rank[y]) rank[x]++;
        par[y] = x;
        sz[x] += sz[y];
        return true;
    }
};

int main() {
    int N, M, K; cin >> N >> M >> K;
    map<int, vector<int>> friends;
    map<int, vector<int>> block;
    vector<int> ans(N);
    UnionFind<int> ff(N);
    for (int i = 0; i < M; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        friends[a].push_back(b);
        friends[b].push_back(a);
        ff.unite(a, b);
    }

    for (int i = 0; i < N; i++)
    {
        ans[i] = ff.size(i)-friends[i].size()-1;
    }
    
    for (int i = 0; i < K; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        if(ff.is_same(a,b)){
            ans[a]--;
            ans[b]--;
        }
    }

    for (int i = 0; i < N; i++)
    {
        cout << ans[i];
        if(i!=N-1) cout << " ";
        else cout << endl;
    }
}

Measured memory_bytes: 13688
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
const int MAX =1e5+6;
const long long inf=1e18;
const int mod=1e9+7;
vector<int>adj[MAX];

int main(){
    int a;
    int f=0;
    cin>>a;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==a)
                f=1;
        }
    }
    if(f)
        cout<<"Yes";
    else
        cout<<"No";
}

Measured memory_bytes: 2560
import java.util.*;
import java.io.*;

public class Main {


    public Main(FastScanner in, PrintWriter out) {
        String s = in.next();
        Map<Integer, Integer> map = new HashMap<>();
        map.put(0, 1);
        long res = 0;
        int n = s.length(), cur = 0, p = 1;
        for (int i = n - 1; i >= 0; i--) {
            int d = s.charAt(i) - '0';
            cur = (d * p + cur) % 2019;
            res += map.getOrDefault(cur, 0);
            map.merge(cur, 1, Integer::sum);
            p = p * 10 % 2019;
        }
        out.println(res);
    }

    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        // Scanner in = new Scanner(
                // new BufferedReader(new InputStreamReader(System.in)));
        FastScanner in = new FastScanner(System.in);

        Main sol = new Main(in, out);

        out.close();
    }
}


class FastScanner{
    private InputStream stream;
    private byte[] buf = new byte[1024];
    private int curChar;
    private int numChars;

    public FastScanner(InputStream stream)
    {
        this.stream = stream;
    }

    int read()
    {
        if (numChars == -1)
            throw new InputMismatchException();
        if (curChar >= numChars){
            curChar = 0;
            try{
                numChars = stream.read(buf);
            } catch (IOException e) {
                throw new InputMismatchException();
            }
            if (numChars <= 0)
                return -1;
        }
        return buf[curChar++];
    }

    boolean isSpaceChar(int c)
    {
        return c==' '||c=='\n'||c=='\r'||c=='\t'||c==-1;
    }

    boolean isEndline(int c)
    {
        return c=='\n'||c=='\r'||c==-1;
    }

    int nextInt()
    {
        return Integer.parseInt(next());
    }

    long nextLong()
    {
        return Long.parseLong(next());
    }

    double nextDouble()
    {
        return Double.parseDouble(next());
    }

    String next(){
        int c = read();
        while (isSpaceChar(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isSpaceChar(c));
        return res.toString();
    }

    String nextLine(){
        int c = read();
        while (isEndline(c))
            c = read();
        StringBuilder res = new StringBuilder();
        do{
            res.appendCodePoint(c);
            c = read();
        }while(!isEndline(c));
        return res.toString();
    }
}


Measured memory_bytes: 44088
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    long long x;
    cin >> N;
    cin >> x;
    vector<long long> a;
    a.resize(N);
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    int i = 1;
    if(a[0] > x) cout << 0 << "\n";
    else{
        while(i < N){
            a[i]+= a[i-1];
            if(a[i] == x){
                cout << i + 1 << "\n";
                break;
            }
            else if(a[i] > x){
                cout << i << "\n";
                break;
            }else{
                i++;
            }
        }
        if(i == N) cout << N - 1 << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define INF 1e9+7
#define pf2 pop_front
#define pb2 pop_back
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order //ind k (ind from 0 )
#define fastio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key // < x
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

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

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}

void pr(string x){
	freopen((x+".in").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}
//Reynaldo's Template

int main(){
	ll N,K;
	cin >> N >> K;
	ll x[N+5];
	for(int i=1;i<=N;i++) cin >> x[i];
	tree<pair<ll,ll> ,null_type,less<pair<ll,ll> >,rb_tree_tag,tree_order_statistics_node_update> st;
	ll ans = 0,sum1 = 0,sum2 = 0;
	st.insert({0,0});
	for(ll i=1;i<=N;i++){
		sum1 += x[i];
		ll tmp = sum1  - (i * K);
//		cout << tmp << " " << st.ofk({tmp+1,1e9})<< "\n";
		ans += st.ofk({tmp+1,-1});		
		sum2+= x[i];
		ll tmp2 = sum2 - (i*K);
		st.insert({tmp2,i});
	}
	cout << ans << "\n";
}



Measured memory_bytes: 14336
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
using namespace std;
const int mod = 1000000007;
#define ll long long

int main()
{
	string S;
	cin >> S;
	int an = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '+')an++;
		else an--;
	}
	cout << an << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        String S=sc.next();
        int yy=Integer.valueOf(S.substring(0,2));
        int mm=Integer.valueOf(S.substring(2,4));
        if(isMonth(yy)&&isMonth(mm)){
            System.out.println("AMBIGUOUS");
        }else if(isMonth(mm)){
            System.out.println("YYMM");
        }else if(isMonth(yy)){
            System.out.println("MMYY");
        }else {
            System.out.println("NA");

        }

    }
    static boolean isMonth(int a){
        return a>0&&a<13;
    }

}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=200010;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
LL ans;
char str[N];
int n,sz[N];
int bgn[N],nxt[N<<1],to[N<<1],E;
int Max[N],Maxc[N],Maxp[N],Min[N];
inline void add_edge(int u,int v){nxt[++E]=bgn[u],bgn[u]=E,to[E]=v;}
inline void dfs1(int u,int f)
{
	sz[u]=(str[u]=='1');
	Min[u]=inf;
	for(int v,i=bgn[u];i;i=nxt[i])
	{
		if((v=to[i])==f)continue;
		dfs1(v,u);
		sz[u]+=sz[v];
		if(sz[v])chkmin(Min[u],Max[v]+1);
		if(Max[v]+1>Max[u])
			Maxc[u]=Max[u],Max[u]=Max[v]+1,Maxp[u]=v;
		else
			chkmax(Maxc[u],Max[v]+1);
	}
}
inline void dfs2(int u,int f)
{
	for(int v,i=bgn[u];i;i=nxt[i])
	{
		if((v=to[i])==f)continue;
		if(Maxp[u]==v)
		{
			if(Maxc[u]+1>Max[v])
				Maxc[v]=Max[v],Max[v]=Maxc[u]+1,Maxp[v]=u;
			else
				chkmax(Maxc[v],Maxc[u]+1);
			if(sz[1]-sz[v]>0)chkmin(Min[v],Maxc[u]+1);
		}
		else
		{
			if(Max[u]+1>Max[v])
				Maxc[v]=Max[v],Max[v]=Max[u]+1,Maxp[v]=u;
			else
				chkmax(Maxc[v],Max[u]+1);
			if(sz[1]-sz[v]>0)chkmin(Min[v],Max[u]+1);
		}
		dfs2(v,u);
	}
	//printf("%d 1:%d p:%d 2:%d min:%d\n",u,Max[u],Maxp[u],Maxc[u],Min[u]);
	int high=min(Max[u]-1,Maxc[u]+1);
	if(str[u]=='1')
		ans+=high+1;
	else
	if(Min[u]<=high)
		ans+=high-Min[u]+1;
}
int main()
{
	int x,y;
	file();
	read(n);
	For(i,2,n)read(x),read(y),add_edge(x,y),add_edge(y,x);
	scanf("%s",str+1);
	dfs1(1,0);
	dfs2(1,0);
	printf("%lld\n",ans+1);
	return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define sz(s) (int)(s.size())
#define mod 1000000007

using namespace std;
class CompareFirst
{
public:
  bool operator()(pair<int,int> n1,pair<int,int> n2) {
    return n1.first>n2.first; //>:desc <:asc
  }
};


int main(){

  string s;
  char dig;
  int i,j,k,l,n,m,keta;
  vector<string> vs;
  vector<int> vi;
  pair<int,int> pr;
  //unordered_map<string,int> mp;
  //priority_queue<int> pq; // default ‘å‚«‚¢‡
  //priority_queue<pair<int,int>,vector<pair<int,int>>,CompareFirst> pq;
  
  long long ans=0,com;

  cin >> s;
  n = (int)(s.size());
  long long dp[13]={0};

  int mul = 1;
  dp[0]=1;
  rep(i,0,n-1){
      long long nextdp[13]={0};
    dig = s[n-1-i];
    if(dig == '?'){
      rep(j,0,9){
        rep(k,0,12){
          nextdp[(mul*j+k)%13] += dp[k];
          nextdp[(mul*j+k)%13] %= mod;
        }
      }
      j=-1;
    }else{
      j=(int)(dig - '0'); 
      rep(k,0,12){
        nextdp[(mul*j+k)%13] += dp[k];
        nextdp[(mul*j+k)%13] %= mod;
      }
    }
    mul *= 10;
    mul %= 13;
    swap(dp,nextdp);
 //   cout << i << " ";
 //   cout << j << " ";
 //   cout << dig << " ";
 //   rep(j,0,12)cout << dp[j] << " ";
 //     cout << endl;
  }

  cout << dp[5] << endl;

  return 0;

}

Measured memory_bytes: 512
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main() {
    int a, b;
    char op;

    while (true) {
        cin >> a >> op >> b;
        
        if (op == '?') break;
        else if (op == '+') cout << a + b << endl;
        else if (op == '-') cout << a - b << endl;
        else if (op == '*') cout << a * b << endl;
        else if (op == '/') cout << a / b << endl;
    }
}

Measured memory_bytes: 3004
use v5.26; # strict say state biwise
use warnings;
use List::Util qw(reduce any all none notall first max maxstr min minstr product sum sum0 pairs unpairs pairkeys pairvalues pairfirst pairgrep pairmap shuffle uniq uniqnum uniqstr);

chomp (my $n = <STDIN>);
chomp (my $s = <STDIN>);
my ($ans, $r, $g, $b) = (0, 0, 0, 0);
for my $i (0..$n-1) {
  if (substr($s, $i, 1) eq 'R') {
    $r++;
  } elsif (substr($s, $i, 1) eq 'G') {
    $g++;
  } else {
    $b++;
  }
  for my $j ($i+1..$n-1) {
    my $k = $j + $j - $i;
    last if $k >= $n;
    $ans++ if substr($s, $i, 1) ne substr($s, $j, 1) && substr($s, $i, 1) ne substr($s, $k, 1) && substr($s, $j, 1) ne substr($s, $k, 1);
  }
}
say ($r * $g * $b - $ans);

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

int main() {
    int N;
    int a;
    cin >> N;
    vector<int> A;
    rep(i, N-1) {
        cin >> a;
        A.push_back(a);
    }
    vector<int> ans(N);
    for(int ai: A) {
        ans[ai-1] += 1;
    }

    for(int an: ans) {
        cout << an << endl;
    }
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct uftree{
	int par[200005];
	int rank[200005];
	int cnt[200005];
	uftree(){
	}
	void init(int n){
		for(int i=0;i<n;i++){
			par[i]=i;
			rank[i]=0;
			cnt[i]=1;
		}
	}
	int find(int x){
		if(par[x]==x)return x;
		return par[x]=find(par[x]);
	}

	void unite(int x,int y){
		x=find(x);
		y=find(y);
		if(x==y)return;
		if(rank[x]<rank[y]){
			cnt[y]+=cnt[x];
			par[x]=y;
		}else{
			if(rank[x]==rank[y])rank[x]++;
			cnt[x]+=cnt[y];
			par[y]=x;
		}
	}

	int getCnt(int x){
		x=find(x);
		return cnt[x];
	}

	bool same(int x,int y){
		return find(x)==find(y);
	}
};


int n,p1,p2;
uftree uf;
int f[1001],t[1001];
string str[1001];
int dp[601][601];
int prev[601][601];
vector<int> G[601];
int cnt[601][2];
vector<int> member[601][2];
int gr[601][2];
int flag[601];
int path[601][601];
int nv;

bool dfs(int v,int c){
	gr[nv][c]=v;
	flag[v]=c;
	cnt[nv][c]+=uf.getCnt(v);
	for(int i=0;i<p1+p2;i++){
		if(uf.same(i,v))member[nv][c].push_back(i);
	}
	for(int i=0;i<G[v].size();i++){
		if(flag[G[v][i]]>=0){
			if(flag[v]==flag[G[v][i]])return false;
		}else{
			if(!dfs(G[v][i],1-c))return false;
		}
	}
	return true;
}

void solve(){
	uf.init(p1+p2);
	for(int i=0;i<n;i++){
		if(str[i]=="yes"){
			uf.unite(f[i],t[i]);
		}
	}
	for(int i=0;i<p1+p2;i++){
		G[i].clear();
	}
	memset(path,0,sizeof(path));
	for(int i=0;i<n;i++){
		if(str[i]=="no"){
			if(path[uf.find(f[i])][uf.find(t[i])]==1)continue;
			G[uf.find(f[i])].push_back(uf.find(t[i]));
			G[uf.find(t[i])].push_back(uf.find(f[i]));
			path[uf.find(f[i])][uf.find(t[i])]=1;
			path[uf.find(t[i])][uf.find(f[i])]=1;
		}
	}
	memset(dp,0,sizeof(dp));
	memset(flag,-1,sizeof(flag));
	memset(gr,-1,sizeof(gr));
	memset(cnt,0,sizeof(cnt));
	dp[0][0]=1;
	nv=0;
	for(int i=0;i<p1+p2;i++){
		member[nv][0].clear();
		member[nv][1].clear();
		int v=uf.find(i);
		if(flag[v]==-1){
			if(!dfs(v,0)){
				printf("no\n");
				return;
			}
			if(cnt[0]==cnt[1]){
				printf("no\n");
				return;
			}
			for(int j=p1;j>=0;j--){
				if(dp[nv][j]==0)continue;
				dp[nv+1][j+cnt[nv][0]]+=dp[nv][j];
				prev[nv+1][j+cnt[nv][0]]=j;

				dp[nv+1][j+cnt[nv][1]]+=dp[nv][j];
				prev[nv+1][j+cnt[nv][1]]=j;
			}
			nv++;
		}
	}
	if(dp[nv][p1]!=1){
		printf("no\n");
		return;
	}
	vector<int> ans;
	int nowp1=p1;
	for(int i=nv;i>=1;i--){
		int diff=nowp1-prev[i][nowp1];
		if(diff>0){
			if(diff==cnt[i-1][0]){
				for(int j=0;j<member[i-1][0].size();j++){
					ans.push_back(member[i-1][0][j]);
				}
			}else{
				for(int j=0;j<member[i-1][1].size();j++){
					ans.push_back(member[i-1][1][j]);
				}
			}
		}
		nowp1=prev[i][nowp1];
	}
	sort(ans.begin(),ans.end());
	for(int i=0;i<ans.size();i++){
		printf("%d\n",ans[i]+1);
	}
	printf("end\n");
}

int main(void){
	while(1){
		scanf("%d%d%d",&n,&p1,&p2);
		if(n==0 && p1==0 && p2==0)break;
		for(int i=0;i<n;i++){
			cin >> f[i] >> t[i] >> str[i];
			f[i]--;
			t[i]--;
		}
		solve();
	}
	return 0;
}

Measured memory_bytes: 6588
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define pb push_back
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define F first
#define S second
#define MP make_pair
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

priority_queue<int,vector<int>,greater<int>> wall[200005],wally[200005];

int main()
{jizz
	int h,w,n,x,y,ans,nw=1;
	cin >> h >> w >> n,ans=h;
	for(int i=0;i<n;++i)
		cin >> y >> x,wall[x].push(y),wally[y].push(x);
	for(int i=1;i<=h;++i)
	{
		while(!wall[nw].empty()&&wall[nw].top()<=i) wall[nw].pop();
		if(!wall[nw].empty())
		{
			ans=min(ans,wall[nw].top()-1);
			//cout << i << " " << nw << " " << wall[nw].top() << "\n";
			if(wall[nw].top()-1==i) break;
		}
		if(i==h) break;
		while(!wally[i+1].empty()&&wally[i+1].top()<=nw) wally[i+1].pop();
		if(wally[i+1].empty()||wally[i+1].top()!=nw+1) ++nw;
	}
	cout << ans << "\n";
}

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

using namespace std;

int main() {

	long n, m;
	cin >> n >> m;

	vector<long> c(m + 1);
	for (long i = 0; i < m; i++) {
		cin >> c[i];
	}

	vector<long> dp(n + 2,1000000000);

	dp[0] = 0;
	for (long i = 1; i <= n; i++) {

		for (long j = 0; j < m; j++) {
			if (i - c[j] >= 0) {
				dp[i] = min(dp[i],dp[i - c[j]] + 1);
			}
		}
	}

	cout << dp[n] << endl;

	return 0;
}


Measured memory_bytes: 3120
n = int(input())
H = list(map(int, input().split()))
INF = 10**8
C = [INF]*n
C[0] = 0
C[1] = abs(H[1]-H[0])
for i in range(2,n):
  C[i] = min(C[i-2]+abs(H[i]-H[i-2]),C[i-1]+abs(H[i]-H[i-1]))
print(C[n-1])

Measured memory_bytes: 13924
import core.bitop;
import std.algorithm;
import std.array;
import std.ascii;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;
void log(A...)(A arg) { stderr.writeln(arg); }
int size(T)(in T s) { return cast(int)s.length; }

void main() {
    int N, M;
    int[][] B;
    bool input() {
        readf("%d %d\n", &N, &M);
        if (N == 0 && M == 0) return false;
        B = iota(0, N, 1).map!((i) => readln.chomp.map!((a) => cast(int)(a - '0')).array).array;
        return true;
    }
    void solve() {
        if (N <= M) {
            int ans = 0;
            foreach (int bit; 0 .. (1 << N)) {
                // bit: ?????????????????¬??§??????????????§????????¶?°
                foreach (j; 0 .. M) {
                    int c = 0;
                    foreach (i; 0 .. N) {
                        if (bit & (1 << i)) {
                            c += B[i][j];
                        }
                    }
                    if (c % 2 != 0) goto next;
                }
                ans = max(ans, bit.popcnt);
                next:;
            }
            writeln(ans);
        } else {
            auto X = B.map!((xs) => xs.map!(to!string).join("").to!int(2)).array;
            auto cur = new int[1 << M];
            auto prv = new int[1 << M];
            cur[] = int.min / 4;
            prv[] = int.min / 4;
            cur[0] = 0;
            foreach (j; 0 .. N) {
                swap(cur, prv);
                foreach (int bit; 0 .. (1 << M)) {
                    // bit: ???????????????????????§??????????????£???????°
                    cur[bit ^ X[j]] = max(cur[bit ^ X[j]], prv[bit] + 1);
                    cur[bit] = max(cur[bit], prv[bit]);
                }
            }
            writeln(cur[0]);
        }
    }
    while (input()) {
        solve();
    }
}

Measured memory_bytes: 21752
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int A;
int B;

int main(){
	
	cin>>A>>B;
	
	if( A+B >= 10 ) puts("error");
	else{		cout<<A+B<<endl;}
		
	
	
	return 0;

}

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

int main() {
    int n;
    cin >> n;
    string s[n];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    int ans = 0;
    int acnt = 0, bcnt = 0, abcnt = 0;
    for (int i = 0; i < n; i++) {
        int m = s[i].length();
        for (int j = 0; j < m - 1; j++) {
            if (s[i][j] == 'A' && s[i][j+1] == 'B') ans++;
        }
        if (s[i][0] == 'B' && s[i][m-1] == 'A') abcnt++;
        else if (s[i][0] == 'B') bcnt++;
        else if (s[i][m-1] == 'A') acnt++;
    }

    if (acnt == 0 && bcnt == 0) ans += max(0, abcnt - 1);
    else ans += abcnt + min(acnt, bcnt);

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


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


#define base 1000000007LL
#define ll long long
// unsigned long long int t = 10000000000000000003ULL;
#define ulint unsigned long long int
#define ld long double
#define X first
#define Y second
#define pb push_back
#define EPS 1e-15
#define all(a) (a).begin(), (a).end()
#define sz(a) int((a).size())

#define ms(s, n) memset(s, n, sizeof(s))

#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define sqr(a) (a)*(a)

#define foru(i,a,b) for (ll i = (a); i <= (b); i++)
#define ford(i,a,b) for (ll i = (a); i >= (b); i--)
#define cbit(a) __builtin_popcount(a)
#define uni(a) (a).resize(unique(all(a)) - (a).begin())
#define cprint(n) printf("%.6lf + %.6lfi\n", (n).real(), (n).imag())

#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it !=(a).end(); it++)


using namespace std;
typedef pair<ll, ll> II;
typedef pair<int, int> ii;



struct Edge{
    ll u,v,w;
    Edge(ll u=0, ll v=0, ll w=0): u(u),v(v),w(w) {}
    bool operator < (Edge a){return w<a.w;}
};

const int M=1e5+7;
const int MM=4*M;
const ll MOD=base;
const int MAX=1e9;


inline ll gcd(ll a, ll b) {ll r; while (b) {r = a % b; a = b; b = r;} return a;}
inline ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
inline ll power(ll n, ll k, ll p = MOD) {ll r = 1; for (; k; k >>= 1LL) {if (k & 1LL) r = r * n % p; n = n * n % p;} return r;}
inline ll inverse(ll n, ll p=MOD){return power(n,p-2);}
ll search(ll a[], ll N, ll x){ ll l = 0, r = N - 1; while (l <= r){ ll mid = (l + r) / 2; if (x == a[mid]){ return 1; } else if (x < a[mid]){ r = mid - 1; } else if (x > a[mid]){ l = mid + 1; } } return -1; }
ll find_greater_equal(ll a[], ll N, ll x){ int q = lower_bound(a, a + N, x) - a; if(q == N){ return -1; } return q; }
ll find_greater(ll a[], ll N, ll x){ int q = upper_bound(a, a + N, x) - a; if(q == N){ return -1; } return q; }

string s;
string t;
ll c1[26], c2[26];
vector<ll> a;
vector<ll> b;
int main(){
    ios::sync_with_stdio(0);
    cin >> s >> t;
    for (int i = 0; i < s.size(); i++){
    	c1[s[i] - 'a']++;
	}
	for (int i = 0; i < t.size(); i++){
    	c2[t[i] - 'a']++;
	}
	ll n = 26;
	for (int i = 0; i < n; i++){
		if(c1[i] != c2[i]){
			if(c1[i] > 0){
				a.push_back(c1[i]);
			}
			if(c2[i] > 0){
				b.push_back(c2[i]);
			}
		}
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if(a.size() != b.size()){
		cout << "No"; return 0;
	}
	for(int i = 0; i < a.size(); i++){
		if(a[i] != b[i]){
			cout << "No"; return 0;
		}
	}
	cout << "Yes";
    return 0;
}





Measured memory_bytes: 916
A, B, M = map(int, input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
X = [list(map(int,input().split())) for i in range(M)]

min_price = min(a) + min(b)

for i in X:
    min_price = min(min_price, a[i[0]-1] + b[i[1]-1] - i[2])

print(min_price)

Measured memory_bytes: 38560
#include <bits/stdc++.h>
#include <cstdlib>  // abs() for integer 絶対値求めやつ
#include <cmath>    // abs() for float, and fabs()
#include <algorithm>
#include <vector>
#include <string>
#define rep(i,n) for(int i = 0; i < (n);i++)
#define SORT(a) sort((a).begin(),(a).end());
using namespace std;
#define INF 2000000000
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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;

// enter
int n ;
long long w, weight[110],value[110];

//dp
long long dp[110][100100]={0};

int main(){
		cin>> n >> w;
		rep(i,n) cin>> weight[i] >> value[i];

		//DP roop
		rep(i,n){
			for(int sum_w = 0 ; sum_w <= w; sum_w ++){
				//i番目の品を選ぶ場合
				if(sum_w - weight[i] >= 0){
					/*cout<<"dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]"<<endl;
					che(dp[i][sum_w - weight[i]],"dp[i][sum_w - weight[i]]");
					che(i+1,"i+1番目");che(sum_w,"sum_0");che(weight[i],"weight[i]");che(value[i],"value[i]");*/

					chmax(dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]);
					//che(dp[i+1][sum_w],"dp[i+1][sum_w]");
				}

				//i番目の品物を選ばない場合
/*cout<<"dp[i+1][sum_w], dp[i][sum_w - weight[i]] + value[i]"<<endl;
che(dp[i][sum_w - weight[i]],"dp[i][sum_w - weight[i]]");
					che(i+1,"i+1番目");che(sum_w,"sum_0");che(weight[i],"weight[i]");che(value[i],"value[i]");
				che(dp[i][sum_w],"dp[i][sum_w]");*/
				chmax(dp[i+1][sum_w], dp[i][sum_w]);
					//che(dp[i+1][sum_w],"dp[i+1][sum_w]");

			}
		}
		cout<<dp[n][w]<<endl;

				}
																								

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

typedef long long ll;

inline int read()
{
    int x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            f=-f;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        x=(x<<1)+(x<<3)+(c^48);
        c=getchar();
    }
    return f*x;
}

int a[1000005];

int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1; i<=100; i++)
    {
        for(int j=1; j<=100; j++)
        {
            for(int k=1; k<=100; k++)
            {
                int p=i*i+j*j+k*k+i*j+k*j+i*k;
                if(p<=10000)
                    a[p]++;
            }
        }
    }
    for(int i=1; i<=n; i++)
    {
        printf("%d\n",a[i]);
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
const ll M = 998244353;

int main(){
  ll N,K;
  cin>> N >> K;
  ll L[K],R[K];
  //vector<ll> p;
  for(ll i=0;i<K;i++){
    cin >> L[i] >> R[i];
  }
  ll a[N+1];
  ll f[N+1];
  for(ll i=0;i<N+1;i++){
    f[i]=0;
    a[0]=0;
  }
  f[1] = 1;
  a[1] = 1;
  for(ll i=0;i<N+1;i++){
    for(ll j=0;j<K;j++){
      ll li = i-R[j];
      ll ri = i-L[j];
      if(ri<0) continue;
      if(li<1) li=1;
      f[i] += (a[ri] - a[li-1])%M;
    }
    a[i] = a[i-1]+f[i];
  }

  cout << f[N]%M << endl;
}


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

int main() {
  set<string> st;
  int n;
  cin>>n;
  while (n--) {
    string cmd, str;
    cin>>cmd>>str;
    if (cmd=="insert") {
      st.insert(str);
    } else {
      cout<<(st.find(str)!=st.end()?"yes":"no")<<endl;
    }
  }
  return 0;
}



Measured memory_bytes: 32184
#include<cstdio>
int n, q;
char s[300000]={};
int t[300000]={};
int d[300000]={};


int kekka(int x){
	int iti=x;
	int mode=0;
	for(int i=0;i<q;i++){
		if(s[iti]==t[i]){
			if(d[i]==0)iti--;
			else iti++;
		}
		if(iti==-1){
			mode=-1;
			break;
		}
		if(iti==n){
			mode=1;
			break;
		}
	}
	return mode;
}
int main(){
	scanf("%d%d",&n,&q);
	scanf("%s",s);
	char x[2];
	char y[2];
	for(int i=0;i<q;i++){
		scanf("%s%s",x,y);
		t[i]=x[0];
		d[i]=(y[0]=='R');
	}
	
	int ll,rr;
	int l=0;
	int r=n-1;
	if(kekka(0)>=0){
		ll=-1;
	}else if(kekka(n-1)==-1){
		ll=n-1;
	}else{
		for(int i=0;true;i++){
			if(l+1==r){
				ll=l;
				break;
			}
			
			if(kekka((l+r)/2)==-1)l=(l+r)/2;
			else r=(l+r)/2;
		}
	}
	l=0;
	r=n-1;
	if(kekka(n-1)<=0){
		rr=n;
	}else if(kekka(0)==1){
		rr=0;
	}else{
		for(int i=0;true;i++){
			if(l+1==r){
				rr=r;
				break;
			}
			
			if(kekka((l+r)/2)==1)r=(l+r)/2;
			else l=(l+r)/2;
		}
	}
	printf("%d\n",rr-ll-1);
	return 0;
}

Measured memory_bytes: 1920
n = gets.to_i
w = []
n.times do
  w << gets
end
if w.uniq.size == n
head = []
tail = []
w.each do |i|
  head << i[0]
  tail << i[-2]
end
head.shift
tail.pop
if head == tail
  ans = 'Yes'
else
  ans = 'No'
end
else
  ans = 'No'
end
puts ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	scanf("%d",&n);
	getchar();
	string s;
	getline(cin,s);
	m=s.size();
	m/=2;
	int flag=1;
	if(n%2)printf("No\n");
	else {
		for(int i=0;i<m;i++) {
			if(s[i]!=s[i+m]) {
				flag=0;
				//printf("%c %c\n",s[i],s[i+m]);
			}
		}
		if(flag) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
} 

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

int main(){
    
        string N;
        cin>>N;
        
        int sum=0;
        
        for(int i=N.size()-1;i>=0;i--){
            sum+=(N.at(i)-'0')*pow(10,N.size()-1-i);
        }
        
        int sum1=0;
        
        int X;
        
        int Y;
        
        for(int i=0;i<N.size();i++){
            
            if(i==0){
                sum1+=sum%10;
                X=sum%10;
            }
            else if(i==1){
                sum1+=((sum-X)/10)%10;
                Y=(sum-X)/10;
                X=((sum-X)/10)%10;
            }
            
            
            else{
                sum1+=((Y-X)/10)%10;
                int a=(Y-X)/10;
                X=a%10;
                Y=a;
                
                
                
            }
        }
        
        if(sum%sum1==0){
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }



Measured memory_bytes: 256
N = int(input())

A = map(int, input().split())
B = map(int, input().split())
C = map(int, input().split())

L = []
L.extend(((x, 3)  for x in A))
L.extend(((x, 2)  for x in B))
L.extend(((x, 1)  for x in C))

L = sorted(L, reverse=True)

cnt_C = 0
cnt_B = 0
cnt_A = 0
for x, i in L:
    if i == 1:
        cnt_C += 1
    elif i == 2:
        cnt_B += cnt_C
    elif i == 3:
        cnt_A += cnt_B

print(cnt_A)


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

#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0);
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(ll x=j;x<n;x++)
#define repr(x,j,n)for(ll x=j;x>n;x--)
#define mod 1000000007
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;



ll modexp(ll a,ll b,ll m)
{
    ll r=1;
    a=a%m;
    while(b>0)
    {
    if(b&1)
    r=(r*a)%m;
    b=b/2;
    a=(a*a)%m;
    }
    return r%m;
}

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


ll n;
cin>>n;
vi a(4,0);
rep(i,0,n)
{
    string s;
    cin>>s;
    if(s=="AC")a[0]++;
    else if(s=="WA")a[1]++;
    else if(s=="TLE")a[2]++;
    else a[3]++;
}
cout<<"AC x "<<a[0]<<endl;
cout<<"WA x "<<a[1]<<endl;
cout<<"TLE x "<<a[2]<<endl;
cout<<"RE x "<<a[3]<<endl;

}


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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int A, B, K;
  cin >> A >> B >> K;
  set<int> st;
  for (int i = 0; i < K; i++) {
    if (i + A <= B)
      st.insert(A + i);
    if (A <= B - i)
      st.insert(B - i);
  }
  for (auto x : st)
    cout << x << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int[] a = new int[n];
        for(int i = 0;i<a.length;i++) {
            a[i] = stdIn.nextInt();
            //System.out.println(a[i]);
        }
        double sum = 0;
        for(int i = 0;i<a.length;i++) {
            //System.out.println(a[i]);
            sum += (double)1/a[i];
        }
        //System.out.println(sum);
       System.out.println(1/sum);
    }
}

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

long long GCD(long long x,long long y){
  if(y == 0) return x;
  return GCD(y,x%y);
}


int main() {
  long long a = 1;
  int n;
  cin >> n;
  for(int i = 0;i < n;i++){
    long long b;
    cin >> b;
    a *= b/GCD(a,b);
  }
  cout << a << endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int a_1, a_2, a_3;
  cin>>a_1>>a_2>>a_3;
  int S=a_1+ a_2+ a_3;
  if(S>=22){
    cout<<"bust"<<endl;
  }else{
    cout<<"win"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
array = list(map(int, input().split()))
dic = {}
ans = 0
for item in array:
    if item in dic:
        dic[item] += 1
    else:
        dic[item] = 1
dic_sorted = sorted(dic.items(), key=lambda x:x[1])
count = len(dic)
i = 0
while K < count:
    count -= 1
    ans += dic_sorted[i][1]
    i += 1
print(ans)


Measured memory_bytes: 38964
//g++でビルド

#include "bits/stdc++.h"

using namespace std;

int n;
vector<pair<int, int> > bluepoints;
vector<int> redx, redy, bluex, bluey;

int main(){
    cin >> n;
    redx.resize(n);
    redy.resize(n);
    bluex.resize(n);
    bluey.resize(n);
    for(int i = 0; i < n; i++){
        cin >> redx[i] >> redy[i];
    }
    for(int i = 0; i < n; i++){
        cin >> bluex[i] >> bluey[i];
        bluepoints.push_back(make_pair(bluex[i], bluey[i]));
    }

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

    for(int i = 0; i < n; i++){
        bluex[i] = bluepoints[i].first;
        bluey[i] = bluepoints[i].second;
    }

    int result = 0;

    vector<bool> red(n, false), blue(n, false);

    for(int i = 0; i < n; i++){
        if(blue[i]){
            continue;
        }
        int x = -1;
        int y = -1;
        int maxy = -10000000;
        for(int j = 0; j < n; j++){
            if(!red[j] && redx[j] < bluex[i] && redy[j] < bluey[i] && redy[j] > maxy){
                x = i;
                y = j;
                maxy = redy[j];
            }
        }

        if(x != -1){
            result++;
            red[y] = true;
            blue[x] = true;
            //cout << "pair:" << redx[y] << " "  << redy[y] << "    " << bluex[x] << " " << bluey[x] << endl;
        }
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 256