akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
// const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> a(N), b(N);
    for (int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    for (int i = 0; i < N; i++) {
        cin >> b.at(i);
    }

    ll cnt[2] = {0};
    for (int i = 0; i < N; i++) {
        if (a[i] < b[i]) {
            cnt[0] += (b[i] - a[i]) / 2;
        } else {
            cnt[1] += a[i] - b[i];
        }
    }
    cerr << cnt[0] << " " << cnt[1] << endl;
    if (cnt[1] > cnt[0]) {
        cout << "No\n";
    } else
        cout << "Yes\n";
}


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

int main() {
  int n;
  cin >> n;
  cout << n * 800 - (n / 15 * 200) << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil
from operator import itemgetter
from copy import deepcopy
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
inf = 10**17
mod = 10**9 + 7

cand=[111,222,333,444,555,666,777,888,999]
n=I()
for i in range(n,1000):
    if i in cand:
        print(i)
        sys.exit()

Measured memory_bytes: 3572
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
ans=0
j=0
for i in a:
	ans+=b[i-1]
	if i==j+1 and i!=1:
		ans+=c[j-1]
	j=i
print(ans)

Measured memory_bytes: 3064
#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)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define fi first
#define se second
#define INF 1000000009
#define LLINF 1000000000000000009LL
using ll = long long;

const int D = 60;
const int MAX_N = 200009;

int to[D][MAX_N];

int main() {
  int n; ll k;
  cin >> n >> k;
  rep(i,n) {
    cin >> to[0][i];
    to[0][i]--;
  }
  rep(i,D-1) {
    rep(j,n) {
      to[i+1][j] = to[i][to[i][j]];
    }
  }
  int ans = 0;
  for (int i = D-1; i>=0; i--) {
    ll l = 1LL<<i;
    if (l <= k) {
      k -= l;
      ans = to[i][ans];
    }
  }
  cout << ans + 1 << endl;
  return(0);
}


Measured memory_bytes: 50516
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}

int main(void) {
  ll r, d, x;
  cin >> r >> d >> x;
  ll i;
  for(i=0; i<10; i++) {
    pt(r*x-d);
    x=r*x-d;
  }
  
  
  
  
}


Measured memory_bytes: 384
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
int main() 
{ 
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ll n;
  cin>>n;
  ll arr[n];
  ll s = 0;
  for(ll i=0;i<n;i++){
    cin>>arr[i];
    s ^= arr[i];
  }
  for(ll i=0;i<n;i++){
    cout<<(arr[i]^s)<<" ";
  }
  cout<<"\n";
	return 0; 
}
 

Measured memory_bytes: 5208
#include<iostream>
#define rep(i,n) for(int=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main(){
    int N;
    cin >> N;
    int ans=1;
    int i=1;
    int tmp=i*i;
    while(tmp<=N){
        i++;
        if(tmp>N){
            break;
        }else{
            ans=tmp;
        }
        tmp=i*i;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const ll MOD = (ll)1000000007;//10^9+7
const ll INF2 = (ll)100000000000000000;//10^18


int main() {
    string str;
    cin>>str;
    string ans;

    for(auto s: str){
        if(s=='0'){
            ans.PB('0');
        }else if(s=='1'){
            ans.PB('1');
        }else{
            if(ans.size())  ans.pop_back();
        }
    }
    cout<<ans<<endl;
}


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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/detail/standard_policies.hpp>

#define f first
#define s second

#define pb push_back
#define pp pop_back
#define mp make_pair

#define sz(x) (int)x.size()
#define sqr(x) ((x) * 1ll * (x))
#define all(x) x.begin(), x.end()

#define rep(i, l, r) for (int i = l; i <= r; i++)
#define per(i, l, r) for (int i = l; i >= r; i--)

#define dbg(x) cerr << (#x) << " --> " << (x) << nl;
#define Kazakhstan ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);

#define nl '\n'
#define ioi exit(0);

#define Toktama ""

using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
//typedef tree < pair <int, int>, null_type, less < pair <int, int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 1e5 + 7, inf = 1e9 + 7, mod = 1e9 + 7;
const ll linf = (ll)1e18 + 7;
const int dx[] = {-1, 0, 1, 0, 1, -1, -1, 1}, dy[] = {0, 1, 0, -1, 1, -1, 1, -1};

int get_int() {
  char x = getchar();
  bool mns = 0;
  while (!isdigit(x)) mns |= x == '-', x = getchar();
  int res = 0;
  while (isdigit(x)) res = res * 10 + x - '0', x = getchar();
  if (mns) res = -res;
  return res;
}
void add(int &x, int y) {
  x += y;
  if (x >= mod) x -= mod;
  if (x < 0) x += mod;
}
int mult(int x, int y) {
  return x * 1ll * y % mod;
}
int sum(int x, int y) {
  add(x, y);
  return x;
}

int n;
int p[N], lvl[N];
vector < pair <int, pair <int, int> > > g;
struct node {
  int v, u, cost;
  node(int v, int u, int cost) : v(v), u(u), cost(cost) {}
  bool operator < (const node &x) {
    return cost < x.cost;
  }
};
int get(int x) {
  if (p[x] == x) return x;
  return p[x] = get(p[x]);
}
bool unit(int x, int y) {
  int px = get(x), py = get(y);
  if (px == py) return 0;
  if (lvl[px] > lvl[py]) p[py] = px;
  else if (lvl[py] > lvl[px]) p[px] = py;
  else p[px] = py, lvl[px]++;
  return 1;
}
bool cmpx(pair <int, pair <int, int> > l, pair <int, pair <int, int> > r) {
  return l.s.f < r.s.f;
}
bool cmpy(pair <int, pair <int, int> > l, pair <int, pair <int, int> > r) {
  return l.s.s < r.s.s;
}
void solve() {
  n = get_int();
  rep(i, 1, n) {
    int x = get_int(), y = get_int();
    g.pb({0, {x, y}});
  }
  sort(all(g));
  g.erase(unique(all(g)), g.end());
  n = sz(g) - 1;
  rep(i, 0, n)
    g[i].f = i, p[i] = i, lvl[i] = 1;
  sort(all(g), cmpx);
  vector <node> a;
  rep(i, 0, n) {
    rep(j, i + 1, min(n, i + 50))
      a.pb(node(g[i].f, g[j].f, min(abs(g[j].s.f - g[i].s.f), abs(g[j].s.s - g[i].s.s))));
  }
  sort(all(g), cmpy);
  rep(i, 0, n) {
    rep(j, i + 1, min(n, i + 50))
      a.pb(node(g[i].f, g[j].f, min(abs(g[j].s.f - g[i].s.f), abs(g[j].s.s - g[i].s.s))));
  }
  sort(all(a));
  ll ans = 0;
  for (auto i : a)
    if (unit(i.v, i.u)) ans += i.cost;
  cout << ans;
}
int main() {
  #ifndef Toktama
    freopen (Toktama".in", "r", stdin);
    freopen (Toktama".out", "w", stdout);
  #endif
  int t = 1;
  while (t--)
    solve();
  ioi
}


Measured memory_bytes: 200924
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n = x / 100;
    int r = x % 100;

    cout << (r <= n * 5) << endl;

    return 0;
}

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

