akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	string K;
	int D;
	cin >> K >> D;
	N = K.size();
	vector< vector< vector< int > > > dp(N + 1, vector< vector< int > >(2, vector< int >(D, 0)));
	dp[0][1][0] = 1;
	rep(i, N) rep(t, 2) rep(j, D) {
		rep(x, 10) {
			int ni = i + 1, nt = t, nj;
			nj = (j + x) % D;
			if (t) {
				if (x > K[i] - '0')
					continue;
				if (x < K[i] - '0')
					nt = 0;
			}
			(dp[ni][nt][nj] += dp[i][t][j]) %= MOD;
		}
	}
	//cout << dp[1];
	cout << (dp[N][0][0] + dp[N][1][0] - 1 + MOD) % MOD << endl;
	return 0;
}

Measured memory_bytes: 17024
#include <bits/stdc++.h>//toINFandByd
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define endl "\n"
using namespace std;
typedef long long ll;

void solve(){
    int n;
    cin >> n;
    vector<ll> a(n);
    forn(i,n) cin >> a[i];
    int q;
    cin >> q;
    map<ll,int> m;
    int i;
    ll sum = 0;
    for(i=0;i<n;i++){
        m[a[i]]++;
        sum+=a[i];
    }
    while(q--){
        ll b,c;
        cin >> b >> c;
        sum -= m[b]*b;
        sum += m[b]*c;
        auto it = m.find(c);
        if(it==m.end()){
            m[c] = m[b];
        }
        else{
            it->second += m[b];
        }
        auto itr = m.find(b);
        itr->second = 0;
        cout << sum << endl;
    }

}   

int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 9972
#include <iostream>

using namespace std;

int main() {
    string str;


    getline(cin, str);
    string newStr = str;
    for (int i = 0; i < str.length(); i++) {
        if ((int) str[i] >= (int) 'a' && (int) str[i] <= (int) 'z') {
            newStr[i] = ((int) str[i] - 32);
        } else if ((int) str[i] >= (int) 'A' && (int) str[i] <= (int) 'Z') {
            newStr[i] = ((int) str[i] + 32);

        }


    }


    for (int i = 0; i < str.length(); i++) {
        cout << newStr[i];
    }
    cout << endl;

}

Measured memory_bytes: 3204
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
    .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn main() {
    let v1: Vec<u32> = read_vec();
    let (n,m,l) = (v1[0], v1[1], v1[2]);
    let a: Vec<Vec<i64>> = read_vec2(n);
    let b: Vec<Vec<i64>> = read_vec2(m);
    let mut c: Vec<Vec<i64>> = Vec::new();
    for i in 0..a.len() {
        let mut r: Vec<i64> = Vec::new();
        for j in 0..(l as usize) {
            let mut sum = 0;
            for k in 0..b.len() {
                sum += a[i][k] * b[k][j];
            }
            r.push(sum);
        }
        c.push(r);
    }
    for v in &c {
        println!("{}",
            v.iter().map(|i| i.to_string())
            .collect::<Vec<String>>().join(" "));
    }
}



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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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


string s;
ll dp[100005][13];

