akhauriyash/Code-Regression huggingface dataset:
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
   return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
   os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll a,c=0;cin>>a;
  
  string b;cin>>b;
  c+=b[3]-'0';
  c+=10*(b[2]-'0');
  c+=100*(b[0]-'0');


  cout<<a*c/100<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long int64;
int main(){
	int n, m; cin >> n >> m;
    int sum = 0;
    for(int i = 0; i < m; i++){
    	int x; cin >> x;
        sum += x;
    }
    if(sum > n) cout << -1 << endl;
    else cout << (n - sum) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<vector>
#include<list>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<set>
using namespace std;
set<int>a;
void solve(int b[10],int i,string s,bool c[10],int n,int k) {
	for (int j = 0; j < n; j++) {
		if (c[j]) {
			if (i == k&&c[j]) {
				string u = s;
				s += to_string(b[j]);
				a.insert(stoi(s));
				s = u;
			}
			else {
				c[j] = false;
				solve(b, i+1, s+to_string(b[j]), c, n, k);
				c[j] = true;
			}
		}
	}
}
int main() {
	int n, k;
	while (cin >> n >> k&&n != 0 && k != 0) {
		a.clear();
		int b[10];
		bool c[10];
		for (int i = 0; i < n; i++) {
			cin >> b[i];
			c[i] = true;
		}
		k--;
		for (int i = 0; i < n; i++) {
			c[i] = false;
			solve(b, 1, to_string(b[i]),c,n,k);
			c[i] = true;
		}
		cout << a.size() << endl;
	}
}

Measured memory_bytes: 3264
#include <iostream>
#include <vector>
using namespace std;
int main(){vector<int>a(3),b(3);int f=0,s=0,t=0,o=0;for(int i=0;i<3;i++){cin>>a[i]>>b[i];switch(a[i]){case 1:f++;break;case 2:s++;break;case 3:t++;break;case 4:o++;break;}switch(b[i]){case 1:f++;break;case 2:s++;break;case 3:t++;break;case 4:o++;break;}}if(f>=3||s>=3||t>=3||o>=3)cout<<"NO";else if(f<3&&s<3&&t<3&&o<3)cout<<"YES";}


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

using namespace std;
typedef long long ll;
typedef long double ld;
using graph = vector<vector<int>>;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define all(x) (x).begin(),(x).end()
#define size(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))

#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000

#define pb push_back
#define mp make_pair
#define f first
#define s second

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

#define FIND(a,b) find(all(a),b)!=a.end()

long double ldabs(long double x){return x < 0 ? -x : x;}

int main(){
	int n;cin>>n;
	vector<ld> a(n);
	rep(i,n)cin>>a[i];
	ld ai,aj;
	sort(all(a));
	ai=a[n-1];
	ld tmp =500000000.0;
	for(ld x:a){
		if(chmin(tmp,ldabs(ai/2.0-x))){
			aj=x;
		}
	}
	cout << (ll)ai<< " "<<(ll)aj<<endl;
}



Measured memory_bytes: 1792
h,w,k = map(int,input().split())
s = [input() for _ in range(h)]
ans = [[0]*w for _ in range(h)]

num = 1
start = -1
for i,si in enumerate(s):
    count = 0
    if "#" in si:
        if start<0:start = i
        for j,sij in enumerate(si):
            if sij == "#":
                count += 1
                if count >= 2: num += 1
            ans[i][j] = num
        num += 1
    elif start>=0:
        for j in range(w):
            ans[i][j] = ans[i-1][j]

for i in range(start,0,-1):
    for j in range(w):
        ans[i-1][j] = ans[i][j]

for i in range(h):
    print(*ans[i])

Measured memory_bytes: 7552
import Foundation

func readInts() -> [Int]{
    readLine()!.split(separator: " ").map { Int($0)! }
}

func main(){
    let n = Int(readLine()!)!
    var ary = [String]()
    let counter = [Int](repeating: 1, count: n)
    for _ in 1...n {
        ary.append(readLine()!)
    }
    
    print(Dictionary(zip(ary, counter),uniquingKeysWith: +).count)
    
    
}

main()


Measured memory_bytes: 29404
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
using P = pair<int,int>;
const int MOD = 1000000007;

int main() {
    int w,h,n,ans=0;
    cin>>w>>h>>n;
    vector<vector<bool>> r(w,vector<bool>(h,true));
    rep(i,n) {
        int x,y,a;
        cin>>x>>y>>a;
        if (a==1) {
            rep(j,x) {
                rep(k,h) {
                    r[j][k]=false;
                }
            }
        } else if (a==2) {
            for (int j=x; j<w; j++) {
                rep(k,h) {
                    r[j][k]=false;
                }
            }
        } else if (a==3) {
            rep(j,w) {
                rep(k,y) {
                    r[j][k]=false;
                }
            }
        } else {
            rep(j,w) {
                for (int k=y; k<h; k++) {
                    r[j][k]=false;
                }
            }
        }
    }
    rep(i,w) {
        rep(j,h) {
            if (r[i][j]) ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
from collections import defaultdict

############ ---- USER DEFINED INPUT FUNCTIONS ---- ############
def inp():
    return(int(input().rstrip()))
def inlt():
    return(list(map(int,input().rstrip().split())))
def insr():
    s = input().rstrip()
    return(s[:len(s) - 1])
def invr():
    return(map(int,input().rstrip().split()))
################################################################
n,X,Y = invr()
ans = defaultdict(int)

for i in range(1,n):
    for j in range(i + 1,n + 1):
        if i < X:
            if j > Y:
                result = min(j - i,(X-i) + (j - Y) + 1)
            else:
                result = min(j - i,(X-i) + (Y - j) + 1)
        else:
            if j > Y:
                result = min(j - i,(i - X) + (j - Y) + 1)
            else:
                result = min(j - i,(i - X) + (Y - j) + 1)
        ans[result] += 1
    

for i in range(1,n):
    print(ans[i])


Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
using P = pair<int, int>;
const int mx = 100005;
int n, m, a, b, d[mx];
vector<int> G[mx];
vector<P> ans;
bool dfs(int p, int u){
	bool ptou = true;
	d[u] = d[p]+1;
	for(int nx: G[u]) if(!d[nx]){
		ptou ^= dfs(u,nx);
	}else if(d[u] > d[nx]+1){
		ans.push_back(P(u,nx));
		ptou ^= 1;
	}
	if(p+u) ans.push_back(ptou?P(p,u):P(u,p));
	return ptou;
}
int main(){
	scanf("%d%d", &n, &m);
	if(m%2) return 0*puts("-1");
	rep(i,m){
		scanf("%d%d", &a, &b);
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0,0);
	for(P it: ans) printf("%d %d\n", it.first+1, it.second+1);
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    ll r;
    cin >> r;
    cout << 3*r*r << endl;
}

Measured memory_bytes: 3552
'use strict'
const Main = (arg) => {
  let input = arg.trim().split('\n');
  let n = parseInt(input[0]);
  let dArr = input[1].split(' ').map(Number);
  // console.log({ n, dArr });

  dArr.sort((a, b) => a - b);
  let nL = dArr[(dArr.length) / 2 - 1];
  let nR = dArr[(dArr.length) / 2];
  // console.log({nL, nR})
  let answer = nR - nL;
  console.log(answer)



}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 28488
#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
	string a;
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]==',')
		{
			cout<<" ";
			continue;
		}
		cout<<a[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define FOR1(i, n) FOR(i, 1, n+1)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define int long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));

#define dl(line) cerr << "RUN: until " << (line) << "th line." << endl
#define dv(name, value) cerr << (name) << " is " << (value) << endl
#define da(v)  cerr << "["; REPI(itr, v){cerr << *itr << (itr != --v.end() ? ", " : "");} cerr << "]" << endl


signed main(){
  char s; cin >> s;
  printf("%c\n", s+1);
}


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

using namespace std;

int main(void) {
    int H, N, A;
    cin >> H >> N;

    for (int i = 0; i < N; i++) {
        cin >> A;
        H -= A;
        if (H <= 0) break;
    }

    cout << (H <= 0 ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int N=0,i=0,j=0,count=0;
  int A[10000];
  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  count=selsort(A,N);
  if(N>1){
    for(i=0;i<N;i++){
      if(i<N-1){
	printf("%d ",A[i]);
      }
      if(i==N-1){
	printf("%d",A[i]);
      }
    }
    printf("\n");
    printf("%d\n",count);
  }
  else {
    for(i=0;i<N;i++){
      printf("%d",A[i]);
    }
    printf("\n");
    printf("%d\n",count);
  }
  return 0;
}
int selsort(int A[], int N){
  int i=0,j=0,temp=0;
  int min=0;
  int count=0;
  for(i=0;i<=N-1;i++){
    min=i;
    for(j=i;j<=N-1;j++){
      if(A[j]<A[min]){
	min=j;
      }
    }
    temp=A[i];
    A[i]=A[min];
    A[min]=temp;
    if(i!=min)count++;
  }
  return count;
}



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

int main() {
    int n;
    cin >> n;
    vector<int> x(n);
    for(int i=0;i<n;i++){
        cin >> x.at(i);
    }
    int ans=100000000;
    for(int i=1;i<=100;i++){
        int total=0;
        for(int j=0;j<n;j++){
            total += (x.at(j)-i)*(x.at(j)-i);
        }
        ans = min(ans,total);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    A = list(map(int, input().split()))
    x = 0
    for a in A:
        x ^= a
    ret = [None]*N
    for i,a in enumerate(A):
        ret[i] = x ^ a
    print(*ret)



if __name__ == '__main__':
    main()

Measured memory_bytes: 31456
n=int(input())
A=sorted(map(int,input().split()))
B=sorted(map(int,input().split()))
C=sorted(map(int,input().split()))

def bisect_l(b):
    l=-1
    r=n
    while l+1<r:
        m=(l+r)//2
        if A[m]<b:
            l=m
        else:
            r=m
    return l

def bisect_r(b):
    l=-1
    r=n
    while l+1<r:
        m=(l+r)//2
        if C[m]>b:
            r=m
        else:
            l=m
    return r
r=0
for b in B:
    a=bisect_l(b)+1
    c=n-bisect_r(b)
    r+=a*c
print(r)

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

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

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

int main(void){

    int h, n;
    cin >> h >> n;
    int total = 0;
    roop(i, n) {
        int x; cin >> x;
        total += x;
    }

    cout << (h <= total ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using ll = long long;

int main() {
    int n; cin >> n;
    if (n % 1000 == 0) {
        cout << 0 << endl;
        return 0;
    }
    cout << 1000 - (n % 1000) << endl;
    return 0;
}

Measured memory_bytes: 3584
#include<iostream>
#include<iomanip>
using namespace std;
using ll = long long int;
ll w, h, x, y;


int main(void) {
	cin >> w >> h >> x >> y;

	cout << fixed << setprecision(15) << h * w / 2. << " " << (x * 2 == w && y * 2 == h) << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) {
		if ((ct = getcha()) == '-') {
			while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
			return -A;
		}
		else {
			A = ct - '0';
			while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';;
			return A;
		}
	}
	else {
		if ((ct = *ci++) == '-') {
			while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
			return -A;
		}
		else {
			A = ct - '0';
			while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';;
			return A;
		}
	}
}

const int mod = 1e9 + 7;
const int IMAX = 100000;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;
void pakuri_sort(int N, int A[]) {
	const int b = 8;
	int tmp[100001];
	rep(k, 4) {
		int kazu[1 << b] = {}, kazu2[1 << b] = {};
		rep(i, N) kazu[A[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu[i + 1] += kazu[i];
		for (int i = N - 1; i >= 0; i--) tmp[--kazu[A[i] >> k * b & ((1 << b) - 1)]] = A[i];
		k++;
		rep(i, N) kazu2[tmp[i] >> k * b & ((1 << b) - 1)]++;
		rep(i, (1 << b) - 1) kazu2[i + 1] += kazu2[i];
		for (int i = N - 1; i >= 0; i--) A[--kazu2[tmp[i] >> k * b & ((1 << b) - 1)]] = tmp[i];
	}
}
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), K = getint();

	int A[100000];
	rep(i, N) A[i] = getint() + (1 << 30);
	pakuri_sort(N, A);

	ll kotae = 0;
	for (int i = 0; i < min(N - K + 1, K - 1); i++) {
		kotae -= ll(f.fac[N - i - 1]) * f.ifac[N - i - K] % mod * A[i] % mod;
	}
	for (int i = K - 1; i < N - K + 1; i++) {
		kotae += (ll(f.fac[i]) * f.ifac[i - K + 1] - ll(f.fac[N - i - 1]) * f.ifac[N - i - K]) % mod * A[i] % mod;
	}
	for (int i = max(K - 1, N - K + 1); i < N; i++) {
		kotae += ll(f.fac[i]) * f.ifac[i - K + 1] % mod * A[i] % mod;
	}

	kotae %= mod;
	kotae = kotae * f.ifac[K - 1] % mod;

	printf("%lld", (kotae + mod) % mod);

	Would you please return 0;
}

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

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; }

int64_t dp[105][100005];

int main() {
  int64_t N, W;
  cin >> N >> W;
  vector<vector<int64_t>> vv(N, vector<int64_t>(2));
  for (int64_t i = 0LL; i < N; i++) {
    cin >> vv.at(i).at(0) >> vv.at(i).at(1);
  }
  for (int64_t i = 0LL; i <=W; i++) {
    if (i<vv.at(0).at(0)) dp[0][i]=0LL;
    if (i >= vv.at(0).at(0)) dp[0][i] = vv.at(0).at(1);
  }
  for (int64_t i = 0LL; i < N-1; i++) {
    for (int64_t j = 0LL; j <= W; j++) {
      if (j < vv.at(i+1).at(0)) {
        dp[i+1][j]=dp[i][j];
      }
      else {
        dp[i+1][j] = max(dp[i][j], dp[i][j-vv.at(i+1).at(0)] + vv.at(i+1).at(1));
      }
    }
  }
  cout << dp[N-1][W] << endl;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define rep(i, n)        for(int i=0; i<(int)(n); ++i)
int main() {
  int a,b,c,d;
  cin>>a>>b>>c;
  d=a+b+c;
  cout<<min(a,min(b,c))+(d-max(a,max(b,c))-min(a,min(b,c)));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<1000000007>;

vector<pair<long long, long long>> prime_factorize(long long n){
    vector<pair<long long, long long>> res;
    for (long long p = 2; p * p <= n; p++)
    {
        if(n % p != 0) continue;
        int num = 0;
        while(n % p == 0){ ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if(n != 1) res.push_back(make_pair(n, 1));
    return res;
}

int main() {
    int N; cin >> N;
    vector<long long> A(N);
    vector<long long> num(1100000, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        auto pf = prime_factorize(A[i]);
        for (auto p : pf) num[p.first] = max(num[p.first], p.second);
    }

    mint LCM = 1;
    for (int v = 2; v < 1100000; v++)
    {
        LCM *= modpow(mint(v), num[v]);
    }

    mint res = 0;
    for (auto a : A)
    {
        res += LCM / a;
    }
    cout << res << endl;
}

Measured memory_bytes: 8960
//Catchharsh
    //I Luv Kunj017
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 998244353;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (ll x,ll n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
          for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
         if(prime[i]==0)
           seve.pb(i);
       }
    }
    int main()
    {   
         IOS;
         ll n,m,i,j,d,k;
         cin>>n>>d;
         vector<ll> v[n];
         for(i=0;i<n;i++)
         {
           for(j=0;j<d;j++)
           {
             cin>>k;
             v[i].pb(k);
           }
         }
         ll cnt=0;
         for(i=0;i<n;i++)
         {
           for(j=i+1;j<n;j++)
           {
            // cout<<i<<endl;
             vector<ll> a=v[i];
             vector<ll> b=v[j];
             ll temp=0;
             for(k=0;k<d;k++)
             {
              // cout<<a[k]<<" "<<b[k]<<endl;
              temp+=power(a[k]-b[k],2);
             } 
             // cout<<temp<<endl;
             if(sqrt(temp)-(ll)sqrt(temp)==0)
              cnt++;
           }
         }
         cout<<cnt;
    }

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int gcd(int a, int b) {
	if (b == 0) return a;
	else return gcd(b, a%b);
}

int main() {
	int N, X;

	cin >> N >> X;

	int tmp;
	int g;
	cin >> g;
	g = abs(g - X);
	for (int i = 1; i < N; i++) {
		cin >> tmp;
		g = gcd(abs(tmp - X), g);
	}

	cout << g << endl;

	return 0;
}

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

long long findAns(long long n, long long a, long long b){
    if(a - 1 < n - b) return a + (b - a - 1)/2;
    else return n - b + 1 + (b - a - 1)/2;
}

int main(){
    long long A, B, N;
    cin >> N >> A >> B;

    if(N == 2){
        cout << 1 << endl;
    } else if((B - A) % 2 == 0){
        cout << (B - A) / 2 << endl;
    } else{
        cout << findAns(N, A, B) << endl;
    }
}

Measured memory_bytes: 3632
import copy

D = int(input())
C = list(map(int, input().split()))
S = []
for _ in range(D):
    s_row = list(map(int, input().split()))
    S.append(s_row)

results = []

# Cを無視して最大値をとる
# for d in range(D):
#     s_row = S[d]
#     max_value = max(s_row)
#     max_index = s_row.index(max_value)
#     results.append(max_index+1)

# 26種類順番にやる
# for d in range(D):
#     results.append((d % 26) + 1)
#     results.append(max_index+1)

# 次の日に減る分も考慮して選ぶ
last = [0 for i in range(26)]
next_costs = [0 for i in range(26)]

for d in range(D):

    for i in range(26):
        next_costs[i] = C[i] * (d+1-last[i])

    result = -100000
    next_costs_sum = sum(next_costs)
    result_idx = -1
    for i in range(26):
        tmp_result = S[d][i] - (next_costs_sum - C[i] * (d+1-last[i]))
        if tmp_result > result:
            result = tmp_result
            result_idx = i
    last[result_idx] = d + 1
    results.append(result_idx + 1)

for result in results:
    print(result)


Measured memory_bytes: 69532
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007





int main()
{
	FAST;
	ll n;
	cin >> n;
	ll m;
	cin >> m;
	ll a[n+5];
	ll x = 0;
	ll mn = INT_MAX;
	for(ll i = 0; i < n; i ++){
		cin >> a[i];
		mn = min(mn, a[i]);
	}
	ll ans = 0;
	n -= m;
	ans++;
 
	if (n > 0) {
		m --;
		ans += (n + m - 1) / m;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4324
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   debug::instance

using namespace std;

template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

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

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

void solve() {
	int A = fetch<int>();
	int B = fetch<int>();
	int M = fetch<int>();
	auto left = fetch_vec<ll>(A);
	auto right = fetch_vec<ll>(B);
	ll answ = *min_element(left.begin(), left.end()) + *min_element(right.begin(), right.end());
	for(int id = 0; id < M; ++id) {
		int i = fetch<int>() - 1;
		int j = fetch<int>() - 1;
		ll c  = fetch<ll>();
		answ = min(answ, left[i] + right[j] - c);
	}
	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
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; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}



signed main(){

  int n,a,b;
  string str;
  string c[2];
  FOR(i,2) cin >> c[i];
  if(c[0][0]==c[1][2] && c[0][1]==c[1][1] && c[0][2]==c[1][0])
    cout <<"YES\n";
  else
    cout <<"NO\n";

  return 0;
}



struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ri register int
#define rep(i,a,b) for(ri i=(a);i<=(b);++i)
#define rep2(i,a,b,c) for(ri i=(a);i<=(b);i+=(c))
#define REP(i,a,b) for(ri i=(a);i>=(b);--i)
#define REP2(i,a,b,c) for(ri i=(a);i>=(b);i-=(c))
using namespace std;

string s3[3]={
"aab",
"c.b",
"cdd"
};
string s4[4]={
"aaef",
"bbef",
"ghcc",
"ghdd"
};
string s5[5]={
"aabbf",
"ccg.f",
"ddgee",
"..hij",
"..hij"
};
string s6[6]={
"aabbcc",
"ddeeff",
"ghi...",
"ghi...",
"...jkl",
"...jkl"
};
string s7[7]={
"aabbcc.",
"ddee..h",
"ffgg..h",
"....ijk",
"....ijk",
"....lmn",
"....lmn"
};
char a[1005][1005];

signed main()
{
	ios::sync_with_stdio(0);
	ri n;cin>>n;
	if(n==2)return puts("-1"),0;
	rep(i,1,n)rep(j,1,n)a[i][j]='.';
	if(n==3){rep(i,0,2)cout<<s3[i]<<endl;return 0;}
	rep2(i,1,n-7,4){
		rep(j,0,3)rep(k,0,3)a[i+j][i+k]=s4[j][k];
	}
	ri x=(n%4)+4,i=n-(x-1);
	if(x==4)rep(j,0,3)rep(k,0,3)a[i+j][i+k]=s4[j][k];
	if(x==5)rep(j,0,4)rep(k,0,4)a[i+j][i+k]=s5[j][k];
	if(x==6)rep(j,0,5)rep(k,0,5)a[i+j][i+k]=s6[j][k];
	if(x==7)rep(j,0,6)rep(k,0,6)a[i+j][i+k]=s7[j][k];
	rep(i,1,n){rep(j,1,n)cout<<a[i][j];cout<<endl;}
	return 0; 
}

Measured memory_bytes: 2176
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        //ソートするため配列に
        String[] S = s.split("");
        String[] T = t.split("");
        //ソート
        Arrays.sort(S);
        Arrays.sort(T, Comparator.reverseOrder());
        //compareToするために配列を変数に戻す
        String a = "";
        String b = "";
        for(int i = 0; i < S.length; i++) a += S[i];
        for(int i = 0; i < T.length; i++) b += T[i];
        //S<T -> S-T==-1
        int flag = a.compareTo(b);

        if(flag < 0) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

ll sumtoN(ll n){
  if(n%2==0){
    return (n/2)*(n+1);
  }
  else{
    return (((n-1)/2)*n+n);
  }
}

int main(){
  ll N;
  cin >> N;
  ll ans = sumtoN(N)-N;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  string taro, hanako;
  int t = 0, h = 0;
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> taro;
    cin >> hanako;
    if (taro == hanako)
    {
      t++;
      h++;
    }
    else if (taro > hanako)
    {
      t += 3;
    }
    else if (taro < hanako)
    {
      h += 3;
    }
  }
  cout << t << " " << h << "\n";
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < n; ++i)
#define FOR(i, b, n) for (ll i = b; i < n; ++i)

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

void solve(ll a, ll b, ll c, ll d) {
  cout << max(max(a * c, b * d), max(a * d, b * c)) << endl;
}

int main(){
  // int 3E4  long 2E9  ll 9E18
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll a;
  cin >> a;
  ll b;
  cin >> b;
  ll c;
  cin >> c;
  ll d;
  cin >> d;

  solve(a, b, c, d);

  return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> 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; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n,ans=1; scanf("%d",&n);
    while(ans<=n)ans*=2;
    printf("%d\n",ans/2);
    return 0;
}


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

int main(){
    string s;
    cin >> s;
    if (s == "AAA" || s == "BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
inline int read() {
	int f=1,x=0;char ch=getchar();
	while(!isdigit(ch)) {if(ch=='-') f=-1;ch=getchar();}
	while(isdigit(ch)) {x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
int main() {
	int n,k;
	char str[20];
	n=read();
	scanf("%s",str);
	k=read();
	for(int i=0;i<n;i++) {
		if(str[i]!=str[k-1]) str[i]='*';
	}
	printf("%s",str);
	return 0;
}


Measured memory_bytes: 256
//! Framework <https://github.com/vain0x/procon>

#![allow(non_snake_case)]
#![allow(unused_imports)]

use std::collections::*;

pub struct Scan(Box<dyn Iterator<Item = &'static str>>); // '

impl Scan {
    fn new() -> Self {
        let mut buf = String::new();
        let read_line = move || {
            std::io::stdin().read_line(&mut buf).unwrap();
            Box::leak(buf.split_off(0).into_boxed_str()).split_whitespace()
        };
        Scan(Box::new(std::iter::repeat_with(read_line).flatten()))
    }

    pub fn word<T: std::str::FromStr>(&mut self) -> T {
        self.0.next().unwrap().parse().ok().unwrap()
    }

    pub fn list<T: std::str::FromStr>(&mut self, len: usize) -> Vec<T> {
        std::iter::repeat_with(|| self.word()).take(len).collect()
    }
}

fn main() {
    let mut scan = Scan::new();

    let A = scan.word::<u64>();
    let B = scan
        .word::<String>()
        .chars()
        .filter(|&c| c != '.')
        .collect::<String>()
        .parse::<u64>()
        .unwrap();

    println!("{}", A * B / 100);
}


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

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

    ios_base::sync_with_stdio(false);cin.tie(NULL);
    ll a[2],b[2];
    cin>>a[0]>>a[1]>>b[0]>>b[1];
    ll ans=-1e18;
    for(int i=0;i<2;i++){
        for(int j=0;j<2;j++){
            ans=max(ans,a[i]*b[j]);
        }
    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3644
price = [1, 5, 10, 50, 100, 500]

while True:
    values = list(map(int, input().split()))
    p, n = values[0], values[1:]
    ans = 1e100
    if p == 0:
        break

    p_sum = sum(map(lambda s: s[0] * s[1], zip(price, n)))

    for change in range(1000):
        total = p + change
        pay = [0] * 6
        for i in reversed(range(6)):
            if total >= price[i]:
                pay[i] = min(n[i], int(total / price[i]))
                total -= pay[i] * price[i]

        if total > 0:
            break

        coins = sum(pay)

        _change = change
        for i in reversed(range(6)):
            if _change >= price[i]:
                coins += int(_change / price[i])
                _change %= price[i]

        ans = min(ans, coins)

    print(ans)

Measured memory_bytes: 6768
#include<bits/stdc++.h>
using namespace std;
typedef  long long  ll;
ll mod=1000000007;
ll power(ll a,ll b){
    ll res=1;
    while(b){
        if(b&1)
        res=(res*a)%mod;
        a=(a*a)%mod;
        b/=2;
    }
    return res;
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
        #endif
        ll n;cin>>n;
        ll ans;
        ans=power(10,n);
        ans=(ans-power(9,n)+mod)%mod;
        ans=(ans-power(9,n)+mod)%mod;
        ans=(ans+power(8,n))%mod;
        cout<<ans;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> vec;
	rep(i, N)
	{
		int	a;
		cin >> a;
		switch (a)
		{
			case 0:
				int	b;
				cin >> b;
				vec.push_back(b);
				break;
			case 1:
				int	c;
				cin >> c;
				cout << vec.at(c) << endl;
				break;
			case 2:
				vec.pop_back();
				break;
		}
	}
}



Measured memory_bytes: 3856
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    static class Solver {
        // int INF = (1 << 30) - 1;
        // long L_INF = (1L << 62) - 1;
        // long MOD = (long) 1e9 + 7;

        int S, W;
        // int[] A;

        // write your code
        public void solve(InputReader in, PrintWriter out) {
            S = in.nextInt();
            W = in.nextInt();
            // A = new int[N];
            // for (int i = 0; i < N; i++) {
            // A[i] = in.nextInt();
            // }

            if (S <= W) {
                out.println("unsafe");
            } else {
                out.println("safe");
            }
        }

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

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

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

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

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

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

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


Measured memory_bytes: 32844
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
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; }

int main() {
  ll x, k, d; cin >> x >> k >> d;

  ll ans = 0;
  x = abs(x);
  ll div = x / d;
  if(div > k){
    ans = x - k * d;
  } else {
    k -= div;
    k %= 2;
    ans = abs(x % d - k * d);
  }

  cout << ans << endl;
}


Measured memory_bytes: 3632
sheet = [[0 ,300,500,600,700,1350,1650],
         [6 ,  0,350,450,600,1150,1500],
         [13,  7,  0,250,400,1000,1350],
         [18, 12,  5,  0,250, 850,1300],
         [23, 17, 10,  5,  0, 600,1150],
         [43, 37, 30, 25, 20,   0, 500],
         [59, 52, 45, 40, 35,  15,   0]]

while 1:
    s = int(raw_input())-1
    if s == -1: break
    st = int(raw_input().replace(" ",""))
    g = int(raw_input())-1
    gt = int(raw_input().replace(" ",""))
    s,g = min(s,g),max(s,g)
    dist = sheet[g][s]
    cost = sheet[s][g]
    if dist <= 40 and (1730 <= st <= 1930 or 1730 <= gt <= 1930):
        cost = cost/2
        cost = cost/100*100 + (cost%100+49)/50*50
    print cost

Measured memory_bytes: 4272
#include <bits/stdc++.h>
#define maxn 202333
using namespace std;
const auto int_limits = numeric_limits<int> ();
long long x[maxn], y[maxn];
int main() {
	long long n, Mia, Maa, Mib, Mab;
	Mia = Mib = int_limits.max();
	Maa = Mab = int_limits.min();
	cin >> n;
	for(int i = 1; i <= n; ++i) cin >> x[i] >> y[i];
	for(int i = 1; i <= n; ++i) {
		Mia = min(Mia, x[i] - y[i]);
		Maa = max(Maa, x[i] - y[i]);
		Mib = min(Mib, x[i] + y[i]);
		Mab = max(Mab, x[i] + y[i]);
	}
	cout << max(Maa - Mia, Mab - Mib);
	return 0;
}

Measured memory_bytes: 6644
using System;
class Bamboo
{
	static void Main(string[] args)
	{
		while (true)
		{
			string[] input = Console.ReadLine().Split(' ');
			int m = int.Parse(input[0]);
			int n = int.Parse(input[1]);
			if (m == 0 && n == 0) break;
			bool[] year = new bool[7368792];
			for (int i = 1; i < n; i++)
			{
				for (int j = 1; m * j < 7368792; j++)
				{
					year[m * j] = true;
				}
				m = getNextFalseYear(year, m);
			}
			int r = getNextFalseYear(year, m);
			while (year[r])
			{
				r++;
			}
			Console.WriteLine(r);
		}
	}
	static int getNextFalseYear(bool[] year, int m)
	{
		for (int i = m + 1; i < 7368792; i++)
		{
			if (!year[i]) return i;
		}
		return 0;
	}
}


Measured memory_bytes: 44192
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define int long long
vector<vector<pair<int,int> > > g;
vector<int > h;
vector<int> cnt;
int n;
int s,e,t;
bool ok;
bool dfs(int id,int pre){
    if(id==e){
        
        return true;
    }
    for(auto xx:g[id]){
        int x = xx.second;

        if(x==pre)continue;
            if(dfs(x,id)){
                h[id] = x;
                return true;
            }
        
    }
    return false;
}

void dfs2(int id,int pre){
    int cnt = 1;
    if(id==s){
        cnt = 0;
    }
    int K = inf;
    //cerr << h[id] << endl;
    for(auto& xx:g[id]){
        int x = xx.second;
        if(x==pre)continue;
        if(x!=h[id]){
            xx.first -= g[x].size();
            dfs2(x,id);
        }
        if(x==h[id]){
            //cerr << id << " " << x << endl;
            K = xx.first;
        }
        
        //cerr << xx.first << " " << id << " " << x << endl;
    }
    sort(g[id].begin(),g[id].end());
    for(auto xx:g[id]){
        int k = xx.first;
        int x = xx.second;
        if(x==pre)continue;
        if(x==h[id])continue;
        //cerr << id << " " <<  cnt << " " << k << endl;
        if(cnt>=k){
            ok = false;
        }else{
            cnt++;
        }
    }
    //cerr << cnt <<  " " << K << endl;
    if(cnt>=K)ok = false;
    if(h[id]!=-1)dfs2(h[id],id);
}

signed main(){
    int n;
    cin >> n;
    cin >> t >> s >> e;
    g.resize(n);
    h.resize(n,-1);
    s--;e--;
    rep(i,n-1){
        int a,b,w;
        cin >> a >> b >> w;
        a--;b--;
        if(t==0){
            g[a].push_back(MP(inf,b));
            g[b].push_back(MP(inf,a));
        
        }else{
            g[a].push_back(MP((w+t-1)/t,b));
            g[b].push_back(MP((w+t-1)/t,a));
        }
    }
    
    ok = true;
    dfs(s,-1);
    dfs2(s,-1);
    if(ok){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 14656
import sys
input = sys.stdin.readline

def main():
    k, n = map(int, input().split())
    a = list(map(int, input().split()))
    a += [k + a[0]]

    maxi = 0
    ind = 0
    for i in range(n):
        if maxi < a[i+1] - a[i]:
            maxi = a[i+1] - a[i]
            ind = i

    for i in range(ind+1, n):
        yield a[i+1] - a[i]

    for i in range(0, ind):
        yield a[i+1] - a[i]


print(sum(main()))

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

using namespace std;
int main()
{
    int M = 20010;
    unordered_set<int> sqsum;
    for (int i = 0; i*i < M; i++) {
        for (int j = 0; j*j < M; j++) {
            sqsum.insert(i*i + j*j);
        }
    }
    vector<int> sqsump(M);
    for (int i : sqsum) for (int j : sqsum) {
        if (i*j < M) sqsump[i*j]++;
    }
    int N; cin >> N;
    while (N--) {
        int m, n; cin >> m >> n;
        cout << (sqsump[m*m+n*n] < 3 ? "P" : "C") << endl;
    }
    return 0;
}

Measured memory_bytes: 3460
#include<stdio.h>
void swap(int* a, int* b){
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}
int main(void) {
    int a, b;
    while(1) {
        scanf("%d%d", &a, &b);
        if(a == 0 && b == 0) break;
        if(a > b) swap(&a, &b);
        printf("%d %d\n", a, b);
    }
    return 0;
}


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

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}

int main() {
  int n,r=0,b=0;
  string s;
  cin>>n>>s;
  for(int i=0;i<n;i++){
    if(s[i]=='R') r++;
    if(s[i]=='B') b++;
  }
  if(r>b){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256