akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n = sc.nextInt(), a[] = sc.nxtArr(n);
		long sum = 0;
		for (int x : a)
			sum += x;
		long ans = 0;
		int MOD = (int) 1e9 + 7;
		for (int x : a) {
			sum -= x;
			ans += x * 1L * (sum % MOD) % MOD;
			ans %= MOD;
		}
		System.out.println(ans);

		out.close();

	}

	static class DSU {
		int[] p, r;

		DSU(int n) {
			p = new int[n];
			r = new int[n];
			for (int i = 0; i < n; i++)
				p[i] = i;
		}

		boolean union(int x, int y) {
			x = findSet(x);
			y = findSet(y);
			if (x == y)
				return false;
			if (r[x] > r[y]) {
				p[y] = x;
			} else {
				p[x] = y;
				if (r[x] == r[y])
					r[y]++;
			}
			return true;

		}

		int findSet(int x) {
			if (p[x] == x)
				return x;
			else
				return p[x] = findSet(p[x]);
		}
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

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

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

		boolean ready() throws IOException {
			return br.ready() || st.hasMoreTokens();
		}

		int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 55224
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <iomanip>
#include <bitset>
#include <stack>
#include <memory.h>
#include <list>
#include <numeric>
#include <functional>
#include <complex>
#include <unordered_set>
#include <cctype>
#include <cassert>


using namespace std;

typedef long long ll;
typedef long double ld;

const int nax = 1e5 + 5;

int dp[nax];

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("angle2.in", "r", stdin);
	//freopen("angle2.out", "w", stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	int n, k;
	cin >> n >> k;

	vector<int>a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = 1; i <= k; i++) {
		for (int j = 0; j < n; j++) {
			if (i - a[j] >= 0 && !dp[i - a[j]]) {
				dp[i] = 1;
			}
		}
	}

	dp[k] ? puts("First") : puts("Second");
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,m,k;
   cin>>n>>m>>k;
   map<pii,int>mp;
   vector<int>rows(n+1);
   vector<int>columns(m+1);
   int ans=0;
   for(int i=0;i<k;i++)
   {
       int u,v;
       cin>>u>>v;
       mp[{u,v}]++;
       rows[u]++;
       columns[v]++;

   }
   int idx=-1;
   int mx=0;
   for(int i=1;i<=n;i++)
   {
       if(rows[i]>mx)
       {
           idx=i;
           mx=rows[i];
       }
   }
   for(int j=1;j<=m;j++)
   {
       int c=columns[j];
       if(mp[{idx,j}])
        {
            int val=mx+c-1;
            ans=max(ans,val);
        }
      else
            ans=max(ans,mx+c);
   }
   idx=-1;
   mx=0;
   for(int j=1;j<=m;j++)
   {
       if(columns[j]>mx)
       {
           idx=j;
           mx=columns[j];
       }
   }
   for(int i=1;i<=n;i++)
   {
       if(mp[{i,idx}])
        {
            int val=mx+rows[i]-1;
            ans=max(ans,val);
        }
       else
       ans=max(ans,mx+rows[i]);
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 64124
n = STDIN.gets.chomp.to_i
a = []
i = 1
STDIN.each{|x|
  data = x.chomp.split(" ")
  a.push([data[0], data[1].to_i, i])
  i += 1
  }

a.sort!{|x, y| y[1] <=> x[1]}
a.sort!{|x, y| x[0] <=> y[0]}

a.each{|x|
  puts x[2]
  }

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

public class Main {
	public static void main(String[] args) {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		
		int n = sc.nextInt();
		int[] array = new int[n];
		for(int i = 0; i < n; i++)
			array[i] = sc.nextInt();
		
		long sum = 0;
		for(int i = 0; i < n; i++) {
			for(int j = i + 1; j < n; j++) {
				sum += array[i] * array[j];
			}
		}
		
		System.out.println(sum);
	}
}


Measured memory_bytes: 24276
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[][] = new int[n][3] ;
		int sum[] = new int[n];
		int cnt = 0;
		//-------------??´??°??\???------------------
		for(int i = 0; i < n; i++){
			for(int k = 0; k < 3; k++){
				a[i][k] = sc.nextInt();
			}
		}
		//----------------?????????---------------
		for(int i = 0; i < 3; i++){
			for(int k = 0; k < n; k++){
				for(int j = 0; j < n; j++){
					if(a[k][i] == a[j][i]){
						cnt++;
					}
				}
				if(cnt == 1){
					sum[k] += a[k][i];
				}
				cnt = 0;
			}
		}
		//---------------??????--------------------
		for(int i = 0; i < n; i++){
			System.out.println(sum[i]);
		}
	}

}

Measured memory_bytes: 28636
n, m = map(int, input().split())
if abs(n - m) >= 2:
    print(0)
else:
    dog = 1
    for i in range(1, n+1):
        dog = (dog * i) % (10 ** 9 + 7)
    monkey = 1
    for j in range(1, m+1):
        monkey = (monkey * j) % (10 ** 9 + 7)
    ans = dog * monkey
    if n == m:
        ans *= 2
    print(ans % (10 ** 9 + 7))


