akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;


public class Main {
	
	static class Point {
		int x, y;
		public Point(int xx, int yy) {
			x = xx;
			y = yy;
		}
		int cross(Point o) {
			return x * o.y - o.x * y;
		}
		Point sub(Point o){
			return new Point(x - o.x, y - o.y);
		}
	}
	
	static class Scanner{
		BufferedReader br=null;
		StringTokenizer tk=null;
		public Scanner(){
			br=new BufferedReader(new InputStreamReader(System.in));
		}
		public String next() throws IOException{
			while(tk==null || !tk.hasMoreTokens()) {
				String cad = br.readLine();
				if (cad == null)
					return null;
				tk=new StringTokenizer(cad);
			}
			return tk.nextToken();
		}
		public int nextInt() throws NumberFormatException, IOException{
			return Integer.valueOf(next());
		}
		public long nextLong() throws NumberFormatException, IOException{
			return Long.valueOf(next());
		}
		public double nextDouble() throws NumberFormatException, IOException{
			return Double.valueOf(next());
		}
	}
	
	static long mod = 998244353;
	static long[] pow2;
	
	public static void main(String args[]) throws NumberFormatException, IOException {
		Scanner sc = new Scanner();
		int N = sc.nextInt();
		Point[] p = new Point[N];
		for(int i = 0; i < N; i++)
			p[i] = new Point(sc.nextInt(), sc.nextInt());
		pow2 = new long[N + 1];
		pow2[0] = 1;
		for(int i = 1; i <= N; i++)
			pow2[i] = (pow2[i - 1] * 2) % mod;
		long sub = 1;
		for(int i = 0; i < N; i++) { 
			sub++;
			for(int j = i + 1; j < N; j++) {
				int count = 0;
				for(int k = j + 1; k < N; k++) {
					if (p[j].sub(p[i]).cross(p[k].sub(p[i])) == 0)
						count++;
				}
				sub = (sub + pow2[count]) % mod;
			}
		}
		System.out.println((pow2[N] - sub + mod) % mod);
	}

}


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

int main(){
	int N;
	cin >> N;
	vector<int> P(N);
	for(auto &p : P) cin >> p;
	int ans = 0;
	int m = INT_MAX;
	for(int i=0;i<N;i++) {
		if(P[i] <= m) ans++;
		m = min(m, P[i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		char[] arr = sc.next().toCharArray();
		char prev = 'X';
		int count = 0;
		for (char c : arr) {
		    if (c != prev) {
		        count++;
		        prev = c;
		    }
		}
		System.out.println(count);
	}
}


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

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

	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	char ch[] = br.readLine().toCharArray();
	if (Character.isUpperCase(ch[0])) {
	    System.out.println("A");
	} else {
	    System.out.println("a");
	}
    }
}

Measured memory_bytes: 32496
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long ll;
int main()
{
	int n,q;
	ll k;
	cin>>n>>k>>q;
	std::vector<ll> v(n,k-q);
	for(int i=0; i<q; i++){
		ll x;
		cin>>x;
		x--;
		v[x]++;
	}
	for(int i=0; i<n; i++){
		if(v[i]<=0)printf("No\n");
		else printf("Yes\n");
	}
	return 0;
}

Measured memory_bytes: 1408
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define vint vector<int>
#define pint pair<int, int>
#define pb(a) push_back(a)
#define all(v) v.begin(), v.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl

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

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

	int a[3];

    for (int i = 0; i < 3; i++)
    {
        cin>>a[i];
    }

    sort(a,a+3);

    yn((a[0]==a[1]&&a[0]!=a[2])||(a[1]==a[2]&&a[0]!=a[2]));
    

	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <bits/stdc++.h>
