akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

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

    string sa = s.substr(0, a);
    string sb = s.substr(a+1);

    auto ans = "No";
    if(all_of(sa.begin(),sa.end(),::isdigit) && all_of(sb.begin(),sb.end(),::isdigit) && s[a] == '-'){
        ans = "Yes";
    }

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


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



int main(){
    double A,B;
    cin>>A>>B;
    double Amax=A+1; double Bmax=B+1;
    A=A/0.08;
    Amax=Amax/0.08;
    B=B/0.1;
    Bmax=Bmax/0.1;
  double product=ceil(max(A,B));
    if(product>=Amax||product>=Bmax){
    cout<<"-1"<<endl;
    }else{
    cout<<product<<endl;
    }
    
  
}


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

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int n;
	cin >> n;

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

	vector <int> mc(n + 1);
	mc[2] = abs(h[2] - h[1]);
	for (int i = 3; i <= n; i++)
		mc[i] = min(mc[i - 1] + abs(h[i] - h[i - 1]),
		            mc[i - 2] + abs(h[i] - h[i - 2]));

	cout << mc[n];
	return 0;
}

Measured memory_bytes: 3980
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s[7],d,f,g,h,i,j;
	for(i=0;i<6;i++)scanf("%d",&s[i]);
	d=s[0]+s[1]*5+s[2]*10+s[3]*50+s[4]*100+s[5]*500;
	if(d<1000) printf("0\n");
	else printf("1\n");
	return 0;
}

Measured memory_bytes: 2680
#include <vector>
#include <iostream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>

using namespace std;

template<typename T, typename S>
istream& operator >> (istream& is, pair<T, S>& p) {
    is >> p.first >> p.second;
    return is;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& v) {
    for (auto& x : v) {
        is >> x;
    }
    return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& v) {
    for (auto& x : v) {
        os << x << " ";
    }
    os << "\n";
    return os;
}

uint64_t SolveBrute(uint64_t N, uint64_t A, map<uint64_t, uint64_t>& ans) {
    if (ans.count(N)) return ans[N];
    uint64_t minans = N;
    for (uint64_t i = 2; i <= sqrt(N) + 10 && i < N; ++i) {
        uint64_t x = (N + i - 1) / i;
        uint64_t curans = min(SolveBrute(i, A, ans) + x + A, SolveBrute(x, A, ans) + i + A);
        if (curans < minans) {
            minans = curans;
        }
    }
    return ans[N] = minans;
}

const int MAXK = 35;
// const int MAXT = 10;// 2e6;

uint64_t Solve(int T, uint64_t A, uint64_t N) {
    vector<map<uint64_t, uint64_t>> dp(MAXK + 1);
    dp[0][0] = 1;
    for (int k = 1; k <= MAXK; ++k) {
        // cerr << T << " " << k << " " << dp[k - 1].size() << " " << 35 * 35 << endl;
        const int MAXD = MAXK + 5 + k;
        for (const auto& [S, P] : dp[k - 1]) {
            for (uint64_t t = max(T, MAXD) - MAXD; t <= T; ++t) {
                dp[k][S + t] = max(dp[k][S + t], P * t);
            }
        }
    }
    uint64_t min_ans = N;
    for (int k = 1; k <= MAXK; ++k) {
        for (const auto& [S, P] : dp[k]) {
            if (P >= N) {
                uint64_t curans = A * (k - 1) + S;
                if (curans < min_ans) min_ans = curans;
            }
        }
    }
    return min_ans;
}


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

#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    uint64_t N, A;
    cin >> N >> A;
    uint64_t min_ans = N;
    for (int k = 2; k <= MAXK; ++k) {
        int MINT = pow(N, 1.0 / k);
        // for (int T = MINT; T <= MINT + MAXK + 5; ++T) {
            min_ans = min(min_ans, Solve(MINT + MAXK + 5, A, N));
        // }
    }
    cout << min_ans;
}


Measured memory_bytes: 6156
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"

const int W = 1e5 + 5;

int n, w;
int wt[105], val[105];
int dp[105][W];

int findAns(int idx, int tw){

    if(idx == 0 or tw == 0){
        dp[idx][tw] = 0;
        return 0;
    }

    int &ans = dp[idx][tw];
    if(ans != -1){
        return ans;
    }

    if(wt[idx] > tw){
        ans= findAns(idx - 1, tw);
        return ans;
    }

    ans= max(val[idx] + findAns(idx - 1, tw - wt[idx]), findAns(idx - 1, tw));
    return ans;
}

int32_t main(){

    memset(dp, -1, sizeof(dp));

    cin >> n >> w;

    for(int i = 1;i <= n; ++i){
        cin >> wt[i] >> val[i];
    }
    int ans = findAns(n, w);
    cout << ans << endl;

}


Measured memory_bytes: 85652
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    x = list(map(int, input().split()))
    L = int(input())
    Q = int(input())

    LOG = 30    # 30 > log2(10**9)
    nxt = [[-1]*N for _ in range(LOG)]
    for i in range(N):
        nxt[0][i] = bisect.bisect_left(x, x[i]+L+1) - 1

    for k in range(LOG-1):
        for i in range(N):
            if nxt[k][i] == -1:
                nxt[k+1][i] = -1
            else:
                nxt[k+1][i] = nxt[k][nxt[k][i]]

    for _ in range(Q):
        a, b = map(int, input().split())
        if a > b:
            a, b = b, a
        a -= 1
        b -= 1
        ans = 0
        for k in reversed(range(LOG)):
            if nxt[k][a] < b:
                a = nxt[k][a]
                ans += 2 ** k
        print(ans + 1)



if __name__ == '__main__':
    main()

Measured memory_bytes: 115484
#include<bits/stdc++.h>
using namespace std;
const long long mod=1000000000+7;
const long long INF=-mod;

