akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main { //クラス名はMain
    public static void main(String[] args) {
      //整数の入力
      Scanner sc = new Scanner(System.in);
      String S = sc.next();

      String answer = S.equals("ABC") ? "ARC" : "ABC";
 
      System.out.println(answer);
    }
}

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

typedef struct node{
  int left;
  int right;
  int parent;
}node;

void Preorder(int);
void Inorder(int);
void Postorder(int);

node* tree;
int n;

int main(){
  int i,n,id,left,right,root;

  scanf("%d",&n);

  tree = (node *)malloc(sizeof(node)*n);

  for(i=0;i<n;i++) tree[i].parent = -1;
  for(i=0;i<n;i++){
    scanf("%d %d %d",&id,&left,&right);
    tree[id].left=left;
    tree[id].right=right;
    if(left!=-1) tree[left].parent=id;
    if(right!=-1) tree[right].parent=id;
  }

  for(i=0;i<n;i++){
    if(tree[i].parent==-1) break;
  }
  root=i;

  printf("Preorder\n");
  Preorder(root);
  printf("\n");

  printf("Inorder\n");
  Inorder(root);
  printf("\n");

  printf("Postorder\n");
  Postorder(root);
  printf("\n");

  return 0;
}

void Preorder(int c){
  printf(" %d",c);
  if(tree[c].left != -1) Preorder(tree[c].left);
  if(tree[c].right != -1) Preorder(tree[c].right);
  return;
}

void Inorder(int c){
  if(tree[c].left != -1) Inorder(tree[c].left);
  printf(" %d",c);
  if(tree[c].right != -1) Inorder(tree[c].right);
  return;
}

void Postorder(int c){
  if(tree[c].left != -1) Postorder(tree[c].left);
  if(tree[c].right != -1) Postorder(tree[c].right);
  printf(" %d",c);
  return;
}

Measured memory_bytes: 616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=403,INF=1<<30;
ll table[MAX][MAX];

void make(){
    for(ll i=1;i<=400;i++){
        ll res=1;
        table[i][0]=res;
        for(int j=1;j<=400;j++){
            res*=i;
            res%=mod;
            table[i][j]=res;
        }
    }
    
    for(int j=0;j<=400;j++){
        for(int i=1;i<=400;i++){
            table[i][j]+=table[i-1][j];
            table[i][j]%=mod;
        }
    }
}

int main(){
    
    make();
    int N,C;cin>>N>>C;
    vector<ll> A(N),B(N);
    
    for(int i=0;i<N;i++) cin>>A[i];
    for(int i=0;i<N;i++) cin>>B[i];
    
    ll dp[N+1][C+1];
    for(int i=0;i<=N;i++){
        for(int j=0;j<=C;j++){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    
    for(int i=1;i<=N;i++){
        for(int j=0;j<=C;j++){
            for(int k=0;k<=j;k++){
                dp[i][j]+=dp[i-1][j-k]*((table[B[i-1]][k]-table[A[i-1]-1][k]+mod)%mod);
                dp[i][j]%=mod;
            }
        }
    }
    
    cout<<dp[N][C]<<endl;
}





Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 500000

using namespace std;

struct yes {
  int l, r, ans, ind;
};

int fv[maxn+5], v[maxn+5];
yes qry[maxn+5];
int n;

bool ok (int j) {
  return j >= 1 && j <= n;
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  int q; cin >> n >> q;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i];
  for (i = 1; i <= q; i++) {
    cin >> qry[i].l >> qry[i].r;
    qry[i].ind = i;
  }
  int szb = sqrt(n);
  sort(qry+1, qry+q+1, [&szb] (yes &a, yes &b) {
        if (a.l/szb != b.l/szb) return a.l/szb < b.l/szb;
        return a.r < b.r;
       });
  int now = 0, nl = 0, nr = 0;
  for (i = 1; i <= q; i++) {
    if (nr < qry[i].r) {
      for (j = nr+1; j <= qry[i].r; j++) {
        if (!ok(j)) continue;
        fv[v[j]]++;
        if (fv[v[j]] == 1) now++;
      }
    } else if (nr > qry[i].r) {
      for (j = nr; j > qry[i].r; j--) {
        if (!ok(j)) continue;
        fv[v[j]]--;
        if (fv[v[j]] == 0) now--;
      }
    }
    nr = qry[i].r;
    if (nl > qry[i].l) {
      for (j = nl-1; j >= qry[i].l; j--) {
        if (!ok(j)) continue;
        fv[v[j]]++;
        if (fv[v[j]] == 1) now++;
      }
    } else if (nl < qry[i].l) {
      for (j = nl; j < qry[i].l; j++) {
        if (!ok(j)) continue;
        fv[v[j]]--;
        if (fv[v[j]] == 0) now--;
      }
    }
    nl = qry[i].l;
    qry[i].ans = now;
  }
  sort(qry+1, qry+q+1, [](yes &a, yes &b) { return a.ind < b.ind; });
  for (i = 1; i <= q; i++) cout << qry[i].ans << '\n';
  return 0;
}


Measured memory_bytes: 15500
import java.util.*;

class Main {
public static void main(String[] args){

Scanner sc = new Scanner(System.in);
String a = sc.next();
String b = sc.next();
String c = sc.next();
a = a.substring(0,1);
b = b.substring(0,1);
c = c.substring(0,1);
System.out.println(a + b + c);

}
}

Measured memory_bytes: 23764
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define F(i,a,n) for(int i=a; i<n; i++)

int main(){
  int l;
  scanf("%d",&l);
  double L=((double)l)/3;
  printf("%f\n",L*L*L);
  return 0;
}

Measured memory_bytes: 128
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    x, n = map(int, input().split())
    p = list(map(int, input().split()))
    add = 1
    if x not in p:
        print(x)
    else:
        while True:
            if (x - add) not in p:
                print(x - add)
                return
            elif (x + add) not in p:
                print(x + add)
                return
            else:
                add += 1

if __name__ == '__main__':
    main()

Measured memory_bytes: 9200
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define MI          map<int, int>
#define PI          pair<int, int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)3e3+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int n;
ll a[N], dp[N][N];
ll fn(int i, int j){
    if (i<1 or j<1 or j>n or i>n) return 0;
    if (i==j) return a[i];
    if (i>j) return 0;
    if (dp[i][j]) return dp[i][j];
    return dp[i][j] = max(a[i] + min(fn(i+2, j), fn(i+1, j-1)), a[j] + min(fn(i, j-2), fn(i+1, j-1)));
}
int main(){
    sc(n);
    ll sum =0;
    fr(i, 1, n) {
        lsc(a[i]);
        sum +=a[i];
    }
    lpr(2*fn(1, n) - sum);n_l;
    return 0;
}



Measured memory_bytes: 70144
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define endl "\n"
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);
int dp[1001][10001];
void solve() {
    int h,n;cin>>h>>n;
    int a[n],b[n];
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    for(int i=1;i<=10000;i++)dp[0][i]=INT_MAX;
    int ans=INT_MAX;
    for(int i=1;i<=n;i++){
        for(int j=0;j<=h;j++){
            dp[i][j]=dp[i-1][j];
            dp[i][j]=min(dp[i][j],b[i-1]+dp[i][max(0ll,j-a[i-1])]);
            if(i==n && j==h){
                ans=min(ans,dp[i][j]);
            }
            //cout<<dp[i][j]<<" ";
        }
        //cout<<endl;
    }
    cout<<ans<<endl;
}