Measured memory_bytes: 3064
n, m = map(int, input().split())
s, c = [], []
for i in range(m):
    a, b = map(int, input().split())
    s.append(a), c.append(b)


for i in range(0, 10 ** n):
    loop = True
    string = str(i)
    if len(string) != n:
        continue
    for j in range(m):
        if string[s[j] - 1] != str(c[j]):
            loop = False
    if loop:
        print(string)
        exit()

print('-1')

Measured memory_bytes: 3064
import java.util.*;

public class Main{ 

   public static void main(String args[]) {
	 
    Scanner s=new Scanner(System.in);
    
    	int n=s.nextInt();
    	
    	long arr[][]=new long[n+1][4];
    	for(int i=1;i<=n;i++) {
    		for(int j=1;j<=3;j++) {
    		arr[i][j]=s.nextLong();
    		}
    	}
    	long dp[][]=new long[n+1][4];
    	
    	
    	for(int i=1;i<=n;i++) {
    		
    			dp[i][1]=arr[i][1] + Math.max(dp[i-1][2], dp[i-1][3]);
    		    dp[i][2]=arr[i][2] + Math.max(dp[i-1][1], dp[i-1][3]);
    			dp[i][3]=arr[i][3] + Math.max(dp[i-1][2], dp[i-1][1]);
    		
    	 }
    	System.out.println(Math.max(dp[n][1], Math.max(dp[n][2], dp[n][3])));
    	
    	
    }

}

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

int main(){
  ll x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  ll ans = min(k, x / d);
  k -= ans;
  x -= ans * d;
  if(k % 2 == 0) {
    cout << x << endl;
  }else{
    cout << d - x << endl;
  }
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
using namespace std;
#define IOS {ios :: sync_with_stdio(false); cin.tie(0);cout.tie(0); }
#define F first
#define S second
#define pb push_back
typedef long double ld;
#define deci(n) cout << fixed << setprecision(n);
typedef long long ll;

#define mem0(x)  memset(x,0,sizeof(x));
#define mem1(x)  memset(x,1,sizeof(x));
#define memm1(x) memset(x,-1,sizeof(x));
#define all(a) a.begin(), a.end()
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)
#define fori(n)  for (ll i = 0; i < n; i++)
#define fori2(n) for(ll i=1;i<=n;i++)
#define forj(n)  for (ll j = 0; j < n; j++)
#define forj2(n) for(ll j=1;j<=n;j++)
#define fork(n)  for (ll k = 0; k < n; k++)
#define fork2(n) for(ll k=1;k<=n;k++)
#define vll vector <ll>
#define mll map <ll, ll>
#define vpll vector <pll>
const ll md = 1e9 + 7;

#define BSET(a, p) ((a) | (1ll << (p)))
#define BCHK(a, p) ((a) & (1ll << (p)))
#define BXOR(a, p) ((a) ^ (1ll << (p)));
#define BREM(a, p) (BCHK(a, p)?(BXOR(a, p)):(a))
#define BSHO(a, N) (bitset<N>(a))
// const ll N = 100005;
// ll fac[N] = {1};
// #define calfac for(ll i=1  ;i<N;i++) fac[i] = (fac[i-1]*i)%md;
// ll C[N+1][M+1]; 
// void  ncr(){
//     ll n = N,k = M; 
//     for (ll i = 0; i <= n; i++) { 
//         for (ll j = 0; j <= min(i, k); j++) { 
//             if (j == 0 || j == i)  C[i][j] = 1; 
//             else C[i][j] = C[i - 1][j - 1] +  C[i - 1][j]; 
//         } 
//     } 
// } 


#define RBTTYPE int
#define ordered_set tree<RBTTYPE, null_type, less<RBTTYPE>, rb_tree_tag,tree_order_statistics_node_update> 
// Ordered set docs:
// order_of_key (k) : Number of items strictly smaller than k .
// find_by_order(k) : K-th element in a set (counting from zero).
ll modexp(ll x, ll ex) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
ll modInv(ll a)
{
    return pow(a,md-2);
}
 
// ll nCr(ll n,ll r)
// {
//     return (fac[n]*modInv((fac[r]*fac[n-r])%md))%md;
// }

 
ll po(ll x,ll n){
    if(n==0) return 1;
    if(n%2==1) return (x*po(x,n-1));
    else {
        ll k=po(x,n/2);
        return (k*k);
    }
}
 
ll gcd(ll x, ll y) {
    if (x < y) return gcd(y, x);
    if (y == 0) return x;
    return gcd(y, x % y);
}
const ll N = 404; 
const ll mx = 1e18L+2;
ll a[N],sum[N],dp[N][N];


int32_t main(){
    IOS;
    ll i,j,k,n,m,l;
    cin >> n;
    fori2(n) {
        cin >> a[i];
        sum[i] = sum[i-1] + a[i];
    }
    for(l = 1 ; l <= n ; l++){
        for(i = 1 ; i <= n - l + 1 ; i++){
            j = i + l - 1;
            if(l==1){
                dp[i][j] = 0;
                continue;
            }
            dp[i][j] = mx;
            for(k = i ; k <= j - 1 ; k++){
                dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j]+sum[j]-sum[i-1]);
            }
        }
    }
    cout << dp[1][n] <<"\n";

} 

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

