akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<stdio.h>
#include<string>
#include<numeric>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define sz(x) int(x.size())
#define INF 1e5
#define MODE 1000007
int main(){
	double w,h,x,y;
	cin>>w>>h>>x>>y;
	if(w/2==x && h/2==y) cout<<w*h/2<<" "<<1<<endl;
	else cout<<w*h/2<<" "<<0<<endl;
}


Measured memory_bytes: 384
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))
A.insert(0, 0)

ans = [[-1 for _ in range(W)] for _ in range(H)]
color = 1

for i in range(H):
    for j in range(W):
        if A[color] == 0:
            color += 1
        A[color] -= 1
        ans[i][j] = color

for i in range(H):
    a = ans[i]
    if i % 2 == 1:
        a = a[::-1]
    print(" ".join(map(str, a)))

Measured memory_bytes: 3572
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")

//# include <x86intrin.h>
# include <bits/stdc++.h>

//# include <ext/pb_ds/assoc_container.hpp>
//# include <ext/pb_ds/tree_policy.hpp>

//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int cnt[N];
string s;
int a[N];
vector < int > g[N];
int u[N];
int ans, res;
int cur;
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	shuffle(permutation.begin(), permutation.end(), rng);



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

	if (c > a + b && (c - a - b) * (ll)(c - a - b) > 4ll * a * (ll)b) puts("Yes");
	else puts("No");
	return Accepted;
}

// B...a

Measured memory_bytes: 18688
MOD = 10**9 + 7
list_size = 20000001

f_list = [1] * list_size
f_r_list = [1] * list_size

for i in range(list_size-1):
	f_list[i+1] = (f_list[i] * (i+1)) % MOD

f_r_list[-1] = pow(f_list[-1], MOD - 2, MOD)

for i in range(list_size-2, -1, -1):
	f_r_list[i] = (f_r_list[i+1] * (i+1)) % MOD

h, w, k = map(int, input().split())
ans = k * f_list[h+w] * f_r_list[h+w-k]
ans += (h+w) * k * (k+1) * f_list[h+w-1] * f_r_list[2] * f_r_list[h+w-k]
ans %= MOD
ans += h * w * f_list[h+w-2] * (k-1) * k * (k+1) * pow(3, MOD-2, MOD) * f_r_list[h+w-k]
ans %= MOD
print(ans)

Measured memory_bytes: 346904
from copy import deepcopy

def getval():
    n,a = map(int,input().split())
    x = list(map(int,input().split()))
    return n,a,x

def main(n,a,x):
    #DP: dp[ith card][j cards picked][sum k]
    dp = [[[0 for k in range(2500+1)] for j in range(n+1)]]
    dp[0][0][0] = 1
    for i in range(n):
        cur = x[i]
        temp = deepcopy(dp[-1])
        for j in range(1,n+1):
            prev = dp[-1][j-1]
            for k in range(1,2500+1):
                if cur<=k:
                    temp[j][k] += prev[k-cur]
        dp.append(temp)
    ans = 0
    for i in range(1,n+1):
        ans += dp[n][i][a*i]
    print(ans)
      
if __name__=="__main__":
    n,a,x = getval()
    main(n,a,x)

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

int main(void) {
    while (true) {
        int n,x;cin>>n>>x;
        if (n == 0 && x == 0) break;
        int result = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = i + 1; j <= n; j++) {
                for (int k = j + 1; k <= n; k++) {
                    if (i + j + k == x) result++;
                }            
            }
        }
        cout << result << endl;        
    }

    return 0;
}


Measured memory_bytes: 3084
using System;
using System.Linq;

namespace abc056_b
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            Console.WriteLine(Math.Max(0, Math.Max(x[2] - (x[0] + x[1]), x[1] - (x[0] + x[2]))));
        }
    }
}

Measured memory_bytes: 13268
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { -1,0,1,0 }, dy[4] = { 0,-1,0,1 };
const char dir[4] = { 'u','l','d','r' };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        (wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)
# pragma warning(disable:4996)

int n, m;
int a[101010];

