akhauriyash/Code-Regression huggingface dataset:
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
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();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EACH(t,i,c) for(t::iretator i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);

const int INF = INT_MAX/10;
typedef vector<double> vd;

struct state {
	int p, t;
	double c;
	state(int p, int t, double c) : p(p), t(t), c(c) {};
	bool operator<(const state other)const {
		return c>other.c;
	}
};

int main() {
	int n, m, p, a, b;
	while(cin >> n >> m >> p >> a >> b, n) {
		vi ticket(n);
		REP(i, n) {
			cin >> ticket[i];
		}
		
		vvi road(m, vi(m, INF));
		int x, y, z;
		REP(i, p) {
			cin >> x >> y >> z;
			road[x-1][y-1] = z;
			road[y-1][x-1] = z;
		}

		priority_queue<state> Q;
		Q.push(state(a-1, 0, 0));
		double ans = INF;
		vector<vd> cost(m, vd(1<<n, INF));
		cost[a-1][0] = 0;
		while(!Q.empty()) {
			state st = Q.top();
			Q.pop();

			if(st.p == b-1) {
				ans = min(ans, st.c);
				continue;
			}
			if(cost[st.p][st.t] < st.c) {
				continue;
			}
			REP(i, m) {
				if(i != st.p && road[st.p][i] != INF) {
					REP(j, n) {
						if(!(st.t&(1<<j))) {
							int nt = st.t|(1<<j);
							double nc = st.c + (double)road[st.p][i]/(double)ticket[j];
							if(cost[i][nt] > nc) {
								cost[i][nt] = nc;
								Q.push(state(i, nt, nc));
							}
						}
					}
				}
			}
		}

		if(ans == INF) {
			cout << "Impossible" << endl;
		} else {
			printf("%.3f\n", ans);
		}
	}

	return 0;
}

Measured memory_bytes: 2772
from collections import defaultdict
from math import sqrt
from fractions import gcd

n, m = [int(i) for i in input().split()]

def factorize(n):    
    i = 2
    A = defaultdict(int)
    
    while n % i == 0:
        n //= i
        A[i] += 1
    i += 1

    while n != 1 and i <= sqrt(n):
        while n % i == 0:
            n //= i
            A[i] += 1
        i += 2
    if n != 1:
        A[n] = 1

    return A

D = set()
F = list(factorize(m).items())
l = len(F)

memo = dict()

def dfs(i, j, k):
    if (i, j, k) in memo:
        return None
    memo[i, j, k] = True
    if i == l:
        D.add(k)
        return None

    if F[i][1] > j:
        dfs(i, j+1, k*F[i][0])
    dfs(i+1, 0, k)
    
    return None

dfs(0, 0, 1)

D = sorted(list(D), reverse=True)
ans = 1

for d in D:
    if m // n < d:
        continue

    ans = max(ans, gcd(d, m-(d*(n-1))))

print(ans)

Measured memory_bytes: 5344
import numpy as np
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7


def main():
  N = int(readline())
  P = list(map(int, readline().split()))
  ans = 0
  for i in range(N-2):
    p1 = P[i]
    p2 = P[i+1]
    p3 = P[i+2]
    if (p1<p2<p3) or (p1>p2>p3):
      ans += 1
  
  print(ans)
  
  
  
  
      
if __name__ == '__main__':
  main()

Measured memory_bytes: 12208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ちゃんと考えてわかって実装 */
ll GetDigit(ll num, ll k){
    ll digit=0;
    while(num!=0){
        num /= k;
        digit++;
    }
    return digit;
}
int main(void){
    ll n, k;
    cin >> n >> k;
    cout << GetDigit(n, k);
    return 0;
}

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

using namespace std;
typedef long long ll;
ll a, b, c, ans, tmp;

