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

public class Main {

	public static void main(String[] args) {
		while (true) {
			int n = nextInt();
			int m = nextInt();

			if (n == 0) {
				break;
			}

			int[] taro = new int[101];
			int sum_taro = 0;
			for (int i = 0; i < n; i++) {
				int card = nextInt();
				sum_taro += card;
				taro[card]++;
			}

			int[] hanako = new int[101];
			int sum_hanako = 0;
			for (int i = 0; i < m; i++) {
				int card = nextInt();
				sum_hanako += card;
				hanako[card]++;
			}

			if (Math.abs(sum_hanako - sum_taro) % 2 != 0) {
				System.out.println(-1);
				continue;
			}

			for (int i = 0; i < 101; i++) {
				int diff = (sum_taro - sum_hanako) / 2;
				if (i - diff >= 0 && i - diff <= 100 && taro[i] > 0
						&& hanako[i - diff] > 0) {
					System.out.println(i + " " + (i - diff));
					break;
				}
				if (i == 100) {
					System.out.println(-1);
				}

			}

		}

	}

	static int nextInt() {
		int c;
		try {
			c = System.in.read();
			while (c != '-' && (c < '0' || c > '9'))
				c = System.in.read();
			if (c == '-')
				return -nextInt();
			int res = 0;
			while (c >= '0' && c <= '9') {
				res = res * 10 + c - '0';
				c = System.in.read();
			}
			return res;
		} catch (IOException e) {
			e.printStackTrace();
		}
		return -1;
	}

}

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

using ll = long long;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int N; cin >> N;
  vector<pair<int, int>> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i].first; A[i].second = i;
  }
  sort(A.begin(), A.end());
  reverse(A.begin(), A.end());
  A.push_back({0, -1});
  vector<ll> ans(N);
  for (int i = 0; i < N; i++) {
    A[i+1].second = min(A[i+1].second, A[i].second);
    ans[A[i].second] += ll(A[i].first - A[i+1].first) * (i+1);
  }
  for (int i = 0; i < N; i++) {
    cout << ans[i] << " \n"[i+1==N];
  }
}

Measured memory_bytes: 2672
#include <iostream>
#include <cstdio>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		double x1,y1,x2,y2,x3,y3,xp,yp,r;
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		xp=0;
		yp=0;
		double a=y2-y1,b=y3-y1,c=y2-y3,d=x2-x1,e=x3-x1;
		if(y1 != y2 && y1 != y3){
			xp=(c/2-e*(x1+x3)/2/b+d*(x2+x1)/2/a)/(-e/b+d/a);
			yp=-e/b*(xp-(x1+x3)/2)+(y1+y3)/2;
		}else if(y1==y2){
			xp=(x1+x2)/2;
			yp=-e/b*(xp-(x1+x3)/2)+(y1+y3)/2;
		}else if(y1==y3){
			xp=(x1+x3)/2;
			yp=-d/a*(xp-(x1+x2)/2)+(y1+y2)/2;
		}
		r = sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
		xp*=1000;
		if(xp>0)
			xp+=0.5;
		else
			xp-=0.5;
		int xp2=xp;
		yp*=1000;
		if(yp>0)
			yp+=0.5;
		else
			yp-=0.5;
		int yp2=yp;
		printf("%.3lf %.3lf %.3lf\n",xp2/(double)1000,yp2/(double)1000,r);
	}
	return 0;
}

Measured memory_bytes: 1244
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;
using ll = long long;

ll n, m, o, add, ans, A[1010101];
string s, str;
char c[101010];
int main() {
	cin >> n >> m;
	cout << n - m + 1 << endl;
	return 0;
}

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

int main(void){
  int N,T,A;
  double min = 100000;
  cin>>N>>T>>A;
  vector<int> v;
  vector<double> a,b,c;
  v.resize(N);
  a.resize(N);
  b.resize(N);
  c.resize(N);
  for(int i = 0;i < N;i++)cin>>v[i];

  for(int t = 0;t < N;t++){
    a[t] = T - v[t] * 0.006;
    if(a[t] - A >= 0)b[t] = a[t] - A;
    else b[t] = A - a[t];
    if(b[t] <= min)min = b[t];

  }
  for(int k = 0;k < N;k++){
    if(min == b[k])cout<<k+1;
  }


}


Measured memory_bytes: 256
// Best practice
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <functional> // for less 
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> pbds; 
 
#define fbo find_by_order
#define ook order_of_key
 
signed main() {
   tezz
   
   string s;
   cin >> s;
   if(s=="Sunny")cout << "Cloudy";
   else if(s=="Cloudy")cout << "Rainy";
   else cout << "Sunny";
   
   return 0;
}
 


Measured memory_bytes: 256
N, K = map(int, input().split())
E = [[] for i in range(N)]
for i in range(N-1):
  a, b = map(int, input().split())
  E[a-1].append(b-1)
  E[b-1].append(a-1)
counts = [False]*N
q = [0]
counts[0] = True
r = K
while q:
  i = q.pop()
  # get_nexts
  js = E[i]
  c = K-1 if i == 0 else K-2
  for j in js:
    if counts[j]:
      continue
    counts[j] = True
    r = (r*c)%1000000007
    c -= 1
    q.append(j)
