akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

ll d[MAXn];
int main(){
    IOS();
    ll n;
    cin >> n;
    REP (i,n) cin >> d[i];
    ll ans = 0;
    REP1 (i,n-2) {
        vector<ll> v;
        for (ll j=i-1;j<=i+1;j++) v.eb(d[j]);
        sort(ALL(v));
        if (v[1] == d[i]) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.HashMap;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author anand.oza
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CGreenBin solver = new CGreenBin();
        solver.solve(1, in, out);
        out.close();
    }

    static class CGreenBin {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            HashMap<String, Integer> count = new HashMap<>();
            int n = in.nextInt();

            for (int i = 0; i < n; i++) {
                char[] c = in.next().toCharArray();
                Arrays.sort(c);
                String s = String.valueOf(c);
                count.put(s, count.getOrDefault(s, 0) + 1);
            }

            long answer = 0;
            for (int x : count.values()) {
                answer += nc2(x);
            }

            out.println(answer);
        }

        long nc2(long n) {
            return n * (n - 1) / 2;
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 44816
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var n, a, b int
	fmt.Fscan(r, &n)
	fmt.Fscan(r, &a)
	fmt.Fscan(r, &b)
	xs := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Fscan(r, &xs[i])
	}

	ans := 0
	for i := 0; i < n-1; i++ {
		distance := xs[i+1] - xs[i]
		if distance*a <= b {
			ans += distance * a
		} else {
			ans += b
		}
	}

	fmt.Println(ans)
}

// Union-Find
type unionFind struct {
	d []int
}

func newUnionFind(n int) *unionFind {
	uf := new(unionFind)
	uf.d = make([]int, n)
	for i := 0; i < n; i++ {
		uf.d[i] = -1
	}
	return uf
}

func (uf *unionFind) find(x int) int {
	if uf.d[x] < 0 {
		return x
	}
	uf.d[x] = uf.find(uf.d[x])
	return uf.d[x]
}

func (uf *unionFind) unite(x, y int) bool {
	rootX := uf.find(x)
	rootY := uf.find(y)
	if rootX == rootY {
		return false
	}

	if uf.d[rootX] < uf.d[rootY] {
		uf.d[rootX] += uf.d[rootY]
		uf.d[rootY] = rootX
	} else {
		uf.d[rootY] += uf.d[rootX]
		uf.d[rootX] = rootY
	}

	return true
}

func (uf *unionFind) same(x, y int) bool {
	return uf.find(x) == uf.find(y)
}

func (uf *unionFind) size(x int) int {
	return -uf.d[uf.find(x)]
}

// mod combination
func modpow(a, n, mod int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % mod
		}
		a = a * a % mod
		n = n / 2
	}
	return res
}

func modcomb(n, a, mod int) int {
	x := 1
	y := 1
	for i := 0; i < a; i++ {
		x = x * (n - i)
		x %= mod
		y = y * (i + 1)
		y %= mod
	}
	return x * modpow(y, mod-2, mod) % mod
}

func modfactorial(n, mod int) int {
	result := 1
	for i := 1; i <= n; i++ {
		result = (result * i) % mod
	}
	return result
}

// Utility

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func primeFactor(x int) map[int]int {
	res := make(map[int]int)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			res[i]++
			x = x / i
		}
	}
	if x != 1 {
		res[x] = 1
	}
	return res
}

func divisor(x int) []int {
	res := make([]int, 0)
	for i := 1; i*i <= x; i++ {
		if x%i == 0 {
			res = append(res, i)
			if i != x/i {
				res = append(res, x/i)
			}
		}
	}
	return res
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x / gcd(x, y) * y
}

func reverseString(s string) string {
	r := []rune(s)
	for i, j := 0, len(r)-1; i < len(r)/2; i, j = i+1, j-1 {
		r[i], r[j] = r[j], r[i]
	}
	return string(r)
}

// Queue ...
type Queue []int

// pop ...
func (q *Queue) empty() bool {
	return len(*q) == 0
}

// push ...
func (q *Queue) push(i int) {
	*q = append(*q, i)
}

// pop ...
func (q *Queue) pop() (int, bool) {
	if q.empty() {
		return 0, false
	} else {
		res := (*q)[0]
		*q = (*q)[1:]
		return res, true
	}
}

// Stack ...
type Stack []int

// pop ...
func (s *Stack) empty() bool {
	return len(*s) == 0
}

// push ...
func (s *Stack) push(i int) {
	*s = append(*s, i)
}

// pop ...
func (s *Stack) pop() (int, bool) {
	if s.empty() {
		return 0, false
	} else {
		index := len(*s) - 1
		res := (*s)[index]
		*s = (*s)[:index]
		return res, true
	}
}


Measured memory_bytes: 3072
#include<stdio.h>
int main()