//マクロ
//型エイリアス
using ll = long long;
using P=pair<long long,long long>;
using vl=vector<long long>;
//ショートカット
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<n;i++) //半開区間
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
//入力
#define vin(v,N) for(long long i=0;i<N;i++) cin>>v.at(i)
#define lin(n) long long n;cin>>n
#define vlin(v,N) vector<long long>v(N);for(long long i=0;i<N;i++)cin>>v.at(i)

//関数
//最大公約数
long long gcd(long long m,long long n){
  long long a=max(m,n);
  long long b=min(m,n);
  long long r=a%b;
  while(r!=0){
    a=b; b=r; r=a%b;
  }
  return b;
}
// 最小公倍数
long long lcd(long long m,long long n){
  return m*n/gcd(m,n);
}
//xのn乗
long long power(long long x,long long N){
  long long ret=1;
  for(long long i=0;i<N;i++)   
    ret*=x;
  return ret;
}
//nCr
long long C(long long n, long long r);
//nCr (mod)
long long modC(long long n, long long r) {
    vector<long long> f(n+1),inv(n+1),invf(n+1);
    f[0]=f[1]=1;
    invf[0]=invf[1]=1;
    inv[1]=1;
    for (long long i=2;i<n+1;i++) {
        f[i]=(i*f[i-1])%mod;
        inv[i]=mod-((mod/i)*inv[mod%i])%mod;
        invf[i]=(inv[i]*invf[i-1])%mod;
    }
    long long cmb=f[n]*(invf[r]*invf[n-r]%mod)%mod;
    if (n>=r) return cmb;
    else return 0;
}
//素因数分解(mapで返す)
map<long long,long long> factor(long long p){
  ll p1=p;
  map<long long,long long>ret;
  for(long long i=2;i*i<=p1;i++){
     while(p%i==0){
      ret[i]++;
      p/=i;
    }
  }
  if(p!=1)
  ret[p]++;
  return ret;
}
//素数判定
bool is_prime(long long N){
  for(long long i=2;i*i<=N;i++){
    if(N%i==0)
      return false;
  }
  return true;
}
//最大値更新
void chmax(long long &a,long long b){
  a=max(a,b);
}
//最小値更新
void chmin(long long &a,long long b){
  a=min(a,b);
}