int32_t main() {
    IOS;
    int test = 1;
    // cin >> test;
    while (test--) {
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

Measured memory_bytes: 78464
#include<iostream>
#include<vector>

using namespace std;

int main(void) {
    int h, w;
    cin >> h >> w;
    vector<string> S(h);
    for (auto &s: S) {
        cin >> s;
    }
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            int cnt = 0;
            if (S[i][j] == '.') {
                for (int x = -1; x <= 1; ++x) {
                    for (int y = -1; y <= 1; ++y) {
                        int idx_x = j + x;
                        int idx_y = i + y;
                        if (idx_x < 0 || idx_x >= w) continue;
                        if (idx_y < 0 || idx_y >= h) continue;
                        if (S[idx_y][idx_x] == '#') cnt++;
                    }
                }
                S[i][j] = static_cast<char>(cnt + '0');
            }
        }
    }
    for (auto y: S) {
        for (auto x: y) {
            cout << x;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
-- ABC110 D Factorization
import qualified Data.IntSet as IntSet
import Data.List
import qualified Data.IntMap.Strict as IntMap

main :: IO ()
main = do
  (n:m:_) <- fmap (map read . words) getLine :: IO [Int]
  print $ solve (fromIntegral n) m

-- solve :: Int -> Int -> Int
solve n m = foldr (\x acc -> acc `modmul` (combination (fromIntegral x) n)) 1 counts
  where
    as = factorization m
    counts = IntSet.foldr (\x acc -> IntMap.insert x (length $ filter (==x) as) acc) IntMap.empty $ IntSet.fromList as


divConst = 10^9 + 7 :: Integer
modmul x y = ((x `mod` divConst) * (y `mod` divConst)) `mod` divConst
moddiv x y = modmul x (power y (divConst - 2))
power x y
  | y == 0 = 1
  | y == 1 = x `mod` divConst
  | y `mod` 2 == 0 = (power x (y `div` 2))^2 `mod` divConst
  | otherwise = (power x (y `div` 2))^2 * x `mod` divConst
factorial n = foldr modmul 1 [1..n]
fact n m = foldr modmul 1 [(m+1)..n]

-- combination :: Int -> Int -> Int
combination a n = foldl' moddiv (fact (a + n - 1) (n - 1)) [1..a]

-- factors :: Int -> [Int]
factors n = [x | x <- [2..n], n `mod` x == 0]

-- factorization :: Int -> [Int]
factorization 1 = []
factorization x = let v = head $ factors x
                  in  v : factorization (x `div` v)


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

int main (){
	int rate;
	cin>>rate;
	if(rate<1200){
		cout<<"ABC"<<endl;
	}else if(rate<2800){
		cout<<"ARC"<<endl;
	}else{
		cout<<"AGC"<<endl;}
	return 0;
}


Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	s := make([]string, n)
	for i := 0; i < n; i++ {
		s[i] = scanString()
	}

	ans := -1

	for i := 0; i < n; i++ {
		q := []int{i}
		d := make([]int, n)
		for j := 0; j < n; j++ {
			d[j] = -1
		}
		d[i] = 0
		k := 0
		debug(i)
		nq := []int{}
		for len(q) != 0 {
			v := q[0]
			q = q[1:]
			for j := 0; j < n; j++ {
				if d[j] == -1 && s[v][j] == '1' {
					d[j] = k + 1
					nq = append(nq, j)
				}
			}
			if len(q) == 0 {
				q = nq
				nq = []int{}
				k++
			}
		}
		f := true
		for u := 0; u < n; u++ {
			for v := u; v < n; v++ {
				if s[u][v] == '1' && abs(d[u]-d[v]) != 1 {
					f = false
				}
			}
		}
		if f {
			ans = max(ans, k)
		}
	}

	fmt.Fprintln(wr, ans)

}

type pair struct{ a, b int }


Measured memory_bytes: 3152
// ABC175-A
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    string s;
    cin>>s;
    int ans=0,ren=0;
    rep(i,3){
        if(s[i]=='R') ren++;
        else{
            ans=max(ans,ren);
            ren=0;
        }
    }
    ans=max(ans,ren);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3604
from collections import defaultdict
N = int(input())
S = input()
def match(n):
  D = defaultdict(list)
  for i in range(N + 1 - n):
    D[S[i:i + n]].append(i)
  for L in D.values():
    if len(L) > 1 and L[-1] - L[0] >= n:
      return True
  return False
def bs(upper, lower):
  if upper - lower == 1:
    return lower
  mid = (upper + lower) // 2
  if match(mid):
    return bs(upper, mid)
  else:
    return bs(mid, lower)
print(N // 2 if match(N // 2) else bs(N // 2, 0))

Measured memory_bytes: 10132
import java.util.*

fun main(argv : Array<String>){
    
    val scan = Scanner(System.`in`)
    
    //
    val str = scan.next()
    
    //
    for( i in str.indices){
        
        if(i>=str.indices.count()/2)
            break
        
        if( str[i] != str[str.length-1-i]){
            println("No")
            return
        }
    }
    print("Yes")
    
}



Measured memory_bytes: 31396
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
#include <time.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int main(){

	int A,B,C,D;
	scanf("%d %d %d %d",&A,&B,&C,&D);

	if(A+B > C+D){
		printf("Left\n");
	}else if(A+B < C+D){
		printf("Right\n");
	}else{
		printf("Balanced\n");
	}

	return 0;
}


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

using namespace std;
using ll = long long;

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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  int ans = min(a * n, b);
  cout << ans << endl;
  return 0;
}


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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var S2 = S + S;
		Console.WriteLine(S2.IndexOf(T) != -1 ? "Yes" : "No");
		
	}
	String S,T;
	public Sol(){
		S = rs();
		T = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13280
#include <iostream>
using namespace std;
int main() {
  int a = 700;
  string s;
  cin >> s;
  if (s[0] == 'o') a += 100;
    if (s[1] == 'o') a += 100;
      if (s[2] == 'o') a += 100;
        cout << a << endl;
}

Measured memory_bytes: 256
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();
		int A[]=new int[N];
		for(int i=0;i<N;i++) A[i]=sc.nextInt();
		int D[][] = new int[M][2];
		for(int i=0;i<M;i++) {
			D[i][0]=sc.nextInt();//B
			D[i][1]=sc.nextInt();//C
		}
		sc.close();
		Queue<Integer> pq = new PriorityQueue<Integer>();
		for(int i=0;i<N;i++)pq.offer(A[i]);
		//reverse sort D by C
		Arrays.sort(D,(d1,d2)->d2[1]-d1[1]);
		
		boolean fin = false;
		for(int i=0;i<M;i++) {
			int tB = D[i][0];
			int tC = D[i][1];
			for(int j=0;j<tB;j++) {
				if(pq.peek()<tC) {
					pq.poll();
					pq.offer(tC);
				}else {
					fin = true;
					break;
				}
			}
			if(fin)break;
		}
		long ans = 0;
		while(!pq.isEmpty()) {
			ans += pq.poll();
		}
		System.out.println(ans);
	}
}

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