int main() {
	cin>>a>>b>>c;
	tmp=min(a, c);
	ans+=tmp;
	a-=tmp;
	c-=tmp;
	
	tmp=min(b, c);
	ans+=tmp*2;
	b-=tmp;
	c-=tmp;
	
	ans+=b;
	if (c) ans+=1;
	
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

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

int main(){
	string S;
	cin >> S;
	int ans=0;
	rep(i,3){
		if(S[i]=='1') ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N,K;
  cin >> N >> K;
  vi p(N);
  rep(i,N) {
    cin >> p[i];
  }
  sort(rng(p));
  int ans = 0;
  rep(i,K) {
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3660
using System;
using System.Collections.Generic;

namespace std
{
    class Test {
        static void Main(string[] args) {
            List<int> ary = new List<int>();
            var num = Console.ReadLine();
            var input = Console.ReadLine().Split(' ');
             var n = int.Parse(num);
           
            for (int i = 0; i< n; i++) {
                var inp = int.Parse(input[i]);
                ary.Add(inp);
            }
           
            Test obj = new Test();
            obj.BubbleSort(ary, n);

        }
        
        
        public void BubbleSort(List<int> ary, int n) {
            int cnt = 0;
            bool flag = true;   // 逆の隣接要素が存在する
            int k = 0;           
            while (flag) {
                flag = false;
                for( int j = n-1; j > k; j--) {
                    if (ary[j] < ary[j-1]) {
                    // ary[j]とary[j-1] swap
                        int tmp = ary[j];
                        ary[j] = ary[j-1];
                        ary[j-1] = tmp;
                        cnt++;
                        flag = true;
                    }
                }
                k++;
            }
            for (int i= 0; i< n; i++) {
                Console.Write(ary[i]);
                if(i < n - 1) Console.Write(" "); //空白
            }
            Console.WriteLine("");//改行
            Console.WriteLine(cnt);//ソート数
 
         }
    }
}


Measured memory_bytes: 7872
#include <iostream>
#include <cctype>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int comp(const void* a, const void* b){
	return *(int*)a - *(int*)b;
}

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}

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

const int MAX = 210000;;

int N;
int A[MAX], B[MAX], C[MAX];

int main() {
    while (cin >> N) {
        for (int i = 0; i < N; ++i) cin >> A[i];
        for (int i = 0; i < N; ++i) cin >> B[i];
        for (int i = 0; i < N; ++i) cin >> C[i];

        sort(A, A+N);
        sort(B, B+N);
        sort(C, C+N);
        long long res = 0;
        for (int i = 0; i < N; ++i) {
            long long a = lower_bound(A, A+N, B[i]) - A;
            long long c = C + N - upper_bound(C, C+N, B[i]);
            res += a * c;
        }
        cout << res << endl;
    }
}


Measured memory_bytes: 4764
U,R,D,L="URDL"
d={i:[]for i in"URDL"}
_,*a=map(str.split,open(0))
for*z,u in a:d[u]+=[*map(int,z)],
I=N=9e9;P,M="x+y,","x-y,"
for*F,S in(D,U,"x,y,"),(L,R,"y,x,"),(U,R,P+M),(L,D,P+M),(L,U,M+P),(D,R,M+P):
 n=p=-I
 for x,y,r in sorted(eval(f"[({S}Q)for Q,P in enumerate(F)for x,y in d[P]]")):
  if r:n,p=x,y
  elif x==n:N=min(N,y-p)
print(["SAFE",N*5][N<I])

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

bool is_frame(int i, int j, int h, int w) {
  return (i == 0 || i == h-1 ||
          j == 0 || j == w-1);
}

  int main() {
  int h, w;
  while (true) {
    cin >> h >> w;
    if (h == 0 && w == 0) return 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++)
        cout << (is_frame(i, j, h, w) ? '#' : '.');
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 1152
N, K = map(int, input().split())
A = [0] + [int(a) for a in input().split()]
for i in range(N):
    A[i+1] += A[i]
S = []
for i in range(1, N+1):
    for j in range(i):
        S.append(A[i] - A[j])
l, r = 0, 1 << 50
while r - l > 1:
    m = (l+r) // 2
    if len([1 for i in range(len(S)) if S[i] & m == m]) >= K:
        l = m
    else:
        r = m
print(l)

Measured memory_bytes: 74992
use whiteread::parse_line;

fn main() {
    let (d, n): (u32, u32) = parse_line().unwrap();

    if n == 100 {
        println!("{}", 101 * 100_u32.pow(d));
    } else {
        println!("{}", n * 100_u32.pow(d));
    }
}


Measured memory_bytes: 2184
// ARC100
// C - Linear Approximation

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;

const int MAX_N = 200000;

int N;
int B[MAX_N];

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        B[i] = a - i + 1;
    }
    sort(B, B + N);

    int b = B[N / 2];
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ans += abs(B[i] - b);
    }
    cout << ans << endl;

    return 0;
}


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

typedef pair<int, int> pii;

#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()

const int inf = 2e9;
const int N = 105;

int n, a[N], cnt[N];

int main() {
	cin >> n;
	int mn = inf, mx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		cnt[a[i]]++;
		mn = min(mn, a[i]);
		mx = max(mx, a[i]);
	}
	if (cnt[mn] > 2 || cnt[mx] < 2) return cout << "Impossible", 0;
	int d = cnt[mn] == 1 ? mn * 2 : mn * 2 - 1;
	if (mx != d) return cout << "Impossible", 0;
	for (int i = mn; i <= mx; i++) 
		if (cnt[i] == 0) 
			return cout << "Impossible", 0;
	cout << "Possible";
}


Measured memory_bytes: 3580
//#define NDEBUG
#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <utility>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

struct rep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr rep(const usize f, const usize l) noexcept
      : f(std::min(f, l)), l(l) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
struct revrep {
  struct itr {
    usize i;
    constexpr itr(const usize i) noexcept : i(i) {}
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  const itr f, l;
  constexpr revrep(const usize f, const usize l) noexcept
      : f(l - 1), l(std::min(f, l) - 1) {}
  constexpr auto begin() const noexcept { return f; }
  constexpr auto end() const noexcept { return l; }
};
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) noexcept {
  return a < b ? b - a : a - b;
}
template <class T> void chmin(T &a, const T &b) noexcept {
  if (b < a)
    a = b;
}
template <class T> void chmax(T &a, const T &b) noexcept {
  if (a < b)
    a = b;
}
template <class F> class fix_point : private F {
public:
  explicit constexpr fix_point(F &&f) : F(std::forward<F>(f)) {}

  template <class... Args>
  constexpr decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, std::forward<Args>(args)...);
  }
};
template <class F> constexpr decltype(auto) make_fix(F &&f) {
  return fix_point<F>(std::forward<F>(f));
}
template <class T> T scan() {
  T ret;
  std::cin >> ret;
  return ret;
}

} // namespace n91
#include <array>
#include <map>
#include <string>

