akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const int N = 105;

int n, m, ex, ey;
char s[N][N], a[N][N];
short ans, dp[N][N][N][N], sum[N][N];

int Sum(int U, int L, int D, int R) {
	if (U > D) swap(U, D);
	if (L > R) swap(L, R);
	return sum[D][R] + sum[U - 1][L - 1] - sum[D][L - 1] - sum[U - 1][R];
}

void Upd(short &x, short y) {
	x = max(x, y);
}

int main() {
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) {
		scanf("%s", s[i] + 1);
		for (int j = 1; j <= m; ++j) {
			if (s[i][j] == 'E') {
				ex = i;
				ey = j;
			}
			if (s[i][j] == 'o') sum[i][j] = 1;
			sum[i][j] -= sum[i - 1][j - 1];
			sum[i][j] += sum[i][j - 1] + sum[i - 1][j];
		}
	}
/*	for (short a = ex; a >= 1; --a) {
		for (short c = ey; c >= 1; --c) {
			for (short b = ex; b <= n; ++b) {
				for (short d = ey; d <= m; ++d) {
					short U = b - ex + 1, D = n - ex + a;
					short L = d - ey + 1, R = m - ey + c;
					short now = dp[a][b][c][d];
					Upd(ans, now);
					if (a > U)
						Upd(dp[a - 1][b][c][d], now + Sum(a - 1, max(L, b), a - 1, min(R, d)));
					if (b < D)
						Upd(dp[a][b + 1][c][d], now + Sum(b + 1, max(L, b), b + 1, min(R, d)));
					if (c > L)
						Upd(dp[a][b][c - 1][d], now + Sum(max(U, a), c - 1, min(D, b), c - 1));
					if (d < R)
						Upd(dp[a][b][c][d + 1], now + Sum(max(U, a), d + 1, min(D, b), d + 1));
				}
				}
				}
				}*/
	int x = ex, y = ey;
	#define upd Upd
	#define S Sum
	for(int a=x;a;a--)
		for(int b=y;b;b--)
			for(int c=x;c<=n;c++)
				for(int d=y;d<=m;d++)
					{
						ans=max(ans,dp[a][b][c][d]);int L=d-y+1,R=m-y+b,U=c-x+1,D=n-x+a;
						if(a>U) upd(dp[a-1][b][c][d],dp[a][b][c][d]+S(a-1,max(b,L),a-1,min(d,R)));
						if(b>L) upd(dp[a][b-1][c][d],dp[a][b][c][d]+S(max(a,U),b-1,min(c,D),b-1));
						if(c<D) upd(dp[a][b][c+1][d],dp[a][b][c][d]+S(c+1,max(b,L),c+1,min(d,R)));
						if(d<R) upd(dp[a][b][c][d+1],dp[a][b][c][d]+S(max(a,U),d+1,min(c,D),d+1));
					}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 227584
require 'date'

while true
  y1, m1, d1, y2, m2, d2 = gets.strip.split(' ').map(&:to_i)
  if y1 == -1; break; end
  day1 = Date.new(y1, m1, d1)
  day2 = Date.new(y2, m2, d2)
  diff = 0
  while day1 != day2
    day1 += 1
    diff += 1
  end
  p diff
end

Measured memory_bytes: 6372
class PriorityQueue:
    def __init__(self,priority):
        self.__queue=[]
        self.__priority=priority
    def __getvalue(self,i):
        return self.__queue[i-1]
    def __changevalue(self,node1,value1):
        self.__queue[node1-1]=value1
    def __swapvalue(self,node1,node2):
        t=self.__getvalue(node1)
        self.__changevalue(node1,self.__getvalue(node2))
        self.__changevalue(node2,t)
    def __cmp(self,node1,node2):
        return self.__priority(self.__getvalue(node1),self.__getvalue(node2))
    def __update_down(self,node):
        l=node<<1
        r=(node<<1)+1
        largest=node
        if l<=self.getlen() and self.__cmp(l,node)==True:
            largest=l
        if r<=self.getlen() and self.__cmp(r,largest)==True:
            largest=r
        if largest!=node:
            self.__swapvalue(node,largest)
            self.__update_down(largest)
    def __update_up(self,node):
        father=node>>1
        if father<1:
            return 
        if self.__cmp(node,father):
            self.__swapvalue(node,father)
            self.__update_up(father)
    #def show(self):
    #    print(self.__queue)
    def getlen(self):
        return len(self.__queue)
    def empty(self):
        if self.getlen()==0:
            return True
        else:
            return False
    def top(self):
        return self.__queue[0]
    def push(self,value):
        self.__queue.append(value)
        self.__update_up(self.getlen())
    def pop(self):
        self.__swapvalue(1,self.getlen())
        self.__queue.pop()
        self.__update_down(1)

class compare:
    greater=lambda x,y: x>y
    less=lambda x,y: x<y

n,k=input("").split()
n,k=int(n),int(k)
l=input("").split()
l=list(map(int,l))
pq=PriorityQueue(compare.greater)
for i in l:
    pq.push(i)
sum=0
while k>0:
    sum=sum+pq.top()
    pq.pop()
    k=k-1
print(sum)

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


#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1e9 + 7ll;
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; }
const ll inf = 1ll << 60;

int n, q;
vector<vector<int>> tree(202020);
vector<int> parent(202020);
vector<ll> counter(202020);
vector<ll> add(202020);

int main() {
    ll n;
    cin >> n;
    cout << n * (n-1) / 2 << endl;
    return 0;
}





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

int lcd(int a, int b) {
  if (a < b) {
    swap(a, b);
  }
  if (b == 0) {
    return a;
  } else {
    return lcd(b, a % b);
  }
}

vector<int> O;

int b_search(int s, int e, int t) {
  int m = e / 2;
  if (O[m] == t) {
    return m;
  } else if (t < O[m]) {
    return b_search(s, m, t);
  } else {
    return b_search(m, e, t);
  }
}

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> M(N);
  int min_m = 10001;
  for (int i = 0; i < N; ++i) {
    cin >> M.at(i);
    X -= M.at(i);
    min_m = min(min_m, M.at(i));
  }
  int result = N + X / min_m;
  cout << result << endl;
}

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

