akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string.h>
#include <vector>
//s#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep_a(i,a,n) for(int i=a; i<n; i++)
#define r0 return 0
#define INF (int)1e15
#define MOD 1000000007

int main(){

 long long n;
 cin>>n;

  map<long long,long long>mp;

  for(int i=0;i<n;i++){
       long long a;
       cin>>a;
       mp[a]++;
  }

  vector<long long>vec(0);

  for(auto c:mp){
    if(c.second >= 2){
        for(int i=0;i<c.second/2;i++){
           vec.push_back(c.first);
         }
    }
  }

  if(vec.size() < 2)
    cout<<"0"<<endl;
  else {
    sort(all(vec));
    reverse(all(vec));
    cout<<vec[0]*vec[1]<<endl;
      }

 return 0;
}


Measured memory_bytes: 9768
// Template
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
#include <complex>
#define rep(i, x) for (int i = 0; i < (x); ++i)
#define rng(i, x, y) for (int i = (x); i < (y); ++i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1001001001;
constexpr ll INF = 3003003003003003003;
template <typename T> inline bool chmin(T &x, const T &y) {if (x > y) {x = y; return 1;} return 0;}
template <typename T> inline bool chmax(T &x, const T &y) {if (x < y) {x = y; return 1;} return 0;}
void solve();
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solve();
    return 0;
}

// Mod-Int
constexpr int MOD = 1000000007;
struct ModInt {
    ll val;
    ModInt() = default;
    ModInt(ll x) : val(x % MOD + (x < 0 ? MOD : 0)) {}
    ModInt &operator+= (const ModInt &x) {if ((val += x.val) >= MOD) val -= MOD; return *this;}
    ModInt &operator-= (const ModInt &x) {if ((val -= x.val) < 0) val += MOD; return *this;}
    ModInt &operator*= (const ModInt &x) {(val *= x.val) %= MOD; return *this;}
    ModInt operator+ (const ModInt &x) const {return ModInt(*this) += x;}
    ModInt operator- (const ModInt &x) const {return ModInt(*this) -= x;}
    ModInt operator* (const ModInt &x) const {return ModInt(*this) *= x;}
    ModInt pow(ll t) const {
        if (!t) return ModInt(1);
        ModInt m = pow(t / 2);
        m *= m;
        if (t & 1) m *= *this;
        return m;
    }
    ModInt inv() const {return pow(MOD - 2);}
    ModInt &operator/= (const ModInt &x) {return *this *= x.inv();}
    ModInt operator/ (const ModInt &x) const {return ModInt(*this) /= x;}
    friend istream &operator>> (istream &is, ModInt &x) {is >> x.val; return is;}
    friend ostream &operator<< (ostream &os, const ModInt &x) {os << x.val; return os;}
};
ModInt comb(int x, int y) {
    ModInt res(1);
    rep(i, y) res *= ModInt(x - i);
    rep(i, y) res /= ModInt(i + 1);
    return res;
}

void solve() {
    int n, a, b;
    cin >> n >> a >> b;
    ModInt ans = ModInt(2).pow(n);
    ans -= comb(n, a);
    ans -= comb(n, b);
    ans -= ModInt(1);
    cout << ans << "\n";
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }
template<class T>
ostream &operator<<(ostream &os,const vector<T> &v){
	for(int i = 0;i < v.size();i++) os << (i ? "," : "[") << v[i];
	os << "]";
	return os;
}

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }

const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int a,b,n;
	cin >> a >> b >> n;
	if(n < b - 1) cout << a * n / b << endl;
	else cout << a * (b - 1) / b << endl;
}

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

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg) / 360) * 2 * M_PI)
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)

using namespace std;

typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
    ll i, j, k;
    char a;
    cin >> a;
    if(a - 'A' < 26) {
        cout << 'A' << endl;
    } else {
        cout << 'a' << endl;
    }

    return 0;
}


Measured memory_bytes: 3592
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010

/* Starry Sky Tree */
//0-index

struct StarrySkyTree{
  typedef int Type;
  int segn2;
  vector<Type> data,s_data;
  function<Type(Type, Type)> merge;
  
  StarrySkyTree(function<Type(Type, Type)> merge, int n): merge(merge)
  {
    for(segn2=1;segn2<n;segn2*=2);
    data.assign(segn2*2,0);
    s_data.assign(segn2*2,0);
  }

  StarrySkyTree(int n): //Original Ver.
    StarrySkyTree([](Type a, Type b){ return max(a, b); }, n) {}
  
  //get minimum value of [a,b)
  Type query(int a,int b,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(r <= a || b <= l) return -INF; //大きさに注意
    if(a <= l && r <= b) return data[k] + s_data[k];
    return merge(query(a,b,l,(l+r)/2,k*2+1),query(a,b,(l+r)/2,r,k*2+2))+s_data[k];
  }
  
  //add x to [a,b)
  Type add(int a,int b,Type x,int l=0,int r=-1,int k=0){
    if(r==-1) r+=segn2;
    if(a <= l && r <= b){
      s_data[k]+=x;
    }else if(a < r && l < b){
      data[k] = merge(add(a,b,x,l,(l+r)/2,k*2+1),add(a,b,x,(l+r)/2,r,k*2+2));
    }
    return data[k] + s_data[k];
  }
  
};