namespace n91 {

void main_() {
  /*
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  //*/
  const usize n = scan<usize>();
  std::map<std::string, usize> cnt;
  for (const usize i : rep(0, n)) {
    const std::string s = scan<std::string>();
    cnt[s] += 1;
  }
  usize max = 0;
  for (const auto &e : cnt)
    max = std::max(max, e.second);
  for (const auto &e : cnt) {
    if (max == e.second) {
      std::cout << e.first << std::endl;
    }
  }
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


Measured memory_bytes: 25216
#include <bits/stdc++.h>
#include <stdlib.h>
#include <time.h> 
 
using namespace std;
long long mod=1e9+7;
long long INF=1e7;
double EPS = 1e-12;
typedef long long int lld;
double tick(){static clock_t oldt;clock_t newt=clock();double diff=1.0*(newt-oldt)/CLOCKS_PER_SEC;oldt = newt;return diff;}
#define rep(i,a,n) for(long long int i = (a); i <= (n); ++i)
#define repI(i,a,n) for(int i = (a); i <= (n); ++i)
#define repD(i,a,n) for(long long int i = (a); i >= (n); --i)
#define repDI(i,a,n) for(int i = (a); i >= (n); --i)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sc(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define scd(a) scanf("%d",&a)
#define scd2(a,b) scanf("%d%d",&a,&b)
#define scd3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scf(a) scanf("%lf",&a)
#define scf2(a,b) scanf("%lf%lf",&a,&b)
#define scf3(a,b,c) scanf("%lf%lf%lf",&a,&b,&c)
#define prL(a) printf("%lld\n",a)
#define prS(a) printf("%lld ",a)
#define prdL(a) printf("%d\n",a)
#define prdS(a) printf("%d ",a)
#define all(c) c.begin(), c.end()
#define sz(a) ((int)a.size())
#define Error(x) cout<< #x << " = " << (x) <<endl;
#define Error2(a,b) cout<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define Error3(a,b,c) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<")\n";
#define Error4(a,b,c,d) cout<<"("<<#a<<" , "<<#b<<" , "<<#c<<" , "<<#d<<" ) = ( "<<(a)<<" , "<<(b)<<" , "<<(c)<<" , "<<(d)<<")\n";
#define errop(a) cout<<#a<<" = ( "<<((a).x)<<" , "<<((a).y)<<" )\n";
#define mset(a, v) memset(a, v, sizeof(a))
#define popcount __builtin_popcountll
 
typedef pair<lld,lld> PA;
 
lld powP(lld a,lld b){
    if(b==0) return 1%mod;
    lld k;
    k=powP(a,b/2);
    k=k*k%mod;
    if(b%2==0) return k;
    else return a*k%mod;
}
 
bool bitSet(lld n,lld i){
    if((n&(1LL<<i))!=0) return true;
    else return false;
}
 
lld findGcd(lld a,lld b){
    if(a==0) return b;
    else return findGcd(b%a,a);
}
 
#define lim 300010
#define lim2 200010
#define qqqqqq 210
// Ab :)
// inline lld sqr(lld x) { return x * x; }
// unordered_map<lld,lld>::iterator it;
// std::ios::sync_with_stdio(false);
// priority_queue<PA> Q;
// lld dp[1<<18];

// vector<lld> G[lim];
// string S[lim];
// lld A[lim],B[lim],C[lim];
// map<lld,lld> M;

int main(){
    lld T,i,p,j,l,n,e,r,b,c,k,m,q,a,d,w,x,y,u,v,z,t,curr,prev,sum,ans,pos,val,countA,indicator;
    sc2(a,b);
    prL(a * b - a - b + 1);
    return 0;
}

Measured memory_bytes: 256
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//(int)'a'は97 (int)'A'は65
//おまじない



int main() {

	int n[26] = { 0 };
	char str[101];
	cin >> str;

	for (int i = 0; str[i] != '\0'; i++) {
		n[(int)str[i]-97]++;
	}
	roop(i, 0, 26) {
		if (n[i] % 2 != 0) {
			No;
			return 0;
		}
	}

	Yes;
	return 0;

	return 0;
}


Measured memory_bytes: 256
# 参考　yy4さん
from heapq import heappush, heappop
import sys    
input = sys.stdin.readline    
n, m = map(int, input().split())
    
vmax = pow(10, 5)
jobs = {i:[] for i in range(1,vmax + 1)}
for _ in range(n):
    a, b = map(int, input().split())
    jobs[a].append(-b)
    

ans =0
hq = []
for i in range(1, m + 1):
    for j in jobs[i]:
        heappush(hq, j)
    if hq:
        v = heappop(hq)
        v *= -1
        ans += v
print(ans)

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

int main()
{
  int t, n, k, x[100000], i, len;
  for(cin >> t; t>0; t--)
    {
      cin >> n;
      cin >> k;
      for(i=0; i<n; i++) cin >> x[i];
      len = x[n-1] - x[0];
      for(i=0; i<n-1; i++) x[i] = x[i+1] - x[i];
      sort(x, x+n-1);
      for(i = 2; k>1 && n>=i; k--)
	{
	  len -= x[n-i];
	  i++;
	}
      cout << len << endl;
    }
  return 0;
}

Measured memory_bytes: 1564
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double

using namespace std;

    const ll N = 1e2 + 7;
    const ll mod = 1e9 + 7;
    const ld eps = 1e-9;



void solve(){
    int n , ans = 0;
    cin >> n;
    vector < int > a(n + 1);
    for(int i = 1; i <= n; ++ i)
        cin >> a[i];
    sort(a.begin() , a.end());
    for(int i = 1; i <= n; ++ i){
        for(int j = i + 1; j <= n; ++ j){
            for(int k = j + 1 ; k <= n; ++ k){
                if(a[i] + a[j] > a[k] && a[i] != a[j] && a[j] != a[k] && a[i] != a[k]){
                    ++ ans;
                }
            }
        }
    }
    cout << ans;
}

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

/**

**/


Measured memory_bytes: 3664
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
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; }
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> s(h,vector<char>(w));
    rep(i,h)rep(j,w)cin >> s[i][j];
    vector<vector<int>> y(h,vector<int>(w));
    vector<vector<int>> t(h,vector<int>(w));
    rep(i,h){
        int c = 0;
        rep(j,w){
            if(s[i][j]=='.')c++;
            if(s[i][j]=='#')c=0;
            y[i][j]=c;
        }
        for(int j=w-2;j>=0;j--){
            if(s[i][j]=='.'&&s[i][j+1]=='.')y[i][j]=y[i][j+1];
        }
    }
    rep(j,w){
        int c = 0;
        rep(i,h){
            if(s[i][j]=='.')c++;
            if(s[i][j]=='#')c=0;
            t[i][j]=c;
        }
        for(int i=h-2;i>=0;i--){
            if(s[i][j]=='.'&&s[i+1][j]=='.')t[i][j]=t[i+1][j];
        }
    }
    int ans = 0;
    rep(i,h)rep(j,w){
        if(s[i][j]=='.')chmax(ans,t[i][j]+y[i][j]-1);
    }
    cout << ans << endl;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//ABC161 F
/*
long long replace(long long n,long long i){

    while(n>=i){

        if(n%i==0)n/=i;

        else{
            n-=i;
        }
    
    }
    return n;
}
*/
vector<long long>prime1;
vector<long long>prime2;

vector<long long> eratos(long long n,vector<long long>prime){
    long long tmp=sqrt(n);
    for(long long i=2;i<=tmp;i++){
        if(n%i==0){
            prime.push_back(i);
            //while(n%i==0)n/=i;
            //prime.push_back(n/i);
        }
    }
    //if(n!=1)prime.push_back(n);
    return prime;
}

long long  cal(long long n){

    long long tmp=sqrt(n);

    long long ret=1;
    for(long long i=2;i<=tmp;i++){
    long long now=1;
        while(n%i==0){
            n/=i;
            now++;
        }
        ret*=now;
    }
    if(n!=1){
        ret*=2;
    }

    return ret;
}

int main(){

    long long n;
    cin>>n;

    long long ans=1;
    if(n==2){
        cout<<"1"<<endl;
        return 0;
    }
    
    prime1=eratos(n,prime1);
    
    //nの約数について
    for(long long i=0;i<prime1.size();i++){
        long long p=n/prime1[i];

        //cout<<prime1[i]<<endl;
        //cout<<p<<endl;
        if(p%prime1[i]==1){
            ans++;
        }
        else if(p==prime1[i]){
            ans++;
        }
        else if(p%prime1[i]==0){
            
            while(p%prime1[i]==0){
                p/=prime1[i];
            }
            p%=prime1[i];
            if(p==1)ans++;
        }
    }
    //cout<<ans<<endl;
    //nの約数以外について
    
    ans+=cal(n-1);
    ans--;
    
    cout<<ans<<endl;
    return 0;

}
/*

*/


Measured memory_bytes: 3724
import math

D = int(input())
c = list(map(int, input().split()))
S = []
for i in range(D):
    S.append(list(map(int, input().split())))

nocontest = [1 for i in range(26)]
count_nocontest = [2 for i in range(26)]
for i in range(D):
    s = S[i]
    contest = [0 for j in range(26)]
    for j in range(26):
        contest[j] = c[j] * nocontest[j] * s[j]
    #print(contest)
    max_contest = max(contest)
    ans = contest.index(max_contest)
    print(ans + 1)
    
