akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    ll x, y;
    cin >> x >> y;
    ll ans = 0;
    if((x > 0 && y > 0) || (x < 0 && y < 0)){
        ans += fabs(y - x);
        if(x > y){
            ans += 2;
        }
    }else{
        if(x == 0){
            if(y > 0) ans += fabs(y - x);
            if(y < 0) ans += (fabs(y - x) + 1);
        }else if(y == 0){
            if(x > y) ans += (fabs(y - x) + 1);
            if(x < y) ans += (fabs(y - x));
        }else{
            ans += (fabs(y - (-x)) + 1);
        }
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> k;
  if (k % 2 == 0 || k % 5 == 0) {
    cout << -1 << '\n';
    return 0;
  }
  int ans = 1, a = 7;
  while (true) {
    if (a % k == 0) {
      cout << ans << '\n';
      return 0;
    }
    ans++;
    a *= 10;
    a += 7;
    a %= k;
  }
  return 0;
}


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

using namespace std;

long long gcd(long long a, long long b){
	return b?(gcd(b,a%b)):a;
}
	

int main(){

	string s;
	cin>>s;
	for(int i=0; i<s.size()-1; ++i)
		if(toupper(s[i])==toupper(s[i+1]))
			return cout<<"Bad"<<endl,0;

	cout<<"Good"<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    unsigned long long ans=0;
    if(k%2==0&&n>=(k/2))
    {
        int x=(n-(k/2))/k+1;
        ans+=(long long)x*x*x;
        //cout<<x<<endl;
    }
    int x=n/k;
    ans+=(long long)x*x*x;
    cout<<ans;
    return 0;
}

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

int main(){
  int N,Y;
  cin>>N>>Y;
  Y/=1000;
  for(int x=0;x<=N;x++){
    for(int y=0;x+y<=N;y++){
      int z = N-x-y;
      if(10*x+5*y+z==Y){
        cout<<x<<" "<<y<<" "<<z<<endl;
        return 0;
      }
    }
  }
  cout<<"-1 -1 -1"<<endl; 
  return 0;
}

Measured memory_bytes: 256
import java.util.Arrays; 
import java.util.Scanner; 
public class Main { public static void main(String[] args) { 
Scanner keyboard = new Scanner(System.in); 

int A = keyboard.nextInt(); 
int B = keyboard.nextInt(); 
int C = keyboard.nextInt(); 
int D = keyboard.nextInt(); 

String ans = "";

if(A+B > C+D){
ans = "Left";
} else if(A+B == C+D){
ans = "Balanced";
} else{
ans = "Right";
}
		System.out.println(ans);
		keyboard.close();
	 	}
 } 


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<bitset>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<climits>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
#include<iomanip>
#include<sstream>
using namespace std;
#define ll long long
inline ll read() {
    char ch = getchar(); ll x = 0, f = 1;
    while(ch < '0' || ch > '9') {
        if(ch == '-') f = -1;
        ch = getchar();
    } while('0' <= ch && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    } return x * f;
}
int a[2000],ans;
int main(){
	int n=read();
	for (int i=1;i<=n;i++)
	{
		a[i]=read();
		if (a[i]==a[i-1])
		{
		  ans++;
		  a[i]=0;
		}
	}
	cout<<ans;

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <set>
#define inf 100000000

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

int N, K;
vector<int> G[100005];
int p[100005];
P val[100005];
int ans [100005];

bool check(int v, int prev, int r)
{
	if(p[v] != -1 && p[v] % 2 != r) return false;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == prev) continue;
		if(!check(G[v][i], v, (r+1)%2)) return false;
	}
	return true;
}

P dfs(int v, int prev)
{
	P ret = make_pair(-inf, inf), res;
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == prev) continue;
		res = dfs(G[v][i], v);
		if(res.first == inf) return make_pair(inf, -inf);
		ret.first = max(ret.first, res.first-1);
		ret.second = min(ret.second, res.second+1);
	}
	if(ret.first > ret.second) return make_pair(inf, -inf);
		
	if(p[v] != -1){
		if(p[v] < ret.first || p[v] > ret.second) return make_pair(inf, -inf);
		else ret = make_pair(p[v], p[v]);
	}
	return val[v] = ret;
}

void dfs2(int v, int prev, int x)
{
	if(x == inf) ans[v] = val[v].first;
	else ans[v] = max(val[v].first, x-1);
	for(int i = 0; i < G[v].size(); i++){
		if(G[v][i] == prev) continue;
		dfs2(G[v][i], v, ans[v]);
	}
}

