akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define fill(a,val) memset(a,val,sizeof(a))
#define REP(i,a,b) for (auto i = a; i != b; i++)
#define ll long long int
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define pb push_back
#define SQ(a) (a)*(a)
 
const int N = 10005;
using namespace std;
 
int main()
{
    std::ios::sync_with_stdio(false);
    //ll p = 1000000007; 
    
    int T = 1;
    //cin>>T;
    // cin.ignore(); must be there when using getline(cin, s)
    while(T--)
    {
          ll n,k;
          cin>>n>>k;
          ll val1 = ( n/k )* k;
          ll val2 = (n/k + 1)*k;
          cout<<min(abs(n-val1),abs(n-val2));
          
    }
    return 0;
}

 

Measured memory_bytes: 3620
from collections import Counter
import sys

N = int(input())
V = list(map(int, input().split()))

A = V[0::2]
B = V[1::2]

# print(A, B)

cnt = 0

if len(set(V)) == 1:
    print(N // 2)
    sys.exit()

A_counter = Counter(A)
B_counter = Counter(B)

A_top2 = A_counter.most_common(2)
B_top2 = B_counter.most_common(2)

if A_top2[0][0] != B_top2[0][0]:
    cnt += len(A) - A_top2[0][1]
    cnt += len(B) - B_top2[0][1]
else:
    cnt = min(
        len(A) - A_top2[0][1] + len(B) - B_top2[1][1],
        len(A) - A_top2[1][1] + len(B) - B_top2[0][1],
    )

print(cnt)

Measured memory_bytes: 19036
n,q=map(int,input().split())
s=str(input())
l=[]
r=[]
for i in range(q):
    a,b=map(int,input().split())
    l.append(a)#文字列の最初
    r.append(b)#文字列の最後

ans=[]
ans.append(0)
count=0
for i in range(n-1):
    if s[i:i+2]=="AC":
        count+=1
        ans.append(count)
    else:
        ans.append(count)

for i in range(q):
    print(ans[r[i]-1]-ans[l[i]-1])


#print(s[2:7])=ACTAC

Measured memory_bytes: 14164
#include<stdio.h>

 int main(void) {

 int i,n; 

  int number;

  long long int sum=0;

  int min=0; 

  int max=0;  

   scanf("%d",&n); 

    for(i=0;i<n;i++)

  {  

    scanf("%d",&number);   

  if(i==0) 

  {

  min = number;

  max = number;

  } 

  if(number<min) min = number; 

   if(number>max) max = number;  

    sum += number; 

     }

   printf("%d %d %lld\n",min,max,sum); 

     return 0;

 }  

Measured memory_bytes: 600
#include <stdio.h>
#include <algorithm>
using namespace std;
int main(void)
{
    int p, q, r, a, b, c, ans;
    scanf("%d%d%d", &p, &q, &r);
    a=p+q;
    b=q+r;
    c=p+r;
    ans=a;
    if(ans>b) ans=b;
    if(ans>c) ans=c;

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


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
// #define endl '\n';
#define fi first
#define se second
#define NONVOID [[nodiscard]]
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;



int main() {

    ll ans=INF;
    ll n,m,x;
    cin>>n>>m>>x;
    vll c(n);
    vvll v(n,vll(m));

    rep(i,n){
        cin>>c[i];
        rep(j,m)cin>>v[i][j];
    }
    rep(i,(1LL<<n)){
        ll tmp=0;
        vll rikai(m,0);
        rep(j,n){
            if((1LL<<j)&i){
                tmp+=c[j];
                rep(k,m){
                    rikai[k]+=v[j][k];
                }
            }
        }
        bool ok=1;
        rep(i,m)if(rikai[i]<x)ok=0;
        if(ok)chmin(ans,tmp);
    }
    if(ans!=INF)fin(ans);
    else fin(-1);
}

Measured memory_bytes: 3636
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
//#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define reps(i, j, k) for(auto i = j; i < k; ++i)
#define rep(i, j) reps(i, 0, j)
#define decs(i, j, k) for(auto i = j; i >= k; --i)
#define dec(i, j) decs(i, j, 0)
#define iter(i, j) for(auto i = j.begin(); i != j.end(); ++i)
#define pb push_back
#define vi vector<int>
#define vll vector<ll>
#define pi pair<int, int>
#define vpi vector<pi>
#define vb vector<bool>
#define F first
#define S second
#define mp make_pair
#define um unordered_map
#define all(x) (x).begin(), (x).end()  
#define fast_io ios::sync_with_stdio(0); cin.tie(0);
#define file_io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define IMAX std::numeric_limits<int>::max()
#define IMIN std::numeric_limits<int>::min()
using namespace std;

int main()
{
    //fast_io
    //file_io
	string s; cin >> s;
	string ans = "No";
	reps(i, 1, s.length())
	{
		if(s[i] != s[0]) 
		{
			ans = "Yes";
			break;
		}
	}
	cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

ll in(){
	ll x;
	cin >> x;
	return x;
}

int n,m;
vector<int> d;
vector<int> color;
vvector<int> edges;
vector<pii> memo;

void input(){
	n = in();
	m = in();
	d.resize(n);
	edges.resize(n);
	color.resize(n,-1);
	foreach(i,d){
		i = in();
	}
	rep(i,m){
		int a,b;
		a = in();
		b = in();
		--a;
		--b;
		if(a>b)swap(a,b);
		edges[a].push_back(b);
		edges[b].push_back(a);
		memo.emplace_back(a,b);
	}
}

void draw_color_eq(){
	rep(i,n){
		if(color[i]>=0)continue;
		foreach(j,edges[i]){
			if(d[i]!=d[j]){
				continue;
			}
			int dis = d[i];
			queue<int> que;
			que.push(i);
			color[i] = 0;
			while(que.size()){
				int p = que.front();
				que.pop();
				foreach(k,edges[p]){
					if(d[k]!=dis)continue;
					if(color[k]!=-1)continue;
					color[k] = !color[p];
					que.push(k);
				}
			}
		}
	}
}

map<pii,int> solve(){
	map<pii,int> ans;
	auto add_ans = [&](int a,int b,int c){
		if(a>b)swap(a,b);
		ans[pii(a,b)] = c;
	};
	vector<pii> order;
	rep(i,n){
		order.emplace_back(d[i],i);
	}
	sort(all(order));
	foreach(now,order){
		int place = now.second;
		int dis = now.first;
		foreach(to,edges[place]){
			if(d[to]>d[place])continue;
			if(d[to]==d[place]){
				add_ans(place,to,dis);
				continue;
			}
			if(color[place]==-1){
				color[place] = color[to];
			}
			if(color[place]==color[to]){
				add_ans(to,place,dis-d[to]);
			}else{
				add_ans(to,place,dis);
			}
		}
		if(color[place]==-1){
			return map<pii,int>();
		}
	}
	return ans;
}

int main(){
	input();
	draw_color_eq();
	map<pii,int> ans = solve();
	if(ans.empty()){
		cout << -1 << endl;
		return 0;
	}
	foreach(i,color){
		if(i){
			cout << "B";
		}else{
			cout << "W";
		}
	}
	cout << endl;
	foreach(i,memo){
		cout << ans[i] << endl;
	}
	return 0;
}


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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };



int main() {
	int n, i;
	cin >> n;
	vl a(n);
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	sort(a.begin(), a.end());
	ll cnt1 = 0, cnt2 = 1;
	ll pre = a[0];
	for (i = 1; i < n; i++) {
		if (pre == a[i]) {
			cnt2++;
		}
		else {
			if (cnt2 % 2 == 1) {
				cnt1++;
			}
			pre = a[i];
			cnt2 = 1;
		}
	}
	if (cnt2 % 2 == 1) {
		cnt1++;
	}
	cout << cnt1 << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    string abc = "ABC";
    string arc = "ARC";
    if(s.compare(abc) == 0) cout << arc << endl;
    else cout << abc << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define INF 1LL << 60
#define MOD 1000000007ll
#define EPS 1e-10
#define REP(i, m) for (long long i = 0; i < m; i++)
#define FOR(i, n, m) for (long long i = n; i < m; i++)
#define pb push_back
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef long double ld;

int main() {
  int n;
  cin >> n;
  int a[n], b[n];
  map<int, int> m;
  REP(i, n){
    cin >> a[i];
    b[i] = a[i];
  }
  sort(b, b+n);
  REP(i, n){
    m[b[i]] = i;
  }
  int ans = 0;
  REP(i, n){
    if((i%2) != (m[a[i]]%2)) ans++;
  }
  cout << ans/2 << endl;
	return 0;
}


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

int main(int argc, char *argv[])
{
    int n, b;
    cin >> b >> n;

    int mult = 1;
    if(b > 0) mult = b == 1 ? 100 : 10000;

    if(n <= 99)
    {
        cout << n * mult << endl;
    }
    else
    {
        cout << 101 * mult << endl;
    }
}


Measured memory_bytes: 256
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit('(i8,i8,i8[:])', cache=True)
def main(N, K, A):
    B = np.maximum(A, 0)
    Acum = np.zeros(len(A) + 1, np.int64)
    Bcum = np.zeros(len(A) + 1, np.int64)
    Acum[1:] = np.cumsum(A)
    Bcum[1:] = np.cumsum(B)
    ret = -(10**18)
    for l in range(N - K + 1):
        r = l + K
        sum1 = Bcum[l]
        sum2 = Bcum[-1] - Bcum[r]
        sum3 = Acum[r] - Acum[l]
        x = sum1 + sum2 + max(sum3, 0)
        ret = max(ret, x)
    return ret

N, K = map(int, readline().split())
A = np.array(read().split(), np.int64)

print(main(N, K, A))


Measured memory_bytes: 113156
#include <bits/stdc++.h>
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int a, b, c; scanf("%d%d%d", &a, &b, &c);
	
	printf("%d\n", a * b / 2);
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int count = 1;
        if(a != b && a != c){
            count += 1;
        }

        if(b != c){
            count += 1;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 35760
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		double esp = 0.00000001;
		while(cin.hasNext()){
			double w = cin.nextDouble();
			if(w <= 48.00){
				System.out.println("light fly");
			}
			else if(w <= 51.00 && w >= 48.00 + esp){
				System.out.println("fly");
			}
			else if(w <= 54.00 && w >= 51.00 + esp){
				System.out.println("bantam");
			}
			else if(w <= 57.00 && w >= 54.00 + esp){
				System.out.println("feather");
			}
			else if(w <= 60.00 && w >= 57.00 + esp){
				System.out.println("light");
			}
			else if(w <= 64.00 && w >= 60.00 + esp){
				System.out.println("light welter");
			}
			else if(w <= 69.00 && w >= 64.00 + esp){
				System.out.println("welter");
			}
			else if(w <= 75.00 && w >= 69.00 + esp){
				System.out.println("light middle");
			}
			else if(w <=81.00 && w >= 75.00 + esp){
				System.out.println("middle");
			}
			else if(w <= 91.00 && w >= 81.00 + esp){
				System.out.println("light heavy");
			}
			else{
				System.out.println("heavy");
			}
		}
	}

}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int turn = 0;
  while (a > 0 && c > 0) {
    if (turn % 2 == 0) {
      c -= b;
    } else {
      a -= d;
    }
    turn++;
  }

  if (c <= 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3636
"""
author : halo2halo
date : 9, Jan, 2020
"""

import sys

# import numpy as np
import itertools

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, L = map(int, readline().split())
F = [L + i for i in range(N)]


tmp = 1000
ans=0
for i in itertools.combinations(F, N - 1):
    if abs(sum(F)-sum(i)) < tmp:
        tmp = abs(sum(F)-sum(i))
        ans=sum(i)

print(ans)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int[] a = new int[n];
		int max1 = 0;
		int max2 = 0;
		for(int i=0;i<n;i++) {
			a[i] = in.nextInt();
			if(a[i]>max1) {
				max2 = max1;
				max1 = a[i];
			}else if(a[i]>max2) {
				max2 = a[i];
			}
		}
		for(int i=0;i<n;i++) {
			if(a[i]==max1) System.out.println(max2);
			else System.out.println(max1);
		}
		
		in.close();

	}

}


Measured memory_bytes: 93328
'use strict'

function main(input) {
  input = input.trim()
  // .split(' ')
  // .map(v => ~~v)
  const ans = input.match(/[aiueo]/) ? 'vowel' : 'consonant'
  console.log(ans)
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'))


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double a, b, x;
    cin>>a>>b>>x;
    if(x>(0.5*a*a*b))
    {
        double h = 2 * x / (a * a) - b;
        double ans = atan((a) / (b - h)) * 180 / pi;
        printf("%.12lf",(90-ans));
    }
    else
    {

        double ans = atan((a*b*b)/(2*x))*180/pi;
        printf("%.12lf",(ans));

    }
}


Measured memory_bytes: 256
//If you are reading this then you are at wrong place.
#include<bits/stdc++.h>
#define mod 1000000007
#define lli long long int
using namespace std;
bool prime [1000001];
void debug(lli a){cout<<a<<endl;}
lli sieve(lli a){memset(prime,true,sizeof(prime));lli p,i;for(p=2;p*p<=a;p++){if(prime[p]==true){for(i=p*2;i<=a;i+=p)prime[i]=false;}}return 0;}
lli powermod(lli _a,lli _b,lli _m){lli _r=1;while(_b){if(_b%2==1)_r=(_r*_a)%_m;_b/=2;_a=(_a*_a)%_m;}return _r;}
lli find_max(lli __a,lli __b){return __a^((__a^__b) & -(__a<__b));}
lli add(lli __a,lli __b,lli MOD){lli x = (__a+__b)%MOD; return x; }
lli mul(lli a,lli b,lli MOD){lli x = (a*b)%MOD; return x; }
lli sub(lli a,lli b,lli MOD){lli x = (a-b+MOD)%MOD; return x; }
lli div(lli a,lli b,lli MOD){lli x = a;lli y = powermod(b,MOD-2,MOD);lli res = (x*y)%MOD;return res;}
int main()
{
	//ifstream cin("testcase.txt");
	//ofstream cout("output.txt");	
	ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);	
	cout.precision(20);
	lli t,i,j;
	//cin>>t;
	//memset(dp, -1, sizeof dp);
	t=1;
	lli counter1=0;
	while(t--)
	{
		counter1++;
		lli n,k;
		cin>>n>>k;
		lli a[n];
		for(i=0;i<n;i++)
			cin>>a[i];
		lli ans=0;
		for(i=0;i<n-1;i++)
		{
			if(a[i]+k>=a[i+1])
			{
				ans+=a[i+1]-a[i];
				//cout<<a[i]<<endl;
			}
			else
				ans+=k;
		}
		cout<<ans+k<<endl;
		//cout<<"Case #"<<counter1<<" ";
		//cout<<endl;	
	}	
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;
    cin >> n;
    vector<int> p(n),q(n);
    REP(i,n) cin >> p[i];
    REP(i,n) cin >> q[i];
    vector<int> v(n);
    iota(ALL(v),1);
    int a,b,cnt=0;
    do{
        cnt++;
        REP(i,n){
            if(v==p)a=cnt;
            if(v==q)b=cnt;
        }
    }while(next_permutation(ALL(v)));
    cout << abs(a-b);

    return 0;
}