using namespace std;
#define endl			"\n"
#define ll				long long
#define all(v)			((v).begin()), ((v).end())
#define sz(v)			((int)((v).size()))
#define clr(v, d)		memset(v, d, sizeof(v))
#define rep(i, v)		for(int i=0;i<H(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define vi				vector <int>
#define vl				vector <ll>
#define pll				pair <ll,ll>
#define vii				vector <pll>
#define PI				double PPPPPP = 3.14159265358979323846;
void run() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr), cout.tie(nullptr);
}
void solve() {
	ll x;
	cin >> x;
	ll ans = (x / 500) * 1000 + ((x % 500) / 5) * 5;
	cout << ans;

}
int main() {
	run();
	int t = 1;
	///cin>>t;
	while (t--)
		solve();

}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){

    int n;
    cin >> n;
    vector<int> p(n);
    rep(i, n) cin >> p[i];

    int cnt = 0;

    for(int i = 1; i < n-1; ++i){
        int x = p[i];
        vector<int> y = {p[i-1], p[i], p[i+1]};
        sort(y.begin(), y.end());
        if(y[1] == x) ++cnt;
    }
    ppp(cnt);

    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

struct Edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    Edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<Edge>>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s, t;
    cin >> s >> t;
    t += s;
    cout << t << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 1000000
ll f(ll x){
    return x*(x-1)/2;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    string s; cin>>s;
    vector<pair<bool,ll> >v;
    ll cnt=1;
    for(int i=1;i<s.size();i++){
	if(s[i-1]!=s[i]){
	    v.push_back(make_pair((s[i-1]=='<'),cnt));
	    cnt=0;
	}
	cnt++;
    }
    v.push_back(make_pair((s[s.size()-1]=='<'),cnt));
    ll ans=0;
    if(v[0].first==0){
	ans+=f(v[0].second+1);
	for(int i=0;i<v.size()-1;i++){
	    v[i]=v[i+1];
	}
	v.pop_back();
    }
    if(v.size()==0){
	cout<<ans<<endl;
	return 0;
    }
    if(v.back().first==1){
	ans+=f(v.back().second+1);
	v.pop_back();
    }
    if(v.size()==0){
	cout<<ans<<endl;
	return 0;
    }
    for(int i=0;i<v.size();i+=2){
	ans+=f(v[i].second);
	ans+=f(v[i+1].second);
	ans+=max(v[i].second,v[i+1].second);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 5780
#include<iostream>
#include<vector>
#include<iterator>
#include<algorithm>
int main()
{
  using namespace std;
  int n,k;
  vector<int> vec(n+1);
  cin>>n>>k;
  for(int i=0;i<n;i++){
  cin>>vec[i];
  if(vec[i]>=k) vec[n+1]++;
}
	cout<<vec[n+1]<<endl;
  return 0;
}

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

#define ff first
#define ss second
#define pb push_back
#define sz size()
#define mp make_pair
#ifndef ONLINE_JUDGE 
#include "/home/asif/Codes/Library/debug.h"
#endif
/*--------------------------------------------------------------------*/

const int N = 1e5 + 5;
const int MOD = 1000000007;

ll bigMod(ll p){
  if(p == 0) return 1LL;
  ll ret = bigMod(p / 2);
  ret *= ret;
  ret %= MOD;
  if(p & 1) ret = (ret * 2) % MOD;
  return ret;
}

map< pii, ll > M;

int main() {

  int n;
  ll x, y, z = 0;
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> x >> y;
    if(x == 0 and y == 0){
      z++;
      continue;
    }
    if(y < 0){
      y = -y;
      x *= -1LL;
    }
    ll d = __gcd(abs(x), abs(y));
    x /= d, y /= d;
    M[{x, y}]++;
  }
  ll ans = 1LL;
  for(auto it : M){
    if(it.ss == 0) continue;
    x = it.ff.ss, y = -it.ff.ff;
    if(M.find({x, y}) == M.end()) {
      ans *= bigMod(it.ss);
      ans %= MOD;
    }
    else {
      ans *= (bigMod(it.ss) + bigMod(M[{x, y}]) - 1);
      ans %= MOD;
      M[{x, y}] = 0;
    }
  }
  ans += z - 1;
  ans %= MOD;
  if(ans < 0) ans += MOD;
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 16076
def gcd(a,b):
	return gcd(b,a%b) if b else a
n = int(input())
a = list(map(int,input().split()))
lcm = 1
for v in a:
	lcm *= v//gcd(v,lcm)
ans = 0
for v in a:
	ans += lcm // v
print(ans%1000000007)

Measured memory_bytes: 4084
def insertionSort(A, n, g):
    cnt = 0
    for i in xrange(g, n):
        v = A[i]
        j = i - g
        while (j >= 0) and (A[j] > v):
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
    return cnt
 
def shellSort(A, n):
    cnt, m, t = 0, 1, n
    while (t-1)/3 > 0:
        t, m = (t-1)/3, m+1
    print m
    G = [1]
    for i in xrange(1,m):
        G.append(1+G[i-1]*3)
    G = list(reversed(G))
    print " ".join( map(str, G) )
    for i in xrange(0, m):
        cnt += insertionSort(A, n, G[i])
    return cnt
 
# MAIN
n = input()
A = [input() for i in xrange(n)]
cnt = shellSort(A, n)
print cnt
for i in range(n):
    print A[i]

Measured memory_bytes: 69820
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc161/tasks/abc161_a>
 問題文============================================================
 A - ABC Swap
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll X,Y,Z; cin >> X >> Y >> Z;
    swap(X,Y); swap(X,Z);
    cout << X << " " << Y << " " << Z << endl;
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n, ans;
	int i, j, k, l;

	while( scanf("%d", &n) != EOF ) {
		ans = 0;
		for( i = 0; i <= 9; i++ ) {
			for( j = 0; j <= 9; j++ ) {
				for( k = 0; k <= 9; k++ ) {
					for( l = 0; l <= 9; l++ ) {
						if( i + j + k + l == n )
							ans ++;
					}
				}
			}
		}
		printf("%d\n", ans);
	}
	

	return 0;
}

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

int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];

    ll cnt[200005];
    rep(i, 200005) cnt[i] = 0;
 
    rep(i, N){
        cnt[A[i]]++;
    }

    ll comb = 0;
    rep(i, 200005){
        if(cnt[i] >= 2){
            ll ans = cnt[i] * (cnt[i] - 1) / 2;
            comb += ans;
           // cout << comb << " ";
        }
    }
    // cout << endl;

    rep(i, N){
        cout << comb - cnt[A[i]] + 1 << endl;
    }
    // cout << comb - cnt[A[N-1]] + 1 << endl;

    return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	int k;
	cin >> k;
	int n[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	
	cout << n[k-1] << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
bool rev(long long int a,long long int b)
{
    if(a>b)return true;
    else return false;
}
bool compa(pair<string,pair<int,int>>a,pair<string,pair<int,int>>b)
{
    if(a.first==b.first)
    {
        if(a.second.first>b.second.first)
        return true;
        else
        return false;
    }
    if(a.first<b.first)
    return true;
    else 
    return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    string s;
    cin>>s;
    long long int k;
    cin>>k;
    long long int i=0;
    while(s[i]=='1'){k--;i++;} 
    if(k>0)
    cout<<s[i];
    else
    cout<<1<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


Measured memory_bytes: 3628
#include <iostream>

using namespace std;

int main () {
  int N, K, ans=0, x;
  cin >> N >> K;
  for (int i=0; i<N; i++) {
    cin >> x;
    ans += min (x, K-x) * 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
s = list(range(1,14))
h = list(range(1,14))
c = list(range(1,14))
d = list(range(1,14))

n = int(input())
while n > 0:
    x = input().split(' ')
    x[1] = int(x[1])
    if x[0] == 'S':
        s[x[1]-1] = 0
    elif x[0] == 'H':
        h[x[1]-1] = 0
    elif x[0] == 'C':
        c[x[1]-1] = 0
    elif x[0] == 'D':
        d[x[1]-1] = 0
    n -= 1

for t in s:
    if t != 0: print("S %d" % t)
for t in h:
    if t != 0: print("H %d" % t)
for t in c:
    if t != 0: print("C %d" % t)
for t in d:
    if t != 0: print("D %d" % t)

Measured memory_bytes: 7692
#include <bits/stdc++.h>
#define int long long

using namespace std;
int mod=1e9+7;
int fac[100005];

int modInverse(int a, int m)
{
    int m0 = m;
    int y = 0, x = 1;

    if (m == 1)
        return 0;

    while (a > 1)
    {
        // q is quotient
        int q = a / m;
        int t = m;

        // m is remainder now, process same as
        // Euclid's algo
        m = a % m, a = t;
        t = y;

        // Update y and x
        y = x - q * y;
        x = t;
    }

    // Make x positive
    if (x < 0)
        x += m0;

    return x;
}

int compute(int a,int b)
{
    if(a<b)
        return 0;
    int z=(fac[b]*fac[a-b])%mod;
    z=modInverse(z,mod);
    z=fac[a]*z;
    z%=mod;
    return z;
}

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

    fac[0]=1;
    for (int i = 1; i <=n+1 ; ++i) {
        fac[i]=(fac[i-1]*i)%mod;
    }

    int a[n+2];
    int mm[n+2]={0};
    int ind1,ind2;
    n++;
    for (int i = 1; i <=n ; ++i) {
        cin>>a[i];
        if(mm[a[i]])
        {
            ind1=mm[a[i]];
            ind2=i;
        }
        mm[a[i]]=i;
    }

    for (int j = 1; j <=n ; ++j) {
        int ans=(compute(n,j)-compute(n-(ind2-ind1+1),j-1)+mod)%mod;
        cout<<ans<<"\n";
    }
}

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

int main() {
	int L, R, d, ans = 0;
	scanf("%d%d%d", &L, &R, &d);
	for(int i = 1; i <= 100; ++i) {
		if(L <= i * d && i * d <= R) ++ ans;
	}
	cout << ans;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define int long long

signed main(){
	int k, n;
	cin >> k >> n;
	int a[n], an[n];
	cin >> a[0];
	for (int i = 1; i < n; i++){
		cin >> a[i];
		an[i] = a[i] - a[i - 1];
	}
	an[0] = (k - a[n - 1] + a[0]);
	int mx = 0, su = 0;
	for (int i = 0; i < n; i++){
		su += an[i];
		mx = max(an[i], mx);
	}
	cout << su - mx;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		String op = sc.next();
		int B = sc.nextInt();
		if(op.equals("+")) {
			System.out.println(A + B);
		} else if(op.equals("-")) {
			System.out.println(A - B);
		}
	}
}


Measured memory_bytes: 21972
using System;
using System.IO;

namespace AizuOnline
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var H = new int[1000];
            var W = new int[1000];
            var i = 0;

            while (true)
            {
                var x = Console.ReadLine().Split(' ');

                H[i] = Convert.ToInt32(x[0]);
                W[i] = Convert.ToInt32(x[1]);
                if (H[i] == 0)
                {
                    break;
                }
                i++;
            }

            for (int m = 0; m < H.Length && H[m] != 0; m++)
            {
                for (int k = 0; k < H[m]; k++)
                {
                    for (int j = 0; j < W[m]; j++)
                    {
                        if (k % 2 == 0 && j % 2 == 0 || k % 2 == 1 && j % 2 == 1)
                        {
                            Console.Write("#");
                        }
                        else
                        {
                            Console.Write(".");
                        }
                    }
                    Console.WriteLine();
                }
                Console.WriteLine();
            }

            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 9080
import sys
if sys.platform in ['ios', 'win32', 'darwin']:
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(x) for x in input().split()]

H, W = MAP()
# M = [[0]*W for _ in range(H)]
# # print(M)

# MOVE = [-1,-1],[-1,0],[-1,1],[0,-1],[0,0],[0,1],[1,-1],[1,0],[1,1]

# for h in range(H):
# 	for w in range(W):
# 		for dh, dw in MOVE:
# 			nh = h + dh
# 			nw = w + dw
# 			if nh<0 or nh>H-1 or nw<0 or nw>W-1:
# 				continue
# 			#print(nh, nw)
# 			M[nh][nw] += 1

# ans = 0
# for m in M:
# 	for mm in m:
# 		if mm%2: ans+=1
# print(ans)

if H==1 and W==1:
	print(1)
else:
	cards = H*W
	if min(H,W) >= 2:
		edges = (H+W)*2-4
	else:
		edges = 2

	edges = (H+W)*2-4 if min(H,W) >= 2 else 0 if H==0 and W== 0 else 2 if min(H,W) == 1 else 0
	#print(cards, edges)
	print(cards-edges)

Measured memory_bytes: 38384
#include <cstdio>

int h, w, dx[] = {0,0,-1,1}, dy[] = {1,-1,0,0};
long long a, b, ans;
char s[405][405], t;

void dfs(int x, int y){
  char t;
  ((t = s[x][y]) == '#' ? a : b)++;
  s[x][y] = 0;
  for(int i = 0; i < 4; i++) if((s[x+dx[i]][y+dy[i]] | t) > t) dfs(x+dx[i], y+dy[i]);
}

int main(){
  scanf("%d %d\n", &h, &w);
  for(int i = 1; i <= h; i++){scanf("%s", s[i]+1);s[i][w+1] = 0;}
  for(int i = 1; i <= h; i++) for(int j = 1; j <= w; j++)
    if(s[i][j]) a = b = 0, dfs(i,j), ans += a*b;
  printf("%lld\n", ans);
}


Measured memory_bytes: 7808
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;


public class Main {

    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int n = s.nextInt(),k=s.nextInt();
        int arr[] = new int[n];
        for(int i=0;i<n;i++)arr[i]=s.nextInt();
        Arrays.sort(arr);
        int i=0,sum=0;
        while(k--!=0)sum+=arr[i++];
        System.out.println(sum);

    }
}




class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(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
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

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


}

Measured memory_bytes: 25860
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
    
    ll m,d;
    cin>>m>>d;
    ll ans=0;
    ll tens,ones;
    for(ll i=20;i<=d;i++)
    {
        tens=i/10;
        ones=i%10;
        tens*=ones;
        if(tens<=m && ones>=2)
        {
            ans++;
        }
    }
    cout<<ans;
    return 0;
}

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

#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
//

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > ii;
#define sz(a) int((a).size())
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(typeof((c).begin() i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())

//main function here

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n-1;i++)
        cin>>a[i];
    ll sum=a[0];
    for(int i=0;i<n-2;i++)
    {
        //cout<<sum<<"\n";
        sum+=min(a[i],a[i+1]);
    }
    //cout<<a[n-2]<<" ";
    sum+=a[n-2];  
    cout<<sum<<"\n";
  return 0;
 }