{
    int a,b,c,x,y,z,ans;
    scanf("%d %d %d",&a,&b,&c);

    if(a<=b&&a<=c)
    {
        x=a;
        if(b<=c)
        {
            y=b;
            z=c;
        }
        else
        {
            y=c;
            z=b;
        }
    }

    else  if(b<=c&&b<=a)
    {
        x=b;
        if(c<=a)
        {
            y=c;
            z=a;
        }
        else
        {
            y=a;
            z=c;
        }
    }
    else  if(c<=b&&c<=a)
    {
        x=c;
        if(a<=b)
        {
            y=a;
            z=b;
        }
        else
        {
            y=b;
            z=a;
        }
    }


    ans=z*10+y+x;

    printf("%d",ans);




}


Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <clocale>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = (s), i##_len=(n); i < i##_len; ++i)
#define FORS(i, s, n) for(int i = (s), i##_len=(n); i <= i##_len; ++i)
#define VFOR(i, s, n) for(int i = (s); i < (n); ++i)
#define VFORS(i, s, n) for(int i = (s); i <= (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) FORS(i, 0, n)
#define VREP(i, n) VFOR(i, 0, n)
#define VREPS(i, n) VFORS(i, 0, n)
#define RFOR(i, s, n) for(int i = (s), i##_len=(n); i >= i##_len; --i)
#define RFORS(i, s, n) for(int i = (s), i##_len=(n); i > i##_len; --i)
#define RREP(i, n) RFOR(i, n, 0)
#define RREPS(i, n) RFORS(i, n, 0)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v), greater<decltype(v[0])>())
#define SZ(x) ((int)(x).size())
#define REV(x) reverse(ALL(x))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end())

using ld = long double;
using ll = long long;
using ui = unsigned int;
using ull = unsigned long long;
using Pi_i = pair<int, int>;
using Pll_ll = pair<ll, ll>;
using VB = vector<bool>;
using VC = vector<char>;
using VD = vector<double>;
using VI = vector<int>;
using VLL = vector<ll>;
using VS = vector<string>;
using VSH = vector<short>;
using VULL = vector<ull>;

const int MOD = 1000000007;
const int INF = 1000000000;
const int NIL = -1;
const double EPS = 1E-10;

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


int main(){
    int A, B, C; cin >> A >> B >> C;
    ll K; cin >> K;
    cout << ((K%2) ? B-A : A-B) << endl;
    return 0;
}


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

x = x2 - x1
y = y2 - y1