void solve() {
    cin >> s;
	int d = s.size();

	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	rep(i, d){
		rep(j, 13){
			if(s[i] == '?'){
				rep(k, 10){
					dp[i+1][(j*10+k)%13] = modint(modint(dp[i+1][(j*10+k)%13]) + modint(dp[i][j]));
				}
			}else{
				int k = s[i] - '0';
				dp[i+1][(j*10+k)%13] = modint(modint(dp[i+1][(j*10+k)%13]) + modint(dp[i][j]));
			}
		}
	}

	cout << dp[d][5] << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 14800
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli h, w, n;
vector<lli> a;
lli bd[101][101];
int main() {
  cin >> h >> w >> n;
  read_n(a, n);
  lli c = 1, r = a[0];
  for (lli j=0; j<h; ++j) {
    for (lli i = (j%2 ? 0 : w-1); 0<=i && i<w; i += (j%2 ? 1 : -1)) {
      bd[j][i] = c;
      --r;
      if (r == 0) {
	r = a[++c - 1];
      }
    }
  }
  for (lli j=0; j<h; ++j) {
    for (lli i=0; i<w; ++i) {
      if (i > 0) cout << ' ';
      cout << bd[j][i];
    }
    cout << '\n';
  }
  return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int n, k;
	scanf("%d %d", &n, &k);
	if (n == 2)
	{
		if (k == 0)
		{
			printf("1\n");
			printf("1 2\n");
			return 0;
		}
		else
		{
			printf("-1\n");
			return 0;
		}
	}
	if (n == 3)
	{
		if (k == 0)
		{
			printf("3\n");
			printf("1 2\n2 3\n1 3\n");
			return 0;
		}
		if (k == 1)
		{
			printf("2\n");
			printf("1 2\n2 3\n");
			return 0;
		}
		printf("-1\n");
		return 0;
	}
	int max = (n - 1) * (n - 2) / 2;
	if (k > max)
	{
		printf("-1\n");
		return 0;
	}
	int m = 0;
	int ans1[10004], ans2[10004];
	int i, j;
	for (i = 1; i < n; i++)
	{
		ans1[m] = 1;
		ans2[m] = i + 1;
		m++;
	}
	i = 2;
	j = 3;
	while (max > k)
	{
		max--;
		ans1[m] = i;
		ans2[m] = j;
		m++;
		j++;
		if (j > n)
		{
			i++;
			j = i + 1;
		}
	}
	printf("%d\n", m);
	for (i = 0; i < m; i++)
		printf("%d %d\n", ans1[i], ans2[i]);
	return 0;
}


Measured memory_bytes: 256
# include <stdio.h>

int main(void)
{
  int i,N;
  scanf("%d",&N);
  int A[N],B[N],C[N];
  
  for(i = 0;i < N;i++) scanf("%d",&A[i]);
  for(i = 0;i < N;i++) scanf("%d",&B[i]);
  for(i = 0;i < N - 1;i++) scanf("%d",&C[i]);
  
  int sum = 0;
  for(i = 0;i < N;i++) {
  	sum += B[ A[i] - 1];

    if(i > 0 && A[i] == A[i - 1] + 1) sum += C[ A[i - 1] - 1];
   
  }
  
  printf("%d\n",sum);

  return 0;
}
  

Measured memory_bytes: 128
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 0
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
 
//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}
int a,b,c;
main(){
	cin>>a>>b;
	dump(!!(a%b));
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
//const lld MAXN = 1e9;

int main()
{
	priority_queue<int> s;

	while(1)
	{
		string t;
		cin >> t;
		if (t == "end")
		{
			break;
		}

		if (t == "extract")
		{
			int a = s.top();
			s.pop();
			cout << a << endl;
		}else
		{
			int n;
			cin >> n;
			s.push(n);
		}
	}

	return 0;
}

Measured memory_bytes: 7032
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()

typedef long long LL;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> Array;
typedef vector<int> LArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

int itiv;
inline int getInt() { return (cin >> itiv, itiv); }
void readAll(Array& vec, int n) { for (int i = 0; i < n; i++) cin >> vec[i]; }
inline bool between(int first, int last, int n) { return first <= n && n <= last; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

int m, n;
int dx[] = { -1, 0, 1, 0 }, dy[] = { 0, -1, 0, 1 };
int dr[] = { 0, -1, 0, 1 }, dc[] = { -1, 0, 1, 0 };


int main(void)
{
	while(cin >> n && n)
	{
		for (int i = 0; i < n; i++)
		{
			vector<int> arr(3);
			readAll(arr, 3);
			sort(ALL(arr));
			cout << (arr[2] * arr[2] == arr[0] * arr[0] + arr[1] * arr[1] ? "YES" : "NO") << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1204
N, M, X = map(int,input().split())
A = list(map(int,input().split()))
a1 = 0
for k in range(1,X):
    if k in A:
        a1 += 1
a2 = 0
for k in range(X,N):
    if k in A:
        a2 += 1
print(min(a1,a2))


Measured memory_bytes: 38256
#include <iostream>
#include <cmath>
#include <stdint.h>
#include <iomanip>
#include <vector>
#include <queue>
using namespace std;
 
#define int long long
#define INF 1001001001
int ans[2200];
int dis[2200][2200];
vector<int> v[2200];
 
void bfs(int start){
 
 	queue<int> q;
 	
 	q.push(start);
 	
 	dis[start][start] = 1;
 	
 	while(!q.empty()){
 	
 		int u = q.front();
	 	q.pop();
	 	for( int v : v[u]){
		  
		    if(dis[v][start] == 0){
	 		
	 			dis[v][start] = dis[u][start]+1;		
	 			q.push(v);
		    }
     	}
 		
	}
 
	
}
 
 
int32_t main() {
	
    int N,X,Y;
  
    cin >> N >> X >> Y;
	
	X--;Y--;
	
	
	for(int i=0; i<N-1;i++){
		
		v[i].push_back(i+1);
		v[i+1].push_back(i);
		
	}
	
	v[X].push_back(Y);
	v[Y].push_back(X);
 
 	for(int i=0; i<N; i++)
 		bfs(i);
 		
 	for(int i=0; i<N; i++){
 		for(int j=i+1; j<N; j++){
 			
 			 ans[dis[j][i] -1]++;
		 }
 		
	 }	
 	
 	for(int i=1; i<N; i++){
 		
 		cout << ans[i] << endl;
	 }
 	
 	
}

Measured memory_bytes: 37612
import itertools
num = int(input())
array1 = tuple(map(int, input().split()))
array2 = tuple(map(int, input().split()))
all_list = list(itertools.permutations(range(1, num + 1)))
 
array1_index = all_list.index(array1) + 1
array2_index = all_list.index(array2) + 1
 
if array1_index > array2_index:
  print(array1_index-array2_index)
else:
  print(array2_index-array1_index)
  

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

int main (){
    double A , B , H , M ;
    cin >> A >> B >> H >> M;
    double ang = 3.141592653589*(30*H + M/2 -6*M )/180;
    /*if(ang <0){
        ang = (-1)*ang;
    }*/
    double acos;
    acos = cos(ang);

   // cout << ang << endl;
   // cout << acos << endl;
    double ans2 = (A*A) + (B*B) - (2*A*B*acos);
    double ans = sqrt(ans2);
   // cout << ans2 << endl;
  
  cout << fixed << setprecision(16);
    cout << ans << endl;




    
}


Measured memory_bytes: 4188
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }     //最小公倍数
using Graph = vector<vector<ll>>;
ll inf=300000000000000000;
const double PI = 3.14159265358979323846;
int main(){
  ll n;
  cin >> n;
  n--;
  ll o[13];
  o[0]=26;
  rep(i,12)o[i+1]=26*o[i];
  int cnt=0;
  while(o[cnt]<=n){
    n-=o[cnt];
    cnt++;
  }
  cnt++;
  string ans="";
  rep(i,cnt)ans+='a';
  //cout << cnt << endl;
  rep(i,cnt){
    ll u=n%26;
    ans[cnt-1-i]=('a'+u);
    n/=26;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3628
n, m = map(int,input().split())
cor, war = 0,0
c = [[0,0] for k in range(n)] #[ACしたか,WA数]
for i in range(m):
  p,s = list(input().split())
  p = int(p)-1
  if s == "AC" and c[p][0] == 0: #初めてのACなら正答数を増やしてフラグを立て、ペナルティを誤答数分増やす
    cor += 1
    c[p][0] = 1
    war += c[p][1]
  if s == "WA" and c[p][0] == 0: #ACしていない状態でのWA数を記録
    c[p][1] += 1
print(cor,war)    

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

int main() {
  string s;
  cin>>s;
  if(s=="SUN"){
    cout<<7<<endl;
  }
  else if(s=="MON"){
    cout<<6<<endl;
  }
  else if(s=="TUE"){
    cout<<5<<endl;
  }
  else if(s=="WED"){
    cout<<4<<endl;
  }
  else if(s=="THU"){
    cout<<3<<endl;
  }
  else if(s=="FRI"){
    cout<<2<<endl;
  }
  else{
    cout<<1<<endl;
  }
  
}


Measured memory_bytes: 3612
#!/usr/bin/env python3
import sys


def solve(X: int):
    ans = 0
    for b in range(1, 32):
        for p in range(2, 10):
            bp = b**p
            if bp > X:
                pass
            else:
                ans = max(ans, bp)

    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    X = int(next(tokens))  # type: int
    solve(X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return 0;
        }
    }

    // 素数である
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

    
  int main(){
      lint T1,T2,A1,A2,B1,B2;
      cin>>T1>>T2>>A1>>A2>>B1>>B2;
      A1*=T1;
      B1*=T1;
      A2*=T2;
      B2*=T2;
      lint g=0;
    lint dif=abs(A1+A2-B1-B2);
    if(dif!=0){
    if(abs(A1-B1)%dif==0)g++;
    }
      if((A1+A2)==(B1+B2))cout<<"infinity";
      else if(A1>B1&&A2>B2)cout<<0;
      else if(A1<B1&&A2<B2)cout<<0;
      else if(abs(A1-B1)>abs(A2-B2))cout<<0;
      else cout<<(lint)((abs(A1-B1)+dif-1)/dif)*2-1+g;

    }
     
  


Measured memory_bytes: 256
// I look at my watch
// it say nine twenty-five
// And I think oh God
// I'm still alive
 
#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(x) int((x).size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cerr << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define For(i,a,b) for(int i = int(a); i < int(b); ++i)
#define roF(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
 
typedef long long ll;
typedef pair<int,int> ii;
typedef long double ld;

const int N=1e5+100;
vector<ii>gfo[N];
bool color[N];

void dfs(int u,int p,ll c){
	color[u]=c&1;
	for(ii v:gfo[u])if(v.ff!=p)
		dfs(v.ff,u,c+v.ss);
}

int main(){	
	int n;
	cin>>n;
	For(i,0,n-1){
		int u,v,val;cin>>u>>v>>val;
		u--,v--;
		gfo[u].pb({v,val});
		gfo[v].pb({u,val});
	}
	dfs(0,-1,0);
	For(i,0,n)cout<<color[i]<<endl;

	return 0;
}


Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
 
int main(){
	int n;
	vector<int> a;
	
	cin >> n;
	
	int mostLargestNum = 0;
	int secondLargestNum = 0;
	for(int i = 0; i < n; i++){
		int input;
		cin >> input;
		a.push_back(input);
		if(input > mostLargestNum){
			secondLargestNum = mostLargestNum;
			mostLargestNum = input;
		}
		else if(input > secondLargestNum){
			secondLargestNum = input;
		}
	}
	
	for(int i = 0; i < n; i++){
		if(a[i] == mostLargestNum){
			cout << secondLargestNum << endl;
		}else{
			cout << mostLargestNum << endl;
		}
	}
	
	return 0;
}

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

#define ll long long
#define int long long
#define loop(i,s,e) for(int i=s;i<e;i++)
#define rloop(i,s,e) for(int i=e;i>=s;i--)
#define fr first
#define sc second
#define pb push_back
#define  vii vector<int>
#define vll vector<ll>
#define vpii vector<pair<int ,int >>
#define vpll vector<pair<ll, ll> >
#define  pii pair<int,int>
#define lb(v,x) lower_bound(v.begin(),v.end(),x);
#define ub(v,x) upper_bound(v.begin(),v.end(),x);
const long mod =1e9+7;
const int N = 2e5+10;
const long long inf= 1e18;

ll gcd(ll a ,ll b){if(b==0) return a;return gcd(b,a%b);}
ll mul(ll a ,ll b){return (a%mod * b%mod )%mod;}
ll mpower(ll a, ll b){if(b==0) return 1;ll temp=mpower(a,b/2);if(b%2==0){return mul(temp,temp);}else{	return mul(mul(temp,temp) , a);}}
ll inv(ll a){return mpower(a,mod-2);}
ll ncr(ll n, ll r){if(r==0)return 1;ll ans=n%mod;ans=mul(ans,ncr(n-1,r-1));ans=mul(ans,inv(r));	return ans;}
ll power(ll a, ll b){if(b==0) return 1;ll temp=power(a,b/2);if(b%2==0)return temp*temp;else return temp*temp*a;}
ll add(ll a, ll b){return (a%mod + b%mod)%mod;}


void solve()
{
   int n;cin>>n;
   int a[n];
   loop(i,0,n)
   {
       cin>>a[i];
   }
   map<int,int> mp;
   int ans=0;
   loop(i,0,n)
   {
       ans+=mp[i-a[i]];
       mp[i+a[i]]++;
   }
   cout<<ans;
   

    
}

int32_t main()
{
	ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t=1;//cin>>t;
	while(t--){
        solve();
	}
}

Measured memory_bytes: 27848
import java.util.*;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int a[] = new int[N];
		int ans = 0;
		int flag = 0;
		int sum = 0;
		int R = 2;
		for(int i=0;i<N;i++)
		{
			a[i] = sc.nextInt();
		}
		for(int i=0;i<N;i++)
		{
			if(a[i]==1)
			{
				sum = i;
				flag = 1;
				ans = i;
				break;

			}
		}
		if(flag==0)
		{
			System.out.println(-1);
		}
		else if(flag==1)
		{
			for(int i=ans;i<N;i++)
			{
				if(R==a[i])
				{
					R++;
				}
				else
				{
					sum++;
				}
			}
			System.out.println(sum-1);
		}
	}
}

Measured memory_bytes: 68428
n = int(input())
numbers = list(map(int, input().split()))
ans = 0
while True:
    index = 1
    for i in range(n):
        if numbers[i] % 2 == 0:
            numbers[i] = numbers[i] / 2
        else:
            index = 0
            break
    if index == 1:
        ans += 1
    else:
        break
print(ans)


Measured memory_bytes: 2940
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class xCubic
    {
        static void Main(string[] args)
        {
            var x = int.Parse(Console.ReadLine());

            Console.WriteLine(x * x * x);

        }
    }
}



Measured memory_bytes: 15944
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 1005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


int arr[maxii];
int arr2[maxii];
int gcd(int a,int b)
{
    if(b==0){
      return a;
     }
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    int res=(a*b)/gcd(a,b);
    return res;
}
int po(int a,int b)
{
    int res=1;
    while(b)
    {
        if(b%2!=0)
        {
            res*=a;
            b--;
        }
        else
        {
            a*=a;
            b/=2;
        }
    }
    return res;
}

lln modMul(lln  a, lln b,lln mod){
    lln ans = 0;
    a = a % mod;
    while (b > 0){
        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;
        a = (a%mod * 2%mod) % mod;
        b /= 2;
    }
    return ans % mod;
}
lln powerMod(lln a,lln b,lln mod){
	if(b==0)return 1LL%mod;
	lln x=powerMod( a,b/2,mod );
	x = ( x%mod * x%mod ) % mod;
	if( b%2==1 )x = ( x%mod * a%mod ) % mod;
	return x%mod;
}

int main()
{
char a;
cin>>a;
if(a>='a' && a<='z')
{
    cout<<"a";
}
else cout<<"A";

}







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

#define crap ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define repA(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define CN cout<<"No\n"
#define CY cout<<"Yes\n"

using namespace std;
using ll = long long;
ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);  
      
} 
// #define MAXN 1000001 
// ll sieve[MAXN]; 
// void makesieve()
// {
//     sieve[1] = 1; 
//     for (int i = 2; i < MAXN; i++) 
//         sieve[i] = i; 
//     for (int i = 4; i < MAXN; i += 2) 
//         sieve[i] = 2; 
//     for (int i = 3; i * i < MAXN; i++) { 
//         if (sieve[i] == i) { 
//             for (int j = i * i; j < MAXN; j += i) 
//                 if (sieve[j] == j) 
//                     sieve[j] = i; 
//         } 
//     } 
// }
ll powerflow(ll x, ll n)
{
    ll res;
    if (n == 0) {
        return 1;
    }
    res = powerflow(x, n-1);             // recurse
    if(INT_MAX / res < x) {          // check for overflow
        return -1; //LONG_MAX;
    }
    return x * res;
}
ll mod=1000000007;
ll power(ll a,ll b,ll m)
{
    a%=m;b%=m;
    ll res=1;
    while(b!=0)
    {
        if(b&1)
        res=(res*a);
        b=b/2;
        a=(a*a)%mod;
    }
    return res;
}
struct compare  
 {  
   bool operator()(const int& l, const int& r)  
   {  
       return l > r;  
   }  
 };
void solve()
{
    int n; cin>>n;
    vector<pair<int,int>>v(n);
    rep(i,n)
    {
        int x,y; cin>>x>>y;
        v[i]={x,y};
    }
    int f=0;
    for(int i=1;i<n-1;i++)
    {
        if(v[i-1].F==v[i-1].S&&v[i].F==v[i].S&&v[i+1].F==v[i+1].S)
        {
            CY;
            return;
        }
    }
    CN;

}
int main()
{
    crap;
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r", stdin) ;
        freopen("output.txt","w", stdout) ;
        freopen("error.txt","w", stderr) ;
    #endif
    int t;t=1;
   // cin>>t;
    while(t--)
        {solve();}
    return 0;
}

Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
string s[501];
int d[26][26],n;
int main(){
  while(cin>>n,n){
    int ans=0,f=0;
    r(i,26)r(j,26)d[i][j]=1e8;
    r(i,n)cin>>s[i];
    r(i,n-1){
      r(j,s[i].size()){
        if(j>=s[i+1].size()){f++;break;}
        if(s[i][j]!=s[i+1][j]){
            d[s[i][j]-'a'][s[i+1][j]-'a']=-1;
            break;
        }
      }
    }
    r(k,26)r(i,26)r(j,26)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    r(i,26)if(d[i][i]<0)ans++;
    cout<<(ans||f?"no":"yes")<<endl;
  }
}

Measured memory_bytes: 3132
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC114A
{
    class Program
    {
        static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());


            if (x == 3 || x == 5 || x == 7)
                Console.WriteLine("YES");
            else Console.WriteLine("NO");

            Console.ReadKey();
        }
    }
}


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