using namespace std;

const int N = 4e5 + 5, LG = 61;
const long long inf = 1LL << LG;

int a[N];
int to[N];
long long go[LG][N];
int last[N];

int main() {
  int n;
  long long k;
  scanf("%d %lld", &n, &k);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a+i);
  }
  for (int i = 0; i < n; ++i) {
    a[n+i] = a[i];
  }
  fill(last, last+N, 2 * n);
  for (int i = 2 * n-1; i >= n; --i) {
    last[a[i]] = i;
  }
  for (int i = n-1; i >= 0; --i) {
    to[i] = last[a[i]] - i + 1;
    last[a[i]] = i;
  }
  for (int i = 0; i < n; ++i)
    go[0][i] = to[i];
  for (int i = 0; i + 1 < LG; ++i) {
    for (int j = 0; j < n; ++j) {
      go[i+1][j] = min(go[i][j] + go[i][(j+go[i][j]) % n], inf);
    }
  }
  long long cur = 0;
  long long tot = 1LL * k * n;
  for (int i = LG-1; i >= 0; --i) {
    if (cur + go[i][cur % n] < tot) {
      cur += go[i][cur % n];
    }
  }
  cur %= n;
  vector<int> ans;
  memset(last, -1, sizeof last);
  for (int i = cur; i < n; ++i) {
    if (last[a[i]] != -1) {
      while (1) {
        int cur = ans.back();
        ans.pop_back();
        last[cur] = -1;
        if (cur == a[i])
          break;
      }
    }
    else {
      last[a[i]] = i;
      ans.push_back(a[i]);
    }
  }
  for (int i = 0; i < (int)ans.size(); ++i) {
    if (i)
      printf(" ");
    printf("%d", ans[i]);
  }
  printf("\n");
  return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
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<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
const int mod = 998244353; //1e9+7;
struct Mint {
   int val;
   Mint inv() const {
       int tmp, a = val, b = mod, x = 1, y = 0;
       while(b) tmp = a / b, a -= tmp * b, swap(a, b), x -= tmp * y, swap(x, y);
       return Mint(x);
   }
public:
   Mint() :val(0) {}
   Mint(ll x) :val(x >= 0 ? x % mod : x % mod + mod) {}
   int mtoi() { return this->val; }
   Mint pow(ll t) { Mint res = 1; while(t){if(t&1)res *= *this;*this *= *this;t >>= 1;}return res; }
   Mint& operator+=(const Mint& x) { if ((val += x.val) >= mod) val -= mod; return *this; }
   Mint& operator-=(const Mint& x) { if ((val += mod - x.val) >= mod) val -= mod; return *this; }
   Mint& operator*=(const Mint& x) { val = (ll)val * x.val % mod; return *this; }
   Mint& operator/=(const Mint& x) { return *this *= x.inv(); }
   bool operator==(const Mint& x) const { return val == x.val; }
   bool operator!=(const Mint& x) const { return val != x.val; }
   bool operator<(const Mint& x) const { return val < x.val; }
   bool operator<=(const Mint& x) const { return val <= x.val; }
   bool operator>(const Mint& x) const { return val > x.val; }
   bool operator>=(const Mint& x) const { return val >= x.val; }
   Mint operator+(const Mint& x) const { return Mint(*this) += x; }
   Mint operator-(const Mint& x) const { return Mint(*this) -= x; }
   Mint operator*(const Mint& x) const { return Mint(*this) *= x; }
   Mint operator/(const Mint& x) const { return Mint(*this) /= x; }
};
struct factorial {
   vector<Mint> Fact, Finv;
public:
   factorial(int maxx) {
       Fact.resize(maxx+1,Mint(1)),Finv.resize(maxx+1); rep(i,0,maxx)Fact[i+1]=Fact[i]*Mint(i+1);
       Finv[maxx]=Mint(1)/Fact[maxx]; rrep(i,maxx,0)Finv[i-1]=Finv[i]*Mint(i);
   }
   Mint fact(int n,bool inv) { if(inv) return Finv[n]; else return Fact[n]; }
   Mint nPr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[n-r]; }
   Mint nCr(int n,int r) { if(n<0||n<r||r<0) return Mint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};
//template end



int main(){
   int n; cin>>n;
   int cnt=0;
   rep(i,1,n+1){
      string s=to_string(i);
      if((int)(s.size())%2)cnt++;
   }
   printf("%d\n",cnt);
   return 0;
}


Measured memory_bytes: 256
function parseInt(x) parse(Int, x) end
function main()
	n = parseInt.(split(readline()))
	x = Array{Int}(2, n[1])
	for i in 1:n[1]
		x[:,i] = readline() |> split |> x -> map(parseInt, x)
	end
	maxa = maximum(x[1,:])
	useb = Int[]
	for i in 1:n[1]
		if x[2,i] > maxa
			push!(useb, x[2,i])
		end
	end
	useb = sort(useb, rev=true)
	hp = n[2]
	count = 0
	for i in 1:length(useb)
		if hp > 0
			hp -= useb[i]
			count += 1
		end
	end
	if hp > 0
		if hp%maxa == 0
			count += div(hp, maxa)
		else
			count += div(hp, maxa)+1
		end
	end
	print(count)
