akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
	int x,y;
	while(1){
		scanf("%d %d",&x,&y);
		if(x == 0 && y == 0){
			break;
		}
		if(x<y){
			printf("%d %d\n",x,y);
		}
		else{
			printf("%d %d\n",y,x);
		}
	}
	return 0;
}

Measured memory_bytes: 600
import numpy as np

N = int(input())

inp = map(int,input().split(' '))

A = [0] + [int(i) for i in inp] + [0]
s = np.sum(np.abs(np.diff(A,n=1)))

for j in range(1,N+1):
    df = np.abs(A[j+1]-A[j-1]) - np.abs(A[j]-A[j-1]) - np.abs(A[j+1]-A[j])
    print(int(s+df))

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

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while (true){
            String line = br.readLine();
            String[] ln = line.split(" ");
            int H = Integer.parseInt(ln[0]);
            int W = Integer.parseInt(ln[1]);
            if (H==0 && W==0) break;
            for (int j=0; j<H; j++){
                if (j%2==0){
                    for (int i=0; i<W; i++){
                        if (i%2==0) sb.append("#");
                        else sb.append(".");
                    }
                }else{
                    for (int i=0; i<W; i++){
                        if (i%2==0) sb.append(".");
                        else sb.append("#");
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        StringBuilder k = new StringBuilder(100);
        System.out.print(k);
        System.out.print(sb);
    }
}

Measured memory_bytes: 21188
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)

int32_t N,K;
int32_t memo[2001][2001];//黒の始点,x,y

template<typename T>void imos2d(int32_t x, int32_t y, int32_t x2, int32_t y2, T& arr)
{
	++arr[x][y];
	--arr[x][y2];
	--arr[x2][y];
	++arr[x2][y2];
}
void imos(int32_t x, int32_t y, int32_t x2, int32_t y2)
{
	imos2d(x, y, x2, y2, memo);
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N>>K;
	for (size_t i = 0; i < N; i++)
	{
		int32_t x, y; char c;
		in >> x >> y>>c;
		x %= 2*K; y %= 2*K;

		if (((x < K && y < K) || (x >= K && y >= K)) == (c == 'B'))
		{
			auto x_ = x % K, y_ = y % K;
			//++memo[0][0]; --memo[x_ + 1][y_ + 1];
			imos(0, 0, x_ + 1, y_ + 1);
			imos(x_ + K + 1, 0, 2 * K, y_ + 1);

			imos(0, y_ + K + 1, x_ + 1, 2 * K);
			imos(x_ + K + 1, y_ + K + 1, 2 * K, 2 * K);

			imos(x_ + 1, y_ + 1, x_ + K + 1, y_ + K + 1);
		}
		else
		{
			auto x_ = x % K, y_ = y % K;
			//++memo[x_ + 1][y_ + 1]; --memo[x_ + K + 1][y_ + K + 1];

			imos(x_ + 1, 0, x_ + K + 1, y_ + 1);
			imos(x_ + 1, y_ + K + 1, x_ + K + 1, 2 * K);

			imos(0, y_ + 1, x_ + 1, y_ + K + 1);
			imos(x_ + K + 1, y_ + 1, 2 * K, y_ + K + 1);
		}
	}

	for (size_t i = 0; i < 2001; i++)
		for (size_t j = 1; j < 2001; j++)
	{
			memo[i][j] += memo[i][j - 1];
	}
	for (size_t i = 1; i < 2001; i++)
		for (size_t j = 0; j < 2001; j++)
	{
		memo[i][j] += memo[i - 1][j];
	}

	int32_t max = 0;
	for (size_t i = 0; i < 2 * K; i++)
		for (size_t j = 0; j < 2*K; j++)
		{
			max = std::max(max, memo[i][j]);
		}
	out << max << endl;

	return 0;
}
#endif


Measured memory_bytes: 15872
#include <iostream>
#include <vector>
#include <algorithm>

constexpr int INF = 1145141919;

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

    int N, M, C;
    std::cin >> N >> M >> C;

    std::vector<std::vector<int>> A(N, std::vector<int>(M));
    std::vector<int> B(M);

    for(int i=0; i<M; i++){
        std::cin >> B.at(i);
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<M; j++){
            std::cin >> A.at(i).at(j);
        }
    }

    int count=0;
    for(int i=0; i<N; i++){
        int buf=C;
        for(int j=0; j<M; j++){
            buf = buf + A[i][j]*B[j];
        }
        if(buf>0){
            count++;
        }
    }

    std::cout << count;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <algorithm>
using namespace std;
int main() {
    int n,cnt=0,a,b;
    cin>>a>>b;
    for(int i=a;i<=b;i++)
    {
        string t=to_string(i);
        string t2=t;
        reverse(t2.begin(),t2.end());
       // cout<<i<<" "<<t<<" "<<t2<<endl;11009 11332
        if(t==t2) cnt++;
    }
    cout<<cnt<<endl;
    return 0;
}

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

int main()
{
  float a,b,x;
  cin>>a>>b>>x;
  float v=a*a*b;
  float s=a*b;
  float y=x/a;
  float tan;
  float ans;
  if(v>=2*x){
    tan=b*b/(2*y);
    ans=atan(tan);
    ans=ans*180/3.14159265358979;
  }
  else{
    y=s-y;
    tan=2*y/(a*a);
    ans=atan(tan);
    ans=ans*180/3.1415926535;
  }
  cout<<setprecision(7)<<ans<<endl;
}