bool hasnext[SIZE], hasown[SIZE];
int prevmax[SIZE];

int main(){
  int n, m, x;

  scanf("%d", &n);

  for(int i=0;i<n;i++) prevmax[i] = -1;
  
  for(int i=0;i<n;i++){
    scanf("%d", &m);
    for(int j=0;j<m;j++){
      scanf("%d", &x);
      x--;
      hasnext[i] |= x == i+1;
      hasown[i] |= x == i;
      if(x < i) prevmax[i] = max(prevmax[i], x);
    }
  }

  StarrySkyTree seg(n+1);

  seg.add(1,n+1, -INF);
  
  for(int i=0;i<n;i++){
    if(!hasown[i] && !hasnext[i]){
      seg.add(prevmax[i]+1, i+1, 1);
    }

    int res = seg.query(0,i+1);
    
    seg.add(i+1, i+2, res - seg.query(i+1, i+2));

    if(!hasown[i] && hasnext[i]){
      seg.add(prevmax[i]+1, i+1, 1);
    }
  }

  cout << n - seg.query(0,n+1) << endl;
  
  return 0;
}



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

int main() {
  int N;
  cin >> N;
  unsigned long long int LX = 2;
  unsigned long long int LY = 1;
  unsigned long long int answer;
  if(N == 1) {
    cout << 1 << endl;
  }
  if(N > 1) {
  for(int i = 0;i < N - 1;i++) {
    answer = LX + LY;
    LX = LY;
    LY = answer;
  }
    cout << answer <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int main(){
  int N;
  rd(N);
  wt_L("ABC");
  wt_L(N);
  wt_L("\n");
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int N;
//   rd(N);
//   wtF("ABC{N}\n");
// }


Measured memory_bytes: 256
import math
N = int(input())
a = [int(i) for i in input().strip().split(" ")]

a_h = math.ceil(sum(a) / len(a))
a_l = math.floor(sum(a) / len(a))

d_h = sum([(a_h-i)**2 for i in a])
d_l = sum([(a_l-i)**2 for i in a])

print(min(d_h,d_l))


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

char transcriptome(char a){
  switch (a) {
    case 'A':
      return 'T';
    case 'T':
      return 'A';
    case 'G':
      return 'C';
    case 'C':
      return 'G';
    }
  return 'N';
}

int main(){
  char a;
  cin>>a;
  cout<<transcriptome(a)<<endl;
}


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

using namespace std;

int main()
{
    char inp[111111];
    scanf("%s", inp);
    
    int k;
    scanf("%d", &k);
    
    int len = strlen(inp);
    for(int i = 0; i < len && k > 0; i++) {
        if(inp[i] == 'a') 
            continue;
        
        
        int dist = 'z' - inp[i] + 1;
        if(dist > k)
            continue;
        
        inp[i] = 'a';
        k -= dist;
    }
    
    if(k > 0) {
        k %= 26;
        inp[len - 1] = (inp[len - 1] - 'a' + k) % 26 + 'a';
    }
    
    printf("%s\n", inp);
    
    return 0;
}

Measured memory_bytes: 384
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void readV(T...)(ref T t){auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(typeof(v));r.popFront;}}
void readA(T)(size_t n,ref T t){t=new T(n);auto r=readln.splitter;foreach(ref v;t){v=r.front.to!(ElementType!T);r.popFront;}}
void readM(T...)(size_t n,ref T t){foreach(ref v;t)v=new typeof(v)(n);foreach(i;0..n){auto r=readln.splitter;foreach(ref v;t){v[i]=r.front.to!(ElementType!(typeof(v)));r.popFront;}}}
void readS(T)(size_t n,ref T t){t=new T(n);foreach(ref v;t){auto r=readln.splitter;foreach(ref j;v.tupleof){j=r.front.to!(typeof(j));r.popFront;}}}

void main()
{
  int n; readV(n);
  int[] a; readA(n, a);

  int[int] h;
  foreach (ai; a) ++h[ai];

  int r = 0;
  foreach (k, v; h)
    if (v >= k) r += v-k;
    else        r += v;

  writeln(r);
}


Measured memory_bytes: 5976
def minimun_cost_sort(array)
	are_sorted = Array.new(array.size, false)
	sorted_array = array.sort
	min_value = array.min
	cost_sum = 0

	array.each_index do |i|
		next if are_sorted[i]
		index = i
		cycle_cost_sum = 0
		cycle_min_value = 10000 # enough large value
		cycle_size = 0
		# ソートされていない値からサイクルを見つけてソート済みとする
		loop do
			# 移動コスト計算に必要な値を算出
			cycle_size += 1
			value = array[index]
			cycle_min_value = cycle_min_value < value ? cycle_min_value : value
			cycle_cost_sum += value

			are_sorted[index] = true
			index = sorted_array.index(value) # ソート後の位置を辿ることでサイクルを見つける
			break if are_sorted[index]
		end
		# サイクル内での最適な移動は数式に落とし込んでいる
		# 移動の最小コスト候補は２通りあるのでそれぞれ計算して比較する
		cost1 = cycle_cost_sum + (cycle_size - 2) * cycle_min_value
		cost2 = cycle_min_value + cycle_cost_sum + (cycle_size + 1) * min_value
		cost_sum += cost1 < cost2 ? cost1 : cost2
	end
	cost_sum
end

n = STDIN.gets.to_i
array = STDIN.gets.split[0...n].map(&:to_i)
puts minimun_cost_sort(array)

Measured memory_bytes: 6124
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
int n, k;
string s;
 
bool addNewSeg(int i) {
    return (i == 0 && s[i] == '0') || (i + 1 < n && s[i] == '1' && s[i + 1] == '0');
}
 
bool delOldSeg(int i) {
    return s[i] == '0' && (i == n - 1 || s[i + 1] == '1');
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> k;
    cin >> s;
 
    int j = 0;
    int ans = 0;
    for(int i = 0; i < n; i++) {
        while(j < n - 1 && k - addNewSeg(j) >= 0)
            k -= addNewSeg(j++);
        ans = max(ans, j - i + 1);
        k += delOldSeg(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
  int x, n; scanf("%d%d", &x, &n);
  std::vector<int> p(101);
  for(int i = 0; i < n; i++) {
    int a; scanf("%d", &a);

    p[a]++;
  }

  for(int d = 0; ; d++) {
    for(auto v: {x - d, x + d}) {
      if(0 < v and v < 101 and p[v]) continue;
      printf("%d\n", v);
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<map>
#include<stack>
#define FOR(i,a,b) for(int i=(a); i<int(b); ++i)
#define RFOR(i,a,b) for(int i=(b)-1; i>=int(a); --i)
#define rep(i,n) FOR(i,0,n)
#define rep1(i,n) FOR(i,1,int(n)+1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
#define al(d) d.begin(),d.end()
using namespace std;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(int n){
	vector<T> vec;
	rep(i,n){
		T input;
		cin >> input;
		vec.emplace_back(input);
	}
	return vec;
}
using AdjList = vector<vector<int>>;
using Weight = int;
using Flow = int;
struct Edge {
	int src, dst;
	Weight weight;
	Flow cap;
	Edge() : src(0), dst(0), weight(0) {}
	Edge(int s, int d, Weight w) : src(s), dst(d), weight(w) {}
};
using Edges = std::vector<Edge>;
using Graph = std::vector<Edges>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

void add_edge(Graph &g, int a, int b, Weight w = 1) {
	g[a].emplace_back(a, b, w);
	g[b].emplace_back(b, a, w);
}
void add_arc(Graph &g, int a, int b, Weight w = 1) { g[a].emplace_back(a, b, w); }

// Recieve edge(=(int,int)) as an adj list.
vector<vector<int>> getadj(int N, int M){
	// Initialize all lists of the graph as a empty vector.
	vector<int> init;
	vector<vector<int>> graph(N,init);

	rep(i,M){
		int a, b;
		cin >> a >> b;
		graph[a-1].emplace_back(b-1);
		graph[b-1].emplace_back(a-1);
	}
// rep(i,N)
// 	putv(graph[i]);
	return graph;
}

#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
using namespace std;
long long Manhattan_dist(long long x1, long long y1, long long x2, long long y2){return abs(x1-x2) + abs(y1-y2);}

int main(){
	int N,M;
	cin >> N>>M;
	long long x,y;
	vector<pair<long long,long long>> students;
	vector<pair<long long,long long>> check_points;
	rep(i,N){
		cin >> x >> y;
		students.emplace_back(make_pair(x,y));
// cout << students[i].first << "," << students[i].second << endl;
	}
	rep(i,M){
		cin >> x >> y;
		check_points.emplace_back(make_pair(x,y));
// cout << check_points[i].first << "," << check_points[i].second << endl;
	}
	long long min_dist[N];
	long long min_dist_pos[N];
	long long sx,sy;
	rep(i,N){
		sx = students[i].first;
		sy = students[i].second;
		min_dist[i] = Manhattan_dist(sx,sy,check_points[0].first,check_points[0].second);
		min_dist_pos[i] = 0;
		for(int j = 1; j<M; ++j){
			long long dist = Manhattan_dist(sx,sy,check_points[j].first,check_points[j].second);
			if(dist < min_dist[i]){
				min_dist[i] = dist;
				min_dist_pos[i] = j;
			}
		}
	}
	rep(i,N)
		cout << min_dist_pos[i]+1 << endl;
}



Measured memory_bytes: 256
// Problem : C - Connect Cities
// Contest : AtCoder - ACL Beginner Contest
// URL : https://atcoder.jp/contests/abl/tasks/abl_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int long long
#define db double
#define mod 1000000007
#define pb push_back
#define pp pair<int,int>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repe(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=b;i>=a;i--)
#define maxn 200005
#define ss second
#define ff first
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
int inv(int a, int b){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int n,m;
int vis[maxn];
vector<int> g[maxn];
void dfs(int c)
{
	vis[c]=1;
	for(auto x:g[c])
		if(vis[x]==0)
			dfs(x);
}
void solve()
{
	cin >> n >> m;
	rep(i,0,m)
	{
		int x,y;
		cin >> x >> y;
		g[x].pb(y);
		g[y].pb(x);
	}
	int cnt=0;
	for(int i=1;i<=n;i++)
	{
		if(vis[i] == 0)
		{
			dfs(i);
			cnt++;
		}
	}	
	cout << cnt-1;
}
signed main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    //cin >> t;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 13464
N, M = map(int, input().split())
li = [list(map(int, input().split())) for _ in range(N)]

sortedLi = sorted(li, key=lambda x:(x[0], x[1]))

num = 0
ans = 0
for AB in sortedLi:
    if num + AB[1] >= M:
        ans += (M - num) * AB[0]
        break
    else:
        num += AB[1]
        ans += AB[1] * AB[0]

print(ans)



Measured memory_bytes: 36068
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;

using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
	public Program() { }

	static void Main(string[] args)
	{
		new Program().prog();
	}
	Scanner cin;
	const int MOD = 1000000007;
	const int INF = int.MaxValue;
	const double EPS = 1e-7;
	const double PI = 3.1415926536;

	void prog()
	{
		cin = new Scanner();
		int[,] dir8 = new int[8, 2] { { -1, -1 }, { -1, 0 }, { -1, 1 }, { 0, -1 }, { 0, 1 }, { 1, -1 }, { 1, 0 }, { 1, 1 } };
		int[,] dir4 = new int[4, 2] { { -1, 0 }, { 0, -1 }, { 0, 1 }, { 1, 0 } };

		string str = cin.next();
		string cor = "CODEFESTIVAL2016";
		int ans = 0;
		for (int i = 0; i < 16; i++)
		{
			if(str[i] != cor[i])
			{
				ans++;
			}
		}
		Console.WriteLine(ans);
	}

}

class Scanner
{
	string[] s;
	int i;

	char[] cs = new char[] { ' ' };

	public Scanner()
	{
		s = new string[0];
		i = 0;
	}

	public string next()
	{
		if (i < s.Length) return s[i++];
		string st = Console.ReadLine();
		while (st == "") st = Console.ReadLine();
		s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
		i = 0;
		return next();
	}

	public int nextInt()
	{
		return int.Parse(next());
	}

	public long nextLong()
	{
		return long.Parse(next());
	}

	public double nextDouble()
	{
		return double.Parse(next());
	}
}

Measured memory_bytes: 2904
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine().Split(" ");
        var x = long.Parse(s[0]);
        var k = long.Parse(s[1]);
        var d = long.Parse(s[2]);

        if (x > 0)
        {
            long プラスからマイナスになるまでの回数 = (long)(x / d);
            x = x - (Math.Min(k, プラスからマイナスになるまでの回数) * d);
            k = k - Math.Min(k, プラスからマイナスになるまでの回数);
        }
        if (x < 0)
        {
            long マイナスからプラスになるまでの回数 = Math.Abs((long)(x / d));
            x = x + (Math.Min(k, マイナスからプラスになるまでの回数) * d);
            k = k + Math.Min(k, マイナスからプラスになるまでの回数);
        }
        //long min = 0;
        if (k % 2 == 0)
        {
            // 偶数回の移動
            // x
            Console.WriteLine(Math.Abs(x));
            return;
        }
        else
        {
            // 奇数回の移動
            if (x <= 0)
            {
                x += d;
            }
            else
            {
                x -= d;
            }
            Console.WriteLine(Math.Abs(x));
        }
        //for (long i = 0; i < k; i++)
        //{
        //    if (x < 0)
        //    {
        //        x += d;
        //    }
        //    else
        //    {
        //        x -= d;
        //    }
        //    //min = Math.Min(min, Math.Abs(x));
        //    //if (i > 10)
        //    //{
        //    //    break;
        //    //}
        //}
        //Console.WriteLine(Math.Abs(x));
    }
}


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

int main()
{
	int A, B, C, X, Y;
	scanf("%d %d %d %d %d", &A, &B, &C, &X, &Y);
	
	int cost = A * X + B * Y, min = (X < Y)? X: Y;
	if (A + B > C * 2) cost -= ((A + B) - C * 2) * min;
	if (A > C * 2 && X > min) cost -= (A - C * 2) * (X - min);
	if (B > C * 2 && Y > min) cost -= (B - C * 2) * (Y - min);
	
	printf("%d\n", cost);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>

#define IOS ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define AfterDecimal(n) cout << fixed << setprecision(n);
#define ll long long int
#define ld long double
#define all(a) a.begin(), a.end()
#define pii pair<int, int>
#define pll pair<ll, ll>
#define bits(x) __builtin_popcount(x)

using namespace __gnu_pbds;
using namespace std;

// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")

//template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

#ifdef LOCAL
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << "# "<< name << " = " << arg1 << '\n';
}
template<typename Arg1, typename... Args>
void __f(const char* names, Arg1 && arg1, Args &&... args){
        const char* comma = strchr(names + 1 ,',');
        cout << "# ";
        cout.write(names, comma - names)<< " = " << arg1 << " | ";
        __f(comma + 1, args...);
}
#else
#define debug(...) 36
#endif


std::mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline int ri(int a, int b) {
    return uniform_int_distribution<int>(a, b)(rng);
}

ll power(ll x, ll y, ll p){
   ll res = 1;
   x = x % p;
   while (y > 0) {
      if (y & 1)
         res = (res * x) % p;
      y = y >> 1;
      x = (x * x) % p;
   }
   return res;
}

const ll INF = (ll)(8e18);
const ll MOD = (ll)(1e9 + 7);
const ll HMOD = (ll)4222234727;
const ll Hashprime = (ll)31;

const int maxn = 100100;

int32_t main(){
    IOS;
    #ifndef ONLINE_JUDGE
    //  freopen("input.txt", "r", stdin);
    //  freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    while(t--){
      string s; cin >> s;
      string temp[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT", "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
      for(int i = 0; i < 14; i++){
         if(temp[i] == s){
            for(int j = i + 1; j < 14; j++){
               if(temp[j] == "SUN"){
                  cout << j - i << '\n';
                  return 0;
               }
            }
         }
      }
    }
    #ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
    #endif
}
//g++ -DLOCAL -std=c++17 -Wshadow -Wall -o "c" "comp.cpp" -fsanitize=address -fsanitize=undefined -D_GLIBCXX_DEBUG -g


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K, y = 0;
  cin >> N >> K;
  
  
 
  // ここにプログラムを追記
  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    if (2*x <= 2*(K-x)) {
      y += 2*x;
    }
    else {
      y += 2*(K-x);
    }
  }
  cout << y << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 4000000000000000000;
ll n,a,b,c,d;
map<ll,ll> mem;
ll dp(ll x){

    if (x == 0ll) return 0ll;
    if (x == 1ll) return d;
    if (mem.count(x)) return mem[x];
    //printf("%lld\n",x);
    ll res = INF;
    if (x <= INF/d) res = d*x;
    ll L,R,l,r;
    L = x/2;
    R = L+1;
    l = x-L*2;
    r = R*2-x;
    res = min(res,l*d+a+dp(L));
    if (R < x) res = min(res,r*d+a+dp(R));
    L = x/3;
    R = L+1;
    l = x-L*3;
    r = R*3-x;
    res = min(res,l*d+b+dp(L));
    if (R < x) res = min(res,r*d+b+dp(R));
    L = x/5;
    R = L+1;
    l = x-L*5;
    r = R*5-x;
    res = min(res,l*d+c+dp(L));
    if (R < x) res = min(res,r*d+c+dp(R));
    //printf("%lld: %lld\n",x,res);
    return mem[x] = res;
}
int main(){
    int t;
    scanf("%d",&t);
    while (t--){
        scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
        mem.clear();
        printf("%lld\n",dp(n));
    }
}


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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    vector<ll> B(N);
    for(int i = 0; i < N; i++) cin >> B[i];
    vector<ll> C(N);
    for(int i = 0; i < N; i++) cin >> C[i];

    sort(A.begin(), A.end());
    sort(C.begin(), C.end());

    ll ans = 0;
    for (int i = 0; i < N; i++)
    {
        auto iter_a = lower_bound(A.begin(), A.end(), B[i]);
        auto iter_c = upper_bound(C.begin(), C.end(), B[i]);
        ll a = (ll)(iter_a - A.begin()); //B[i]より小さいA[i]の個数
        ll c = (ll)(C.end() - iter_c); //B[i]より大きいC[i]の個数

        ans += a * c;
    }
    
    cout << ans << endl;
    return 0;
}

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

namespace CP
{
    class Atria
    {
        static void Main(string[] args)
        {
            long[] s = ReadLine().Split(' ').Select(long.Parse).ToArray();
            long n = s[0];
            long d = s[1];
            long ans = 0;
            for (long i = 0; i < n; i++)
            {
                long[] input = ReadLine().Split(' ').Select(long.Parse).ToArray();
                long x = input[0];
                long y = input[1];
                if (Sqrt((x * x) + (y * y)) <= d) ans++;
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 41236
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n=int(readline())
    arr=list(map(int, readline().rstrip().split()))
    while len(arr)>1:
        x=min(arr)
        arr=[a%x for a in arr]
        arr.append(x)
        arr=[a for a in arr if a!=0]
    print(arr[0])

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------

Measured memory_bytes: 17336
#include <bits/stdc++.h>
using namespace std;
int main () {
	int N;
    cin >> N;
	int c[4];
	for (int i = 0; i < 4; ++i)
	{
		c[i] = 0;
	}
	for (int i = 0; i < N; ++i)
	{
		char tmp;
		cin >> tmp;
		if(tmp == 'P'){
			c[0]++;
		}else if(tmp == 'W'){
			c[1]++;
		}else if(tmp == 'G'){
			c[2]++;
		}else{
			c[3]++;
		}
	}
	int count = 0;
	for (int i = 0; i < 4; ++i)
	{
		if(c[i] != 0){
			count++;
		}
	}
	if(count == 3){
		cout << "Three" << endl;
	}else{
		cout << "Four" << endl;
	}
}

Measured memory_bytes: 256
import math
N, P = map(int, input().split())
A = list(map(int, input().split()))

def nCr(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)

even = 0
odd = 0
for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1

temp1 = 0
for e in range(even + 1):
    temp1 += nCr(even, e)

temp2 = 0
if P == 0:
    for o in range(odd + 1):
        if o % 2 == 0:
            temp2 += nCr(odd, o)
else:
    for o in range(odd + 1):
        if o % 2 != 0:
            temp2 += nCr(odd, o)
ans = temp1 * temp2
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int n;
  cin >> n;
  int number;
  vector<int>sum(n,0);
  for(int i=0; i < n-1;i++){
    cin >> number;
    sum.at(number-1)++;
   
  }
    
  for(int i=0;i<n;i++){
    cout << sum.at(i)<<endl;
  }
  

}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long k,a,b,now=1;
  cin >> k >> a >> b;
  if(a-now>k){
    k=0;
    now+=k;
  }else{
    k-=a-now;
    now+=a-now;
  }
  if(b-a>2){
    now+=(k/2)*(b-a);
    k%=2;
  }
  now+=k;
  cout << now << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {

    private static int MOD = 1_000_000_007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();

        StringBuilder ans = new StringBuilder();
        if (a < b) {
            for (int i = 0; i < b; i++) {
                ans.append(a);
            }
        } else if (b < a) {
            for (int i = 0; i < a; i++) {
                ans.append(b);
            }
        } else {
            for (int i = 0; i < a; i++) {
                ans.append(a);
            }
        }

        System.out.println(ans.toString());
    }
}


Measured memory_bytes: 21204
M, K = map(int, input().split())

if K >= 2**M:
    print(-1)
elif M == 1 and K == 1:
    print(-1)
elif M == 1 and K == 0:
    print("0 0 1 1")
else:
    x_list = list(range(2**M))
    x_k_list = [x for x in x_list if x != K]
    res_list = x_k_list + [K] + list(reversed(x_k_list)) + [K]
    print(" ".join([str(r) for r in res_list]))


Measured memory_bytes: 79732
#include <bits/stdc++.h>
    #define Mod 1000000007
    #define INF 1e9
    #define INFL 9e18
    #define EPS 1e-9
    #define pb push_back
    #define mp make_pair
    #define SET(a) memset(a,-1,sizeof(a))
    #define CLR(a) memset(a,0,sizeof(a))
    #define CPY(a,b) memcpy(a,b,sizeof(a))
    #define all(a) (a).begin(),(a).end()
    #define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define N 200005
    #define fs first
    #define sc second
    using namespace std;

    typedef  long long int ll;
    typedef pair<ll,ll> ii;
    typedef vector <ii> vii;
    typedef vector <ll> vi;
   
  

   
    int main()
    {
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    // #endif
    ios;
 ll n,y;
 cin>>n>>y;
 for(int i=0;i<=2000;i++)
 {
  for(int j=0;j<=2000;j++)
  {
    ll val=i*10000+j*5000+(n-i-j)*1000;
    if(val==y && (n-i-j)>=0)
    {
      cout<<i<<" "<<j<<" "<<n-i-j;
      return 0;
    }
  }
 }

cout<<-1<<" "<<-1<<" "<<-1;













    return 0;


    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  double n,d;
  cin >> n >> d;
  vector<vector<double>> point(n,vector<double>(d));
  for(int i=0;i<n;i++){
    for(int j=0;j<d;j++){
      cin >> point.at(i).at(j);
    }
  }
  double distance;
  int count=0;
  for(int i=0;i<n;i++){ //一個目の点
    if(i==n-1) break;
    for(int j=i+1;j<n;j++){ //二個目の点
      double sum = 0;
      distance = 0;
      if(i==j) continue;
      for(int k=0;k<d;k++){//座標
       sum  += pow( point.at(i).at(k) - point.at(j).at(k),2 );
      }
      distance = sqrt(sum);
      if( ceil(distance) == floor(distance) ){
        count++;
      }
    }
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <variant>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,m;
  cin>>n>>m;
  vector<vecint> g(n);
  REP(i,m) {
    int a,b;
    cin>>a>>b;
    --a;--b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  queue<int> q;
  int INF = 1e9;
  vecint dis(n, INF);
  vecint pa(n, -1);
  q.push(0);
  dis[0] = 0;
  while (!q.empty()) {
    int i = q.front();
    q.pop();
    for(auto&&to:g[i]) {
      if (dis[to] > dis[i] + 1) {
        dis[to] = dis[i] + 1;
        pa[to] = i;
        q.push(to);
      }
    }
  }
  cout<<"Yes\n";
  FOR(i,1,n) {
    cout<<pa[i]+1<<"\n";
  }
  return 0;
}


Measured memory_bytes: 10696
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 3;
vector<int> g[MAXN];
vector<int> indeg(MAXN, 0);
vector<int> depth(MAXN, -1);

int ans = 0;
int dfs(int u, int d)
{
    if (depth[u] != -1)
        return depth[u];
    for (int v : g[u])
    {
        depth[u] = max(depth[u], 1 + dfs(v, d + 1));
    }
    return depth[u];
}

int main()
{
    int n, m;
    scanf("%d %d", &n, &m);
    int root = 0;
    int x, y;
    for (int i = 0; i < m; i++)
    {
        scanf("%d %d", &x, &y);
        indeg[y]++;
        g[x].push_back(y);
    }

    for (int i = 1; i <= n; i++)
        if (!indeg[i])
        {
            g[root].push_back(i);
        }

    ans = dfs(0, 0);
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    int N, K;
    cin >> N >> K;
    string S;
    cin >> S;
    int zero = 0;
    int ans = 0;
    queue<int> q;
    q.push(0);
    for(int i = 0; i < S.size(); i++) {
        if(S[i] == '0') {
            if(q.size() > K) {
                ans = max(i - q.front(), ans);
                q.pop();
            }
            zero++;
        } else {
            if(zero) q.push(i);
            zero = 0;
        }
    }
    ans = max(ans, N - q.front());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;

public class Hello
{
    public static void Main()
    {

        int[]  nm =  Array.ConvertAll(System.Console.ReadLine().Split(' '),int.Parse);
        List < List<int> > G  = new List<List<int>>();
        var que = new Queue<int>();
        int[] dist = new int[nm[0] + 1];
        int[] direction = new int[nm[0] + 1];
        bool non_solve = false; 

        for(int i=0; i <= nm[0]; i++)
        {
            G.Add(new List<int>());
            dist[i] = -1;

        }
        for(int i=1;i<=nm[1];i++)
        {
            int[] ab = Array.ConvertAll(System.Console.ReadLine().Split(' '), int.Parse);
            G[ab[0]].Add(ab[1]);//Gが部屋
            G[ab[1]].Add(ab[0]);

        }
        dist[1] = 0;
        que.Enqueue(1);
        while(que.Count>0)
        {
            int q = que.Dequeue();
            foreach(int point in G[q] )
            {
                if (dist[point] != -1) continue;
                dist[point] = dist[q] + 1;
                que.Enqueue(point);
            }
        }
        for(int i=2; i<= nm[0];i++)
        {
            int mindist_g = nm[0];
            int i2 = 0;
            G[i].Sort((a, b) =>  dist[a].CompareTo(dist[b]));
            if(dist[i]==dist[G[i][0]])
            {
                non_solve = true;
            }

            if(non_solve == true)
            {
                System.Console.WriteLine("No");
                return;
            }
            direction[i] = G[i][0];
        }
        System.Console.WriteLine("Yes");
        for(int i=2;i<=nm[0];i++)
        {
            System.Console.WriteLine(direction[i]);
        }
    }
}

Measured memory_bytes: 52060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for(int i = a; i < b; i++)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
typedef long long int lli;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

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

int main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> sum(n);
    sum[0] = 0;
    for(int i =1; i < n; i++){
        if (s.substr(i-1, 2) == "AC") sum[i] = sum[i-1] + 1;
        else sum[i] = sum[i-1];
    }

    rep(i,q){
        int l, r;
        cin >> l >> r;
        l--; r--;
        cout << sum[r] - sum[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 3848
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    ll n,m; cin >> n >> m;
    vector<ll> a(n); rep(i,n) cin >> a[i];
    ll sum = 0; rep(i,n) sum += a[i];
    int c = 0;
    rep(i,n){
        if(a[i]*4*m >= sum) c++;
    }
    if(c >= m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <limits.h>
#include <time.h>
int main(){
    int n,x,t;
    scanf("%d %d %d",&n,&x,&t);
    if(n<=x){
        printf("%d",t);
        return 0;
    }
    if(n%x==0){
        printf("%d",t*(n/x));
        return 0;
    }
    printf("%d",t*(n/x+1));
    return 0;
}

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

int main() {
	int N, M, C; cin >> N >> M >> C;
	int b[25];
	int a[25][25];
	for (int i = 0; i < M; i++) {
		cin >> b[i];
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++) {
			cin >> a[i][j];
		}
	}
	int c = 0;
	for (int i = 0; i < N; i++) {
		int sum = C;
		for (int j = 0; j < M; j++) {
			sum += b[j] * a[i][j];
		}
		if (sum > 0)c++;
	}
	cout << c;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmin(T & ref, const T  value) {
    if (ref > value) ref = value;
}

template<typename T>
static inline void chmax(T & ref, const T value) {
    if (ref < value) ref = value;
}

class Primes {
private:
    vector<int> Prime_Number;
    vector<bool> is_prime_;
public:
    Primes(int N) {
        is_prime_.resize(N + 1, true);
        is_prime_[0] = is_prime_[1] = false;
        for (int i = 0; i < N + 1; i++) {
            if (is_prime_[i]) {
                Prime_Number.push_back(i);
                for (int j = 2 * i; j <= N; j += i) is_prime_[j] = false;
            }
        }
    }
    int operator[](int i) { return Prime_Number[i]; }
    vector<int>& primes() { return Prime_Number; }
    int size() { return Prime_Number.size(); }
    int back() { return Prime_Number.back(); }
    bool isPrime(int q) { return is_prime_[q]; }
};

int main() {

    Primes pr(1e5 + 1);
    vector<int> match(1e5 + 1, 0);
    for (auto p : pr.primes()) {
        auto c = p * 2-1;
        if (c > 1e5) break;
        if (pr.isPrime(c)) {
            match[c]=1;
        }
    }
    vector<int> sums(1e5 + 2, 0);
    for (int i = 0; i < 1e5 + 1; i++) {
        sums[i + 1] = sums[i] + match[i];
    }
    int q;
    cin >> q;
    vector<int> ans;
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        auto a = sums[r+1] - sums[l];
        ans.push_back(a);
    }
    for (auto a : ans) {
        cout << a << endl;
    }
    return 0;
}



Measured memory_bytes: 4736
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main()
{
	string s;
	int ans=0;
	
	cin>>s;
	//cerr<<s<<" "<<ans<<endl;
	for(int i=0;i<6;i++)
	{
		if(s[i]=='1')
		{
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
using namespace std;
using Graph = vector<vector<int>>;

typedef long long ll;
typedef long double ld;


#define int long long
#define rep(i, n) for(long long i = 0; i < (n); i++)
#define sqrt(d) pow((long double) (d), 0.50)

const ll INF = 2e9;
const ll large_P = 1e9 + 7;





signed main() {
	int R; cin >> R;
	ld r = (ld)R;

	ld pi = 3.14159265358979;
	cout << 2.0 * r * pi << endl;
}

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


int main() {
  int n;
  cin>>n;
  int retu[n];
  rep(i,n)
    cin>>retu[i];
  int cnt=0;
  rep(i,n){
    if(i+1!=retu[i])
      cnt++;
  }
  if(cnt>2)
    cout<<"NO"<<endl;
  else
    cout<<"YES"<<endl;
    
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
import math
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(N):
    if N == 0:
        print('0')
        return
    x = math.ceil(math.log2(abs(N))) + 1
    minus = [(-2) ** i for i in range(1, x + 1, 2)]
    plus = [(-2) ** i for i in range(0, x + 1, 2)]
    minus.sort()
    plus.sort(reverse=True)

    minus_sum = [0]
    for m in minus:
        minus_sum.append(minus_sum[-1] + m)
    plus_sum = [0]
    for p in plus:
        plus_sum.append(plus_sum[-1] + p)

    ans = ''
    n = 0
    flg = True if len(plus) > len(minus) else False
    m = 0
    p = 0
    while True:
        if flg:
            tg = plus[p]
            p += 1
        else:
            tg = minus[m]
            m += 1

        if n + tg >= N:
            if n + tg != N and n + tg + (minus_sum[-1] - minus_sum[m]) > N:
                ans += '0'
            else:
                ans += '1'
                n += tg
        else:
            if n + tg + (plus_sum[-1] - plus_sum[p]) < N:
                ans += '0'
            else:
                ans += '1'
                n += tg
        flg = not flg
        if p >= len(plus) and m >= len(minus):
            break
    print(str(int(ans)))


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    # A = [int(i) for i in input().split()]
    # B = [int(i) for i in input().split()]
    # AB = [[int(i) for i in input().split()] for _ in range(N)]
    solve(N)

    # # test
    # from random import randint
    # from func import random_str
    # solve()


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


int main(){
  
  int N,K;
  cin >> N >> K;
    
  int count=0;
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    if(K-x>x){count+=2*x;}
    else count+=2*K-2*x;
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)

using namespace std;
using ll = long long;
using P = pair<int,int>;
using ull= unsigned long long;
const ll K_MAX=1e5+5;


// a+b+2sqrt(a*b)<c
// 2*sqrt(a*b)<c-a-b
// 4*a*b<(c-a-b)**2
int main(){
  ll a,b,c;
  cin >>a>>b>>c;
  string ans;
  if (c-a-b<0){
    ans="No";
  }else{
    if((c-a-b)*(c-a-b)>4*a*b){
    ans="Yes";
    }else{
    ans="No";
    }

  }

  cout<<ans<<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

// 小大
int cmp1( const void *p, const void *q ) {
    if( ((frequent*)p)->aa == ((frequent*)q)->aa  ) return ((frequent*)p)->bb - ((frequent*)q)->bb;
    return ((frequent*)p)->aa - ((frequent*)q)->aa;
}

int main(void){
    // char ;
    ll n,ans=1;
    scanf("%lld",&n);
    if(n==1){
        printf("1\n");
        return 0;
    }
    ll x[n],y[n];
    rep(i,0,n){
        scanf("%lld%lld",&x[i],&y[i]);
    }
    ll r=0;
    frequent d[n*(n-1)];
    rep(i,0,n){
        rep(j,0,n){
            if(i==j) continue;
            d[r].aa=x[i]-x[j];
            d[r].bb=y[i]-y[j];
            r++;
        }
    }
    qsort(d,r,sizeof(frequent),cmp1);
    ll fff=1,ma=1;
    rep(i,1,r){
        if( d[i].aa==d[i-1].aa  && d[i].bb==d[i-1].bb ){
            fff++;
        }else{
            ma=max2(ma,fff);
            fff=1;
        }
        // printf("%lld f ",fff);
    }
    // rep(i,0,r){
    //     printf("%lld %lld\n",d[i].aa,d[i].bb);
    // }
    ans=n-ma;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
int main () {
    int n, m, q; //10 10 50
    cin >> n >> m >> q;
    int a[q], b[q], c[q], d[q];
    for(int i = 0; i < q; i++) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
    }
    ll max = 0;
    for (int i1 = 1; i1 <= m; i1++) {
        for (int i2 = i1; i2 <= m; i2++) {
            for (int i3 = i2; i3 <= m; i3++) {
                for (int i4 = i3; i4 <= m; i4++) {
                    for (int i5 = i4; i5 <= m; i5++) {
                        for (int i6 = i5; i6 <= m; i6++) {
                            for (int i7 = i6; i7 <= m; i7++) {
                                for (int i8 = i7; i8 <= m; i8++) {
                                    for (int i9 = i8; i9 <= m; i9++) {
                                        for (int i10 = i9; i10 <= m; i10++) {
                                            int i[11] = {0, i1, i2, i3, i4, i5, i6, i7, i8, i9, i10};
                                            ll now_max = 0;
                                            for (int j = 0; j < q; j++) {
                                                if (i[b[j]] - i[a[j]] == c[j]) {
                                                    now_max += d[j];
                                                }
                                            }
                                            if (max < now_max) {
                                                    max = now_max;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 3612