int main() {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N-1);
  for (int i=0; i<N; i++) {
    cin >> A.at(i);
  }
  for (int i=0; i<N; i++) {
    cin >> B.at(i);
  }
  for (int i=0; i<N-1; i++) {
    cin >> C.at(i);
  }
  int answer = 0;
  for (int i=0; i<N; i++) {
    answer += B.at(i);
  }
  for (int i=0; i<N-1; i++) {
    if (A.at(i+1)-A.at(i) == 1) {
      answer += C.at(A.at(i)-1);
    }
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;
constexpr double pi = acos(-1);
constexpr double EPS = 1e-10;

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

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

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

    int num = 1;
    ll ans = 0;
    for(int i=0; i<n; i++){
        ans += (a[i] - 1) / num;
        if(i == 0 || num == a[i]) num++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
#define REP(i,a) for(int i = 0; i < (a);i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;
using Graph = vector < vector<int>>;
long int sum[200020] = {};
/*切り上げの計算！*/
int maxtime(int x) {
	return(x + 9) / 10 * 10;

}
int main() {
	int N;
	cin >> N;
	int Q;
	cin >> Q;
	string s;
	cin >> s;
	vector<int> t(N,0);
	for (int i = 1; i < N; i++) {
		string k;
		k = "AC";
		if ((s[i - 1] == k[0]) && (s[i] == k[1])) {
			t[i] = t[i] + 1;
		}
	}
	vector<int> ruiseki(N + 20, 0);
	ruiseki[0] = 0;
	for (int i = 1; i <= N; i++) {
		ruiseki[i] = ruiseki[i - 1] + t[i - 1];
	}
	for (int i = 0; i < Q; i++) {
		int a;
		int b;
		cin >> a >> b;
		cout << ruiseki[b] - ruiseki[a] << endl;
	}
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <deque>
#include <numeric>
#include <cmath>
#include <map>
#include <set>
#define ull unsigned long long
#define ll long long
using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << a*b-(a+b-1) << endl;

    return 0;
}

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

using namespace std;

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

  vector<int> v;
  for(int i=0;i<n;i++){
    int x;
    cin >> x;
    v.push_back(x);
  }

  int sum = 0;
  for(int i=0 ; i<n ; i++){
    for(int j=i+1 ; j<n ; j++){
      sum += v[i]*v[j];
    }
  }

  cout << sum;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

	long long int X;
	scanf("%lld", &X);

	long long int i;
	long long kake = 0;

	for(i = 0; i < 1000000000; i++){
		
		kake  = i * (i + 1);

		if(2 * X <= kake){
			break;
		}

	}

	printf("%lld\n", i);

	return 0;

}

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

int main(void){
	long L, R;
  	int a[2019] = {0};
  	cin >> L >> R;
  	if (R - L >= 2019) cout << 0 << endl;
  	else{
      int tmp = 0;
      for (long i = L; i < R ; i++){
        for (long j = i+1;  j <= R; j++){
          tmp = i*j%2019;
          a[tmp] = 1;
        }
      }
      for (int i = 0; i < 2019 ; i++){
		if(a[i] == 1) {
         	cout << i << endl;
        	break;
        }
      }
    }
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int dp[100001];
vector <int> g[100001];

int f(int node) {
	if(dp[node]!=-1)
	return dp[node];
	
	int ans =0;
	for(int i=0; i<g[node].size(); ++i) {
		ans = max(ans, f(g[node][i]));
	}
	dp[node] = ans+1;
	return dp[node];
}

int main() {
	int n, m, x, y, l=0;
	cin>>n>>m;
	
	for(int i=0; i<m; ++i){
		cin>>x>>y;
		g[x].push_back(y);
	}
	for(int i=0; i<n+1; ++i)
	dp[i]=-1;
	for(int i=1; i<=n; ++i) {
		l = max(l, f(i));
	}
	cout<<(l-1);
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;

class BIT{
    long long *tree;
    int depth;

    public:
    BIT(unsigned int n){
        for(depth=0;(1<<depth)<n;depth++) ;
        tree = new long long[1<<depth]();
    }

    void add(unsigned int index, long long value){
        index++;
        for(;index<=(1<<depth);index+=index&-index){
            tree[index-1]+=value;
        }
    }

    long long sum(unsigned int index){
        index++;
        long long s=0;
        for(;index>0;index-=index&-index){
            s+=tree[index-1];
        }

        return s;
    }

    long long sum(unsigned int left, unsigned int right){
        return sum(right-1) - sum(left-1);
    }

    ~BIT(){
        delete[] tree;
    }
};
/*
    BIT bit(N);     // 長さ N の列について管理
    bit.add(i, v);  // 列(0-indexed)の i 番目に v を加算
    bit.sum(i);     // 列(0-indexed)の 0 番目から i 番目までの i+1 個の要素の和を返す
                    // i 番目も和に*含まれる*ことに注意
    bit.sum(l,r);   // 列の i ∈ [l, r) 番目の要素の和を返す
                    // r 番目は和に*含まない*ことに注意
*/

int main(){
    ll n;
    ll A[200000], AA[200000];
    unordered_map<ll, ll> f;
    cin >> n;
    for(ll i=0;i<n;i++){
        cin >> A[i];
        AA[i]=A[i];
    }
    sort(AA, AA+n);
    ll j=0;
    for(ll i=0;i<n;i++){
        if(i==0 || AA[i]!=AA[i-1]){
            f[AA[i]]=j;
            j++;
        }
    }
    BIT B(200000);
    ll inversion = 0;
    for(ll i=0;i<n;i++){
        ll tt = B.sum(f[A[i]]);
        ll t  = i - tt;
        B.add(f[A[i]], 1);

        inversion += t;
    }
    cout << inversion << endl;
    
    return 0;
}


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

using namespace std;

int arr1[100001];
int dfs(int *arr,int index,int n)
{
  if(index>=n)
    return 1e8;
  
  if(index==n-1)
    return 0;
  
  if(arr1[index]!=-1)
    return arr1[index];
  
  if(index+2<n)
  {
    return arr1[index] = min(abs(arr[index]-arr[index+1])+dfs(arr,index+1,n),abs(arr[index]-arr[index+2])+dfs(arr,index+2,n));
  }
  
  else
  {
    return arr1[index] = abs(arr[index]-arr[index+1]+dfs(arr,index+1,n));
  }
  
}

int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n;
  cin>>n;
  int arr[n];
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  memset(arr1,-1,sizeof(arr1));
  int ans = dfs(arr,0,n);
  
  cout<<ans<<endl;
    
}

Measured memory_bytes: 8976
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n,sumv=0;
	cin>>n;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=n-1;i++)
	{
		for (int j=i+1;j<=n;j++)  sumv+=a[i]*a[j];
	}
	cout<<sumv<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.stream.DoubleStream;

public class Main {
    public static void main(String[] args) {
        try (BufferedReader in = new BufferedReader(new InputStreamReader(System.in))){
            while (true) {
                int n = Integer.parseInt(in.readLine());
                if (n == 0) break;

                double[] arr = Arrays.stream(in.readLine().split(" "))
                        .mapToDouble(Double::parseDouble)
                        .toArray();

                double m = DoubleStream.of(arr).average().getAsDouble();
                double a2 = DoubleStream.of(arr).map(d -> Math.pow((d - m), 2)).sum() / n;
                double a = Math.sqrt(a2);
                System.out.printf("%.8f\n", a);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}



Measured memory_bytes: 32068
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
int x[200005],y[200005];
const double pi=3.1415926535897932384626433832795;
struct cross
{
    int x;
    int y;
    friend bool operator < (const cross &a,const cross &b)
    {
        return a.x<b.x;
    }
};
cross c[200005];
int ans[200005];
int dp[200005];
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int x1,y1;
    int x2,y2;
    scanf("%d%d",&x1,&y1);
    scanf("%d%d",&x2,&y2);
    int n;
    scanf("%d",&n);
    int i;
    for (i=0;i<n;i++)
    {
        scanf("%d%d",&x[i],&y[i]);
    }
    if (x1==x2)
    {
        double ans=abs(y2-y1)*100ll;
        for (i=0;i<n;i++)
        {
            if (x[i]==x1)
            {
                if ((y1<y[i])&&(y[i]<y2)) ans+=10*(pi-2);
                if ((y2<y[i])&&(y[i]<y1)) ans+=10*(pi-2);
            }
        }
        printf("%.15lf\n",ans);
    }
    else if (y1==y2)
    {
        double ans=abs(x2-x1)*100ll;
        for (i=0;i<n;i++)
        {
            if (y[i]==y1)
            {
                if ((x1<x[i])&&(x[i]<x2)) ans+=10*(pi-2);
                if ((x2<x[i])&&(x[i]<x1)) ans+=10*(pi-2);
            }
        }
        printf("%.15lf\n",ans);
    }
    else
    {
        if (x1>x2)
        {
            swap(x1,x2);
            swap(y1,y2);
        }
        if (y1>y2)
        {
            swap(y1,y2);
            for (i=0;i<n;i++)
            {
                y[i]=y1+y2-y[i];
            }
        }
        int num=0;
        for (i=0;i<n;i++)
        {
            if ((x1<=x[i])&&(x[i]<=x2)&&(y1<=y[i])&&(y[i]<=y2))
            {
                c[num].x=x[i];
                c[num].y=y[i];
                num++;
            }
        }
        sort(c,c+num);
        for (i=0;i<num;i++)
        {
            ans[i]=999999999;
        }
        int now_max_ans=0;
        for (i=0;i<num;i++)
        {
            int t=lower_bound(ans,ans+now_max_ans,c[i].y)-ans;
            if (t==now_max_ans) now_max_ans++;
            ans[t]=c[i].y;
        }
        double final_ans=(y2-y1)*100ll+(x2-x1)*100ll-now_max_ans*10*(2-pi/2);
        if (now_max_ans>min(x2-x1,y2-y1)) final_ans+=5*pi;
        printf("%.15lf\n",final_ans);
    }
    return 0;
} 


Measured memory_bytes: 4096
import java.util.Scanner;
 
public class Main {
	public static void main (String args[]) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		if(n % 2 == 0) {
			System.out.println(n / 2);
		} else {
			System.out.println((n / 2) + 1);			
		}
	}
}

Measured memory_bytes: 21972
module Main where

-- import Utils

import Control.Applicative

getInt :: IO Int
getInt = head <$> getInts

getInts :: IO [Int]
getInts = map read . words <$> getLine

main :: IO ()
main = do
  {[a, b] <- getInts
  ; putStrLn (unwords (map show[a * b,2 * (a + b)])) 
  }

  




Measured memory_bytes: 3640
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back


signed main(){
    int n;
    cin>>n;
    vector<int> c(n);
    rep(i,n)cin>>c[i];
    
    vector<int> v(n,0);
    int q;
    cin>>q;
    vector<int> t(q),x(q),d(q);
    rep(i,q)cin>>t[i]>>x[i]>>d[i];
    rep(i,q){
        x[i]--;
        if(t[i]==1){   //input
            v[x[i]] += d[i];
            if(v[x[i]]>c[x[i]]){
                cout<<x[i]+1<<endl;
                return 0;
            }
        }else{  //output
            v[x[i]] -= d[i];
            if(v[x[i]]<0){
                cout<<x[i]+1<<endl;
                return 0;
            }
        }
    }
    cout<<0<<endl;
}



Measured memory_bytes: 5216
import sys
N, M = map(int, input().split())
A = [input() for s in range(N)]
B = [input() for s in range(M)]
for i in range(N - M + 1):
    for j in range(N - M + 1):
        flg = 1
        for x in range(M):
            for y in range(M):
                if B[x][y] !=  A[i+x][j+y]:
                    flg = 0
        if flg == 1:
            print('Yes')
            sys.exit()
print('No')

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int m = scanner.nextInt();
			int c = scanner.nextInt();
			scanner.nextLine();
			int b[] = new int[m];
			IntStream.range(0, m).forEach(i -> b[i] = scanner.nextInt());
			scanner.nextLine();
			System.out.println(IntStream.range(0, n).filter(i -> {
				int sum = IntStream.range(0, m).map(j -> scanner.nextInt() * b[j]).sum();
				scanner.nextLine();
				return (sum + c) > 0;
			}).count());
		}
	}
}