x3 = x2 - y
y3 = y2 + x
x4 = x1 - y
y4 = y1 + x
print('{} {} {} {}'.format(x3,y3,x4,y4))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> a(n + 1), b(n);
  for (int i = 0; i < n + 1; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    int n = max(min(a[i], b[i]), 0);
    a[i] -= n;
    b[i] -= n;
    ans += n;
    if (0 < b[i]) {
      int m = min(b[i], a[i + 1]);
      a[i + 1] -= m;
      b[i] -= m;
      ans += m;
    }
  }
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  ll r, D, X;
  cin >> r >> D >> X;
  for (int i=1; i<=10; i++) {
    X = r*X-D;
    cout << X << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	int n;
	while(cin >> n) {
		int a[200005] = {0};

		for(int i = 0; i < n; i++) {
			cin >> a[i];
		}
		int big1 = -0x3f3f3f3f, big2 = -0x3f3f3f3f;
		int t1;
		for(int i = 0; i < n; i++) {
			if(big1 < a[i]) {
				big1 = a[i];
				t1 = i;
			}
		}
		for(int i = 0; i < n; i++) {
			if(i == t1)
				continue;
			big2 = max(big2, a[i]);
		}
		for(int i = 0; i < n; i++) {
			if(i == t1) {
				cout << big2 << endl;
			}
			else
				cout << big1 << endl;
		}
	}
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int N;
long long X;
long long ans[51], cnt[51];

long long dfs(int id, long long rem) {
  if (rem == 1) {
    if (id == 0) return 1;
    else return 0;
  } 
  else if (rem >= 2 && rem <= cnt[id-1]+1) {
    return dfs(id-1, rem-1);
  } 
  else if (rem == cnt[id-1]+2) {
    return ans[id-1] + 1;
  } 
  else if (rem == cnt[id]) {
    return 2*ans[id-1] + 1;
  } 
  else {
    return dfs(id-1, rem-cnt[id-1]-2) + 1 + ans[id-1];
  }
}

int main() {
  cin >> N >> X;

  ans[0] = 1;
  cnt[0] = 1;

  long long res;
  for (int i = 1; i <= N; i++) {
    cnt[i] = 2 * cnt[i-1] + 3;
    ans[i] = 2 * ans[i-1] + 1;
    /*if (cnt[i] < X) {
      ans[i] = 2 * ans[i-1] + 1;
    } else {
      res = dfs(i, X);
      break;
    }*/
  }


  res = dfs(N, X);

  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N, K = MAP()

i = 0
while K**i <= N:
    i += 1
print(i)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/

vector<vector<ll>> G;
vector<bool> seen;
queue<ll> Q;
struct UnionFind{
  vector<ll> par,siz;
  
  UnionFind(ll N):par(N+1),siz(N+1,1){
    for(int i=0; i<=N; i++)
      par[i]=i;
  }
  
  void mkpar(ll n, ll set){//親はset=根
    for(auto next_n: G[n]){
      if (seen[next_n]) continue;
      seen[next_n]=true;
      par[next_n]=set;
      mkpar(next_n, set);
    }
  }

  void mkpar2(){//親は1個上、引数1個
    while (!Q.empty()){
      ll n = Q.front(); Q.pop();
      for(auto next_n: G[n]){
        if (seen[next_n]) continue;
        seen[next_n] = true;
        par[next_n] = n;
        Q.push(next_n);
      }
    }
  }

  ll root(ll x){
    if(par[x]==x)
      return x;
    return par[x]=root(par[x]);
  }
  
  void unite(ll x, ll y){
    ll rx=root(x), ry=root(y);
    if(rx==ry)
      return;
    par[ry]=rx;
    siz[rx]+=siz[ry];    
  }
  
  bool issame(ll x, ll y){
    return root(x)==root(y);
  }
  
  ll size(ll x){
    return siz[root(x)];
  }
};

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

  ll N, M; cin >> N >> M;
  G.assign(N+1, vector<ll>());
  seen.assign(N+1,false);
  for(int i=0; i<M; i++){
    ll a,b; cin>>a>>b;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  UnionFind tree(N);
  seen[1]=true;
  Q.push(1);
  tree.mkpar2();
  cout << "Yes" << endl;
  for (ll i=2; i<=N; i++)
    cout<<tree.par[i]<<endl;
}


Measured memory_bytes: 13668
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=505;
int a[maxn];int n,k;
int pre[maxn],suf[maxn];
bool cal(int x)
{
	//cout<<x<<endl;
	vector<int> vec(n+1);
	for(int i=1;i<=n;i++)
	{
		vec[i]=a[i]%x;
	}
	sort(vec.begin()+1,vec.end());
	pre[0]=0;suf[n+1]=0;// i=1;
	for(int i=1;i<=n;i++)
	{
		pre[i]=pre[i-1]+vec[i];
	//	cout<<pre[i]<<" ";
	}
	//cout<<endl;
	for(int i=n;i>=1;i--)
	{
		suf[i]=suf[i+1]+x-vec[i];
		//cout<<suf[i]<<" ";
	}
	//cout<<endl;
	for(int i=1;i<=n;i++)
	{
		if(pre[i]==suf[i+1] && pre[i]<=k)
		{
			return true;
		}
	}
	return false;
}
int main()
{
	cin>>n>>k;int sum=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	int ans=1;vector<int> tmp;int flag=0;
	for(int i=1;i<=sqrt(sum);i++)
	{
		if(sum%i==0)
		{
			tmp.push_back(i);
			if(cal(sum/i))
			{
				ans=sum/i;flag=1;
				//cout<<ans<<endl;
				break;
			}
		}
	}
	if(flag==0)
	{
		for(int i=tmp.size()-1;i>=0;i--)
		{
			if(cal(tmp[i]))
			{
				ans=tmp[i];
				break;
			}
		}
	}
	cout<<ans<<endl;
 } 

Measured memory_bytes: 256
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int n = cin.ReadInt;
            string[] s = new string[100];
            bool flg = true;
            for (int i = 0; i < n; i++) s[i] = cin.Read;
            for (int i = 1; i < n && flg; i++)
            {
                if (s[i - 1][s[i - 1].Length-1] != s[i][0])
                {
                   
                    flg = false;
                }
                for (int j = 0; j < i && flg; j++)
                {
                    if (s[i] == s[j])
                    {
                      
                        flg = false;
                    }
                    
                }
            }
            
            if (flg == true)
            {
                WriteLine("Yes");
            }
            else
            {
                WriteLine("No");
            }



        }//void solve
    }//public static voiid Main(string[] args
 

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}



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


void updMax(int& ref, int v) {
  ref = max(ref, v);
}

int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N, T; cin >> N >> T;
  vector<int> A(N), B(N);
  for (int i = 0; i < N; i++) cin >> A.at(i) >> B.at(i);
  vector<vector<int>> dp(T+1, vector<int>(2));
  for (int i = 0; i < N; i++) {
    for (int t = T; t > 0; t--) {
      for (int k = 0; k < 2; k++) {
	if (t - A.at(i) >= 0) updMax(dp.at(t).at(k),
				     dp.at(t - A.at(i)).at(k) + B.at(i));
	if (k == 1 && t - 1 >= 0) updMax(dp.at(t).at(1),
					 dp.at(t-1).at(0) + B.at(i));
      }
    }
  }
  cout << dp.at(T).at(1) << endl;

  return 0;
}



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