end

main()

Measured memory_bytes: 160564
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>


using namespace std;
typedef long long ll;

const int N = 2e5 + 100;
const int inf = 0x3f3f3f3f;
const int OO = 1e9 + 100;

ll mod = 1e9 + 7;

string s, t;
string mx;


	int lcs[3010][3010];
int main() {
	
	
	cin >> s >> t;
	int S = s.size(), T = t.size();
	for (int i = 0; i <= S; ++i)
	{
		for (int j = 0; j <= T; ++j)
		{
			lcs[i][j] = 0;
		}
	}
	for (int i = 1; i <= S; ++i)
	{
		for (int j = 1; j <= T; ++j)
		{
			if (s[i - 1] == t[j - 1])
				lcs[i][j] = lcs[i - 1][j - 1] + 1;
			else
				lcs[i][j] = max(lcs[i - 1][j], lcs[i][j - 1]);
		}
	}
	//cout << lcs[S][T] << endl;

	deque<char>sol;
	int i = S, j = T;
	while (i >= 1 && j >= 1)
	{
		if (s[i-1] == t[j-1])
		{
			sol.push_front(s[i - 1]);
			i--, j--;
		}
		else
		{
			if (lcs[i - 1][j] > lcs[i][j - 1])
				i--;
			else
				j--;
		}
	}
	for (int i = 0; i < sol.size(); ++i)
	{
		cout << sol[i];
	}


	return 0;
}


Measured memory_bytes: 38340
#include<stdio.h>
int main()
{
    int a,b=0,c=0,d,e,i,j,f[150000];
    scanf("%d",&a);
    for(i=0;i<a;i++)
    {
        scanf("%d",&f[i]);
    }
    for(i=1;i<a;i++)
    {
        if(f[i-1]>=f[i])c++;
        else
        {
            if(c>b)b=c;
            c=0;
        }
    }
    if(c>b)b=c;
    printf("%d\n",b);
    return 0;
}


Measured memory_bytes: 512
import java.util.*;

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

		while (H > 0) {
			int HHWW = H * H + W * W;

			// >この問題の入力で与えられる横長整長方形に対しては，
			// >それより大きい最小の横長整長方形の高さと幅はともに150を超えないことが分かっている．
			int bestH = 149;
			int bestW = 150;
			int bestHHWW = bestH * bestH + bestW * bestW;

			for (int h = 1;h <= 149;++h) {
				for (int w = h + 1;w <= 150;++w) {
					int hhww = h * h + w * w;
					if (HHWW < hhww || (HHWW == hhww && H < h)) {
						if (hhww < bestHHWW || (bestHHWW == hhww && h < bestH)) {
							bestH = h;
							bestW = w;
							bestHHWW = hhww;
						}
					}
				}
			}
			
			System.out.println(bestH +" " + bestW);

			H = sc.nextInt();
			W = sc.nextInt();
		}

	}
}



Measured memory_bytes: 27708
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int res = 0;
        for (int i = 0; i < N; i++) {
            int a = Integer.parseInt(sc.next());

            while (a % 2 == 0) {
                res++;
                a /= 2;
            }

        }

        System.out.println(res);
    }
}


Measured memory_bytes: 30372
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	ll x;
	ll a[100001];
	ll wa[100000]={};
	scan(N);scan(x);
	rep(i,N) scan(a[i]);
	ll ans=0;
	ll amari=0;
	rep(i,N-1){
		if(a[i]+a[i+1]>x){
			wa[i]=a[i]+a[i+1]-x;
		}
	}
	rep(i,N-2){
		if(wa[i]>0&&wa[i+1]>0){
			ll sage=min(min(wa[i],wa[i+1]),a[i+1]);
			wa[i]-=sage;
			wa[i+1]-=sage;
			ans+=sage;
		}
	}
	rep(i,N-1){
		if(wa[i]>0) ans+=wa[i];
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;var min = int.MaxValue;
        for(var i = 1; i < num; i++)
        {
            var j = num - i;
            min = Min(min, Sum(i) + Sum(j));
        }
        WriteLine(min);
    }
    private static int Sum(int num)
    {
        var s = num.ToString();
        var res = 0;
        for (var i = 0; i < s.Length; i++)
            res += int.Parse(s.Substring(i,1));
        return res;
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  
static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 15296
#include<stdio.h>
#include<string>
#include<utility>
#include<iostream>
#include<queue>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<bitset>

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

int main(){
    int n;
    scanf("%d",&n);
    printf("%d\n",(n-1)/2);
    return 0;
}

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


 int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }


int main() {
    int n;
    cin >> n;
    ll ans = 0;
    rep(i,n) {
        rep(j,n) {
             rep(k,n) {
                ll a =gcd(gcd(i,j),k);
                ans += a;
            }
        }
   }
   cout << ans << endl;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 8;

int ask(int x){
    cout << x+1 << endl;

    string s;
    cin >>s;

    if(s=="Yes") return -1;
    return s=="Near";
}

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

    // make graph
    vector<pair<int,int>> e;
    for(int i=N; i<n; ++i){
        int mask = i-N;
        rep(j,N)if(mask>>j&1){
            e.pb({j+1, i+1});
        }
    }

    cout << e.size() << endl;
    for(const auto &p:e) cout << p.fi << " " << p.se << endl;

    auto game = [&](){
        int m = 0;
        rep(i,N){
            int a = ask(i);
            if(a == -1) return;
            m |= a<<i;
        }

        assert(ask(N+m) == -1);
    };

    while(k--) game();
    return 0;
}



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