int main() {
	cin >> n >> m;
	REP(i, n)cin >> a[i];
	REP(i, n) {
		if (i)a[i] += a[i - 1];
		a[i] %= m;
	}
	map<LL, LL>cnt;
	cnt[0]++;
	REP(i, n)cnt[a[i]]++;
	LL ans = 0;
	for (auto e : cnt)ans += e.second*(e.second - 1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 4608
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=int (a);i<int (n);i++)
#define OUT  freopen("output.txt", "w", stdout)
#define IN  freopen("input.txt", "r", stdin)
#define mem(a,b) memset((a),(b),sizeof(a))
#define NumofDigits(n) ((int)log10(n)+1)
#define NumofBits(n) ((int)log2(n)+1)
#define PI 3.14159265358979323846264
#define vii vector<pair<int,int>>
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi  vector<int>
#define nl  cout<<"\n"
#define pb  push_back
#define mp  make_pair
#define ll  long long 
#define ss  second 
#define ff  first
#define endl "\n"
#define sp  " "
using namespace std;
	
int main(){
ios::sync_with_stdio(0);cin.tie(0);

ll t=1; //cin>>t; 
while(t--){
ll n,W;cin>>n>>W;
ll w[n],val[n];
rep(i,0,n)cin>>w[i]>>val[i];
ll ar[n+1][W+1];
rep(i,0,n+1)ar[i][0]=0;
rep(i,0,W+1)ar[0][i]=0;

rep(i,1,n+1){
rep(j,1,W+1){
	if(w[i-1]<=j)
	ar[i][j]=max(val[i-1]+ar[i-1][j-w[i-1]],ar[i-1][j]);
	else ar[i][j]=ar[i-1][j];
}
}
/*rep(i,0,n+1){rep(j,0,W+1)cout<<ar[i][j]<<sp;nl;}*/
cout<<ar[n][W];



}


}


Measured memory_bytes: 82424
#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;

signed main(){
    int n;
    cin >> n;
    string s;
    string even;
    cout << 0 << endl;
    cin >> s;
    if(s == "Male"){
        even = s;
    }else if(s == "Female"){
        even = s;
    }else{
        return 0;
    }
    int left = -1, right = n;
    while(abs(right - left) > 1){
        int mid = (right + left) / 2;
        cout << mid << endl;
        cin >> s;
        if(s == "Vacant"){
            return 0;
        }else if((mid % 2 == 0 && s == even) || (mid % 2 == 1 && s != even)){
            left = mid;
        }else{
            right = mid;
        }
    }
    return 0;
}

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

using namespace std;
class UnionFind {
public:
	vector<int> Parent;

	UnionFind(int N) {
		Parent = vector<int>(N, -1);
	}

	int root(int A) {
		if (Parent[A] < 0)return A;
		return Parent[A] = root(Parent[A]);
	}

	int size(int A) {
		return -Parent[root(A)];
	}

	bool connect(int A, int B) {
		A = root(A);
		B = root(B);
		if (A == B)
			return false;

		if (size(A) < size(B))
			swap(A, B);

		Parent[A] += Parent[B];
		Parent[B] = A;

		return true;
	}
};
		
int main(){
	
	int N,M;
	cin>>N>>M;
	vector<int>A(M),B(M);
	for(int i=0;i<M;i++){
		cin>>A[i]>>B[i];
		A[i]--;
		B[i]--;
	}
	vector<long long> ans(M);
	ans[M-1]=(long long)N*(N-1)/2;
	
	UnionFind Uni(N);

	for(int i=M-1;i>0;i--){

		if(Uni.root(A[i])!=Uni.root(B[i])){
			ans[i-1]=ans[i]-(long long)Uni.size(A[i])*Uni.size(B[i]);
			Uni.connect(A[i],B[i]);
		}
		else ans[i-1]=ans[i];
		
	}
	for(int i=0;i<M;i++)
		cout<<ans[i]<<endl;
	
	return 0;
}
	


Measured memory_bytes: 3328
// created by mtnshh
 
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;

#define ll long long
#define ld long double
 
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
 
#define err() cout<<"--------------------------"<<endl; 
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)    A.rbegin(),A.rend()
#define ft first
#define sd second
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V>
#define Vpll vector<pll>
 
#define endl "\n"
 
const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e18;
#define PI 3.14159265
 