Measured memory_bytes: 256
// Problem : C - 755
// Contest : AtCoder - AtCoder Beginner Contest 114
// URL : https://atcoder.jp/contests/abc114/tasks/abc114_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
int cnt=0;
ll n;
inline bool check(ll val)
{
unordered_set<ll> s;
		while(val>0)
		{
			s.insert(val%10);
			val/=10;
		}
return (sz(s)==3)?1:0;
}
		
void dfs(ll val)
{
	if(val>n)
	return;
	else
	{
		cnt+=check(val)?1:0;
		dfs(val*10+3);
      	dfs(val*10+5);
        dfs(val*10+7);
	}
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	cin>>n;
	dfs(0);
	cout<<cnt<<nl;
}
// read the question correctly (ll vs int)
// template by bqi343

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    long double s = 0;
    vector<int> a(n);
    for(auto &x : a)
        cin >> x, s+=(long double)x;
    s/=(long double)(4*m);
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    for(int i=0; i<m; i++){
        if((long double)a[i]<s){
            return cout << "No", 0;
        }
    }
    cout << "Yes";
    return 0;
}


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

int main(void) {
  string s, t;
  cin>>s>>t;
  int ss=s.size();
  int st=t.size();
  bool f=true;
  for(int i=ss-1; i>=st-1; i--) {
    for(int j=0; j<st; j++) {
      if(s[i-j]!=t[st-j-1] and s[i-j]!='?') {
	f=false;
      }
    }
    if(f) {
      for(int j=0; j<st; j++) {
	s[i-j] = t[st-j-1];
      }
      for(int j=0; j<ss; j++)
	if(s[j]=='?') s[j] = 'a';
      cout<<s<<endl;
      return 0;
    }
    f=true;
  }
  cout<<"UNRESTORABLE"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MT make_tuple
#define PB push_back
typedef long long ll;

int N;
ll a, b, x=1, y=1;

int main () {
        cin >> N;
        fo(i, 0, N) {
                cin >> a >> b;
                ll n = max((y + b - 1) / b, (x + a - 1) / a);
                assert(n*a >= x);
                assert(n*b >= y);
                x = n * a, y = n * b;
        }
        cout << x + y << endl;
        return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int main() {
    int arr[100001];
    long long int n,i,x,sum=0,cnt=0,rem,value=0,max=-1;
    scanf("%lld%lld",&n,&x);
    for(i=0;i<n;i++){
        scanf("%d",&arr[i]);
    }
    
    for(i=0;i<n;i++){
        sum+=arr[i];
            cnt=i+1;
    }
    rem=x-sum;
    for(i=0;i<n;i++){
        value=rem/arr[i];
        if(value>max){
            max=value;
        }
    }
    printf("%lld",cnt+max);
    return 0; 
    }

Measured memory_bytes: 1708
main :: IO ()
main = do
    [n, k] <- fmap (map read . words) getLine     :: IO [Int]
    ws     <- fmap (map read . lines) getContents :: IO [Int]
    let sumW = sum ws
        minP = sumW `div` k - 1
        maxP = sumW
    print $ solve n k ws minP maxP

solve :: Int -> Int -> [Int] -> Int -> Int -> Int
solve n k ws minP maxP = mlc minP maxP
  where
    mlc row high
        | (high - row) == 1 = high
        | c < n             = mlc mid high
        | otherwise         = mlc row mid
      where
        c   = lc ws mid 1 0 0
        mid = (high + row) `div` 2

    lc []     p track loaded total = total
    lc (x:xs) p track loaded total
        | total == n = total
        | track > k  = total
        | otherwise  =
            if (loaded + x) > p then
                lc (x:xs) p (track + 1) 0 total
            else
                lc xs p track (loaded + x) (total + 1)



Measured memory_bytes: 48172
import java.util.*;

public class Main {

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

    int i;
    int j;

    for (i = 0; i < s.length(); i++) {
      if (s.charAt(i) == 'A') break;
    }

    for (j = s.length()-1; j >= 0; j--) {
      if (s.charAt(j) == 'Z') break;
    }

    System.out.println(j-i+1);

  }

}


Measured memory_bytes: 28700
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int R = sc.nextInt();
        
        if(N >= 10) {
            System.out.println(R);
        }else {
            System.out.println(R + (100 * (10 - N)));
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    string n;
    cin>>n;
    if ((n[0]==n[1] && n[1]==n[2]) || (n[1]==n[2] && n[2]==n[3]))
        cout<<"Yes\n";
    else
        cout<<"No\n";
}

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

count = 0

for i in range(n):
  d1, d2 = map(int, input().split())
  if d1 == d2:
    count += 1
  else:
    count = 0
  if 3 <= count:
    s = 'Yes'
    break
  else:
    s = 'No'

print(s)

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

using namespace std;

int main()
{
    //freopen("input.txt", "r", stdin);

    string s;

    cin >> s;

    if(s[s.length()-1] == 's')
    {
        s += "es";
    }
    else{
        s += "s";
    }


cout << s << endl;




    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define MAXN 200100
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define in_range(x, y, n) (x >= 0 and x < n and y >= 0 and y < n)
using namespace std;
const ll mod = 1e9 + 7;
ll memo[MAXN];



int main() {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;

    for (int i=0; i< (int)s.size(); i++){
        if (s[i] == ',') cout << " ";
        else cout << s[i];
    }
    cout << endl;
    return 0;
}

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

int main () {
  vector<int> vec(5);
  for (int i = 0; i < 5; i++) {
    cin >> vec.at(i);
  }
  
  if (vec.at(0) == 0) {
    cout << 1 << endl;
  }  
  
  else if (vec.at(1) == 0) {
    cout << 2 << endl;
  }
  
  else if (vec.at(2) == 0) {
    cout << 3 << endl;
  }
  
  else if (vec.at(3) == 0) {
    cout << 4 << endl;
  }
  
  else if (vec.at(4) == 0) {
    cout << 5 << endl;
  }
}

Measured memory_bytes: 3568
import java.util.Arrays;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] pasta = new int[3];
		int[] juice = new int[2];
		
		pasta[0] = sc.nextInt();
		pasta[1] = sc.nextInt();
		pasta[2] = sc.nextInt();
		juice[0] = sc.nextInt();
		juice[1] = sc.nextInt();
		Arrays.sort(pasta);
		Arrays.sort(juice);
		System.out.println(pasta[0] + juice[0] - 50);
 	}

}