const int MAXN = 105;
int N, pUp[MAXN], pDown[MAXN], Ans = 1;

int main() {
    int i, k;
    scanf("%d", &N);
    for(i = 1; i <= N; i++) scanf("%d", &k), pUp[i] = pUp[i - 1] + k;
    for(i = 1; i <= N; i++) scanf("%d", &k), pDown[i] = pDown[i - 1] + k;

    for(i = 1; i <= N; i++) Ans = max(Ans, pUp[i] + pDown[N] - pDown[i - 1]);
    printf("%d", Ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
#define ld long double

#define all(X) (X).begin(), (X).end()
#define reset(X) memset(X, 0, sizeof(X))
#define mp(a, b) make_pair(a, b)
#define pb push_back
#define endl '\n'
#define ff first
#define ss second


using namespace __gnu_pbds;
using namespace std;
const int mod=1e9+7;
 // const int mod=998244353;
 // const int mod=1e9+9;
const int INF=4e18+10;
// const int INF=4e18+10;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define read(n) int n; cin>>n;
#define readv(x, n) vector<int> x(n); for(auto &i:x) cin>>i;


typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> pii;

template<typename T1,typename T2>
void set_min(T1& a, T2 b)
{
    a=min(a, (T1)b);
}


int multiply(int a, int b, int in_mod){return (a*b)%in_mod;}
int mult_identity(int a){return 1;}


auto power(auto a, int b, int in_mod)
{
    auto prod=mult_identity(a);
    auto mult=a%in_mod;
    while(b!=0)
    {
        if(b%2)
        {
            prod=multiply(prod,mult, in_mod);

        }
        mult=multiply(mult, mult,in_mod);
        b/=2;
    }
    return prod;
}
int mod_inv(int q, int in_mod)
{

    return power(q, in_mod-2,in_mod);
}

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

int fact(int n,int in_mod){
    int f=1;
    for(int i=1;i<=n;i++) f=(f*i)%in_mod;
    return f;
}
int ncr(int n,int r,int in_mod){
    return (((fact(n,in_mod)*mod_inv(fact(r,in_mod),in_mod))%in_mod)*mod_inv(fact(n-r,in_mod),in_mod))%in_mod;
}

void solve()
{
    string s,t;
    cin>>s>>t;
    int n=s.size();
    int cnt=0;
    for(int i=0;i<n;i++){
        if(s[i]!=t[i]) cnt++;
    }
    cout<<cnt<<endl;
}

signed main()

{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed<<setprecision(10);
    #ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
        freopen ("INPUT.txt" , "r" , stdin);
        freopen ("OUTPUT.txt" , "w" , stdout);
    }
    #endif
    auto clk=clock();
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // -------------------------------------Code starts here---------------------------------------------------------------------

    int t=1;
    //cin>>t;
    for(int test=1;test<=t;test++)
    {
        // cout<<"Case #"<<test<<": ";
        // cout<<endl;
        solve();
        // cout<<endl;

    }

    // -------------------------------------Code ends here------------------------------------------------------------------


    clk = clock() - clk;
    cerr << fixed << setprecision(6) << "Time: " << ((long double)clk)/CLOCKS_PER_SEC << "\n";
    return 0;
}

Measured memory_bytes: 3872
n=int(input())
from collections import Counter as co
c=co(map(int,input().split()))
ans=pow(2,n//2,10**9+7)
if n%2 :
    if 0 not in c or c[0]>1:ans=0
    for i in range(1,n):
        if i%2==0 :
            if i not in c or c[i]!=2:ans=0;break
        else:
            if i in c:ans=0;break
else:
    if 0 in c:ans=0
    for  i in range(1,n):
        if i%2:
            if i not in c or c[i]!=2:ans=0;break
        else:
            if i in c:ans=0;break
print(ans)

Measured memory_bytes: 22216
#include<iostream>
#include<string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    int ans = 0;
    string s, t;
    cin >> s >> t;
    rep(i,s.size()){
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3912
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES

#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <functional>
#include <utility>
#include <tuple>
#include <vector>
#include <string>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <iterator>
#include <bitset>
#include <complex>
#include <limits>
#include <random>
#include<fstream>
#include<array>


using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;

const double EPS = 1e-9;

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

	string S;
	cin >> S;

	cout << S;
	if (S.back() == 's')cout << "es" << endl;
	else cout << "s" << endl;

	return 0;
}


Measured memory_bytes: 3608
#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>;

const ll INF = 1e18;
ll dp[200005][4];

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    int k = n % 2 + 1;
    rep(i, n + 1) rep(j, k + 1) dp[i][j] = -INF;
    dp[0][0] = 0;
    rep(i, n)
    {
        rep(j, k + 1)
        {
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j]);
            ll now = dp[i][j];
            if ((i + j) % 2 == 0)
                now += a[i];
            dp[i + 1][j] = max(dp[i + 1][j], now);
        }
    }
    ll ans = dp[n][k];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 11176
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()
n = len(s) + 1