const ll N = 100005;

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin >> n;
    ll A[n];
    rep(i,0,n)  cin >> A[i];
    sort(A, A+n);
    reverse(A, A+n);
    ll done = n - 2;
    ll ans = A[0];
    rep(i,1,n){
        if(done > 1){
            ans += 2 * A[i];
            done -= 2;
        }
        else if(done == 1){
            ans += A[i];
            done -= 1;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int q;
  cin >> q;
  vector<set<int>> sevec(26);
  for (int i = 0;i<n;++i){
    int now = s[i] - 'a';
    sevec[now].insert(i);
  }
  
  for (int i = 0;i<q;++i){
    int kind;
    cin >> kind;
    if (kind == 1){
      int iq;
      char cq, charbef;
      cin >> iq >> cq;
      --iq;
      charbef = s[iq];
      s[iq] = cq;
      sevec[charbef - 'a'].erase(iq);
      sevec[cq - 'a'].insert(iq);
    }else{
      int lq, rq;
      cin >> lq >> rq;
      --lq;--rq;
      int ans = 0;
      for(int i=0;i<26;++i){
        auto ite = sevec[i].lower_bound(lq);
        if (ite != sevec[i].end()){
          int val = *ite;
          if (val <= rq) ++ans;
        }
      }
      cout << ans << endl;
    }
  }
}


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

int main() {
  int a,b;
  cin >> a >> b;
  if(a <= 2*b) cout << 0 << endl;
  else cout << a-2*b << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int D = sc.nextInt();
		int T = sc.nextInt();
		int S = sc.nextInt();

		if(D <= T*S)
		{
			System.out.println("Yes");
		}
		else
		{
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 27060
#include <bits/stdc++.h>
using namespace std;
int n,a[200005];
inline bool check(int x)
{
	if(x==1)
	{
		bool ch=true;
		for(int i=1;i<n;i++)
		{
			if(a[i+1]<=a[i])
			{
				ch=false;
			}
		}
		return ch;
	}
	map<int,int> mp;
	int cur=-1;
	for(int i=1;i<=n;i++)
	{
		if(a[i]<=cur)
		{
			cur=a[i];
			while(1)
			{
				if(mp[cur]<x-1)
				{
					break;
				}
				mp[cur]=0;
				cur--;
			}
			mp[cur]++;
			if(cur<=0)
			{
				return false;
			}
		}
		else
		{
			cur=a[i];
		}
		mp.erase(mp.upper_bound(cur),mp.end());
	}
	return true;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int l=1,r=300000,ans;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(check(mid))
		{
			ans=mid,r=mid-1;
		}
		else
		{
			l=mid+1;
		}
	}
	cout<<ans;
	return 0;
}

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

signed main(){
    int n;
    cin >> n;
    int a[5];
    for(int i = 0; i < 5; i++) cin >> a[i];
    int MIN = a[0];
    for(int i = 1; i < 5; i++) MIN = min(MIN, a[i]);
    int ans = (n + MIN - 1) / MIN + 4;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

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

    ll sum = 0;
    rep(i,N) sum += A[i];

    ll sum2 = 0;
    ll ans = sum;
    rep(i,N){
        sum -= A[i], sum2 += A[i];
        ans = min(ans,abs(sum-sum2));
    }
    pr(ans);
    return 0;
}


Measured memory_bytes: 1024
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int P = 1e9 + 7;

int main(){
  int n , x;
  scanf("%d",&n);
  vector<pii> v;
  rep(i,0,n) {
    scanf("%d",&x);
    v.pb(mp(x , 0));
  }
  rep(i,0,n) {
    scanf("%d",&x);
    v.pb(mp(x , 1));
  }
  sort(all(v));
  int cnt = 0 , type = 0;
  int ans = 1;
  for(auto e : v) {
    if(cnt && type != e.se) {
      ans = ll(ans) * cnt % P;
      --cnt;
    } else {
      type = e.se;
      ++cnt;
    }
  }
  printf("%d\n",ans);
  return 0;
}


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

//--------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

//--------------------------------------------
const double EPS = 1e-14;
const double PI  = acos(-1.0);

//--------------------------------------------

int main(){
  int n;
  string s;

  cin >> n >> s;

  int sum = 0;
  int max = 0;
  REP(i, n) {
    if (s.at(i) == 'I') sum += 1;
    else sum -= 1;

    if (sum > max) max = sum;
  }

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


Measured memory_bytes: 256
N, D, A = map(int, input().split())
XH = sorted([tuple(map(int, input().split())) for _ in range(N)])
ans, r, S, R = 0, 0, [0] * (N + 2), []
for l in range(N):
    while r + 1 < N and XH[r + 1][0] - XH[l][0] <= 2 * D:
        r += 1
    S[l + 1] += S[l]
    bomb = (max(XH[l][1] - S[l + 1], 0) + A - 1) // A
    ans += bomb
    S[l + 1] += bomb * A
    S[r + 1 + 1] -= bomb * A
    R.append(r)
print(ans)


Measured memory_bytes: 90712
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {
	int INF = 1<<28;
	double EPS = 1e-9;
	long MOD = (long)1e9 + 7;
	int n, m;
	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			n = sc.nextInt(); m = sc.nextInt();
			int a = sc.nextInt(), b = sc.nextInt(), c = sc.nextInt(), t = sc.nextInt();
			if((n|m|a|b|c|t) == 0) break;
			MOD = m;
			long[] s = new long[n];
			for(int i=0;i<n;i++) {
				s[i] = sc.nextLong();
			}
			
			long[][] A = new long[n][n];
			for(int i=0;i<n;i++) {
				if(i-1 >= 0) A[i][i-1] = a;
				A[i][i] = b;
				if(i+1 < n) A[i][i+1] = c;
			}
//			debug(A);
			A = pow_mod(A, t);
			long[] ans = new long[n];
			for(int i=0;i<n;i++) {
				for(int j=0;j<n;j++) ans[i] = ( ans[i] + A[i][j] * s[j]) % MOD;
			}
			
			for(int i=0;i<n;i++) System.out.print(ans[i] + (i==n-1? "\n": " "));
		}
	}
	
	long[][] pow_mod(long[][] A, int t) {
		long[][] ret = new long[n][n];
		for(int i=0;i<n;i++)ret[i][i] = 1;
		
		while(t>0) {
			if((t&1)==1) {
				ret = mlt_mod(ret, A);
			}
			A = mlt_mod(A, A);
			t >>= 1;
//			debug(ret, A, t);
		}
		
		return ret;
	}
	
	long[][] mlt_mod(long[][] A, long[][] B) {
		long[][] ret = new long[n][n];
		for(int i=0;i<n;i++) for(int j=0;j<n;j++) {
			for(int k=0;k<n;k++) ret[i][j] = (ret[i][j] + A[i][k] * B[k][j]) % MOD;
		}
		return ret;
	}
	
	void debug(Object...os) {
		System.err.println(deepToString(os));
	}
	
	public static void main(String[] args ){
		new Main().run();
	}
}

Measured memory_bytes: 56444
using System;
using System.Linq;

namespace ABC082
{
    class A
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
            Console.WriteLine(Math.Ceiling((s[0] + s[1]) * 0.5));
        }
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
using namespace std;
ll INF = 1000000007;
using Graph = vector<vector<ll>>;

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する

vector<int> next_y = {-1,1,0,0};
vector<int> next_x = {0,0,-1,1};

//h : 行 w : 列
ll h, w;
vector<vector<string>> vec(h, vector<string>(w));


int main() {
    cin >> h >> w;
    vec.resize(h, vector<string>(w));

    //全マスを未訪問(-1)に初期化
    vector<vector<ll>> dist(h, vector<ll>(w, -1));

    //グリッドの読み込み
    string s;
    queue< pair<ll,ll> > black;
    rep(i,h){
        cin >> s;
        rep(j,w){
            vec.at(i).at(j) = s[j];
            if(vec.at(i).at(j) == "#"){
                black.push(make_pair(i,j));
                dist[i][j] = 0;
            }
        }
    }

    while(!black.empty()){

        pair<ll,ll> black_pos = black.front();
        ll black_y = black_pos.first;
        ll black_x = black_pos.second;
        black.pop();

        rep(i,4){
            //次に行くマス
            ll next_pos_y = black_y + next_y.at(i);
            ll next_pos_x = black_x + next_x.at(i);
            
            //場外なら何もしない
            if(next_pos_x < 0 || next_pos_x >= w || next_pos_y < 0 || next_pos_y >= h){
                continue;
            }
            
            //既に訪問済みなら小さい方にする
            if(dist[next_pos_y][next_pos_x] != -1){
                continue;
            }

            //壁なら何もしない
            if(vec[next_pos_y][next_pos_x] == "#"){
                continue;
            }

            //訪問できるノードの距離を記録し、queに格納
            dist[next_pos_y][next_pos_x] = dist[black_y][black_x] + 1;
            black.push(make_pair(next_pos_y,next_pos_x));
            
        }
        
    }

    ll ans = 0;

    rep(i,h){
        rep(j,w){
            ans = max(ans, dist[i][j]);
        }
    }

    cout << ans << endl;

}


Measured memory_bytes: 79156
/******************************************************************************

                            Online Java Compiler.
                Code, Compile, Run and Debug java program online.
Write your code in this editor and press "Run" button to execute it.

*******************************************************************************/
import java.util.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int a = sc.nextInt();
		System.out.println((h+a-1)/a);
	}
}