Measured memory_bytes: 256
k,n,*a=map(int,open(0).read().split())
dist=10**7
for i in range(n):
    if i==0:
#        print(a[-1]-a[0])
        dist=min(dist,a[-1]-a[0])
    else:
#        print(a[-1+i]+k-a[i])
        dist=min(dist,a[-1+i]+k-a[i])
print(dist)

Measured memory_bytes: 31632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int i,j,n,k;
	int a[100009];
	cin>>n>>k;
	int dp[k+1];
	for(i=0;i<n;i++)
		cin>>a[i];
	for(i=0;i<=k;i++)
	{
		//for(j=0;j<n;j++)
		dp[i]=0;	//lost
	}
	for(i=a[0];i<=k;i++)
	{
		int flag=0;
		for(j=0;j<n;j++)
		{
			if(i-a[j]>=0 && dp[i-a[j]]==0)
			{
				//flag=1;
				dp[i]=1;
			}
		}		
	}
	//for(i=0;i<=k;i++)
	//	cout<<dp[i]<<endl;
	if(dp[k]==1)
		cout<<"First\n";
	else
		cout<<"Second\n";
	return 0;

}


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

#define all(x) x.begin(),x.end()
#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd+nd+1)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline LL read(){
    LL res=0, f=1;char ch=getchar();
    while(ch<'0'|ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200'005;

const int MOD = 1000000007;

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

template<typename T>
void chmin(T& a, T b){if(a>b)a=b;}

template<typename T>
void chmax(T& a, T b){if(b>a)a=b;}

LL n;

LL sz[MAXN], sum[MAXN], ans[MAXN];
LL col[MAXN];

#define go(e,u) for(int e=head[u];e;e=Next[e])
int to[MAXN<<1],Next[MAXN<<1],head[MAXN],tol;

void add_edge(int u,int v){
    Next[++tol]=head[u];to[tol]=v;head[u]=tol;
    Next[++tol]=head[v];to[tol]=u;head[v]=tol;
}

LL calc(LL x){return x*(x+1)/2;}

void dfs(int u,int f){
    int c=col[u];
    sz[u]=1;LL o=sum[c];
    go(e,u){
        int v=to[e];
        if(v==f)continue;
        LL t=sum[c];
        dfs(v,u);
        ans[c]-=calc(sz[v]-(sum[c]-t));
        sz[u]+=sz[v];
    }
    sum[col[u]]=o+sz[u];
}

int main(){
    n=read();
    for(int i=1;i<=n;++i)col[i]=read(),ans[i]=n*(n+1)/2;

    for(int i=1,u,v;i<n;++i){
        u=read();
        v=read();
        add_edge(u,v);
    }

    dfs(1,0);

    for(int i=1;i<=n;++i){
        LL t=n-sum[i];
        ans[i]-=calc(t);
        cout<<ans[i]<<endl;
    }

    return 0;
}



Measured memory_bytes: 35544
N,M=map(int,input().split())
x=[list(map(int,input().split())) for i in range(N)]
x.sort()
tmp,ans=0,0
for i in range(N):
    if tmp+x[i][1]<M:
        tmp+=x[i][1]
        ans+=x[i][0]*x[i][1]
    else:
        ans+=(M-tmp)*x[i][0]
        break
print(ans)

Measured memory_bytes: 27756
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<limits>
#include<iomanip>
#include<cmath>
#include<climits>
using namespace std;

typedef long long ll;
typedef string S;
typedef pair<int,int> P;
typedef vector<int> vi;
const int mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    cout << ((n+1)/2>=k?"YES":"NO") << endl;
    return 0;
}

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