int main() {
  int a, b, c; cin >> a >> b >> c;
  bool exist = false;
  for (int i = 0; i < b; i++) {
    if (a * i % b == c) exist = true;
  }
  if (exist) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int a = sc.nextInt();
    int b = sc.nextInt();
    if (b>=a) {
	    System.out.println(0);
    } else {
      System.out.println(a-b);
    }
  }
}


Measured memory_bytes: 21460
#include<stdio.h>
#include<string.h>
int main(){
  char s[200001];
  int i;
  scanf("%s",s);
  int len=strlen(s),num;
  for(i=0;i<len;i++){
    if(s[i]=='A'){
      num=i;
      break;
    }
  }
  for(i=len-1;i>=0;i--){
    if(s[i]=='Z'){
      num=i-num+1;
      break;
    }
  }
  printf("%d\n",num);
  return 0;
}


Measured memory_bytes: 1804
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>


using namespace std;

int main(){
  string s,t;
  cin >> s >> t;
  int ssize = s.size();
  int tsize = t.size();
  pair<int,pair<int,int>> dp[ssize+1][tsize+1];
  for(int i = 0 ; i <ssize+1; i++){
     for(int j = 0 ; j <tsize+1; j++){
         dp[i][j] = make_pair(0, make_pair(-1,-1));
     }
  }
  for(int i = 0 ; i < ssize; i++){
     for(int j = 0 ; j < tsize; j++){
        dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        if(s[i] == t[j]){
           dp[i+1][j+1] = max(dp[i+1][j+1], make_pair(dp[i][j].first+1, make_pair(i,j)));
        }
     }
  }
  string ans = "";
  int x= ssize; int y =tsize;
  while(dp[x][y].second.first !=-1){
     //cout << x << ", "<< y <<": " << dp[x][y].second.first << ", "<< dp[x][y].second.second<<endl;
     ans = s[dp[x][y].second.first] + ans;
     int tmpx = dp[x][y].second.first;
     int tmpy = dp[x][y].second.second;
     x = tmpx;
     y = tmpy;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 105856
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <string>
#include <set>
#include <bitset>
#include <unordered_map>
#include <cmath>

using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
template <class T>
using Vvec = vector<vector<T> >;

template <class T>
void debug(T& v)
{
    for(auto& x: v) cout << x << " ";
    cout << endl;
}

int main()
{
    ll N, K;
    cin >> N >> K;
    vector<ll> s(N+1);
    for(int i=0; i<N; i++){
        ll tmp;
        cin >> tmp;
        s[i+1] = s[i] + tmp;
    }

    vector<ll> a(N*(N+1)/2);
    int k = 0;
    for(int i=0; i<N; i++){
        for(int j=i+1; j<=N; j++){
            a[k] = s[j] - s[i];
            k++;
        }
    }
    sort(a.begin(), a.end());

    ll l = 1;
    while(l < a.back()) l <<= 1;

    ll ans = 0;
    while(l > 0){
        l >>= 1;
        auto itr = lower_bound(a.begin(), a.end(), l);
        if(distance(itr, a.end()) >= K){
            ans += l;
            for(auto& x: a){
                x = max((ll)0, x-l);
            }
        }
        else{
            for(auto& x: a){
                if(x >= l) x -= l;
            }
        }
        sort(a.begin(), a.end());
    }

    cout << ans << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#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 Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define pb push_back
#define eb emplace_back

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    else return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int h,n;
    cin >> h >> n;
    vector<int> a(n),b(n);
    rep(i,n) cin >> a[i] >> b[i];
    vector<int> dp(h+1,INF);
    dp[0] = 0;
    rep(i,n){
        rep(j,h){
            chmin(dp[min(h,j+a[i])],dp[j]+b[i]);
        }
    }
    cout << dp[h] << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
 #define PI 3.14159265359

using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
  int64_t N,M;
  cin>>N>>M;
  if((M-2*N)%2==0 && M-2*N>=0 && 4*N-M>=0 && (4*N-M)%2==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  //vector<int64_t> A(N);
  //for(int i=0; i<N; i++){cin>>A[i];}
  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
 // cout << N << endl;
}

Measured memory_bytes: 3632
#include <cmath>
#include <queue>
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
using namespace std;

typedef pair<int, int> pii;

const int maxn = 105;
const int inf = 1e9;
const double eps = 1e-12;

int n, s, t, flag[maxn];

vector<pii> mp[maxn];
void add_edge(int u, int v, int d){
	mp[u].push_back(make_pair(v, d));
	mp[v].push_back(make_pair(u, d));
}

double eq[maxn][maxn];
double gauss(){
	
	for(int i = 1; i <= n; ++i){
		int tmp = i;
		for(int j = i; j <= n; ++j) if(fabs(eq[j][i]) > fabs(eq[tmp][i])) tmp = j;
		for(int j = i; j <= n; ++j) swap(eq[i][j], eq[tmp][j]); swap(eq[i][0], eq[tmp][0]);
		
		for(int j = i + 1; j <= n; ++j){
			double tt = eq[j][i] / eq[i][i];
			for(int k = i; k <= n; ++k) eq[j][k] -= eq[i][k] * tt;
			eq[j][0] -= eq[i][0] * tt;
		}
	}
	for(int i = n; i >= 1; --i){
		for(int j = i + 1; j <= n; ++j) eq[i][0] -= eq[i][j] * eq[j][0];
		eq[i][0] /= eq[i][i];
	}
	return eq[s][0];
}

queue<int> que;
int dist[maxn];
bool inq[maxn];
void spfa(){
	
	for(int i = 1; i <= n; ++i) dist[i] = inf;
	dist[t] = 0;
	que.push(t);
	while(!que.empty()){
		int u = que.front();
		inq[u] = false;
		que.pop();
		for(int l = 0; l < mp[u].size(); ++l){
			int v = mp[u][l].first;
			if(dist[v] <= dist[u] + mp[u][l].second) continue;
			dist[v] = dist[u] + mp[u][l].second;
			if(!inq[v]){
				inq[v] = true;
				que.push(v);
			}
		}
	}
}

void work(){
	
	for(int i = 1; i <= n; ++i) mp[i].clear();
	for(int i = 1; i <= n; ++i) for(int j = 0; j <= n; ++j) eq[i][j] = 0.00;
	for(int i = 1; i <= n; ++i) scanf("%d", &flag[i]);
	for(int i = 1; i <= n; ++i) for(int j = 1; j <= n; ++j){
		int d; scanf("%d", &d);
		if(i < j || d == 0) continue;
		add_edge(i, j, d);
	}
	spfa();
	if(dist[s] == inf){
		puts("impossible");
		return;
	}
	for(int u = 1; u <= n; ++u){
		if(u == t){
			eq[u][u] = 1.00;
			continue;
		}
		for(int l = 0; l < mp[u].size(); ++l){
			int v = mp[u][l].first;
			if(flag[u] && dist[u] != dist[v] + mp[u][l].second) continue;
			eq[u][v] += 1.00;
			eq[u][0] -= 1.00 * mp[u][l].second;
			eq[u][u] -= 1.00;
		}
	}
	printf("%.10f\n", gauss() + eps);
}

int main(){

	while(true){
		scanf("%d%d%d", &n, &s, &t);
		if(n + s + t == 0) break;
		work();
	}
	return 0;
}

Measured memory_bytes: 3336
//Be Name Khoda
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const int MOD = (int)1e9 + 7;
const int MAXN = (int)1e6 + 7;
bool dp[MAXN];
bool erase(string s, int i)
{
	if(i + 5 > s.size())
		return false;
	if(s[i] == 'e' and s[i + 1] == 'r' and s[i + 2] == 'a' and s[i + 3] == 's' and s[i + 4] == 'e')
		return true;
	return false;
}
bool eraser(string s, int i)
{
	if(i + 6 > s.size())
		return false;
	if(s[i] == 'e' and s[i + 1] == 'r' and s[i + 2] == 'a' and s[i + 3] == 's' and s[i + 4] == 'e' and s[i + 5] == 'r')
		return true;
	return false;
}
bool dream(string s, int i)
{
	if(i + 5 > s.size())
		return false;
	if(s[i] == 'd' and s[i + 1] == 'r' and s[i + 2] == 'e' and s[i + 3] == 'a' and s[i + 4] == 'm')
		return true;
	return false;
}
bool dreamer(string s, int i)
{
	if(i + 7 > s.size())
		return false;
	if(s[i] == 'd' and s[i + 1] == 'r' and s[i + 2] == 'e' and s[i + 3] == 'a' and s[i + 4] == 'm' and s[i + 5] == 'e' and s[i + 6] == 'r')
		return true;
	return false;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	for (int i = s.size() - 1; i >= 0; i--)
	{
		if(erase(s, i) and (i + 5 == s.size() or dp[i + 5]))
			dp[i] = 1;
		else
		if(eraser(s, i) and (i + 6 == s.size() or dp[i + 6]))
			dp[i] = 1;
		else
		if(dream(s, i) and (i + 5 == s.size() or dp[i + 5]))
			dp[i] = 1;
		else
		if(dreamer(s, i) and (i + 7 == s.size() or dp[i + 7]))
			dp[i] = 1;
	}
	if(dp[0])
		cout << "YES";
	else
		cout << "NO";
}

Measured memory_bytes: 720
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b&&b!=c){
    cout<<"Yes";
  }
  else if(a==c&&a!=b){
    cout<<"Yes";
  }
  else if(b==c&&a!=b){
    cout<<"Yes";
  }
  else if(1){
    cout<<"No";
  }
}


Measured memory_bytes: 256
<?php
$mem = [];
$ans = 0;
$S = [1, 3, 6];
fscanf(STDIN, "%d", $K);
for ($i = 1; $i <= $K; $i++) {
    for ($j = $i; $j <= $K; $j++) {
        for ($k = $j; $k <= $K; $k++) {
            $Q = 2;
            if ($i === $j) {
                $Q--;
            }
            if ($j === $k) {
                $Q--;
            }
            $x = gcd($i, $j);
            if ($x === 1) {
                $ans += 1 * $S[$Q];
            } else {
                $y = gcd($x, $k);
                $ans += $y * $S[$Q];
            }
        }
    }
}
printf("%d", $ans);

//最大公約数
function gcd($m, $n){
    global $mem;

    if($n > $m) list($m, $n) = array($n, $m);
    $mm = $m;
    $nn = $n;

    if (isset($mem[$mm][$nn])) {
        return $mem[$mm][$nn];
    }

    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    $mem[$mm][$nn] = $m;
    return $m;
}
 
//最小公倍数
function lcm($m, $n){
    return $m * $n / gcd($m, $n);
}

Measured memory_bytes: 17556
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=998244353;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
    int x;
    cin>>x;
    int ma=INT_MAX;
    int n;
    cin>>n;
    set<int> s;
    for(int i=-1;i<=101;i++)s.insert(i);
    for(int i=0;i<n;i++){
        int p;cin>>p;
        s.erase(p);
    }
    auto ite=s.lower_bound(x);
    int d=*ite;
    ite--;
    int e=*ite;
    if(abs(d-x)<abs(e-x))cout<<d<<"\n";
    else cout<<e<<"\n";
}