int main() {
  int n, i;
  unsigned long long cnt, ans = 0;
  cin >> n;
  vector<string> s(n);
  for (i = 0; i < n; i++) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
  }
  sort(s.begin(), s.end());
  cnt = 1;
  for (i = 0; i < n-1; i++) {
    if (s[i] == s[i+1]) cnt++;
    else if (s[i] != s[i+1] && cnt > 1) {
      ans += cnt*(cnt-1)/2;
      cnt = 1;
    }
    if (i == n-2)
      ans += cnt*(cnt-1)/2;
  }
  cout << ans << endl;
}

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

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<setprecision(10)<<fixed;
	int n;
	cin>>n;
	int m=INT_MAX;
	int t;
	int c=0;
	for(int i=0;i<n;i++)
	{
		cin>>t;
		if(t<=m)
			c++;
		if(m>t)
			m=t;
	}
	cout<<c<<endl;
	return 0;
}



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

int m, n;

int main(){
    while(cin >> m, m){
        set<pair<int,int>> cons, sky;
        int x, y;
        for(int i = 0; i < m; i++){
            cin >> x >> y;
            cons.insert({x,y});
        }
        cin >> n;
        for(int i = 0; i < n; i++){
            cin >> x >> y;
            sky.insert({x,y});
        }

        pair<int,int> s = *(cons.begin());

        for(pair<int,int> target : sky){
            int diffx = target.first - s.first;
            int diffy = target.second - s.second;

            bool judge = true;
            for(pair<int,int> c : cons){
                pair<int,int> p(diffx + c.first, diffy + c.second);
                if(sky.find(p) == sky.end()){
                    judge = false;
                    break;
                }
            }

            if(judge){
                cout << diffx << " " << diffy << endl;
                break;
            }
        }
    }
    return 0;
}


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

signed main(){
    int n,a,b;
    cin >>n >> a >>b;
    int p,x,y,z;
    x =0;y=0;z=0;
    for(int i=0;i<n;i++){
        cin >> p;
        if(p<=a){
            x++;
        }else{
            if(p<=b){
                y++;
            }else{
                z++;
            }
        }
    }
    cout << min(min(x,y),z);




    return 0;
}

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


int main(){
    int N,D;
    float X[11][11];
    float ftmp;
    int itmp;
    float tmp;
    int ans = 0;
    cin >> N >> D;

    for(int i = 1; i <= N; i++){
        for(int j = 1; j <= D; j++){
            cin >> X[i][j];
        }
    }
    for(int i = 1; i < N; i++){
        for(int k = 1; k+i <= N; k++){
            tmp = 0;
            for(int j = 1; j <= D; j++){
                tmp = tmp + (X[i][j]-X[i+k][j])*(X[i][j]-X[i+k][j]);
            }
            ftmp = sqrt(tmp);
            itmp = sqrt(tmp);
            if(ftmp == itmp){
                ans++;
            }
        }
    }

   

  
    cout << ans <<"\n";
    
    
    return 0;
}

Measured memory_bytes: 256
// 22
#include <bits/stdc++.h>
using namespace std;
#define coutc "\033[48;5;196m\033[38;5;15m"
#define endc "\033[0m"
#define endl '\n'
#define M(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) \
  M(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep4(_, x, n, s) \
  for (int _ = x; (s < 0) ? _ > n : _ < n; _ += s)
#define rep3(_, x, n) rep4(_, x, n, (x < n ? 1 : -1))
#define rep2(_, n) rep3(_, 0, n)
#define rep1(n) rep2(i, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define len(x) int(x.size())
#define lli __int128_t
#define li long long int
#define ld long double
// 4
template <class A, class B>
ostream &operator<<(ostream &o, const pair<A, B> &p) {
  return o << "(" << p.fi << ", " << p.se << ")";
}
// 5
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v) {
  rep(i, len(v)) o << setw(7) << left << v[i];
  return o << endc << endl << coutc;
}
// 5
template <class A, class B>
ostream &operator<<(ostream &o, const map<A, B> &m) {
  for (auto &kv : m) o << kv;
  return o;
}
// 7
template <class T, class... Ts>
void debug(const T &e, const Ts &... r) {
#ifdef DEBUG
  cerr << coutc << e;
  ((cerr << " " << r), ..., (cerr << endc << endl));
#endif
}
// 3
void _main(int tc) {
  ld x;
  cin >> x;
  li s = 100;
  int cnt = 0;
  while (s < x) {
    s = s * 1.01;
    cnt++;
  }
  cout << cnt << endl;
}
// 7
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0), exit(0);
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 3716
def partition(A, p, r):
	x = A[r]
	i = p - 1
	for j in range(p, r):
		if A[j] <= x:
			i += 1
			A[i], A[j] = A[j], A[i]
	A[i + 1], A[r] = A[r], A[i + 1]
	return i + 1

n = int(input())
A = list(map(int, input().split()))

idx = partition(A, 0, n - 1)
S = " ".join(map(str, A[:idx]))
S += " [" + str(A[idx]) + "] "
S += " ".join(map(str, A[idx + 1:]))
print(S)