ans = [[0, 0] for _ in range(n)]
# 左に連続する<
for i in range(1, n):
    if s[i-1] == '<':
        ans[i][0] = ans[i-1][0] + 1
# 右に連続する>
for i in range(0, n-1):
    if s[n-2-i] == '>':
        ans[n-2-i][1] = ans[n-1-i][1] + 1
print(sum(max(i) for i in ans))


Measured memory_bytes: 133160
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		if (Math.abs(x - a) < Math.abs(x - b)) {
			System.out.println("A");
		} else {
			System.out.println("B");
		}
	}
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	string s;
	string srev;
	cin >> s;
	srev = s;
	reverse(ALL(s));
	if (s != srev) {
		ps(No);
		return(0);
	}
	else {
		int temp = s.size() / 2;
		string sfor = s.substr(0, temp);
		string sforrev = sfor;
		reverse(ALL(sforrev));
		if (sfor != sforrev) {
			ps(No);
			return(0);
		}

		string slat = srev.substr(0, temp);
		string slatrev = slat;
		reverse(ALL(slatrev));
		if (slat != slatrev) {
			ps(No);
			return(0);
		}
		ps(Yes);
	}
	return(0);
}

Measured memory_bytes: 256
# 文字列の操作だけでできるか

S = input()
Q = int(input())

T = 0
l = ""
r = ""
for i in range(Q):
    Query = list(input().split())
    if len(Query) == 1:
        # T = T ^ 1 (排他的論理和; 0 XOR 1 = 1, 1 XOR 1 = 0)
        T ^= 1
    elif T == 0:
        s = Query[2]
        if Query[1] == '1':
            #S = s + S
            l = s + l
        else:
            #S = S + s
            r = r + s
    else:
        s = Query[2]
        if Query[1] == '1':
            #S = S + s
            r = r + s
        else:
            #S = s + S
            l = s + l

S = l + S + r

if T == 1:
    S = S[::-1]

print(S)


Measured memory_bytes: 4412
#include<iostream>
#include<string>

using namespace std;

int main(){
  string S; cin >> S; int alphabet[30] = {0};
  for(int i = 0; i < S.size(); i++){
    int c = S[i] - 'a';
    if(alphabet[c] != 0){ cout << "no" << endl; return 0;}
      alphabet[c]++;}
  
  cout << "yes" << endl; return 0;}
    


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

int main() {
    int n, m;
    cin >> n >> m;
    int a[n], b[n], c[m], d[m];
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];

    rep(i, n) {
        int minv = 1e9, idx = 0;
        rep(j, m) {
            int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (dist < minv) minv = dist, idx = j + 1;
        }
        cout << idx << endl;
    }

    return 0;
}


Measured memory_bytes: 3528
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	while(true){
		int N;
		int a[25][25]={};
		cin>>N;
		if(N==0) break;
		rep(i,N){
			int d,t;
			cin>>d>>t;
			rep(j,d){
				int x;
				cin>>x;
				a[d][(t-j+d)%d]+=x;
			}
		}
		int mx=0;
		rep(i,55440){
			int tmp=0;
			rep1(j,24){
				if(j==13||j==17||j==19||j==23) continue;
				tmp+=a[j][i%j];
			}
			chmax(mx,tmp);
		}
		int b[4]={13,17,19,23};
		rep(i,4){
			int c=b[i];
			int m=0;
			rep(j,c) chmax(m,a[c][j]);
			mx+=m;
		}
		cout<<mx<<endl;
	}
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;

class Q1
{
    static void Main(String[] args)
    {
        String str = Console.ReadLine();
        int n = int.Parse(str);
        if (n % 10 == 9 || n / 10 == 9) Console.WriteLine("Yes");
        else Console.WriteLine("No");
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
string T;
string T2 = "";
int main()
{
    cin >> T;
    for (int i = 0; i < T.length(); i++)
    {
        if (T[i] == 'P')
        {
            T2 += 'P';
        }
        else
        {
            T2 += 'D';
        }
    }
    cout<<T2;
}

Measured memory_bytes: 3892
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			int n=sc.nextInt();
			if(n<2){
				System.out.println("0");
			}else if(n==2){
				System.out.println("1");
			}else{
				int count=1;
				for(int i=3;i<=n;i+=2){
					boolean result=true;
					for(int j=3;j<=Math.sqrt(i);j+=2){
						if(i%j==0){
							result=false;
							break;
						}
					}
					if(result){
						count++;
					}
				}
				System.out.println(count);
			}
		}
	}
}

Measured memory_bytes: 26604
#include <bits/stdc++.h>
#define pb push_back

using namespace std;

void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}
#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(_VA_ARGS_)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int =0;_<n;++)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"

typedef pair<int,int> pii;
typedef long long int ll;
typedef long double ld;

const int DMAX = 1e5+10;