Measured memory_bytes: 28628
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <climits>
#include <map>
typedef long long ll;
using namespace std;

typedef pair<int,int> p;

int main()
{
  // input & declare
  ll x;
  cin >> x;
  int i = 1;
  ll sum = 0;
  while (true) {
    sum += i;
    if (sum >= x) {
      std::cout << i << '\n';
      exit(0);
    }
    i++;
  }

}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

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

int main() {
    int a, b; cin >> a >> b;

    if (a <= b) cout << a << endl;
    else cout << a - 1 << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

	public class Main {

		static long mod = 1000000007;

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);
			String[] t = sc.nextLine().split(" ");
			int n  	   = Integer.parseInt(t[0]);
			int ans    = 0;
			//long k = Long.parseLong(t[1].replaceAll("\\.", ""));

			String[] r = sc.nextLine().split(" ");
			for(int i = 0; i < n; i ++) {
				ans += twoThree(Integer.parseInt(r[i]));
			}

			System.out.println(ans);
		}

		public static int twoThree(int x) {

			int cnt = 0;
			while(x % 2 == 0) {

				if(x % 2 == 0) {
					x /= 2;
				}
				cnt++;
			}
			return cnt;
		}
	}


Measured memory_bytes: 41092
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;

int main(){
    int a,b;
    cin>>a>>b;
    if(a>8||b>8) cout<<":("<<endl;
    else cout<<"Yay!"<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int Com(int n, int k) {
	int x=1, y=1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

int dp[150][3][150];

signed main() {
	string n;
	int K;
	cin >> n >> K;
	dp[0][0][0] = 1;
	for (int i = 0; i < n.size(); i++) {
		int D = n[i] - '0';
		for (int j = 0; j < 2; j++) {
			for (int k = 0; k <= n.size(); k++) {
				for (int d = 0; d <= (j ? 9 : D); d++) {
					dp[i + 1][j || (d < D)][d ? k + 1 : k] += dp[i][j][k];
				}
			}
		}
	}
	cout << dp[n.size()][1][K] + dp[n.size()][0][K] << endl;

	return 0;
}

Measured memory_bytes: 640