Measured memory_bytes: 23252
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define int long long
#define ll long long
#define eps LDBL_EPSILON
#define moder 1000000007
#define double long double
#define INF LLONG_MAX/10000
#define P pair<int,int>
#define prique priority_queue
using namespace std;
int n, a[10010], b[10010], c[10010], ans[10010];
P d[10010];
vector<int> vec[10010];
int used[10010];
void dfs(int s, int p) {
	for (int i : vec[s]) {
		if (!used[i]) {
			used[i] = p + 1;
			dfs(i, p + 1);
		}
	}
}
signed main() {
	cin >> n;
	int ma = 0, cnt;
	rep(i, n - 1) {
		cin >> a[i] >> b[i];
		vec[a[i]].push_back(b[i]);
		vec[b[i]].push_back(a[i]);
	}
	rep(i, n)cin >> c[i];
	REP(i, n) {
		if (ma < vec[i].size()) {
			ma = vec[i].size();
			cnt = i;
		}
	}
	used[cnt] = 1;
	dfs(cnt, 1);
	REP(i, n) {
		d[i] = make_pair(used[i], i);
	}
	sort(c, c + n);
	sort(d + 1, d + n + 1, greater<P>());
	REP(i, n) {
		ans[d[i].second] = c[i - 1];
	}
	int sum = 0;
	rep(i, n - 1) {
		sum += min(ans[a[i]], ans[b[i]]);
	}
	cout << sum << endl;
	REP(i, n - 1)cout << ans[i] << " ";
	cout << ans[n] << endl;
	return 0;
}

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

#define int long long
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
#define MP make_pair
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;