Measured memory_bytes: 3592
<?php
  fscanf(STDIN, "%i %i %i", $n, $a, $b);
  $xs = explode(" ", trim(fgets(STDIN)));
  $cost = 0;
  for ($i = 1; $i < $n; $i++)
  {
    $dist = $xs[$i] - $xs[$i - 1];
    $cost += min([$a * $dist, $b]);
  }
  echo $cost.PHP_EOL;
?>


Measured memory_bytes: 10868
#include "bits/stdc++.h"
#define ed cout << "\n";
#define speed                         \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define ll long long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define All(obj) (obj).begin(), (obj).end()

using namespace std;

int main()
{
    speed;
    string s;
    cin >> s;
    int ans = 700;
    if (s.at(0) == 'o')
        ans += 100;
    if (s.at(1) == 'o')
        ans += 100;
    if (s.at(2) == 'o')
        ans += 100;

    cout << ans;
    ed;
    return 0;
}

Measured memory_bytes: 256
import Foundation

func main() {
    guard let line = readLine() else { return }
    //let inputs = line.components(separatedBy: " ").compactMap() { Int($0) }
    var inputs = [String]()
    for a in line {
        inputs.append(String(a))
    }
    var count = 0
    if inputs[1] == "R" {
        count += 1
        if inputs[0] == "R" {
            count += 1
            if inputs[2] == "R" {
                count += 1
            }
        } else if inputs[2] == "R" {
            count += 1
        }
    } else {
        if inputs[0] == "R" || inputs[2] == "R" {
            count += 1
        }
    }
    print(count)
}
main()


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

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