Measured memory_bytes: 17176
#include <bits/stdc++.h>
#define ll long long
#define maxn 100005 /*rem*/
#define mod 998244353
#define db double
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define pi pair<int, int>
#define fi first
#define se second
using namespace std;
int n, m, v, p;
int a[maxn];
int b[maxn];
bool check(int pl) {
	int ns = a[pl] + m;
	vector<ll> b;
	for (int i = 1; i <= n; i++)
		if (i == pl) continue;
		else 
			b.pb(ns - a[i]);
	sort(b.begin(), b.end());
	for (int i = 0; i < p - 1; i++)
		b[i] += 1e10;
	sort(b.begin(), b.end());
	if (b[0] < 0) return 0;
	ll sum = 0;
	for (int i = 0; i < b.size(); i++)
		sum += b[i]; 
//		cout << b[i] << ' ';
	ll nv = v - 1;
	if (sum < 1ll * m * nv) return 0;
	for (int i = b.size() - 1; i >= 0; i--) {
		sum -= b[i];
		nv--;
		if (sum < 1ll * m * nv) return 0;
	}
	return 1;
}
int main() {
	cin >> n >> m >> v >> p;
	for (int i = 1; i <= n; i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + n + 1);
	int l = 1, r = n;
	while (l < r) {
		int mid = (l + r) >> 1;
		if (check(mid)) r = mid;
		else l = mid + 1;
	}
	cout << n - l + 1 << endl;
	return 0;
}


Measured memory_bytes: 2508
#include <iostream>

using namespace std;

int main(){
  int N, mod;
  cin >> N;
  mod = N%10;
  if(mod == 2 || mod == 4 || mod == 5 || mod == 7 || mod == 9) cout << "hon" << endl;
  else if(mod == 3) cout << "bon" << endl;
  else cout << "pon" << endl; 
  return 0;
}


Measured memory_bytes: 3624
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const long long inf = 1LL << 62;
int main() {
	int N;
	cin >> N;
	vector<int> A(N), B(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i] >> B[i];
	}
	vector<int> rank(2 * N);
	for (int i = 0; i < 2 * N; ++i) rank[i] = i;
	sort(rank.begin(), rank.end(), [&](int i, int j) {
		int v1 = (i < N ? A[i] : B[i - N]);
		int v2 = (j < N ? A[j] : B[j - N]);
		return v1 < v2;
	});
	vector<int> bit(N);
	long long sum = 0;
	for (int i = 0; i < N; ++i) {
		bit[rank[i] % N] |= 1 << (rank[i] / N);
		sum += (rank[i] < N ? A[rank[i]] : B[rank[i] - N]);
	}
	vector<int> c(4);
	for (int i = 0; i < N; ++i) {
		++c[bit[i]];
	}
	if (c[0] >= 1 || c[1] == 0 || c[2] == 0) {
		cout << sum << endl;
	}
	else {
		vector<int> irank(2 * N);
		for (int i = 0; i < 2 * N; ++i) irank[rank[i]] = i;
		long long delta = inf;
		for (int i = 0; i < 2 * N; ++i) {
			if (irank[i] >= N) {
				int tar = rank[N - 1];
				if (abs(i - tar) == N) {
					tar = (N == 1 ? -1 : rank[N - 2]);
				}
				if (tar != -1) {
					delta = min(delta, (long long)(i < N ? A[i] : B[i - N]) - (long long)(tar < N ? A[tar] : B[tar - N]));
				}
			}
		}
		if (c[1] == 1) {
			int ptr = find(bit.begin(), bit.end(), 1) - bit.begin();
			delta = min(delta, (long long)(B[ptr] - A[ptr]));
		}
		if (c[2] == 1) {
			int ptr = find(bit.begin(), bit.end(), 2) - bit.begin();
			delta = min(delta, (long long)(A[ptr] - B[ptr]));
		}
		cout << sum + delta << endl;
	}
	return 0;
}

Measured memory_bytes: 2944
n, x = map(int, input().split())
l = list(map(int, input().split()))
d = 0
count = 0
flg = True
for lx in l:
    if d <= x:
        count += 1
        d = d + lx
    else:
        flg = False
        break
if d <= x:
    count +=1
print(count)

Measured memory_bytes: 38256
#include <iostream>

