akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

typedef unsigned long long ll;

int main()
{
  std::string s, s0, s1;
  std::cin >> s;
  ll org_len = s.length();
  for (ll i = 0; i < org_len; i++) {
    s.pop_back();

    if ((s.length() % 2) == 1)
      continue;

    s0 = s.substr(0, s.length() / 2);
    s1 = s.substr(s.length() / 2, s.length());
    if (s0 == s1) {
      std::cout << s.length() << std::endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int INF = 1<<29;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

int main(){
	int n,i,ans=0;
	cin>>n;
	for(i=1;i>=0;i++){
		ans += i;
		if(ans>=n)break;
	}
	cout << i << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;

  vector<string> s(n);
  for(int i=0;i<n;i++){
        cin>>s[i];
    }
      
    bool flags=false;
    int sum=0;


    for(int i=0;i<n-1;i++){
        if(s[i].back()!=s[i+1].front()){
            flags=true;
        }
    }
    sort(s.begin(),s.end());
    for(int i=0;i<n-1;i++){
        if(s[i]==s[i+1]){
            flags=true;
        }
    }

    cout<<((flags)?"No":"Yes")<<endl;

}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'R') {
      cnt++;
    }
  }
  if (cnt > n / 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
N, M = map(int, input().split())

graph = [[0] * N for _ in range(N)]

for _ in range(M):
    i, j = map(int, input().split())
    graph[i - 1][j - 1] = 1
    graph[j - 1][i - 1] = 1

count = 0
i = 0
memo = []
def DepthFirstSearch(i):
    global count
    memo.append(i + 1)
    if len(memo) == N:
        count += 1
        return
    for j in range(N):
        if graph[i][j] == 1:
            if j+1 in memo:
                continue
            DepthFirstSearch(j)
            memo.pop()
    return count

print(DepthFirstSearch(i))

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

int main() {
  
  int N; cin >> N;
  
  int numAC = 0, numWA = 0, numTLE = 0, numRE = 0;
  
  for (int i = 0; i < N; i++) {
    
    string S; cin >> S;
    
    if (S == "AC") numAC++;
    
    if (S == "WA") numWA++;
    
    if (S == "TLE") numTLE++;
    
    if (S == "RE") numRE++;
    
  }
  
  cout << "AC x " << numAC << endl;
  
  cout << "WA x " << numWA << endl;
  
  cout << "TLE x " << numTLE << endl;
  
  cout << "RE x " << numRE << endl;
  
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int main(){
  char x; cin >> x;
  char ans = 'a';
  if(islower(x)) cout << ans << endl;
  else cout << (char)toupper(ans) << endl;
  return 0;
}


Measured memory_bytes: 3580
import java.math.*;
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) throws IOException{
		FastScanner sc = new FastScanner(System.in);
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		int t = 1;
		while (t-->0) {
		    long n = sc.nextLong();
		    long ans = (n*(n+1))/2;
		    for(int i=2;i<=n;i++){
		        if(i%3==0 || i%5==0) ans-=i;
		    } 
		    out.println(ans);
		}
		out.close();
	}
	static int gcd(int a, int b){
	    if(b==0) return a;
	    return gcd(b,a%b);
	}
	static class Pair implements Comparable<Pair>{
		int a, b;
		public Pair(int c, int d){
			a = c;
			b = d;
		}
		public int compareTo(Pair p){
		    return a-p.a;
		}
	}
	static class FastScanner {
		BufferedReader br;
		StringTokenizer st;
		FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}
		FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}
		String nextLine() {
			try {
				return br.readLine();
			} catch (IOException e) {
				return null;
			}
		}
		String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}

Measured memory_bytes: 32988
using namespace std;
#include <iostream>
#include <vector>
#include <map>

typedef long long ll;

class Prime {
// n以下の素数を列挙する
public:
  const int n;
  vector<bool> is_prime;
  vector<int> primes;
  Prime(int size) : n(size), is_prime(n+1, true) {
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; ++i) {
      if (!is_prime[i]) continue;
      primes.push_back(i);
      int tmp = 2*i;
      while (tmp <= n) {
        is_prime[tmp] = false;
        tmp += i;
      }
    }
  }

  bool check(int x) { return is_prime[x]; }
};

int main() {
  int x;
  cin >> x;
  Prime p(200000);
  int i = x;
  while (true) {
    if (p.check(i)) {
      cout << i << endl;
      return 0;
    }
    ++i;
  }
}



Measured memory_bytes: 512
n,*z=`dd`.split.map &:to_i;t=*0...n;*e=t;a=z.shift n+1;d=a.each_cons(2).map{|x,y|y-x};k,*z=z;z.map{|x|t[x-2,2]=t[x-1],t[x-2]};60.times{|i|k[i]>0&&e.map!{|q|t[q]};t=t.map{|q|t[q]}};k=a[0];n.times{|i|p k;k+=d[e[i]]}

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

using namespace std;

using ull = unsigned long long;