int main(void)
{
    long long N, A, B;
    cin >> N >> A >> B;

    long long cnt = (N / (A + B)) * A;
    long long amari = (N % (A + B));
    if (amari < A)
    {
        cnt += amari;
    }
    else if (amari > A)
    {
        cnt += A;
    }

    cout << cnt;

    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
import sys
readline = sys.stdin.readline
read = sys.stdin.read

x,k,d = map(int,read().split())

if x < 0: x = -x

q,r = x//d,x%d

if q >= k:
    print(x-k*d)
else:
    k -= q
    if k%2==0:
        print(r)
    else:
        print(abs(r-d))
    
    




Measured memory_bytes: 9188
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
#define forit(it, st) for(auto it : st)
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
const int days[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int toint(double a){
	return a * 1.08;
}
void solve(){
	double n;
	cin >> n;
	int stn = n;
	n /= 1.08;
	int xx = n;
	int yy = n + 1;
	n = stn;
	if(toint(xx) == n) cout << xx;
	else if(toint(yy) == n) cout << yy;
	else cout << ":(";

}	

 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<fstream>

using namespace std;

int main(){
	int n=0;
	int m=0;
	int a[100];
	int i=0;
	int j=0;
	int s=0;
	int b[2];
	int h=0;
	
	for(i=0;i<100;i++){
		a[i]=0;
	}
	cin>>n;
	cin>>m;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<m;i++){
		for(j=0;j<n-1;j++){
			b[0]=a[j]%(i+1);
			b[1]=a[j+1]%(i+1);
			if(b[0]>b[1]){
				h=a[j];
				a[j]=a[j+1];
				a[j+1]=h;
			}
		}
	}
	for(i=0;i<n;i++){
		cout<<a[i]<<endl;
	}
}

Measured memory_bytes: 3084
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <bitset>

using namespace std;
typedef long long ll;

int main() {
	ll N, A, B; cin >> N >> A >> B;
	if (B % 2 == A % 2) {
		cout << (B - A) / 2 << endl;
		return 0;
	}

	ll x = 0, y = 0;
	{
		ll a = A, b = B;
		ll k = a - 1;
		x += k;
		a = 1;
		b -= k;
		if (b % 2 == 0) { b--; x++; }
		x += (b - a) / 2;
	}
	{
		ll k = N - B;
		y += k;
		B = N;
		A += k;
		if (A % 2 != N % 2) { A++; y++; }
		y += (B - A) / 2;
	}

	cout << min(x, y) << endl;

	return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  map<string, int> mp;
  rep(i, n) {
    string ss = s[i];
    map<char, int> tmp;
    for (char c : ss) {
      tmp[c]++;
    }
    string key = "";
    for (auto t : tmp) {
      key += t.first;
      key += to_string(t.second);
    }
    mp[key]++;
  }
  ll anaCount = 0;
  for (auto m : mp) {
    ll cnt = m.second;
    if (cnt == 1) {
      continue;
    }
    anaCount += (cnt * (cnt - 1) / 2);
  }
  cout << anaCount << endl;

  return 0;
}


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

using namespace std;

int main() {
    // Input
    int N, M;
    vector<int> A;

    cin >> N >> M;
    A = vector<int>(M);
    for (int i = 0; i < M; i++) cin >> A[i];

    // Process
    int sum = accumulate(A.begin(), A.end(), 0);
    int ans = N - sum;
    if (ans < 0) ans = -1;

    // Output
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3584
Sa = list(raw_input())
Sb = list(raw_input())
Sc = list(raw_input())

player = "A"
while True:
    if player == "A":
        if Sa:
            player = Sa.pop(0).upper()
        else:
            break
    elif player == "B":
        if Sb:
            player = Sb.pop(0).upper()
        else:
            break
    elif player == "C":
        if Sc:
            player = Sc.pop(0).upper()
        else:
            break
        
print player

Measured memory_bytes: 2568
/*Name:- Prince Soni
College:- Jalpaiguri Government Engineering College*/

// this is how we declare a constant value
// const int xyz=2500000;


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

#define ll long long int
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define fr(i,n) for(ll i=0;i<n;i++)
#define fr1(i,n) for(ll i=1;i<=n;i++)
#define endl "\n"

int h[100005];
int dp[100005];


int min_cost(int n){
    
    if(n<=2)
    return dp[n];
    
    if(dp[n]==-1)
    {
        dp[n]=min(abs(h[n]-h[n-1])+min_cost(n-1),abs(h[n]-h[n-2])+min_cost(n-2));
    }
    return dp[n];
}

int main() 
{ 
    fio;
    int n;
    cin>>n;
    fr1(i,n)
    cin>>h[i];
    memset(dp, -1, sizeof dp);
    dp[0]=0;
    dp[1]=0;
    dp[2]=abs(h[2]-h[1]);
    cout<<min_cost(n);
}

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

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

  bool fl=true;
  for(int i=0; i<n; i++){
    if(b[i]>i+1){
      fl=false;
      break;
    }
  }

  if(!fl)cout<<-1<<endl;
  else{
    vector<int> a;
    while(!b.empty()){
      for(int i=b.size()-1; i>=0; i--){
        if(b[i]==i+1){
          a.push_back(b[i]);
          b.erase(b.begin()+i);
          break;
        }
      }
    }

    for(int i=a.size()-1; i>=0; i--)cout<<a[i]<<endl;    
  }
  
}


Measured memory_bytes: 256
a, b, x = map(int, input().split())

import math

if x <= (a * a * b) / 2:
    theta = math.atan((a * b * b) / (2 * x))
else:
    theta = math.atan((2 * (a * a * b - x)) / (a * a * a))

theta = 360 * theta / (2 * math.pi)    
# theta = theta * (10 ** 7)
# theta = int(theta) + 1
# theta = theta / (10 ** 7)

print(theta)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

int search(vvi &g, vi &flg, int cnt, int rest, int v)
{
    if (flg[v] != 0)
    {
        return cnt;
    }

    if (rest == 0)
    {
        return cnt + 1;
    }

    flg[v] = 1;

    for (int n : g[v])
    {
        cnt = search(g, flg, cnt, rest - 1, n);
    }

    flg[v] = 0;

    return cnt;
}

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

    vvi g(n);
    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vi flg(n);
    fill(flg.begin(), flg.end(), 0);

    cout << search(g, flg, 0, n - 1, 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:200000000")

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define int long long
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp(a, b) make_pair(a, b)
#define ret(a) return cout<<a,0;

using namespace std;

mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}

typedef pair < int , int > pii ;
typedef pair < long long  , long long > pll ;

const int N = 30000 + 1 ;	
int n , m ,  k;
ld a[N];
int sum1 = 0 , sum2 = 0;

main(){
	
	ios::sync_with_stdio(0); cin.tie(0);cout.tie(0);
	string s;
	cin >> n;
	for(int i = 1 ; i <= n; i++)	
		cin >> a[i];
	sort(a + 1, a + 1 + n);
	ld ans1 = a[1] , ans2 = a[n];
	for(int i = 2 ; i <= n ; i++)
		ans1 = (ans1 + (ld)a[i])*0.5L;
	for(int i = n - 1; i > 0 ; i--)
		ans2 = (ans2 +a[i])*0.5L;
	cout << setprecision(9) << fixed << max(ans1,ans2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define upperlimit 1000100
#define INF 1000000100
#define INFL 1000000000000000100
#define eps 1e-8
#define endl '\n'
#define sd(n) scanf("%d",&n)
#define slld(n) scanf("%lld",&n)
#define pd(n) printf("%d",n)
#define plld(n) printf("%lld",n)
#define pds(n) printf("%d ",n)
#define pllds(n) printf("%lld ",n)
#define pdn(n) printf("%d\n",n)
#define plldn(n) printf("%lld\n",n)
#define REP(i,a,b) for(i=a;i<=b;i++)
#define mp make_pair
#define pb push_back
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii>
#define vll vector<pll>
#define tr(container,it) for(typeof(container.begin()) it=container.begin();it!=container.end();it++)
#define F first
#define S second
#define clr(a) memset(a,0,sizeof(a))
using namespace std;
 
ll gcd(ll n1,ll n2){
    if(!n1)return n2;
    if(!n2)return n1;
    if(n1%n2==0)return n2;
    return gcd(n2,n1%n2);
}
ll powmod(ll base,ll exponent){
    base%=mod;
    ll ans=1;
    while(exponent){
        if(exponent&1)ans=(ans*base)%mod;
        base=(base*base)%mod;
        exponent/=2;
    }
    ans%=mod;
    return ans;
}
int main()
{
    int n,a,b;
    
    cin>>n>>a>>b;
    cout<<min(n*a,b)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

const double eps = 1e-8;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

ll powll(ll x, ll n) {
	if (n == 0)
		return 1;
	ll xx = powll(x, n / 2);
	if (n % 2 == 0)
		return xx * xx;
	else
		return xx * xx * x;
}

int main() {
	ll N, P;
	cin >> N >> P;
	ll ans = 1;
	if (N == 1) {
		cout << P << endl;
		return 0;
	}
	for (ll k = 2;true;k++) {
		ll now = powll(k, N);
		if (now > P || N >= 45)
			break;
		while (P % now == 0) {
			P /= now;
			ans *= k;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string s;
    bool good = false;

    cin >> s;
    if (s[0] == s[1])
    {
    }
    else if (s[1] == s[2])
    {
    }
    else if (s[2] == s[3])
    {
    }
    else{
        good=true;
    }

    cout << (good == true ? "Good":"Bad");
}

Measured memory_bytes: 256
#include<stdio.h>
main(){
  int  n, i, R[200000], minv, maxv;
  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%d", &R[i]);
  }
  maxv = R[1]-R[0];
  minv = R[0];
  for(i = 1; i < n; i++){
    if(maxv < R[i]-minv){
      maxv = R[i]-minv;
    }
    if(minv > R[i]){
      minv = R[i];
    }
  }
  printf("%d\n", maxv);
  return 0;
}

Measured memory_bytes: 1380
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<stdio.h>
#include<string>
#include<set>
#include<iomanip>
#include<numeric>
#include<map>
#include<limits>

using namespace std;

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t, num, k,n;
cin >> t;
if (t >= 30)
{
	cout << "Yes";
}
else {
	cout << "No";
}
return 0;
}


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

#define REP(i,n) for(decltype(n) i=0; i<(n); ++i)
#define ALL(c) (c).begin(), (c).end()
#define st first
#define nd second
#define pb push_back

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

struct fenwick {
    fenwick(int n) : size(n), v(n,0) {}
    void add(int n, int x){for(;n<size;n|=n+1)v[n]+=x;}
    int sum(int n){int s=0;while(n>=0){s+=v[n];n=(n&(n+1))-1;} return s;}
    int size;
    vi v;
};

struct line {
    int a,b,c;
};

double intersect(line& l, double x){
    return (-x*l.a+l.c)/l.b;
}

long long count_left(vector<line>& v, double x){
    int cnt = 0;
    vector<pair<double,int>> vec;
    vec.reserve(v.size());
    for(auto& l : v)
        vec.emplace_back(intersect(l,x), cnt++);
    sort(ALL(vec));
    fenwick f(v.size());
    long long ans = 0;
    for(auto& p : vec){
        ans += f.sum(p.second);
        f.add(p.second, 1);
    }
    return ans;
}

double medianx(vector<line>&v){
    long long n = v.size();
    long long tot = n*(n-1)/2;
    tot = (tot+1)/2;
    double l=-1e9,r=1e9;
    for(int i=0;i<90;++i){
        double m=(l+r)/2;
        if(count_left(v,m) < tot)
            l=m;
        else
            r=m;
    }
    return (l+r)/2;
}

void solve(){
    int n;
    cin>>n;
    vector<line> v(n);
    REP(i,n){
        cin>>v[i].a>>v[i].b>>v[i].c;
        if(v[i].b < 0){
            v[i].a = -v[i].a;
            v[i].b = -v[i].b;
            v[i].c = -v[i].c;
        }
    }
    sort(ALL(v), [](line&a, line&b){return a.a*b.b>a.b*b.a;});
    double x = medianx(v);
    for(auto& p : v)
        swap(p.a, p.b);
    REP(i,n)
        if(v[i].b < 0){
            v[i].a = -v[i].a;
            v[i].b = -v[i].b;
            v[i].c = -v[i].c;
        }
    sort(ALL(v), [](line&a, line&b){return a.a*b.b>a.b*b.a;});
    double y = medianx(v);
    cout<<setprecision(15)<<fixed<<x<<' '<<y<<'\n';
}

int main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    solve();
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
using namespace std;
 
int main() {
 int x, y;
 cin >> x >> y;
 if (x == 1) {
   x = 14;
 }
 if (y == 1) {
   y = 14;
 }
 if (x > y) {
   cout << "Alice";
 }
  else if (y > x) {
   cout << "Bob";
  }
  else {
    cout << "Draw";
  }
}

Measured memory_bytes: 3624
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>

using namespace std;

//typedefリスト
typedef vector<int> vint;
typedef vector<string> vstr;


int main(void) {
	int a, b,bn,ans;
	ans = 0;
	bn = 0;
	cin >> a >> b;
	for (int i = 1; i <= 100; i *= 10) {
		if (b / i >= 1)bn++;
	}
	for (int i = 0; i < bn; i++) {
		a *= 10;
	}
	for (int i = 0; i < 100100; i++) {
		if (a + b == i * i)ans = 1;
	}
	if (ans == 1)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

using namespace std;

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

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


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

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

		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();
		// ポイントの初期化
		Map<Integer, Integer> pointMap = new HashMap<Integer, Integer>();
		for (int i = 1; i <= n; i++) {
			pointMap.put(i, 0);
		}

		int x = 0;
		for (int i = 1; i <= q; i++) {
			x = sc.nextInt();
			pointMap.put(x, pointMap.get(x) + 1);
		}

		// 答えの出力
		for (int i = 1; i <= n; i++) {
			if (k - q + pointMap.get(i) > 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
		sc.close();
	}
}


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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int N; cin >> N;
    map<string, int> str;
    rep(i, N) {
        string s; cin >> s;
        str[s]++;
    }
    int M; cin >> M;
    rep(i, M) {
        string t; cin >> t;
        str[t]--;
    }
    int ans = 0;
    for (auto i : str) {
        ans = max(ans, i.second);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n,m;cin>>n>>m;
  vector<ll>G[n];
  vector<ll>inG[n];
  vector<ll>in(n,0);
  vector<ll>topo;

  rep(i,m){
    ll a,b;cin>>a>>b;
    G[--a].push_back(--b);
    inG[b].push_back(a);
    in[b]++;
  }

  queue<ll>que;
  rep(i,n)if(in[i]==0)que.push(i);

  while(!que.empty()){
    ll u=que.front();
    que.pop();
    topo.push_back(u);
    for(auto v : G[u]){
      in[v]--;
      if(in[v]==0)que.push(v);
    }
  }

  // cout<<topo<<endl;
  vector<ll>ans(n,0);

  reverse(all(topo));
  for(auto u : topo){
    for(auto v : inG[u])chmax(ans[v],ans[u]+1);
  }

  cout<<*max_element(all(ans))<<endl;

  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 13688
fun main() {
  val X = readInts().sorted().dropLast(1)
  println(X.sum())
}

fun gcd(a: Int, b: Int): Int = if (a < b) gcd(b, a) else if (b == 0) a else gcd(b, a % b)
fun gcd(a: Long, b: Long): Long = if (a < b) gcd(b, a) else if (b == 0L) a else gcd(b, a % b)
fun lcm(a: Int, b: Int): Int = (a * b) / gcd(a, b)
fun lcm(a: Long, b: Long): Long = (a * b) / gcd(a, b)

fun readString() = readLine()!!
fun readStrings() = readLine()!!.split(" ")
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readInts() = readLine()!!.split(" ").map { it.toInt() }
fun readLongs() = readLine()!!.split(" ").map { it.toLong() }


Measured memory_bytes: 39024