Measured memory_bytes: 16384
#include <bits/stdc++.h>
using namespace std;
int main()
{long long i,j,sum,x,y,m,n,t,q,b,l;
 cin>>i>>j>>x>>y;
 sum=LLONG_MIN;
 sum=max(sum,i*x);
 sum=max(sum,y*j);
 sum=max(sum,j*x);
 sum=max(sum,i*y);
 cout<<sum;
       return 0;
}


Measured memory_bytes: 3628
#!/usr/bin/env python
import sys
import re
from collections import deque, defaultdict
from itertools import combinations, combinations_with_replacement
import bisect
from math import factorial, sqrt, log, ceil, floor
sys.setrecursionlimit(1000000)


def get_longest(x, longest, edges):
    if longest[x] is not None:
        return longest[x]
    if not edges[x]:
        longest[x] = 0
    else:
        result = max([get_longest(y, longest, edges)
                      for y in edges[x]])
        longest[x] = result + 1
    return longest[x]


def main():
    input = sys.stdin.readline
    #N, M = map(int, input().split())
    #N, K = map(int, input().split())
    #ps = list(map(int, input().split()))

    N, M = map(int, input().split())

    edges = defaultdict(set)
    for i in range(M):
        x, y = map(int, input().split())
        edges[x].add(y)

    longest = [None] * (N + 1)
    for x in range(N):
        x += 1
        if longest[x] is None:
            get_longest(x, longest, edges)

    print(max(longest[1:]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 232824
# include <iostream>
# include <cmath>
# include <vector>
# include <algorithm>
# include <string>
# include <set>
# include <map>
# include <bitset>
# include <queue>

# define FILE
using namespace std;

int main()
{
    # ifdef FILEs
        freopen( "input.txt", "r", stdin );
        freopen( "output.txt", "w", stdout );
    # endif // FILE
    ios_base::sync_with_stdio( false );

    int n, m;
    cin >> n >> m;
    priority_queue < int > pq;
    for( int i = 1;  i <= n; i++ ){
        int a;
        cin >> a;
        pq.push( a );
    }

    long long ans = 0;
    for( int i = 1; i <= m; i ++ ){
        int q = pq.top();
        pq.pop();
        q/=2;
        pq.push( q );
    }
    while( pq.empty() == false){
        ans += pq.top();
        pq.pop();
    }
    cout << ans;

    return 0;
}


Measured memory_bytes: 892
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	if (a > b)
		printf("a > b\n");
	else if (a < b)
		printf("a < b\n");
	else
		printf("a == b\n");

	return 0;
}


Measured memory_bytes: 2528
import numpy as np
N = int(input())
xs = np.array(list(map(int,input().split(" "))))
x_min,x_max = xs.min(),xs.max()
powers = []
for x in range(x_min,x_max + 1,1):
    powers.append(sum((xs-x)**2))
print(min(powers))

Measured memory_bytes: 12504
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = (1..n).map { readLine()!!.split(" ").map(String::toInt) }

    (0..100).forEach { x ->
        (0..100).forEach { y ->
            val p = xs.first { xyh -> xyh[2] != 0}
            val h = Math.abs(x - p[0]) + Math.abs(y - p[1]) + p[2]
            var c = xs.all { it[2] == Math.max(h - Math.abs(x - it[0]) - Math.abs(y - it[1]), 0) }
            if (c) {
                println("$x $y $h")
                return
            }
        }
    }
}

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

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  int max = 0;
  rep(i, n) {
    int a;
    cin >> a;
    if (a < max) {
      ans += max - a;
    } else {
      max = a;
    }
  }

  cout << ans << endl;
  return 0;
}
/*
*/


Measured memory_bytes: 3524
#include <bits/stdc++.h>
using namespace std;
//gcdを求める
int gcd(int a,int b) {
    int r,m;

    if(a < b) {
        swap(a,b);
    }
    if(a == 1 ||b == 0)
    return 1;

    while( b != 0){

        r = a%b;
        a = b;
        b = r;
    }
    return a;
}
    


int main (){
    //入力
    int n;
    cin >> n;
     vector <int> a = vector<int> (n);
     for(int i = 0 ; i < n ; i ++){
        cin >>  a.at(i);
    }

    vector <int> r = vector<int> (n);
    vector <int> l = vector<int> (n);

    l.at(0) = a.at(0);
    r.at(0) = a.at(n-1);

    

    for(int i = 1 ; i < n; i ++) {
       
        l.at(i) = gcd(a.at(i),l.at(i - 1));
        r.at(i) = gcd(a.at(n - i - 1),r.at(i - 1));

    }

    int ans = r.at(n-2);
    
if(n == 2){
    cout << max(a.at(0),a.at(1)) << endl;
} else {
    for (int i = 1; i < n-1; i ++) {
        
        
        //[i]番目をぬかして最大公約数を求める
        
        ans = max( gcd(l.at(i - 1),r.at(n - i- 2)),ans);
        

    }
    ans = max(ans,l.at(n-2));
    
    cout << ans <<endl;
}
    
}