    for j in range(26):
        if j == ans:
            nocontest[j] = 1
            count_nocontest[j] = 2
        else:
            nocontest[j] += count_nocontest[j]
            count_nocontest[j] += 1
    #print(nocontest)

Measured memory_bytes: 9532
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int main(){
  int n,q;
  while(cin>>n>>q,n|q){
    vector<pair<string,pii> > eras(n);
    REP(i,n){
      cin>>eras[i].first;
      int ey,wy;
      cin>>ey>>wy;
      eras[i].second.first=wy-ey+1;
      eras[i].second.second=max(eras[i].second.second,wy);
    }
    REP(i,q){
      int y;
      cin>>y;
      bool ok=false;
      REP(j,n){
        if(eras[j].second.first<=y&&y<=eras[j].second.second){
          cout<<eras[j].first<<" "<<(y-eras[j].second.first+1)<<endl;
          ok=true;
          break;
        }
      }
      if(!ok){
        cout<<"Unknown"<<endl;
      }
    }
  }
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



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

	ll N = s.size();

	ll t = 0;
	rep(i, N) {
		if (s[i] == 'p') { t++; }
	}

	cout << N / 2 - t;


	system("PAUSE");
}

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

using namespace std;

int main(){
	
	int n;
	cin >> n;
	
	string w[n];
	bool le = true;
	
	for(int i=0;i<n;i++){
		cin >> w[i];
		for(int j=0;j<i;j++){
			if(w[j]==w[i]){
				le=false;
			}
		}
	}
	
	for(int i=0;i<n-1;i++){
		if(w[i][w[i].length()-1]!=w[i+1][0]){
			le=false;
		}
	}
	
	
	if(le==false){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define spair(p) cout<<#p<<": "<<p.fi<<" "<<p.se<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl
#define svec(v) cout<<#v<<":";rep(pachico,v.size())cout<<" "<<v[pachico];cout<<endl
#define svecp(v) cout<<#v<<":";each(pachico,v)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl
#define sset(s) cout<<#s<<":";each(pachico,s)cout<<" "<<pachico;cout<<endl
#define smap(m) cout<<#m<<":";each(pachico,m)cout<<" {"<<pachico.first<<":"<<pachico.second<<"}";cout<<endl

using namespace std;

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<P> vp;
typedef vector<string> vs;

const int MAX_N = 100005;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vi a(n);
    rep(i,n){
        cin >> a[i];
    }
    sort(all(a));
    vi b(n,0), c(n,0);
    if(n % 2){
        b[0] = a[n/2], b[n-1] = a[n/2-1];
        for(int i = 2; i < n-1; i += 2){
            b[i] = a[i/2-1];
        }
        for(int i = 1; i < n-1; i += 2){
            b[i] = a[n/2+1+i/2];
        }
        c[0] = a[n/2], c[n-1] = a[n/2+1];
        for(int i = 2; i < n-1; i += 2){
            c[i] = a[n/2+1+i/2];
        }
        for(int i = 1; i < n-1; i += 2){
            c[i] = a[i/2];
        }
    }else{
        for(int i = 0; i < n; i += 2){
            b[i] = a[n/2-1-i/2];
        }
        for(int i = 1; i < n; i += 2){
            b[i] = a[n-1-i/2];
        }
    }
    ll ans = 0, ans2 = 0;
    rep(i,n-1){
        ans += abs(b[i+1]-b[i]);
    }
    rep(i,n-1){
        ans2 += abs(c[i+1]-c[i]);
    }
    cout << max(ans,ans2) << "\n";
    return 0;
}


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

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

int ma[60][60];

int W,H;
void dfs(int nx,int ny){
	if(ma[ny][nx]==0)return;
	ma[ny][nx]=0;
	int re=0;
	for(int i=0;i<8;i++){
		int nex=nx+dx[i],ney=ny+dy[i];
		if(nex>=0&&ney>=0&&nex<W &&ney<H)dfs(nex,ney);
	}
}


int main(){
	int sx,sy;
	while(cin>>W>>H && W+H){
		for(int i=0;i<H;i++)for(int j=0;j<W;j++){
			cin>>ma[i][j];
		}
		int ans=0;
		for(int i=0;i<H;i++)for(int j=0;j<W;j++){
			if(ma[i][j]==1){ans++;dfs(j,i);}
		}
		cout<<ans<<endl;
	}
	
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;

 
int main() {
	
	string S;
	cin>>S;
	ll ans=0;
	ll X[11];
	int i=1,k=1;
	X[0]=1;
	while(i<=10){
		X[i]=X[i-1]*2;
		i++;
	}
	fx(S.size()){
		for(i=1;x+i<S.size()+1;i++){
			string K=S.substr(x,i);
int left=max(0,x-1);
int a=S.size()-x-i-1;
int right=max(0,a);
ll g=stoll(K.c_str());
ans+=g*X[left+right];
//cout<<K<<" "<<X[left+right]<<" "<<g<<endl;
		}
		
	}
	
	ce(ans)
	
}


Measured memory_bytes: 256
#include <stdio.h>
#include<stdlib.h>
int int_sort( const void * a , const void * b ) {
  if( *( long long int * )a < *( long long int * )b ) {
    return -1;
  }
  else
  if( *( long long int * )a == *(long long  int * )b ) {
    return 0;
  }
  return 1;
}

int main(void){
    long long int N,K;
    scanf("%lld %lld",&N,&K);
    long long int a[114514]={};
      size_t data_cnt=/*sizeof( a )/sizeof( a[0] )*/114514;
    for(int i=0;i<114514;i++)a[i]=2000000000000;
    for(int i=0;i<N;i++){
       long long  int s,t;
        scanf("%lld %lld",&s,&t);
        a[i]=1000000*s+t;
    }
      qsort(( void * )a, data_cnt , sizeof( a[0] )   , int_sort );
      long long int count=0;
      for(int i=0;i<N;i++){
          count+=(a[i]%1000000);
          if(count>=K){
              a[i]=a[i]/1000000;
              printf("%lld",a[i]);
              break;
          }
      }
    return 0;
}


Measured memory_bytes: 1788
class Node():
    def __init__(self, key):
        self.key = key
        self.left = None
        self.right = None
        self.parent = None


class BinarySearchTree():
    def __init__(self):
        self.root = None

    def insert(self, key):
        root_node = self.root
        insert_node = Node(key)
        parent_node = None

        while root_node:
            parent_node = root_node
            if insert_node.key < root_node.key:
                root_node = root_node.left
            else:
                root_node = root_node.right

        insert_node.parent = parent_node

        if parent_node is None:
            self.root = insert_node
        elif insert_node.key < parent_node.key:
            parent_node.left = insert_node
        else:
            parent_node.right = insert_node

    def find(self, key):
        root_node = self.root

        while root_node:
            if root_node.key == key:
                print('yes')
                return 0
            elif root_node.key < key:
                root_node = root_node.right
            else:
                root_node = root_node.left

        print('no')


    def show_preorder(self, node):
        node_list = []

        node_list.append(node.key)
        if node.left is not None:
            node_list.extend(self.show_preorder(node.left))
        if node.right is not None:
            node_list.extend(self.show_preorder(node.right))

        return node_list

    def show_inorder(self, node):
        node_list = []

        if node.left is not None:
            node_list.extend(self.show_inorder(node.left))
        node_list.append(node.key)
        if node.right is not None:
            node_list.extend(self.show_inorder(node.right))

        return node_list

    def print(self):
        print(' ' + ' '.join(map(str, self.show_inorder(self.root))))
        print(' ' + ' '.join(map(str, self.show_preorder(self.root))))


if __name__ == '__main__':
    tree = BinarySearchTree()

    n = int(input())

    for i in range(n):
        command = input().split()

        if command[0] == 'insert':
            tree.insert(int(command[1]))
        elif command[0] == 'find':
            tree.find(int(command[1]))
        elif command[0] == 'print':
            tree.print()

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

int main()
{
   int N; cin>>N;
   vector<pair<pair<string,int>,int>> v(N);
   for(int i=0;i<N;i++){
      cin>>v[i].first.first>>v[i].first.second;
      v[i].first.second*=-1;
      v[i].second=i;
   }
   sort(v.begin(),v.end());
   for(int i=0;i<N;i++) cout<<v[i].second+1<<endl;
   return 0;
}



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

int main() {
  long long n , a , b;
  long long p;
  long long c;

  cin >> n >> a >> b;

  if (n % (a+b) >= a ) {
    c = a + (n / (a+b)) * a; 
  }
  else {
    c = n%(a+b) + (n / (a+b)) * a;
  }
  cout << c << endl;  
}

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

const int M = 100005;
const ll p = 1e9+7;

ll n, a, b, c;
ll fact[M], invfact[M];
ll tot = 0;

ll exp(ll x, ll k) {
	if (k == 0)
		return 1;
	ll y = exp(x, k/2);
	if (k%2 == 0)
		return y*y%p;
	else
		return y*y%p*x%p;
}

ll inv(ll x) { return exp(x, p-2); }

ll binom(ll x, ll y) {
	if (y == 0)
		return 1;
	if (x < y || x < 0 || y < 0)
		return 0;
	return fact[x]*invfact[y]%p*invfact[x-y]%p;
}

int main() {
	cin >> n >> a >> b >> c;
	if (b%2 == 1) {
		cout << "0\n"; return 0;
	}

	fact[0] = invfact[0] = 1;
	for (int i = 1; i < M; ++i) {
		fact[i] = i*fact[i-1]%p;
		invfact[i] = inv(fact[i]);
	}

	for (int i = a+b/2; i <= n; ++i) {
		ll ct = binom(i, b/2)*binom(i-b/2, a)%p;
		ll d = c-3*(i-b/2-a);
		if (d < 0)
			continue;
		ll sum = 0;
		for (int j = 0; j <= d; ++j)
			sum = (sum + binom(b/2+j-1, j)*binom(a, d-j))%p;
		tot = (tot + sum*ct)%p;
	}

	cout << tot << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 998244353
#define mad(a,b) a=(a+b)%mod
#define mul(a,b) a=a*b%mod
#define N 100010
ll n;
pair<ll,ll> c[N];
ll a[N],b[N];
vector<ll> g[N];
bool vis[N];
void dfs(ll x){
    if(vis[x])return;
    vis[x]=1;
    for(auto y:g[x])dfs(y);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cin>>n;
    
    for(int i=0;i<n;i++){
	cin>>a[i];
	c[i].second=a[i];
    }
    for(int i=0;i<n;i++){
	cin>>b[i];
	c[i].first=b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    sort(c,c+n);
    bool oo=1;
    for(int i=0;i<n;i++){
	if(a[i]>b[i])oo=0;
    }
    if(oo==0){
	cout<<"No"<<endl;
	return 0;
    }
    bool ok=0;
    for(int i=0;i<n-1;i++){
	if(a[i+1]<=b[i])ok=1;
    }
    if(ok){
	cout<<"Yes"<<endl;
	return 0;
    }
    for(int i=0;i<n;i++)vis[i]=0;
    unordered_map<ll,ll> p;
    for(int i=0;i<n;i++)p[a[i]]=i;
    for(int i=0;i<n;i++){
	g[i].push_back(p[c[i].second]);
	g[p[c[i].second]].push_back(i);
	//cout<<"#"<<p[c[i].second]<<" "<<i<<endl;
    }
    dfs(0);
    ok=0;
    for(int i=0;i<n;i++){
	if(vis[i]==0)ok=1;
	//cout<<i<<" "<<vis[i]<<endl;
    }
    if(ok){
	cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}



Measured memory_bytes: 16164
#define _GLIBCXX_DEBUG //エラーを出すためのおまじない
#include <bits/stdc++.h>
//#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()
#include <math.h>
using namespace std;
#define coYES cout << "YES" << endl
#define coNO cout << "NO" << endl
#define coYes cout << "Yes" << endl
#define coNo cout << "No" << endl
#define coyes cout << "yes" << endl
#define cono cout << "no" << endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  double n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) {
    int num;
    cin >> num;
    a.at(i) = num;
  }
  double sum = 0;
  rep(i, n) {
    sum += a.at(i);
  }
  double border = sum / (4*m);
  int count = 0;
  rep(i, n) {
    if (a.at(i) >= border) {
      count++;
    }
  }
  if (count >= m) {
    coYes;
  }
  else {
    coNo;
  }
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
const ll INF = (1ll << 60);

int main() {
  ll M;
  cin >> M;
  vi d(M), c(M);
  for (ll i = 0; i < M; i++) cin >> d[i] >> c[i];
  ll ans = 0;

  ll sum1 = 0, sum2 = 0;
  for (ll i = 0; i < M; i++) {
    sum1 += d[i] * c[i];
    sum2 += c[i];
  }

  cout << (sum1 - 1) / 9 + sum2 - 1 << endl;
}


Measured memory_bytes: 3328
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void){

	char inp;
	int cnt=0,cnt2=0;
	int ok=0;
	string word[1024*2];

	while(1){
		inp=getchar();
		if(inp=='\n') break;
		if(inp!=','&&inp!='.'&&inp!=' '){
			word[cnt]+=inp;
		}
		else{
			if(word[cnt].length()>=3&&word[cnt].length()<=6) ok++;
			cnt++;
		}
	}
	for(int i=0;i<cnt;i++){
		if(word[i].length()>=3&&word[i].length()<=6){
			cnt2++;
			if(cnt2==ok) cout<<word[i]<<endl;
			else cout<<word[i]<<" ";
		}
	}
	
	return 0;
}

Measured memory_bytes: 1172
import java.io.*;
import java.util.*;

class Main {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        int num = 1;
        
        while(true){
            int n = scan.nextInt();
            
            if(n == 0) {
            	break;
            	}
            
            System.out.println("Case " + num++ + ": " + n);
        }
    }
}

Measured memory_bytes: 43076
#include "bits/stdc++.h"
using namespace std;
string str1;
 
int main() {
  cin >> str1;
  if(str1.compare("Sunny") == 0){
    cout << "Cloudy" << endl;
  }else if(str1.compare("Cloudy") == 0){
    cout << "Rainy" << endl;
  }else if(str1.compare("Rainy") == 0){
    cout << "Sunny" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

using namespace std;

int main() {
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a / b;
    r = a % b;
    f = (double) a / (double) b;
    cout << d << " " << r << " ";
    printf("%.8f\n", f);

    return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a+b>=c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
(* O(n√n) *)
let n = read_int ()
let divsor_count n =
  let rec f i =
    if i * i > n then 0
    else if i * i = n then 1
    else f (i + 1) + if n mod i = 0 then 2 else 0 in f 1
let ans = ref 0
let _ =
  for i = 1 to n do if i mod 2 = 1 && divsor_count i = 8 then incr ans done;
  Printf.printf "%d\n" !ans

Measured memory_bytes: 384
// インクルード
#include <bits/stdc++.h>

// 名前空間省略
using namespace std;

// メイン関数
int main()
{
    // 標準入出力　高速化
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    long double a,b;
    long double h,m;

    cin >> a >> b >> h >> m;

    long double h_ang = 2*M_PI*(h*60+m)/(60*12);
    long double m_ang = 2*M_PI*m/60;
    long double ang = fabs(h_ang - m_ang);

    long double ans = sqrt(a*a+b*b-2*a*b*cos(ang));
    cout << fixed << setprecision(20) << ans << endl;
}


Measured memory_bytes: 4180
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <cstdio>
#include <algorithm>
using namespace std;

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

    int count = 0;
    int imax = 0, imin = (1 << 7);
    for(int i = 1; i <= n; ++i){
        int a;
        cin >> a;

        if(i == 1) {
            imax = a;
            imin = a;
        }
        if(a <= imax && a <= imin){
            count++;
        }
        imax = std::max(imax, a);
        imin = std::min(imin, a);
    }

    cout << count << endl;
}

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

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

using namespace std;
using lint=long long;

template<class G>
class Fenwick_tree{
	vector<G> a;
public:
	Fenwick_tree(){}
	Fenwick_tree(int n){ build(n); }
	Fenwick_tree(const vector<G>& a){ build(a); }
	void build(int n){
		a.assign(n,G{});
	}
	void build(const vector<G>& a){
		this->a=a;
		for(int i=1;i<a.size();i++) if(i+(i&-i)-1<a.size()) (this->a)[i+(i&-i)-1]+=(this->a)[i-1];
	}
	void add(int i,const G& val){
		for(i++;i<=a.size();i+=i&-i) a[i-1]+=val;
	}
	G sum(int l,int r)const{
		if(l==0){
			G res{};
			for(;r>0;r-=r&-r) res+=a[r-1];
			return res;
		}
		return sum(0,r)-sum(0,l);
	}
	int lower_bound(G val)const{
		if(val<=G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<val) val-=a[x+k-1], x+=k;
		return x;
	}
	int upper_bound(G val)const{
		if(val<G{}) return 0;
		int x=0,k;
		for(k=1;k<=a.size();k<<=1);
		for(k>>=1;k>0;k>>=1) if(x+k<=a.size() && a[x+k-1]<=val) val-=a[x+k-1], x+=k;
		return x;
	}
};

int main(){
	int n,q; scanf("%d%d",&n,&q);
	vector<lint> a(n);
	rep(i,n) scanf("%lld",&a[i]);

	Fenwick_tree<lint> F(a);
	rep(_,q){
		int t,l,r; scanf("%d%d%d",&t,&l,&r);
		if(t==0) F.add(l,r);
		else     printf("%lld\n",F.sum(l,r));
	}

	return 0;
}


Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
int main()
{long long n=0,d=0,d1=0,c=0,d2=0;
    cin>>n>>d;
    long long a[n],b[n];
    for(long long i=0;i<n;i++)
    {
        cin>>a[i]>>b[i];
        d1=floor(sqrt((double)((a[i]*a[i])+(b[i]*b[i]))));
        d2=ceil(sqrt((double)((a[i]*a[i])+(b[i]*b[i]))));
        if(d1<d)
        c++;
        else if(d1==d2&&d1==d)
        c++;
        
    }
    cout<<c;
}

Measured memory_bytes: 6864
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define ssort(a) sort(a.begin(), a.end())
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int ai=a[n-1], aj;
  int it=lower_bound(a.begin(), a.end(), a[n-1]/2)-a.begin();
  if(it==n-1){
    aj=a[n-2];
  } else {
    if(it==0){
      aj=a[0];
    } else {
      if(abs(2*a[it]-a[n-1])>abs(2*a[it-1]-a[n-1])){
        aj=a[it-1];
      } else {
        aj=a[it];
      }
    }
  }
  cout << ai << " " << aj << endl;
  return 0;
}


Measured memory_bytes: 3708
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            execute(sc);
        }
    }

    static void execute(Scanner sc) {
        int n = sc.nextInt();sc.nextLine();
        if (n == 0) { return; }
        int[][] rs = new int[n + 1][n + 1];
        for (int i = 0; i < n; i++) {
            int[] line = convertInt(sc.nextLine().split(" "));
            for (int j = 0; j < n; j++) {
                rs[i][j] = line[j];
            }
            rs[i][n] = sum(line);
        }
        for (int i = 0; i < n + 1; i++) {
            int sumVertical = 0;
            for (int j = 0; j < n; j++) {
                sumVertical += rs[j][i];
            }
            rs[n][i] = sumVertical;
        }
        for (int[] A : rs) {
            for (int i : A) {
                System.out.print(String.format("%5s", String.valueOf(i)));
            }
            System.out.println("");
        }
    }

    static int[] convertInt(String[] args) {
        int[] intA = new int[args.length];
        for (int i = 0; i < args.length; i++) {
            intA[i] = Integer.parseInt(args[i]);
        }
        return intA;
    }

    static int sum(int[] A) {
        int rs = 0;
        for (int i = 0; i < A.length; i++) {
            rs += A[i];
        }
        return rs;
    }
}



Measured memory_bytes: 30084
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int P=1e9+7;
inline void upd(R int &x,R int y){(x+=y)>=P?x-=P:0;}
inline int inc(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
	R int res=1;
	for(;y;y>>=1,x=mul(x,x))(y&1)?res=mul(res,x):0;
	return res;
}
const int N=505;
char s[N];int a[N],b[N],f[N],g[N],C[N][N],st[N],fac[N],ifac[N],n,L,res;
inline int max(R int x,R int y){return x>y?x:y;}
//inline int calc(){
//	int s=0,t=0;
//	t=n-(top-1),s=top+1;
//	fp(i,1,top)s+=(st[i]<<1)-1,t-=max((st[i]<<1)-3,1);
//	return s-1<0||t<0?0:C[s+t-1][s-1];
//}
bool ck(int top){
	fp(i,1,top)a[i]=st[i];
	sort(a+1,a+1+top,[](const int &x,const int &y){return x>y;});
	fp(i,1,n)b[i]=0;
	for(R int i=1,j=1;i<=top;++i){
		while(j<=n&&s[j]!='r')++j;
		if(j>n)return false;
		f[i]=j,b[j]=1,++j;
	}
	for(R int i=1,j=1;i<=top&&a[i]>=2;++i){
		cmax(j,f[i]+1);
		while(j<=n&&s[j]!='b')++j;
		if(j>n)return false;
		g[i]=j,b[j]=1,++j;
	}
	for(R int i=1,j=1,r;i<=top&&a[i]>=3;++i){
		cmax(j,g[i]+1),r=a[i]-2;
//		printf("%d %d\n",i,j);
		while(j<=n&&r)r-=!b[j],++j;
		if(r)return false;
	}
//	fp(i,1,top)printf("%d%c",st[i]," \n"[i==top]);
//	puts("---------------");
	
	return true;
}
inline int calc(R int top){
	R int res=fac[top];
	for(R int i=1,j=1;i<=top;i=j){
		while(j<=top&&st[i]==st[j])++j;
		res=mul(res,ifac[j-i]);
	}
	return res;
}
void dfs(int pos,int s,int t,int lim){
	if(ck(pos-1))upd(res,mul(C[s+t-1][s-1],calc(pos-1)));
//	if(st[pos-1]==3)printf("qwq %d %d %d\n",pos,s,t);
	if(t<=1)return;
	for(int i=lim,rt;i<=t;++i){
		rt=t-max((i<<1)-3,1)-1;
		if(rt<0)return;
		st[pos]=i,dfs(pos+1,s+(i<<1)-1+1,rt,i);
	}
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&L,&n);
	scanf("%s",s+1);
	C[0][0]=fac[0]=ifac[0]=1;
	fp(i,1,500){
		C[i][0]=1,fac[i]=mul(fac[i-1],i);
		fp(j,1,i)C[i][j]=inc(C[i-1][j],C[i-1][j-1]);
	}
	ifac[500]=ksm(fac[500],P-2);fd(i,499,1)ifac[i]=mul(ifac[i+1],i+1);
//	st[1]=3,st[2]=1,printf("%d\n",ck(2));
	dfs(1,1,L+1,1);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 1280
x1, y1, x2, y2 = map(int, input().split())

diff1 = x2 - x1
diff2 = y2 - y1

x3, y3 = x2 - diff2, y2 + diff1
x4, y4 = x3 - diff1, y3 - diff2

print(x3, y3, x4, y4)


Measured memory_bytes: 2940
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <iostream>
#include <string>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

const int MaxN = 1e5;
int n;
LL a[MaxN + 5];

int main()
{
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) {
		scanf("%lld", &a[i]);
	}
	LL ans = 1LL << 60;
	if(a[1] != 0LL){
		LL res = 0LL;
		LL sum = a[1]; int flag;
		if(sum < 0LL) flag = -1;
		else flag = 1;
		for(int i = 2; i <= n; i++) {
			sum += a[i];
			if(flag == 1) {
				if(sum >= 0LL) res += (sum + 1LL), sum = -1LL;
			}
			else {
				if(sum <= 0LL) res += (abs(sum) + 1LL), sum = 1LL;
			}
			flag = -flag;
		}
		ans = min(ans, res);
		if(a[1] > 0) {
			sum = -1; flag = -1;
			res = (a[1] + 1LL);
		}
		else {
			sum = 1; flag = 1;
			res = (abs(a[1]) + 1LL);
		}
		for(int i = 2; i <= n; i++) {
			sum += a[i];
			if(flag == 1) {
				if(sum >= 0LL) res += (sum + 1LL), sum = -1LL;
			}
			else {
				if(sum <= 0LL) res += (abs(sum) + 1LL), sum = 1LL;
			}
			flag = -flag;
		}
		ans = min(ans, res);
	}
	else {
		LL res = 1LL;
		LL sum = 1LL; int flag = 1;
		for(int i = 2; i <= n; i++) {
			sum += a[i];
			if(flag == 1) {
				if(sum >= 0LL) res += (sum + 1LL), sum = -1LL;
			}
			else {
				if(sum <= 0LL) res += (abs(sum) + 1LL), sum = 1LL;
			}
			flag = -flag;
		}
		ans = min(ans, res);
		sum = -1LL; flag = -1;
		res = 1LL;
		for(int i = 2; i <= n; i++) {
			sum += a[i];
			if(flag == 1) {
				if(sum >= 0LL) res += (sum + 1LL), sum = -1LL;
			}
			else {
				if(sum <= 0LL) res += (abs(sum) + 1LL), sum = 1LL;
			}
			flag = -flag;
		}
		ans = min(ans, res);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 1024