//メイン関数
int main(){
  //doubleの桁数
  cout<<fixed<<setprecision(10);
  
  lin(x);
  
  bool OK=false;
  while(true){
    if(is_prime(x)){
      cout<<x;
      break;
    }
    else
      x++;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define il inline
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define mid ((l+r)>>1)
#define MAXN 
#define MAXM 
#define mod
#define inf (1<<30)
#define eps (1e-6)
#define alpha 0.75
#define rep(i, x, y) for(register int i = x; i <= y; ++i)
#define repd(i, x, y) for(register int i = x; i >= y; --i)
#define file(s) freopen(s".in", "r", stdin), freopen(s".my", "w", stdout)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, int> pli;
typedef pair <int, ll> pil;
typedef pair <ll, ll> pll;
template <typename T> il bool chkmin(T &x, T y) {return x > y ? x = y, 1 : 0;}
template <typename T> il bool chkmax(T &x, T y) {return x < y ? x = y, 1 : 0;}
template <typename T> il void read(T &x) {
	char ch = getchar(); int f = 1; x = 0;
	while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}
	while(ch >= '0' && ch <= '9') x = x*10+ch-'0', ch = getchar();
	x *= f;
}
template <typename T, typename... Args> il void read(T &x, Args &...args) {
	read(x), read(args...);
}
char s[15];
int main() {
	scanf("%s", s+1); int x = 0, n = strlen(s+1);
	rep(i, 1, n) x += s[i] == 'o';
	puts(x + 15 - n >= 8 ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
map < pair< string,string >,ll > x; 
int n;
string s;
ll ans;
void rec1(int ind,string r,string b,int cnt)
{
	
	if(cnt==n)
	{
	reverse(b.begin(),b.end());
	x[make_pair(r,b)]++;
	return;
	}
	rec1(ind+1,r+s[ind],b,cnt+1);
	rec1(ind+1,r,b+s[ind],cnt+1);
}
void rec2(int ind,string r,string b,int cnt)
{
	if(cnt==n)
	{
	    reverse(b.begin(),b.end());
	    ans+=x[make_pair(b,r)];
	    return;
	}
	rec2(ind+1,r+s[ind],b,cnt+1);
	rec2(ind+1,r,b+s[ind],cnt+1);
}
int main()
{
	cin>>n;
	cin>>s;
	rec1(0,"","",0);
	rec2(n,"","",0);
	cout<<ans<<endl;
}

Measured memory_bytes: 84992
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Node {
public:
	int location;
	int p, l, r;
	Node(){}
};
class Point {
public:
	int id, x, y;
	Point() {}
	Point(int id, int x, int y) :id(id), x(x), y(y){}
	bool operator < (const Point &p) const {
		return id < p.id;
	}

	void print() {
		printf("%d\n", id);
	}
};

static const int MAX = 1000000;
static const int NIL = -1;

int N;
Point P[MAX];
Node T[MAX];
int np;

bool lessX(const Point &p1, const Point &p2) {
	return p1.x < p2.x;
}
bool lessY(const Point &p1, const Point &p2) {
	return p1.y < p2.y;
}
int makeKDTree(int l, int r, int depth) {
	if (!(l < r)) return NIL;
	int mid = (l + r) / 2;
	int t = np++;
	if (depth % 2 == 0) {
		sort(P + l, P + r, lessX);
	}
	else {
		sort(P + l, P + r, lessY);
	}
	T[t].location = mid;
	T[t].l = makeKDTree(l, mid, depth + 1);
	T[t].r = makeKDTree(mid + 1, r, depth + 1);

	return t;
}
void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
	int x = P[T[v].location].x;
	int y = P[T[v].location].y;

	if (sx <= x && x <= tx && sy <= y && y <= ty) {
		ans.push_back(P[T[v].location]);
	}

	if (depth % 2 == 0) {
		if (T[v].l != NIL) {
			if (sx <= x) {
				find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
			}
		}
		if (T[v].r != NIL) {
			if (x <= tx) {
				find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
			}
		}
	}
	else {
		if (T[v].l != NIL) {
			if (sy <= y) {
				find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
			}
		}
		if (T[v].r != NIL) {
			if (y <= ty) {
				find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
			}
		}
	}
}
int main() {
	int x, y;
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		cin >> x >> y;
		P[i] = Point(i, x, y);
		T[i].l = T[i].r = T[i].p = NIL;
	}
	np = 0;
	int root = makeKDTree(0, N, 0);
	int q;
	scanf("%d", &q);
	int sx, tx, sy, ty;
	vector<Point> ans;
	for (int i = 0; i < q; i++) {
		scanf("%d %d %d %d", &sx,&tx,&sy,&ty);
		ans.clear();
		find(root, sx, tx, sy, ty, 0, ans);
		sort(ans.begin(), ans.end());
		for (int j = 0; j < ans.size(); j++) {
			ans[j].print();
		}
		printf("\n");
	}
}




Measured memory_bytes: 16456
X, K, D = map(int,input().split())

ans = 0
X = abs(X)
if X == K * D:
  ans = 0
elif X > K * D:
  ans = X - (K * D)
else:
  div = X // D
  temp = K - div
  if temp % 2 == 0:
    ans = X - (div * D)
  else:
    ans = abs(X - (div * D) - D)

print(ans)

Measured memory_bytes: 9152
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

play :: Int -> Int -> Int -> Int
play a b c | (a `mod` 2 == 0) && (b `mod` 2 == 0) && (c `mod` 2 == 0) && (a == b) && (b == c) = -1
           | (a `mod` 2 == 0) && (b `mod` 2 == 0) && (c `mod` 2 == 0) = 1 + play ((b+c) `div` 2) ((a+c) `div` 2) ((a+b) `div` 2)
           | otherwise = 0

main = do
  [a, b, c] <- getIntList
  print $ play a b c


Measured memory_bytes: 380
// inputに入力データ全体が入る
function Main(input) {
    var list = input[1].split(" ").map(v=>v-0).sort((b,a)=>a-b);
    var a = 0, b=0;
    list.forEach((v,i)=>{
        if(i%2==0) a+=v;
        else b+=v;
    });
    console.log(a-b)
}

Main(require("fs").readFileSync("/dev/stdin", "utf8").split("\n"));

Measured memory_bytes: 20936
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <map>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-7
#define inf 0x3f3f3f3f
#define mod 1000000007
using namespace std;

int main() {
	speed;
	string s;
	cin >> s;
	for (int i = 1; i < s.size(); ++i) {
		if (s[i - 1] == s[i])
			return cout << "Bad", 0;
	}
	cout << "Good";
}

Measured memory_bytes: 256
# 169A
# A × B を整数として出力せよ

# 1. 入力をプログラミングで扱えるように受け取ること
a, b = map(int, input().split())
# print(a,b)

# 2. 受け取った入力値を使って、適切に処理
answer=a*b

# 3. 計算した結果を出力すること
print(answer)

Measured memory_bytes: 9044
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m;
string s;
bool mp[105][105];
int dp[105][105];

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>s;
		for(int j=0;j<m;j++)mp[i][j+1]= (s[j]=='.')?1:0 ;
	}
	for(int i=0;i<=n;i++)for(int j=0;j<=m;j++)dp[i][j]=2147480000;
	
	dp[0][1]=dp[1][0]=0;
	mp[0][1]=mp[1][0]=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(mp[i][j]){
				dp[i][j]=min(dp[i][j-1],dp[i-1][j]);
			}
			else{
				if(mp[i-1][j])dp[i][j]=dp[i-1][j]+1;
				else dp[i][j]=dp[i-1][j];
				
				if(mp[i][j-1])dp[i][j]=min(dp[i][j],dp[i][j-1]+1);
				else dp[i][j]=min(dp[i][j],dp[i][j-1]);
			}
			
		//	printf("%d %d %d\n",i,j,dp[i][j]);
		}
	}
	cout<<dp[n][m];
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
typedef long long ll;
using namespace std;
const int inf=0x3f3f3f;
const int maxn = 1000010;

ll gcd(ll a,ll b)
{
	return b==0?a:gcd(b,a%b);
 } 