int main(void)
{
	cin >> N;
	int a, b;
	for(int i = 0; i < N-1; i++){
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	
	cin >> K;
	for(int i = 1; i <= N; i++) p[i] = -1;
	for(int i = 0; i < K; i++){
		cin >> a >> b;
		p[a] = b;
	}
	
	if(!check(1, -1, 0) && !check(1, -1, 1)){
		cout << "No" << endl;
		return 0;
	}
	
	if(dfs(1, -1).first == inf){
		cout << "No" << endl;
		return 0;
	}
	
	dfs2(1, -1, inf);//(val[1].first + val[1].second) / 2);
	cout << "Yes" << endl;
	for(int i = 1; i <= N; i++){
		cout << ans[i] << endl;
	}
	
	return 0;
}

Measured memory_bytes: 15744
object Main {
  def main(args: Array[String]): Unit = {
    solve
  }

  def solve(): Unit = {
    val sc = new java.util.Scanner(System.in)
    val h, n = sc.nextInt
    val a = new Array[Int](n)
    for (i <- 0 until n) {
      a(i) = sc.nextInt
    }

    if (h <= a.sum) println("Yes")
    else println("No")
  }
}


Measured memory_bytes: 52472
def GCD(x,y):
    if x < 0:
        x = -x
    if y < 0:
        y = -y
    #x > yとなるようにする
    if x <= y:
        tmp = x
        x = y
        y = tmp
    r = x % y
    while r != 0:
        x = y
        y = r
        r = x % y
    return y
n,x = map(int,input().split())
xl = list(map(int,input().split()))
G = x-xl[0]
for i in range(n):
    G = GCD(G,x-xl[i])
print(G)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
set<string>::iterator it;
int k;
char sz[5001];
string str,s1,minstr;
set<string> set_substring;
void ProcessSubString(string s,int len)
{
	int i,j;
	for(i=0;i<len;i++)
	{
		for(j=0;j<len-i;j++)
		{
			set_substring.insert(s.substr(j,i+1));
		}
	}
}
int main()
{
	int i;
	scanf("%s",sz);
	scanf("%d",&k);
	str=sz;
	minstr=str;
	if(k<=str.length())
	{
		for(i=0;i<str.length()-k;i++)
		{
			s1=str.substr(i,k);
			if(s1<minstr)
			{
				minstr=s1;
				ProcessSubString(s1,k);
			}
		}
		ProcessSubString(str.substr(str.length()-k,k),k);
	}
	else
	{
		ProcessSubString(str,str.length());	
	}
	it=set_substring.begin();
	for(i=0;i<k-1;i++)
	{
		it++;
	}
	printf("%s",(*it).c_str());
	return 0;
}

Measured memory_bytes: 256
function Scanner(input) {
	var self = this;
	self.itemNo = 0;
	self.orgStr = input;
	self.splitedStrs = (function(target) {
		var result = [];
		var target = target.replace(/[\n \t]+/g, " ");
		var strs = target.split(" ");
		for (var i = 0, len = strs.length; i < len; i++) {
			result.push(strs[i]);
		}
		return result;
	}(input));

	self.next = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? result : null;
	}

	self.nextInt = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseInt(result) : null;
	}

	self.nextBigDecimal = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? parseFloat(result) : null;
	}
	
	self.nextByte = function() {
		var result = self.splitedStrs[self.itemNo];
		self.itemNo++;
		return (result != null) ? new Int8Array(result) : null;
	}

}

function Main(sc) {
	
	var N = sc.nextInt();
	var ans = BigInt(sc.next());
	var chk = BigInt(1000000000000000000);
	
	for (var i = 0; i < N-1; i++) {
		if (ans != BigInt(-1)) {
			ans *= BigInt(sc.next());
		} else {
			if (sc.next() == "0") {
				ans = BigInt(0);
				break;
			}
		}
		
		if (ans > chk) {
			ans = BigInt(-1);
		}
	}
	var ans = ans.toString();
	console.log(ans);
}
Main(new Scanner(require("fs").readFileSync("/dev/stdin", "utf8")));
// Main(new Scanner("10 1 2 5 3 4 6 7 3 2 4 1 2 2 3 3 4 4 5 3 6 6 7 1 8 8 9 9 10"));

// var str1 = sc.next(); // Stringで取得
// var int1 = sc.nextInt(); // intで取得
// var bd1 = sc.nextBigDecimal(); // BigDecimalで取得
// var byte1 = sc.nextByte(); // byteで取得
// for (var i = 0; i < 1000000000; i++) var toDelay = "aaa"; // 1000msくらいの遅延
// console.log(wrtnNos); return;


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

const int MAX = 8;
int rows[MAX];
bool cols[MAX];
bool d_left[(MAX * 2) - 1], d_right[(MAX * 2) - 1];
bool cells[MAX][MAX];

void print_queens() {
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      if (cells[i][j] && rows[i] != j) {
        return;
      }
    }
  }

  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      cout << (rows[i] == j ? "Q" : ".");
    }
    cout << endl;
  }
}

void put_queen(int i) {
  if (i == MAX ) {
    print_queens();
    return;
  }

  for (int j = 0; j < MAX; j++) {
    if (cols[j] == true ||
        d_left[i + j] == true ||
        d_right[i - j + MAX - 1] == true 
       ) continue;
    rows[i] = j;
    cols[j] = d_left[i + j] = d_right[i - j + MAX - 1] = true;
    put_queen(i + 1);
    rows[i] = -1;
    cols[j] = d_left[i + j] = d_right[i - j + MAX - 1] = false;
  }
}

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

  int k, r, c;

  for (int i = 0; i < MAX; i++) {
    rows[i] = -1;
    cols[i] = false;
  }
  for (int i = 0; i < (MAX * 2) - 1; i++) {
    d_left[i] = d_right[i] = false;
  }
  for (int i = 0; i < MAX; i++) {
    for (int j = 0; j < MAX; j++) {
      cells[i][j] = false;
    }
  }

  cin >> k;

  for (int i = 0; i < k; i++) {
    cin >> r >> c;
    cells[r][c] = true;
  }

  put_queen(0);

  return 0;
}