int main(){
  int a,b,k;
  cin >>a>>b>>k;
  int g=gcd(a,b);
  int p=0;
  int ans=0;
  for(int i=0; i<g and p<k;i++){
    if(g%(g-i)==0) {
      p++;
      ans = g-i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	int n; int[] aa;
	void solvep(int ip) {
		int m = n - 1;
		for (int i = 0; i < n; i++)
			if (aa[i] < 0)
				m++;
		println(m);
		for (int i = 0; i < n; i++)
			if (aa[i] < 0)
				println((ip + 1) + " " + (i + 1));
		for (int i = 1; i < n; i++)
			println(i + " " + (i + 1));
	}
	void solveq(int iq) {
		int m = n - 1;
		for (int i = 0; i < n; i++)
			if (aa[i] > 0)
				m++;
		println(m);
		for (int i = 0; i < n; i++)
			if (aa[i] > 0)
				println((iq + 1) + " " + (i + 1));
		for (int i = n; i > 1; i--)
			println(i + " " + (i - 1));
	}
	void main() {
		n = sc.nextInt();
		aa = new int[n];
		for (int i = 0; i < n; i++)
			aa[i] = sc.nextInt();
		int ip = -1, iq = -1;
		for (int i = 0; i < n; i++)
			if (aa[i] > 0 && (ip == -1 || aa[ip] < aa[i]))
				ip = i;
			else if (aa[i] < 0 && (iq == -1 || aa[iq] > aa[i]))
				iq = i;
		if (ip != -1 && iq == -1)
			solvep(ip);
		else if (ip == -1 && iq != -1)
			solveq(iq);
		else if (ip != -1 && iq != -1) {
			if (aa[ip] + aa[iq] >= 0)
				solvep(ip);
			else
				solveq(iq);
		} else
			println(0);
	}
}


Measured memory_bytes: 38944
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  string S;
  cin >> N >> S;
  int count = 0;
  int ans = 0;
  for(int i = 0; i < N; i++) {
    if(S.at(i) == 'I') {
      count++;
    }
    else {
      count--;
    }
    if(count > ans) {
      ans = count;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
n = int(input())
r, s = 2, n
a = []
for i in range(r):
    a.append(list(map(int, input().split())))

jagoda = [[-1 for j in range(s)] for i in range(r)]

# Pocetno polje
jagoda[0][0] = a[0][0]

# Prvi redak
for j in range(1, s):
    jagoda[0][j] = jagoda[0][j - 1] + a[0][j]

# Prvi stupac
for i in range(1, r):
    jagoda[i][0] = jagoda[i - 1][0] + a[i][0]

# Ostala polja
for i in range(1, r):
    for j in range(1, s):
        jagoda[i][j] = max(jagoda[i - 1][j], jagoda[i][j - 1]) + a[i][j]

print(jagoda[-1][-1])


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

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

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

    int n, k;
    cin >> n >> k;

    if (k > (n + 1) / 2) {
        cout << "NO\n";
    } else {
        cout << "YES\n";
    }

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
#define el '\n'
template<class T> bool rmn(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool rmx(T &a, T b) { return a < b ? (a = b, true) : false; }
typedef long long ll; typedef long double ld; typedef double dd; typedef pair<int, int> pii;
const ll INFLL=0x7f7f7f7f7f7f7f7f, MOD=1e9+7; const int INF=0x7f7f7f7f;

//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';

/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vv<int> vis, color; 
int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){if(a<0) a=-a; if(b<0) b=-b; while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}

///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());

int k,x; cin>>k>>x;
for(int i=max(-1000000LL,x-k+1);i<min(1000000LL,x+k);++i) cout<<i<<' ';

return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2005;
int n,k,a,b;
vector<int>v[N];
int maxn=0,vis[N],cnt;
pair<int,int>edge[N];
void dfs(int val,int cs)
{
	if(vis[val]==1)
	return;
	vis[val]=1;
	if(cs==k/2+1)
	return;
	for(int i=0;i<v[val].size();i++)
	{
		if(vis[v[val][i]])
		continue;
		cnt++;
		dfs(v[val][i],cs+1);
	}
	return;
}
int main()
{
	scanf("%d %d",&n,&k);
	for(int i=1;i<n;i++)
	{
		scanf("%d %d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
		if(a>b)
		swap(a,b);
		edge[i].first=a;
		edge[i].second=b;
	}
	int ma=0;
	if(k%2==0)
	{
		for(int i=1;i<=n;i++)
		{
			for(int j=0;j<=n;j++)
			vis[j]=0;
			cnt=1;
			dfs(i,1);
			ma=max(ma,cnt);
		}
		printf("%d\n",n-ma);
//		cout<<n-maxn<<endl;
	}
	else
	{
		for(int i=1;i<n;i++)
		{
			for(int j=0;j<=n;j++)
			vis[j]=0;
			int aa=edge[i].first,bb=edge[i].second;
			vis[bb]=1;
			cnt=1;
			dfs(aa,1);
			int sum=cnt;
//			cout<<sum<<" ";
			vis[aa]=1;
			vis[bb]=0;
			cnt=1;
			dfs(bb,1);
			sum+=cnt;
//			cout<<cnt<<endl;
			ma=max(ma,sum);
		}
		printf("%d\n",n-ma);
	}
}

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

travellist = []
for _ in range(M):
    a, b = map(int, input().split())
    travellist.append([a,b])

travellist = sorted(travellist)


To_list = [0]*N
From_list = []
for i in range(M):

    oneroot = travellist[i]
    From = oneroot[0]
    To   = oneroot[1]

    if From == 1:
        To_list[To] = 1

    if To == N:
        From_list.append(From)


for i in From_list:
    if To_list[i] == 1:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")
        

Measured memory_bytes: 109504
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int dp[200][200][2];
int n;

bool rec(int a,int b,int c){
	if(dp[a][b][c]!=-1)return dp[a][b][c];
	if(c==0){//Alice
		if(a<n-1&&a+1!=b){
			if(rec(a+1,b,!c))return dp[a][b][c]=true;
		}
		return dp[a][b][c]=false;
	}
	else{//Bob
		if(b&&b-1!=a){
			if(!rec(a,b-1,!c))return dp[a][b][c]=false;
		}
		return dp[a][b][c]=true;
	}
}
signed main(){
	int a,b;scanf("%d%d%d",&n,&a,&b);a--;b--;
	memset(dp,-1,sizeof(dp));
	puts(rec(a,b,0)?"Alice":"Borys");
}

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

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

string n;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	if(n[0] == '7' || n[1] == '7' || n[2] == '7') cout << "Yes\n";
	else cout << "No\n";
	return 0;
}

Measured memory_bytes: 3656
#include <iostream>
using namespace std;
int n;
int a[210];
int main() {
	cin >>n;
	for(int i=0;i<n;++i)cin>>a[i];
	int res=0;
	while(true){
		bool exist_odd=false;
		for(int i=0;i<n;++i){
			if(a[i]%2!=0)exist_odd=true;
			
			
		}
		if(exist_odd)break;
		for(int i=0;i<n;++i){
			a[i]/=2;
		}
		++res;
	}
	cout <<res<<endl;
	
}



Measured memory_bytes: 256
// Sky's the limit :)
#include<bits/stdc++.h>
using namespace std;
#define int long long

const int N = 205;
int n, m, q;
int a[N], b[N], c[N], d[N];
int arr[N], ans;
 
void fun(int i,int p)
{
	if(i == n + 1) {
		int cost = 0;
		for(int i = 0; i < q; i++) {
			if(arr[b[i]] - arr[a[i]] == c[i]) 
				cost += d[i];
		}
		ans = max(ans, cost);
		return;
	}

	for(int j = p; j <= m; j++) {
		arr[i] = j;
		fun(i + 1, j);
	}
}

signed main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    //int t = 1; cin >> t; while(t--)
    {
    	cin >> n >> m >> q;
		for(int i = 0; i < q; i++) 
			cin >> a[i] >> b[i] >> c[i] >> d[i];
		fun(1,1);

		cout << ans << '\n';
	}
    
    cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
    return 0;
}



Measured memory_bytes: 3820
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

// GCD : greatest common divisor (GCD) via Euclidean algorithm
func GCD(a, b int) int {
	for b != 0 {
		t := b
		b = a % b
		a = t
	}
	return a
}

// LCM : find Least Common Multiple (LCM) via GCD
func LCM(a, b int, integers ...int) int {
	result := a / GCD(a, b) * b

	for i := 0; i < len(integers); i++ {
		result = LCM(result, integers[i])
	}

	return result
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer([]byte{}, 1000000)

	N, M := getInt(), getInt()
	S := getString()
	T := getString()

	L := LCM(N, M)
	ss := L / N
	st := L / M
	m := make(map[int]byte)
	for i := 0; i < N; i++ {
		m[i*ss] = S[i]
	}
	for i := 0; i < M; i++ {
		idx := i * st
		v, ok := m[idx]
		if ok && v != T[i] {
			out(-1)
			return
		}
	}

	out(max(ss*N, st*M))

}


Measured memory_bytes: 4608
#include<iostream>
#include<queue>
#include<string>
#include<vector>
#include<math.h>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include<stack>
#include<sstream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<list>
#include<numeric>
typedef long long ll;

#define pi 3.14159265358979323846264338327950L
#define VI vector<int>
#define VLL vector<long long>
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
const ll MOD = 1e9 + 7;
using namespace std;
template<typename T>
T gcd(T a, T b) {
	if (b == 0) return a;
	return gcd(b, a % b);
	//return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	ll g = gcd(a, b);
	return a / g * b; // Be careful not to overflow
	//return a * b / gcd(a, b);
}

template<typename T>
T binarysearch(vector<T> A, T key) {
	ll left = 0;ll right = 4;ll mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key == A[mid]) return 1;
		if (key > A[mid]) left = mid + 1;
		else if (key < A[mid]) right = mid;
	}
	return 0;
}

template<typename T>
T finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) { // 発見できたとき
		return 1;
	}
	else { // 発見できなかったとき
		return 0;
	}
}
ll frac(ll n)//階乗
{
	if (n == 0) {
		return 1;
	}
	return (n * frac(n - 1)) % MOD;
}