ll lcm(ll a,ll b)
{
	return a*b/gcd(a,b);
}
int main()
{
	ll n;
	cin>>n;
	cout<<lcm(2,n);
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) cin >> a[i];
    int cnt = 1, cond = 0;
    for(int i = 1; i < n; i++){
        if(cond == 1){
            if(a[i] < a[i - 1]){
                cond = 0;
                cnt++;
            }
        }else if(cond == -1){
            if(a[i] > a[i - 1]){
                cond = 0;
                cnt++;
            }
        }else{
            if(a[i] < a[i - 1]) cond = -1;
            else if(a[i] > a[i - 1]) cond = 1;
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 640
#include <iostream>

void show(int *A, int N)
{
	std::cout << A[0];
	for (int i=1; i<N; i++) {
		std::cout << " " << A[i];
	}
	std::cout << std::endl;
}

int main()
{
	int N;
	std::cin >> N;
	
	int *A = new int[N];
	for (int i=0; i<N; i++) std::cin >> A[i];
	
	show(A, N);
	
	for (int i=1; i<N; i++) {
		int key = A[i];
		int j;
		for (j=i-1; j>=0 && A[j] > key; j--) {
			A[j+1] = A[j];
		}
		A[j+1] = key;
		show(A, N);
	}
	
	delete[] A;
	
	return 0;
}




Measured memory_bytes: 3096
from math import ceil

n = int(input())
CSF = [list(map(int,input().split())) for i in range(n-1)]

for i in range(n-1):
	time = CSF[i][1]+CSF[i][0]
	for j in range(i+1,n-1):
		if (time-CSF[j][1])%CSF[j][2] != 0 or time-CSF[j][1]<0:
			time = max(CSF[j][1],CSF[j][2]*(ceil(time/CSF[j][2])))
		time += CSF[j][0]
	print(time)
print(0)

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

using namespace std;
using ii = pair<int, int>;

struct SegTree {
    vector<int> vseg;
    int n;
    #define CL(v) ((v) << 1)
    #define CR(v) ((v) << 1 | 1)

    SegTree(vector<int> a){
        this->n = a.size();
        vseg.resize(n << 2);
        build(a, 1, 0, n - 1);
    }

    void build(vector<int>& a, int v, int tl, int tr){
        if(tl == tr)
            vseg[v] = a[tl];
        else{
            int tm = tl + tr >> 1;
            build(a, CL(v), tl, tm);
            build(a, CR(v), tm + 1, tr);
            vseg[v] = max(vseg[CL(v)], vseg[CR(v)]);
        }
    }

    int getMax() {
        return vseg[1];
    }

    void update(int pos, int diff){
        update(1, 0, n - 1, pos, diff);
    }

    void update(int v, int tl, int tr, int pos, int diff) {
        if(tl == tr){
            vseg[v] += diff;
        }else{
            int tm = tl + tr >> 1;
            if (pos <= tm)
                update(CL(v), tl, tm, pos, diff);
            else
                update(CR(v), tm + 1, tr, pos, diff);
            vseg[v] = max(vseg[CL(v)], vseg[CR(v)]);
        }
    }
};

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    int n, x, t, h, w, m;
    cin >> h >> w >> m;
    vector<ii> v(m);
    vector<vector<int>> line(h);
    vector<int> col(w, 0);
    for(int i = 0; i < m; i++){
        cin >> v[i].first >> v[i].second;
        v[i].first --; v[i].second--;
        line[v[i].first].push_back(v[i].second);
        col[v[i].second]++;
    }
    SegTree seg(col);
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int e: line[i])
            seg.update(e, - 1);
        ans = max<int>(ans, line[i].size() + seg.getMax());
        for(int e: line[i])
            seg.update(e, 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 29032
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

struct Point{
	int x,y;
	Point(){}
	Point(int x,int y):x(x),y(y){}
	bool operator<(const Point& p)const{
		if(y!=p.y) return y<p.y;
		return x<p.x;
	}
};

struct Event{
	Point pos;
	int io;		// 0:in,1:out
	int type;	// 0:戦闘機,1:エネルギー弾
	int index;
	Event(){}
	Event(Point p,int io,int t,int i):pos(p),io(io),type(t),index(i){}
	bool operator<(const Event& e)const{
		if(pos.x!=e.pos.x)
			return pos.x<e.pos.x;
		if(io!=e.io)
			return io<e.io;
		return false;
	}
};

int main()
{
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	for(int m,n,r;cin>>m>>n>>r,m|n;){
		vector<Event> es;
		{
			vector<Point> as(m),bs(n);
			rep(i,m) cin>>as[i].x>>as[i].y;
			rep(i,n) cin>>bs[i].x>>bs[i].y;
			
			rep(i,m){
				es.emplace_back(Point(as[i].x-2*r,as[i].y),0,0,i);
				es.emplace_back(Point(as[i].x+2*r,as[i].y),1,0,i);
			}
			rep(i,n){
				es.emplace_back(Point(bs[i].x-2*r,bs[i].y),0,1,i);
				es.emplace_back(Point(bs[i].x+2*r,bs[i].y),1,1,i);
			}
			sort(all(es));
		}
		
		set<Point> as,bs;
		int res=0;
		for(Event& e:es){
			if(e.io==0){
				e.pos.x+=2*r;
				if(e.type==0){
					auto i=bs.lower_bound(Point(-INFTY,e.pos.y-4*r));
					auto j=bs.upper_bound(Point(+INFTY,e.pos.y+4*r));
					for(;i!=j;++i){
						int dx=abs(i->x-e.pos.x),dy=abs(i->y-e.pos.y);
						if(dx*dx+dy*dy<=4*r*4*r)
							res++;
					}
					as.insert(e.pos);
				}
				else{
					auto i=as.lower_bound(Point(-INFTY,e.pos.y-4*r));
					auto j=as.upper_bound(Point(+INFTY,e.pos.y+4*r));
					for(;i!=j;++i){
						int dx=abs(i->x-e.pos.x),dy=abs(i->y-e.pos.y);
						if(dx*dx+dy*dy<=4*r*4*r)
							res++;
					}
					bs.insert(e.pos);
				}
			}
			else{
				e.pos.x-=2*r;
				if(e.type==0)
					as.erase(e.pos);
				else
					bs.erase(e.pos);
			}
		}
		cout<<res<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 18488
#include<iostream>
#include<string>
#include<utility>
#include<vector>
#include<algorithm>

using namespace std;

bool cmp(pair<pair<string, int>, int> p1, pair<pair<string, int>, int> p2) {
	if (p1.first.first != p2.first.first) {
		return p1.first.first < p2.first.first;
	}
	return p1.first.second > p2.first.second;
}

int main(void) {
	int n;
	vector<pair<pair<string, int>, int>> s;
	cin >> n;
	for (int i(0); i < n; i++) {
		pair<pair<string, int>, int> tmp;
		cin >> tmp.first.first >> tmp.first.second;
		tmp.second = i+1;
		s.push_back(tmp);
	}
	sort(s.begin(), s.end(), cmp);

	for (int i(0); i < n; i++) {
		cout << s[i].second << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    
    int a,b,c,d,e,f,g;
    cin >>a>>b>>c>>d>>e>>f;
    
    a = a * 1;
    b = b * 5;
    c = c * 10;
    d = d * 50;
    e = e * 100;
    f = f * 500;
    
    g = a+b+c+d+e+f;
    
    if(g >= 1000){
        cout<<"1"<<endl;
    }else{
        cout<<"0"<<endl;
    }
}



Measured memory_bytes: 3100
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    constexpr int INF = 1e9 + 6;
    int m = INF;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a;  cin >> a;
        if (i == 0 || a < m) ans++;
        m = min(m, a);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_left

N = int(input())
L = list(map(int, input().split()))

L.sort()
result = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        result += bisect_left(L, L[i] + L[j]) - j - 1
print(result)

Measured memory_bytes: 3188
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0)while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e5+10;

	struct DSU
	{
		int fa[N];DSU(){fo(i,0,N-1)fa[i]=i;}
		int findfa(int x){return fa[x]==x?x:fa[x]=findfa(fa[x]);}
		void merg(int x,int y){fa[findfa(x)]=findfa(y);}
	}dsu;
	pr a[N],b[N];int c[N];int fm[N];
	bool check(int n)
	{
		fo(i,2,n) if(c[i-1]>=a[i].FR) return 1;
		return 0;
	}
    void main()
	{
		int n=qread();fo(i,1,n) a[i].FR=qread();fo(i,1,n) a[i].SE=qread(),c[i]=a[i].SE;
		sort(a+1,a+n+1);fo(i,1,n) b[i]=MP(a[i].SE,i);sort(b+1,b+n+1);sort(c+1,c+n+1);
		fo(i,1,n) if(c[i]<a[i].FR) {puts("No");return;}
		if(check(n)) {puts("Yes");return;}
		fo(i,1,n) dsu.merg(i,b[i].SE);
		int cnt=0;fo(i,1,n) cnt+=dsu.findfa(i)==i;
		if(cnt>1) {puts("Yes");return;}
		fo(i,2,n) if(b[i-1].FR==b[i].FR and dsu.findfa(b[i].SE)==dsu.findfa(b[i-1].SE)) {puts("Yes");return;}
		puts("No");
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 3584
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
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 Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        KStones solver = new KStones();
        solver.solve(1, in, out);
        out.close();
    }

    static class KStones {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            int n = sc.nextInt();
            int k = sc.nextInt();
            int[] tab = new int[n];
            boolean[] dp = new boolean[k + 1];

            for (int i = 0; i < n; i++) {
                tab[i] = sc.nextInt();
            }

            for (int i = 0; i < k + 1; i++) {
                if (!dp[i]) {
                    for (int j = 0; j < n; j++) {
                        if (i + tab[j] < k + 1) {
                            dp[i + tab[j]] = true;
                        }
                    }
                }
            }

            if (dp[k]) {
                out.println("First");
            } else {
                out.println("Second");
            }
        }

    }

    static class inputClass {
        BufferedReader br;
        StringTokenizer st;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



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


double degToRad(int deg) {
  return (double)deg*M_PI/180;
}
double calcS(int deg) {
  return sin(degToRad(deg));
}

main() {
  while(1) {
    int m;
    double S[2];
    bool flag = false;
    for(int t = 0; t < 2; t++) {
      S[t] = 0;
      cin >> m;
      if(m == 0) {
	flag = true;
	break;
      }
      int tmp = 0;
      for(int i = 0; i < m-1; i++) {
	int deg;
	cin >> deg;
	S[t] += calcS(deg);
	tmp += deg;
      }
      S[t] += calcS(360-tmp);
    }
    if(flag) break;
    if(S[0] > S[1]) cout << 1 << endl;
    else if(S[0] < S[1]) cout << 2 << endl;
    else            cout << 0 << endl;
  }
}

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

#define inf 2000000009
#define ff first 
#define ss second 
#define ll long long 

int main(){
	int n; cin>>n; 
	ll a[n]; 
	ll ans=0; 
	for(int i=0;i<n;i++){
		cin>>a[i]; 
		ans+=a[i]; 
		ans--; 
	}
	cout<<ans; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
  cin >> n;
  int i=1;
  while(++i<=n){
    int x=i;
    if(x%3==0){
      cout << " " << i;
      continue;
    }
    while(x){
      if(x%10==3){
	cout << " " << i;
	break;
      }
      x/=10;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3096
import sys
from collections import defaultdict

N = int(input())
C = [0]
for _ in range(N):
    c = int(sys.stdin.readline())
    if C[-1] == c:
        continue
    else:
        C.append(c)

ans = 1
dic = defaultdict(lambda: 0)
mod = 10 ** 9 + 7
for c in C:
    a = dic[c]
    dic[c] += ans
    ans = (ans + a) % mod

print(ans % mod)


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

int main() {
    string s;
    cin >> s;
    string t = "CODEFESTIVAL2016";
    int cnt = 0;
    for (int i = 0; i < (int)s.size(); i++) {
        if (s.at(i) != t.at(i)) cnt++;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll q, h, s, d, n;
	cin >> q >> h >> s >> d >> n;
	ll ans = q * n * 4;
	chmin(ans, h * n * 2);
	chmin(ans, s * n);
	if(n%2 == 0){
		chmin(ans, d * n/2);
	}
	else{
		chmin(ans, d * (n/2) + q * 4);
		chmin(ans, d * (n/2) + h * 2);
		chmin(ans, d * (n/2) + s);
	}
	cout << ans << endl;
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    int sx,sy,tx,ty;
    cin >>sx>>sy>>tx>>ty;
    string ans="";
    int dx = tx-sx;
    int dy = ty-sy;

    for(int i = 0; i < dy; i++)
    {
        ans+='U';
    }
    for(int i = 0; i < dx; i++)
    {
        ans+='R';
    }
    for(int i = 0; i < dy; i++)
    {
        ans+='D';
    }
    for(int i = 0; i < dx; i++)
    {
        ans+='L';
    }

    //2syuume
    ans+='L';
    for(int i = 0; i < dy+1; i++)
    {
        ans+='U';
    }
    for(int i = 0; i < dx+1; i++)
    {
        ans+='R';
    }
    ans+='D';
    ans+='R';
    for(int i = 0; i < dy+1; i++)
    {
        ans+='D';
    }
    for(int i = 0; i < dx+1; i++)
    {
        ans+='L';
    }
    ans+='U';

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
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{
	int x1,y1,x2,y2;
};

int table[10005];
Info info[10000];

int N,command;
int min_x,min_y,max_x,max_y;

int calc_S(){

	int ret = 0;

	for(int x = min_x; x <= max_x; x++){
		for(int y = min_y-1; y <= max_y+1; y++)table[y] = 0;

		for(int i = 0; i < N; i++){
			if(info[i].x1 <= x && info[i].x2 > x){
				table[info[i].y1]++;
				table[info[i].y2]--;
			}
		}

		for(int y = min_y; y <= max_y+1; y++){
			table[y] += table[y-1];
			if(table[y] > 0)ret++;
		}
	}
	return ret;
}

int calc_L(){

	int ret = 0;

	//水平な線
	for(int x = min_x; x <= max_x; x++){
		for(int y = min_y-1; y <= max_y+1; y++)table[y] = 0;

		for(int i = 0; i < N; i++){
			if(info[i].x1 <= x && info[i].x2 > x){
				table[info[i].y1]++;
				table[info[i].y2]--;
			}
		}

		for(int y = min_y; y <= max_y+1; y++){
			table[y] += table[y-1];
			if(table[y] > 0 && table[y-1] == 0)ret++;
			if(table[y] == 0 && table[y-1] > 0)ret++;
		}
	}

	//垂直な線
	for(int y = min_y; y <= max_y; y++){
		for(int x = min_x-1; x <= max_x+1; x++)table[x] = 0;

		for(int i = 0; i < N; i++){
			if(info[i].y1 <= y && info[i].y2 > y){
				table[info[i].x1]++;
				table[info[i].x2]--;
			}
		}

		for(int x = min_y; x <= max_x+1; x++){
			table[x] += table[x-1];
			if(table[x] > 0 && table[x-1] == 0)ret++;
			if(table[x] == 0 && table[x-1] > 0)ret++;
		}
	}

	return ret;
}

void func(){

	min_x = BIG_NUM;
	min_y = BIG_NUM;
	max_x = -BIG_NUM;
	max_y = -BIG_NUM;

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

		scanf("%d %d %d %d",&info[i].x1,&info[i].y1,&info[i].x2,&info[i].y2);
		info[i].x1++;
		info[i].y1++;
		info[i].x2++;
		info[i].y2++;

		min_x = min(min_x,min(info[i].x1,info[i].x2));
		min_y = min(min_y,min(info[i].y1,info[i].y2));

		max_x = max(max_x,max(info[i].x1,info[i].x2));
		max_y = max(max_y,max(info[i].y1,info[i].y2));
	}

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

	if(command == 2){
		printf("%d\n",calc_L());
	}
}

int main(){

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

		func();
	}

	return 0;
}



Measured memory_bytes: 3376
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;
struct dat{int x,y,t;};
const int Base = 250;
int sx,sy,gx,gy;
int mp[501][501];
int lx,ly;
int dx[7]={0,1,1,0,-1,-1,0};
int dy[2][7]={{1,0,-1,-1,-1,0,0},{1,1,0,-1,0,1,0}};
int D[501][501][6];

bool onmp(int x,int y){return abs(x-Base)<=lx&&abs(y-Base)<=ly;}

int bfs(){

  for(int i=0;i<501;i++)
    for(int j=0;j<501;j++) 
      for(int k=0;k<6;k++) D[i][j][k] = INF;
  
  
  deque<dat> Q;
  Q.push_front((dat){sx,sy,0});
  D[sy][sx][0] = 0;

  while(!Q.empty()){

    dat p = Q.front();Q.pop_front();
    int x = p.x,y = p.y,t = p.t;

    int cost = D[y][x][t];
    int I = abs((x-Base)*(y-Base)*t)%6;

    if(x==gx&&y==gy) return cost;

    for(int i=0;i<7;i++){
      int nx = x+dx[i];
      int ny = y+dy[x%2][i];
      int nt = (t+1)%6;
      int ncost = cost+(i!=I);
      if(!onmp(nx,ny)||mp[ny][nx]||D[ny][nx][nt]<=ncost)continue;
      if(i!=I)Q.push_back((dat){nx,ny,nt});
      else Q.push_front((dat){nx,ny,nt});
      D[ny][nx][nt] = ncost;
    }
  }
  return -1;
}
  

int main(){
  cin>>sx>>sy>>gx>>gy;
  sx+=Base,sy+=Base;
  gx+=Base,gy+=Base;

  int n;
  cin>>n;
  for(int i=0,x,y;i<n;i++) cin>>x>>y,mp[y+Base][x+Base] = 1;
  cin>>lx>>ly;
  cout<<bfs()<<endl;
  return 0;
}

Measured memory_bytes: 9504
N = int(input())
A = list(map(int,input().split()))

A.sort()

def gcd(n,m):
	if n%m==0:
		return(m)
	else:
		return(gcd(m,n%m))

ans = 0
for i in range(N):
	if i==0:
		ans = A[i]
	else:
		ans = gcd(ans,A[i])
print(ans)

Measured memory_bytes: 14224
#include <iostream>
#include <cstring>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

#define MAX_V 3000
struct Edge{
  int src, dest;
  int cap, rev;
};

const int INF = 1000000000;

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
bool visited[MAX_V];

void add_edge(Graph &g, int src, int dest, int cap) {
  g[src].push_back((Edge){src, dest, cap, (int)g[dest].size()});
  g[dest].push_back((Edge){dest, src, 0, (int)g[src].size() - 1});
}

int dfs(Graph &g, int v, int t, int f) {
  if (v == t) return f;
  visited[v] = true;
  REP(i, g[v].size()) {
    Edge &e = g[v][i];
    if (!visited[e.dest] && e.cap > 0) {
      int d = dfs(g, e.dest, t, min(f, e.cap));
      if (d > 0) {
        e.cap -= d;
        g[e.dest][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(Graph &g, int s, int t) {
  int flow = 0;
  for(;;) {
    memset(visited, 0, sizeof(visited));
    int f = dfs(g, s, t, INF);
    if (f == 0) return flow;
    flow += f;
  }
}

int main() {
  while(1){
    int n,m,l;
    cin>>n>>m>>l;
    if(!n)break;
    vector<vector<int>> b(n,vector<int>(n,INF));
    REP(i,m){
      int u,v,d;
      cin>>u>>v>>d;
      b[u][v] = d;
      b[v][u] = d;
    }
    REP(i,n) b[i][i] = 0;
    REP(k,n)REP(i,n)REP(j,n)
      b[i][j]=min(b[i][j], b[i][k]+b[k][j]);
    vector<pair<int,int>> q;
    REP(i,l){
      int p,t;
      cin>>p>>t;
      q.emplace_back(t,p);
    }
    sort(begin(q),end(q));
    Graph g(l*2+2);
    REP(i,l)REP(j,i){
      int ps,ts,pe,te;
      tie(ts,ps) = q[j];
      tie(te,pe) = q[i];
      if(b[ps][pe] <= te - ts) {
        add_edge(g, j + 1, i + l + 1, 1);
      }
    }
    REP(i,l){
      add_edge(g, 0, i+1, 1);
      add_edge(g, l+i+1, 2*l+1, 1);
    }
    int f = max_flow(g, 0, 2*l+1);
    cout << l - f << endl;
  }
  return 0;
}

Measured memory_bytes: 21324
#include <stdio.h>

int main()
{
	double h, max, min;

	scanf("%lf", &h);

	max = h;
	min = h;

	while(scanf("%lf", &h) != EOF){
		if(max < h) max = h;
		if(min > h) min = h;
	}

	printf("%f\n", (max-min));
	
	return 0;
}

Measured memory_bytes: 648
/*...Part - 01...*/

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>
#include <deque>
#include <iterator>
#include <bitset>
#include <assert.h>
#include <new>
#include <sstream>
//#include <bits/stdc++.h>
using namespace std ;

/*...Part - 02...*/

typedef long long               ll ;
typedef long double             ld ;
typedef unsigned long long      ull ;
typedef pair<int,int>           pii ;
typedef pair<ll,ll>             pll ;
typedef vector<int>             vi ;
typedef vector<ll>              vll ;
typedef vector<vector<int>>     vvi ;

int Int(){int x ; scanf("%d",&x) ; return x ;}
ll Long(){ll x ; scanf("%lld",&x) ; return x ;}

/*...Part - 03...*/
/*....Debugger....*/

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {cout << endl ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << ' ' ;
    err(++it, args...);
}

/*...Part - 04...*/
/*...Needed to change according to problem requirements...*/

const int N          = (int)2e5 + 5 ;
const int maxN       = (int)1e6 + 6 ;
const ll  Mod        = (ll)1e9 + 7 ;
const int inf        = (int)2e9 ;
const ll  Inf        = (ll)1e18 ;

/*..........................................................*/
/*...Part - 05...*/

#define     debug(x)    cerr << #x << " = " << x << '\n' ;
#define     rep(i,b,e)  for(__typeof(e) i = (b) ; i != (e + 1) - 2 * ((b) > (e))  ; i += 1 - 2 * ((b) > (e)))
#define     Int         Int()
#define     Long        Long()
#define     all(x)      x.begin() , x.end()
#define     sz(x)       (int)x.size()
#define     ff          first
#define     ss          second
#define     pb          push_back
#define     eb          emplace_back
#define     mem(a)      memset(a , 0 ,sizeof a)
#define     memn(a)     memset(a , -1 ,sizeof a)

/*...Part - 06...*/
/*...... ! Code start from here ! ......*/

const int max_n = 1e5 + 5, mod = 1e9 + 7 ;

int dp[2][max_n] ;
vector < vector < int > > g ;

inline int mul(int a, int b){
	return (ll)a * b % mod ;
}

inline int add(int a, int b){
	a += b ;
	if(a >= mod)a -= mod ;
	return a ;
}

void dfs(int s, int p = 0){
	dp[0][s] = dp[1][s] = 1 ;
	for(int i : g[s]){
		if(i == p)continue ;
		dfs(i, s) ;
		dp[0][s] = mul(dp[0][s], add(dp[0][i], dp[1][i])) ;
		dp[1][s] = mul(dp[1][s], dp[0][i]) ;
	}
}

int main(){
    int test = 1 , tc = 0 ;
    while(test--){
        int n = Int ;
        g.resize(n + 1) ;
        for(int i = 1 ; i < n ;++i){
        	int x = Int, y = Int ;
        	g[x].pb(y) ;
        	g[y].pb(x) ;
        }
        dfs(1) ;
        cout << add(dp[0][1], dp[1][1]) << '\n' ;
    }
    return 0 ;
}

/*...Always look at the part - 04...*/
/*...............END................*/




Measured memory_bytes: 13440
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;


int main(){
  int a,b,c;cin>>a>>b>>c;
  cout<<(a*b*c)/max(a,max(b,c))/2;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var K int
	fmt.Scan(&K)
	q := []int{1, 2, 3, 4, 5, 6, 7, 8, 9}
	cnt := 0
	for {
		v := q[0]
		q = q[1:]
		cnt++
		if cnt == K {
			fmt.Println(v)
			return
		}
		r := v % 10
		switch {
		case r == 0:
			q = append(q, v*10, v*10+1)
		case 1 <= r && r <= 8:
			q = append(q, v*10+r-1, v*10+r, v*10+r+1)
		case r == 9:
			q = append(q, v*10+8, v*10+9)
		}
	}
}


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

public class Main {

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

        public InputReader(InputStream inputStream) {
            reader = new BufferedReader(new InputStreamReader(inputStream));
            tok = null;
        }

        public InputReader(String inputFile) throws FileNotFoundException {
            reader = new BufferedReader(new FileReader(inputFile));
            tok = null;
        }

        public String nextLine() {
            String c = "";
            try {
                c = reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }

            return c;
        }

        public String next() {
            while (tok == null || !tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(nextLine());
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
            }

            return tok.nextToken();
        }

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

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble(){
            return Double.parseDouble(next());
        }
    }

    public static void main(String args[]) {
        InputStream inputstream = System.in;
        OutputStream outputstream = System.out;
        InputReader in = new InputReader(inputstream);
        PrintWriter out = new PrintWriter(outputstream);
        Task solver = new Task();
        solver.solve(in, out);
        out.flush();
    }

    static class Task {
        public void solve(InputReader in, PrintWriter out) {
            int n=in.nextInt();
            int x=in.nextInt();
            int t=in.nextInt();
            int ans=00;
            if(n%x==0)
            ans=n*t/x;
            else{
                int a=n/x + 1;
                ans=a*t;
            }
            out.println(ans);
        }
    }
}

Measured memory_bytes: 32876
#include <iostream>
#include <cstdio>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <math.h>
#include <map>
#include <functional>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <typeinfo>
#define PI 3.14159265359
#define INF 99999999
#define rep(i, n) for(int i=0; i<n; i++)
#define REP(n) rep(i, n)
#define pb push_back
#define mp make_pair
typedef long long ll;
using namespace std;
typedef pair<int, int> P;

bool is_prime[50001];
int n;

void sieve(int n)
{
	for (int i=0; i<=n; i++) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for (int i=2; i<=n; i++)
	{
		if (is_prime[i])
		{
			for (int j=2*i; j<=n; j+=i) is_prime[j] = false;
		}
	}
}

int main()
{
	sieve(50000);

	while (cin >> n, n)
	{
		int ans = 0;
		for (int i=2; i<=n/2; i++)
		{
			if (is_prime[i] && is_prime[n - i]) ans++;
		}
		cout << ans << endl;
	}
	
	return 0;
}

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

// Template START
#define endl "\n"
#define async ios_base::sync_with_stdio(false); cin.tie(NULL);
#define int long long int
#define all(y) y.begin(), y.end()
#define present( x, y ) (x.find( y ) != x.end())
const int mod = (int)1e9 + 7 ;
template<class T>
auto matrix( int r, int c, T v ){
    return vector<vector<T>>( r, vector<T>( c, v ) ) ;
}
template<class T>
auto matrix( int o1, int o2, int o3, T v ){ 
    return vector<vector<vector<T>>>( o1, vector<vector<T>>( o2, vector<T>( o3, v ) ) ) ;
}
#define v vector
// Template END

int power( int x, int n ){
    if( n == 0 ) return 1 ;
    else if( n & 1 ) return ( x * power( (x*x) % mod, n / 2 ) ) % mod ;
    return power( (x*x) % mod, n / 2 ) % mod ;
}

signed main(){
    int n ; cin >> n ;
    v<pair<int,int>> coords(n) ;
    for( int i = 0 ; i < n ; i++ ) cin >> coords[i].first >> coords[i].second ;
    int pMax = coords[0].first + coords[0].second ;
    int pMin = pMax ;
    int mMax = coords[0].first - coords[0].second ;
    int mMin = mMax ;
    for( int i = 1 ; i < n ; i++ ){
        int temp1 = coords[i].first + coords[i].second ;
        int temp2 = coords[i].first - coords[i].second ;
        pMax = max( pMax, temp1 ) ;
        pMin = min( pMin, temp1 ) ;
        mMax = max( mMax, temp2 ) ;
        mMin = min( mMin, temp2 ) ;
    }
    cout << max( abs(pMax - pMin), abs(mMax - mMin) ) ;
    return 0 ;   
}          

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const ll mod = 1e9 + 7;

int main(){

  int n;cin>>n;
  vector<ll>sum(n+1,0),num(n+1,0);
  rep(i,0,n){
    ll a;cin>>a;
    sum[i+1]=num[i+1]=a;
    sum[i+1]+=sum[i];
    num[i+1]^=num[i];
  }

  ll ans=0;
  for(int i=1,j=1;i<=n;++i){
    for(;j<=n&&sum[j]-sum[i-1]==(num[j]^num[i-1]);++j);
    ans+=j-i;
  }
  
  out(ans);

  return 0;
}


Measured memory_bytes: 3328
#include<stdio.h>

int main( void ) 
{
	int a,b;
	int  res=0;
	int i;	
	while( EOF != scanf( "%d%d", &a, &b ) ) {
		res=a+b;
		a=10;
		for( i=1; ; i++ ) {
			b=res-a;
			if( 0<=b ) {
				a*=10;			
			} else {
				break;
			}
		}
		printf( "%d\n", i);
	}

	return 0;
}

Measured memory_bytes: 600
#include<stdio.h>
int main(){
	int x,y;
	for(;;){
	scanf("%d %d",&x,&y);
		if(x==0&&y==0){break;
		}else if(x<y){printf("%d %d\n",x,y);
		}else if(x>y){printf("%d %d\n",y,x);
		}else if(x==y){printf("%d %d\n",x,y);}
	}
	return 0;
}

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

int N,K;
int A[100010];
int ans = 0;

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


Measured memory_bytes: 256
I=input
n=int
for i in range(n(input())):
  I();t=[];x=0
  for i,j in zip(map(n,I().split()[::-1]),I()[::-1]):
    for k in t:i^=k*(i^k<i)
    j=n(j);t.append(i*(j^1));x|=(i>0)&j
  print(x)

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

using namespace std;
#define ll  long long
#define ld  long double
#define endl '\n'
#define FAST ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238463;
const int MAXN = 2e5 + 5;

void debug_out() {
    cerr << endl;
}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}

#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

int main() {
    FAST
    long double n;
    cin>>n;
    cout<<2.0*n*PI<<endl;

    return 0;
}


Measured memory_bytes: 3808