print(r)


Measured memory_bytes: 23552
import java.util.*;
import java.text.*;
/*
Main class for AOJ where there is no input.
*/
public class Main{
   public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      String[] arr;
      int m;
      int d;
      int sum = 0;
      int[] month = {31,29,31,30,31,30,31,31,30,31,30,31};
      String answer = "";
      
      while(true){
         sum = 0;
         arr = sc.nextLine().split(" ");
         
         m = Integer.parseInt(arr[0]);
         d = Integer.parseInt(arr[1]);
         
         if(m == 0){
            break;
         }
         
         for(int i = 1; i <= m -1; i ++){
            sum += month[i-1];
         }
         sum += d;
         
         switch(sum%7){
            case 0:
               answer = "Wednesday";
               break;
            case 1:
               answer = "Thursday";
               break;
            case 2:
               answer = "Friday";
               break;
            case 3:
               answer = "Saturday";
               break;
            case 4:
               answer = "Sunday";
               break;
            case 5:
               answer = "Monday";
               break;
            case 6:
               answer = "Tuesday";
               break;
               
         }
         
         System.out.println(answer);
      }
      
    
   }//main
}//class

Measured memory_bytes: 25752
n,k = map(int,input().split())
r,s,p = [int(i) for i in input().split()]
T = input()

point = {"r":p,"p":s,"s":r}

ans = 0
for i in range(min(n,k)):
    before = T[i]
    counter = 0
    for s in T[i::k]:
        if before == s:
            counter += 1
        else:
            ans += (counter+1)//2 * point[before]
            before = s
            counter = 1
    ans += (counter+1)//2 * point[before]
print(ans)


Measured memory_bytes: 3316
// https://onlinejudge.u-aizu.ac.jp/courses/lesson/8/ITP2/3/ITP2_3_D
#include <iostream>
#include <vector>
#include <string>
int main()
{
    int n;
    std::cin >> n;
    std::vector<std::string> A(n);
    for (auto &x : A)
    {
        std::cin >> x;
    }
    int m;
    std::cin >> m;
    std::vector<std::string> B(m);
    for (auto &x : B)
    {
        std::cin >> x;
    }
    std::cout << (A < B) << std::endl;
}



Measured memory_bytes: 3288
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    N, X = map(int, input().split())
    L = list(map(int, input().split()))

    ans = 1
    now = 0
    for l in L:
        now += l
        if now <= X:
            ans += 1

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 4196
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++)
#define S(v) sort(v.begin(), v.end())
#define SS(v) sort(v.begin(), v.end(), greater<int>())
#define print(v) for(auto i:v)cout<<i<<" "


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	// freopen("in.txt","r", stdin);
	ll t=1;
	// cin>>t;
	while(t--)
	{
		ll n, x, m,ans =0;
		cin>>n>>x>>m;
		map<ll,vector<ll>> mp;
		vector<ll> v;
		v.push_back(0);
		loop(i,0,n){
			ans += x;
			mp[x].push_back(i);
			v.push_back(ans);
			// cout<<x<<" ";
			if(mp[x].size()>1)	{
				ll j = mp[x][0];
				ll k = i - j;
				ans += ((n-i-1)/k)*(v[i] - v[j]);
			 	ans += v[j+1+(n-i-1)%k] - v[j+1];
				// ans = ans%m;
				break;
			}
			x = (x%m * x%m)%m;					
		}
		// cout<<endl;
		// print(v);
		cout<<ans<<endl;
	}
	
} 