inline int two(int n) { return 1 << n; }
inline int test(int n, int pos) { return (bool) (n & two(pos)); }
inline void set_bit(int &n, int b) { n |= two(b); }
inline void unset_bit(int &n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }

vector <int> V[DMAX];

bool uz[10];

char s[DMAX];
char t[DMAX];

int n;

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

    int i,j,lg;

    cin>>lg;
    cin>>s;
    cin>>t;
    for(i=0;i<lg;i++)
        cout<<s[i]<<t[i];
    cout<<'\n';

    return 0;
}

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

using namespace std;

int main () {
	int n,l;
	cin >> n >> l;
	string a[105];
	for (int i=1;i<=n;i++) cin >> a[i];
	sort (a+1,a+n+1);
	for (int i=1;i<=n;i++) cout << a[i];
	cout << endl;
	return 0;
}

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

typedef long long int ll;

map <ll,ll> m;

int main(){
  ll n;
  cin>>n;
  vector <ll> a(n);
  ll i;
  for(i=0;i<n;i++){
    cin>>a[i];
    m[a[i]]++;
  }
  ll ans=0;
  for(i=1;i<=n;i++){
    ans+=((m[i]*(m[i]-1))/2);
  }
  for(i=0;i<n;i++){
    ll temp=ans-((m[a[i]]*(m[a[i]]-1))/2)+(((m[a[i]]-1)*(m[a[i]]-2))/2);
    cout<<temp<<endl;
  }
  return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

ld dist( int a, int b , int p , int q )
{
    return sqrt((p-a)*(p-a) + (q-b)*(q-b)) ;
}

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int n ; cin >> n ;
    vpii v ( n ) ;

    int per = 0 ;
    for ( int i=0 ; i < n ; i++ ) cin >> v[i].F >> v[i].S ;

    sort ( all ( v ) ) ;

    ld tot_dis = 0 ;

    do
    {
        ld d = 0 ;
        for ( int i=0 ; i < n-1 ; i++ )
            d += dist ( v[i].F , v[i].S , v[i+1].F , v[i+1].S ) ;

        tot_dis += d ;
        per ++ ;

    }while ( next_permutation ( all ( v ) ) ) ;

    //cout << "per : " << per ; line

    ld ans = tot_dis / per ;
    pp ( ans ) ;
}

int main()
{
    int t = 1;
    //cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
N = gets.to_i
k = N.to_s.length

cnt = 0
1.upto(k) do |i|
	next if i % 2 == 0
	if i < k
		cnt = cnt + 10 ** i - 10 ** (i - 1)
	elsif i == k
		cnt = cnt + N - 10 ** (i - 1) + 1
	end
end

puts cnt

Measured memory_bytes: 1788
a = input()
date = list(a)
year = int(date[0])*1000 + int(date[1])*100 + int(date[2])*10 + int(date[3])
mon = int(date[5])*10 + int(date[6])
day = int(date[8])*10 + int(date[9])
if year < 2019 or mon < 5 :
  print("Heisei")
else :
  print("TBD")
 


Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
int main() {
	string s[] = { "Sunny","Cloudy","Rainy","Sunny" };
	string S;

	cin >> S;
	int i = 0;
	while (s[i++] != S);

	cout << s[i] << endl;

	return 0;
}

Measured memory_bytes: 256
import os

import itertools
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7


# MOD = 998244353


def test(N, A):
    ret = -INF
    for choices in itertools.combinations(range(N), N // 2):
        ok = True
        for i, j in zip(choices, choices[1:]):
            if abs(i - j) == 1:
                ok = False
                break
        if ok:
            s = 0
            for i in choices:
                s += A[i]
            ret = max(ret, s)
    print(ret)


N = int(sys.stdin.buffer.readline())
A = list(map(int, sys.stdin.buffer.readline().split()))
N = len(A)

cnt = 2 if N % 2 == 1 else 1
# dp[i][j]: iまでみて、j個とばしたときの総和の最大値
dp = [[-INF] * (cnt + 1) for _ in range(N + 2)]
for i in range(cnt + 1):
    dp[i][i] = 0
for i in range(N):
    for j in range(cnt + 1):
        for k in range(cnt + 1):
            if i + 2 + k < len(dp) and j + k < len(dp[0]):
                dp[i + 2 + k][j + k] = max(dp[i + 2 + k][j + k], dp[i][j] + A[i])
print(dp[-1][-1])

# test(N, A)


Measured memory_bytes: 58288
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		cout<<"3C";
		n%=39;
		if(n==0)cout<<39<<endl;
		else if(log10(n)>=1)cout<<n<<endl;
		else cout<<"0"<<n<<endl;
	}
	return 0;
}

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

int main() {
    int N;
    std::cin >> N;

    std::vector<int> a(N + 1);
    for (int i = 1; i <= N; i++) std::cin >> a[i];

    std::vector<bool> v(N + 1);
    std::vector<int> ans;
    for (int i = N; i > 0; i--) {
        int sum_a = 0;
        for (int j = i; j <= N; j += i)
            if (v[j]) sum_a++;
        if (a[i] != sum_a % 2) {
            v[i] = true;
            ans.push_back(i);
        }
    }

    if (ans.size() == 0)
        std::cout << "0\n";
    else {
        std::cout << ans.size() << "\n";
        std::cout << ans[ans.size() - 1];
        for (int i = ans.size() - 2; i >= 0; i--)
            std::cout << " " << ans[i];
        std::cout << "\n";
    }
}