template<typename T>
T keta(T a) {
	ll kazu = 1;
	while (1) {
		if (a / 10 != 0) { a /= 10;kazu++; }
		else break;
	}
	return kazu;
}//桁数

//素数判定
template<typename T>
bool IsPrime(T 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;
}

template<typename T>
T nCr(ll n, T r) {
	ll ans = 1;
	for (int i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (int i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
/*char r[4];
int yaju[4];
char op[3];
int sum = 0;
scanf("%s", r);
for (int i = 0;i < 4;i++) {
	yaju[i] = r[i] - '0';
}
*/
//vector<vector<int>> data(3, vector<int>(4));
//vector<vector<Type>> vv(n);
//cout << fixed << setprecision(20) << endl;

int main() {
	string s;cin >> s;
	for (ll i = 0;i < s.size();i++) {
		if (s[i] != ',')cout << s[i];
		else cout << " ";
	}
}


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

using namespace std;

const int64_t M = 1000000007;
const int MAX_N = 300;
int n, k;
int p[2*MAX_N+1];
int64_t dp[2*MAX_N+1][2*MAX_N+1];
int psum[2*MAX_N+1];
int64_t gpre[2*MAX_N];

int64_t g(int i, int j)
{
  int n = psum[j] - psum[i-1];
  if (i == j || n % 2 == 1) return 0;
  if (n == 0) return 1;
  return gpre[n-1];
}

int main()
{
  cin >> n >> k;
  fill_n(p, 2*n+1, 0);
  int a, b;
  for (int i = 0; i < k; i++) {
    cin >> a >> b;
    p[a] = b;
    p[b] = a;
  }

  psum[0] = 0;
  for (int i = 1; i <= 2*n; i++) {
    psum[i] = psum[i-1] + (p[i] == 0 ? 1 : 0);
  }

  fill_n(gpre, 2*n, 0);
  gpre[1] = 1;
  for (int i = 3; i < 2*n; i += 2) {
    gpre[i] = gpre[i-2] * i % M;
  }

  for (int i = 0; i <= 2*n; i++)
    for (int j = 0; j <= 2*n; j++)
      dp[i][j] = 0;

  for (int i = 1; i <= 2*n; i++) {
    int max_out = p[i];
    if (p[i] > 0 && p[i] < i) continue;
    for (int j = i+1; j <= 2*n; j++) {
      if (p[j] > 0 && p[j] < i) break;
      max_out = max(max_out, p[j]);
      if (max_out <= j) {
        dp[i][j] = g(i,j);
        if (dp[i][j] != 0) {
          for (int k = i+1; k < j; k++) {
            dp[i][j] = (dp[i][j] - (dp[i][k] * g(k+1, j) % M) + M) % M;
          }
        }
      }
    }
  }

  int64_t r = 0;
  for (int i = 1; i <= 2*n; i++) {
    for (int j = i+1; j <= 2*n; j++) {
      int zeros = 2*n - 2*k - (psum[j] - psum[i-1]);
      r = (r + dp[i][j] * (zeros == 0 ? 1LL : gpre[zeros - 1]) % M) % M;
    }
  }

  cout << r << endl;

  return 0;
}


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

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

  int a;
  int minValue = 1000000;
  int maxValue = -1000000;
  long long sum = 0;

  for (int i = 0; i < n; i++) {
    cin >> a;

    minValue = (a < minValue) ? a : minValue;
    maxValue = (a > maxValue) ? a : maxValue;

    sum += a;
  }

  cout << minValue << " " << maxValue << " " << sum << endl;
  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18,MOD = 1e9 + 7;
const int INT_INF = 1e9,INT_MOD=1e9+7;
#define rep(i, N) for(ll i = 0; i < N; i++)
#define REP(i, n) for(int i = 0; i <= n; i++)
#define rrep(i,n) for(int i=n;i>0;i--)
#define RREP(i,n) for(int i=n;i>=0;i--)
typedef pair<int, int> Pi;
typedef pair<double, double> P;
signed main(){
    int n,x;cin>>n>>x;
    for(int i=1;i<4;i++){
        if(i!=n and i!=x) cout<<i<<endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
      	  for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
       	if(prime[i]==0)
       		seve.pb(i);
       }
    }
    ld dp[301][301][301];
    int main()
    {   
         IOS;
         int n,m,i,j,k,a=0,b=0,c=0;
         cin>>n;
         for(i=0;i<n;i++)
         {
         	cin>>j;
         	if(j==1)
         		a++;
         	else if(j==2)
         		b++;
         	else
         		c++;
         }
        for(k=0;k<301;k++)
        {
        	for(j=0;j<301;j++)
        	{
        		for(i=0;i<301;i++)
        		{
        			if(i+j+k>300)
        				continue;
        			if((i+j+k)!=0)
        				dp[i][j][k]=1.0*n/(i+j+k);
        			if(i>0)
        				dp[i][j][k]+=1.0*i*dp[i-1][j][k]/(i+j+k);
        			if(j>0)
        				dp[i][j][k]+=1.0*j*dp[i+1][j-1][k]/(i+j+k);
        			if(k>0)
        				dp[i][j][k]+=1.0*k*dp[i][j+1][k-1]/(i+j+k);
        		}
        	}
        }
        // cout<<a<<" "<<b<<" "<<c;
        cout<<fixed<<setprecision(13)<<dp[a][b][c];

    }

Measured memory_bytes: 426240
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String N = sc.next();
		int t = 0;
		String ans;
		for(int i =0; i<N.length(); i++) {
			t += Character.getNumericValue(N.charAt(i));
		}

		if (t%9 == 0) {
			ans = "Yes";
		}else {
			ans = "No";
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 40424
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt(); //時
		int b = scan.nextInt(); //分
		int c = scan.nextInt();
		int d = scan.nextInt();
		int k = scan.nextInt(); //勉強時間
		int m1 = c - a;
		//おきてから寝るまで
		int m2;
		if(d >= b) {
			m2 = d - b;
		} else {
			m2 = 60 - (b - d);
			m1--;
		}
		int h = m1 * 60 + m2 - k;
		System.out.println(h);
		
	}

}

Measured memory_bytes: 35676
N,M = map(int,input().rstrip().split(" "))
G = [[] for i in range(N + 1)]
ans = False
for i in range(M):
    a,b = map(int,input().rstrip().split(" "))
    G[a].append(b)
    G[b].append(a)
for i in G[1]:
    if (N in G[i]):
        ans = True
if ans:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")


Measured memory_bytes: 108388
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			char[] w = scanner.next().toCharArray();
			Map<Character, Integer> map = new HashMap<>();
			for (char c : w) {
				map.put(c, map.getOrDefault(c, 0) + 1);
			}
			boolean result = true;
			for (Character c : map.keySet()) {
				if (0 != (map.get(c) & 1)) {
					result = false;
					break;
				}
			}
			System.out.println(result ? "Yes" : "No");
		}
	}
}