struct UnionFind {
  vector<int> par;
  vector<int> count;
  UnionFind(int N) : par(N), count(N, 1) {
    for(int i = 0; i < N; ++i) {
      par[i] = i;
    }
  }
  int root(int x) {
    if(par[x] == x) {
      return x;
    }
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    auto rx = root(x);
    auto ry = root(y);
    if(rx == ry) {
      return;
    }
    par[rx] = ry;
    count[ry] += count[rx];
  }
  int size(int x) { return count[root(x)]; }
  bool same(int x, int y) { return root(x) == root(y); }
};

int main() {
  int N, M;
  cin >> N >> M;
  vector<UnionFind> ufs(M, UnionFind(N));
  int a, b;
  for(int i = 0; i < M; ++i) {
    cin >> a >> b;
    for(int j = 0; j < M; ++j) {
      if(i != j) {
        ufs[j].unite(a - 1, b - 1);
      }
    }
  }
  int ans = 0;
  for(int i = 0; i < M; ++i) {
    if(ufs[i].size(0) != N) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {

	var a int

	if sc.Scan() {
		a, _ = strconv.Atoi(sc.Text())
	}

	fmt.Printf("%d:%d:%d\n", a/3600, a%3600/60, a%3600%60)
}



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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}


void solve(std::istream &in, std::ostream &out) {
  int L;
  in >> L;
  int r = 0;
  while ((1 << (r + 1)) <= L) ++r;
  out << r + 1 << ' ' << (2 * r) + (__builtin_popcount(L)) - 1 << '\n';
  for (int i = 1; i <= r; ++i) {
    out << i << ' ' << i + 1 << ' ' << 0 << '\n';
    out << i << ' ' << i + 1 << ' ' << (1 << (i - 1)) << '\n';
  }
  int ff = (1 << 20) - 1;
  for (int i = 0; i <= 19; ++i) {
    ff -= 1 << i;
    if ((L & ff) == 0) break;
    if (L >> i & 1) {
      out << i + 1 << ' ' << r + 1 << ' ' << (L & ff) << '\n';
    }
  }
}

Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>
#include <atcoder/all>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

char field[100][101];

auto main() -> i32 {
	i32 h, w;
	scanf("%d%d", &h, &w);
	for (i32 i = 0; i < h; ++i) {
		scanf("%s", field[i]);
	}
	atcoder::mf_graph<i32> graph(h * w + 2);
	i32 s = h * w;
	i32 t = h * w + 1;
	for (i32 y = 0; y < h; ++y) {
		for (i32 x = 0; x < w; ++x) {
			if (field[y][x] == '#') continue;
			if ((y + x) % 2 == 0) {
				i32 v = y * w + x;
				graph.add_edge(s, v, 1);
				if (y > 0 && field[y - 1][x] == '.') {
					graph.add_edge(v, (y - 1) * w + x, 1);
				}
				if (x > 0 && field[y][x - 1] == '.') {
					graph.add_edge(v, y * w + (x - 1), 1);
				}
				if (y + 1 < h && field[y + 1][x] == '.') {
					graph.add_edge(v, (y + 1) * w + x, 1);
				}
				if (x + 1 < w && field[y][x + 1] == '.') {
					graph.add_edge(v, y * w + (x + 1), 1);
				}
			} else {
				graph.add_edge(y * w + x, t, 1);
			}
		}
	}

	printf("%d\n", graph.flow(s, t));
	for (auto e : graph.edges()) {
		if (e.from == s || e.to == t || e.flow == 0) {
			continue;
		}
		i32 y0 = e.from / w;
		i32 x0 = e.from % w;
		i32 y1 = e.to / w;
		i32 x1 = e.to % w;
		if (std::abs(y0 - y1) == 1) {
			field[std::min(y0, y1)][x0] = 'v';
			field[std::max(y0, y1)][x1] = '^';
		} else {
			field[y0][std::min(x0, x1)] = '>';
			field[y1][std::max(x0, x1)] = '<';
		}
	}

	for (i32 i = 0; i < h; ++i) {
		printf("%s\n", field[i]);
	}

	return 0;
}


Measured memory_bytes: 5588
//! 尺卂乃卂.卂ﾌ乇乇ㄒ
#include<bits/stdc++.h>
//#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
//Using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> Ordered_set;

#define ll              long long
#define int             long long
#define ld             long double
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define vii             vector<vi>
#define vip            vector<pii>
#define mii             map<int,int>
#define mip             map<pair<int,int>,int>
#define mic             map<char,int> 
#define all(v)          v.begin(),v.end()  
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define lb(x)           (x&(-x))
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
#define itr(it,v)          for(auto it:v)
#define show(arr,n)     for(int i=0;i<n;i++) cout<<arr[i]<<" "; cout<<"\n";
#define fi(i,n)         for(int i=0;i<n;i++)
#define fir(i,k,n)       for(int i=k;k<n?i<n:i>n;k<n?i+=1:i-=1)
#define ff               first 
#define ss               second
#define deb(x) cout << #x << "=" << x << endl
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define check(x) (x && cout<<"Yes\n")||(cout<<"No\n");
#define fin(s)          freopen(s,"r",stdin);  
#define fout(s)         freopen(s,"w",stdout);

const ld pi = 3.141592653589793238462643383279502884;
const int xd[]={-1,0,1,0};
const int yd[]={0,-1,0,1};
int XX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int YY[] = { -1, 0,  1, -1, 1, -1, 0, 1 };

int expo(int a,int b,int m);
int mmi(int a,int m);
void ipgraph(int m);

const int N=5*(1e5)+10;
vii adj(N);
int a[N];

void  solve(){

}
int32_t main()
{
    FIO
    int a,b,c,d; cin>>a>>b>>c>>d;
    int x=max(a*c,max(a*d,max(b*c,b*d)));
    cout<<x<<"\n";
    return 0;

}

void ipgraph(int m){
    int i, u, v;
    while(m--){
          cin>>u>>v;
         u--, v--;
    adj[u].pb(v);
    adj[v].pb(u);
    }
}
int expo(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return a;
    int val=(expo(a,b/2,m)*expo(a,b/2,m))%m;
    if(b & 1) return (val*a)%m;
    else return val;
}
int mmi(int a,int m){
    return expo(a,m-2,m);
}

Measured memory_bytes: 15040
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define pb              push_back
#define int             long long
#define mp              make_pair
#define pr              pair<long long,long long>
#define vr              vector<long long>
#define mod1            1000000007
#define mod2            998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define ll              long long
#define ld	            long double
#define w(x)            int x; cin>>x; while(x--)

int32_t sum_of_digit(int n)  
{  
    if (n == 0)  
    return 0;  
    return (n % 10 + sum_of_digit(n / 10));  
}  



int32_t main()
{ 
    int n;
    cin>>n;
    
    int ac=0,tle=0,wa=0,re=0;
    for(int i=0;i<n;i++)
    {
        string s;
        cin>>s;
        if(s=="TLE")
        tle++;
        else if(s=="AC")
        ac++;
        else if(s=="WA")
        wa++;
        else
        re++;
    }
    cout<<"AC x "<<ac<<"\n";
    cout<<"WA x "<<wa<<"\n";
    cout<<"TLE x "<<tle<<"\n";
    cout<<"RE x "<<re<<"\n";
	return 0;
	}

Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int ans = 0;
		sc.close();
		
		ans = (A-1)*(B-1);
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 23764
N = int(input())

ep = []
for i in range (N):
    a = list(map(int,input().strip().split()))
    for j in range(i,N):
        if a[j] != -1:
            ep.append([a[j],i,j])

P = [i for i in range(N)]
def root(x):
    path_to_root = []
    while P[x] != x:
        path_to_root.append(x)
        x = P[x]
    for node in path_to_root:
        P[node] = x # パス圧縮
    return x
def is_same_set(x,y):
    return root(x) == root(y)
def unite(x,y):
    P[root(x)] = root(y)

ep.sort()
T = []
ans = 0
for e in ep:
    if is_same_set(e[1],e[2]) == False:
        ans += e[0]
        unite(e[1],e[2])
print(ans)



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

int main()
{
	string t;
	cin >> t;
	for (int i = 0; i < t.size(); ++i)
	{
		cout << (t[i] == '?'?'D':t[i]);
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 3720
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	int a, b, c = 0; cin >> a >> b;
	if (b < 10) {
		c = a * 10 + b;
	}
	else if (b < 100) {
		c = a * 100 + b;
	}
	else if (b = 100) {
		c = a * 1000 + b;
	}
	for (int h = 1; h <= 320; h++) {
		if (h * h == c) {
			cout << "Yes" << endl; return 0;
		}
	}
	cout << "No" << endl;	cin >> a;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int a[100000][3];
	int f=1,i,j,n;
	cin>>n;
	for(i=0;i<=n;i++)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		if(a[i][2]+a[i][1]>a[i][0]||a[i][0]%2!=(a[i][1]+a[i][2])%2) f=0;
	}
	if(f==1) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for(ll i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(ll i=(begin);i>(end);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(),greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=(" <<; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << ")" << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define f first
#define s second
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
ll mod = 1000000007;


int main()
{
	// 入力
	ll A,B,C;
	cin>>A>>B>>C;

	if(C*A<=B) cout<<C<<endl;
	else cout<<B/A<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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 namespace std;

int main() {
   int a,b;
   cin >> a >> b;
   cout << max(a-b*2,0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[])
{
    int n,t;
    cin>>n;
    bool found=true;
    for(int i=0;i*7<=n;i++)
    {
        found=false;
        t=n-7*i;
        if(t%4==0)
        {
            found=true;
            break;
        }
    }
    if(found)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
using ll = long long;
ll A[20];
double P[20];
ll LCM[1<<20];
double P_[1<<20];

ll gcd(ll x, ll y){
  if(x < y) swap(x,y);
  while(y) x %= y, swap(x,y);
  return x;
}

int main(){
  ll n, m;
  cin >> n >> m;
  // vector<ll> A(n);
  // vector<double> P(n);
  for(int i = 0; i < n; ++i) cin >> A[i];
  for(int i = 0; i < n; ++i) cin >> P[i], P[i] /= 100.0;
  double ans = 0;
  // vector<ll> LCM;
  // vector<double> P_;
  // LCM.push_back(1);
  // P_.push_back(-1.0);
  LCM[0] = 1;
  P_[0] = -1;
  ll s = 1, s_ = 1;
  for(int i = 0; i < n; ++i){
    // ll s = LCM.size();
    for(ll j = 0; j < s; ++j){
      if(LCM[j]/gcd(LCM[j],A[i]) > m/A[i]) continue;
      ll t = LCM[j]/gcd(LCM[j],A[i])*A[i];
      if(t > m) continue;
      double p = -P_[j]*P[i];
      ans += m/t*p;
      // LCM.push_back(t);
      // P_.push_back(p);
      LCM[s_] = t;
      P_[s_] = p;
      ++s_;
    }
    s = s_;
  }
  printf("%.12f\n",ans);
  return 0;
}



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

using namespace std ;
#define   ll long long
#define   null NULL
#define   endl '\n'
#define   mp make_pair
#define   pb push_back
#define   ff first
#define   ss second

ll mod = (ll)(1e9 + 7);
ll inf = (ll)(1e17 + 17);
vector <int> dp , v ;
int k ;
int rec (int n ) {
	if (n <= 0) return 0 ;
	if (n == 1) return dp[n] = abs (v[n] - v[0]) ;
	if (dp[n] != -1)return dp[n] ;
	int ans = INT_MAX ;
	for (int i = 1 ; i <= k ; i++) {
		if (n - i >= 0) {
			int sub = abs(v[n] - v[n - i]) + rec(n - i) ;
			ans = min(ans , sub) ;
		}
	}
	return dp[n] = ans ;
}

int main () {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	int n ;
	cin >> n >> k;
	v.resize(n) ;
	dp.assign(n, -1) ;
	for (auto &it : v) cin >> it ;
	cout << rec(n - 1) ;
	return 0 ;
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[101010];
map<int,int> M;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>x, M[x]++;
	
	int A[3]={};
	FORR(r,M) {
		if(r.second%2==0) A[2]++;
		else A[1]++;
	}
	while(A[2]>=2) {
		A[2]-=2;
		A[1]+=2;
	}
	cout<<A[1]<<endl;
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 4992
#include <iostream>

using namespace std;
int n,q,res[100001];
string s;
int main()
{
    //freopen("C.INP" ,"r",stdin);
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin >> n >> q;
    cin >> s;
    res[0]=0;
    for (int i=0;i<n;i++)
    {
        if (s[i]=='A'&&s[i+1]=='C') res[i+1]=res[i]+1;
        else res[i+1]=res[i];
    }
    //for (int i=0;i<n;i++) cout << res[i] << " ";
    //cout << " \n";
    while (q--)
    {
        int l,r;
        cin >> l >> r;
        cout << res[r-1]-res[l-1] << "\n";
    }
}


Measured memory_bytes: 1488
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n; cin >> n;
  vector<int> v(n);
  int sum = 0,maxval = 0;
  for(int&e:v){
    cin >> e;
    sum += e;
    maxval = max(maxval,e);
  }
  sum -= (maxval>>1);
  cout << sum << endl;
  return 0;
}

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

int main() {
	int N, ans = 0;
	cin >> N;
	vector<int> V(N), C(N);
	for (int& i : V) cin >> i;
	for (int& i : C) cin >> i;
	for (int i = 0; i < N; ++i) ans += max(V[i] - C[i], 0);
	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int N,i;
    scanf("%d",&N);
    char S[N+1];
    scanf("%s",S);
    if(N%2==1)
        printf("No\n");
    else
    {
        int len=strlen(S);
        int x=len/2;
        int j=0,k=0;
         char A[100],B[100];
        for(i=0;i<x; i++)
        {
            A[j]=S[i];
            j++;
        }
        A[j]='\0';
        for(i=x; i<len; i++)
        {
            B[k]=S[i];
            k++;
        }
        B[k]='\0';
        if(strcmp(A,B)==0)
            printf("Yes\n");
        else printf("No\n");
        }
    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;
  if (a >= b) {
    rep(i, a) {
      cout << b;
    }
  }
  else {
    rep (i, b) {
      cout << a;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,s,ans;
vector<ll> vec;
ll f(ll b,ll n){
	ll ret=0ll;
	while(n>=b){
		ret+=n%b;
		n/=b;
	}
	ret+=n;
	return ret;
}
int main(){
	scanf("%lld%lld",&n,&s);
	if(n==s)return !printf("%lld\n",n+1);
	ll m=abs(n-s);
	for(ll i=1;i*i<=m;i++){
		if(m%i)continue;
		vec.push_back(m/i+1);
		if(f(i+1,n)==s)return !printf("%lld\n",i+1);
	}
	reverse(vec.begin(),vec.end());
	for(auto i:vec)if(f(i,n)==s)return !printf("%lld\n",i);
	return !printf("-1\n");
}

Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i, n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i, n) for(ll i=(ll)(n-1);i>=0;i--)
#define FOR(i, a, b) for(ll i=(ll)(a); i<=(ll)(b); i++)
#define RFOR(i, a, b) for(ll i=(ll)(a);i>=(ll)(b); i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

signed main()
{
	int N;
	cin >> N;
	ll sum = 0;
	map<int, ll> mp;
	vector<ll> ans;
	REP(i, N){
		int a;
		cin >> a;
		mp[a]++;
		sum += a;
	}
	int Q;
	cin >> Q;
	REP(i, Q){
		int B, C;
		cin >> B >> C;
		sum -= mp[B]*B;
		sum += mp[B]*C;
		mp[C] += mp[B];
		mp[B] = 0;
		ans.PB(sum);
	}
	for(auto v : ans){
		cout << v << endl;
	}
	return 0;
}


Measured memory_bytes: 9944
def main():
    import sys
    N,K=list(map(int,sys.stdin.readline().split()))
    output=0
    for k in range(K,N+2):
        output+=(2*N-k+1)*k//2-k*(k-1)//2+1
        output%=10**9+7

    print(output)
main()

Measured memory_bytes: 9180
n, m = map(int, input().split())
xlist = list(sorted(map(int, input().split())))
xd = {}

modl = [0 for _ in range(m)]
for x in xlist:
  modl[x%m] += 1
  if x in xd:
    xd[x] += 1
  else:
    xd[x] = 1

mina = modl[0] // 2
ans = mina
modl[0] -= mina*2
for i in range(1, m//2+1):
  if i != m-i:
    mina = min(modl[i], modl[m-i])
    ans += mina
    modl[i] -= mina
    modl[m-i] -= mina
  else:
    mina = modl[i] // 2
    ans += mina
    modl[i] -= mina*2

for k, v in xd.items():
  tmp = min(v//2, modl[k%m]//2)
  ans += tmp
  modl[k%m] -= tmp * 2

print(ans)


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

int main()
{
	int scard, card[20], full, str, straight;
	
	while (scanf("%d", &scard) != EOF){
		full = str = straight = 0;
		for (int i = 0; i < 15; i++) card[i] = 0;
		card[scard - 1]++;
		for (int i = 1; i < 5; i++){
			scanf(",%d", &scard);
			card[scard - 1]++;
		}
		for (int i = 0; i < 13; i++){
			str = 0;
			if (card[i] == 4) full = 100;
			if (card[i] == 3) full += 3;
			if (card[i] == 2) full += 2;
			if (card[i] == 1) {
				for (int j = i; j < i + 5; j++){
					if (j == 13 && card[0] == 1) str++;
					if (card[j] == 1) str++;
					if (str == 5) straight = 1;
				}
			}
		}
		if (full == 100) cout << "four card" << endl;
		else if (full == 5) cout << "full house" << endl;
		else if (straight == 1) cout << "straight" << endl;
		else if (full == 3) cout << "three card" << endl;
		else if (full == 4) cout << "two pair" << endl;
		else if (full == 2) cout << "one pair" << endl;
		else cout << "null" << endl;
	}
	return(0);
}

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

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d ;

  if (abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
    cout << "Yes" << endl;
  else
    cout << "No"  << endl;

  return 0;
}

Measured memory_bytes: 888
#pragma GCC optimize("Ofast")  
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define int long long 
#define endl "\n"
#define all(x) (x).begin(),(x).end()
const int MOD = 1e9+7;
const int mxN = 2e5+3;

void solve(){
	int n, x, t;
	cin >> n >> x >> t;
	int r = n/x;
	if(n % x != 0)r++;
	int ans = r * t;
	cout << ans << endl;
}

int32_t main(){
	IO;
	
	int nT = 1;
	//cin >> nT;
	for(int i = 1; i <= nT; ++i)
		solve();
	return 0;
}


Measured memory_bytes: 3592
int main(void){
  int a,b,c,k,i;
  scanf("%d %d %d", &a,&b,&c);
  scanf("%d", &k);
  i=0;
  while(b<=a){
    b=2*b;
    i++;
  }
  while(c<=b){
    c=2*c;
    i++;
  }
  if(i<=k){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}

Measured memory_bytes: 1728
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, M = map(int, input().split())
X = list(map(int, input().split()))
Y = list(map(int, input().split()))
MOD = int(1e9) + 7

xs = 0
for i in range(N):
    xs += i * X[i] % MOD - (N - i - 1) * X[i] % MOD + 2 * MOD
    xs %= MOD

ys = 0
for i in range(M):
    ys += i * Y[i] % MOD - (M - i - 1) * Y[i] % MOD + 2 * MOD
    ys %= MOD

print(xs * ys % MOD)

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll N;
    ll prevPrev = 2, prev = 1;
    cin >> N;
    for(ll i = 1;i < N;i++) {
        ll temp = prev + prevPrev;
        prevPrev = prev;
        prev = temp;
    }
    cout << prev << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char ss[9],to[100][9];
	int tok[100];
	int i,j,n,m,kin,k,flag;
	
	while(~scanf("%d%d",&n,&m)){
		if(n==0)break;
		kin=0;
		
		for(i=0;i<n;i++){
			scanf(" %s ",to[i]);
			scanf("%d",&tok[i]);
//			printf("%s %d\n",to[i],tok[i]);
		}
		
		
		for(i=0;i<m;i++){
			scanf(" %s ",ss);
			
			for(j=0;j<n;j++){
				flag=0;
				for(k=0;k<8;k++){
					if(to[j][k]=='*')continue;
					if(to[j][k]!=ss[k])flag=1;
				}
				if(flag==0)kin+=tok[j];
			}
		}
		printf("%d\n",kin);
	}
	return 0;
}

Measured memory_bytes: 772
#include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
const double EPS=1e-8;
double xs[31],ys[31],zs[31];
int main(){
  int n;
  while(cin>>n&&n){
    double cx=0,cy=0,cz=0;
    for(int i=0;i<n;i++){
      cin>>xs[i]>>ys[i]>>zs[i];
      cx+=xs[i],cy+=ys[i],cz+=zs[i];
    }
    cx/=n,cy/=n,cz/=n;
    const int ITE_MAX=500;
    double co=0.5;
    for(int o=0;o<500;o++){
      for(int iter=0;iter<ITE_MAX;iter++){
	int idx=-1;
	double max_dist=-1;
	double d;
	for(int j=0;j<n;j++){
	  d=sqrt(pow(xs[j]-cx,2)+pow(ys[j]-cy,2)+pow(zs[j]-cz,2));
	  if(max_dist<d)max_dist=d,idx=j;
	}
	double dx=xs[idx]-cx,dy=ys[idx]-cy,dz=zs[idx]-cz;
	cx+=dx*co;
	cy+=dy*co;
	cz+=dz*co;
      }
      co/=2;
    }
    double d=0;
    double max_dist=-1;
    for(int j=0;j<n;j++){
      d=sqrt(pow(xs[j]-cx,2)+pow(ys[j]-cy,2)+pow(zs[j]-cz,2));
      max_dist=max(max_dist,d);
    }
    printf("%.5f\n",max_dist);
  }
  
  return 0;
}

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

int main() {

	int n, x, L[100 + 1];

	std::cin >> n >> x;
	for (int i = 0; i < n; ++i) std::cin >> L[i];

	int ans = 0;
	int cnt = 0;

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

		ans += L[i]; 
		if (ans > x) break;
		cnt++;


	}

	std::cout << cnt + 1<< std::endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
using vi = vector<i64>;
using vvi = vector<vi>;

int main() {
    int h, w;
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            string s;
            cin >> s;
            if (s == "snuke") {
                cout << char('A' + j) << i + 1 << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
# print(n,l)
step=0
max_temp=0
for i in range(len(l)-1):
    max_temp=max(max_temp,l[i])
    if max_temp>l[i+1]:
        step+=(max_temp-l[i+1])
print(step)

Measured memory_bytes: 32364
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = G;
		WriteLine(I[1] * (I[2] / I[0]));
	}
}


Measured memory_bytes: 13268
class Factorial:
    def __init__(self, n, mod):
        self.f = f =[0] * (n + 1)
        f[0] = b = 1
        for i in range(1, n + 1):f[i] = b = b * i % mod
        self.inv = inv = [0] * (n + 1)
        inv[n] = b = pow(self.f[n], mod - 2, mod)
        for i in range(n,0,-1):inv[i-1] = b = b * i % mod
        self.mod = mod
    def factorial(self, i):
        return self.f[i]
    def ifactorial(self, i):
        return self.inv[i]
    def comb(self, n, k):
        if n >= k:return self.f[n] * self.inv[n - k] * self.inv[k] % self.mod
        else:return 0

MOD = 10**9 + 7
F = Factorial(200000, MOD)
s = int(input())
p = 0
for i in range(s // 3):
    i += 1
    d = F.comb(s - i * 2 - 1, i - 1)
    p = (p + d) % MOD
print(p)

Measured memory_bytes: 67380
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        int num = Integer.parseInt(str);

        int total;
        total = num * num * num;
        System.out.println(total);
        
    }
  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}



Measured memory_bytes: 26160
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;

int N,a[100010];

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

    int i;
    for (i=1; i<=N; i++) cin >> a[i];
    sort(a+1,a+N+1);

    int l=1,res=0;
    for (i=1; i<=N; i++){
        while (a[i]-a[l]>2) l++;


        res=max(res,i-l+1);
    }

    cout << res << "\n";

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <cstdio>
#include <vector>

using namespace std;
#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;

const int INF = 1001001001;
const int dy[] = {-1, 0, 1, 0};
const int dx[] = {0, 1, 0, -1};

int w, h;
int field[20][20];

int search(int y, int x, int depth)
{
	if(depth == 11)
		return INF;

	int ret = INF;
	rep(i, 4){
		int py = y, px = x;
		for(int j=0;; ++j){
			py += dy[i];
			px += dx[i];
			if(py<0 || h<=py || px<0 || w<=px)
				break;
			if(field[py][px] == 3)
				return depth;
			if(field[py][px] == 1){
				if(j == 0)
					break;
				
				field[py][px] = 0;
				ret = min(ret, search(py-dy[i], px-dx[i], depth+1));
				field[py][px] = 1;
				break;
			}
		}
	}
	return ret;
}

int main()
{
	while(scanf("%d%d", &w, &h), w){
		int sy, sx;
		rep(i, h) rep(j, w){
			scanf("%d", &field[i][j]);
			if(field[i][j] == 2){
				sy = i;
				sx = j;
				field[i][j] = 0;
			}
		}

		int ans = search(sy, sx, 1);
		if(ans == INF)
			ans = -1;
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1028
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn main() {
    let v = read_vec::<u64>();
    let (n, a, b) = (v[0], v[1], v[2]);
    let n = n as usize;
    let x = read_vec::<u64>();
    let x = x.iter().map(|&x| x * a).collect::<Vec<_>>();
    let mut dp = vec![std::u64::MAX; n];
    dp[0] = 0;
    for i in 1..n {
        dp[i] = dp[i - 1];
        dp[i] += min(b, x[i] - x[i - 1]);
    }
    println!("{}", dp[n - 1]);
}


Measured memory_bytes: 8444
class Union:
  def __init__(me,n):
    me.n = n
    me.up = [-1]*n
    me.dw = [ [] for i in range(n) ]
    
  def connect(me,a,b):
    _a = a if me.up[a] == -1 else me.up[a]
    _b = b if me.up[b] == -1 else me.up[b]
    if (_a==_b):
      return False,-1,-1
    la,lb = len(me.dw[_a]) , len(me.dw[_b])
    if ( len(me.dw[_a]) < len(me.dw[_b]) ): 
      _a,_b=_b,_a
    # _a についか
    me.up[_b]=_a
    me.dw[_a].append(_b)
    for it in me.dw[_b]:
      me.up[it]=_a
    me.dw[_a].extend(me.dw[_b])
    me.dw[_b]=[]
    return True,la+1,lb+1
    
N,M = [ int(it) for it in input().split() ] 
li = [  [ int(it) for it in input().split() ] for i in range(M) ]
li.reverse()
u = Union(N)

pr = []
S = (N//2)*(N-1) if N%2==0 else (N)*((N-1)//2)
for a,b in li:
  pr.append(S)
  flag,p,q = u.connect(a-1,b-1)
  if flag:
    S -= p*q
pr.reverse()
[ print (it) for it in pr ]  
  
  
  



Measured memory_bytes: 39076
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	ll n, a[100001], dp[100001];
	cin >> n;
	for (ll i = 0;i < n;i++)
	cin >> a[i];
	dp[0] = 0;
	dp[1] = abs(a[0] - a[1]);
	for (ll i = 2;i < n;i++)
	dp[i] = min(abs(a[i - 2] - a[i]) + dp[i - 2], abs(a[i - 1] - a[i]) + dp[i - 1]);
	cout << dp[n - 1];
}

Measured memory_bytes: 1792
h,w = map(int, input().split())
sl = []
for _ in range(h):
    sl.append(list(input()))

left_cnts = []
for hi, row in enumerate(sl):
    curr_left_cnts = []
    curr_cnt = 0
    for i, s in enumerate(row):
        if s == '.':
            curr_left_cnts.append(curr_cnt)
            curr_cnt += 1
        else:
            curr_left_cnts.append(-1)
            curr_cnt = 0
    left_cnts.append(curr_left_cnts)


right_cnts = []
for hi, row in enumerate(sl):
    curr_right_cnts = []
    curr_cnt = 0
    for i, s in enumerate(row[::-1]):
        if s == '.':
            curr_right_cnts.append(curr_cnt)
            curr_cnt += 1
        else:
            curr_right_cnts.append(-1)
            curr_cnt = 0
    curr_right_cnts = curr_right_cnts[::-1]
    right_cnts.append(curr_right_cnts)


sl_t = [list(x) for x in zip(*sl)]
left_cnts_t = []
for hi, row in enumerate(sl_t):
    curr_left_cnts = []
    curr_cnt = 0
    for i, s in enumerate(row):
        if s == '.':
            curr_left_cnts.append(curr_cnt)
            curr_cnt += 1
        else:
            curr_left_cnts.append(-1)
            curr_cnt = 0
    left_cnts_t.append(curr_left_cnts)


right_cnts_t = []
for hi, row in enumerate(sl_t):
    curr_right_cnts = []
    curr_cnt = 0
    for i, s in enumerate(row[::-1]):
        if s == '.':
            curr_right_cnts.append(curr_cnt)
            curr_cnt += 1
        else:
            curr_right_cnts.append(-1)
            curr_cnt = 0
    curr_right_cnts = curr_right_cnts[::-1]
    right_cnts_t.append(curr_right_cnts)


ans = 0
for hi in range(h):
    for wi in range(w):
        if sl[hi][wi] == '#':continue
        cnt = left_cnts[hi][wi] + right_cnts[hi][wi] + left_cnts_t[wi][hi] + right_cnts_t[wi][hi]
        ans = max(ans, cnt)

print(ans+1)

Measured memory_bytes: 396560
using System;

namespace AtCoder_09_27
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] C= new int[N];
            int[] S = new int[N]; //= int.Parse(CSF[1]);
            int[] F = new int[N]; // = int.Parse(CSF[2]);
            for (int i = 0; i < N-1; i++)
            {
                string[] CSF = Console.ReadLine().Split(' ');
                C[i] = int.Parse(CSF[0]);
                S[i] = int.Parse(CSF[1]);
                F[i] = int.Parse(CSF[2]);

            }
            for (int i = 0; i < N - 1; i++)
            {
                int ans = 0;
                for (int j = i; j < N - 1; j++)
                {
                    if (ans <= S[j])
                    {
                        ans = S[j];
                    }
                    else
                    {
                        int over = (ans - S[j]) % F[j];
                        if (over > 0)
                        {
                            ans += F[j] - over;
                        }
                    }
                    ans += C[j];
                }
                Console.WriteLine(ans);
            } 
           Console.WriteLine(0);

        }
    }
}


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

int main() {

  string s; 
  cin >> s;
  
  string st = s;
  
  sort(s.begin(),s.end());
  s.erase(unique(s.begin(), s.end()), s.end());
  
  string ans = "Yes";
  for(int i=0; i<s.size(); i++){
    int c = 0;
    for(int j=0; j<st.size(); j++){
      if (st.at(j) == s.at(i)) c++;
    }
    if (c % 2 == 1){
      ans = "No";
    }
  }
  
  cout << ans << endl;
  
}


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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n;
    cin>>n;
    vector<int> a(n);
    for(auto & b : a) cin>>b;
    vector<int> c(3);
    ll ret = 1ll;
    for(int i=0;i<n;++i){
        ll count = 0ll; int id = -1;
        if(a[i] == c[0]){count++;id=0;}
        if(a[i] == c[1]){count++;id=1;}
        if(a[i] == c[2]){count++;id=2;}
        if(id == -1){
            cout << 0 << endl;
            return 0;
        }
        (ret *= count)%=mo;
        c[id]++;
    }
    cout << ret << endl;
    return 0;
}



Measured memory_bytes: 640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		
		int i = 1;
		int j = 2;
		int k = 2;
//		
//		long bunsiTest = 4*3498*3498*3498;
//		long bunboTest = 3498*3498+3498*3498+3498*3498;
//		System.out.println(bunsiTest/bunboTest);
		
		for(i = n/4+1; i <= 3500; i++){
//			System.out.println("i = "+i);
			if(i % 2 == 0){
				j = i;
			}
			if(i % 2 == 1){
				j = i + 1;
			}
			for(j = Math.max(j, n*i/(4*i - n) + 1); j <= 3500; j ++){
				long tmpBunbo = (long)4*i*j - n*i - n*j;
				long tmpBunsi = (long)n*i*j;
				
				if(tmpBunsi%tmpBunbo == 0){
					System.out.println(i + " " + j + " " + tmpBunsi/tmpBunbo);
					return ;
				}
				else{
					continue;
				}
				
//				for(k = j; k <= 3500 ; k += 2 ){
//					long bunsi = (long)4*i*j*k;
////					System.out.println("test");
//					long bunbo = (long)i*j + j*k + k*i;
//					
//					if(bunsi % bunbo == 0 && bunsi / bunbo == n){
//						System.out.println(i+" "+j+" "+k);
////						break;
//						return;
//					}
//				}
			}
		}
		
	}
	
	

}


Measured memory_bytes: 21460
n = int(input())
a = list(map(int, input().split()))
s = 0
for x in a: s ^= x

ans = [0] * n
for i in range(n):
    res = 0
    x, y = a[i], s
    for j in range(50):
        if x % 2 != y % 2: res += 2**j
        x >>= 1
        y >>= 1
    ans[i] = res

print(*ans)


Measured memory_bytes: 105544