int main() {
    string S;
    cin >> S;
    for(int i = 0; i < 3; ++i) {
        if(S[i] == S[i+1]){
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, m, n) for(int i=(m); i<(n); ++i)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
#define Cout(x) cout << (x) << endl
#define Cout2(x, y) cout << (x) << " " << (y) << endl
#define dump(x) cout << #x << " = " << (x) << endl;
#define forauto(i, a) for(auto i : a)cout << i << " "; puts("");
typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
const int inf = 1e9;
const double pi = acos(-1.0);

//			0		  1			2		  3			4		  5			6		  7			8		  9			初期
VS str = { "0111111","0000110","1011011","1001111","1100110","1101101","1111101","0100111","1111111","1101111","0000000" };

string re(string a, string b) {
	string ret;
	rep(i, 7) {
		ret += a[i] == b[i] ? '0' : '1';
	}
	return ret;
}


int main() {
	while (true) {
		int n; cin >> n;
		if (n == -1)break;

		VI d(n + 1); d[0] = 10;
		rep(i, n)cin >> d[i + 1];
		FOR(i, 1, n + 1) {
			//cout << d[i - 1] << ", " << d[i] << " -> ";
			Cout(re(str[d[i - 1]], str[d[i]]));
		}
	}
}


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

int main(){
  int sx,sy,tx,ty;
  cin >>sx>>sy>>tx>>ty;
  for(int i=0;i<ty-sy;i++){
    cout<<"U";
  }
  for(int i=0;i<tx-sx;i++){
    cout<<"R";
  }
  for(int i=0;i<ty-sy;i++){
    cout<<"D";
  }
  for(int i=0;i<tx-sx;i++){
    cout<<"L";
  }
  cout<<"L";
  for(int i=0;i<ty-sy+1;i++){
    cout<<"U";
  }
  for(int i=0;i<tx-sx+1;i++){
    cout<<"R";
  }
  cout<<"D";
  cout<<"R";
  for(int i=0;i<ty-sy+1;i++){
    cout<<"D";
  }
  for(int i=0;i<tx-sx+1;i++){
    cout<<"L";
  }
  cout<<"U"<<endl;
  return 0;
}

    

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

vector<ll> ret;
void divisor(long long n)
{

    for (long long i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i);
            if (i * i != n)
                ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
}

int main()
{
    //最大公約数を求める。
    ll n, m;
    cin >> n >> m;
    divisor(m);
   sort(ret.begin(), ret.end());
  sort(ret.begin(), ret.end());
  sort(ret.begin(), ret.end());
    ll k = 0;

    k = ret[lower_bound(ret.begin(), ret.end(), n) - ret.begin()];
    cout << m / k << endl;
    //公約数のうち、N以上となるもののうち最小値になるものを選択すれば良い。
    //Mが大きすぎるのでfor分で回すと死ぬ。
    //公約数と成り得る数をqueに格納していけば絶対にできる。(どうやる？)
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <set>
#include <string>
#include <algorithm>
#include <vector>

#define rep(i,n)    for(int i=0; i<(int)n; i++)
typedef long double ld;
typedef long long ll;
typedef std::vector<int> vint;
typedef std::vector<ll> vll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, ll> pll;

using std::cin;
using std::cout;
using std::endl;
using std::string;

int main() {
    
    int n;
    cin >> n;
    int As[n];
    rep(i, n) {
        cin >> As[i];
    }

    int q;
    cin >> q;
    int ms[q];
    bool ans[q];
    rep(i, q) {
        cin >> ms[i];
        ans[i] = false;
    }

    

    rep(i, 1<<n) {
        int sum = 0;
        rep(j, n) {
            if (i & (1<<j)) {
                sum += As[j];
                // cout << j << "j" << endl;
            }
            
        }
        // cout << sum << endl;
        rep(j, q) {
            if (sum == ms[j]) {
                ans[j] = true;
            }
        }
    }

    rep(i, q) {
        cout << ((ans[i]) ? "yes" : "no") << endl;
    }
}


Measured memory_bytes: 3100
import sys
input = sys.stdin.readline

n, a, b = [int(x) for x in input().split()]

def nCk(n, k, mod=10 ** 9 + 7):
    if n < k:
        return 0
    k = min(k, n - k)
    numer = 1
    for x in range(n - k + 1, n + 1):
        numer = (numer * x) % mod
    denom = 1
    for x in range(1, k + 1):
        denom = (denom * x) % mod
    return numer * pow(denom, mod - 2, mod) % mod

ans = 0
total = 0
total = 2 ** n - 1
total %= 7 + 10 ** 9

total -= nCk(n, a) + nCk(n, b)
total %= 7 + 10 ** 9

print(total)

Measured memory_bytes: 281244
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 10 05:50:12 2020

@author: baddude
"""


ttl = int(input())
no_1yen = int(input())

remain = ttl % 500
if no_1yen >= remain:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range(N):
  if(i == 0):
    pass
  else:
    if(A[i] - A[i-1] >= 0):
      pass
    else:
      tmp = A[i-1] - A[i]
      ans += tmp
      A[i] += tmp
print(ans)

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,w,z;cin>>n>>z>>w;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    int ans=abs(w-a[n-1]);
    if(n>1)ans=max(ans,abs(a[n-1]-a[n-2]));
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#if __has_include("D:/dhiraj/Programming/debug.h")
    #include "D:/dhiraj/Programming/debug.h"
#else
    #include <bits/stdc++.h>
    using namespace std;
    #define d(...) 11
    #define cerr if(0) cerr
#endif

// Macro --------------------------------------------------------------------

#define ll                  long long int
#define FOR(i, a, b, s)     for(ll i = (a); ((s) > 0 ? i < (b) : i > (b)); i += (s))
#define FOR1(b)             FOR(i, 0, b, 1)
#define FOR2(i, b)          FOR(i, 0, b, 1)
#define FOR3(i, a, b)       FOR(i, a, b, (a) <= (b) ? 1 :-1)
#define FOR4(i, a, b, s)    FOR(i, a, b, s)
#define GET5(a, b, c, d, e, ...) e
#define FORC(...)           GET5(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)
#define loop(...)           FORC(__VA_ARGS__)(__VA_ARGS__)
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define endl                '\n'

// Template -----------------------------------------------------------------

// multiple input
template <typename... T> 
inline void inp(T&... args) {
    ((cin>>args), ...);
}
// scan vector
template <typename T> 
inline istream &operator >>(istream &in, vector<T> &a) {
    for(auto &x : a) in >> x;
    return in;
}
// scan pair
template <typename T, typename U> 
inline istream &operator >>(istream &in, pair<T, U> &a) {
    in >> a.first >> a.second; 
    return in;
}

// Solve --------------------------------------------------------------------

void solve(int &T)
{
    ll x, k, d;
    inp(x, k, d);

    if(x >= 0)
    {
        ll L = min(k, x / d);
        k -= L;
        x = x - (L * d);
        x = x - (d * (k & 1));
    }
    else
    {
        ll R = min((abs(x) / d), k);
        k -= R;
        x = x + (R * d);
        x = x + (d * (k & 1));
    }   
    cout << abs(x) << endl;
}

// Main ---------------------------------------------------------------------

int main()
{
    #ifdef Dhiraj
        freopen("D:/dhiraj/Programming/i1.txt", "r", stdin);
        freopen("D:/dhiraj/Programming/o1.txt", "w", stdout);
        // freopen("D:/dhiraj/Programming/e1.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);

    int t = 1;
    for(int i = 1; i <= t; i++) {
        cerr << "Case #" << i << "\n";
        solve(i);
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits//stdc++.h>
using namespace std;
int in(void){int x;cin>>x;return x;}
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
#define ll long long int
long long int dx[4]={1,0,-1,0};
long long int dy[4]={0,1,0,-1};

int main() {
	int n,m;
	cin>>n>>m;
	int f[m]={};
	rep(i,0,n){
		int j;
		cin>>j;
		rep(k,0,j){
			int x;
          cin>>x;
			f[x-1]++;
		}
	}
	int ans=0;
	rep(i,0,m){
		if(f[i]==n){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var items = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = items[0];
            var K = items[1];
            var A = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            int[] B = null;
            foreach (var _ in Enumerable.Range(0, K))
            {
                B = Enumerable.Repeat(0, N).ToArray();
                foreach (var i in Enumerable.Range(0, N))
                {
                    var l = Math.Max(0, i - A[i]);
                    var r = Math.Min(N - 1, i + A[i]);
                    B[l]++;
                    if (r + 1 < N)
                    {
                        B[r + 1]--;
                    }
                }

                foreach (var i in Enumerable.Range(1, N - 1))
                {
                    B[i] += B[i-1];
                }

                A = B;
                if (A.All(elem => elem == N))
                {
                    break;
                }
            }

            Console.WriteLine(string.Join(" ", A));
        }
    }
}


Measured memory_bytes: 61544
import Control.Applicative

calcTime :: Int -> (Int, Int, Int)

calcTime t
    = (h, m, s) where
        h = t `div` 3600
        m = t `mod` 3600 `div` 60
        s = t `mod` 60
    
lineUp :: (Int, Int, Int) -> String

lineUp (h, m, s)
    = show h ++ ":" ++ show m ++ ":" ++ show s
    
solve :: Int -> (Int, Int, Int)

solve
    = calcTime

main :: IO ()
    
main
    = do
        input <- read <$> getLine
        putStrLn $ lineUp $ solve input

Measured memory_bytes: 3664
import collections
q = collections.deque(list(raw_input()))
operations = [raw_input().split(' ') for _ in range(int(raw_input()))]
rev = False

for op in operations:
	if len(op) == 1:
		rev = not(rev)
	elif len(op) == 3:
		_, where, char = op
		where = bool(int(where) - 1) ^ rev
		if where:			
			q.append(char)
		else:
			q.appendleft(char)

print ''.join(list(q)[:: (-1 if rev else 1)])



Measured memory_bytes: 86284
import sys
import decimal # 10進法に変換，正確な計算

def input():
    return sys.stdin.readline().strip()

def main():
    a = list(map(int, input().split())) 
    h = 0   
    for i in a:
        h += i
    if h >= 22:
        print("bust")
        return
    print("win")
    

main()


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

int main(){
    int a, b;
    cin >> a >> b;
    cout << (a-1)*(b-1) << endl;
    return 0;
}

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

using namespace std;

typedef pair<int, int> Pair;
typedef pair<Pair, int> Triple;

#define mp(x, y) make_pair(x, y)
#define left(x) x.first.first
#define right(x) x.first.second

const int N = 5010;

int n;
char s[N];
int sa[N], rnk[N];
Triple tmp[N];

bool cmp_sa(int x, int y) {
    return s[x] < s[y];
} 

bool cmp_rnk(Triple x, Triple y) {
    if (left(x) != left(y)) return left(x) < left(y);
    return right(x) < right(y);
}

int m = 128;

void calc_SA() {
    for (int i = 0; i < n; i++) sa[i] = i;
    sort(sa, sa+n, cmp_sa);	
    int p = 0;
    rnk[sa[0]] = 0;
    for (int i = 1; i < n; i++) 
        rnk[sa[i]] = s[sa[i]] == s[sa[i-1]] ? p : ++p;

    for (int k = 1; k <= n; k <<= 1) {
        for (int i = 0; i < n; i++)
            tmp[i] = mp(mp(rnk[i], i+k < n ? rnk[i+k] : -1), i);
        sort(tmp, tmp+n, cmp_rnk);
        int p = 0;
        rnk[tmp[0].second] = 0;
        for (int i = 1; i < n; i++)
            rnk[tmp[i].second] = tmp[i].first == tmp[i-1].first ? p : ++p;
    }

    for (int i = 0; i < n; i++) sa[rnk[i]] = i;
}

int main() {  
    int k;
    scanf("%s %d", s, &k);
    n = strlen(s);
    calc_SA();
    // for (int i = 0; i < n; i++) cout << sa[i] << ' ';
    //     puts("");
    for (int i = 0; i < n; i++) {
        int lp = sa[i];
        if (i) {
            int rp = sa[i-1];
            while (s[lp] == s[rp] && lp < n && rp < n) lp++, rp++;
        }

        // cout << lp << endl;
        if (n - lp >= k) {
            for (int j = sa[i]; j < lp; j++)
                putchar(s[j]);
            for (int j = lp, l = 1; l <= k; j++, l++) 
                putchar(s[j]);
            puts("");
            break;
        } else {
            k -= (n - lp);
        }
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <functional>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;

/*
    if you have any question about any part of my code,
    please don't shy to ask anytime :)
*/



void solve()
{
    char c;
    cin>>c;
    if(isupper(c))
    {
        cout<<"A"<<endl;
    }
    else
    {
        cout<<"a"<<endl;
    }
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3608
fun main(args: Array<String>) {
    fun gcd(a: Long, b: Long): Long {
        return if (b > 0) gcd(b, a % b) else a
    }

    fun calcFactors(n: Long): Map<Long, Long> {//素因数分解
        val factors = mutableMapOf<Long, Long>()
        var tmp = n
        var i = 2L
        while (i * i <= tmp) {
            while (tmp % i == 0L) {
                factors[i] = factors.getOrElse(i) { 0 } + 1
                tmp /= i
            }
            i++
        }
        if (tmp > 1) factors[tmp] = 1
        return factors
    }

    val (a, b) = readLine()!!.split(' ').map(String::toLong)
    val gcd = gcd(a, b)
    val factors = calcFactors(gcd)
    println(factors.size + 1)

}

Measured memory_bytes: 38340
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e5 +7;

#include <math.h>
#define PI 3.14159265358979323846264338327950L



int main() {
    int n, m;
    cin >> n >> m;
        if (n != m) {
            cout << "No";
        }
        else {
            cout << "Yes";
        }
    return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define INF 1e17+9;
#define rep(i,n) for(int i=0;i<n;i++)

const long long MOD = 1e9+7;
const double PI=acos(-1);

using namespace std;

int main() {
	int n,m;
	cin >> n >> m;
	vector<vector<int>> p(n+1);
	
	for(int i=0;i<m;i++){
		int x,y;
		cin >> x >> y;
		p[x].push_back(y);
		p[y].push_back(x);
	}
	
	int cnt=0,str=n;
	for(int i=0;i<p[str].size();i++){
		if(p[str][i]==1){
			cout << "POSSIBLE" << endl;
			return 0;
		}
		int nxt=p[str][i];
		int sz=p[nxt].size();
		for(int j=0;j<sz;j++){
			if(p[nxt][j]==1){
				cout << "POSSIBLE" << endl;
				return 0;
			}
		}
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}


Measured memory_bytes: 12016
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t K;
  cin >> K;
  if (K < 10) {
    cout << K << endl;
    return 0;
  }
  vector<vector<int64_t>> lunluns(19);
  for (int64_t i = 1; i < 10; ++i) {
    lunluns[1].emplace_back(i);
  }
  int64_t count = 9;
  for (int64_t d = 2; d <= 18; ++d) {
    for (const int64_t &prev : lunluns[d - 1]) {
      for (int64_t next_1st = (prev % 10) - 1; next_1st <= (prev % 10) + 1;
           ++next_1st) {
        if (next_1st >= 0 && next_1st < 10) {
          const int64_t next = prev * 10 + next_1st;
          lunluns[d].emplace_back(next);
          ++count;
          if (count == K) {
            cout << lunluns[d].back() << endl;
            return 0;
          }
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4272
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>

int A, B, C;

int main(int argc, char **argv) {
    std::cin >> A >> B >> C;
    
    if (A + B + 1 >= C) {
        std::cout << B + C << std::endl;
    } else {
        std::cout << A + B + 1 + B << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define co(x) cout << x <<endl
#define cs(x) cout << x <<" "
#define el cout << endl
#define sp(x) cout << setprecision(x);
#define cer(x) cerr << x <<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(ALL(x), val), x.end())
#define vi vector<int> 
#define vvi vector<vector<int>> 
#define pii pair<int,int>
#define vpii vector<pair<int,int>> 
#define vl vector<ll> 
#define vvl vector<vector<ll>> 
#define vd vector<double> 
#define vvd vector<vector<double>> 
#define vb vector<bool> 
#define vvb vector<vector<bool>>
#define vs vector<string>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
ll mod = 1e9 + 7;
ll inf = 1001001001001000;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a * b / g; }
bool is_prime(ll x) { for (ll i = 2; i * i <= x; i++) { if (x % i == 0)return false; } return true; }

struct edge 
{
	int to, cost;
	edge(int t, ll c) : to(t), cost(c) {};
};

int n;
vector<vector<edge>> graph;
vl dist;

void dfs(int v, int p, ll d)
{
	auto es = graph[v];
	for (auto e : es)
	{
		if (e.to == p || dist[e.to]!=inf)continue;
		chmin(dist[e.to], d + e.cost);
		dfs(e.to, v, dist[e.to]);
	}
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	graph = vector<vector<edge>>(n);
	rep(i, n - 1)
	{
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		graph[a].push_back(edge(b, c));
		graph[b].push_back(edge(a, c));
	}
	int q, k; cin >> q >> k;
	vi x(q), y(q);
	rep(i, q)
	{
		cin >> x[i] >> y[i];
		x[i]--; y[i]--;
	}
	dist= vl(n, inf);
	k--;
	//dfs
	dfs(k, -1, 0);
	rep(i, q)
	{
		ll ans = dist[x[i]] + dist[y[i]];
		co(ans);
	}
	return 0;
}


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

class Person{
	int id, d;

	public Person(int id, int d) {
		super();
		this.id = id;
		this.d = d;
	}
	
}

public class Main {
	static int mod = (int) 1e9 + 7;
	static int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), q = fs.nextInt();
		int ans[] = new int[q];
		Arrays.fill(ans, -1);
		int rw[][] = new int[n][3];
		for(int i=0;i<n;i++) {
			int s = fs.nextInt(), t = fs.nextInt(), x = fs.nextInt();
			rw[i][0] = s; rw[i][1] = t-1; rw[i][2] = x;
		}
		
		TreeSet<Person> ts = new TreeSet<>((p1,p2)->p1.d - p2.d);
		for(int i=0;i<q;i++) {
			int d = fs.nextInt();
			ts.add(new Person(i, d));
		}
		
		Arrays.sort(rw,(r1, r2)->r1[2] - r2[2]);
		
		for(int i=0;i<n;i++) {
			int s = rw[i][0], t = rw[i][1], x = rw[i][2];
			Person cp = new Person(n, s-x);
			while(ts.ceiling(cp)!=null) {
				Person p = ts.ceiling(cp);
				if(p.d <= t - x) {
					ts.remove(p);
					ans[p.id] = x;
					continue;
				}
				break;
			}
		}
		for(int i=0;i<q;i++) {
			System.out.println(ans[i]);
		}
		
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

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

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

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

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 95464
import java.util.*;

class Main{
	public static void main(String args[]) throws Exception{
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = sc.nextInt();
		if(X >= A && X <= A + B){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 20820
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL N=3e5+10;
const LL p=998244353;
LL n,a,b,k;
LL fac[N],inv[N];
inline LL pw(LL x,LL y){
	LL ans=1;
	while(y){
		if(y&1)(ans*=x)%=p;
		x=x*x%p; y>>=1;
	}
	return ans;
}
inline LL C(LL n,LL m){
	return m>n?0:fac[n]*inv[m]%p*inv[n-m]%p;
}
int main(){
	fac[0]=inv[0]=1;
	for(int i=1; i<N; ++i)fac[i]=fac[i-1]*i%p,inv[i]=pw(fac[i],p-2);
	scanf("%lld%lld%lld%lld",&n,&a,&b,&k);
	LL ans=0;
	for(LL i=0; i<=n; ++i){
		LL j=(k-a*i)/b;
		if(a*i+b*j==k&&j>=0)ans=(ans+C(n,i)*C(n,j)%p)%p;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 4992
n = int(input())
A = []
for _ in range(n):
    x, y = map(int, input().split())
    A.append([x, y])
import itertools, math
tmp = 0
l = len(list(itertools.permutations(A, n)))
for x in itertools.permutations(A, n):
    for i in range(1, n):
        xi, xj, yi, yj = x[i-1][0], x[i][0], x[i-1][1], x[i][1]
        tmp += math.sqrt(((xi - xj) ** 2) + ((yi - yj) ** 2))
print(tmp / l)

Measured memory_bytes: 7972
// #include <bits/stdc++.h>//C++のライブラリすべてinclude
#include<stdio.h>
#include<string>
#include<iostream>
#include<algorithm>
#include<queue>
#include<tuple>
#include<map>//map<char,char> a["a"]="a"
#include<limits>//ex numeric_limits<int>::max()
#include<math.h>
#define llong long long
#define INF 999999999

using namespace std;

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

    int A,B;
    cin >> A>>B;
    cout << (A-1)*(B-1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    int d;cin>>d;
    vin c(26);rep(i,26)cin>>c[i];
    vvin s(d,vin(26));
    rep(i,d)rep(j,26)cin>>s[i][j];
    vvin last(d,vin(26,0));int sum,tmp;ll m;
    vin ans(d);
    rep(i,d){
        m=-INF;
        if(i>0)rep(j,26)last[i][j]=last[i-1][j];
        rep(j,26){
            sum=0;
            sum+=s[i][j];
            rep(k,26){
                if(k==j)continue;
                sum-=c[k]*(i+1-last[i][k]);
            }
            if((ll)sum>m){
                tmp=j;
                m=(ll)sum;
            }
        }
        ans[i]=tmp;
        last[i][tmp]=i+1;
    }
    int res,l;
    rep(i,1000){
        rep(j,d){
            m=0;
            rep(k,26){
                sum=0;
                res=ans[j];
                rep2(l,j,d){
                    if(ans[l]==k){
                        sum+=c[k]*(j+1-last[j][k])*(l-j);
                        break;
                    }
                }
                rep2(l,j,d){
                    if(ans[l]==res){
                        sum-=c[res]*(j+1-last[j][res])*(l-j);
                    }
                }
                if(m<sum){
                    m=sum;
                    tmp=k;
                }
            }
            if(m==0)continue;
            ans[j]=tmp;
            l=last[j][tmp];
            rep2(k,j,d){
                if(last[k][tmp]!=l)break;
                last[k][tmp]=j+1;
            }
        }
    }
    rep(i,d)cout<<ans[i]+1<<endl;
}

Measured memory_bytes: 3724
/*	
*  Sachin Mittal
*/
#include<bits/stdc++.h>
#define int long long
#define M 998244353
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,j,n) for(int i=j;i<n;i++)
#define F first
#define S second
#define lb lower_bound
#define mem0(dp) memset(dp,0,sizeof(dp))
#define mem1(dp) memset(dp,-1,sizeof(dp))
#define pb push_back
#define sz(s) (int)(s.size())
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;

void solve()
{
	int n;cin>>n;
	map<string,int> m;
	int ans=0;
	rep(i,0,n)
	{
		string s;cin>>s;
		if(!m.count(s))m[s]=1,ans++;
	}
	cout<<ans;
}

int32_t main(){

ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int tst=1;
//cin>>tst;
while(tst--)
{
	solve();
}
}

Measured memory_bytes: 19288
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 1000000005

int main(){

    int n,m;
    cin >> n >> m;
    vector<int> a(n);
    vector<int> b(n);
    vector<int> c(m);
    vector<int> d(m);


    REP(n){
        cin >> a[i] >> b[i];
    }

    REP(m){
        cin >> c[i] >> d[i];
    }

    for(int i = 0;i < n;i++){
        int flag = 1000000000;
        int ans = 1000000000;
        for(int j = 0;j < m;j++){
            //cout << "flag=" << flag <<  endl;
            

            int tmp = abs(a[i]-c[j])+abs(b[i]-d[j]);
            //cout << "tmp=" << tmp << endl;

            //cout << "j=" << j << endl;
            if(ans >= tmp){
                //cout << "ans=" << ans << endl;
                //cout << "tmp=" << tmp << endl;
                if(ans > tmp){

                    ans = tmp;
                    flag = j+1;

                }else{
                    flag = min(flag,j+1);
                }


            }
            
            
            //cout << "ans=" << ans << endl;
            //cout << "flag=" << flag << endl;
        }
        cout << flag << endl;
        flag = 1000000000;
        ans = 1000000000;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define range(i, l, r) for(int (i) = (l); (i) < (r); (i)++)
#define reversed_range(i, l, r) for (int (i) = (r) - 1; (i) >= l; (i)--)
using namespace std;
template <typename T>
using vec = vector<T>;
using lint = long long;
using ulint = unsigned long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

template <typename S, typename T>
ostream& operator <<(ostream& os, pair<S, T> p) {
    os << "(";
    os << p.first << ", " << p.second;
    return os << ")";
}

template <typename T>
ostream& operator <<(ostream& os, vec<T> v) {
    os << "[";
    if (v.size() == 0) return os << "]";
    for (int i = 0; i < v.size() - 1; i++) {
        os << v.at(i) << ", ";
    }
    return os << v.at(v.size() - 1) << "]";
}

template <typename T>
ostream& operator <<(ostream& os, set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename T>
ostream& operator <<(ostream& os, unordered_set<T>& s) {
    os << "{";
    if (s.begin() == s.end()) return os << "}";
    auto it_first_item = s.begin();
    cout << *it_first_item;
    for (auto it = ++it_first_item; it != s.end(); it++) {
        cout << ", " << *it;
    }
    return cout << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

template <typename K, typename V>
ostream& operator <<(ostream& os, unordered_map<K, V> m) {
    os << "{";
    if (m.begin() == m.end()) return os << "}";
    auto it_first_item = m.begin();
    cout << it_first_item->first << ": " << it_first_item->second;
    for (auto it = ++it_first_item; it != m.end(); it++) {
        cout << ", " << it->first << ": " << it->second;
    }
    return os << "}";
}

lint pow(lint num, lint e, lint MOD) {
    lint res = 1;
    lint cur_num = num;
    while (e) {
        if (e & 1) {
            res *= cur_num;
            res %= MOD;
        }
        cur_num *= cur_num;
        cur_num %= MOD;
        e >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    lint N;
    cin >> N;
    cout << (N - 1) * N / 2 << "\n";
}

Measured memory_bytes: 256
n = input()
c = len(n)-1
for i in range(2**c):
    op = ['-']*c
    for j in range(c):
        if ((i>>j) & 1):
            op[c-1-j] = '+'
    op += ['']
    formula = ''
    for ni,oi in zip(n,op):
        formula += (ni+oi)
    if eval(formula)==7:
        print(formula+'=7')
        break


Measured memory_bytes: 3060
fun main(args: Array<String>) {
    abc079c()
}

private enum class Op(val value: String) { PLUS("+"), MINUS("-") }

fun abc079c() {
    val (a, b, c, d) = readLine()!!.map { it.toString().toInt() }

    var op1 = Op.PLUS
    var op2 = Op.PLUS
    var op3 = Op.PLUS

    for (i in 0..bits(3)) {
        op1 = if (i % 2 == 0) Op.PLUS else Op.MINUS
        op2 = if ((i shr 1) % 2 == 0) Op.PLUS else Op.MINUS
        op3 = if ((i shr 2) % 2 == 0) Op.PLUS else Op.MINUS
        if (exec(a, op1, b, op2, c, op3, d) == 7) break
    }

    println("""$a${op1.value}$b${op2.value}$c${op3.value}$d=${exec(a, op1, b, op2, c, op3, d)}""")
}

private fun exec(a: Int, op1: Op, b: Int, op2: Op, c: Int, op3: Op, d: Int): Int {
    return a + (if (op1 == Op.PLUS) b else -b) + (if (op2 == Op.PLUS) c else -c) + (if (op3 == Op.PLUS) d else -d)
}

private fun bits(x: Int): Int {
    var ret = 1

    repeat(x) { ret *= 2 }

    return ret - 1
}


Measured memory_bytes: 31856
#include <bits/stdc++.h>
#define INF 2e9
using namespace std;
typedef long long llong;
typedef long double ldouble;

int main()
{
  int ans = 1;
  int N,M;
  cin >> N >> M;
  vector<int> s(M);
  vector<int> c(M);
  for(int i=0; i<M; ++i) cin >> s.at(i) >> c.at(i);
  vector<int> num(N,0);
  vector<int> flg(N,0);
  for(int i=0; i<M; ++i){
    if(flg.at(s.at(i)-1)==0){
      num.at(s.at(i)-1) = c.at(i);
      flg.at(s.at(i)-1) = 1;
    } else if(num.at(s.at(i)-1)!=c.at(i)){
      ans = -1;
      break;
    }
  }
  if(ans == -1) cout << ans << endl;
  else if(N>1 && num.at(0)==0){
    if(flg.at(0)==1) cout << -1 << endl;
    else {
      num.at(0) = 1;
      for(int i=0; i<N; ++i) cout << num.at(i);
      cout << endl;
    }
  }
  else {
    for(int i=0; i<N; ++i) cout << num.at(i);
    cout << endl;
  }
}




Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    N = int(lines.pop(0))
    res = 0
    for i in range(N):
        x,u = lines.pop(0).split(' ')
        if u == 'BTC':
            res += 380000.0 * float(x)
        else:
            res += int(x)
    print(res)

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

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

signed main(){
    int n;
    cin >> n;
    double root = sqrt(n);
    for(int i = 1; i <= root; i++){
        if(n % i == 0){
            int b = n / i;
            ans = min<int>(ans,max(to_string(i).size(),to_string(b).size()));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            N = Input.ReadInt();
            int a = 0;
            int b = 0;
            int c = 0;

            {
                int[] A = Input.ReadIntArray();
                for (int i = 0; i < N; i++)
                {
                    if (A[i] == 3) a++;
                    if (A[i] == 2) b++;
                    if (A[i] == 1) c++;
                }
            }

            double[,,] DP = new double[302, 302, 302];

            // 遷移 - 上から行くのは意味がおかしくなるのでNG
            // 下から行けば良い
            for (int i = 0; i <= 300; i++)
            {
                for (int j = 0; j <= 300; j++)
                {
                    for (int k = 0; k <= 300; k++)
                    {
                        double x = i + j + k;

                        // 3個を食べる
                        if (i > 0)
                        {
                            DP[i, j, k] += (DP[i-1, j+1, k] + (N / x)) * (i / x);
                        }

                        // 2個を食べる
                        if (j > 0)
                        {
                            DP[i, j, k] += (DP[i, j-1, k+1] + (N / x)) * (j / x);
                        }

                        // 1個を食べる
                        if (k > 0)
                        {
                            DP[i, j, k] += (DP[i, j, k-1] + (N / x)) * (k / x);
                        }
                    }
                }
            }

            Console.WriteLine(DP[a, b, c]);
        }

    }
// libs ----------


// common ----------

internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 228320
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;
    cin >> s;
    map<string, int> days = {
        {"SUN", 7},
        {"MON", 6},
        {"TUE", 5},
        {"WED", 4},
        {"THU", 3},
        {"FRI", 2},
        {"SAT", 1}
    };
    cout << days[s] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
using namespace std;
signed main(){
int n,m,k;
cin>>n>>m>>k;
int a[n],b[m];
for(int i=0;i<n;i++){
    cin>>a[i];
}
for(int j=0;j<m;j++){
    cin>>b[j];
}
int x=0,y=0,sum1=0,sum2=0;
while(y<m && (sum2+b[y])<=k){
    sum2+=b[y];
    y++;
}
y--;
int ans=y+1;

for(int i=0;i<n;i++){
    sum1+=a[i];
    while(sum2>(k-sum1) && y>=0){
      sum2-=b[y];
      y--;

    }
    if(sum1<=k){
    ans=max(i+y+2,ans);}
}
cout<<ans;

}


Measured memory_bytes: 6708
#include<bits/stdc++.h>
using namespace std;
int main() {
	vector<int> a(3);
  	cin >> a[0] >> a[1] >> a[2];
  	sort(a.begin(), a.end());
  	a[1] -=a[0];a[2] -=a[0];a[0] = 0;
  	if(a[1] %2 == 0 && a[2] % 2 == 0)
      	cout << (a[2] - a[1]) /2 + a[2] /2 << endl;
    else if(a[1] % 2 == 0 && a[2] % 2 == 1)
      	cout << 1+(a[2]-1)/2+(a[2]-a[1]-1)/2 <<endl;
  	else if(a[1] % 2 == 1 && a[2] % 2 == 0)
      	cout << 1 + a[2]/2+(a[2]-a[1] +1)/2 << endl;
  	else
      	cout << 1 + (a[2]-a[1])/2+(a[2]+1)/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}

int main() {
	int a;
	cin >> a;
	int x = 360;
	int d = gcd(360, a);
	cout << x / d << endl;
}

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

    using namespace std;

    int main(){
        ios::sync_with_stdio(0);
        cin.tie(0);
        cout.tie(0);
        cout<<fixed;
        cout<<setprecision(10);
        double a,b,h,m;
        cin>>a>>b>>h>>m;

        // hour coordinate
        double deg_h=((h*360)/12)*(M_PI/180.0) + ((m*30)/60)*(M_PI/180.0);
        double deg_m=((m*360)/60)*(M_PI/180.0);
        double hx=a*sin(deg_h);
        double hy=a*cos(deg_h);
        double mx=b*sin(deg_m);
        double my=b*cos(deg_m);
//        cout<<hx<<" "<<hy<<" "<<mx<<" "<<my<<" "<<"\n";
        double dist=sqrt((hx-mx)*(hx-mx) + (hy-my)*(hy-my));
        cout<<dist;
        return 0;
    }


Measured memory_bytes: 4096
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  ll A[n];
  for(int i=0; i<n; ++i) cin >> A[i];
  int ans = 0;
  for(int i=0; i<n; ++i){
    while(i+1 < n && A[i] == A[i+1]) ++i;
    if(i+1 < n && A[i] < A[i+1]){
      while(i+1 < n && A[i] <= A[i+1]) ++i;
    }
    else if(i+1 < n && A[i] > A[i+1]){
      while(i+1 < n && A[i] >= A[i+1]) ++i;
    }
    ++ans;
  }
  cout << ans << endl;
}

Measured memory_bytes: 4372
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <string>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int vec = 0;
int H, W;

int news(int n) {
	int t;

	int h, w;
	h = n / W;
	w = n % W;

	if (vec == 0) {
		if ((w == W - 1) && (h % 2 == 0)) {
			t = W;
			vec = 1;
		}
		else
			t = 1;
	}
	else {
		if ((h % 2 == 1) && w == 0) {
			vec = 0;
			t = W;
		}
		else
			t = -1;
	}

	return n + t;
}

int main(void) {
	int N;
	int a[10005];
	int b[10005];
	int count = 0;

	cin >> H >> W;
	cin >> N;
	for (int i = 0; i < N; ++i)
		cin >> a[i];

	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < a[i]; ++j) {
			b[count] = i + 1;
			count = news(count);
			//printf("%d ", count);
		}
	}

	for (int i = 0; i < H; ++i) {
		cout << " " << b[i*W];
		for (int j = 1; j < W; ++j)
			cout << " " << b[i*W + j];
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 384