Measured memory_bytes: 9064
#include <stdio.h>
main()
{
	double a,b;
	
	scanf("%lf", &a);
	scanf("%lf", &b);
	
	if(a>b)
	printf("GREATER\n");
	else if(a<b)
	printf("LESS\n");
	else
	printf("EQUAL\n");
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する
const int MOD=1000000007;

//a^n modをO(logN)で計算
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//a/bをmodで割った余り、フェルマーの小定理
int64_t div(int64_t a,int64_t b,int64_t mod){
    return (a%mod)*(modpow(b,mod-2,mod)%mod)%mod;
}
// a-bをMODで割ったあまり、負にならない工夫
long long sub(long long a,long long b){
    long long ans = ((a%MOD)-(b%MOD))%MOD;
    if(ans>=0){
        return ans;
    }
    else{
        return ans+MOD;
    }
}
int main(){
    int n;
    cin>>n;
    int64_t ajmod=0;
    int64_t ans=0;
    vector<int64_t> a(n);
    rep(i,n)cin>>a[i];
    rep(i,n){
        ajmod += a[i]%MOD;
        ajmod %= MOD;
    }
    rep(i,n){
        ajmod = sub(ajmod,a[i]);
        ans += a[i]*ajmod %MOD;
        ans %= MOD;
    }
    cout<<ans%MOD<<endl;
}

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

const int LIMIT = 200000;

int main() {
    int n, c;
    cin >> n >> c;
    int s[n], t[n], cs[n];
    for (int i = 0; i < n; i++) {
        scanf("%d %d %d", &s[i], &t[i], &cs[i]);
    }
    int tt[LIMIT], sm[LIMIT] = {};
    for (int i = 1; i <= c; i++) {
        for (int j = 0; j < LIMIT; j++) tt[j] = 0;
        for (int j = 0; j < n; j++) if(cs[j] == i) tt[s[j]*2-1]++, tt[t[j]*2+1]--;
        for (int j = 1; j < LIMIT; j++) tt[j] += tt[j-1];
        for (int j = 0; j < LIMIT; j++) if(tt[j]>0) sm[j]++;
    }
    int Max = 0;
    for (int i = 0; i < LIMIT; i++) {
        Max= max(Max, sm[i]);
    }
    cout << Max << endl;
    return 0;
}


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

int main()
{
    char s[4];
    int cnt = 0;

    scanf("%s", s);
    
    for(int i = 0; i < 3; i++)
    {
        if(s[i] == '1') cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
import copy

n = int(input())
x = list(map(int, input().split()))
x_sort = copy.deepcopy(x)
x_sort.sort()

center_a = x_sort[int(n / 2) - 1]
center_b = x_sort[int(n / 2)]

for i in range(n):
    if x[i] <= center_a:
        print(center_b)
    else:
        print(center_a)


Measured memory_bytes: 27156
import sys
import heapq


def input():
    return sys.stdin.readline()[:-1]


if __name__ == "__main__":
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A = [-v for v in A]
    heapq.heapify(A)
    for m in range(M):
        v = heapq.heappop(A)
        heapq.heappush(A, -(-v // 2))
    ans = 0
    for a in A:
        ans -= a
    print(ans)


Measured memory_bytes: 14180
main::IO()
main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    print $ solve n m

solve :: Int -> Int -> Int
solve n m
    |1 < abs (n - m) = 0
    |n == m = ((f n) * (f m) * 2) `mod` 1000000007
    |abs (n - m) == 1 = ((f n) * (f m)) `mod` 1000000007
    where
        f k = foldr1(\x y -> (x * y)`mod` 1000000007)[1..k]


Measured memory_bytes: 3708
#include<cstdio>
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
#include<cctype>
#include<vector>
#include<ctime>
#include<cmath>
#define LL long long
#define pii pair<int,int>
#define mk make_pair
#define fi first
#define se second
using namespace std;
const int N = 2e5 + 3; 
inline int read(){
	int v = 0,c = 1;char ch = getchar();
	while(!isdigit(ch)){
		if(ch == '-') c = -1;
		ch = getchar();
	}
	while(isdigit(ch)){
		v = v * 10 + ch - 48;
		ch = getchar();
	}
	return v * c;
}
char s[33],ss[33]; 
int main(){
	scanf("%s%s",s,ss);
	int ans = 0;
	for(int i = 0;i < 3;++i) ans += (s[i] == ss[i]);
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
t, a = list(map(int, input().split()))
h = list(map(int, input().split()))
h_c = [t - i * 0.006 for i in h]
d = 10 ** 7
adr=0
for i in h_c:
    if abs(a - i) < d:
        d = abs(a - i)
        ans = adr
    adr += 1
print(ans + 1)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>

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

using namespace std;

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;

int main() {
//	cout << fixed << setprecision(15);
    int n, k;
    cin >> n >> k;
    vi c(n + 1);
    rep(i, k) {
        int d;
        cin >> d;
        rep(j, d) {
            int a;
            cin >> a;
            c[a]++;
        }
    }
    int ans = 0;
    rep1(i, n) if(c[i] == 0) ans++;
    cout << ans << endl;
}


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

int main() {
    int S;
    cin >> S;
    int A, B, C, D;
    A = S / 1000;
    B = (S - A*1000) / 100;
    C = (S - A*1000 - B*100) / 10;
    D = (S - A*1000 - B*100 - C*10);
    vector<string> vec(3);
    vector<int> N = {B, C, D};
    for(int i = 0; i < 8; i++){
        int num = A;
        for(int j = 0; j < 3; j++){
                if(((i >> j) & 1) == 1){
                vec.at(j) = "+";
                num += N.at(j);
            }else{
                vec.at(j) = "-";
                num -= N.at(j);
            }
        }
        if(num == 7){
            cout << A << vec.at(0) << B << vec.at(1) << C << vec.at(2) << D <<  "=7" << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<stack>
#include<queue>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;
int main()
{
	char a[25];
	for(int i=0;i<19;i++)
	scanf("%c",&a[i]);
	for(int i=0;i<19;i++)
	{
		if(i==5||i==13)
		{
		printf(" ");
		continue;
	    }
	    else
	    printf("%c",a[i]);
	}
	return 0;
}

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

int main() {
	int W, A, B;
	cin >> W >> A >> B;
	if (A + W < B) {
		cout << abs(B - A - W) << endl;
	}
	else if (A <= B && B <= A + W) {
		cout << 0 << endl;
	}
	else if (A <= B + W && B <= A) {
		cout << 0 << endl;
	}
	else {
		cout << abs(B + W - A) << endl;
	}
}


Measured memory_bytes: 3548
#!/usr/bin/env ruby
a, b, x = STDIN.readline().strip().split(' ').map(&:to_i)
def m(a, b, x)
  na = (a - 1)/ x
  nb = b / x 
  r = nb - na
  # puts "na:#{na}, nb:#{nb}, r:#{r}"
  r
end
puts "#{m(a, b, x)}"


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

typedef long long ll;
typedef pair<ll,ll> P;

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

	ll n;cin >> n;
	ll top = 0, second = 0, id;
	REP(i, n){
		ll a;cin >> a;
		if(a > top){
			id = i;
			second = top;
			top = a;
		}
		else {
			second = max(second, a);
		}
	}

	REP(i, n){
		if(i == id)cout << second << '\n';
		else cout << top << '\n';
	}


	return 0;
}


Measured memory_bytes: 1664
fun main(args: Array<String>) {
    val n = readLine()!!.toLong()
    val aList = readLine()!!.split(' ').map(String::toLong)
    val evenList = aList.filterIndexed { index, l -> index % 2 == 0 }
    val oddList = aList.filterIndexed { index, l -> index % 2 == 1 }
    val evenGroupBy = evenList.groupBy { it }.toSortedMap().toList().sortedByDescending { it.second.size }
    val oddGroupBy = oddList.groupBy { it }.toSortedMap().toList().sortedByDescending { it.second.size }

    var count1 = 0L
    count1 += evenList.size - evenGroupBy[0].second.size
    var flag1 = false
    for (i in oddGroupBy) {
        if (i.first != evenGroupBy[0].first) {
            count1 += oddList.size - i.second.size
            flag1 = true
            break
        }
    }
    if (!flag1) count1 += oddList.size

    var count2 = 0L
    count2 += oddList.size - oddGroupBy[0].second.size
    var flag2 = false
    for (i in evenGroupBy) {
        if (i.first != oddGroupBy[0].first) {
            count2 += evenList.size - i.second.size
            flag2 = true
            break
        }
    }
    if (!flag2) count2 += evenList.size

    println(Math.min(count1, count2))
}

Measured memory_bytes: 86308
//package com.company;
// Always comment out package when submitting.

import java.io.*;
import java.util.*;

public class Main {
    // Actual Code
    public static class Task {


        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            double[] prob = new double[n];
            for (int i = 0; i < n; i++) {
                prob[i] = sc.nextDouble();
            }
            double[] dp = new double[n + 1];
            dp[0] = 1.0;
            for (int i = 0; i < n; i++) {
                for (int j = n; j >= 1; j--) {
                    dp[j] = dp[j - 1] * prob[i] + dp[j] * (1 - prob[i]);
                }
                dp[0] = dp[0] * (1 - prob[i]);
            }
            double ret = 0.0;
            for (int i = (n / 2) + 1; i <= n; i++) {
                ret += dp[i];
            }
            pw.println(ret);
        }
    }

    // template, actual code is in class Task.
    static long TIME_START, TIME_END;
    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("File.in"));
        PrintWriter pw = new PrintWriter(new BufferedOutputStream(System.out));
//        PrintWriter pw = new PrintWriter(new FileOutputStream("File.out"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
//        System.err.println("Memory increased:" + (usedMemoryAfter-usedMemoryBefore) / 1000000 );
//        System.err.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    // Faster IO with BufferedReader wrapped with Scanner
    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s){br = new BufferedReader(new InputStreamReader(s));}

        public Scanner(FileReader s) throws FileNotFoundException {br = new BufferedReader(s);}

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

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

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

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

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

        public boolean ready() throws IOException {return br.ready();}
    }
}

Measured memory_bytes: 22868
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
/* clang-format on */

int main() {
  ll N, P;
  while (cin >> N >> P) {
    ll res = 1;
    for (ll p = 2; p * p <= P; p++) {
      if (P % p == 0) {
        int e = 0;
        while (P % p == 0) {
          ++e;
          P /= p;
        }
        int v = e / N;
        for (int i = 0; i < v; i++) res *= p;
      }
    }
    if (P > 1) {
      int e = 1;
      int v = e / N;
      for (int i = 0; i < v; i++) res *= P;
    }
    cout << res << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int h,w;
int fie[2001][2001];
int data[2001][2001];
int sum[2001][2001];

int main(void){
	scanf("%d%d",&h,&w);
	for(int i=0;i<h;i++){
		string str;
		cin >> str;
		for(int j=0;j<w;j++){
			if(str[j]=='#')fie[i][j]=1;
		}
	}
	for(int i=0;i<w-1;i++){
		for(int j=0;j<h-1;j++){
			int cnt=0;
			for(int k=0;k<2;k++){
				for(int l=0;l<2;l++){
					cnt+=fie[j+k][i+l];
				}
			}
			if(cnt%2==1){
				data[j][i]=1;
			}
		}
	}
	for(int i=0;i<w-1;i++){
		for(int j=0;j<h-1;j++){
			if(data[j][i]==1)sum[j][i]=0;
			else{
				sum[j][i]=1;
				if(j>0)sum[j][i]+=sum[j-1][i];
			}
		}
	}
	int res=max(w,h);
	for(int i=0;i<h-1;i++){
		stack<P> st;
		for(int j=0;j<=w-1;j++){
			if(st.empty()){
				st.push(P(j,sum[i][j]));
			}else{
				if(st.top().second<sum[i][j]){
					st.push(P(j,sum[i][j]));
				}else if(st.top().second>sum[i][j]){
					int target=j;
					while(st.size() && st.top().second>=sum[i][j]){
						P p=st.top();
						st.pop();
						int area=(p.second+1)*(j-p.first+1);
						res=max(res,area);
						target=p.first;
					}
					st.push(P(target,sum[i][j]));
				}
			}
		}
	}
	printf("%d\n",res);
	return 0;
}

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

#define __STDC_FORMAT_MACROS
#define p64 PRId64

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define ALL(f, x, ...)                                                         \
    ([&] (decltype ((x)) ALL) {                                                \
        return (f) (begin (ALL), end (ALL), ##__VA_ARGS__);                    \
    }) (x)

using namespace std;
using ll = int64_t;

int main() {
    int N;
    cin >> N;
    vector<double> A (N, 0);
    REP (i, N) cin >> A[i];
    cout << fixed << setprecision (14)
         << (double)1 / ALL (accumulate, A, (double)0,
                             [=] (double pre, double cur) {
                                 return pre + (double)1 / cur;
                             })
         << endl;
    return 0;
}

Measured memory_bytes: 3812
using System;

class Program
{
  static void Main(string[] args)
  {
    string[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    
    if(a < 9 && b < 9) Console.WriteLine("Yay!");
    else Console.WriteLine(":(");
  }
}

Measured memory_bytes: 13140
fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    let vec: Vec<&str> = buf.split_whitespace().collect();
    let a: i32 = vec[0].parse().unwrap();
    let b: i32 = vec[1].parse().unwrap();
    let ab: i32 = vec[2].parse().unwrap();
    let mut min_a: i32 = vec[3].parse().unwrap();
    let mut min_b: i32 = vec[4].parse().unwrap();
    let mut ans = 0;

    if min_a > min_b {
        if ab * 2 < a + b{
            while min_b > 0{
                ans = ans + 2 * ab;
                min_b = min_b - 1;
                min_a = min_a - 1;
            }
            if a > 2 * ab{
                while min_a > 0{
                    ans = ans + 2 * ab;
                    min_b = min_b - 1;
                    min_a = min_a - 1;
                }
            }else{
                while min_a > 0 {
                    ans = ans + a;
                    min_a = min_a - 1;
                }
            }
        }else{
            while min_b > 0 {
                ans = ans + b;
                min_b = min_b - 1;
            }
            while min_a > 0 {
                ans = ans + a;
                min_a = min_a - 1;
            }
        }
    }else{
        if ab * 2 < a + b{
            while min_a > 0{
                ans = ans + 2 * ab;
                min_b = min_b - 1;
                min_a = min_a - 1;
            }
            if b > 2 * ab{
                while min_b > 0{
                    ans = ans + 2 * ab;
                    min_b = min_b - 1;
                    min_a = min_a - 1;
                }
            }else{
                while min_b > 0 {
                    ans = ans + b;
                    min_b = min_b - 1;
                }
            }
        }else{
            while min_b > 0 {
                ans = ans + b;
                min_b = min_b - 1;
            }
            while min_a > 0 {
                ans = ans + a;
                min_a = min_a - 1;
            }
        }
    }

    println!("{:?}", ans);

}


Measured memory_bytes: 4352
#include<iostream>
using namespace std;
int main()
{
 
  int k,a,b,i;
  cin>>k>>a>>b;
  
  for(i=a;i<b+1;i++){
    if(i%k==0){
      printf("OK\n");
      return 0;
    }
  }
  printf("NG\n");
  
  return 0;
}


Measured memory_bytes: 3600
n = int(input())
d = [list(map(int,input().split())) for i in range(n)]

c = 0
for i in d:
    if(i[0] == i[1]):
        c += 1
        if(c >= 3):
            print("Yes")
            exit()
    else:
        c = 0
print("No")

Measured memory_bytes: 9176
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
using namespace std;
int main() {
	int p, q, r;
	std::cin >> p >> q >> r;
	
	int ans;
	ans = (p+q+r) - max(p,max(q,r));
	
	std::cout << ans << std::endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try (Scanner s = new Scanner(System.in)) {
            final int ROOM = s.nextInt(), PATH = s.nextInt();
            var paths = new HashMap<Integer, Set<Integer>>();
            for (int i = 0; i < PATH; i++) {
                int a = s.nextInt(), b = s.nextInt();
                paths.computeIfAbsent(a, k -> new HashSet<>()).add(b);
                paths.computeIfAbsent(b, k -> new HashSet<>()).add(a);
            }
            var sign = new HashMap<Integer, Integer>();
            sign.put(1, 0);
            var queue = new ArrayDeque<Integer>();
            queue.add(1);
            while (!queue.isEmpty()) {
                Integer i = queue.pollFirst();
                var to = paths.get(i);
                for (Integer j : to) {
                    if (sign.containsKey(j)) {
                        continue;
                    }
                    sign.put(j, i);
                    queue.add(j);
                }
            }
            System.out.println("Yes");
            for (int i = 2; i <= ROOM; i++) {
                System.out.println(sign.get(i));
            }
        }
    }
}


Measured memory_bytes: 107328
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define rep(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define irep(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define rrep(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

bool check(int x, int y, int r, int c) {
    if (x != 0 && x != r && y!=0 && y!=c)
        return false;

    return true;
}
int main() {
    int r, c, n;
    cin >> r >> c >> n;
    vector<pair<int, int>> ex1, ex2, ey1, ey2;
    rep(i, 0, n) {
        int x[2], y[2];
        cin >> x[0] >> y[0] >> x[1] >> y[1];
        if (!check(x[0], y[0], r, c) || !check(x[1], y[1], r, c))
            continue;

        rep(j, 0, 2) {
            if (x[j] == 0)
                ey1.push_back(make_pair(y[j], i));
            else if (x[j] == r)
                ey2.push_back(make_pair(y[j], i));
            else if (y[j] == 0)
                ex1.push_back(make_pair(x[j], i));
            else if (y[j] == c)
                ex2.push_back(make_pair(x[j], i));
        }
    }
    sort(ex1.begin(), ex1.end(), greater<pair<int, int>>());
    sort(ey1.begin(), ey1.end());
    sort(ex2.begin(), ex2.end());
    sort(ey2.begin(), ey2.end(), greater<pair<int, int>>());

    vector<int> order;
    for (auto t : ey1)
        order.push_back(t.second);
    for (auto t : ex2)
        order.push_back(t.second);
    for (auto t : ey2)
        order.push_back(t.second);
    for (auto t : ex1)
        order.push_back(t.second);

    stack<int> st;
    for (auto t : order) {
        if (st.size() && st.top() == t)
            st.pop();
        else {
            st.push(t);
        }
    }
    cout << (st.empty() ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 3688
#include <iostream>

using namespace std;
int main(int argc, char *argv[]) {
	int a, b ,c;
	cin >> a >> b >> c;
	if(a==b) cout << c << endl;
	if(b==c) cout << a << endl;
	if(a==c) cout << b << endl;
	return 0;
}

Measured memory_bytes: 256
using System;

namespace ConsoleApp7
{
    class Program
    {
        static void Main(string[] args)
        {
            string[]oppai = Console.ReadLine().Split(' ');
            int a,b,c;
            a= int.Parse(oppai[0]);
            b= int.Parse(oppai[1]);
            c= int.Parse(oppai[2]);
            if (a < b)
            {
                if (b < c)
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

Measured memory_bytes: 9004
class in{struct my_iterator{int it;const bool rev;explicit constexpr my_iterator(int it_, bool rev=false):it(it_),rev(rev){}int operator*(){return it;}bool operator!=(my_iterator& r){return it!=r.it;}void operator++(){rev?--it:++it;}};const my_iterator i,n;public:explicit constexpr in(int n):i(0),n(n){}explicit constexpr in(int i,int n):i(i,n<i),n(n){}const my_iterator& begin(){return i;}const my_iterator& end(){return n;}};

#include <bits/stdc++.h>
using namespace std;

using i64 = long long;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    i64 w, h;
    cin >> w >> h;
    vector<i64> p(w);
    for(auto& x : p) cin >> x;
    vector<i64> q(h);
    for(auto& x : q) cin >> x;
    i64 pSum = accumulate(p.begin(), p.end(), 0LL);
    i64 qSum = accumulate(q.begin(), q.end(), 0LL);
    i64 ans = pSum + qSum;
    sort(p.begin(), p.end());
    sort(q.begin(), q.end());
    for(i64 x : p) {
        auto it = lower_bound(q.begin(), q.end(), x + 1);
        i64 i = q.end() - it;
//        cout << x << ' ' << i << endl;
        ans += x * i;
    }
    for(i64 x : q) {
        i64 i = p.end() - lower_bound(p.begin(), p.end(), x);
//        cout << x << ' ' << i << endl;
        ans += x * i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main(){
    char fig[101];

    while(scanf("%s", fig) != EOF){
        int sum = 0, i;
        int nums[100] = {0};

        for(i = 0; fig[i]; i++)
            switch(fig[i]){
                case 'I' :
                    nums[i] = 1;
                    break;

                case 'V' :
                    nums[i] = 5;
                    break;

                case 'X' :
                    nums[i] = 10;
                    break;

                case 'L' :
                    nums[i] = 50;
                    break;

                case 'C' :
                    nums[i] = 100;
                    break;

                case 'D' :
                    nums[i] = 500;
                    break;

                default :
                    nums[i] = 1000;
            }

        for(i = 0; nums[i]; i++)
            if(nums[i] < nums[i + 1])
                sum -= nums[i];
            else
                sum += nums[i];

        printf("%d\n", sum);
    }

    return 0;
}

Measured memory_bytes: 536
#include <bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MAXN 200005
#define REP(temp, init_val, end_val) for (int temp = init_val; temp <= end_val; ++temp)
#define REPR(temp, init_val, end_val) for (int temp = init_val; temp >= end_val; --temp)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> intpair;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while (c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while (c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
inline int lowbit(int x){
    return x & (-x);
}
inline int modadd(int x, int y){
    return (x + y >= MOD ? x + y - MOD: x + y);
}
inline int sgn(int x){
    return (x < 0 ? -1: (x > 0 ? 1: 0));
}
template<typename T>
T gcd(T a, T b){
    return (!b) ? a: gcd(b, a % b);
}
int poww(int a, int b){
    int res = 1;
    while (b > 0){
        if (b & 1) res = 1ll * res * a % MOD;
        a = 1ll * a * a % MOD, b >>= 1;
    }
    return res;
}
const int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const int ddx[] = {-1, -1, -1, 0, 0, 1, 1, 1}, ddy[] = {-1, 0, 1, -1, 1, -1, 0, 1};

/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/

int n, b[105], tmp[105];
int dd[105];
void init(){
    n = read();
    REP(i, 1, n)
        b[i] = read();
}
void solve(){
    REPR(i, n, 1){
        int t = -1;
        REP(j, 1, i){
            if (b[j] == j)
                t = j;
        }
        if (t == -1){
            printf("-1\n");
            return ;
        }
        dd[i] = t;
        while (t < i)
            b[t] = b[t + 1], ++t;
    }
    REP(i, 1, n)
        printf("%d\n", dd[i]);
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 3764
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val Array(datR, datG, datB) = readLine.split(" ").map(_.toInt)
    val Array(datK) = readLine.split(" ").map(_.toInt)

    def recGreater(times: Int, base: Int, target: Int): (Int, Int) = {
      if (base < target) (times, target)
      else recGreater(times + 1, base, target * 2)
    }
    val (k1, datG2) = recGreater(0, datR, datG)
    val (k2, datB2) = recGreater(0, datG2, datB)

    val ans = (k1 + k2) <= datK
    println(if(ans) "Yes" else "No")
  }
}


Measured memory_bytes: 54628
/**
 * A_B_Probrem.cpp
 * Create:20180419
 * Description:a,bを読み込んで、以下の値を計算する。
 * a / b 整数
 * a % b 整数
 * a / b 浮動小数点
 */
#include <iostream>

int main(int argc, char* argv[]){
  int a, b;

  std::cin >> a >> b;

  int x = a / b;
  int y = a % b;
  double z = (double)a / double(b);

  // std::cout << x << " " << y << " " << z << std::endl;
  printf("%d %d %.8f", x, y, z);

  return 0;
}



Measured memory_bytes: 3220
x,k,d = map(int, input().split())

tmp = (x+d*k)/(2*d)
tmp = int(tmp)
ans = []
for i in [0,k,tmp]:
    for j in range(-10,10):
        a = i+j
        if a<0 or k<a:
            continue
        y = x+d*k - 2*d*a
        ans.append(abs(y))
ans = min(ans)
print(ans)


Measured memory_bytes: 61860
n,m = map(int, input().split())
num = [0]*n
tf = True
for _ in range(m):
  d = list(map(int, input().split()))
  if d[0]==1 and d[1]==0 and n>1:
    tf = False
    break
  if num[d[0]-1] == 0:
    num[d[0]-1] = d[1]
    continue
  if num[d[0]-1] != d[1]: 
    tf = False
if num[0]==0 and n>1:
  num[0] = 1
if tf:
  ans = 0
  for i in range(n-1,-1,-1):
    ans += num[(n-1)-i]*(10**i)
  print(ans)
else: print(-1)

Measured memory_bytes: 9188
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")
 
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cassert>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <numeric>
#include <time.h>
#include <stack>
#include <bitset>
// #include <any>

#define prev asasddlsa
#define rank aljds

#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i >= l; i++)
 
using namespace std;
 
typedef long long ll;
typedef double dbl;
 
template<typename T>
void print(const vector<T>& s){
    for (auto x : s)
        cout << x << "";
    cout << endl;
}
 
template<class T>   
void print(const T* s, int n){
    for (int i = 0; i < n; i++)
        cout << s[i] << "";
    cout << endl;
}

template<class T>
void print(vector<vector<T>> s){
    for (int i = 0; i < s.size(); i++)
        print(s[i]);
}

auto build(int n, int m, int t){
    if (n == 0 || m == 0)
        return vector<vector<int>>();
    auto kek = build(n - 1, m - 1, t ^ 1);
    // print(kek);
    int nn = (1 << (n - 1)) - 1, mm = (1 << (m - 1)) - 1;
    n = (1 << n) - 1, m = (1 << m) - 1;
    vector<vector<int>> s(n, vector<int>(m));
    if (t){
        for (int i = 0; i < n; i++)
            s[i][m / 2] = 1;
        for (int i = 0; i < m; i++)
            s[n / 2][i] = 1;
    }
    s[n / 2][m / 2] = 1;
    for (int x = 0; x < 2; x++){
        for (int y = 0; y < 2; y++){
            for (int i = 0; i < nn; i++){
                for (int j = 0; j < mm; j++){
                    s[x * (nn + 1) + i][y * (mm + 1) + j] = kek[i][j];
                }
            }
        }
    }
    return s;
}

int solve(){
    int n, m;
    cin >> n >> m;
    auto res = build(n, m, min(n, m) & 1);
    print(res);
    return 0;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(10);
    cout << fixed; 
    int t = 1;
    // cin >> t;
    while (t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 9600
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long int;

const ll MOD = 1e9 + 7;

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

  string prev = s;

  while (true) {
    string next;
    ll cnt = 0;
    for (ll i = 0; i < prev.size(); i++) {
      if (prev.substr(i, 2) == "()") {
        i++;
        cnt++;
      } else {
        next.push_back(prev[i]);
      }
    }
    if (cnt == 0) {
      break;
    } else {
      prev = next;
    }
  }

  string bef = "";
  string aft = "";

  for (ll i = 0; i < prev.size(); i++) {
    if (prev[i] == ')') {
      bef += "(";
    } else {
      aft += ")";
    }
  }
  cout << (bef + s + aft) << endl;
}

Measured memory_bytes: 256
from collections import deque

h,w = map(int, input().split())
maze = [list(input()) for _ in range(h)]

dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

ans = 0

for a in range(h):
    for b in range(w):
        if maze[a][b] == ".":
            DQ = deque([(a, b)])
            visit = [[-1] * w for _ in range(h)]
            visit[a][b] = 0
            tmp = 0
            while DQ:
                px, py = DQ.popleft()
                for i in range(4):
                    nx = px + dx[i]
                    ny = py + dy[i]
                    if 0<=nx<=h-1 and 0<=ny<=w-1 and maze[nx][ny]=="." and visit[nx][ny]==-1:
                        visit[nx][ny] = visit[px][py] + 1
                        tmp = visit[nx][ny]
                        DQ.append((nx, ny))
            ans = max(ans, tmp)

print(ans)

Measured memory_bytes: 75000
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int x, mx;
long long dat[200];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> x;
	for (int i = 1; 1; i++) {
		long long tmp = i;
		for (int j = 0; j < 4; j++) {
			tmp *= i;
		}
		if (tmp - dat[i - 1] > 1e9) {
			mx = i;
			break;
		}
		dat[i] = tmp;
	}
	for (int i = mx - 1; i >= 0; i--) {
		long long R = dat[i];
		for (int j = i - 1; j > -mx; j--) {
			long long L;
			if (j >= 0) L = dat[j];
			else L = -dat[-j];
			if (R - L == x) {
				cout << i << " " << j << "\n";
				return 0;
			}
		}
	}
	//system("pause");
	return 0;
}

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    C *= 2;

    int ans = 1 << 30;
    for (int i = 0; i <= 100000; i++) {
        int sum = C * i + max(0, A * (X - i)) + max(0, B * (Y - i));
        ans = min(ans, sum);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3608
import sys
import numpy as np
N = int(input())
D = list(map(int,input().split()))
M = max(D)
countlist=list(map(int,np.zeros(M+1)))
ans=1

for i in D:
    countlist[i]+=1

if countlist[0]!=1 :
    print(0)
    sys.exit()
elif M<2:
    print(1)
    sys.exit()

if D[0]!=0 :
    print(0)
    sys.exit()

for i in range(2,M+1):
        ans *= countlist[i-1]**countlist[i]



print(ans%998244353) 

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

int main() {
	int n;
	cin >> n;
	bool arry[4][13] = { false };
	int rearr[100];
	char k;
	int num;
	while (1) {
		for (int i = 1; i <= n; i++) {
			cin >> k >> num;
			int m = k == 'S' ? 0 : k == 'H' ? 1 : k == 'C' ? 2 : k == 'D' ? 3 : NULL;
			arry[m][num-1] = true;
		}

		for (int j = 0; j < 4; j++) {
			for (int l = 0; l < 13; l++) {
				if (arry[j][l] == 0) {
					char q = j == 0 ? 'S' : j == 1 ? 'H' : j == 2 ? 'C' : j == 3 ? 'D' : NULL;
					cout << q << " " << l+1  << endl;
				}
			
			}

		}
		break;
	}

}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
        long long int t=0;
        string c;
        string s;
       long long int n,m,o=0,l,d=0,i,j,p=0,k,f;
       double pie=3.141592653589793238;
    long long int MOD=1000000007;
    cin>>n;
    long long int a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[a[i]-1]=i;
    }
    //d=d+1;
    p=n;
    for(i=0;i<n;i++)
    {
        if(b[i]<p)
        {
            //cout<<i<<" ";
            d=d+1;
            p=b[i];
        }
    }
    cout<<d;
    //cout<<P;
 return 0;
}

Measured memory_bytes: 3328
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        s = S()
        if s == '0':
            break
        d = collections.defaultdict(int)
        r = 0
        for c in s:
            c = int(c)
            nd = collections.defaultdict(int)
            for k,v in d.items():
                nd[(k*10+c) % 11] = v
            if c > 0:
                nd[c] += 1
            r += nd[0]
            d = nd
        rr.append(r)

    return '\n'.join(map(str, rr))



print(main())



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

int main() {
  int N; cin >> N;
  for(int i = 1; i < 10; i++) {
    for(int j = 1; j < 10; j++) {
      if(N == (i*j)) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256