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

namespace ConsoleApp1
{
    class ABC178E
    {
        // https://atcoder.jp/contests/abc178/tasks/abc178_e

        const long m = 1000000007;

        const long LUX = 0;
        const long LUY = 1000000001;

        const long LDX = 0;
        const long LDY = 0;

        const long RUX = 1000000001;
        const long RUY = 1000000001;

        const long RDX = 1000000001;
        const long RDY = 0;

        static void Main(string[] args)
        {
            int N = Int32.Parse(Console.ReadLine());

            long lud = long.MaxValue;
            long lux = 0;
            long luy = 1000000001;

            long ldd = long.MaxValue;
            long ldx = 0;
            long ldy = 0;

            long rud = long.MaxValue;
            long rux = 1000000001;
            long ruy = 1000000001;

            long rdd = long.MaxValue;
            long rdx = 1000000001;
            long rdy = 0;

            for (int i = 0; i < N; i++)
            {
                var items = Console.ReadLine().Split();
                long x = Int64.Parse(items[0]);
                long y = Int64.Parse(items[1]);

                long d;
                d = dist(x, y, LUX, LUY);
                if (d < lud)
                {
                    lud = d;
                    lux = x;
                    luy = y;
                }
                d = dist(x, y, LDX, LDY);
                if (d < ldd)
                {
                    ldd = d;
                    ldx = x;
                    ldy = y;
                }
                d = dist(x, y, RUX, RUY);
                if (d < rud)
                {
                    rud = d;
                    rux = x;
                    ruy = y;
                }
                d = dist(x, y, RDX, RDY);
                if (d < rdd)
                {
                    rdd = d;
                    rdx = x;
                    rdy = y;
                }
            }

            Console.WriteLine(
                Math.Max(
                    dist(lux, luy, rdx, rdy),
                    dist(ldx, ldy, rux, ruy)
                )
            );
        }

        static long dist(long dx1, long dy1, long dx2, long dy2)
        {
            return Math.Max(dx1 - dx2, dx2 - dx1) + Math.Max(dy1 - dy2, dy2 - dy1);
        }
    }
}


Measured memory_bytes: 46116
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 10000000
#define rep(i,a,b) for(ll (i)=a;(i)<(ll)(b);(i)++)
using ipair = pair<ll,ll>;