Measured memory_bytes: 3200
a, b, c = list(map(int, input().split()))
k = int(input())

if max(a, b, c) == a:
    for i in range(k):
        a *= 2
elif max(a, b, c) == b:
    for i in range(k):
        b *= 2
elif max(a, b, c) == c:
    for i in range(k):
        c *= 2

print(a+b+c)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int sum = 0;
  int N = 0;
    cin >> N;
  vector<int> data(N);
  for (int i = 0; i < N; i++) {
    cin >> data.at(i);
  }
  
  sort(data.begin(), data.end());
  
  for(int i = 0; i < N; i++) {
    sum += data.at(i);
    }
    sum -= data.at(N-1);
    
    if (sum > data.at(N-1)){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define whlie while
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repr(i,N) for(int i = (N) - 1; i >= 0; i--)
#define rep1(i,N) for(int i = 1; i <= (N) ; i++)
#define repr1(i,N) for(int i = (N) ; i > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define vrep(v,it) for(auto it = v.begin(); it != v.end(); it++)
#define vrepr(v,it) for(auto it = v.rbegin(); it != v.rend(); it++)
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) ll __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; using vl = vector<ll>;
using vi = vector<int>; using vvi = vector< vector<int> >;
constexpr int inf = 1001001001;
constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>; using vp = vector<P>;
constexpr int MOD = /** 1000000007; //*/ 998244353;
////////////////

void solve(){

  ini(N);
  vl d(N); in(d);
  ll ans = 0;
  rep(i,N) rep(j,N) if(i != j) ans += d[i] * d[j];
  out(ans / 2);

}

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

int main(){
	int A,B,M;cin>>A>>B>>M;
	
	vector<int> a(A);for(int i=0;i<A;++i)cin>>a[i];
	vector<int> b(B);for(int i=0;i<B;++i)cin>>b[i];

	int minA=*min_element(a.begin(),a.end());
	int minB=*min_element(b.begin(),b.end());
	int ans=minA+minB;

	for(int i=0;i<M;++i){
		int x,y,c;
		cin>>x>>y>>c;
		x--;y--;
		ans=min(ans,a[x]+b[y]-c);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=20000000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long max(long long a,long long b){
	if(a<b)return b;
	else return a;	
}
long long min(long long a,long long b){
	if(a>b)return b;
	else return a;	
}
long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	else return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a*b/gcd(a,b);
}


long long getDigit(long long n){
	if(n==1)return 1;
	else return log10(n)+1;
}

class Point{
public:
	long long x;
	long long y;
};
long long N,M;
vector<long long>X(100006,0);
bool isOK(long long time){
	long right=0;
	for(int i=0;i<M;i++){
		if(right>=X[i]-1){
			//go right
			right=X[i]+time;
		}else{
			if(right < X[i]-time-2)return false;
			right=max(X[i],X[i]+(time-(2*(X[i]-right)-1)));
		}
		//cout<<right<<endl;
	}
	if(right<N-1)return false;
	return true;
	
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long N,M,X,Y;
	cin>>N>>M>>X>>Y;
	vector<long long>x(N);
	vector<long long>y(M);
	for(int i=0;i<N;i++)cin>>x[i];
	for(int i=0;i<M;i++)cin>>y[i];
	
	for(int z=X+1;z<=Y;z++){
		bool ans=true;
		for(int i=0;i<N;i++){
			if(x[i]>=z)ans=false;
		}for(int i=0;i<M;i++){
			if(y[i]<z)ans=false;
		}
		if(ans){
			cout<<"No War"<<endl;
			return 0;
		}
	}
	cout<<"War"<<endl;
}


Measured memory_bytes: 1024
import Data.Array.IO
import Data.List.Split

main = do
    inks <- fmap (map (map read.splitOn ",").lines)getContents
    f <- newArray ((0,0),(9,9)) 0 :: IO (IOArray (Int,Int) Int)
    field <- dropInks f inks
    inkDepth <- getElems field
    print $ length.filter (== 0) $ inkDepth
    print $ maximum inkDepth

dropInks :: IOArray (Int,Int) Int -> [[Int]] -> IO (IOArray (Int,Int) Int)
dropInks field [] = return field
dropInks field (x:xs) = do
    field' <- dropInk field x
    dropInks field' xs

dropInk :: IOArray (Int,Int) Int -> [Int] -> IO (IOArray (Int,Int) Int)
dropInk f [x,y,size] = mapM_ (flip (modifyField f) (+1)) region >> return f
    where region = getRegion [x,y,size]
getRegion [x,y,n] = case n of
                 1 -> [(i,j) | i <- [x-1..x+1], j <- [y-1..y+1], abs (i-x) + abs (j-y) <= 1]
                 2 -> [(i,j) | i <- [x-1..x+1], j <- [y-1..y+1]]
                 3 -> [(i,j) | i <- [x-2..x+2], j <- [y-2..y+2], abs (i-x) + abs (j-y) <= 2]

modifyArray a i f = writeArray a i =<< fmap f (readArray a i)

modifyField :: IOArray (Int,Int) Int -> (Int,Int) -> (Int->Int) -> IO ()
modifyField field ix func = do
    bound <- getBounds field
    if ix `elem` range bound then modifyArray field ix func
                             else return ()

printField :: IOArray (Int,Int) Int -> IO ()
printField f = do
    es <- mapM (\i -> mapM (readArray f) [(x,y) | x <- [i], y <- [0..9]]) [0..9]
    mapM_ putStrLn $ map (unwords.map show) $ es

Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


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

  int n;
  cin >> n;
  int a[n];
  rep(i,n) cin >> a[i];
  if(a[0]!=0){
    cout << -1 << endl;
    return 0;
  }
  ll ans=0;
  rep1(i,n-1){
    if(a[i]>a[i-1]+1){
      cout << -1 << endl;
      return 0;
    }
    if(a[i]==a[i-1]+1){
      ans++;
    }
    else{
      ans+=a[i];
    }    
  }
  cout << ans << endl;
  
  return 0;
    

}