Measured memory_bytes: 3656
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define PP pair<int, int>
int N, M, Q;
int R[200010];
int D[100010];
int res[100010];
vector<PP> G[100010];

struct node {
	int cost, now, year;
	bool operator<(const node &n1) const {
		return cost > n1.cost;
	}
};

class BIT {
public:
	int n;
	vector<int> bit;
	BIT() {
		bit.resize(200010);
	}
	int sum(int i) {
		int s = 0;
		while (i > 0) {
			s += bit[i];
			i -= i & -i;
		}
		return s;
	}

	void add(int i, int x) {
		while (i <= n) {
			bit[i] += x;
			i += i & -i;
		}
	}
};

void solve() {
	priority_queue<node> pq;
	pq.push(node{ 0, 1, 1 << 30 });
	while (!pq.empty()) {
		node n = pq.top();
		pq.pop();
		if (D[n.now] < n.cost) continue;
		if (res[n.now] < n.year) continue;
		int co = n.cost + 1;
		for (auto &u : G[n.now]) {
			if (co < D[u.first]) {
				D[u.first] = co;
				res[u.first] = min(res[n.now], R[u.second]);
				pq.push(node{ D[u.first], u.first, res[u.first] });
			}
			else if (co == D[u.first]) {
				if (res[u.first] < min(res[n.now], R[u.second])) {
					res[u.first] = min(res[n.now], R[u.second]);
					pq.push(node{ D[u.first], u.first, res[u.first] });
				}
			}
		}
	}
	BIT bit1;
	bit1.n = Q;
	for (int i = 2; i <= N; i++) {
		if (res[i] != 1 << 30) {
			bit1.add(res[i], 1);
		}
	}
	for (int i = 1; i <= Q; i++) {
		cout << bit1.sum(i) << endl;
	}
}