Measured memory_bytes: 1408
#include<stdio.h>
#define MAX 100
#define INFTY 1000000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

int prim(){
    int u,minv,i,v;
    int d[MAX],p[MAX],color[MAX];

    for(i = 0; i < n; i++){
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    d[0] = 0;

    while(1){
        minv = INFTY;
        u = -1;
        for(i = 0;i < n; i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
           }
        }
        if(u == -1) break;
        color[u] = BLACK;
        for(v = 0; v < n; v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[v] > M[u][v]){
                    d[v] = M[u][v];
                    p[v] = u;
                    color[v] = GRAY;
                }
            }
        }
    }
    int sum = 0;
    for(i = 0; i < n; i++){
        if(p[i] != -1) sum += M[i][p[i]];
    }

    return sum;
}

int main(){
    int i,j,e;
    scanf("%d",&n);

    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            scanf("%d",&e);
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }

    printf("%d\n",prim());

    return 0;
}


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

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

  int N;
  cin >> N;
  vector<int> A(N);
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }
  sort(begin(A), end(A));
  sort(begin(B), end(B));
  int medianA, medianB;
  if (N & 1) {
    medianA = A[(N + 1) / 2 - 1];
    medianB = B[(N + 1) / 2 - 1];
  } else {
    medianA = (A[(N / 2) - 1] + A[N / 2]);
    medianB = (B[(N / 2) - 1] + B[N / 2]);
  }
  
  cout << (medianB - medianA + 1) << "\n";
  return 0;
}