int main(){
    int X,Y;
    cin >> X >> Y;
    if((4*X-Y)/2>=0 && (4*X-Y)%2==0 && (-2*X+Y)/2>=0 && (-2*X+Y)%2==0){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

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

int main(void){
	
	int a,b;
	int i,j,k;
	
	cin >> a >> b;
	
	i = a+b;
	j = a-b;
	k = a*b;
	
	if(i<j){
		i = j;
	}
	if(i<k){
		i = k;
	}
	
	
	
	cout << i;
	
	return 0;
}

Measured memory_bytes: 256
Q, H, S, D = map(int, input().split())
L = int(input())
quantities = [(8*Q, 'Q'), (4*H, 'H'), (2*S, 'S'), (D, 'D')]
rest = {'Q': 4*Q, 'H': 2*H, 'S': S, 'D': D//2}
quantities.sort()
if quantities[0][1] == 'D' and L%2 != 0:
  print(L//2*D + rest[quantities[1][1]])
elif quantities[0][1] == 'D' and L%2 == 0:
  print(L//2*D)
else:
  print(L*rest[quantities[0][1]])

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

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

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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

LL Gcd(LL a, LL b) {
  if (a < b) {
    return Gcd(b,a);
  }
  if (b == 0) {
    return a;
  }
  else {
    return Gcd(b,a%b);
  }
}

LL Lcm(LL a, LL b) {
  LL abd = Gcd(a,b);
  LL x = a / abd, y = b / abd;
  
  return x*y*abd;
}


LL RepSqu(LL N, LL P, LL M) {
  if(P == 0) {
    return 1;
  }
  if(P%2 == 0) {
    LL t = RepSqu(N, P/2, M);
    return t*t % M;
  }
  return (N * RepSqu(N, P-1, M)) % M;
}


int main() {
  
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int A,B,x,y,ans=-1;
  cin >> A >> B;
  
  FOR(i,1,100000){
    x = i*8/100, y = i*10/100;
    if(x == A && y == B){
      ans = i;
      break;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main()
{
    string s;
	cin >> s;

	if ( s[0] == s[1] && s[1] == s[2] )
	{
		cout << "Yes" << endl;
	}
	else if ( s[1] == s[2] && s[2] == s[3] )
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

	return ( 0 );


}


Measured memory_bytes: 256
#include <bits/stdc++.h>                 // [PRIMES]               1777 ~2^10.80
using namespace std;                     //                       10333 ~2^13.33
using ll = long long;                    // seq 1 128 | factor   100333 ~2^16.61
using ld = long double;                  //   | grep -v ' .* '  1300111 ~2^20.31
using vl = vector<ll>;                   //                    10300777 ~2^23.30
using vvl = vector<vl>;                  //                   100400999 ~2^26.58
using pll = pair<ll,ll>;                 //                  1300400999 ~2^30.28
using vpll = vector<pll>;                //                 10200500333 ~2^33.25
using vb = vector<bool>;                 //                100200400777 ~2^36.54
using vs = vector<string>;               //               1200300700111 ~2^40.13
const ll oo = 0x3f3f3f3f3f3f3f3fLL;      //              10200300500777 ~2^43.21
const ld eps = 1e-9;                     //             100200300400777 ~2^46.51
#define sz(c) ll((c).size())             //            1200300400600999 ~2^50.09
#define all(c) begin(c),end(c)           //           10200300400600111 ~2^53.18
#define mp make_pair                     //          100200300400600333 ~2^56.48
#define mt make_tuple                    //         1200300400500800999 ~2^60.06
// #define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })


int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	cout << setprecision(16);;
	cerr << setprecision(16);

	ll n;
	cin >> n;
	vector<vector<vector<ld>>> dp(n+1, vector<vector<ld>>(n+1, vector<ld>(n+1, 0.0)));
	ll pa = 0, pb = 0, pc = 0;
	FOR(i,0,n) {
		ll p; cin >> p;
		switch (p) {
			case 1: pa++; break;
			case 2: pb++; break;
			case 3: pc++; break;
		}
	}

	FOR(c,0,n+1) FOR(b,0,n+1) FOR(a,0,n+1) {
		if (a+b+c > n) continue;
		if (a==0 && b==0 && c==0) continue;

		ld expected = 0.0;
		ld non_zero = a+b+c;
		if (a) {
			expected += (a/non_zero)*dp[a-1][b][c];
		}
		if (b) {
			expected += (b/non_zero)*dp[a+1][b-1][c];
		}
		if (c) {
			expected += (c/non_zero)*dp[a][b+1][c-1];
		}

		expected += ((ld) n)/(non_zero);
		dp[a][b][c] = expected;

		if (a==pa && b==pb && c==pc) {
			cout << dp[pa][pb][pc] << "\n";
			return 0;
		}
	}

	return 0;
}


Measured memory_bytes: 431360
# 貰うDP

n = int(input())


max_n = 110000
dp = [n] * max_n

# 初期化
dp[0] = 0

for i in range(1, n + 1):
    pow6, pow9 = 1, 1
    while pow6 <= i:
        dp[i] = min(dp[i], dp[i - pow6] + 1)
        pow6 *= 6
    while pow9 <= i:
        dp[i] = min(dp[i], dp[i - pow9] + 1)
        pow9 *= 9

print(dp[n])


Measured memory_bytes: 3828
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

int main() {
    int h, w;
    cin >> h >> w;
    char s[h][w];
    rep(i, h) rep(j, w) cin >> s[i][j];

    rep(i, h) {
        rep(j, w) {
            if (s[i][j] == '#') {
                cout << '#';
                continue;
            }
            int tmp = 0;
            for (int k = -1; k <= 1; ++k) {
                for (int l = -1; l <= 1; ++l) {
                    int nx = i + k, ny = j + l;
                    if (nx >= 0 && nx <= h - 1 && ny >= 0 && ny <= w - 1) {
                        if (s[nx][ny] == '#') tmp++;
                    }
                }
            }
            cout << tmp;
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double eps = 1e-6;
const int INF = 0x3f3f3f3f;
const int N = 200000 + 5;

int main(){
	string a,b;
	cin >> a >> b;
	int f = 0;
	for(int i = 0; i < a.length(); i++){
		if(a[i] != b[i]){
			f = 1;
			break;
		}
	}
	if(f == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3520
n, m, l = map(int, input().split())

matrix_A = [list(map(int, input().split())) for _ in range(n)]
matrix_B = [list(map(int, input().split())) for _ in range(m)]

matrix_B_transposed  = list(map(list, zip(*matrix_B)))

for a in matrix_A:
    c = []
    for bt in matrix_B_transposed:
        c.append(sum(x * y for (x, y) in zip(a, bt)))
    print(*c)


Measured memory_bytes: 6684
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAX_N = 1010;
const int MAX_W = 1010;
int memo[MAX_N][MAX_W];
int W, N, v[MAX_N], w[MAX_N], min_w;

int main()
{
    for(int c = 1; ~scanf("%d", &W) && W; ++c)
    {
        scanf("%d", &N);
        for(int i = 0; i < N; ++i)
            scanf("%d,%d", v+i, w+i);
        fill_n(memo[N], W+1, 0);
        for(int i = N - 1; i >= 0; --i)
            for(int j = 0; j <= W; ++j)
                if(j < w[i])
                    memo[i][j] = memo[i+1][j];
                else
                    memo[i][j] = max(memo[i+1][j], memo[i+1][j-w[i]] + v[i]);
        min_w = W;
        while(memo[0][W] == memo[0][min_w-1])
            --min_w;
        printf("Case %d:\n%d\n%d\n", c, memo[0][W], min_w);
    }
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {
    private static Scanner scan;

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

        // 表の行数rと列数c、r × c の要素を持つ表
        int r = scan.nextInt();
        int c = scan.nextInt();
        int[][] hyou = new int[r+1][c+1];

        for (int i = 0; i < r; i++) {
            for (int j = 0; j < c; j++) {
                hyou[i][j] = scan.nextInt();
            }
        }
        for (int i = 0; i < r +1; i++) {
            for (int j = 0; j < c + 1; j++) {
                if (j == c) {
                    System.out.println(hyou[i][c]);
                } else {
                    System.out.print(hyou[i][j] + " ");
                    hyou[i][c] += hyou[i][j];
                    hyou[r][j] += hyou[i][j];
                }
            }
        }
    }
}

Measured memory_bytes: 39588
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <fstream>
#include <sstream>
#include <math.h>
#include <map>
using namespace std;

int main()
{
	int A,B;
	cin >> A >> B;
	
	if(A>=13){cout << B << endl;}
	else if(A<=5){cout << "0" << endl;}
	else{cout << B/2 << endl;}

}

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

hs = list(map(int,input().split()))

hs[0] -= 1
b = True

for i in range(1,n):
  if hs[i-1]+1 <= hs[i]:
    hs[i] -= 1
  elif hs[i-1] > hs[i]:
    b = False
    break
if b:
  print("Yes")
else:
  print("No")

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

namespace aizu1
{
public class Solution
    {
        public static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] s = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), tmp=>int.Parse(tmp));
            int q = int.Parse(Console.ReadLine());
            int[] t = Array.ConvertAll<string, int>(Console.ReadLine().Split(' '), tmp => int.Parse(tmp));
            int c = 0;

            for(int i=0;i<q;i++)
            {
                int left = 0, right = n - 1;

                if (findElement(t[i], left, right, s)) c++;
                
            }

            Console.WriteLine(c);
        }

        public static bool findElement(int i, int left, int right, int[]s)
        {
            if (left == right) return false;
            if (i < s[left] || i > s[right]) return false;
            if (i == s[left] || i == s[right]) return true;
            else
            {
                int mid = (left + right) / 2;
                if (i == s[mid]) return true;
                if (i < s[mid]) return findElement(i, left, mid-1,s);
                if (i > s[mid]) return findElement(i,mid+1,right,s);
            }
            return false;
        }
    }
}

Measured memory_bytes: 18844
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int a1 = Integer.parseInt(sc.next()) - 1;
		int b1 = Integer.parseInt(sc.next()) - 1;
		int a2 = Integer.parseInt(sc.next()) - 1;
		int b2 = Integer.parseInt(sc.next()) - 1;
		int a3 = Integer.parseInt(sc.next()) - 1;
		int b3 = Integer.parseInt(sc.next()) - 1;

		int[] nums = new int[4];
		nums[a1]++;
		nums[b1]++;
		nums[a2]++;
		nums[b2]++;
		nums[a3]++;
		nums[b3]++;

		String answer = "YES";
		if (nums[0] != 1 && nums[0] != 2) {
			answer = "NO";
		}
		if (nums[1] != 1 && nums[1] != 2) {
			answer = "NO";
		}
		if (nums[2] != 1 && nums[2] != 2) {
			answer = "NO";
		}
		if (nums[3] != 1 && nums[3] != 2) {
			answer = "NO";
		}
		System.out.println(answer);
	}
}


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

vector<pair<int,double> > G[100000];
double p;
int n;
int deep=0;
double ans=0;
double ans2;

vector<int> used(100000,0);
vector<int> used1(100000,0);

void dfs(int x){

  deep++;
  for(int i=0;i<G[x].size();i++){
    if(used[G[x][i].first]==0){
      used[G[x][i].first]=1;
      ans+=pow(p,deep)*G[x][i].second;
      dfs(G[x][i].first);
    }
  }
  deep--;
}

void dfs2(int x){
  deep++;
  for(int i=0;i<G[x].size();i++){
    if(used1[G[x][i].first]==0){
      used1[G[x][i].first]=1;
      ans2+=pow(p,deep)*(G[x][i].second+ans);
      dfs2(G[x][i].first);
    }
  }
  deep--;
}

int main(){
  cin>>p>>n;
  for(int i=0;i<n-1;i++){
    int a,b;
    double c;
    cin>>a>>b>>c;
    a--;
    b--;
    G[a].push_back(make_pair(b,c));
    G[b].push_back(make_pair(a,c));
  }
  used[0]=1;
  used1[0]=1;
  dfs(0);
  ans2=ans;
  deep=0;
  dfs2(0);

  cout<< fixed << setprecision(10) <<ans2<<endl;
}



Measured memory_bytes: 15592
N, C, K = map(int, input().split())
T = sorted([int(input()) for _ in range(N)])
ans = 0
i = 0
while i < N:
    p = 0
    lm = T[i] + K
    while i < N and p < C and lm >= T[i]:
        p += 1
        i += 1
    ans += 1
print(ans)


Measured memory_bytes: 8280
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007

int main(){
    int n;cin>>n;
    
    map<string,int> S;

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

    int maxi=0;
    for(auto i=S.begin();i!=S.end();i++){
        maxi=max(maxi,i->second);
    }

    for(auto i=S.begin();i!=S.end();i++){
        if(maxi==i->second){
            cout<<i->first<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 25216
#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
using namespace std;
int a;
string s;

int main() {
    scanf("%d", &a);
    cin >> s;
    if(a >= 3200)
        cout << s << endl;
    else
        puts("red");
    return 0;
}

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

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;}

const long long INF = 1LL << 60;
const long long mod = 1000000007;


int main(void){
    int s,w;cin >> s >> w;
    if(s<=w) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
	bool res = false;

	string str;
	cin >> str;

	bool existA = false;
	bool existB = false;

	for (const char c : str)
	{
		if (c == 'A')
			existA = true;
		else if (c == 'B')
			existB = true;

		if (existA && existB)
		{
			res = true;
			break;
		}
	}

	if (res)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

Measured memory_bytes: 768
n = int(input())
a=list(map(int,input().split()))
dic = {}
dic2 = {}
for i in range(n + 1):
    dic[a[i]] = 0
    dic2[a[i]] = []
f = 0
s = 0
for i in range(n + 1):
    dic[a[i]] += 1
    dic2[a[i]].append(i)
    if dic[a[i]] == 2:
        f = dic2[a[i]][0]
        s = i
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = n + 1
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル
 
for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

for k in range(1,n+2):
    if k==1:
        print(n)
    elif k>f+n-s+1:
        print(cmb(n+1,k,mod))
    else:
        if cmb(n+1,k,mod)-cmb(f+n-s,k-1,mod)>=0:
            print(cmb(n+1,k,mod)-cmb(f+n-s,k-1,mod))
        else:
            print(cmb(n+1,k,mod)-cmb(f+n-s,k-1,mod)+mod)

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

int main(){
  long n,k;
  cin >> n >> k;
  long a[n];
  for(long i = 0;i < n;i++){
    cin >> a[i];
  }
  vector<long> tennum(n),tennum2(n);
  for(long i = 0;i < n;i++){
    for(long j = i+1;j < n;j++){
      if(a[i] > a[j]){
        tennum.at(i)++;
      }
    }
  }
  for(long i = 0;i < n;i++){
    for(long j = 0;j < n;j++){
      if(i == j) continue;
      if(a[i] > a[j]){
        tennum2.at(i)++;
      }
    }
  }
  long ans = 0,inf = 1000000007;
  for(long i = 0;i < n;i++){
    long c = (k*tennum2.at(i)+tennum.at(i))%inf;
    long d = (k*(k+1)/2)%inf;
    ans += (inf + c*k - (tennum2.at(i)*d))%inf;
    ans += inf;
    ans %= inf; 
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<vector>
#include<utility>
#include<complex>
#include<algorithm>

using namespace std;

const double eps=1e-9;

template<class T> bool eq(T a,T b){
	return abs(a-b)<eps;
}

template<class T> int sgn(T r){
	return eq(r,0.0)?0:(r>0?1:-1);
}

typedef complex<double> Point;
typedef complex<double> Vector;
typedef pair<Point,Point> Line;

double crP(Vector a,Vector b){
	return (conj(a)*b).imag();
}

bool isPara(Line l1,Line l2){
	Vector a=l1.second-l1.first;
	Vector b=l2.second-l2.first;
	return eq(crP(a,b),0.0);
}

Point interLL(Line l1,Line l2){
	if(isPara(l1,l2)) return Point(NAN,NAN);
	Point a1=l1.first,a2=l1.second;
	Point b1=l2.first,b2=l2.second;
	double num=crP(b1-a1,a2-a1);
	double den=crP(a2-a1,b2-b1);
	return b1+(b2-b1)*(num/den);
}

int ccw2(Point p1,Point p2,Point p3){
	Vector b=p2-p1;
	Vector c=p3-p1;
	return sgn(crP(b,c));
	//1:counter
	//-1:clock
	//0:on
}

Vector getPerp(Vector v){
	double a=v.real(),b=v.imag();
	return Vector(b,-a)/abs(v);
}

void print(Point p){
	if(isnan(p.real())) printf("NAN point\n");
	else printf("(%f,%f)\n",p.real(),p.imag());
}

int W,H,N,R;

Line ls[110][2];

bool check(Point p){
	for(int i=0;i<N+2;i++){
		int s=1;
		for(int j=0;j<2;j++){
			Line l=ls[i][j];
			s*=ccw2(l.first,l.second,p);
		}
		if(i<N&&s==-1) return false;
		if(i>=N&&s==1) return false;
	}
	return true;
}

int main(){
/*	Point p1=Point(0,-1);
	Point p2=Point(0,1);
	Point p3=Point(1,0);
	Point p4=Point(-1,0);
	Line l1=Line(p1,p2);
	Line l2=Line(p3,p4);
	print(interLL(l1,l2));*/
	while(true){
		scanf("%d%d%d%d",&W,&H,&N,&R);
		if(W==0&&H==0) break;
		for(int i=0;i<N;i++){
			int x1,y1,x2,y2,t;
			scanf("%d%d%d%d%d",&x1,&y1,&x2,&y2,&t);
			Point p1=Point(x1,y1),p2=Point(x2,y2);
			Vector v=getPerp(p2-p1);
			t+=R;
			ls[i][0]=Line(p1+v*(double)t,p2+v*(double)t);
			ls[i][1]=Line(p1-v*(double)t,p2-v*(double)t);
		}
		ls[N][0]=Line(Point(R,0),Point(R,H));
		ls[N][1]=Line(Point(W-R,0),Point(W-R,H));
		ls[N+1][0]=Line(Point(0,R),Point(W,R));
		ls[N+1][1]=Line(Point(0,H-R),Point(W,H-R));
		bool ans=false;
		for(int i=0;i<N+2;i++) for(int j=i+1;j<N+2;j++){
			for(int k=0;k<2;k++) for(int m=0;m<2;m++){
				Point p=interLL(ls[i][k],ls[j][m]);
		//		printf("%d %d %d %d::",i,k,j,m);
		//		print(p);
				if(isnan(p.real())) continue;
				if(check(p)){
					ans=true;
					goto output;
				}
			}
		}
		output:;
		if(ans) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 1036
import java.util.Scanner;
import java.util.Arrays;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long sum = 0;
    char[] n = sc.nextLine().toCharArray();
    for (int cnt = 0; cnt < n.length; cnt++) {
      sum += Character.getNumericValue(n[cnt]);
    }
    String ans = (sum % 9 == 0) ? "Yes" : "No";
    System.out.println(ans);
    sc.close();
  }
}

Measured memory_bytes: 41312
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
using namespace std;
typedef long long ll;
int main(){
  int n = 0;
  cin >> n;
  vector<int> num(n);
  for(int i = 0;i <= n - 1;i++)cin >> num[i];
  int res = 0;
  for(int i = 1;i <= n - 2;i++){
    if(num[i] <= max(num[i - 1],num[i + 1]) && num[i] >= min(num[i - 1],num[i + 1]))res++;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
using namespace std;
namespace adaptor = boost::adaptors;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
typedef long long ll;

void Main()
{
	int A, B, C;
  	cin >> A >> B >> C;
  	if((A*B*C == 175) && (A*B+B*C+C*A == 95) && (A+B+C==17)){
		cout << "YES" << endl;
      	return;
	}
  else{
		cout << "NO" << endl;
	return;
  }
  
}

int main()
{
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>

int n, m, field[92][92];
int field_copy[92][92], ans = -1;

int dp(int finish_x, int finish_y) {
	int res = 0;
	if (field[finish_x][finish_y] == 0) { return 0; }
	field[finish_x][finish_y] = 0;
	if (field[finish_x][finish_y - 1] == 1) { res = std::max(res, dp(finish_x, finish_y - 1)); }
	if (field[finish_x][finish_y + 1] == 1) { res = std::max(res, dp(finish_x, finish_y + 1)); }
	if (field[finish_x - 1][finish_y] == 1) { res = std::max(res, dp(finish_x - 1, finish_y)); }
	if (field[finish_x + 1][finish_y] == 1) { res = std::max(res, dp(finish_x + 1, finish_y)); }
	field[finish_x][finish_y] = 1;
	return res + 1;
}

int main(void) {
	while (true) {
		scanf("%d%d", &n, &m);
		if (n == 0 && m == 0) { break; }
		for (int i = 0; i < n; ++i) { for (int j = 0; j < m; ++j) { scanf("%d", &field[i + 1][j + 1]); } }

		ans = 0;
		for (int x = 0; x < n; ++x) { for (int y = 0; y < m; ++y) { field_copy[x + 1][y + 1] = field[x + 1][y + 1]; } }
		for (int i = 0; i < n; ++i) {
			for (int j = 0; j < m; ++j) {
				ans = std::max(ans, dp(i + 1, j + 1));
				for (int x = 0; x < n; ++x) { for (int y = 0; y < m; ++y) { field[x + 1][y + 1] = field_copy[x + 1][y + 1]; } }
			}
		}

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

Measured memory_bytes: 2632
#include <iostream>

using namespace std;
int main()
{
long long int N,K,a;
cin>>N>>K;
if(K%2==1){cout<<(N/K)*(N/K)*(N/K);}
else if(K%2==0)
{
a=(N+K/2)/K;
cout<<(((N/K)*(N/K)*(N/K))+(a*a*a));
}
    return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
A = list(map(int, input().split()))

B = [0]*(N+1)

b = 0
for i, a in enumerate(A):
    b += a - 1
    b %= K
    B[i+1] = b

Q = {}
X = 0

for i, b in enumerate(B):
    if i>=K:
        Q[B[i-K]] -= 1
 
    if b in Q:
        X += Q[b]
        Q[b] += 1
    else:
        Q[b] = 1

print(X)


Measured memory_bytes: 41224
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = 1e9+7;

int main()
{   
    

    ll n , m;
    cin >> n >> m;

    vector<ll>adj[n+1];
    for(int i=0;i<m;i++){
        ll a , b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    ll vis[n+1]={false};
    ll parent[n+1];
    memset(parent , -1 , sizeof(parent));

    queue<ll>q;
    q.push(1);
    vis[1]=true;

    while(!q.empty()) {
        ll src=q.front();
        q.pop();
        //vis[src]=true;
        //cout << src << endl;
        //cout << parent[src] << " ";
        for(auto it : adj[src]) {
            if(!vis[it]) {
                parent[it]=src;
                vis[it]=true;
                q.push(it);
            }
        }
    }

    for(int i=2;i<=n;i++){
        if(parent[i]==-1) {
            cout << "No\n";
            return 0;
        }
    }

    cout << "Yes\n";

    for(int i=2;i<=n;i++){
        cout << parent[i] << "\n";
    }
    
    return 0;
}

Measured memory_bytes: 13768
# -*- coding:utf-8 -*-
"""解説
dp[j][k][s] := x1,...,xjから k枚選んで xiの合計をsにするような選び方の総数

[@lilium氏]
https://atcoder.jp/contests/abc044/submissions/5887235
"""

def solve():
    N, A = list(map(int, input().split()))
    X = list(map(int, input().split()))

    max_x = max(X)
    dp = [[[0 for _ in range(4000+1)] for __ in range(N+1)] for ___ in range(N+1)]

    dp[0][0][0] = 1

    # dp[i][j][k] := i枚のうちj枚を選んで、和がkになる組み合わせ
    for i in range(N):
        for j in range(N):
            for k in range(4000+1):
                if dp[i][j][k] != 0:
                    dp[i+1][j][k] += dp[i][j][k]  # i枚目を選ばなかった
                    dp[i+1][j+1][k+X[i]] += dp[i][j][k]  # i枚目を選んだ

    ans = 0
    for j in range(1, N+1):
        ans += dp[N][j][j*A]
    print(ans)

if __name__ == "__main__":
    solve()


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

const int MAX_N = 310;
ll minD[MAX_N][MAX_N];
ll ans[MAX_N][MAX_N];

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

  int N, M;
  ll L;
  cin >> N >> M >> L;

  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      minD[i][j] = INF;
    }
    minD[i][i] = 0;
  }

  int a, b, c;
  for(int i = 0; i < M; i++){
    cin >> a >> b >> c;
    a--;
    b--;
    minD[a][b] = c;
    minD[b][a] = c;
  }

  // WF
  for(int k = 0; k < N; k++){
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        chmin(minD[i][j], minD[i][k] + minD[k][j]);
      }
    }
  }

  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      if(minD[i][j] <= L){
        ans[i][j] = 1;
      }else{
        ans[i][j] = INF;
      }
    }
    ans[i][i] = 0;
  }

  for(int k = 0; k < N; k++){
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        chmin(ans[i][j], ans[i][k] + ans[k][j]);
      }
    }
  }

  int Q;
  cin >> Q;
  vector<pair<int, int>> st(Q);
  int s, t;
  for(int i = 0; i < Q; i++){
    cin >> s >> t;
    s--;
    t--;
    st[i] = make_pair(s, t);
  }

  for(int i = 0; i < Q; i++){
    s = st[i].first;
    t = st[i].second;
    if(ans[s][t] >= INF){
      cout << -1 << endl;
    }else{
      cout << ans[s][t] - 1 << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

ll fastPow(ll x, ll n)
{
    if (n == 0)
        return 1;
    if (n % 2 == 0)
        return fastPow(x * x % MOD, n / 2);
    else
        return x * fastPow(x, n - 1) % MOD;
}

ll modDiv(ll a, ll b)
{
    return a * fastPow(b, MOD - 2) % MOD;
}

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

    int n;
    ll all, res, p[112345];
    cin >> n;

    all = 1;
    REP(i, n)
    {
        all *= (i + 1);
        all %= MOD;
    }

    p[0] = 0;
    p[1] = 1;
    REP(i, n + 10)
    {
        p[i + 2] = p[i + 1] + modDiv(1, i + 2);
        p[i + 2] %= MOD;
    }

    res = 0;

    REP(i, n)
    {
        ll a;
        cin >> a;

        res += (all * a) % MOD * (p[n - (i + 1) + 1] + p[(i + 1)] - 1);
        res %= MOD;
    }

    //res *= all;
    res %= MOD;

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1024
# A - 高橋君とホテルイージー

# 1  軒のホテルがあります。 このホテルの宿泊費は、次のようになっています。

# 最初の K 泊までは、1 泊あたり X 円
# K+1 泊目以降は、1 泊あたり Y 円

# このホテルに N 泊連続で宿泊する と 宿泊費は合計で何円になるか

# N 宿泊数　を標準入力から得る
N = int(input())
# K 最初の拍数　を標準入力から得る
K = int(input())
# X K日間の料金  を標準入力から得る
X = int(input())
# Y K+1~Nまでの料金 を標準入力から得る
Y = int(input())
# print(N, K, X, Y)

# K 泊までの料金を計算
# K * X
first_charge = K * X
# print(first_charge)

# K + 1 ~ N までの料金を計算
# (N - K) * Y
second_charge = (N - K) * Y
# print(second_charge)

# 合算
# K >= N の場合は、N * X 円
if K >= N:
    answer = N * X
else:
    answer = first_charge + second_charge

# 結果を出力
print(answer)


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

int main(){ 
    int a,b,k;
    cin >> a >> b >> k;
    if(a < b)swap(a,b);
    int count=0;
    for(int i=b; ;i--){
        if(a % i==0 && b % i==0)count++;
        if(count == k){
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import fractions
a, b, c, d = map(int, input().split())
l = c * d // fractions.gcd(c, d)
n = b - a + 1
print(n - (((b//c) - (a//c) + (a%c == 0)) + ((b//d) - (a//d) + (a%d == 0)) - ((b//l) - (a//l) + (a%l == 0))))

Measured memory_bytes: 5048
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = 1e9 + 7;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if(stoi(s.substr(0, 4)) >= 2019 && stoi(s.substr(5, 2)) > 4) cout << "TBD" << endl;
    else cout << "Heisei" << endl;
    return 0;
}



Measured memory_bytes: 256
n,m = (int(i) for i in input().split())
if n>m:
    n,m = m,n
if n == 1:
    if m == 1:
        print(1)
    elif m>1:
        print(m-2)
#elif n ==2:
#    print(0)
else:
    #print(n*m-(2*m+(n-2)*2))
    print((n-2)*(m-2))


Measured memory_bytes: 2940
N,C,K=list(map(int,input().split()))
import sys
l=[r.rstrip() for r in sys.stdin.readlines()]
l=list(map(int,l))
l.sort()
ans=0
now=0
for i in range(N):
   X=l[now]
   for j in range(C):
      if X <= l[now] <= X+K:
         now+=1
         if now==N:
            break
      else:
         break
   ans+=1
   if now==N:
      break
print(ans)

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

using namespace std;

int main(void) {
    int m;
    int n;
    while (1) {
        cin >> m >> n;
        if (m == 0 && n == 0) {
            break;
        }

        vector<bool> v(7368792, 0);
        int base = m;
        int base_now;
        int count = 0;
        while (1) {
            base_now = 0;
            for (int i = 1; i * base < v.size(); i++) {
                base_now += base;
                v[base_now] = 1;
            }
            count++;

            if (count == n) {
                break; 
            }

            while (1) {
                if (v[base] == 0) {
                    break;
                } else {
                    base++;
                }
            }
        }


        int check = m;
        while (1) {
            if (v[check] == 0) {
                cout << check << endl;
                break;
            }
            check++;
        }
    }
    return 0;
}

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


int main() {
    int n,x,ings=0,mini=1500;
    cin>>n>>x;
    int ing[n];
    for (int i = 0; i < n; ++i) {
        cin>>ing[i];
        ings+=ing[i];
        mini=min(mini,ing[i]);
    }
    cout<<(x-ings)/mini+n<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
int n;
int bit[100010];
void add(int v, int x) {

	while (v <= n)
	{
		bit[v] += x;
		v += v & -v;
	}
}

ll sum(int v) {
	ll r = 0;
	while (v > 0)
	{
		r += bit[v];
		v -= v & -v;
	}
	return r;
}
void put(string v) {
	cout << "a" << v<< "b" << endl;
}
void solv() {

	int a, b;
	cin >> a >> b;

	cout << fixed << (a / b) << " " << (a % b) << " " << ((double)a / (double)b) << endl;
}


int main() {
	//	COMinit();
	solv();

	return 0;
}



Measured memory_bytes: 3284
n, q = [parse(Int, x) for x in split(chomp(readline()))]
str = readline() |> chomp

ac = zeros(Int, n-1)
count = 0
for i = 1:n-1
    if str[i] == 'A' && str[i+1] == 'C'
        count += 1
    end
    ac[i] = count
end

ac = vcat(0, ac)

val = zeros(Int, q)

lines = readlines()

for (i, line) in enumerate(lines)
    l, r = [parse(Int, x) for x in split(line)]
    val[i] = ac[r] - ac[l]
end

for v in val
    println(v)
end

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

#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define SPEED ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sz size()
#define all(x) x.begin(),x.end()
#define OO 1e18
#define iOO INT_MAX
#define Mdp memset(dp,-1,sizeof dp)
#define R return
#define Test int TT;cin>>TT;for(int T=1;T<=TT;T++)
using namespace std;

ll Dp[1000100];
int main()
{

    SPEED;

    int n,a[1000010];
    cin >> n;
    for(int i=0;i<n;i++)
    {
        cin >> a[i];
        Dp[i] = OO;
    }
    Dp[0] = 0;
    for(int i=0;i<n;i++)
    {
        if(i+1 < n)
            Dp[i+1] = min(Dp[i+1],Dp[i]+abs(a[i]-a[i+1]));
        if(i+2 < n)
            Dp[i+2] = min(Dp[i+2],Dp[i]+abs(a[i]-a[i+2]));
    }

    cout << Dp[n-1] << endl;
    R 0;
}


Measured memory_bytes: 3456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	static int count = 0;

	static final int LIMIT = 123456 * 2 + 1;
	static int array[] = new int[LIMIT];

	public static void main(String args[]) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		for (int i = 1; i < LIMIT; i++) {
			if (isPrime(i)) {
				count++;
			}
			array[i] = count;
		}

		while (true) {
			String str = br.readLine();
			int n = Integer.parseInt(str);

			if (n == 0)
				break;

			int ans = array[n * 2] - array[n];
			System.out.println(ans);
		}
	}

	static boolean isPrime(int n) {

		for (int i = 2; i * i <= n; i++) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}


Measured memory_bytes: 26408
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
x,y = gets.split.map(&:to_i)
if x == 2 || y == 2 then
  puts "No"
  exit
end
if a.include?(x) then
  if a.include?(y) then
    puts "Yes"
  else
    puts "No"
  end
else
  if b.include?(y)
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
constexpr double eps=1e-8;
const double pi=acos(-1);
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int Random(int mi,int ma){
    random_device rnd;
    mt19937 mt(rnd());//32bit
    //[mi,ma]
    uniform_int_distribution<int>engine(mi,ma);
    return engine(mt);
}
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
vector<int>kaijo,invkaijo;
void init_fact(int n){
    kaijo.resize(n+1);
    invkaijo.resize(n+1);
    kaijo[0]=1;
    for(int i=1;i<=n;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
    rep(i,n+1)invkaijo[i]=modpow(kaijo[i],mod-2);
}
int comb(int a,int b){
    if(a<b)return 0;
    if(a<0||b<0)return 0;
    return kaijo[a]*invkaijo[a-b]%mod*invkaijo[b]%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
struct UnionFind{
    vector<int>par,siz;
    UnionFind(int x){
        par.resize(x);
        siz.resize(x);
        rep(i,x){
            par[i]=i;
            siz[i]=1;
        }
    }
    int find(int x){
        if(par[x]==x)return x;
        return par[x]=find(par[x]);
    }
    void unite(int x,int y){
        x=find(x),y=find(y);
        if(x==y)return;
        if(siz[x]<siz[y])swap(x,y);
        par[y]=x;
        siz[x]+=siz[y];
    }
    bool same(int x,int y){
        return find(x)==find(y);
    }
    int size(int x){
        return siz[find(x)];
    }
};
int n,m;
signed main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--,b--;
        if(!uf.same(a,b)){
            uf.unite(a,b);
        }
    }
    int ans=0;
    rep(i,n)chmax(ans,uf.size(i));
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6368
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
int main(){
cin.tie(0);
ios::sync_with_stdio(false);

	string s;
	cin>>s;
	int ans[26]={0};
	REP(i,s.size())
		ans[s[i]-97]++;
	REP(i,26){
		if(ans[i]%2==1){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	
	return 0;
}

Measured memory_bytes: 256
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
int main()
{
	boost
	ll n;
	cin>>n;
	double p[n];
	for(ll i=0;i<n;i++)
	{
		cin>>p[i];
	}
	double dp[n+1][n+1]={0};// head,tail
	dp[1][0]=p[0];
	dp[0][1]=1-p[0];
	dp[0][0]=0;
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<=n;j++)
		{
			if(i+j>n) continue;
			if((i==0&&j==1)||(i==1&&j==0)||(i==0&&j==0))
			{
				continue;
			}
			if(i-1>=0&&j-1>=0)dp[i][j]=dp[i-1][j]*p[i+j-1]+dp[i][j-1]*(1-p[j+i-1]);
			else if(i-1>=0) dp[i][j]=dp[i-1][j]*p[i+j-1];
			else if(j-1>=0) dp[i][j]=dp[i][j-1]*(1-p[j+i-1]);
		}
	}
	double tot=0.0;
	for(ll i=0;i<=n;i++)
	{
		for(ll j=0;j<i;j++)
		{
			if(i+j==n)tot+=dp[i][j];
		}
	}
	printf("%.13lf",tot);
	return 0;
}

Measured memory_bytes: 70656
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.util.*

fun main(args: Array<String>) {
    val sc = FastScanner(System.`in`)

    val a = sc.next().map { it.toString().toInt() }

    val n = 3
    val s = 1 shl n
    for (x in 0 until s) {
        var res = a[0]
        var ans = a[0].toString()
        for (k in 0 until n) {
            if (x shr k and 1 == 1) {
                res += a[k + 1]
                ans += "+${a[k + 1]}"
            }
            else {
                res -= a[k + 1]
                ans += "-${a[k + 1]}"
            }
        }
        if (res == 7) {
            ans += "=7"
            println(ans)
            return
        }
    }


}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 31140
#include<iostream>
using namespace std;
const int maxn=200010;
int a1[maxn],a2[maxn];
int n,m;
int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		if(x==1) a1[y]=1;
		if(y==n) a2[x]=1;
	}
	for(int i=2;i<n;i++){
		if(a1[i]&&a2[i]){
			cout<<"POSSIBLE"<<endl;
			return 0;
		}
	}
	cout<<"IMPOSSIBLE"<<endl;
	return 0;
}

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

#define int long long

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

// ------------------------------------------------------------------------------------------

string K;
int D;
int dp[11111][2][111]; // dp[i桁目][未満フラグ][mod Dした値] = 総数

signed main() {
  cin >> K >> D;

  dp[0][0][0] = 1; // 初期化
  // DP
  for (int digit = 0; digit < K.size(); digit++) {
    for (int smaller : {0, 1}) {
      for (int modD = 0; modD < D; modD++) {
        int lim = (smaller ? 9 : K[digit] - '0');
        for (int num = 0; num <= lim; num++) {
          int nSmaller = smaller || (num < lim);
          if (smaller == 1 && nSmaller == 0) continue;
          Add(dp[digit+1][nSmaller][(modD + num) % D], dp[digit][smaller][modD]);
        }
      }
    }
  }

  int ans = 0;
  for (int smaller : {0, 1}) {
    Add(ans, dp[K.size()][smaller][0]);
  }

  // int ans = rec(0, 0, 0); // メモ化再帰に投げる
  Add(ans, -1LL); // 0になる場合の数を引く
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 18688
#include <iostream>
#include <math.h>

using namespace std;

int main()
{
	int a,b;
	cin>>a>>b;
	int x=b;
	while(x>0)
	{
		a*=10;
		x/=10;
	}
	a+=b;
	if(sqrt(a)==int(sqrt(a))) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define rep1(i,n) for (int (i) = 1; (i) <= (n); i++)
typedef long long int llint;

using namespace std;

const long long int inf = 1 << 29 ;

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

vector<pair<llint, int>> factoring(llint n) {
	int d = 0;
	vector<pair<llint, int>> fact;
	while ((n & 1) == 0) {
		n /= 2;
		d++;
	}
	if (d > 0) fact.push_back({ 2,d });

	for (int i = 3; i <= floor(sqrt(n)); i += 2) {
		d = 0;
		while (n % i == 0) {
			n /= i;
			d++;
		}

		if (d > 0) fact.push_back({ i,d });
	}

	if (n > 1) fact.push_back({n,1});

	return fact;
}


int main(void) {
	llint a,b;
	cin >> a >> b;
  llint n = gcd(a,b);
	//cout << n << endl;
	//for (pair<llint,int> v : factoring(n)) cout << "(" << v.first << "," << v.second << ") "; cout << endl;
	cout << factoring(n).size() + 1 << endl;
}

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

int main() {
  int X, A;
  cin >> X >> A;
  if (X<A) {
    cout << 0 << endl;
  }
  else {
    cout << 10 << endl;
  }
}

Measured memory_bytes: 3640