Measured memory_bytes: 1024
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    int N;
    scan(N);
    auto B = readln.split.to!(long[]);
    auto A = new long[](N);
    A[0] = B[0];
    foreach (i ; 1 .. N - 1) {
        A[i] = min(B[i], B[i - 1]);
    }
    A[N - 1] = B[N - 2];
    auto ans = A.sum(0L);
    writeln(ans);
}







void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;

    foreach (arg; args) {
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    }

    return isChanged;
}


Measured memory_bytes: 256
numbers = list(map(int, input().split()))
W = numbers[0]
H = numbers[1]
x = numbers[2]
y = numbers[3]
r = numbers[4]

if x + r > W or x - r < 0 or y + r > H or y - r < 0:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 5596
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
long long F(long long A){ 
    long long ta = A;
    long long fa = 0;
    for(int i = 0; i <= 10; i++){
        if(ta <= 0) break;
        ta /= 10;
        fa++;
    }
    return fa;
}
int main() {
    long long N;
    cin >> N;
    long long n = sqrt(N);
    long long min = 10;
    for(int i = 1; i <= n; i++){
        if(N%i == 0){
            long long A = i;
            long long B = N / i;
            long long m;
            if(F(A) > F(B)) m = F(A);
            else m = F(B);
            if(min > m) min = m;
        }
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

int main() {
	int n; scanf("%d", &n);
	std::vector<i64> a(n);
	for(int i = 0; i < n; i++) scanf("%lld", &a[i]);
	i64 m, k; scanf("%lld%lld", &m, &k);
	std::vector<int> b(m);
	for(int i = 0; i < m; i++) {
		scanf("%d", &b[i]);
		
		b[i]--;
	}
	
	std::vector<i64> d(n - 1);
	for(int i = 0; i < d.size(); i++) d[i] = a[i + 1] - a[i];
	
	std::vector<int> op(d.size());
	for(int i = 0; i < op.size(); i++) op[i] = i;
	for(auto v: b) std::swap(op[v - 1], op[v]);
	
	std::vector<int> ret(d.size());
	for(int i = 0; i < d.size(); i++) ret[i] = i;
	std::function<void ()> solve = [&]() {
		while(k) {
			if(k & 1) {
				std::vector<int> tmp(ret.size());
				for(int i = 0; i < op.size(); i++) {
					tmp[i] = ret[op[i]];
				}
				ret.swap(tmp);
			}
			
			std::vector<int> nxt = op;
			for(int i = 0; i < op.size(); i++) {
				nxt[i] = op[op[i]];
			}
			op.swap(nxt);
			k >>= 1;
		}
	};
	solve();
	
	std::vector<i64> ans(n, 0); ans[0] = a[0];
	for(int i = 0; i < ret.size(); i++) ans[i + 1] = d[ret[i]];
	for(int i = 0; i < ret.size(); i++) ans[i + 1] += ans[i];
	
	for(auto v: ans) printf("%lld\n", v);
	return 0;
}


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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int main() {
    ll X, K, D;
    cin >> X >> K >> D;

    if (-D <= X and X <= D) {
        if (K % 2 == 0) {
            cout << llabs(X) << endl;
        }
        else {
            if (X < 0) {
                cout << llabs(X+D) << endl;
            }
            else {
                cout << llabs(X-D) << endl;
            }
        }
        return 0;
    }

    ll tmp = llabs(X) / D;
    if (tmp > K) {
        if (X < 0) {
            cout << llabs(X + D * K) << endl;
        }
        else {
            cout << llabs(X - D * K) << endl;
        }
    }
    else {
        if (X < 0) {
            X += D * tmp;
            K -= tmp;

            if (K%2 == 0) {
                cout << llabs(X) << endl;
            }
            else {
                if (X < 0) {
                    cout << llabs(X + D) << endl;
                }
                else {
                    cout << llabs(X - D) << endl;
                }
            }
        }
        else {
            X -= D * tmp;
            K -= tmp;

            if (K%2 == 0) {
                cout << llabs(X) << endl;
            }
            else {
                if (X < 0) {
                    cout << llabs(X+D) << endl;
                }
                else {
                    cout << llabs(X-D) << endl;
                }
            }
        }
    }


}


Measured memory_bytes: 3632
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

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

  if (S[0] != '1' || S[S.length() - 1] != '0' || S[S.length() - 2] != '1'){
    cout << -1 << endl;
    return 0;
  }

  for (int i = 0; i < S.length() - 1; i++){
    if (S[i] != S[S.length() - 2 - i]){
      cout << -1 << endl;
      return 0;
    }
  }

  int half;
  for (int i = 0; i < S.length() - 1; i++){
    if (i > S.length() - 2 - i){
      break;
    }
    if (S[i] == S[S.length() - 2 - i] && S[i] == '1'){
      half = i + 1;
    }
  }

  int now = 1;
  for (int i = 1; i < half; i++){
    cout << now << " " << i + 1 << endl;
    if (S[i - 1] == '1') now = i + 1;
  }

  cout << now << " " << half + 1 << endl;
  
  for (int i = half + 2; i <= S.length(); i++){
    cout << half + 1 << " " << i << endl;
  }
  

  return 0;
}


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

int main() {
  long long n;
  cin >> n;
  
  long long mod = pow(10, 9) + 7;
  long long ans = 1, full = 1, nine = 1;
  for(int i = 0; i < n; i++){
    ans = ans * 10 % mod;
    full = full * 8 % mod;
    nine = nine * 9 % mod;
  }
  
  ans += mod * 3;
  ans -= nine*2 - full;
  
  cout << ans % mod << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;


int main()
{
    int n;
    cin >> n;
    vector<int>s(5);
    rep(i,5)s[i]=0;
    rep(i,n)
    {
        string ss;
        cin >> ss;
        switch (ss[0])
        {
        case 'M':
            s[0]++;
            break;
        case 'A':
            s[1]++;
            break;
        case 'R':
            s[2]++;
            break;
        case 'C':
            s[3]++;
            break;
        case 'H':
            s[4]++;
            break;
        }
    }
   
    ll ans=0;
    for(int i=0;i< (1<<5);i++)
    {
        if(__builtin_popcount(i)!=3)continue;
        ll sum=1;
        for(int k=0;k<5;k++)
        {
            if(i&(1<<k))
            {          
                    sum *=s[k]; 
            }
        }
        ans+=sum;
       
    }
     cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef vector<pii> vii;
typedef vector<pll> vll;
#define fi first
#define se second
#define pi 3.141592653589793
#define mod 998244353
#define pb push_back
#define all(v) v.begin(),v.end()
#define tc int t;cin>>t;while(t--)
#define pqmax priority_queue<int>
#define pqmin priority_queue<int,vi,greater<int>>
#define fast_io ios_base::sync_with_stdio(0), cin.tie(NULL)
#define tc_g int tt;cin>>tt;for(int ti=1;ti<=tt;ti++)
#define case_g "Case #"<<ti<<": "
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<int, int, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_map;

int main() {
	fast_io;
	ll a;
	string b;
	cin >> a >> b;
	ll c = 0;
	for (int i = 0;i < b.size();i++) {
		if (b[i] != '.')
			c = c * 10 + (b[i] - '0');
	}
	cout << (a * c) / 100 << '\n';
}


Measured memory_bytes: 3652
package main

import (
	"fmt"
	"strings"
	"strconv"
)

func main() {
	var n int
	fmt.Scan(&n)
	
	a := make([]int,n)
	ans := make([]string,n)
	
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		ans[a[i] - 1] = strconv.Itoa(i + 1)
	}
	fmt.Println(strings.Join(ans, " "))
}

Measured memory_bytes: 8320
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  ll S,ans;
  cin>>S;
  ans=pow(S,3);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main(){
    int a,b,c,k;
    long long int ans = 0;

    cin >> a >> b >> c >> k;

    if(k >= a){
        ans+=a;
        k-= a;
    }else{
        cout << k << endl;
        return 0;
    }

    if(k > 0 && k >= b){
        k-=b;
    }else{
        k = 0;
    }

    if(k > 0 && k >= c){
        ans -= c;
        k -= c;
    }else{
        ans -= k;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  int N;
  ci(N);
  int a = 0;
  rep(i, N){
    int l, r;
    ci(l, r);
    a += r - l + 1;
  }
  co(a);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <map>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;

#define int long long
#define u64 unsigned long long
#define reg register
#define debug(x) cerr<<#x<<" = "<<x<<endl;
#define rep(a,b,c) for(reg int a=(b),a##_end_=(c); a<=a##_end_; ++a)
#define ret(a,b,c) for(reg int a=(b),a##_end_=(c); a<a##_end_; ++a)
#define drep(a,b,c) for(reg int a=(b),a##_end_=(c); a>=a##_end_; --a)
#define erep(i,G,x) for(reg int i=G.Head[x]; i; i=G.Nxt[i])

inline int Read() {
    int res = 0, f = 1;
    char c;
    while (c = getchar(), c < 48 || c > 57)if (c == '-')f = 0;
    do res = (res << 3) + (res << 1) + (c ^ 48);
    while (c = getchar(), c >= 48 && c <= 57);
    return f ? res : -res;
}

template<class T>inline bool Min(T &a, T const&b) {
    return a > b ? a = b, 1 : 0;
}
template<class T>inline bool Max(T &a, T const&b) {
    return a < b ? a = b, 1 : 0;
}

const int N = 2e5 + 5, M = 9e5 + 5;

int n, m, A[N], B[N], tot[N], Ans, flag;

main() {
    n = Read();
    rep(i, 1, n)A[i] = B[i] = Read(), tot[A[i]]++, Max(Ans, A[i]);
    sort(B + 1, B + n + 1);
    if (tot[Ans] > 1) {
        rep(i, 1, n)printf("%d\n", Ans);
    } else {
        rep(i, 1, n) {
            if (A[i] == Ans)printf("%d\n", B[n - 1]);
            else printf("%d\n", Ans);
        }
    }
    return 0;
}

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

signed main(){
  int n; cin >> n;
  vector<int> a(n);
  int ans = 1e9;
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int t = 1; t < n; t++){
    int x = 0, y = 0;
    for(int i = 0; i < n; i++){
      if(i + 1 <= t) x += a[i];
      else y += a[i];
    }
    ans = min(ans, abs(x - y));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;
#define MOD 1000000007
#define EPS 10e-8
int t[13];
int taiou[13][13],swit[13],denk[13],p[13],f;

int main(){
    int N,M,k[13],s[13][13];
    cin  >> N >> M ;
    rep(i,M){
        cin >>  k[i];
        rep(j,k[i]){
            cin >> s[i][j];
            s[i][j]--;
            taiou[s[i][j]][swit[s[i][j]]]=i;
            swit[s[i][j]]++;
        }
    }
    rep(i,M){
        cin >> p[i];
    }
    for (int bit = 0; bit < (1<<N); ++bit) {
        vector<int> S;
        for (int i = 0; i < N; ++i) {
            if (bit & (1<<i)) { // i が bit に入るかどうか
                S.push_back(i);
            }
        }
        rep(i,M){
            denk[i]=0;
        }
        for (int i = 0; i < (int)S.size(); ++i) {
            rep(j,swit[S[i]]){
                denk[taiou[S[i]][j]]++;
            }
        }
        rep(i,M){
            if(denk[i]%2!=p[i]){
                break;
            }
            if(i==M-1){
                f++;
            }
        }
    }
    cout << f << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int l=sc.nextInt();
        sc.close();
        int n=0, m=0;
        while(l>=(1<<n++));n--;
        StringBuilder sb =new StringBuilder();
        for(int bit=1;bit<n;bit++, m+=2){
            sb.append(bit+" "+(bit+1)+" "+0+"\n"+bit+" "+(bit+1)+" "+(1<<(bit-1))+"\n");
            if((l&(1<<(bit-1)))!=0){
                sb.append(bit+" "+n+" "+(l>>bit<<bit)+"\n");
                m++;
            }
        }
        System.out.println(n+" "+m);
        System.out.print(sb);
    }
}


Measured memory_bytes: 22100
// -*- coding: utf-8 -*-
// Last-Updated : <2014/06/19 18:14:34 by samui>

#include <iostream>
#include <cstdio>
#include <string>

#include <vector>

int main(int argc, char **argv){
  int L,A,B,C,D;
  std::cin>>L;
  std::cin>>A;
  std::cin>>B;
  std::cin>>C;
  std::cin>>D;
  while(A>0 || B >0){
    A-=C;
    B-=D;
    L--;
  }
  std::cout<<L<<std::endl;
  return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        static int Solve(int H, int W, string[] A)
        {
            var memo = new int[H][];
            for (int h = 0; h < H; ++h) { memo[h] = Enumerable.Repeat(int.MaxValue, W).ToArray(); }
            var q = new Queue<Tuple<int, int>>();
            for (int h = 0; h < H; ++h)
            {
                for (int w = 0; w < W; ++w)
                {
                    if (A[h][w] == '#')
                    {
                        memo[h][w] = 0;
                        q.Enqueue(new Tuple<int, int>(h, w));
                    }
                }
            }
            while (q.Count > 0)
            {
                var p1 = q.Dequeue();
                int h1 = p1.Item1, w1 = p1.Item2;
                foreach (var p2 in new[] { new[] { h1, w1 - 1 },
                                           new[] { h1, w1 + 1 },
                                           new[] { h1 - 1, w1 },
                                           new[] { h1 + 1, w1 } })
                {
                    int h2 = p2[0], w2 = p2[1];
                    if (0 <= h2 && h2 < H && 0 <= w2 && w2 < W)
                    {
                        if (memo[h2][w2] > memo[h1][w1] + 1)
                        {
                            memo[h2][w2] = memo[h1][w1] + 1;
                            q.Enqueue(new Tuple<int, int>(h2, w2));
                        }
                    }
                }
            }
            return memo.Max(raw => raw.Max());
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int H = V[0], W = V[1];
            var A = new string[H];
            for (int h = 0; h < H; ++h) { A[h] = Read(); }
            Console.WriteLine(Solve(H, W, A));
        }
    }
}


Measured memory_bytes: 53184
import sys

sys.setrecursionlimit(2147483647)
INF = float("inf")
MOD = 1000000007

a=open(0)
N,_,*a = map(int, a.read().split())

dp = [-1 for _ in range(100010)]
dp[0] = 0
for i in a: dp[i] = 0
def rec(i):
    if dp[i] > -1:
        return dp[i]
    if i<3:
        dp[i] = rec(i-1) + 1
        return dp[i]
    dp[i] = (rec(i-1)+rec(i-2))%MOD
    return dp[i]
    
print(rec(N))






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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, x[1000], y[1000], t[2], d[32];

int main() {
	cin >> n;
	inc(i, n) { cin >> x[i] >> y[i]; }
	
	inc(i, n) { t[(x[i] + y[i]) % 2] = 1; }
	if(t[0] && t[1]) {
		cout << -1 << endl;
		return 0;
	}
	
	incII(i, 0, 30) { d[i] = 1 << (30 - i); }
	d[31] = 1;
	int m = (t[0] ? 32 : 31);
	
	cout << m << endl;
	inc(i, m) { cout << d[i] << (i == m - 1 ? "\n" : " "); }
	inc(i, n) {
		int X = y[i] + x[i];
		int Y = y[i] - x[i];
		
		int xp = 0, yp = 0, z;
		string s;
		inc(j, m) {
			z = 0;
			if(xp < X) { xp += d[j]; z |= 1; } else { xp -= d[j]; }
			if(yp < Y) { yp += d[j]; z |= 2; } else { yp -= d[j]; }
			s += "DRLU"[z];
		}
		
		cout << s << "\n";
	}
	
	return 0;
}


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


int main(){
	string s, t;
	cin >> s >> t;
	sort(s.begin(),s.end());
	sort(t.begin(),t.end());
	reverse(t.begin(),t.end());

	for(int i=0; i<s.size(); i++){
		if(t[i]>s[i]){
			cout << "Yes" ;
			return 0;
		}
		if(s[i]>t[i]){
			cout << "No";
			return 0;
		}
	}
	if(s.size()==t.size()){
		cout << "No";
	} else {
		cout << "Yes" ;
	}
}

Measured memory_bytes: 256
import math
from scipy.sparse.csgraph import csgraph_from_dense,floyd_warshall


H,W = map(int,input().split())

S = []

# def warshall_floyd(d):
#     for k in range(n):
#         for i in range(n):
#             for j in range(n):
#                 d[i][j] = min(d[i][j],d[i][k] + d[k][j])
#     return d



for i in range(H):
    tmp = list(input())
    S.append([t for t in tmp])

d = [[10**9 for _ in range(H*W)] for _ in range(H*W) ]
for i in range((H)*W):
    if i == H*W-1:
        pass 
    elif i % W == W-1:
        if S[i//W][i%W] == ".":
            if S[i//W+1][i%W] == ".":
                d[i][i+W] = 1
                d[i+W][i] = 1
    elif i > (H-1)*W-1:
        if S[i//W][i%W] == ".":
            if S[i//W][i%W+1] == ".":
                d[i][i+1] = 1
                d[i+1][i] = 1

    else:
        if S[i//W][i%W] == ".":
            if S[i//W+1][i%W] == ".":
                d[i][i+W] = 1
                d[i+W][i] = 1
            if S[i//W][i%W+1] == ".":
                d[i][i+1] = 1
                d[i+1][i] = 1
n = H*W
#x = warshall_floyd(d)                

G = csgraph_from_dense(d, null_value=10**9)
x = floyd_warshall(G)

ans = 0
for x_ in x:
    for xx in x_:
        if xx < 10000 and xx > ans:
            ans = xx
print(int(ans))




Measured memory_bytes: 20996
n = int(input())
mi1= 10**10
ma1= -10**10
mi2=10**10
ma2=-10**10
P = []
for i in range(n):
  a = list(map(int,input().split()))
  P.append(a)
P.sort(key = lambda x:x[0])
for i in range(n):
    p=P[i]
    mi1=min(mi1,p[0]+p[1])
    ma1=max(ma1,p[0]+p[1])
    mi2=min(mi2,p[0]-p[1])
    ma2=max(ma2,p[0]-p[1])
print(max(ma1-mi1,ma2-mi2))

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

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

    // for(int i = n; i > 0; i--){
    //     if(floor(sqrt(i)) == sqrt(i)){
    //         cout << i << endl;
    //         return 0;
    //     }
    // }
    for(int i = 1; ; i++){
        if(i * i > n){
            cout << (i - 1) * (i - 1) << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

x_A = A * math.sin(math.radians((60 * H + M)/2))
# print(x_A)
y_A = A * math.cos(math.radians((60 * H + M)/2))
# print(y_A)
x_B = B * math.sin(math.radians(6 * M))
# print(x_B)
y_B = B * math.cos(math.radians(6 * M))
# print(y_B)
print(math.sqrt((x_A - x_B) ** 2 + (y_A - y_B) ** 2))

Measured memory_bytes: 9512
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main(void){

    int A,B,C,D,E,F; cin>>A>>B>>C>>D>>E>>F;
    double max_noudo=0;
    int max_satosui=0, max_sato=0;
    int T=-1, S=0;
    for (int A_mizu = 0; A_mizu <= F; A_mizu+=(A*100)) {
        for (int B_mizu = 0; B_mizu <= F-A_mizu; B_mizu+=(B*100)) {
            for (int C_sato = 0; C_sato <= F-(A_mizu+B_mizu); C_sato+=C) {
                for (int D_sato = 0; D_sato <= F-(A_mizu+B_mizu+C_sato); D_sato+=D) {
                    int s=C_sato+D_sato, t=A_mizu+B_mizu+s;
                    if(t>0 && s<=(A_mizu+B_mizu)/100*E && (T<0 || S*t<s*T)) {
                        S = s; T=t;
                    }
                }
            }
        }
    }
    cout<<T<<" "<<S<<endl;

    return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	//java11

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String S = sc.next();
		String T = sc.next();

		int ans = 0;
		for(int i=0; i<S.length(); i++) {
			if(S.charAt(i) != T.charAt(i)) {
				ans++;
			}
		}

		System.out.println(ans);
	}


}


Measured memory_bytes: 41112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PLL> VP;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "

int main()
{
    ll N; cin >> N;
    map<ll ,ll> count;
    rep(i,N){
        ll a; cin >> a;
        count[a]++;
    }
    ll find=0;
    ll one=0,two=0;
    for(auto i=count.begin(); i!=count.end(); ++i){
        if((i->S)>=2){
            if(one<(i->F)){
                two=one;
                one=i->F;
            }
            else{
                if(two<(i->F)){
                    two=i->F;
                }
            }
        }
    } 
    ll first=one*two;
    ll second=0;
    for(auto i=count.begin(); i!=count.end(); i++){
        if(i->S>=4){
            if(second<i->F){
                second=i->F;     
            }
        }
    }
    if(first>second*second){
        cout << first << endl;
    }  
    else{
        cout << second*second << endl;
    }
}

Measured memory_bytes: 6528
#include <stdio.h>

int main(void){

  int n,m;
  scanf("%d %d", &n, &m);
  int k[m],s[m][n],p[m];
  for (int i = 0; i < m; i++) {
    scanf("%d", &k[i]);
    for (int j = 0; j < k[i]; j++) {
      scanf("%d", &s[i][j]);
    }
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &p[i]);
  }
  int switches[n];
  for (int i = 0; i < n; i++) {
    switches[i] = 0;
  }
  int flag;
  int on_switch;
  int answer = 0;
  while (1) {
    flag = 1;
    for (int i = 0; i < m; i++) {
      on_switch = 0;
      for (int j = 0; j < k[i]; j++) {
        on_switch += switches[s[i][j]-1];
      }
      if (on_switch%2 != p[i]) {
        flag = 0;
        break;
      }
    }
    if (flag == 1) {
      answer++;
    }
    on_switch = 0;
    for (int i = 0; i < n; i++) {
      on_switch += switches[i];
    }
    if (on_switch == n) {
      break;
    }
    switches[0]++;
    for (int i = 1; i < n; i++) {
      switches[i] += switches[i-1]/2;
      switches[i-1] %= 2;
    }
  }
  printf("%d\n", answer);

  return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ll long long
#define PINT pair<int,int>
#define f1 first
#define s2 second
const int INF = 1e9 + 7;

using namespace std;

#define MAX_V 202
struct edge{int to, cap, rev;}; //辺（行き先，容量，逆辺）

vector<edge> G[MAX_V];  //隣接リスト
int level[MAX_V];   //ｓからの距離
int iter[MAX_V];    //どこまで調べ終わったか

//sからの最短距離をBFSで計算する
void bfs(int s){
    memset(level, -1, sizeof(level));
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(!que.empty()){
        int v = que.front(); que.pop();
        REP(i,G[v].size()){
            edge &e = G[v][i];
            if(e.cap > 0 && level[e.to] < 0){
                level[e.to] = level[v] + 1;
                que.push(e.to);
            }
        }
    }
}

//増加パスをDFSで探す
int dfs(int v, int t, int f){
    if(v == t) return f;
    for(int &i = iter[v]; i < G[v].size(); i++){
        edge &e = G[v][i];
        if(e.cap > 0 && level[v] < level[e.to]){
            int d = dfs(e.to, t, min(f, e.cap));
            if(d > 0){
                e.cap -= d;
                G[e.to][e.rev].cap += d;
                return d;
            }
        }
    }
    return 0;
}

//sからtへの最大流を求める
int max_flow(int s, int t){
    int flow = 0;
    for(;;){
        bfs(s);
        if(level[t] < 0) return flow;
        memset(iter, 0, sizeof(iter));
        int f;
        while((f = dfs(s, t, INF)) > 0){
            flow += f;
        }
    }
}

//fromからtoへ向かう容量capの辺をグラフに追加する
void add_edge(int from, int to, int cap){
    G[from].push_back((edge){to, cap, G[to].size()});
    G[to].push_back((edge){from, 0, G[from].size() - 1});
}

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

    int n;
    cin >> n;
    vector<PINT> red(n),blue(n);
    REP(i,n) cin >> red[i].f1 >> red[i].s2;
    REP(i,n) cin >> blue[i].f1 >> blue[i].s2;

    sort(red.begin(),red.end());
    sort(blue.begin(),blue.end());

    FOR(i,1,n) add_edge(0,i,1);
    FOR(i,101,101+n) add_edge(i,201,1);
    REP(i,n){
        REP(j,n){
            if(red[j].f1>=blue[i].f1) break;
            if(red[j].f1<blue[i].f1 && red[j].s2<blue[i].s2){
                add_edge(i,101+j,1);
            }
        }
    }

    cout << max_flow(0,201) << endl;
    return 0;
}


Measured memory_bytes: 384