Measured memory_bytes: 4784
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  lint N,D;
  cin>>N>>D;
  int ans=0;
  REP(i,N){
    lint X,Y;
    cin>>X>>Y;
    if(X*X+Y*Y<=D*D)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3604
import qualified Data.ByteString.Char8 as C
import Data.List
import Data.Ord

main = sol <$> get <*> get >>= print

get = unfoldr (C.readInt . C.dropWhile (==' ')) <$> C.getLine

sol [_,k] as = f k ps
  where
  bs = sortBy (flip compare) as
  ps = zip bs $ scanr1 (+) bs
  f _ []   = 0
  f k ps@((b,s):ps')
    | b>=k = f k ps'
    | s>=k = f (k-b) ps'
    | True = length ps

Measured memory_bytes: 2556
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    vector<vector<int>> c(3, vector<int>(3));
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    for(int i = 0; i <= 100; i++){
        vector<vector<int>> vc = c;
        vector<int> b(3);
        bool f = true;
        for(int ii = 0; ii < 3; ii++){
            if(vc[0][ii] - i < 0) {
                f = false;
                break;
            }
            vc[0][ii] -= i;
            b[ii] = vc[0][ii];
            //cout << "b " << b[ii] << endl;
        }
        if(!f) continue;
        for(int j = 0; j <= 100; j++){
            bool f2 = true;
            for(int ii = 0; ii < 3; ii++){
                //cout << c[1][ii] << " " << j << endl;
                if(vc[1][ii] - j != b[ii]) {
                    f2 = false;
                    break;
                }
                vc[1][ii] -= j;
            }
            if(!f2) continue;
            for(int k = 0; k <= 100; k++){
                bool f3 = true;
                for(int ii = 0; ii < 3; ii++){
                    if(vc[2][ii] - k != b[ii]) {
                        f3 = false;
                        break;
                    }
                    vc[2][ii] -= k;
                }
                if(!f3){
                    continue;
                } else {
                    //cout << i << " " << j << " " << k << endl;
                    cout << "Yes" << endl;
                    return 0;
                }
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include  <bits/stdc++.h>
using namespace std;
#define ll long long
int main ()
{
   ll a,b,c,s;
   cin>>a>>b;
   s=0;
   while (a>0)
{
   a-=b;
   s++;
}
 cout <<s <<endl;
return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
using namespace std;
int main()
{
    fastio;
    string str;
    cin>>str;
    long long i,a[str.size()],cnt=0,sum=0;
    for(i=0;i<str.size();i++)
    {
        if(str[i]=='B')
        {
            cnt++;
        }
        a[i]=cnt;
    }
    for(i=0;i<str.size();i++)
    {
        if(str[i]=='W')
        {
            sum=sum+a[i];
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 5292
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

H, W = map(int, raw_input().split())
N = input()
a = map(int, raw_input().split())

pos = 0
ans = [[0] * W for i in range(H)]
for i in range(H):
    R = range(W) if i % 2 else range(W - 1, -1, -1)
    ls = []
    for j in R:
        if a[pos] == 0:
            pos += 1
        a[pos] -= 1
        ans[i][j] = pos + 1

for ls in ans:
    print " ".join(map(str, ls))

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

int ans[365],c[26],s[365][26],last[26],csum,nowscore,newscore;
const int INF=1e9,d=365,starttemp=4000,endtemp=100;
double temperature,prob;

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

void FIN(bool a){
  if(a){
    ofstream fout("output.txt");
    REP(i,d)fout<<ans[i]+1<<"\n";
    fout.close();
    return;
  }
  REP(i,d)cout<<ans[i]+1<<"\n";
  return;
}
/*
int score(){
  int res=0;
  memset(last,-1,sizeof(last));
  REP(day,d){
    res+=s[day][ans[day]];
    last[ans[day]]=day;
    REP(i,26)res-=c[i]*(day-last[i]);
  }
  return res;
}
*/
int score(){//上のがO(26*365)、こっちがO(365)のスコア計算
  int res=0,minus=csum;
  memset(last,-1,sizeof(last));
  REP(day,d){
    res+=s[day][ans[day]];
    minus-=c[ans[day]]*(day-last[ans[day]]);
    last[ans[day]]=day;
    res-=minus;
    minus+=csum;
  }
  return res;
}
void swap(){
  int RAND=rand();
  int day=RAND%(d-8),diff=((RAND^newscore)&7)+1;
  swap(ans[day],ans[day+diff]);
  newscore=score();
  prob=exp((newscore-nowscore)/temperature);
  if(prob>(rand()%INF)/(double)INF)nowscore=newscore;
  else swap(ans[day],ans[day+diff]);
}
void onechange(){
  int day=rand()%365;
  REP(i,26){
    int tmp=ans[day];
    ans[day]=i;
    newscore=score();
    prob=exp((newscore-nowscore)/temperature);
    if(prob>(rand()%INF)/(double)INF)nowscore=newscore;
    else ans[day]=tmp;
  }
}

int main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  clock_t start=clock();
  memset(last,-1,sizeof(last));
  cin>>c[0];
  REP(i,26){cin>>c[i];csum+=c[i];}
  REP(i,d)REP(j,26)cin>>s[i][j];
  REP(day,d){
    int idx,mx=-INF;
    REP(i,26){
      int A=c[i]*(day-last[i])+s[day][i];
      if(mx<A)mx=A,idx=i;
    }
    ans[day]=idx,last[idx]=day;
  }
  nowscore=score();
  while(true){
    clock_t nowt=clock();
    const double Time=static_cast<double>(nowt-start)/CLOCKS_PER_SEC;
    if(Time>1.97)break;
    temperature=starttemp+(double)(endtemp-starttemp)*(nowt-start)/(CLOCKS_PER_SEC*1.97);
    REP(_,50)
      if((_^newscore)&1)swap();
      else onechange();
  }
  FIN(0);
}


Measured memory_bytes: 4300
import itertools

N=int(input())
p=list(map(str,input().split()))
q=list(map(str,input().split()))
P=''.join(p)
Q=''.join(q)

ns=list(itertools.permutations(range(1,N+1)))
Ns=[]
for i in range(len(ns)):
    temparr=[]
    for j in range(N):
        a=ns[i][j]
        temparr.append(str(a))
    b=''.join(temparr)
    Ns.append(b)

PO=Ns.index(P)
QO=Ns.index(Q)
print(abs(PO-QO))


Measured memory_bytes: 16736
#include<bits/stdc++.h>
#define N 1005
using namespace std;
typedef long long ll;
ll n,v,a[N],b[N],c[N],d[N];
vector<ll> X,Y;

int main(){
  cin>>n>>v;
  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];
  for(int i=0;i<n;i++)cin>>d[i];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      X.push_back(a[i]+b[j]);
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      Y.push_back(c[i]+d[j]);
  Y.push_back((1e17));
  sort(Y.begin(),Y.end());
  ll ans=0;
  for(int i=0;i<X.size();i++){
    vector<ll>::iterator x=upper_bound(Y.begin(),Y.end(),v-X[i]);
    vector<ll>::iterator y=lower_bound(Y.begin(),Y.end(),v-X[i]);
    ans+=x-y;
  }
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 23052
N, X = map(int, input().split())
L = list(map(int, input().split()))
D = [0 for i in range(N + 1)]
bounding = 0
for i in range(N):
    D[i + 1] = D[i] + L[i]

for d in D:
    if d <= X:
        bounding += 1

print(bounding)

Measured memory_bytes: 3060
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_9_A&lang=jp
  * String - Finding a Word
  */
object Main {
  def main(args: Array[String]): Unit = {
    val word = io.StdIn.readLine().toLowerCase
    val words = Iterator.continually(io.StdIn.readLine()).takeWhile(_ != null)
      .takeWhile(_ != "END_OF_TEXT")
      .flatMap(_.toLowerCase.split(" "))
    println(words.count(_ == word))
  }
}

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

#include <string>

#include <vector>
#include <list>
#include <map>

#include <algorithm>
#include <utility>

using namespace std;

int main(const int argc, const char **argv){
  int A, B, K;
  scanf("%d %d %d", &A, &B, &K);

  int count = 0;

  for(int i = 100; i > 0 ; i--){
    if(A % i == 0 && B % i == 0){
      count++;
      if(count == K){
        printf("%d", i);
        return 0;
      }
    }
  }

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String topCoder = sc.next();
        int result =0;
        for(int i=0;i<topCoder.length();i++){
            char atCoder;
            if(topCoder.charAt(i)=='p') {
                if (i % 2 == 0) {
                    atCoder = 'g';
                    result--;
                }
                else atCoder = 'p';
            }
            else{
                if (i % 2 == 0) {
                    atCoder = 'g';

                }
                else {
                    atCoder = 'p';
                    result++;
                }
            }
        }
        System.out.println(result);
    }

 }


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

int gcd(int a, int b) {

    int x, r;        
    if(b > a){
        x = a;
        a = b;
        b = x;
    }

    while(b != 0){
        r = a % b;
        a = r;
        r = b;
        b = a;
        a = r;
    }
    return a; 
}

int main(void){
    int a, b;
    while(cin >> a >> b) {
        int lcm = a / gcd(a,b) * b;
        cout << gcd(a,b) << " " << lcm << endl;
    }
    return 0;
}


Measured memory_bytes: 3080
#include<stdio.h>
int main(void)
{
    int a, b, c;

    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

    if(a>=0 && a<=100)
    {
        if(b>=0 && b<=100)
        {
            if(c>=0 && c<=100)
            {
                if(a<b && b<c)
                {
                printf("Yes\n");
                }
                else
                {
                printf("No\n");
                }
            }
        }
    }
    return 0;
}


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

class Program
{
    public static void Main()
    {

        var line = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int N = line[0];
        int L = line[1];

        List<int> list = new List<int>();

        for(int i = 1; i <= N; i++)
        {
            list.Add(L + i - 1);
        }

        int m = 0;

        foreach (var l in list)
        {
            m = m + l;
        }


        if (L > 0)
        {
            Console.WriteLine(m - list[0]);
        }
        else if (L + N > 0)
        {
            Console.WriteLine(m);
        }
        else if (L + N <= 0)
        {
            Console.WriteLine(m - list[list.Count() - 1]);
        }


    }
}

Measured memory_bytes: 13396
N, M = map(int, input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
                
    return divisors

if N==1:
    print(M)

else:
    div = sorted(make_divisors(M))
    i = 0 
    while i<=len(div) and M//div[i]>=N:
        ans = div[i]
        i+=1
    print(ans)

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

int r,D,x;
void Weight(){
    cin >> r >> D >> x;
    int weight=x;
    for(int i=1;i<=10;i++){
        cout << r*x-D << endl;
        x=r*x-D;
    }
}

int main(){
    Weight();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <deque>
#include <numeric>
#include <utility>
using namespace std;

const string YES = "POSSIBLE";
const string NO = "IMPOSSIBLE";

void solve(long long N, long long M, std::vector<long long> a, std::vector<long long> b){
    vector<vector<long long>> edges(N);
    for(int i=0; i<M; i++){
        edges[a[i]-1].push_back(b[i]-1);
        edges[b[i]-1].push_back(a[i]-1);
    }
    deque<pair<long long, int>> q={make_pair(0, 0)};
    vector<int> visited(N, 0);
    while(!q.empty()){
        auto p=q.front();
        q.pop_front();
        auto i=p.first;
        auto cnt=p.second;
        visited[i]++;
        if(cnt>=2)continue;
        for(auto dist: edges[i]){
            if(!visited[dist])q.push_back(make_pair(dist, cnt+1));
        }
    }
    cout << (visited[N-1]>0 ? YES : NO) << endl;
}

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


Measured memory_bytes: 18280
#include <bits/stdc++.h>
 
using namespace std;
 
template <class T>inline T updmax(T& a, T b) {return a = max(a, b);}
template <class T>inline T updmin(T& a, T b) {return a = min(a, b);}
 
class Solution {
public:
	void solve() {
		int n,m;
		cin >> n >> m;
		vector<long long> h(n+1, 0);
		for(int i=0; i<n; i++)cin >> h[i+1];
		n++;
		h[0] = 0;
		vector<vector<vector<long long>>> dp(n+1, vector<vector<long long >>(m+1, vector<long long >(n+1, 0x3f3f3f3f3f3f3f3f)));
		dp[0][0][0] = 0;
		for(int i=0; i < n; i++){
			for(int j=0; j <= min(i, m); j++){
				for(int k=0; k <= i; k++){
					if(dp[i][j][k] < 0x3f3f3f3f3f3f3f3f){
						//変える
						if(j !=m )updmin(dp[i+1][j+1][k], dp[i][j][k]);
						//変えない
						updmin(dp[i+1][j][i+1], dp[i][j][k] + max(h[i+1]-h[k], 0LL));
					}
				}
			}
		}
		long long ans = 0x7f7f7f7f7f7f7f7f; 
		for(int j = 0; j <= m; j++){
			for(int k=0; k <= n; k++){
				updmin(ans, dp[n-1][j][k]);
			}
		}
		cout << ans << "\n";
		
		return;
	};
};
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	Solution solution;
	solution.solve();
	return 0;
}

Measured memory_bytes: 219008