void IN() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N >> M >> Q;
	for (int i = 1; i <= M; i++) {
		R[i] = 1 << 30;
		int to, from;
		cin >> to >> from;
		G[to].push_back({ from, i });
		G[from].push_back({ to, i });
	}
	for (int i = 1; i <= N; i++) {
		res[i] = 1 << 30;
		D[i] = 1 << 30;
	}
	for (int i = 1; i <= Q; i++) {
		int tmp;
		cin >> tmp;
		R[tmp] = i;
	}
}

int main() {
	IN();
	solve();
	return 0;
}


Measured memory_bytes: 14428
#include <bits/stdc++.h>
#define de(x) cout << #x << "=" << x << ", "
#define dd cout << '\n';
#define XinAi ios::sync_with_stdio(0), cin.tie(0);
#define F first
#define S second
#define int long long
using namespace std;
typedef pair<int,int> pii;

int a, b;

signed main()
{
    cin >> a >> b;
    cout << a*(a-1)/2 + b*(b-1)/2 << '\n';
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>a(N);
	int MAX = 0;
	int MIN = 9999999;

	for (int i = 0; i < N; i++) {
		cin >> a[i];
		MAX = max(MAX, a[i]);
		MIN = min(MIN, a[i]);
	}

	cout << MAX - MIN << endl;

	return 0;
}

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

using namespace std;
const int MAX=1e5;
vector<pair<int,int> >v;
long long n,w;
long long dp[101][MAX+3],sol;

long long solve(int ind,int left){
if(left<0) return 1e17;
if(left==0) return 0;
if(ind==n) return 1e17;
if(dp[ind][left]!=-1) return dp[ind][left];
long long ans=1e17;
ans=min(ans,solve(ind+1,left-v[ind].second)+v[ind].first);
ans=min(ans,solve(ind+1,left));
return dp[ind][left]=ans;
}

int main()
{
    cin>>n>>w;
    v.resize(n);
    for(int i=0;i<n;i++) cin>>v[i].first>>v[i].second;
    memset(dp,-1,sizeof(dp));
    int st=MAX;
    long long x = solve(0,st);
    while(x==-1 || x>w){
        st--;
        x=solve(0,st);
    }
    cout<<st;
    return 0;
}


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

using namespace std;

// abc151E - Max-Min Sums

const int cap = 1e5 + 1;
const int mod = 1e9 + 7;
int N, K, A[cap], F[cap];

int mod_inv(int64_t a, int64_t m) {
    int64_t m0 = m; 
    int64_t y = 0, x = 1; 
  
    if (m == 1) 
      return 0; 
  
    while (a > 1) 
    { 
        // q is quotient 
        int64_t q = a / m; 
        int64_t t = m; 
  
        // m is remainder now, process same as 
        // Euclid's algo 
        m = a % m, a = t; 
        t = y; 
  
        // Update y and x 
        y = x - q * y; 
        x = t; 
    } 
  
    // Make x positive 
    if (x < 0) 
       x += m0; 
  
    return x; 
}

int mod_div(int y, int z) {
    return (mod_inv(y, mod) * int64_t(z)) % mod;
}

int comb(int x) {
    return K == 2 ? 1 : mod_div(F[K - 2], mod_div(F[x - K + 2], F[x]));
}