signed main(){
    int x; cin >> x;
    cout<<(x/500)*1000+(x%500/5)*5<<endl;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {

	var N int
	fmt.Scan(&N)

	d := make([]int,N)

	for i, _ := range d {
		fmt.Scan(&d[i])
	}
	// count := N*(N-1)/2
	var ans int
	for j := 0; j < N; j++ {
		for i:=j+1;i < N; i++{
				ans += d[j] * d[i]
			}
	}
	fmt.Println(ans)

}


Measured memory_bytes: 512
# include <iostream>
using namespace std;
const int N=100006;
int a[N];
int n,s;
void work (void)
{
	int i,t;
	t=a[0]+a[1]+a[2];
	for (i=2;i<100000;i++)
	{
		if (t>s)
		s=t;
		t=t-a[i-2]+a[i+1];
	}
	cout<<s;
}
int main (void)
{
	int i,j;
	cin>>n;
	for (i=1;i<=n;i++)
	{
		cin>>j;
		a[j]++;
	}
	work ();
	return 0;
}


Measured memory_bytes: 640
float o(float*a,float*b,float*c){
	return a[1]*(*c-*b)+c[1]*(*b-*a)+b[1]*(*a-*c);
}
float x,p[8];
i;
main(){
	for(;~scanf("%f,",p+i++%8);)
		i%8||puts(x*o(p+2,p+4,p+6)>0&x*o(p+4,p+6,p)>0&x*o(p+6,p,p+2)>0?"YES":"NO",x=o(p,p+2,p+4));
	return 0;
}

Measured memory_bytes: 0
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
	t = readline() |> chomp
	s = Int[Int(t[i]) for i in 1:length(t)]
	q = readline() |> parseInt
	f = 1
	for i in 1:q
		x = readline() |> chomp
		if x[1] == '1'
			f *= -1
		else
			x = split(x)
			ch = Int(x[3][1])
			if x[2][1]=='1'
				if f==1
					unshift!(s,ch)
				else
					push!(s,ch)
				end
			else
				if f==1
					push!(s,ch)
				else
					unshift!(s,ch)
				end
			end
		end
	end
	if f == 1
		for i in 1:length(s)
			print(Char(s[i]))
		end
		println("")
	else
		for i in length(s):-1:1
			print(Char(s[i]))
		end
		println("")
	end
end

main()

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

using namespace std;
typedef long long ll;
typedef long  double lb;
int mod=1e9+7;
const int N=1e5+5;

int main()
{
    int x,y;
    int n=1,m=1;
    scanf("%2d%2d",&x,&y);
    if(x==0)n=0;
    if(y==0)m=0;
    if(x>12)n=2;
    if(y>12)m=2;
    if(m+n==4)cout<<"NA"<<endl;
    else if(m+n==3){
        if(n==1) cout<<"MMYY";
        else cout<<"YYMM";
    }
    else if(n+m==2)
        {
             if(n*m==0)cout<<"NA";
             else
             cout<<"AMBIGUOUS"<<endl;
        }
    else if(n+m==1){
        if(n==1) cout<<"MMYY";
        else cout<<"YYMM";
    }
    else cout<<"NA";
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
Big Integers - Addition of Big Integers
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_2_A&lang=jp

"""
import sys


def main(args):
    A, B = map(int, input().split())
    print(A + B)


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 5956
implicit none
integer(8) :: i,j,k,n
read(5,*) n
do i = 1,int(3*n/4)
  do j = int(3*n/4), 3500
       if (4*i*j-N*i-N*j<=0) then
            continue
       else if (mod(N*i*j,4*i*j-N*i-N*j)==0) then
            goto 100
             endif
enddo
enddo
100 write(6,"(i0,1x,i0,1x,i0)") i,j,(N*i*j)/(4*i*j-N*i-N*j)
end


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

int main(void){
  int n;
  cin >> n;
  int ab[n][2];
  for(int i = 0; i < n; i++) cin >> ab[i][0] >> ab[i][1];
  int max = 0;
  int maxind = 0;
  for(int i = 0; i < n; i++){
    if(ab[i][0] > max){
      max = ab[i][0];
      maxind = i;
    }
  }
  cout << ab[maxind][0] + ab[maxind][1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string e;
int main(){
    q a,b,c,d,x,y,z;
    cin>>a>>b>>c;
    d=a*b;
    if(d==c){cout<<c;}
    else if(d<c){cout<<d;}
    else{cout<<c;}
return 0;}


Measured memory_bytes: 256
h={};n=gets.to_i;a=gets.split.map(&:to_i)[1..-1]
(1<<a.size).times{|i|x=0;y=[];a.size.times{|j|i[j]>0&&(x+=1<<a[j];y<<a[j])};h[x]=y}
puts h.sort.map{|k,v|k.to_s+':'+v.map{|e|' %d'%e}*''}


Measured memory_bytes: 128364
while True:
    x, y = map(int, input().split())
    if x == 0 and y == 0:
        break

    ans = 0
    for i in range(1, x+1):
        for j in range(i+1, x+1):

            c = y - (i+j)

            if c > j and c <= x:
                ans += 1

    print("%d"%(ans))


Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  ll n, k;
  cin >> n >> k;
  vl p, m;
  ll z = 0;
  ll zc = 0;
  REP(i, n) {
    ll a;
    cin >> a;
    if (a > 0) {
      p.push_back(a);
    } else if (a < 0) {
      m.push_back(-a);
    } else {
      zc++;
      ll tmp = n - zc;
      z += tmp;
    }
  }
  sort(ALL(p));
  sort(ALL(m));
  ll ps = p.size();
  ll ms = m.size();

  ll ok = 1e18 + 1;
  ll ng = -ok;
  ll x = (ok + ng) / 2;
  while (abs(ok - ng) > 1) {
    x = (ok + ng) / 2;
    // cout << x << endl;

    ll c = 0;
    if (x > 0) {
      REP(i, ps) {
        ll tmp = upper_bound(p.begin(), p.end(), x / p[i]) - p.begin();
        if (p[i] * p[i] <= x)
          tmp--;
        c += tmp;
      }
      REP(i, ms) {
        ll tmp = upper_bound(m.begin(), m.end(), (x) / m[i]) - m.begin();
        if (m[i] * m[i] <= x)
          tmp--;
        c += tmp;
      }
      c /= 2;
      c += z + ms * ps;
    } else if (x == 0) {
      c += ms * ps + z;

    } else {
      REP(i, ps) {
        ll tmp = m.end() -
                 lower_bound(m.begin(), m.end(), (abs(x) + p[i] - 1) / p[i]);
        c += tmp;
        // cout << tmp << endl;
      }
    }
    // cout << c << endl;
    if (k <= c) {
      ok = x;
    } else {
      ng = x;
    }
  }
  cout << ok << endl;
}


Measured memory_bytes: 2420
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC091
{
    class B
    {
        static void Main(string[] args)
        {

            int N = int.Parse(Console.ReadLine());

            Dictionary<string, int> dict = new Dictionary<string, int>();

            string s = "";
            for (int i = 0; i < N; i++)
            {
                s = Console.ReadLine();
                if (!dict.ContainsKey(s)) { dict.Add(s, 0); }
                if (dict.ContainsKey(s)) { dict[s]++; }
            }

            int M = int.Parse(Console.ReadLine());

            for (int i = 0; i < M; i++)
            {
                s = Console.ReadLine();
                if (!dict.ContainsKey(s)) { dict.Add(s, 0); }
                if (dict.ContainsKey(s)) { dict[s]--; }
            }

            var res = dict.OrderByDescending(x => x.Value);

            if (res.First().Value < 0) Console.WriteLine(0);
            else Console.WriteLine(res.First().Value);
        }
    }
}


Measured memory_bytes: 13280
require 'prime'
M = 10**9 + 7
N = gets.to_i
PRIMES = Prime.each(N).to_a

count = Array.new(PRIMES.length, 0)
for i in 1..N
  x = i
  PRIMES.each_with_index do |pr, j|
    while x % pr == 0
      count[j] += 1
      x /= pr
    end
  end
end

ans = 1
count.each do |x|
  ans *= (x+1)
  ans %= M
end
p ans


Measured memory_bytes: 2300
#include<stdio.h>

int main(void) {
        int w, n, i, a, b, tmp;
        scanf("%d", &w);
        int z[w];
        for(i=0;i<w;i++) {
                z[i]=i+1;
        }
        scanf("%d", &n);
        for(i=0;i<n;i++) {
                scanf("%d,%d", &a, &b);
                tmp = z[a-1];
                z[a-1] = z[b-1];
                z[b-1] = tmp;
        }

        for(i=0;i<w;i++) {
                printf("%d\n", z[i]);
        }

        return 0;
}

Measured memory_bytes: 596
sss = [i for i in input()]
n = int(len(sss))
if n%2 == 0:
  g1 = "01"*n
  g2 = "10"*n
else:
  g1 = "01"*int((n-1)/2) + "0"
  g2 = "10"*int((n-1)/2) + "1"
count_1 = 0
count_2 = 0
for i in range(n):
  if not sss[i] == g1[i]:
    count_1 += 1
  if not sss[i] == g2[i]:
    count_2 += 1
print(min(count_1, count_2))

Measured memory_bytes: 4252
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0))
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0))
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a))
#define Reverse(a) reverse(All(a))
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
using namespace std;
int max_int = 1000000007;
void Debug(auto a);


signed main(){
    int n,a,b;
    cin >> n >> a >> b;
    int m = 0;
    cout << min(a,b) << " " << max(m,a+b-n) << endl;
    
    return 0;
}



void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<bitset>
#include<vector>
#include<set>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

int main(){
    int c[26]={0};
    string s;
    while(getline(cin, s)){
        for(int i=0; i < s.size(); i++){
            if('a' <= s[i] && s[i] <= 'z')c[s[i]-'a']++;
            if('A' <= s[i] && s[i] <= 'Z')c[s[i]-'A']++;
        }
    }
    for(int i=0; i < 26; i++){
        cout << ((char)('a'+ i)) << " : " << c[i] << endl;
    }
    return 0;
}




Measured memory_bytes: 3168
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

double comb(ll n,ll b){
	if(b==0)return 1;
	return (double)n*log(n)-b*log(b)-(n-b)*log(n-b);
}



int main(void){
	ll N,a[100010],a1,a2;
	scanf("%lld",&N);
	rep(i,N)scanf("%lld",&a[i]);
	sort(a,a+N);//小→大
	double big=0;
	reg(i,1,N-1){
		double c; //ここはa[i]/2に最も近い値を選ばなければならない
		ll l=0,r=N-1;
		while(r-l>1){
			ll mid = (r+l)/2;
			if(a[i]/2<a[mid]){
				r=mid;
			}else{
				l=mid;
			}
		}
		c = comb(a[i],a[l]);
		if(big<c){
			big=c;
			a1=i;
			a2=l;
		}
		c = comb(a[i],a[r]);
		if(big<c){
			big=c;
			a1=i;
			a2=r;
		}
	}
	printf("%lld %lld\n",a[a1],a[a2]);
	return 0;
}

Measured memory_bytes: 1408
import java.util.Scanner;

/**
 * https://atcoder.jp/contests/abc157/tasks/abc157_b
 *
 */
public final class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			Box[][] bingo = new Box[3][3];

			for (int i = 0; i < 3; i++) {
				for (int j = 0; j < 3; j++) {
					bingo[i][j] = new Box(scanner.nextInt());
				}
			}

			int n = scanner.nextInt();
			for (int ct = 0; ct < n; ct++) {
				int number = scanner.nextInt();
				for (int i = 0; i < 3; i++) {
					for (int j = 0; j < 3; j++) {
						if (bingo[i][j].number == number) {
							bingo[i][j].checked = true;
						}
					}
				}
			}

			boolean succeed = false;
			if (bingo[0][0].checked && bingo[0][1].checked && bingo[0][2].checked) {
				succeed |= true;
			}
			if (bingo[1][0].checked && bingo[1][1].checked && bingo[1][2].checked) {
				succeed |= true;
			}
			if (bingo[2][0].checked && bingo[2][1].checked && bingo[2][2].checked) {
				succeed |= true;
			}

			if (bingo[0][0].checked && bingo[1][0].checked && bingo[2][0].checked) {
				succeed |= true;
			}
			if (bingo[0][1].checked && bingo[1][1].checked && bingo[2][1].checked) {
				succeed |= true;
			}
			if (bingo[0][2].checked && bingo[1][2].checked && bingo[2][2].checked) {
				succeed |= true;
			}

			if (bingo[0][0].checked && bingo[1][1].checked && bingo[2][2].checked) {
				succeed |= true;
			}
			if (bingo[2][0].checked && bingo[1][1].checked && bingo[0][2].checked) {
				succeed |= true;
			}

			System.out.println(succeed ? "Yes" : "No");
		}
	}

	private static final class Box {
		public final int number;
		public boolean checked;

		public Box(int number) {
			this.number = number;
			this.checked = false;
		}

	}

}


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

#define MOD 1000000007

int main (void){
  long long int n,a = 1,b = 1,c = 1,d;
  cin >> n;

  for(int i = 0; i < n;i++){
    a = (a*10) % MOD;
    b = (b*9) % MOD;
    c = (c*8) % MOD;
  }

  d = (a+c-b-b + MOD+MOD) % MOD;
  cout << d << endl;
  return 0;

}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n-1); i >= 0; i--)
#define all(v) (v).begin(),(v).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a/gcd(a,b)*b; }
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;

int main() {
	int n, m;
	cin >> n >> m;
    vector<P> ans;
    if (n%2) {
        for (int l = 1, r = n-1; l < r; l++, r--) {
            ans.emplace_back(l,r);
        }
    } else {
        bool flag = false;
        for (int l = 1, r = n-1; l < r; l++, r--) {
            if (!flag && r-l <= n/2) {
                --r;
                flag = true;
            }
            ans.emplace_back(l,r);
        }
    }
    rep(i,m) printf("%d %d\n", ans[i].first, ans[i].second);
	return 0;
}


Measured memory_bytes: 4256
<?php
$N = fgets(STDIN);
$input=explode(' ',(fgets(STDIN)));

$ans = 1;
for ($i = 0; $i < $N; $i++) {
    $ans = $ans * $input[$i];
}

if ($ans > 10**18) {
  $ans = '-1';
}

echo (int)$ans;
?>

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

int main() {

  long long int a, b, c;
  cin >> a >> b >> c;

  if ( ( 60 % ( a + b ) ) == 0 ) {

    if ( ( c % ( a + b ) ) <= a ) {
      cout << c << endl;
    }else {
      cout << -1 << endl;
    }

  }else {

    for ( long long int t = 0;; t++ ) {

      if ( ( ( c + 60 * t ) % ( a + b ) ) <= a ) {

	cout << c + 60 * t << endl;
	break;

      }else if ( t > 60 ) {
	cout << -1 << endl;
	break;
      }

    }

  }

  return 0;

}

Measured memory_bytes: 1160
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#endif

#define ITER(c)         __typeof__((c).begin())
#define FOREACH(it, c)  for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)        __typeof__((c).rbegin())
#define RFOREACH(it, c) for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)       REPEAT(i, 0, n)
#define REPEAT(i, k, n) for (int i = (k); i < (n); ++i)
#define REVREP(i, n)    for (int i = ((n)-1); i >= 0; --i)
#define FIND(c, n)      std::find((c).begin(), (c).end(), (n));
#define BSEARCH(c, n)   std::binary_search((c).begin(), (c).end(), (n))
#define LLPOW(p1,p2)    ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)      (sizeof(A)/sizeof((A)[0]))
#define MIN(p1,p2)      (((p1)<(p2))?(p1):(p2))
#define MAX(p1,p2)      (((p1)>(p2))?(p1):(p2))
#define CIN_NO_SYNC     do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)       fgets((p), sizeof(p), stdin)
#define CHOMP(p)        do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)

typedef long long ll;
typedef unsigned long long ull;

#ifdef _DEBUG
#define pf printf
#define pr(n) do { cout << #n " = " << (n) << endl; } while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#endif

int main(){
    string s;
    int count = 0;
    while(getline(cin, s)){
        int len = s.length();
        bool f = true;
        pr(len);
        REP(i,(len+1)/2){
            if(s[i] != s[len-i-1]){
                f = false;
                break;
            }
        }
        if(f) count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 1176
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    input = sys.stdin.buffer.readline

    def calc(n):
        return n * (n+1) // 2

    N = int(input())
    C = list(map(int, input().split()))
    adj = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    que = deque()
    que.append(1)
    seen = [-1] * (N+1)
    seen[1] = 0
    par = [0] * (N+1)
    child = [[] for _ in range(N+1)]
    seq = []
    while que:
        v = que.popleft()
        seq.append(v)
        for u in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] + 1
                par[u] = v
                child[v].append(u)
                que.append(u)
    seq.reverse()
    size = [1] * (N+1)
    for v in seq:
        for u in child[v]:
            size[v] += size[u]

    ans = [calc(N)] * (N+1)
    par_C = [[] for _ in range(N+1)]
    sub = [0] * (N+1)
    sub_0 = [0] * (N+1)
    st = deque()
    st.append(1)
    while st:
        v = st.pop()
        if v > 0:
            st.append(-v)
            for u in child[v]:
                st.append(u)
            c = C[v-1]
            if par_C[c]:
                sub[par_C[c][-1]] += size[v]
            else:
                sub_0[c] += size[v]
            par_C[c].append(v)
        else:
            v = -v
            c = C[v-1]
            assert par_C[c][-1] == v
            par_C[c].pop()
            p = par[v]
            if p:
                cp = C[p-1]
                ans[cp] -= calc(size[v] - sub[p])
                sub[p] = 0
    for c in range(1, N+1):
        ans[c] -= calc(N - sub_0[c])
        print(ans[c])


if __name__ == '__main__':
    main()


Measured memory_bytes: 159576
#include<cstdio>
#define N 110000
inline char gc(){
	static char now[1<<16],*T,*S;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;
}
inline int read(){
	int x=0;char ch=gc();
	while (ch<'0'||ch>'9') ch=gc();
	while (ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=gc();}
	return x;
}
int n,a[N],differ[N];
int main(){
//	freopen("box.in","r",stdin);
	n=read();long long sum=0;long long sum1=0;
	if (n==1){printf("YES");return 0;}
	sum1=(long long)n*(n+1)>>1;
	for (int i=1;i<=n;++i) a[i]=read(),sum+=a[i];a[n+1]=a[1];
	for (int i=1;i<=n;++i) differ[i]=a[i+1]-a[i];int k=sum/sum1;
	if (sum%sum1){printf("NO");return 0;}
	for (int i=1;i<=n;++i){
		double x=(differ[i]-k)/(-1.0*n);
		if (x<0){printf("NO");return 0;}
		int xx=x;if (xx!=x){printf("NO");return 0;}
	}
	printf("YES");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	string A, B, C;
	cin >> A >> B >> C;

	if (A.back() == B.front() && B.back() == C.front())
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}

	return 0;
}


Measured memory_bytes: 3656
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <cmath>
#include <string>
#include <set>
#include <map>
#include <cassert>
#define SIZE 605

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

char mp[SIZE][SIZE];
bool use[SIZE][SIZE];
int tt[SIZE][SIZE],yy[SIZE][SIZE];

int xsum(int x,int i,int j)
{
	return tt[x][j]-(i==0?0:tt[x][i-1]);
}
int ysum(int y,int i,int j)
{
	return yy[j][y]-(i==0?0:yy[i-1][y]);
}
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++) scanf("%s",&mp[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(mp[i][j]=='#')
			{
				int x=i+j,y=i-j+m-1;
				use[x][y]=true;
			}
		}
	}
	n=n+m;//[0,n-1]*[0,n-1] 内にある
	ll ret=0;
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)
		{
			tt[i][j]=yy[i][j]=use[i][j];
			if(j>0) tt[i][j]+=tt[i][j-1];
			if(i>0) yy[i][j]+=yy[i-1][j];
		}
	}
	for(int i=0;i<n;i++)
	{
		for(int s=0;s<n;s++)
		{
			for(int t=s+1;t<n;t++)
			{
				if(use[i][s]&&use[i][t])
				{
					int l=t-s;
					if(i>=l)
					{
						ret+=xsum(i-l,s,t);
						if(use[i-l][s]) ret--;
						if(use[i-l][t]) ret--;
					}
					if(i+l<n)
					{
						ret+=xsum(i+l,s,t);
						if(use[i+l][s]) ret--;
						if(use[i+l][t]) ret--;
					}
				}
				if(use[s][i]&&use[t][i])
				{
					int l=t-s;
					if(i>=l)
					{
						ret+=ysum(i-l,s,t);
					}
					if(i+l<n)
					{
						ret+=ysum(i+l,s,t);
					}
				}
			}
		}
	}
	printf("%lld\n",ret);
	return 0;
}


Measured memory_bytes: 3584
<?php

fscanf(STDIN, '%d', $N);
$harray = explode(' ', trim(fgets(STDIN)));

$westMountHeight = [];
for ($i = 0; $i < $N; $i++) {
    if ($i === 0) {
        $westMountHeight[] = $harray[$i];
    }else{
        if ($harray[$i] >= max($westMountHeight)) {
            $westMountHeight[] = $harray[$i];
        }
    }
}

echo count($westMountHeight) . PHP_EOL;

Measured memory_bytes: 4732
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	while (1) {
		int M; cin >> M;
		if (!M)break;
		ld area1=0, area2=0;
		ld sum1 = 0,sum2=0;
		for (int i = 0; i < M-1; ++i) {
			ld v; cin >> v;
			sum1 += v;
			area1 += sin(v / 180 * acos(-1));
		}
		area1 += sin((360-sum1) / 180 * acos(-1));
		int N; cin >> N;
		for (int i = 0; i < N-1; ++i) {
			ld v; cin >> v;
			sum2 += v;
			area2 += sin(v / 180 * acos(-1));
		}
		area2 += sin((360 - sum2) / 180 * acos(-1));
		if (eps > (abs(area1 - area2))) {
			cout << 0 << endl;
		}
		else if (area1 > area2) {
			cout << 1 << endl;
		}
		else {
			cout << 2 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define Would
#define you
#define please


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

	int N, M;
	cin >> N >> M;

	vector<int> fune[200001];
	rep(i, M) {
		int a, b;
		cin >> a >> b;
		fune[a].push_back(b);
		fune[b].push_back(a);
	}

	int ikeru = 0;
	for (int i: fune[1]) {
		for (int ii : fune[i]) {
			if (ii == N) ikeru = 1;
		}
	}

	if(ikeru) co("POSSIBLE");
	else co("IMPOSSIBLE");

	Would you please return 0;
}

Measured memory_bytes: 12016
<?php
define("MOD", 10**9+7);
fscanf(STDIN, "%d%d", $n, $k);
$A = array_map("intval", explode(" ", fgets(STDIN)));
sort($A);
prepareMod($n);
$ans = 0;
for($i = 0; $i < $n; $i++){
    $ans = ($ans + ($A[$n-$i-1]-$A[$i]) * nCm($n-$i-1, $k-1))%MOD;
}
echo (($ans%MOD)+MOD)%MOD;

function prepareMod($n){
    global $f, $invf;
    $f[0] = $invf[0] = $invf[1] = 1;
    for($i = 1; $i <= $n; $i++)$f[$i] = $f[$i-1]*$i%MOD;
    for($i = 2; $i <= $n; $i++)$invf[$i] = (MOD - intdiv(MOD, $i))*$invf[MOD%$i]%MOD;
    for($i = 2; $i <= $n; $i++)$invf[$i] = $invf[$i]*$invf[$i-1]%MOD;
}
function nCm($n, $m){
    global $f, $invf;
    if($n < 0 || $n - $m < 0)return 0;
    return $f[$n] * $invf[$n-$m] % MOD * $invf[$m] % MOD;
}

Measured memory_bytes: 23408