Measured memory_bytes: 35856
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

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

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------

int main(void){
    int n, T;
    cin >> n >> T;

    vector<int> c(n), t(n);

    for(int i = 0; i < n; i++){
        cin >> c[i] >> t[i];
    }

    int ans = 1e9;
    for(int i = 0; i < n; i++){
        if(t[i] > T)continue;
        ans = min(ans, c[i]);
    }
    if(ans == 1e9){
        cout << "TLE" << endl;
        return 0;
    }
    cout << ans << endl;

    
}



Measured memory_bytes: 256
#include <iostream>

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

    if (*(a.end() - 1) == b[0] && *(b.end() - 1) == c[0]) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.Map.Entry;

import java.util.PriorityQueue;
import java.util.Random;
import java.util.StringTokenizer;
import java.util.TreeSet;


public class Main {
	
	public static void main(String[] args) throws IOException {	
		try(final Scanner sc = new Scanner(System.in)){	
			System.out.println((char)(sc.next().charAt(0) + 1));
		}
	}

	public static class Scanner implements Closeable {
		private BufferedReader br;
		private StringTokenizer tok;

		public Scanner(InputStream is) throws IOException {
			br = new BufferedReader(new InputStreamReader(is));
		}

		private void getLine() throws IOException {
			while(!hasNext()){
				tok = new StringTokenizer(br.readLine());
			}
		}