signed main() {
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];

  function<int64_t(int, int)> dfs = [&](int lb, int rb) {
    static int64_t dp[3001][3001];
    static bool   vis[3001][3001];
    if (vis[lb][rb]) return dp[lb][rb];
    if (lb == rb) return (int64_t) 0;
    vis[lb][rb] = 1;
    return dp[lb][rb] = max(A[lb] - dfs(lb + 1, rb), A[rb - 1] - dfs(lb, rb - 1));
  };

  cout << dfs(0, N) << endl;

  return 0;
}


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

using namespace std;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define FOR(i, a, b) for(int i = (a); i < (b); i++)

signed main() {
  IOS;
  int n, x, sum=0;
  cin >> n >> x;
  int i,L;
  for (i=0; i<n; i++) {
    cin >> L;
    sum += L;
    if (sum > x) break;
  }

  cout << i+1 << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int W;
    int H;
    int x;
    int y;
    int r;
    cin>>W >>H >>x >>y >>r;
    if (r<=x && x<=W-r && r<=y && y<=H-r){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#include <deque> 
#define DBL_MIN 0.000000000000001

#include <iostream>
using namespace std;



int main(void){
    map<char,int> c_num;
    string s;
    cin >> s;
    for(int i =0; i < s.size(); i++){
        c_num[s[i]]++;
    }
    if(abs(c_num['a'] - c_num['b']) <= 1 && abs(c_num['b'] - c_num['c']) <= 1 && abs(c_num['c'] - c_num['a']) <= 1 ){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
    return 0;
}



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

long long a(long long N){
  if(N == 0){
    return(1);
  }
  else{
    return(a(N-1)*2+3);
  }
}

long long p(long long N){
  if(N == 0){
    return(1);
  }
  else{
    return(p(N-1)*2+1);
  }
}

long long f(long long N, long long X){
  if(N == 0){
    if(X <= 0){
      return(0);
    }
    else{
      return(1);
    }
  }
  else if(X <= 1 + a(N-1)){
    return (f(N-1, X-1));
  }
  else{
    return (p(N-1) + 1 + f(N-1, X-2-a(N-1)));
  }
}

int main(){
  long long N;
  long long X;
  cin >> N >> X;
  cout << f(N, X) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
      Scanner s = new Scanner(System.in);
      int A = s.nextInt();
      int B = s.nextInt();
      int C = s.nextInt();
      
      int nana=0, go=0;
      if(A == 5){ go++;} else if(A == 7) {nana++;}
      if(B == 5){ go++;} else if(B == 7) {nana++;}
      if(C == 5){ go++;} else if(C == 7) {nana++;}
      
      if(go == 2 && nana == 1){
      	System.out.println("YES");
      }else{
      	System.out.println("NO");
      }
    }
}

Measured memory_bytes: 21460
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;
#define N 1e5+10
vector<ll> yaku(ll n ){
    set<ll> res;
    vector<ll> tmp;
    for(ll i=1;i*i<=n;i++){
	if( n%i == 0 ){
	    res.insert( i );
	    res.insert( n/i );
	}
    }
    for(auto i:res)tmp.push_back( i );
    return tmp;
}

int main(){
    vector<ll> cnt(N, 0 );
    ll s;
    cin>>s;
    for(ll i=1;i<N;i++){
	ll sum = i;
	for(ll j=1;sum <N ;j++){
	    cnt[sum]++;
	    sum += i+j;
	}
    }
    vector<ll> Y = yaku( s );
    ll res = 0;
    //cout<<"OK"<<endl;
    for(auto i:Y ){
	
	if( i == s/i ){
	    res += cnt[i]*cnt[i];
	}else{
	    res += cnt[i]*cnt[s/i];
	}
	
    }
    cout<<res<<endl;

    return 0;
}



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

#define MAX_LEN 100
#define MAX_LEN1 (MAX_LEN+1)
#define LABEL_OVERFLOW "overflow"

int main(){
   char in1[MAX_LEN1], in2[MAX_LEN1], out[MAX_LEN1];
   int len1, len2, len, i1, i2, o, carry, i, j, n;
   scanf("%d",&n);
   for(j=0;j<n;j++){
      scanf("%s",in1);
      scanf("%s",in2);
      if((len1=strlen(in1))>80||(len2=strlen(in2))>80){
         printf("%s\n",LABEL_OVERFLOW);
         continue;
      }
      if(len1>len2) len=len1;
      else len=len2;
      out[len]='\0';
      for(i=0,carry=0;i<len;i++){
         out[len-i-1]='0';
         if(len1-i-1<0) i1=0;
         else i1=in1[len1-i-1]-'0';
         if(len2-i-1<0) i2=0;
         else i2=in2[len2-i-1]-'0';
         if((o=i1+i2+carry)>=10){
            carry=1;
            o-=10;
         } else carry=0;
         out[len-i-1]=o+'0';
      }
      if(carry>0){
         if(len>=80) printf("%s\n",LABEL_OVERFLOW);
         else printf("1%s\n",out);
      } else printf("%s\n",out); 
   }
   return 0;
}

Measured memory_bytes: 608
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <set>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <random>
#include <chrono>
using namespace std;

const int maxn = 1e6 + 5;
const int mod = 1e9 + 7;
int fac[maxn], inv[maxn];

int qpow(int a, int n){
    int ret = 1;
    while(n > 0){
        if(n & 1){
            ret = 1LL * ret * a % mod;
        }
        a = 1LL * a * a % mod;
        n >>= 1;
    }
    return ret;
}

void pre_comb(){
    fac[0] = 1;
    for(int i = 1;i < maxn;i++){
        fac[i] = 1LL * fac[i - 1] * i % mod;
    }
    inv[maxn - 1] = qpow(fac[maxn - 1], mod - 2);
    for(int i = maxn - 2;i >= 0;i--){
        inv[i] = 1LL * inv[i + 1] * (i + 1) % mod;
    }
}

int comb(int n, int m){
    if(m > n or m < 0) return 0;
    return 1LL * fac[n] * inv[m] % mod * inv[n - m] % mod;
}

int H, W, A, B;

int main(){
    cin >> H >> W >> A >> B;
    pre_comb();
    int ans = 0;
    for(int i = 1;i <= min(H - A, W - B);i++){
        int x = H - A + 1 - i;
        int y = B + i;
        ans = (ans + 1LL * comb(x - 1 + y - 1, x - 1) * comb(H - x + W - y, H - x)) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds; 

#define int long long
#define pb push_back
#define pf push_front
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define f first
#define s second
#define sz(x) (int)x.size()
#define endl "\n"
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout<<(x)<<endl
#define watch2(x,y) cout<<(x)<<" "<<(y)<<endl
#define watch3(x,y,z) cout<<(x)<<" "<<(y)<<" "<<(z)<<endl
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld; 
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> oset;

const int INF = 9e18;
const int mod = 1e9 + 7;
const int N = 1005;

int i,n,k,p[N];

void solve()
{
    cin>>n>>k;
    for(i=1;i<=n;++i)
    {
        cin>>p[i];
    }
    int ans=0;
    sort(p+1,p+n+1);
    for(i=1;i<=k;++i)
    {
        ans+=p[i];
    }
    cout<<ans;
}

signed main()
{
    fastio;
    int t;
    //cin>>t;
    t=1;
    while(t--)
    {
        solve();
    }
    return 0;
}

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

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

	int i;
	int counter = 0;
	for (i = a; i <= b; i++) {
		if (c % i == 0) counter++;
	}
	cout << counter << "\n";

	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

char s[3];
int main(){
	scanf("%s", s);
	char c = s[0];
	if(c - 'A' < 26) c = 'A';
	else c = 'a';
	printf("%c\n", c);
}


Measured memory_bytes: 3820
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define input(array) repi(array##_itr, array) { cin >> *(array##_itr); }
#define F first
#define S second
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
string solve(bool a) { return ((a) ? "Yes" : "No"); }
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	string s;
	int k;
	ll ans=0LL;
	cin >>s>>k;
	vector<pair<char, int>> dis;
	pair<char, int> data = mp(s[0], 1);
	for (int i = 1; i < s.size(); i++) {
		if (s[i] != data.F) {
			dis.push_back(data);
			data = mp(s[i], 0);
		}
		data.S++;
	}
	dis.push_back(data);
	if (dis.size() == 1) {
		ans = (ll)s.size() * k / 2;
	} else {
		for (int i = 0; i < dis.size(); i++) {
			if ((i == dis.size() - 1 or i==0) and dis[0].F==dis.back().F) {
				ans += (ll)dis[i].S / 2;
				if (i == 0) {
					ans += (ll)(dis.front().S + dis.back().S) / 2 * (k - 1);
				}
			} else {
				ans += (ll)dis[i].S/2*k ;
			}
		}
	}

	cout<<ans<<endl;
}

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

int main() {
    ll n;
    ll max[5] = {0};
    ll ans;
    ll nn;
    
    cin >> n;
    
    for (int i = 0; i < 5; i++) {
        cin >> max[i];
    }
    
    for (int i = 0; i < 5; i++) {
        if (i == 0) {
            nn = max[i];
        }
        else if (nn > max[i]) {
            nn = max[i];
        }
    }
    
    ans = (n / nn) + ((n % nn) ? 1 : 0) + 4;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main{
    static int X;
    static int min;
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);

        X = sc.nextInt();
        sc.close();

        int sum = 0;
        int i = 0;
        while(true){
            i++;
            sum += i;
            if(sum >= X)
                break;
        }
        System.out.println(i);
    }

}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define int long long
struct P {
  int X, Y;
  double arg;
  bool operator <(const P& other) const {
    return this->arg < other.arg;
  }
};
int sq(int x, int y) {
  return x*x + y*y;
}
signed main() {
  int N; cin >> N;
  vector<P> PS(N);
  for (int i = 0; i < N; ++i) {
    cin >> PS[i].X >> PS[i].Y;
    PS[i].arg = atan2(PS[i].Y, PS[i].X);
  }
  sort(PS.begin(), PS.end());
  int ans = 0;
  for(int i = 0; i < N; i++) {
    int sx = PS[i].X;
    int sy = PS[i].Y;
    ans = max(ans, sq(sx, sy));
    for (int j = i + 1; j % N != i; j++) {
      sx += PS[(j % N)].X;
      sy += PS[(j % N)].Y;
      ans = max(ans, sq(sx, sy));
    }
  }
  cout.setf(ios::fixed); cout.precision(20);
  cout << sqrt(ans) << endl;
}


Measured memory_bytes: 512
#H and V

h,w,k = map(int,input().split())

c = [list(str(input())) for j in range(h)]

ans = 0

for maskR in range(2**h):
    for maskC in range(2**w):
        black = 0
        for i in range(h):
            for j in range(w):
                if ((maskR >> i) & 1) == 0 and ((maskC >> j) & 1) == 0 and c[i][j] == '#':
                    black += 1
        if black == k:
            ans += 1

print(ans)
    


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


int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    for(int i = k; i < n; i++)
    {
        if(a[i] > a[i - k]) cout << "Yes" << "\n";
        else cout << "No" << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 4044
#define _GLIBCXX_DEBUG
#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 x;
    cin >> x;
    int n = x.size();
    int a[4];
    rep(i, 4)  a[i] = x[i] - '0';

    char op[3];
    rep(bit, 8) {
        int sum = a[0];
        rep(i, n - 1) {
            if(bit & (1 << i)) {
                sum += a[i + 1];
                op[i] = '+';
            } else {
                sum -= a[i + 1];
                op[i] = '-';
            }
        }
        if(sum == 7) break;
    }

    rep(i, n - 1) {
        cout << a[i] << op[i];
    }
    cout << a[3] << "=7" << endl;

    return 0;
}

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

typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;

#define ALL(s) (s).begin(),(s).end()
#define EACH(i,s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl

template<class T1, class T2> ostream& operator<<(ostream &s, pair<T1,T2> P){return s<<'<'<<P.first<<", "<<P.second<<'>';}
template<class T> ostream& operator<<(ostream &s, vector<T> P) {s<<"{ ";for(int i=0;i<P.size();++i){if(i>0)s<<", ";s<<P[i];}return s<<" }"<<endl;}
template<class T1, class T2> ostream& operator<<(ostream &s, map<T1,T2> P) {s<<"{ ";for(__typeof__(P.begin()) it=P.begin();it!=P.end();++it){if(it!=P.begin())s<<", ";s<<'<'<<it->first<<"->"<<it->second<<'>';}return s<<" }"<<endl;}



const int MAX = 110;
int deg[MAX];
int a, b;

int main() {
    while (cin >> a >> b) {
        if (a == 0 && b == 0) {
            bool ok = true;
            if (!(deg[1] & 1) || !(deg[2] & 1)) ok = false;
            for (int i = 3; i < MAX; ++i) if (deg[i] & 1) ok = false;
            
            if (ok) puts("OK");
            else puts("NG");
            
            memset(deg, 0, sizeof(deg));
        }
        deg[a]++;
        deg[b]++;
        
        //for (int i = 0; i < MAX; ++i) if (deg[i] > 0) cout << i << " : " << deg[i] << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1116
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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

    ll n;
    cin >> n;
    vector<vector<ll>> a(n, vector<ll>(60, 0));
    rep(i, n){
        ll num;
        cin >> num;
        ll d = 0;
        while(num){
            if(num%2) a[i][d] = 1;
            num /= 2;
            ++d;
        }
    }

    // rep(i, n) {
    //     rep(j, 60) cout << a[i][j];
    //     cout << endl;
    // }

    vector<ll> bit_num(60, 0);
    rep(i, n){
        rep(j, 60) bit_num[j] += a[i][j];
    }

    // cout << endl;
    // rep(i, 60) cout << bit_num[i];
    // cout << endl;

    ll MOD = 1000000007;
    ll res = 0;
    ll base = 1;
    rep(i, 60){
        res += base%MOD * bit_num[i]%MOD * (n - bit_num[i])%MOD;
        res %= MOD;

        base *= 2;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 152704
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
using namespace std;
const long INF = 1e9;
const long MOD = 1e9 + 7;
#define repi(i, n, init) for (int i = init; i < int(n); i++)

struct Node
{
    Node()
    {
        parent = -1;
        depth = num_of_children = 0;
    }
    int parent, depth, num_of_children;
    vector<int> children;
};
void calcDepth(vector<Node> &G, int root)
{
    repi(i, G.at(root).num_of_children, 0)
    {
        G.at(G.at(root).children.at(i)).depth = G.at(root).depth + 1;
        calcDepth(G, G.at(root).children.at(i));
    }
}

int main()
{
    int n;
    cin >> n;
    vector<Node> G(n);
    repi(i, n, 0)
    {
        int node, k;
        cin >> node >> k;
        repi(j, k, 0)
        {
            int data;
            cin >> data;
            G.at(node).children.push_back(data);
            G.at(node).num_of_children++;
            G.at(data).parent = node;
        }
    }
    //root検索
    int root = 0;
    repi(i, n, 0)
    {
        if (G.at(i).parent == -1)
        {
            root = i;
            break;
        }
    }
    calcDepth(G, root);

    repi(i, n, 0)
    {
        if (G.at(i).parent == -1)
        {
            cout << "node " << i << ": parent = " << G.at(i).parent << ", depth = " << G.at(i).depth << ", root, [";
            repi(j, G.at(i).num_of_children, 0)
            {
                cout << G.at(i).children.at(j) << ((j + 1) % G.at(i).num_of_children ? ", " : "");
            }
            cout << "]" << endl;
        }
        else if (G.at(i).num_of_children != 0)
        {
            cout << "node " << i << ": parent = " << G.at(i).parent << ", depth = " << G.at(i).depth << ", internal node, [";
            repi(j, G.at(i).num_of_children, 0)
            {
                cout << G.at(i).children.at(j) << ((j + 1) % G.at(i).num_of_children ? ", " : "");
            }
            cout << "]" << endl;
        }
        else
        {
            cout << "node " << i << ": parent = " << G.at(i).parent << ", depth = " << G.at(i).depth << ", leaf, []" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 7536
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES {cout<<"YES"<<'\n';}
#define NO {cout<<"NO"<<'\n';}
#define Yes {cout<<"Yes"<<'\n';}
#define No {cout<<"No"<<'\n';}
#define yes {cout<<"yes"<<'\n';}
#define no {cout<<"no"<<'\n';}
void YN(bool flg){cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg){cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg){cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) {cout << n << '\n';}
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
int ABS(int a) {if(a<0) a = -a; return a;}
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n /= 2; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数の個数*/int divisor_number(int n){auto p = prime_factor(n); int res = 1; for(auto x:p)res*=(x.second+1); return res;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(15);

    string s; int k; cin >> s >> k;
    REP(i,min((int)s.size(),k)) if(s[i]>='2'){out(s[i]); return 0;}
    out(1);

    return 0;
}

Measured memory_bytes: 256
using System.Collections.Generic;
using System.Linq;
using static System.Math;
using System;

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var y1 = int.Parse(line[0]);
        var m1 = int.Parse(line[1]);
        var d1 = int.Parse(line[2]);
        line = Console.ReadLine().Trim().Split(' ');
        var y2 = int.Parse(line[0]);
        var m2 = int.Parse(line[1]);
        var d2 = int.Parse(line[2]);
        var a1 = getAge(y1, m1, d1);
        var b1 = getAge(y2, m2, d2);
        var ans = -1;
        for (int i = 0; i < a1.Count(); i++)
            ans = Max(ans, Abs(a1[i] - b1[i]));
        Console.WriteLine(ans);
    }
    public static List<int> getAge(int y, int m, int d)
    {
        var yyyy = 3004;
        var ans = new List<int>();
        var bd = new DateTime(y, m, d);
        var mo = new int[] { 1, 3, 5, 7, 8, 10, 12 };
        foreach (var x in mo)
        {
            for (int i = 1; i <= 31; i++)
            {
                var now = new DateTime(yyyy, x, i);
                var age = now.Year - bd.Year;
                if (bd > now.AddYears(-age)) age--;
                ans.Add(age);
            }
        }
        var mo2 = new int[] { 4, 6, 9, 11 };
        foreach (var x in mo2)
        {
            for (int i = 1; i <= 30; i++)
            {
                var now = new DateTime(yyyy, x, i);
                var age = now.Year - bd.Year;
                if (bd > now.AddYears(-age)) age--;
                ans.Add(age);
            }
        }
        for (int i = 1; i <= 29; i++)
        {
            var now = new DateTime(yyyy, 2, i);
            var age = now.Year - bd.Year;
            if (bd > now.AddYears(-age)) age--;
            ans.Add(age);
        }
        return ans;
    }
}



Measured memory_bytes: 18324
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stdlib.h>

using namespace std;

int main() {
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;
    int price;
    c = 2*c;
    price = a*x + b*y;
    if(x > y) {
        price = min(price,c*y + a*(x-y));
    }else if (x < y) {
        price = min(price,c*x + b*(y-x));
    }
    price = min(price,c*max(x,y));
    cout << price;
    return 0;
}


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

int main(void) {
  const ll N = 202, S = 1, T = 102, LabelX = -1, LabelY = -2;

  ll A, B;
  cin >> A >> B;
  vector< vector<ll> > D(A + 1, vector<ll>(B + 1));
  REP(i, 1, A + 1) REP(j, 1, B + 1) cin >> D[i][j];

  struct edge { ll u, v, c; };
  vector<edge> edges;
  vector< vector<bool> > ok(A + 1, vector<bool>(B + 1, false));

  REP(i, S, S + 100) edges.push_back((edge) { i, i + 1, LabelX });
  REP(i, T, T + 100) edges.push_back((edge) { i + 1, i, LabelY });

  REP(p, 0, 101) REP(q, 0, 101) REP(r, 0, 100 + 1) {
    bool f = true;
    REP(x, 1, A + 1) REP(y, 1, B + 1) f = f && D[x][y] <= p * x + q * y + r;
    if(!f) continue;
    ll cnt = 0;
    REP(x, 1, A + 1) REP(y, 1, B + 1) {
      if(!ok[x][y] && D[x][y] == p * x + q * y + r) {
        ok[x][y] = true;
        cnt++;
      }
    }
    if(cnt > 0) edges.push_back((edge) { S + p, T + q, r });
  }

  bool possible = true;
  REP(a, 1, A + 1) REP(b, 1, B + 1) possible = possible && ok[a][b];
  if(!possible) {
    cout << "Impossible" << endl;
  } else {
    cout << "Possible" << endl;
    cout << N << " " << edges.size() << endl;
    for(edge e : edges) {
      if(e.c >= 0) cout << e.u << " " << e.v << " " << e.c << endl;
      else cout << e.u << " " << e.v << " " << (e.c == LabelX ? "X" : "Y") << endl;
    }
    cout << S << " " << T << endl;
  }
}


Measured memory_bytes: 384
import collections
from collections import Counter
n=int(input())
d=collections.deque()
l=list(map(int,input().split()))
d.extend(l)
d.appendleft(0)
c=dict(Counter(d))
s=set(d)
for x in range(1,len(d)+1):
    if x in s:
        print(c[x])
    else:
        print(0)



Measured memory_bytes: 165016
#include <iostream>

using namespace std;

int main(){
  int a[1001];
  a[0]=0;
  for(int i=1;i<=1000;i++){
    a[i]=a[i-1]+i;
  }
  while(1){
    int N;
    cin >> N;
    if(N==0)break;
    int count=0;
    for(int i=0;i<=1000;i++){
      for(int j=i+2;j<=1000;j++){
        if(a[j]-a[i]==N)count++;
      }
    }
    cout << count << endl;
  }
}



Measured memory_bytes: 3048
//int a = stoi(c); 文字列をintへ
//小文字から大文字
//transform(a.begin(), a.end(), a.begin(), ::toupper);
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
//チェックリストはマップを使う
//数が大きい時の比較はstring型で行う
//全て0になったか調べたい->0になるたびにcntする
//またはかかつか
//例外処理は最初にする
//x = p^m + q^n...の約数の個数:(n+1)*(m+1)....
//N!のどの素因数で何回割れるか
//⇔1~Nまでの数がそれぞれどの素因数で何回割り切れるかの和
//パズルの問題->一般化して全探索
//数が大きい時のせぐふぉはコードテストで試してみる
//スペルミスに注意
//stack<ll> s;
//s.push(要素);s.top();s.pop();
//queue<ll> q;
//q.push(要素);q.front();q.pop();
//同じ作業繰り返す系の問題：収束先を見つける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

//円周率
const double PI = 3.14159265358979323846;
//割るやつ
const ll M = (pow(10, 9) + 7);

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}


//a,bの最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//階乗計算
ll f(ll n) {
	if (n == 0 || n == 1) return 1;
	else return (n * f(n - 1)) % M;
}

//Nをdで何回割れるか
ll divcnt(ll N, ll d) {
	ll ans = 0;
	while (1) {
		if (N%d == 0) {
			ans++;
			N /= d;
		}
		else break;
	}

	return ans;
}

//素数判定
bool prime(ll num) {
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2) {
		if (num % i == 0) return false;
	}
	return true;
}

//フィボナッチ数列
vector<ll> memo(pow(10, 6) + 1);
ll fibo(ll n) {
	if (n == 1) return 1;
	else if (n == 2) return 1;
	else if (memo[n] != 0) return memo[n];
	else return memo[n] = fibo(n - 1) + f(n - 2);
}

//ABC158のE見る
int main() {
	ll N; cin >> N;
	vector<string> S(N); rep(i, N)cin >> S[i];

	map<string, ll> p;
	rep(i, N) p[S[i]] = 1;

	ll ans = 0;
	auto begin = p.begin(), end = p.end();
	for (auto it = begin; it != end; it++) {
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 33072
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = 0;
		int b = 0;
		int c = 0;
		for (int i = 0; i < n; i++) {
			long an = sc.nextLong();
			if (an % 4 == 0) {
				a++;
			} else if (an % 2 == 0) {
				b++;
			} else {
				c++;
			}
		}

		if (a >= (n / 2)) {
			System.out.println("Yes");
		} else if ((a >= (c - 1)) && (b % 2 == 0) || (a >= (c - 1)) && (b % 2) <= (a - (c - 1))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
		sc.close();
	}
}


Measured memory_bytes: 59140