int main(void){
  int n, i;
  char c;
  std::cin >> n;
  for(i = 0; i < n; i++){
    std::cin >> c;
    if(c == 'Y'){
      std::cout << "Four" << std::endl;
      return 0;
    }
  }
  std::cout << "Three" << std::endl;
  return 0;
}

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

int main(){
  cin.tie(0);
 	ios::sync_with_stdio(false);
  int n, b, k, q, query, i, m;
  cin >> n;
  bitset<64> x(0), mask[k];
  for(int i = 0; i < n; i++){
    cin >> k;
    for(int j = 0; j < k; j++){
      cin >> b;
      mask[i][b] = 1; 
    }
  }
  cin >> q;
  for(int j = 0; j < q; j++){
    cin >> query >> m;
    switch(query){
      case 0:
        i = m;
        cout << x[i] << "\n";
        break;
      case 1:
        x |= mask[m];
        break;
      case 2:
        x &= ~mask[m];
        break;
      case 3:
        x ^= mask[m];
        break;
      case 4:
        cout << ((x & mask[m]) == mask[m]) << "\n";
        break;
      case 5:
        cout << (x & mask[m]).any() << "\n";
        break;
      case 6:
          cout << (x & mask[m]).none() << "\n";
        break;
      case 7:
        cout << (x & mask[m]).count() << "\n";
        break;
      case 8:
        cout << (x & mask[m]).to_ulong() << "\n";
        break;
    }
  }
  return 0;
}



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

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int a[200];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++)	
	{
		cin >> a[i];
	}
	int cnt = 0;
	for(int i = 1; i <= n; i ++)
	{
		if(a[i] == a[i - 1])
			a[i] = 2000,
			cnt ++;
	}
	cout << cnt;



	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

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