Measured memory_bytes: 2428
N, M = map(int, input().split())
A = list(map(int, input().split()))
BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append([b, c])


def m():
    A.sort()
    BC.sort(reverse=True, key=lambda x:x[1])
    i = 0
    j = 0
    while i < N:
        if A[i] > BC[j][1]:
            return sum(A)
        if BC[j][0] == 0:
            j += 1
            if len(BC) == j:
                return sum(A)
            continue
        A[i] = BC[j][1]
        BC[j][0] -= 1
        i += 1
    return sum(A)


print(m())

Measured memory_bytes: 25648
a,b,x = map(int,input().split())
a_set = set(range(a,min(a+x,b)))
b_set = set(range(max(a,b-x+1),b+1))

#print(a_set)
#print(b_set)

a_set = a_set.union(b_set)
ans_list = list(a_set)
ans_list.sort()
for ans in ans_list:
  print(ans)

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

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

    int ans = 0;
    int maxv = 0;
    rep(i, n) {
        int h; cin >> h;
        if (maxv <= h) ans++;
        maxv = max(h, maxv);
    }

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


Measured memory_bytes: 256
import java.awt.List;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 標準入力
		Scanner sc = new Scanner(System.in);
		//
		int roop = 0;
		// 答えの配列
		double[] double_array = new double[100];
		// 何個入力があるか
		while (sc.hasNext()) {
			
			//値を初期化
			int input_number = 0;
			int points = 0;
			int all_points = 0;
			// 入力数の配列
			ArrayList<Integer> input_array = new ArrayList<Integer>();
			
			input_number = sc.nextInt();

			// 入力値が0だった場合、結果を出力
			if (input_number == 0) 
				break;
			

			// 入力個数分まわす
			for (int i = 0; i < input_number; i++) {

				//
				while (sc.hasNext()) {
					//
					points = sc.nextInt();
					input_array.add(points);
					break;
				}
				// 合計値
				all_points += points;
			}
			// インスタンスを作る
			Sta_Math obj = new Sta_Math(all_points, input_number, input_array);
			obj.cast_standard();
			//
			double_array[roop] = obj.getStandard();
			roop++;
		}
		for (int i = 0; i < roop; i++) {
			System.out.println(double_array[i]);
		}
	}
}

class Sta_Math {

	// 合計値
	private int all = 0;
	// 入力個数
	private int input_number = 0;
	// 平均
	private double average = 0;
	// 標準偏差
	private double standard = 0;
	// 入力数字列
	ArrayList<Integer> input_arr = null;

	// コンストラクタ
	Sta_Math(int a, int i, ArrayList<Integer> b) {
		all = a;
		input_number = i;
		input_arr = b;
		average = (double)a / i;
	}

	// 標準偏差を計算
	public void cast_standard() {
		double hoge = 0;
		// 分子に使う数
		double namerator = 0;
		// 入っている数列分まわす
		for (int val : input_arr) {
			hoge = (val - average) * (val - average);
			namerator += hoge;
		}

		standard = Math.sqrt(namerator / input_number);
	}

	// ゲッター
	public double getStandard() {
		return standard;
	}

}

Measured memory_bytes: 23656
// B.cpp
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 3e5 + 200, mod = 998244353;

int n, cnt[3], ans = 1;
char str[MAX_N];

int encode(char c) { return c == 'R' ? 0 : (c == 'G' ? 1 : 2); }

int main()
{
	scanf("%d%s", &n, str + 1), n *= 3;
	for (int i = 1; i <= n; i++)
	{
		int x[3], y[3], opt = encode(str[i]);
		memcpy(x, cnt, sizeof(x)), cnt[opt]++;
		memcpy(y, cnt, sizeof(y));
		sort(x, x + 3), sort(y, y + 3);
		if (y[2] != x[2])
			continue;
		else if (y[0] != x[0])
			ans = 1LL * ans * (x[1] - x[0]) % mod;
		else
			ans = 1LL * ans * (x[2] - x[1]) % mod;
	}
	for (int i = 1; i <= n / 3; i++)
		ans = 1LL * ans * i % mod;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 4012
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n, k = LI()
    lst = []

    for _ in range(n):
        a, b = LI()
        lst.append((a,b))
    
    lst.sort(key=lambda x: x[0])
    taken = 0
    ans = 0

    for i in range(n):
        ans = lst[i][0]
        taken += lst[i][1]

        if taken >= k:
            break

    print(ans)
main()


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

int main() {
    string T;
    cin >> T;
    for (int i = 0; i < (int)T.size(); i++) {
        if (T[i] == 'P') cout << 'P';
        else cout << 'D';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3752
#include<iostream>

int a = 0 , b = 0 , c = 0 ;

int main()
{
	std::cin >> a >> b >> c ;
	if( a < b && b < c)
	{
		std::cout << "Yes" <<std::endl ;
	}
	else 
	{
		std::cout << "No" << std::endl ;
	}
}

Measured memory_bytes: 1156