		private boolean hasNext() {
			return tok != null && tok.hasMoreTokens();
		}

		public String next() throws IOException {
			getLine();
			return tok.nextToken();
		}

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

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

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

		public int[] nextIntArray(int n) throws IOException {
			final int[] ret = new int[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextInt();
			}
			return ret;
		}

		public long[] nextLongArray(int n) throws IOException {
			final long[] ret = new long[n];
			for(int i = 0; i < n; i++){
				ret[i] = this.nextLong();
			}
			return ret;
		}

		public void close() throws IOException {
			br.close();
		}
	}
}

Measured memory_bytes: 22484
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<list>
#include<iostream>
#include<vector>
using namespace std;
typedef pair<int,int> P;
#define S second
#define F first
struct Rect{
  int x1,y1,x2,y2;
  Rect(){}
  Rect(int x1,int y1,int x2,int y2) : x1(x1),y1(y1),x2(x2),y2(y2) {}
  bool operator < (const Rect& oth)const{
    if(y2 == oth.y2){
      return y1 < oth.y1;
    }
    return y2 < oth.y2;
  }
};
struct Act{
  int up,down;
  Act(){}
  Act(int up,int down) : up(up),down(down) {}
};
int N,R;
Rect S[10002];
vector<Act> A[10002];
int main(){
  while(1){
    scanf("%d %d",&N,&R);
    if(!N && !R) break;
    int minx=100000,maxx=0;
    for(int i=0;i<N;i++){
      scanf("%d %d %d %d",&S[i].x1,&S[i].y1,&S[i].x2,&S[i].y2);
      minx = min(S[i].x1,minx); maxx = max(S[i].x2,maxx);
    }
    sort(S,S+N);
    for(int i=N-1;i>-1;i--){
      //      printf("%d %d %d %d\n",S[i].x1,S[i].y1,S[i].x2,S[i].y2);
      for(int x = S[i].x1; x < S[i].x2; x++){
	if(A[x].empty()){
	  A[x].push_back(Act(S[i].y2,S[i].y1));
	} else {
	  int dw = A[x].back().down;
	  if(dw > S[i].y2){
	    A[x].push_back(Act(S[i].y2,S[i].y1));
	  } else if ( dw > S[i].y1 )
	    A[x].back().down = S[i].y1;
	}
      }
    }
    int res1=0;
    int res2=0;
    int sump=0;
    for(int i=0;i<(int)A[minx].size();i++){
      res1 += (A[minx][i].up - A[minx][i].down);
      res2 += (A[minx][i].up - A[minx][i].down);
    }
    sump = res2;
    res2 += (int)A[minx].size() * 2;
    for(int i=minx+1; i<=maxx; i++){
      int l=0;
      int sumk=0;
      int sumn=0;
      //      printf("%d %d\n",res1,res2);
      for(int j=0;j<(int)A[i].size();j++){
	res1 += (A[i][j].up - A[i][j].down);
	sumn += (A[i][j].up - A[i][j].down);
	bool f=false;
	do{
	  f=false;
	  if(A[i-1][l].up == A[i][j].up){
	    if(A[i-1][l].down >= A[i][j].down){
	      sumk += (A[i-1][l].up - A[i-1][l].down);
	      f=true;
	    }else{
	      sumk += (A[i][j].up - A[i][j].down);
	    }
	  } else if(A[i-1][l].up > A[i][j].up && A[i][j].up > A[i-1][l].down){
	    if(A[i-1][l].down == A[i][j].down){
	      sumk += (A[i][j].up-A[i][j].down);
	      f=true;
	    }else if(A[i-1][l].up > A[i][j].down && A[i][j].down > A[i-1][l].down){
	      sumk += (A[i][j].up - A[i][j].down);
	    } else{
	      sumk += (A[i][j].up - A[i-1][l].down);
	      f=true;
	    }
	  } else if(A[i][j].up > A[i-1][l].up && A[i-1][l].up > A[i][j].down){
	    if(A[i-1][l].down == A[i][j].down){
	      sumk += (A[i-1][l].up - A[i-1][l].down);
	      f=true;
	    }else if(A[i][j].up > A[i-1][l].down && A[i-1][l].down > A[i][j].down){
	      sumk += (A[i-1][l].up - A[i-1][l].down);
	      f=true;
	    } else {
	      sumk += (A[i-1][l].up - A[i][j].down);
	    }
	  } else if(A[i-1][l].down >= A[i][j].up) f=true;
	  if(f) l++;
	} while(f && l < (int)A[i-1].size());
      }
      res2 += (sump - sumk);
      res2 += (sumn - sumk);
      res2 += (int)A[i].size()*2;
      sump = sumn;
    }
    printf("%d\n",res1);
    if(R==2) printf("%d\n",res2);

    for(int i=minx; i<=maxx; i++) A[i].clear();
  }
}

Measured memory_bytes: 1892