int n, m;
int X, Y;
int main(){
    int maxx = -105;
    int miny = 105;
    int x, y;
    scanf("%d%d%d%d", &n, &m, &X, &Y);
    for(int i = 0; i< n; i++){
        scanf("%d", &x);
        if(x>maxx) maxx = x;
    }
    for(int i = 0; i< m; i++){
        scanf("%d", &y);
        if(y<miny) miny = y;
    }
    bool war = min(Y, miny) - max(maxx, X) > 0;
    if(war)printf("No War");
    else printf("War");
    return 0;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define co(n) cout<<n<<endl
using namespace std;
typedef long long ll;
typedef vector<long> vl;
typedef vector<string> vs;

int main(){
  int a,b,c=0,d=0,e,n,m,x,y;
  string s="YES";
  c(n);
  int aa[n];
  rep(i,0,n) cin>>aa[i];
  sort(aa,aa+n);
  rep(i,0,n-1){
    if(aa[i]==aa[i+1]) s="NO";
  }
  co(s);
 
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 1e5 + 5;

int32_t main()
{
	IOS;
	char ch;
	cin >> ch;
	if(isupper(ch))
		cout << "A";
	else
		cout << "a";
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD=1e9+7;
int main()
{
    ll n,temp;
    bool x=0;
    cin>>n;
    rep(i,n)
    {
        cin>>temp;
        if(temp%2==0)
        {
            if(temp%3!=0&&temp%5!=0) x=1;
        }
    }
    if(x) cout<<"DENIED";
    else cout<<"APPROVED";
}


Measured memory_bytes: 256
n=input()
judge=n[-1]
#print(judge)
if judge == '3':
    print('bon')
elif judge == '0':
    print('pon')
elif judge == '1':
    print('pon')
elif judge == '6':
    print('pon')
elif judge == '8':
    print('pon')
else:
    print('hon')


Measured memory_bytes: 8976
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[10];
	char base[3], out;
	int score, n, i;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		
		out = 0;
		score = 0;
		base[0] = 0;
		base[1] = 0;
		base[2] = 0;
		
		while (1){
			scanf ("%s", str);
			
			if (strcmp(str,"HIT") == 0){
				
				if (base[2] == 1){
					score++;
					base[2] = 0;
				}
				if (base[1] == 1){
					base[2] = 1;
					base[1] = 0;
				}
				if (base[0] == 1){
					base[1] = 1;
					base[0] = 0;
				}
				base[0] = 1;
			}
			if (strcmp(str,"HOMERUN") == 0){
				
				score += 1 + base[0] + base[1] + base[2];
				
				base[0] = 0;
				base[1] = 0;
				base[2] = 0;
			}
			if (strcmp(str, "OUT") == 0){
				out++;
				if (out == 3){
					break;
				}
			}
		}
		printf("%d\n", score);
	
	}
	return (0);
}
					
	

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl b(n-1);
  rep(i,n-1){
    cin >> b[i];
  }
  ll ans=b[0]+b[n-2];
  rep(i,n-2){
    ans +=min(b[i],b[i+1]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
 
  int ans = 0;
  for(int i = 0;i < 7; i++){
    int a = pow(2, i);
    if(a <= N ) ans = a;
    else break;
  } 
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    string a,b;
    cin >> n;
    cin >> a;
    cin >> b;
    string r;
    for(int i=0;i<n;i++){
        r.push_back(a[i]);
        r.push_back(b[i]);
    }
    cout << r << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(ll i=0;i<(n);++i)
#define Fr(i,n) for(long long i=1;i<=(n);++i)
#define ifr(i,n) for(long long i=(n)-1;i>=0;--i)
#define iFr(i,n) for(long long i=(n);i>0;--i)
using Graph = vector<vector<int>>;
int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  ll N,r,s,x,y;
  r=0;
  s=0;
  cin >> N;
  Graph G(N);
  for (int i = 0; i < N-1; ++i) {
      int a, b;
      cin >> a >> b;
      G[a-1].push_back(b-1);
      G[b-1].push_back(a-1);
  }
  vector<int> color(N, -1); 
  queue<int> que;
  queue<int> que2;
  color[0] = 1;
  color[N-1]=2;
  que.push(0);
  que2.push(N-1);
  while (!que.empty()or!que2.empty()) {
    x=que.size();
    fr(i,x){
      int v = que.front(); 
      que.pop();
      for (int nv : G[v]) {
          if (color[nv] == -1){
          color[nv] = 1;
          ++r;
          que.push(nv);
      }}}
      y=que2.size();
      fr(i,y){
      int v = que2.front(); 
      que2.pop();
      for (int nv : G[v]) {
          if (color[nv] == -1){
          color[nv] = 2;
          ++s;
          que2.push(nv);
      }}
  }
} if(s<r) cout<<"Fennec";
  else cout<<"Snuke";

}

Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <iomanip>
typedef long long ll;
using namespace std;

int main(){
    ll x;cin>>x;
    int a,b;
    for(int i=-500;i<501;i++){
        for(int j=-500;j<501;j++){
            if(pow(i,5)-pow(j,5)==x){
                a=i;
                b=j;
            }
        }
    }
    cout<<a<<' '<<b<<endl;
}

Measured memory_bytes: 4096
#include <iostream>

using namespace std;

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

int main(){
    int w;
    int h;
    int c;
    cin >> w >> h >> c;
    int whgcd = gcd(w, h);
    cout << (w / whgcd) * (h / whgcd) * c << endl;
}


Measured memory_bytes: 3116
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> L(n);
	rep(i, n) cin >> L.at(i);
	int sum = 0;
	sort(L.begin(), L.end());
	for (int i = 0; i < n - 2; i += 1) {
		int a = L.at(i);
		for (int j = i + 1; j < n - 1; ++j) {
			int b = L.at(j);
			for (int k = j + 1; k < n; ++k) {
				int c = L.at(k);
				if (abs(b - c) < a) sum++;
				else break;
			}
		}
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
n, q = gets.split.map(&:to_i)

tree = Array.new(n) { [] }
(n - 1).times do
  a, b = gets.split.map(&:to_i)
  a -= 1
  b -= 1
  tree[a] << b
end
cnt = Array.new(n, 0)
q.times do 
  pi, xi = gets.split.map(&:to_i)
  pi -= 1
  cnt[pi] += xi
end

que = []
que << [0, 0] # node_id, cnt
ans = []
while !que.empty?
  node, c = que.shift
  ans[node] = c + cnt[node]
  if !tree[node].empty?
    tree[node].each do |child_node|
      que << [child_node, c + cnt[node]]
    end
  end
end

puts ans * ' '

Measured memory_bytes: 36220
/**
 * author: Behradm
 * Created: 2020.08.15 16:28:43
 * In The Name of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int res = 0;
  for (int i = 0; i < (int) s.size(); i++) {
    if (s[i] == 'R') {
      int t = 0;
      while (s[i] == 'R' && i < (int) s.size()) {
        t += 1;
        ++i;
      }
      --i;

      res = max(res, t);
    }
  }

  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

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

int main() {
	int N; cin >> N;
	int *g1, *g2;
	g1 = new int[N];
	g2 = new int[N];

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

	g1[0] = a[0];
	g2[N - 1] = a[N - 1];

	for (int i = 1; i < N; i++) {
		g1[i] = gcd(a[i], g1[i - 1]);
	}
	for (int i = N - 2; i >= 0; i--) {
		g2[i] = gcd(a[i], g2[i + 1]);
	}

	int m = 0;
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			m = max(g2[i + 1], m);
		}
		else if (i == N - 1) {
			m = max(g1[i - 1], m);
		}
		else {
			m = max(gcd(g1[i - 1], g2[i + 1]), m);
		}
	}

	cout << m << endl;
	return 0;
}

Measured memory_bytes: 1408
def examC():
    N = I()
    for h in range(1,3501):
        for w in range(1,3501):
            cur = 4*h*w - N*(h+w)
            if cur>0 and (N*h*w)%cur==0:
                n = (N*h*w)//cur
                print(h,n,w)
                exit()
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

if __name__ == '__main__':
    examC()


Measured memory_bytes: 39024
#include<bits/stdc++.h>
using namespace std;
#define N 1000005
typedef long long LL;
struct mzls
{
	int x1,x,op;
}a[N];
bool operator<(mzls a1,mzls b1)
{
	return a1.x1<b1.x1;
}
pair<int,int>a1[N];
int ans[N],n,m;
map<int,int>mp;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		a[i].x1=x-z,a[i].x=z,a[i].op=0;
		a[i+n].x1=y-z,a[i+n].x=z,a[i+n].op=1;
	}
	n*=2;
	sort(a+1,a+n+1);
	for(int i=1;i<=m;i++)
		scanf("%d",&a1[i].first),a1[i].second=i;
	sort(a1+1,a1+m+1);
	int t1=1;
	for(int i=1;i<=m;i++)
	{
		while(t1<=n&&a[t1].x1<=a1[i].first)
		{
			if(a[t1].op==0)
				mp[a[t1].x]++;
			else
			{
				mp[a[t1].x]--;
				if(mp[a[t1].x]==0)
					mp.erase(a[t1].x);
			}
			t1++;
		}
		if(mp.begin()!=mp.end())
			ans[a1[i].second]=mp.begin()->first;
	}
	for(int i=1;i<=m;i++)
		printf("%d\n",ans[i]==0?-1:ans[i]);
}

Measured memory_bytes: 23680
// https://atcoder.jp/contests/abc090/tasks/abc090_b
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b, ans = 0;
    cin >> a >> b;
    FOR(i, a, b + 1) {
        string t = to_string(i);
        int len = t.length();
        bool flag = true;
        REP(j, len / 2) {
            if (t[j] != t[len - 1 - j]) {
                flag = false;
                break;
            }
        }
        if (flag)
            ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

int main(){
	set<char> st = {'a', 'i', 'u', 'e', 'o'};

	int n;
	while(cin >> n,n){
		vector<string> v(n);
		rep(i,n){
			cin >> v[i];
		}

		vector<string> t(n);
		rep(i,n){
			string tmp;
			tmp = v[i].front();
			range(j,1,v[i].size()){
				if(st.count(v[i][j - 1])){
					tmp += v[i][j];
				}
			}
			t[i] = tmp;
		}

		bool f = true;
		range(k,1,55){
			set<string> c;
			rep(i,n){
				c.emplace(t[i].substr(0,min<int>(k, t[i].size())));
			}
			if(c.size() == n){
				cout << k << endl;
				f = false;
				break;
			}
		}
		if(f) cout << -1 << endl;
	}
}



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

//INSERT ABOVE HERE
Int dp[303][303];
Int nx[303][303];

signed main(){
  Int n,k,mod;
  cin>>n>>k>>mod;
  memset(dp,0,sizeof(dp));
  dp[0][0]=1;
  for(Int i=0;i<k;i++){
    memset(nx,0,sizeof(nx));
    for(Int j=0;j<=n;j++) nx[j][j]=dp[i][j];
    for(Int j=0;j<=n;j++){
      for(Int l=n;l>=0;l--){
	nx[j+1][l]+=nx[j][l]*(l+1);
	nx[j+1][l]%=mod;
	if(l>0){
	  nx[j][l-1]+=nx[j][l];
	  nx[j][l-1]%=mod;
	}
      }
    }
    memset(dp,0,sizeof(dp));
    for(Int j=0;j<=n;j++) dp[i+1][j]=nx[j][0];
  }
  cout<<dp[k][n]<<endl;
  return 0;
}


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

using namespace std;

int N,M,K,L,R,H,W;

const long long int MOD=1000000007;



int main(){
	
	long double radius;
	vector<long double>ans;
	cout<<setprecision(20);
	while(cin>>radius>>N,radius>0.5){
		vector<int>l(100);
		vector<int>r(100);
		for(int i=0;i<N;i++){
			cin>>L>>R>>K;
			r[L+50]=max(r[L+50],K);
			l[R+50]=max(l[R+50],K);
			for(int j=L+51;j<R+50;j++){
				r[j]=max(r[j],K);
				l[j]=max(l[j],K);
			}
		}
		long double ret=100;
		for(int i=-radius+1;i<radius;i++){
			long double h=min(r[i+50],l[i+50]);
			long double amari=radius*radius;
			amari-=i*i;
			amari=sqrt(amari);
			amari-=radius;
			ret=min(ret,h-amari);
		}
		ans.push_back(ret);
	}
	for(auto i:ans)cout<<i<<endl;
	return 0;
}


Measured memory_bytes: 3228
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;


template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long n, std::vector<long long> a){
    map<int,int> v;
    for(int i = 0; i < n; ++i){
        ++v[a[i]];
    }
    i64 ans = 0;
    for(auto& x : v)
        ans += 1LL * x.second * (x.second - 1) / 2;
    for(int i = 0; i < n; ++i){
        i64 tm = ans;
        ans -= 1LL * v[a[i]] * (v[a[i]] - 1) / 2;
        ans += 1LL * (v[a[i]] - 1) * (v[a[i]] - 2) / 2;
        cout << ans << endl;
        ans = tm;
    }
}


signed main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 9088
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());???????????????
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10

int main() {
	string str;
	while (cin >> str) {
		int cnt_J = 0, cnt_I = 0;
		for (int i = 0; i + 2 < str.size(); ++i) {
			if (str[i] == 'J' && str[i + 1] == 'O' && str[i + 2] == 'I') { cnt_J++; }
			if (str[i] == 'I' && str[i + 1] == 'O' && str[i + 2] == 'I') { cnt_I++; }
		}
		cout << cnt_J << endl << cnt_I << endl;
	}

	return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

	int N; cin >> N;

	int a[2][105];

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

	int sum1[105];
	sum1[0] = a[0][0];
	for (int i = 1;i < N;i++){
		sum1[i] = sum1[i-1]+a[0][i];
	}

	int sum2[105];
	sum2[N-1] = a[1][N-1];
	for (int i = N-2;i >= 0;i--){
		sum2[i] = sum2[i+1]+a[1][i];
	}

	int ans = -1;

	for (int i = 0;i < N;i++){
		ans = max(ans, sum1[i]+sum2[i]);
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[100005];
ll n,a[100005];

int func(int ind)
{
    if(ind == (n-1)) return 0;
    if(ind >= n) return INT_MAX;

    if(dp[ind]!= -1) return dp[ind];
    ll left = abs(a[ind] - a[ind+1]) + func(ind+1);
    ll right = INT_MAX;

    if(ind + 2 < n)
        right = abs(a[ind] - a[ind+2]) + func(ind+2);

    dp[ind] = min(left, right);
    return dp[ind]; 
}
int main() {

    cin >> n;
    memset(dp, -1, sizeof dp);

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

    cout<<func(0);
}

Measured memory_bytes: 9828
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		long ruisekiWA = 0;
		for(long l = 1; l < 1000000000; l++) {
			ruisekiWA += l;
			if(ruisekiWA >= x) {
				System.out.println(l);
				return;
			}
		}
	}
}


Measured memory_bytes: 25172
#include<cstdio>
#include<iostream>

using namespace std;

int main(void){

	int a,b;
	char op;

	while(1){

		cin>>a>>op>>b;
		if(op=='?') break;

		switch(op){
			case '+':
				cout<<a+b<<endl;
				break;
			case '-':
				cout<<a-b<<endl;
				break;
			case '*':
				cout<<a*b<<endl;
				break;
			case '/':
				cout<<a/b<<endl;
				break;
		}
	}

	return 0;
}

Measured memory_bytes: 1160
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto s = readln.chomp;

  foreach (i, c; s) {
    if (i >= 1 && s[i-1] == c) {
      writeln(i, " ", i+1);
      return;
    }
    if (i >= 2 && s[i-2] == c) {
      writeln(i-1, " ", i+1);
      return;
    }
  }

  writeln("-1 -1");
}


Measured memory_bytes: 508
from sys import exit
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
coordinates = [a, b, c, d, e]
for i in range(5):
    for j in range(i + 1, 5):
        if coordinates[j] - coordinates[i] > k:
            print(':(')
            exit()
print('Yay!')


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;

int main() {
    //cout.precision(10);
  int n;
  cin >> n;
  for(int i = 1; i <= 1e9; i++) {
    if(i * i > n) {
      cout << (i-1)*(i-1) << endl;
      return 0;
    }
  }
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int a = sc.nextInt();
	static int b = sc.nextInt();
	static int c = sc.nextInt();
	static int d = sc.nextInt();
	static int p = sc.nextInt();

	public static void main(String[] args) {
		waterRate();
	}

	private static void waterRate() {
		int X = 0;
		int Y = 0;

		X = p * a;

			if ( p <= c ) {
				Y = b;
			} else {
				Y = b + (p - c) * d;
			}

		System.out.println(Math.min(X, Y));
	}
}


Measured memory_bytes: 26232
n = gets.to_i
as = gets.split.map &:to_i

b = []
as.each.with_index(1) do |a, i|
  if i % 2 == 0
    b.push a
  else
    b.unshift a
  end
end

if as.size % 2 == 0
  b.reverse!
end

puts b.join(' ')


Measured memory_bytes: 25444
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
ll n,m;
vl v;
 
void input(void){
    cin>>n>>m;
    inputv(v,n);
}
ll check(ll k){
    ll x=0,y;
  	vl v2;
    rep(i,n){
        y=(k+v[i]%k)%k;
      	v2.push_back(y);
      	x+=y;
    }
  sort(all(v2));
  y=0;
  ll ans=x;
  rep(i,n){
    x-=v2[n-1-i];
    y+=k-v2[n-1-i];
    ans=min(ans,max(x,y));
    //cout<<x<<" "<<y<<endl;
  }
    if(ans<m+1)return 1;
  return 0;
}
void solve(void){
    ll a=0;
    vl v1;
    rep(i,n){
        a+=v[i];
    }   
 
    for(ll i=1;i<sqrt(a)+0.05;i++){
        if(a%i==0){
            if(i*i==a)v1.push_back(i);
            else{
                v1.push_back(i);
                v1.push_back(a/i);
            }
        }
    }
 
    sort(all(v1));
    reverse(all(v1));
 
    rep(i,v1.size()){
        if(check(v1[i])==1){
            cout<<v1[i]<<endl;
            return;
        }
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    solve();
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
 
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc=new Scanner(System.in);

		int n;
		n=sc.nextInt();
		
		if(n%10 == 3)
        {
          System.out.println("bon");
        }
     else if((n%10 ==0)||(n%10 ==1)||(n%10 ==6)||(n%10 ==8))
     {
       System.out.println("pon");
     }
      else{
         System.out.println("hon");
      }}}
       


Measured memory_bytes: 35744
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#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,m;
  cin >> n >> m;
  rep(i,m){
    int a;
    cin >> a;
    n -= a;
  }
  if(n>=0){
    cout << n << endl;
  }else{
    cout << -1 << endl;
  }
}


Measured memory_bytes: 3632
#include <stdio.h>
int main(){
	char s[8];
	scanf("%s", &s);
	getchar();
	
	if (s[2]==s[3] && s[4]==s[5])
	{
		printf("Yes");
	}
	
	else{
		printf("No");
		
	}
	return 0;
	
	
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w
using namespace std;

#define int long long 
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int cnt[26] = {},ans;
	string s;
	cin >> s;
	ans = s.length() * (s.length() - 1) / 2;
	for(int i = 0;i < s.length();i++) cnt[s[i] - 'a']++;
	for(int i = 0;i < 26;i++) ans -= cnt[i] * (cnt[i] - 1) / 2;
	cout << ans + 1 << endl;
	return 0;
}

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

#define rep(i, n) for(int i=0;i<n;i++)
#define IOS() ios_base::sync_with_stdio(false)

using namespace std;

int n, q;
char ch[100007];
int sum_set[100007];

void input() {

    cin >> n >> q;
    cin >> ch+1;
}

void process() {

    for(int i=1;i<=n;i++) {
        if(ch[i] == 'A' && ch[i+1] == 'C') {
            sum_set[i+1] = 1;
        }
        sum_set[i] += sum_set[i-1];
    }

    rep(i, q) {

        int st, ed;

        cin >> st >> ed;

        cout << sum_set[ed] - sum_set[st] << endl;
    }


}

int main() {

    IOS();

    input();
    process();


    return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int main() {
	int W, H;
	cin >> W >> H;
	vector<pair<long long,bool>> a;
	for (int i = 0; i < W; ++ i) {
		int x;
		cin >> x;
		a.push_back({x, true});
	}
	for (int i = 0; i < H; ++ i) {
		int x;
		cin >> x;
		a.push_back({x, false});
	}
	sort(a.begin(), a.end());
	int w = W+1, h = H+1;
	long long r = 0;
	for (auto p : a) {
		if (p.second) {
			r += p.first * h;
			-- w;
		} else {
			r += p.first * w;
			-- h;
		}
	}
	cout << r << endl;
}


Measured memory_bytes: 4464
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    k,a,b=map(int,readline().split())
    cnt=1
    if a>=b-1:
        cnt+=k
    else:
        if k<a-1:
            cnt+=k
        else:
            cnt=a
            k-=a-1

            l=k//2
            m=k%2
            cnt+=(b-a)*l
            cnt+=m
    
    print(cnt)

if __name__=="__main__":
    main()

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.LinkedList;
import java.util.PriorityQueue;
import java.util.TreeSet;

 
public class Main {
  public static void main(String[] args) {
    InputReader sc = new InputReader(System.in);
 
    int n = sc.nextInt();
    int[] a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }
    int q = sc.nextInt();

    boolean[] hantei = new boolean[2001];
    hantei[0] = true;
    for(int i = 1; i < 2001; i++){
      hantei[i] = false;
    }

    for(int i = 0; i < n; i++){
      int nownum = a[i];
      for(int j = 2000 - nownum; j >= 0; j--){
        hantei[j + nownum] |= hantei[j];
      }
    }

    for(int i = 0; i < q; i++){
      System.out.println(hantei[sc.nextInt()] ? "yes" : "no");
    }
  }
 
  
// LinkedList<Integer>[] setsu = new LinkedList[n];
// for(int i = 0; i < n; i++){
//   setsu[i] = new LinkedList<Integer>();
// } 

 //ここからテンプレ
  static class InputReader {
      private InputStream stream;
      private byte[] buf = new byte[1024];
      private int curChar;
      private int numChars;
      private SpaceCharFilter filter;

      public InputReader(InputStream stream) {
          this.stream = stream;
      }
 
      public int next() {
          if (numChars == -1)
              throw new InputMismatchException();
          if (curChar >= numChars) {
              curChar = 0;
              try {
                  numChars = stream.read(buf);
              } catch (IOException e) {
                  throw new InputMismatchException();
              }
              if (numChars <= 0)
                  return -1;
          }
          return buf[curChar++];
      }
 
      public String nextStr() {
        int c = next();
        while(isSpaceChar(c)){c = next();}
        StringBuffer str = new StringBuffer();
        do{
          str.append((char)c);
          c = next();
        }while(!isSpaceChar(c));
        return str.toString();
      }

      public int nextInt() {
          int c = next();
          while (isSpaceChar(c))
              c = next();
          int sgn = 1;
          if (c == '-') {
              sgn = -1;
              c = next();
          }
          int res = 0;
          do {
              if (c < '0' || c > '9')
                  throw new InputMismatchException();
              res *= 10;
              res += c - '0';
              c = next();
          } while (!isSpaceChar(c));
          return res * sgn;
      }
 
      public boolean isSpaceChar(int c) {
          if (filter != null)
              return filter.isSpaceChar(c);
          return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
      }
 
      public interface SpaceCharFilter {
          public boolean isSpaceChar(int ch);
      }
  }
}

Measured memory_bytes: 18628
#include <iostream>
#include <algorithm>
#include <set>
using namespace std;
int gcd(int x,int y) 
{
	int z = y;
	while(x%y!=0)
	{
		z = x%y;
		x = y;
		y = z;	
	}
	return z;
}
int Gcd(int t[],int n) 
{
	int i;
	int c=t[0];
	for (i=1;i<n;i++)
	{
		c=gcd(c,t[i]);
	}
	return c;
}
int main()
{
	int n,x,a[100005];
	cin>>n>>x;
	for(int i=0;i<n;i++)
		cin>>a[i];
	a[n]=x;
	sort(a,a+n+1);
	set<int> q;
	for(int i=1;i<=n;i++)
	{
		q.insert(a[i]-a[0]);
	}
	set<int>::iterator it;
	int d[100005],s=0;
	for(it=q.begin();it!=q.end();it++)
	{
		d[s++]=*it;
	}
	int mins=Gcd(d,s);
	cout<<mins<<endl;
	return 0;
}

Measured memory_bytes: 5760