int main() {
    scanf("%d %d", &N, &K);
    for (int i = 1; i <= N; ++i)
        scanf(" %d", &A[i]);
    if (K == 1) {
        printf("0\n");
        return 0;
    }

    sort(A + 1, A + N + 1);
    
    F[0] = 1;
    int64_t p = 1;
    for (int i = 1; i < N; ++i) {
        p = (p * i) % mod;
        F[i] = int(p);
    }

    int ans = 0;
    for (int64_t i = K, cnt = 0; i <= N; ++i) {
        cnt = (cnt + comb(i - 2)) % mod;
        ans = (ans + cnt * A[i]) % mod;
    }

    for (int64_t i = N - K + 1, cnt = 0; i > 0; --i) {
        cnt = (cnt + comb(N - i - 1)) % mod;
        ans = (ans - cnt * A[i]) % mod;
    }

    ans += (ans < 0) * mod;
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys

N=input()
T=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

if max(T)!=max(A):
    print 0
    quit()

L=[ None for _ in range(N) ]

#一意に決まる山の高さを配列に代入。配列にNoneで残っているところが山の高さが一意に決まらない箇所
#左から
for i,t in enumerate(T):
    if i==0:
        L[i]=t
    else:
        if prev_t<t:
            L[i]=t
        elif prev_t>t:
            print 0
            quit()
    prev_t=t


#右から
for i,a in enumerate(A[::-1]):
    i=N-i-1 #左から見た順のインデックスに置き換える
    if i==N-1:
        L[i]=a
    else:
        if prev_a<a:
            if L[i] is not None:    #山の高さが既に入っているときは
                if L[i]!=a: #同じ高さじゃないと矛盾があるので、その場合はゼロで終了
                    print 0
                    quit()
            L[i]=a  #それ以外の場合は山の高さを配列に代入
        elif prev_a>a:
            print 0
            quit()
    prev_a=a

#一意に決まる値を入れたLを左から再検査。最大値が配列Aと矛盾していないか
max_x=0
for x,t in zip(L,T):
    #print x,t
    if x is not None:
        max_x=max(max_x,x)
        if max_x!=t:
            print 0
            quit()

#Lを右から再検査
max_x=0
for x,a in zip(L[::-1],A[::-1]):
    if x is not None:
        max_x=max(max_x,x)
        if max_x!=a:
            print 0
            quit()


ans=1
mod=10**9+7
for x,a,t in zip(L,T,A):
    if x is None:   #山の高さがNoneになっている箇所は自由度がある所なので、aとtの最小値の通り数を答えにかける
        ans*=min(a,t)
        ans%=mod
print ans


Measured memory_bytes: 63772
#include <bits/stdc++.h>
using namespace std;
int main () {
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  int n, total, end, start, both,y;
  total = end = start = both = 0;
  cin >> n;
  for (int x = 0; x < n; x++) {
    string s;
    cin >> s;
    for (y = 0; y < s.length()-1; y++) if (s.substr(y,2) == "AB") total++;
    if (s[0] == 'B') {
      if (s[y] == 'A') {
        both++;
      }
      start++;
    }
    if (s[y] == 'A') end++;
  }
  if (start == both && end == both && both) total--;
  cout << total+min(end,start) << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define BUF_SIZE 512
int map[256] = {
  ['o'] = 1,
  ['x'] = 0,
};
int main(void) {
  FILE* fp;
  fp = stdin;
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, fp)) return 0;
  int toppings = 3, i;
  int res = 700;
  for(i = 0; i < toppings; i++) {
    res += map[line[i]] * 100;
  }
  printf("%d\n", res);

  return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [0] + list(map(int, input().split()))

# 各山に降った雨の量
X = [0] * (N + 1)

# まずx[1]を求める
# X[1] + ... + X[N] = A[1] + ... + A[N]
# X[2]+X[3] = 2*A[2], X[4]+X[5] = 2*A[4], ...より、
# X[1] = A[1] - A[2] + A[3] - ... + A[N]

tmp = 0
for i in range(1, N + 1):
    if i % 2 == 1:
        tmp += A[i]
    else:
        tmp -= A[i]
X[1] = tmp

# x[2],x[3],...,x[N]を漸化式から求める
for i in range(2, N + 1):
    X[i] = 2 * A[i - 1] - X[i - 1]
print(*X[1:])


Measured memory_bytes: 84872
// g++ -std=c++11 test.cpp && ./a.out
// g++ -std=c++11 bfs.cpp && cat bfs.txt | ./a.out

#include <algorithm>
#include <iostream>
#include <queue>
#include <functional>
#include <numeric>
#include <math.h>

using namespace std;

#define PRINT(A) {for (int i = 0; i < A.size(); i++) { cout << A[i] << " ";} cout << endl;}
#define SUM(A) accumulate(A.begin(), A.end(), 0)
#define MAX(A) *max_element(A.begin(), A.end())
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;


int main() {
    int N, D;
    cin >> N >> D;
    VVI points;
    int ans = 0;
    REP(i, N) {
        int x, y;
        cin >> x >> y;
        if (sqrt(pow(x,2) + pow(y,2)) <= D) {
            ans += 1; 
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

s = 0
n.times{|i| s += a[i]}

min = 4 * 1e+9
x = 0
(n - 1).times do |i|
  x += a[i]
  y = s - x
  min = [min, (x - y).abs].min
end

puts min.to_s

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

int main(){
    int N; cin>>N;
    map<string,ll> mp;
    for (int i = 0; i < N; i++){
        string S; cin>>S;
        mp[S]++;
    }
    for(ll i=0;i<4;i++){
        if(i==0){
            cout<<"AC x "<<mp["AC"]<<endl;
        }else if(i==1){
            cout<<"WA x "<<mp["WA"]<<endl;
        }else if(i==2){
            cout<<"TLE x "<<mp["TLE"]<<endl;
        }else{
            cout<<"RE x "<<mp["RE"]<<endl;
        }
    }
}

Measured memory_bytes: 3616
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

m = 0
before = -1
for i in range(N):
    dish = A[i]-1
    m += B[dish]
    if before == A[i]-1:
        m += C[before-1]

    before = A[i]

print(m)


Measured memory_bytes: 3064
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

struct Info{
	Info(int arg_value,int arg_watch_id){
		value = arg_value;
		watch_id = arg_watch_id;
	}
	bool operator<(const struct Info &arg) const{
		return value < arg.value;
	};

	int value,watch_id;
};

int calc(int hour,int minute,int second){
	return 3600*hour+60*minute+second;
}

int N;

void func(){

	int a,b,c,hour,minute,second,tmp_hour,tmp_minute,tmp_second;

	vector<Info> V;

	for(int loop = 0; loop < N; loop++){
		scanf("%d %d %d",&a,&b,&c);

		for(int i = 0; i < 6; i++){

			switch(i){
			case 0: //H:M:S
				hour = a;
				minute = b;
				second = c;
				break;
			case 1: //H:S:M
				hour = a;
				minute = c;
				second = b;
				break;
			case 2: //M:H:S
				hour = b;
				minute = a;
				second = c;
				break;
			case 3: //M:S:H
				hour = c;
				minute = a;
				second = b;
				break;
			case 4: //S:H:M
				hour = b;
				minute = c;
				second = a;
				break;
			case 5: //S:M:H
				hour = c;
				minute = b;
				second = a;
				break;
			}

			for(int diff = 0; diff <= 59; diff++){
				tmp_hour = (hour+diff)%60;
				tmp_minute = (minute+diff)%60;
				tmp_second =  (second+diff)%60;

				if(tmp_hour%5 != tmp_minute/12)continue;
				tmp_hour /= 5;
				V.push_back(Info(calc(tmp_hour,tmp_minute,tmp_second),loop));
			}
		}
	}

	sort(V.begin(),V.end());

	bool check[10],FLG;

	int minimum = BIG_NUM,ans_left,ans_right;

	for(int left = 0; left < V.size(); left++){
		for(int right = left; right < V.size();right++){
			for(int i = 0; i < N; i++)check[i] = false;
			for(int i = left; i <= right; i++)check[V[i].watch_id] = true;

			FLG = true;
			for(int i = 0; i < N; i++){
				if(!check[i]){
					FLG = false;
					break;
				}
			}

			if(FLG){
				if(minimum > V[right].value-V[left].value){
					minimum = V[right].value-V[left].value;
					ans_right = V[right].value;
					ans_left = V[left].value;
				}else if(minimum == V[right].value-V[left].value){
					if(ans_left > V[left].value){
						ans_right = V[right].value;
						ans_left = V[left].value;
					}
				}
			}
		}
	}

	printf("%02d:%02d:%02d %02d:%02d:%02d\n",ans_left/3600,(ans_left%3600)/60,(ans_left%3600)%60,ans_right/3600,(ans_right%3600)/60,(ans_right%3600)%60);
}

int main(){

	while(true){
		scanf("%d",&N);
		if(N == 0)break;

		func();
	}

	return 0;
}

Measured memory_bytes: 3148
N = int(input())
P = [float(a) for a in input().split()]

pre = []
post = [1]

for i in range(N):
    pre = post
    post = [0] * (i+2)
    for j in range(i+2):
        if j > 0:
            post[j] += pre[j-1] * P[i]
        if j <= i:
            post[j] += pre[j] * (1-P[i])

print(sum(post[N//2+1:]))

Measured memory_bytes: 44124
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vl = vector<long>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvb = vector<vector<bool>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
using pll = pair<long, long>;
#define fix20 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define MOD 1000000007
#define all(vec) vec.begin(), vec.end()

int main(){
    int n,m;
    cin >> n >> m;
    if(n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef double db;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

#define N 200010
int n;
vector<int> A[N];
int d[N];

void ff(int r) {
	queue<int> q;
	memset(d, -1, sizeof d);
	d[r] = 0;
	q.push(r);
	while (!q.empty()) {
		int x = q.front(); q.pop();
		for (auto i : A[x])
			if (d[i] == -1) {
				d[i] = d[x]+1;
				q.push(i);
			}
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for (int i = 1; i < n; i ++) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		A[x].pb(y); A[y].pb(x);
	}
	ff(0);
	int r = 0;
	for (int i = 0; i < n; i ++)
		if (d[i] > d[r]) r = i;
	ff(r);
	int S = 0;
	for (int i = 0; i < n; i ++)
		S = max(S, d[i]);
	if (S%3 == 1) puts ("Second"); else puts ("First");
	return 0;
}


Measured memory_bytes: 13556
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	if s[0] == s[1] {
		fmt.Println("Bad")
		return
	}
	if s[1] == s[2] {
		fmt.Println("Bad")
		return
	}
	if s[2] == s[3] {
		fmt.Println("Bad")
		return
	}
	fmt.Println("Good")
}


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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    int N, H;
    cin >> N >> H;
    VLL a(N), b(N);
    LL max_a = 0;

    REP(i, N) {
        cin >> a[i] >> b[i];
        max_a = max(max_a, a[i]);
    }

    sort(ALL(b));
    LL now_dmg = 0;
    int ans = 0;

    RREP(i, N-1) {
        if(b[i] < max_a) break;
        ans++;
        now_dmg += b[i];
        if(H <= now_dmg) break;
    }

    if(H <= now_dmg) {
        cout << ans << endl;
        return 0;
    }

    H -= now_dmg;
    ans += (H + (max_a - 1)) / max_a;
    cout << ans << endl;
}

Measured memory_bytes: 1792
N, X = map(int, input().split())

a = [1]  # 厚さ
p = [1]  # パティの数
for i in range(N):
    a.append(2*a[-1] + 3)
    p.append(2*p[-1] + 1)


def f(n: int, x: int) -> int:
    """レベルnバーガーの下からx枚のパティの数
    """
    if x == 1:
        return 0 if n > 0 else 1
    elif x <= 1+a[n-1]:
        return f(n-1, x-1)
    elif x == 2 + a[n-1]:
        return p[n-1] + 1
    elif x <= 2*a[n-1] + 2:
        return p[n-1] + 1 + f(n-1, x - (2+a[n-1]))
    elif x == 2*a[n-1] + 3:
        return p[n]
    else:
        raise ValueError("xがレベルnバーガーの厚さより大きい, x={}, n={}".format(x, n))


if __name__ == "__main__":
    ans = f(N, X)
    print(ans)


Measured memory_bytes: 3064
#pragma GCC optimize ("-O3")
    #include <bits/stdc++.h>  
     
    using namespace std;
     
    typedef long long ll;
    typedef long double ld;
    typedef pair<int,int> p32;
    typedef pair<ll,ll> p64;
    typedef pair<double,double> pdd;
    typedef vector<ll> v64;
    typedef vector<int> v32;
    typedef vector<vector<int> > vv32;
    typedef vector<vector<ll> > vv64;
    typedef vector<vector<p64> > vvp64;
    typedef vector<p64> vp64;
    typedef vector<p32> vp32;
    ll MOD = 998244353;
    #define forn(i,e) for(ll i = 0; i < e; i++)
    #define forsn(i,s,e) for(int i = s; i < e; i++)
    #define rforn(i,s) for(ll i = s; i >= 0; i--)
    #define rforsn(i,s,e) for(ll i = s; i >= e; i--)
    #define ln "\n"
    #define dbg(x) cout<<#x<<" = "<<x<<ln
    #define mp make_pair
    #define pb push_back
    #define fi first
    #define se second
    #define INF 1e18
    #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
    #define all(x) (x).begin(), (x).end()
    #define sz(x) ((ll)(x).size())
     
    ll mpow(ll a, ll b){
        if(b >= (MOD-1)) b %= (MOD-1);
        if(b==0) return 1;
        ll t1 = mpow(a,b/2);
        t1 *= t1;
        t1 %= MOD;
        if(b%2) t1 *= a;
        t1 %= MOD;
        return t1;
    }
     
    ll mpow(ll a, ll b, ll p){
        if(b==0) return 1;
        ll t1 = mpow(a,b/2,p);   t1 *= t1;
        t1 %= p;
        if(b%2) t1 *= a;
        t1 %= p;
        return t1;
    }
    ll modinverse(ll a, ll m){
        ll m0 = m; 
        ll y = 0, x = 1; 
        if (m == 1) return 0; 
        while (a > 1){
            ll q = a / m; 
            ll t = m; 
            m = a % m, a = t; 
            t = y; 
            y = x - q * y; 
            x = t; 
        }
        if (x < 0) x += m0; 
        return x; 
    }
    ll range(ll l, ll r){
        return l + rand()%(r-l+1);
    }
    
    int main()
    {
        ll t=1;
        //cin>>t;
        while(t--)
        {
            string a;
            cin>>a;
            ll ans = 0;
            for(char c : a)
            {
                ans += (c-'0');
            }
            if(ans%9==0)cout<<"Yes"<<endl;
            else cout<<"No"<<endl;
        }
    }

Measured memory_bytes: 3752
#include<stdio.h>
#include<stdlib.h>

typedef struct Node{
  int key;
  struct Node *right, *left, *parent;
}Node;

Node *root, *NIL;

Node * find(Node *u, int k){
  while(u != NIL && k != u->key){
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

void insert(int k){
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->left;
    }
    else{
      x = x->right;
    }
  }
  
  z->parent = y;
  if(y == NIL){
    root = z;
  }
  else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}

void inorder(Node *u){
  if(u == NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u){
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}

int main(){
  int n, i, x;
  char com[20];

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%s",com);
    if(com[0] == 'f'){
      scanf("%d",&x);
      Node *t = find(root, x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    }
    else if(com[0] == 'i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 20456
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

class Prime
{
	ll i, iLimit;
public:
	bool isPrime(ll a);
};

bool Prime::isPrime(ll a)
{
	if (a == 1) return false;
	iLimit = (int)sqrt(a);
	for (i = 2; i <= iLimit; i++) if (a % i == 0) break;
	return (i == iLimit + 1 ? true : false);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	vector<int> res(100005);
	Prime p;
	for (int i = 1; i <= 100000; ++i) {
		bool elf = p.isPrime(i);
		if (elf) {
			bool ok = p.isPrime((i + 1) / 2);
			if (ok) res[i]++;
		}
		res[i + 1] += res[i];
	}
	int q; cin >> q;
	rep(ri, q) {
		int l, r;
		cin >> l >> r;
		int ans = res[r] - res[l - 1];
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 1024
let () = Scanf.sscanf (read_line ()) "%d %d %d %d" @@ fun h w a b ->
  for i = 0 to h - 1 do
    for j = 0 to w - 1 do
      print_int @@ 
        if i < b then
          if j < a then 0 else 1
        else
          if j < a then 1 else 0
    done;
    print_newline ()
  done

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
    string s, t;
    cin >> s >> t;
    cout << t << s << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <bitset>
#include <unordered_map>

using ll = long long;

using namespace std;

using bs = bitset<26>;
#define INF 200010

int main() {
    string s;
    cin >> s;
    int len = s.size();
    vector<bs> rui(1, 0);
    for (int i=0; i<len; i++) {
        rui.push_back(rui.back());
        rui.back().flip(s[i] - 'a');
    }
    unordered_map<bs, int> dp;
    dp[0] = 0;
    for (int i=0; i<=len; i++) {
        for (int j=0; j<=26; j++) {
            bs from = rui[i];
            if (j > 0) from = from.flip(j-1);
            if (!dp.count(rui[i])) dp[rui[i]] = INF;
            int cost = (dp.count(from) ? dp[from] : INF);
            dp[rui[i]] = min(dp[rui[i]], cost + 1);
        }
    }
    cout << max(dp[rui[len]], 1) << '\n';
    return 0;
}


Measured memory_bytes: 10228
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define iter vector<int>::iterator
#define mod 1000000007

int32_t main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;

    double p[n];
    for(int i=0;i<n;i++)
    {
        cin>>p[i];
    }

    double dp[n+1][n+1];

    for(int i=0;i<n+1;i++)
    {
        dp[0][i]=0.0;
    }
    dp[0][0]=1;
    dp[1][0]=1-p[0];
    for(int i=2;i<n+1;i++)
    {
        dp[i][0]=dp[i-1][0]*(1-p[i-1]);
    }

    for(int i=1;i<n+1;i++)
    {
        for(int j=1;j<n+1;j++)
        {
            dp[i][j]=dp[i-1][j]*(1-p[i-1])+dp[i-1][j-1]*p[i-1];
        }
    }

    double ans=0.0;
    for(int i=(n/2)+1;i<n+1;i++)
    {
        ans+=dp[n][i];
    }
    

    cout << fixed << setprecision(10) << ans <<"\n"; 
        
}

Measured memory_bytes: 140928
from sys import stdin

N=int(input())
xlist=[]
ylist=[]
dict = {}
for i in range(N):
  x, y = map(int, stdin.readline().rstrip().split())
  xlist.append(x)
  ylist.append(y)

for i in range(N):
  for j in range(N):
    if i != j:
      tupleStr=str(xlist[i] - xlist[j])+","+str(ylist[i] - ylist[j])
      if tupleStr in dict:
        dict[tupleStr]+=1
      else:
        dict[tupleStr]=1

maxNum=0
for val in dict.values():
  maxNum = max(maxNum, val)

print(N-maxNum)


Measured memory_bytes: 39536
#include <stdio.h>
#define BLACK 0
#define WHITE 1
#define GRAY -1


int a[101][101];

int n;
int color[101];
int time=0;
int d[101];
int k;
int head=0,tail=0;
int queue[101];

void BFS (int);

void Enqueue(int u){
    if(tail == 101)tail=0;
    queue[tail] =u;
    tail++;
}

int Dequeue(void){
    if(head==101)head=0;
    return queue[head++];
    
}



int main(void){
    int t,u,i,j;

    
    
    scanf("%d",&n);
    
    
   for(i=1;j<=n;i++){
        for(j=1;j<=n;j++){
            a[i][j]=0;
        }
    }
    
    for(i=1;i<=n;i++){
        scanf("%d",&u);
        scanf("%d",&k);
        for(j=1;j<=k;j++){
            scanf("%d",&t);
            a[i][t] =1;
        }
        
    }
    

      BFS(1);
        
        for(i=1;i<=n;i++){
            if(d[i]==2147483647)d[i]=-1;
            printf("%d %d",i,d[i]);
            printf("\n");
        }
        
    return 0;
}
  
void BFS(int s){
        int u,v,i;
        int empty=0;
        
        
        for(u=1;u<=n;u++){
            color[u]=WHITE;
            d[u]=2147483647;
        }
        
        color[s]=GRAY;
        d[s]=0;

    
        Enqueue(s);
        empty++;
        
        while(empty!=0){
            u=Dequeue();
            empty--;
            for(v=1;v<=n;v++){
               //v=a[u][v];
                if(color[v] == WHITE && a[u][v]==1){
                    color[v]=GRAY;
                    d[v]=d[u]+1;
                    Enqueue(v);
                    empty++;
                }
            }
           //
            color[u]=BLACK;
        }
   
        
}

    
    

Measured memory_bytes: 640
/////////////////////////////////////////
////////// ^\/^ *_* :) :-D '~' \\\\\\\\\\
/////////////////////////////////////////
#include <bits/stdc++.h>
//#include <algorithm>
//#include <cstdio>
//#include <functional>
#include <iostream>
//#include <cfloat>
//#include <climits>
//#include <cstdlib>
//#include <cstring>
//#include <cmath>
//#include <map>
//#include <queue>
//#include <set>
//#include <sstream>
//#include <stack>
//#include <string>
//#include <time.h>
//#include <vector>
//#include <random>
//#include <unordered_set>
//#include <complex>
//#include <string.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

int main()
{
	string s,t;
	cin>>s>>t;
	int p=s.size();
	repn(i,p)
	{
		if(s==t)
		{
			puts("Yes");
			rt0;
		}
		string tmp=s.substr(0,s.size()-1);
		s=s[s.size()-1]+tmp;
	}
	if(s==t)
	{
		puts("Yes");
		rt0;
	}
	puts("No");
	rt0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	ll a,b,c;
	cin>>a>>b>>c;
	cout<<b/c-a/c+(a%c?0:1)<<endl;
}










Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  Scanner sc;

  Main() {
    sc = new Scanner(System.in);
  }

  int ni() {
    return sc.nextInt();
  }

  public static void main(String[] args) {
    new Main().run();
  }

  class Disk {
    byte x;
    byte y;
    byte c;
    byte r;

    boolean isIn(Disk disk) {
      return Math.pow(this.r + disk.r, 2) > Math.pow(this.x - disk.x, 2) + Math.pow(this.y - disk.y, 2);
    }
  }

  void run() {
    for (; ; ) {
      int n = ni();
      if (n == 0) {
        break;
      }
      Disk[] list = new Disk[n];
      for (int i = 0; i < n; ++i) {
        Disk d = new Disk();
        d.x = (byte) ni();
        d.y = (byte) ni();
        d.r = (byte) ni();
        d.c = (byte) ni();
        list[i] = d;
      }

      byte[] dp = new byte[1 << n];
      Arrays.fill(dp, (byte) -1);
      dp[0] = 0;
      for (int i = 0; i < 1 << n; ++i) {
        if (dp[i] < 0) {
          continue;
        }
        for (int j = 0; j < n; ++j) {
          if (((i >> j) & 1) == 1) {
            continue;
          }
          boolean flag = true;
          for (int a = 0; a < j; ++a) {
            if (((i >> a) & 1) == 1) {
              continue;
            }
            flag &= !list[j].isIn(list[a]);
          }
          if (!flag) {
            continue;
          }
          for (int k = j + 1; k < n; ++k) {
            if (((i >> k) & 1) == 1) {
              continue;
            }
            boolean glag = true;
            for (int a = 0; a < k; ++a) {
              if (((i >> a) & 1) == 1) {
                continue;
              }
              glag &= !list[k].isIn(list[a]);
            }
            if (!glag) {
              continue;
            }
            if (list[j].c != list[k].c) {
              continue;
            }

//            debug(j, k);

            dp[i | (1 << j) | (1 << k)] = (byte) Math.max(dp[i] + 1, dp[i | (1 << j) | (1 << k)]);
          }
        }
      }
      int max = 0;
      for (int i = 0; i < 1 << n; ++i) {
        max = Math.max(max, dp[i]);
      }

      System.out.println(max * 2);
    }
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }
}

Measured memory_bytes: 226968
#include<stdio.h>

int main(){
	int i,j,R[200000],n,minv,maxv;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	scanf("%d",&R[i]);
	
	maxv=R[1]-R[0];
	minv=R[0];
	
	for(j=1;j<n;j++){
		if(maxv<R[j]-minv) maxv=R[j]-minv;
		if(minv>R[j]) minv = R[j];
	}
	printf("%d\n",maxv);
	return 0;
}

Measured memory_bytes: 1376