akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
#define ll long long 
#define rep(i,a,b) for(signed i=a;i<(b);++i)
#define erep(i,a,b) for(signed i=a;i<=(b);++i)
#define per(i,a,b) for(signed i=(a);i>(b);--i)
#define eper(i,a,b) for(signed i=(a);i>=b;--i)
#define fore(i, x, a) for(auto &&x:a) 
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define pb emplace_back
#define mp make_pair
#define ALL(x) begin(x),end(x)
#define F first
#define S second
#define debug(x)  cout << #x << ": " << (x) << '\n';
const long long INF=1001001001001001001;
const int MOD=(int)1e9 + 7;
const double EPS=1e-9;
using namespace std;
using Pii = pair<int,int>;
using vii = vector<int>;
template<class T>using  PS_queue = priority_queue<T, vector<T>, greater<T> >;
template<class T>using vv = vector<T>;
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; }
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> ostream& operator<<(ostream &os,const vector<vector<T> > &v) {
    ITR(u,begin(v),end(v))ITR(w,begin(*u),end(*u))os<<*w<<(w==end(*u)-1?"\n":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct edge { int from, to, cost; };
int dy[]={0, 1, -1, 0}; int dx[]={1, 0, 0, -1};
// cout << fixed << setprecision(10) << val;

string s;
signed main() {
 cin.tie(0);
 ios::sync_with_stdio(false);
  cin >> s;
  int n = s.size();
  vii ans(n, 0);
  int r = 0;
  rep(i, 0, n-1) {
    if (s[i] == 'R' and s[i+1] == 'R') 
      ans[i] = 0, r++; 
    if (s[i] == 'R' and s[i+1] == 'L') {
      ans[i] = r / 2 + 1;
      ans[i+1] = r / 2 + r % 2 + 1;
      r = 0;
    }
  }
  int l = 0;
  per(i, n-1, 0) {
    if (s[i] == 'L' and s[i-1] == 'L')
      l++;
    if (s[i] == 'L' and s[i-1] == 'R') {
      ans[i] += l / 2;
      ans[i-1] += l / 2 + l % 2;
      l = 0;
    }
  }
  cout << ans << endl;
  return 0;
}




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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  int dx[8]={1,0,-1,0,1,-1,-1,1};
  int dy[8]={0,1,0,-1,1,1,-1,-1};

  for (int i = 0; i < H; i++) 
      cin >> S[i];
/*    例えば、.#.
             ###
             ..#
      とすると、S[0]={., #, .}
      S[1]={#,#,#}
*/

 for (int i = 0; i < H; i++) {
    for (int j = 0; j <W; j++) {
      if (S[i][j] == '.'){  //S[i]のj番目
          int cut = 0;
          for (int k = 0; k < 8; k++) {
             int x =i + dx[k];
             int y =j + dy[k];
             if (x>=0 && x<H && y>=0 && y<W && S[x][y]=='#') {
                 cut ++;
             }
          }
          S[i][j] = '0'+ cut;
      } 
      else
       continue;
      
    }
    cout << S[i] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define u unsigned
#define N1 100005
#define N2 200005
#define endl "\n"
#define mod 1000000007
#define vll vector<ll>
#define pb push_back
#define for0(i,n) for(int i=0;i<n;i++)
#define for1(i,n) for(int i=1;i<=n;i++)

int check(string s1,string s2)
{
    for(int i=0;i<s1.length();i++)
    {
        if(s1[i]!=s2[s2.length()-i-1])
        return 0;
    }
    return 1;
}

int checkp(string s)
{
    int i=0,j=s.length()-1;
    while(i<j)
    {
        if(s[i]!=s[j]) return 0;
        i++;j--;
    }
    return 1;
}

int main()
{
    ll n,a[N1],k;
    cin>>n>>k;
    for1(i,n)
    cin>>a[i];

    ll dp[n+1];
    dp[1]=0;
    dp[2]=abs(a[1]-a[2]);
    for(int i=3;i<=n;i++)
    {
        ll mi=INT_MAX;
        for(int j=i-1;j>=i-k&&j>=1;j--)
        mi=min(dp[j]+abs(a[i]-a[j]),mi);
        dp[i]=mi;
    }
    cout<<dp[n];
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    string A; cin >> A;
    i64 P = 2019;
    i64 N = A.length();

    vector<i64> C(N + 1, 0);
    i64 ten = 1;
    for (i64 i = N - 1; i >= 0; i--) {
        C[i] = (C[i + 1] + (A[i] - '0') * ten) % P;
        ten *= 10; ten %= P;
    }

    i64 cnt = 0;
    vector<i64> dist(P, 0);
    for (i64 i = N; i >= 0; i--) {
        cnt += dist[C[i]];
        dist[C[i]]++;
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int inf = 1e9;

int main() {
	int N,M;
	cin>>N>>M;
	vi a(M),b(M),ans(N);
	rep(i,M){
		cin>>a[i]>>b[i];
		ans[a[i]-1]++;
		ans[b[i]-1]++;
	}
	rep(i,N)cout<<ans[i]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 1010101010;

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

    double r0, w0, c, r;
    cin >> r0 >> w0 >> c >> r;

    while(r0 != 0){
        int ans = 0;
        if(r0/w0 == c) ans = 0;
        else if(r0/w0 > c) ans = 0;
        else{
            while((r0+ans*r)/w0 < c) ans++;
        }

        cout << ans << "\n";
        cin >> r0 >> w0 >> c >> r;
    }
    return 0;
}


Measured memory_bytes: 3260
#include <iostream>
#include <vector>
#include <algorithm>

struct Node {
	int ID;
	int d;
	int f;
	bool visited;
	bool operator<(const Node& rhs) {return this->ID < rhs.ID;}
	bool operator>(const Node& rhs) {return this->ID > rhs.ID;}
	bool operator<=(const Node& rhs) {return this->ID <= rhs.ID;}
	bool operator>=(const Node& rhs) {return this->ID >= rhs.ID;}
	bool operator==(const Node& rhs) {return this->ID == rhs.ID;}
	bool operator!=(const Node& rhs) {return this->ID != rhs.ID;}
};

int step = 1;

void DFS(std::vector<int>* adjlist, Node* nodes, int v)
{
	nodes[v].visited = true;
	nodes[v].d = step;
	step++;
	
	for (int i=0; i<adjlist[v].size(); i++) {
		int id = adjlist[v][i];
		if (!nodes[id].visited) DFS(adjlist, nodes, id);
	}
	
	nodes[v].f = step;
	step++;
}

int main()
{
	int n; std::cin >> n;
	
	std::vector<int>* adjlist = new std::vector<int>[n];
	Node* nodes = new Node[n];
	
	for (int i=0; i<n; i++) nodes[i].visited = false;
	
	for (int i=0; i<n; i++) {
		int x;
		int deg;
		std::cin >> x >> deg;
		nodes[i].ID = x-1;
		for (int j=0; j<deg; j++) {
			int y;
			std::cin >> y;
			adjlist[x-1].push_back(y-1);
		}
	}
	
	std::sort(nodes, nodes + n);
	
	for (int i=0; i<n; i++) {
		if (!nodes[i].visited) DFS(adjlist, nodes, i);
	}
	
	for (int i=0; i<n; i++) {
		std::cout << nodes[i].ID + 1 << " " << nodes[i].d << " " << nodes[i].f << std::endl;
	}
	
	delete[] adjlist;
	delete[] nodes;
	
	return 0;
}



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

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int h,n;
	cin >> h >> n;
	int sum=0,x;
	while(n--){
		cin >> x;
		sum += x;
	}
	if(sum >= h) cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

struct Apple{
      enum Color{red,green,none};
      Color color;
      lint value;
      bool operator<(const Apple& another)const{
        return value<another.value;
      }
  bool operator>(const Apple& another)const{
    return value>another.value;
  }
      Apple(int v,Color c):value(v),color(c){}
    };

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int x,y,a,b,c;
  cin>>x>>y>>a>>b>>c;

  vector<int> p(a),q(b),r(c);
  vector<Apple> apple;
  for(int i=0;i<a;i++){
    cin>>p[i];
    apple.push_back(Apple(p[i],Apple::red));
  }
  for(int i=0;i<b;i++){
    cin>>q[i];
    apple.push_back(Apple(q[i],Apple::green));
  }
  for(int i=0;i<c;i++){
    cin>>r[i];
    apple.push_back(Apple(r[i],Apple::none));
  }
  std::sort(apple.begin(), apple.end(), std::greater<>());
  int red_count=0,green_count=0;
  int count=0;
  lint result=0;
  for(auto apl:apple){
    if(apl.color==Apple::red){
      if(red_count<x){
        result+=apl.value;
        red_count++;
        count++;
      }
    }else if(apl.color==Apple::green){
      if(green_count<y){
        result+=apl.value;
        green_count++;
        count++;
      }
    }else{
      result+=apl.value;
      count++;
    }
    if(count==x+y){
      break;
    }
  }
  cout<<result<<endl;



  return 0;
}




Measured memory_bytes: 11756
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {

	public static final int BIG_NUM  = 2000000000;
	public static final int MOD  = 1000000007;

	public static void main(String[] args) {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		Deque<Integer> S = new ArrayDeque<Integer>();
		int A,B;

		try {

			String input[] = br.readLine().split("\\s+");

			for(int i = 0; i < input.length; i++){
				if(checkInt(input[i])){
					S.addLast(Integer.parseInt(input[i]));
					continue;
				}

				B = S.getLast();
				S.removeLast();
				A = S.getLast();
				S.removeLast();

				if(input[i].equals("+")){
					S.addLast(A+B);
				}else if(input[i].equals("*")){
					S.addLast(A*B);
				}else if(input[i].equals("-")){
					S.addLast(A-B);
				}
			}
			System.out.println(S.peek());

		} catch (NumberFormatException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	public static boolean checkInt(String number){
		Pattern p = Pattern.compile("^[0-9]+$");
		Matcher m = p.matcher(number);
		return m.matches();
	}

}



Measured memory_bytes: 24912
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <set>
#include <queue>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int a[10];
	int b[10];
	for(int i=0;i<10;i++){
		cin >> a[i];
	}
	for(int i=0;i<10;i++){
		cin >> b[i];
	}
	sort(a,a+10);
	sort(b,b+10);
	cout << a[7]+a[8]+a[9] << " " << b[7]+b[8]+b[9] << endl;
}


Measured memory_bytes: 3152
while True:
  n, x = map(int,input().split())
  cnt = 0
  s = [0] * 3
  if n == 0 and x == 0:
    break
  for i in range(1,n+1):
    s[0] = i
    for j in range(i+1,n+1):
      s[1] = j
      for m in range(j+1,n+1):
        s[2] = m
        if sum(s) == x:
          cnt += 1
  print(cnt)


Measured memory_bytes: 5600
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

ll const MAX = 800010;
ll const A_MAX = 200005;
ll tree[MAX];
ll lazy[MAX];
ll n_ = 1;

void init(ll n) {
	while (n_ <= n) {
		n_ *= 2;
	}
	REP(i, 1, n_ * 2) {
		tree[i] = lazy[i] = 0;
	}
}

void add_o(ll u, ll v, ll x, ll k, ll l, ll r) {
	if (u <= l && r <= v) {
		if (r - l > 1) {
			lazy[k] += x;
		}
		else {
			tree[k] += x;
		}
	}
	else if (!(r <= u || v <= l)) {
		add_o(u, v, x, k * 2, l, (l + r) / 2);
		add_o(u, v, x, k * 2 + 1, (l + r) / 2, r);
	}
	if (r - l > 1) {
		tree[k] = max(tree[k * 2], tree[k * 2 + 1]) + lazy[k];
	}
}

ll query_o(ll u, ll v, ll k, ll l, ll r) {
	if (lazy[k] != 0 && r - l > 1) {
		lazy[k * 2] += lazy[k];
		lazy[k * 2 + 1] += lazy[k];
		tree[k * 2] += lazy[k];
		tree[k * 2 + 1] += lazy[k];
		lazy[k] = 0;
	}
	if (u <= l && r <= v) {
		return tree[k];
	}
	else if (r <= u || v <= l) {
		return -1e18;
	}
	else {
		ll ans1 = query_o(u, v, k * 2, l, (l + r) / 2);
		ll ans2 = query_o(u, v, k * 2 + 1, (l + r) / 2, r);
		return max(ans1, ans2);
	}
}


void add(ll l, ll r, ll x) {
	add_o(l, r, x, 1, 0, n_);
}

ll query(ll l, ll r) {
	return query_o(l, r, 1, 0, n_);
}

ll n, m;

struct range {
	ll l; ll r; ll v;
};
range a[MAX], b[MAX];
ll maxv[MAX] = {};
bool ord1(range x, range y) {
	return x.l < y.l;
}
bool ord2(range x, range y) {
	return x.r < y.r;
}

int main() {
	cin >> n >> m;
	REP(i, 1, m) {
		ll x, y, z;
		cin >> x >> y >> z;
		a[i] = b[i] = { x,y + 1,z };
	}
	init(n + 3);
	SORT_O(a, m, ord1);
	SORT_O(b, m, ord2);
	ll ttt = 1e18;
	a[m + 1] = b[m + 1] = { ttt,ttt,ttt };
	ll cur_a = 1; ll cur_b = 1;
	REP(i, 1, n) {
		while (a[cur_a].l == i) {
			add(0, a[cur_a].l, a[cur_a].v);
			cur_a++;
			//cout << i << " " << a[cur_a].l << " " << a[cur_a].v << endl;
		}
		while (b[cur_b].r == i) {
			add(0, b[cur_b].l, -b[cur_b].v);
			//cout << i << " " << b[cur_b].l << " " << -b[cur_b].v << endl;

			cur_b++; 
		}		
		ll x = query(0, i);
		add(i, i + 1, x);	
		maxv[i] = x;
		//cout << maxv[i] << endl;
	}
	ll ans = 0;
	REP(i, 1, n) {
		ans = max(maxv[i], ans);
	}
	cout << ans << endl;
}


Measured memory_bytes: 26368
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(int i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define INFI ((ll)1e9)
#define MINI ((ll)-1e16)
using namespace std;
typedef long long ll;       
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }          
int a[100001];
int res[100001];
ll n,k;


int main(){FIN;
	cin >> n >> k;
	fore(i,0,n){
		cin >> a[i];
	}
	fore(i,0,n){
		res[i]=INFI;
	}
	res[0]=0;
	fore(i,1,k){
		res[i]=abs(a[i]-a[0]);
	}
	fore(i,k,n){
		fore(j,i-k,i && j < n){
			res[i]=min(res[i],(res[j]+abs(a[j]-a[i])));
		}
	}
	cout << res[n-1];
}
	




Measured memory_bytes: 1024
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int A = Integer.parseInt(scanner.next());
        int B = Integer.parseInt(scanner.next());
        int C = Integer.parseInt(scanner.next());
        int K = Integer.parseInt(scanner.next());
        scanner.close();

        Integer[] arr = {A, B, C};
        Arrays.sort(arr, Comparator.reverseOrder());

        for (int i = 0; i < K; i++) {
            arr[0] *= 2;
        }

        int sum = 0;
        for (Integer integer : arr) {
            sum += integer;
        }

        System.out.println(sum);
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector< std::pair<int, int> > shops;

    for (int i = 0; i < n; i++) {
        int a, b;
        std::cin >> a >> b;
        shops.push_back(std::pair<int, int>(a, b));
    }

    std::sort(shops.begin(), shops.end());
    // std::cout << std::endl;

    long long money = 0;
    for (int i = 0; i < shops.size(); i++) {
        long long cost = shops[i].first;
        long long count = shops[i].second;

        // std::cout << cost << ' ' << count << ' ' << m <<  std::endl;

        if (count < m) {
            // std::cout << 'a' << std::endl;
            money = money + cost * count;
            m = m - count;
        } else {
            // std::cout << 'b' << std::endl;            
            money = money + cost * m;
            break;
        }
    }

    std::cout << std::endl << money << std::endl;
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define print(x) cout << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef complex<double> C;
typedef pair<int, int> P;
typedef pair<C, C> PCC;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3
#define MAX_N 1000000001

bool operator<(const C &a, const C &b) {
  return a.real() < b.real();
}

double cross(const C &a, const C &b) {
  return imag(conj(a) * b);
}

void intersectSS(C p1, C p2, C q1, C q2, vector<C> &v) {
  if (cross(p2 - p1, q1 - p1) * cross(p2 - p1, q2 - p1) < 0 && cross(q2 - q1, p1 - q1) * cross(q2 - q1, p2 - q1) < 0) {
    C q = q2 - q1;
    double d1 = abs(cross(q, p1 - q1));
    double d2 = abs(cross(q, p2 - q1));
    double t = d1 / (d1 + d2);
    q = C(p1 + (p2 - p1) * t);

    v.pb(q);
  }
}

double dist(C a, C b) {
  return sqrt(pow(a.real() - b.real(), 2.0) + pow(a.imag() - b.imag(), 2.0));
}

int main(){
  cin.sync_with_stdio(false);
  int n;
  while(cin >> n, n) {
    vector<PCC> v;
    int x1, x2, y1, y2, ans = 1;
    rep(i, n) {
      cin >> x1 >> y1 >> x2 >> y2;

      vector<C> p;
      rep(j, v.size()) {
        intersectSS(v[j].fi, v[j].se, C(x1, y1), C(x2, y2), p);
      }

      S s;
      rep(i, p.size() - 1)repl(j , i + 1, p.size()) if (dist(p[i], p[j]) < 1e-10) s.insert(i);
      ans += p.size() - s.size() + 1;

      v.pb(PCC(C(x1, y1), C(x2, y2)));
    }

    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 3056
N, K, S = map(int ,input().split())


if N == K:
    A = [S] * N
elif S == 10**9:
    A = [S]*K + [1]*(N-K)
elif K == 0:
    A = [S+1] * N
elif S == 1:
    A = [1]*K + [2]*(N-K)
else:
    A = [S+1] * N
    x = S // 2
    y = S - x
    for i in range(K+1):
        if i%2 == 0:
            A[i] = x
        else:
            A[i] = y

print(' '.join(map(str, A)))

Measured memory_bytes: 12068
//Subhash Suman
//Description :

#include <bits/stdc++.h>
#define ll long long int
#define pll pair<ll, ll>
#define pii pair<int, int>

using namespace std;
const int N = 5e3 + 5;
int arr[N][N];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < n - 1; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            if (s[i] == s[j])
            {
                arr[i][j] = 1;
                arr[j][i] = 1;
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i >= j)
            {
                continue;
            }
            int k = 0;
            while (arr[i + k][j + k] == 1 && i + k < j)
            {
                arr[i + k][j + k] = 0;
                k++;
            }
            ans = max(ans, k);
        }
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 98048
//Volume0-0074
import java.util.*;

public class Main {
	
    //declare
	private static final int H   = 3600,
    	                     M   =   60,
    	                     END =   -3;

    public static void main(String[] args) {
    	
    	int h,m,s,time;
    	String[] str;

    	//input
    	Scanner sc = new Scanner(System.in);
    	while(true){
    		str = sc.nextLine().split("\\s");
    		h = Integer.parseInt(str[0]);
    		m = Integer.parseInt(str[1]);
    		s = Integer.parseInt(str[2]);
    		if(h+m+s == END){break;}
    		
    		//calculate
    		time = H * 2 - (h * 3600 + m * 60 + s);
    		
    		//output
    		print(time);
    		print(time*3);
    	}
    }
    
    private static void print(int time){
    	int h,m,s,t;
    	h = time / H;
    	t = time % H;
    	m = t / M;
    	s = t % M;
    	System.out.printf("%02d:%02d:%02d\n",h,m,s);
    }
}

Measured memory_bytes: 17264
import Text.Parsec
import Text.Parsec.String
import Control.Monad
eval :: Parser Int
eval = do
    n <- read <$> many1 digit
    do  char '+'
        e <- eval
        return (n + e)
        <|> return n

main = do
    str <- getLine
    let exprs = map concat $ mapM (\x ->[[x],x:"+"]) str
        vals = map ((\x -> case x of Left _ -> 0;Right n -> n).parse eval "") exprs
    print $ sum vals

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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll a, b;
	ll count1 = 0;
	ll count2 = 0;

	cin >> a >> b;

	char ans[100][100];

	REP(i, 100) {
		REP(j, 50) {
			ans[i][j] = '#';
		}

		REP(j, 50) {
			ans[i][j + 50] = '.';
		}
	}

	REP(i, a - 1) {
		if (count1 > 98) {
			count1 = 0;
			count2 += 2;
		}

		ans[count1][count2] = '.';
		count1 += 2;
	}

	count1 = 0;
	count2 = 0;

	REP(i, b - 1) {
		if (count1 > 98) {
			count1 = 0;
			count2 += 2;
		}

		ans[count1][count2 + 51] = '#';
		count1 += 2;
	}

	cout << 100 << " " << 100 << endl;

	REP(i, 100) {
		REP(j, 100) {
			cout << ans[i][j];
		}

		cout << endl;
	}
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] arr = new int[n];
        BigInteger sum = BigInteger.ZERO;
        Map<Integer, Integer> counter = new HashMap<>();
        for (int i = 0; i < n; i++) {
            arr[i] = sc.nextInt();
            counter.put(arr[i], counter.getOrDefault(arr[i], 0) + 1);
            sum = sum.add(BigInteger.valueOf(arr[i]));
        }
        int q = sc.nextInt();
        BigInteger[] ans = new BigInteger[q];
        for (int i = 0; i < q; i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (counter.containsKey(x)) {
                int counts = counter.get(x);
                // sum += counts * (y - x);
                sum = sum.add(BigInteger.valueOf(counts).multiply(BigInteger.valueOf(y-x)));
                counter.remove(x);
                counter.put(y, counter.getOrDefault(y, 0) + counts);
            }
            ans[i] = sum;
        }
        for (BigInteger i : ans) {
            System.out.println(i);
        }
    }
}

Measured memory_bytes: 80216
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define INF 1050000000
#define N_MAX 100
#define V_MAX (int)1e9
#define W_MAX (int)1e5

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}

ll dp[N_MAX + 10][W_MAX + 10];

int main() //input->compute->output
{
        int N, W;
        cin >> N >> W;
        vector<int> we(N);
        vector<int> va(N);
        rep(i, N) { cin >> we[i] >> va[i]; }

        rep(i, N)
        {
                rep(sum_w, W+1)
                {
                        if (sum_w >= we[i])
                        {
                                dp[i + 1][sum_w] = max(dp[i][sum_w], dp[i][sum_w - we[i]] + va[i]);
                        }
                        else
                        {
                                dp[i + 1][sum_w] = dp[i][sum_w];
                        }
                }
        }
        // rep(i, N + 1)
        // {
        //         rep(j, W + 1)
        //         {
        //                 if (j != 0)
        //                 {
        //                         cout << ' ';
        //                 }
        //                 cout << dp[i][j];
        //         }
        //         cout << endl;
        // }

        cout << dp[N][W] << endl;
        return 0;
}

Measured memory_bytes: 79360
import Control.Monad
import Data.Maybe
import Data.List
import qualified Data.ByteString.Char8 as BS
import qualified Data.Vector as V

main = abc132c

abc132c = do
    n  <- getIntList
    dL <- getIntList
    let (small, large) = getMedian dL
    print $ large - small
    
getMedian :: [Integer] -> (Integer, Integer)
getMedian dL = let sorted = V.fromList (sort dL)
                   num = V.length sorted
                in (sorted V.! (div num 2 - 1), sorted V.! div num 2)

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words
getIntList = readIntList <$> BS.getLine

Measured memory_bytes: 18812
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
std::vector<int> w(1000000),wm(1000000);
int pw(int n,int k){
  int res=1;
  while(k){
    if(k%2)res*=n;res%=MOD;
    k/=2;
    n*=n;n%=MOD;
  }
  return res;
}
int nCk(int n,int k){
  int res=w[n];
  res*=wm[n-k];res%=MOD;
  res*=wm[k];res%=MOD;
  return res;
}
//main
signed main(){

  w[0]=1;for(int i=1;i<1000000;i++)w[i]=w[i-1]*i%MOD;
  for(int i=0;i<1000000;i++)wm[i]=pw(w[i],MOD-2);

  int N;cin>>N;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];

  std::vector<int> p(N);
  for(int i=0;i<N;i++)p[i]=((nCk(N,i+1)*w[i])%MOD*w[N-i-1])%MOD;
  for(int i=1;i<N;i++){
    p[i]+=p[i-1];p[i]%=MOD;
  }
  int ans=0;
  for(int i=0;i<N;i++){
    ans+=v[i]*(p[N-1-i]+p[i]-w[N]+MOD)%MOD;
    ans%=MOD;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 17408
#include<bits/stdc++.h>
using namespace std;
#define max1 1000005
#define sz1 100001
#define mod 1000000007
#define moda 421412341324321ll
#define inf 1e18
#define ll long long int
#define debug(x) cout<<#x<<" "<<x<<endl
typedef pair<ll,ll> pr;
#define rte cout<<"Correct";exit(0);
int intlog(double x) {
    return (int)(log(x) / log(2));
}
double max(double x,double y)
{
    if(x>=y)
    {
        return x;
    }
    else
    {
        return y;
    }
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif*/
  ll l,r;
  cin>>l>>r;
  if(l>=1&&l<=9)
  {
    if(r>=1&&r<=9)
    {
        cout<<l*r;
        return 0;
    }
  }
  cout<<-1<<endl;
} 

Measured memory_bytes: 256
N = int(input())
A = [*map(int, input().split(' ')), 0]

up = True
points = []

for a0, a1 in zip(A, A[1:]):
    if up:
        if a0 < a1:
            up = False
            points.append(a0)
    else:
        if a0 > a1:
            up = True
            points.append(a0)

money = 1000
tickets = 0

for i in range(len(points)):
    if i % 2 == 1:
        money += points[i] * tickets
        tickets = 0
    if i % 2 == 0 and i + 1 < len(points):
        tickets = money // points[i]
        money -= tickets * points[i]

print(money)


Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define REP(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define rep1(i,x,n) for(int (i)=(x);(i)<(int)(n);(i)++)
#define REP1(i,x,n) for(int (i)=(x);(i)<=(int)(n);(i)++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Int = long long;
 
//INT_MAX = 2147483647;
//LLONG_MAX = 9223372036854775807;
//ULLONG_MAX = 18446744073709551615;
const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
typedef pair<int,int> P;
typedef std::priority_queue<int> IntPrioQueue;
typedef std::priority_queue<int, std::vector<int>, std::greater<int> > IntReversePrioQueue;
 
//少数点表示
//cout << std::fixed << std::setprecision(14) << 値
 
int main(){
    cin.tie( 0 ); ios::sync_with_stdio( false );
 
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    
    rep(i,n){
        if(a[i]==0){
            cout << "0" << endl;
            return 0;
        }
    }
    
    ll ans = 1;
    
    rep(i,n){
        if(a[i]<=1000000000000000000/ans){
            ans *= a[i];
        }else{
            cout << "-1" <<endl;
            return 0;
        }
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 3952
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a[ohara], b, c, d, tmp, m, h, w, x, y, sum[ohara], k, q,
    l[ohara], r[ohara];

template <class T>
vector<ll> Zarts(const vector<T> &AR, ll CNT = 0) {
  vector<ll> RES;
  map<T, ll> MP;
  for (auto &e : AR) MP[e] = 0;
  for (auto &e : MP) e.se = CNT++;
  for (auto &e : AR) {
    // fukugen[MP[e]] = e;
    RES.push_back(MP[e]);
  }
  return RES;
}

int main(void) {
  cin.tie(0);
  cout.tie(0);
  ios::sync_with_stdio(false);

  cin >> n >> q;
  V a_in(n + 2 * q + 1);
  ll now = 0;
  rep(i, n) cin >> a_in[now++];
  rep(i, q) {
    cin >> a_in[now] >> a_in[now + q];
    now++;
  }
  auto af = Zarts<ll>(a_in);
  now = 0;
  rep(i, n) a[i] = af[now++];
  rep(i, q) {
    l[i] = af[now];
    r[i] = af[now + q];
    now++;
  }

  rep(i, n) sum[a[i]]++;
  rrep(i, 1, ohara) sum[i] += sum[i - 1];
  rep(i, q) { Cout(sum[r[i]] - sum[l[i] - 1]); }
  return 0;
}


Measured memory_bytes: 36672
/* ****Ragnar7 _Lawliet_**** */
/* First, solve the problem.Then write the code. */
#include<bits/stdc++.h>
#define ll          long long
#define ld 			long double
#define hell        1000000007
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifndef ONLINE_JUDGE
	freopen ("input.txt","r",stdin);
	// freopen ("output.txt","w",stdout);
	#endif
	ll t = 1;
	// cin>>t;
	while(t--)
	{
		string s;
		cin>>s;
		ll ans =0 ;
		for(ll i=0;i<s.size();i++)
			ans+=(s[i]-'0');
		if(ans%9==0)
			cout<<"Yes";
		else
			cout<<"No";
		
	}

	
	time
	return 0;
}

Measured memory_bytes: 3728
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

const int N = (int)3e5;

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}



int main(void){
	int n;cin>>n;
	vector<int> A,B;
	ll ans = 0,sum=0;;
	//, adv = 0;
	rep(i,n){
		int a,b;cin>>a>>b;
		sum+=b;
		if(a <= b){
			ans += b;
			//adv += b-a;
			continue;
		}
		A.push_back(a);B.push_back(b);
	}
	if(A.size() == 0){
		cout<<0<<endl;
		return 0;
	}
	sort(all(B));
	cout<<sum-B[0]<<endl;
	return 0;
}


Measured memory_bytes: 384
def change(num):
    if num<0:
        return str(num)
    else:
        return "+"+str(num)

a,b,c,d=[int(i) for i in input()]
for i in range(10):
    for j in range(-9,10):
        for k in range(-9,10):
            if 9>=7-(i+j+k)>=-9:
                if i==a and abs(j)==b and abs(k)==c and abs(7-(i+j+k))==d:
                    print(str(i)+change(j)+change(k)+change(7-(i+j+k))+"=7")
                    exit()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using Pair = pair<int, int>;
using Vec = vector<int>;
using Graph = vector<Vec>;

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    int n;
    cin >> n;
    vector<int> d,a(n),p(n),q(n);
    rep(i,n){
        cin >> p[i];
    }
    rep(i,n)cin >> q[i];
    rep(i,n)a[i] = i+1;
    int num = 0;
    int anum = 0,bnum = 0;
    do{
        num++;
        bool ok = true;
        rep(i,n){
            if(a[i] != p[i]){
                ok = false;
                break;
            }
        }
        if(ok)anum = num;
        ok = true;
        rep(i,n){
            if(a[i] != q[i]){
                ok = false;
                break;
            }
        }
        if(ok) bnum = num;



    }while(next_permutation(a.begin(),a.end()));
    int ans = abs(anum - bnum);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++) 
#define all(v) begin(v),end(v)
using ll = long long;

int main() {
  string a,b;cin>>a>>b;
  rep(i,a.size()){
    cout<<a[i];
    if(i<b.size())cout<<b[i];
  }
  cout<<endl;
}


Measured memory_bytes: 3568
from math import gcd
from functools import reduce


def lcm(x, y):
    return x * y // gcd(x, y)


def count_2p(n):
    res = 0
    while n % 2 == 0:
        res += 1
        n //= 2
    return res


N, M = map(int, input().split())
X = list(map(int, input().split()))

p2_cnt = [count_2p(n) for n in X]
if all(p2_cnt[0] == p2_cnt[i] for i in range(N)):
    a = reduce(lcm, X)
    cnt = M // (a // 2)
    print(-(-cnt // 2))
else:
    print(0)


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

using namespace std;

int main()
{
  long long N,K;
  cin>> N>> K;

  long long ret=0;  
  for(int i=K+1;i<=N;i++)
  {
    ret+=(N/i)*(i-K);
    if(N%i>=K)ret+=N%i-K+1;  
    cerr<< i<< ": "<< ret<< endl;
  }
  if(K==0)ret=N*N;
  cout<< ret<< endl;

  return 0;
}


Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


s = input()
n = len(s)
v = []
i = 0
tmp = []
while i<n:
    if s[i]=="A":
        tmp.append(0)
        i += 1
    elif i<n-1 and s[i]=="B" and s[i+1]=="C":
        tmp.append(1)
        i += 2
    else:
        i += 1
        if tmp:
            v.append(tmp)
        tmp = []
if tmp:
    v.append(tmp)
ans = 0
for l in v:
    val = 0
    for c in l:
        if c==1:
            ans += val
        else:
            val += 1
print(ans)

Measured memory_bytes: 79860
using System;
using System.Collections.Generic;
using System.Linq;

public struct Point
{
    public int X;
    public int Y;

    public Point(Point p)
    {
        X = p.X;
        Y = p.Y;
    }

    public Point(int x, int y)
    {
        X = x;
        Y = y;
    }

    public static bool operator ==(Point a, Point b)
    {
        return (a.X == b.X && a.Y == b.Y);
    }

    public static bool operator !=(Point a, Point b)
    {
        return !(a == b);
    }

    //objと自分自身が等価のときはtrueを返す
    public override bool Equals(object obj)
    {
        if (!(obj is Point))
        {
            return false;
        }

        Point p = (Point)obj;
        return (X == p.X && Y == p.Y);
    }

    //Equalsがtrueを返すときに同じ値を返す
    public override int GetHashCode()
    {
        return (X << 16) ^ Y;
    }

    public Point Clone()
    {
        return new Point(X, Y);
    }

    public void Reverse()
    {
        X = -X;
        Y = -Y;
    }

    public static Point operator +(Point a, Point b)
    {
        return new Point(a.X + b.X, a.Y + b.Y);
    }

    public static Point operator -(Point a, Point b)
    {
        return new Point(a.X - b.X, a.Y - b.Y);
    }

    public static Point operator *(Point a, int i)
    {
        return new Point(a.X * i, a.Y * i);
    }

    public static Point operator /(Point a, int i)
    {
        return new Point(a.X / i, a.Y / i);
    }
    public static Point operator +(Point a)
    {
        return new Point(+a.X, +a.Y);
    }

    public static Point operator -(Point a)
    {
        return new Point(-a.X, -a.Y);
    }

    public override string ToString()
    {
        return string.Format("({0},{1})", X, Y);
    }

    public int Mdistance(Point that)
    {
        return Math.Abs(X - that.X) + Math.Abs(Y - that.Y);
    }
}

class Solution
{
    static void Main()
    {
        var n = int.Parse(Console.ReadLine());

        var curPoint = new Point(0, 0);
        var curTime = 0;
        for (int i = 0; i < n; i++)
        {
            var vals = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            var nextTime = vals[0];
            var nextPoint = new Point(vals[1], vals[2]);

            var distance = curPoint.Mdistance(nextPoint);
            var t = nextTime - curTime;
            if (distance > t || distance % 2 != t % 2)
            {
                Console.WriteLine("No");
                return;
            }

            curTime = nextTime;
            curPoint = nextPoint;
        }

        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 17452
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K,x=1;
  cin >> N >> K;
  
	for (int i = 0; i < N; i++){
       	if(x<K) x*=2;
      	else x+=K; 
  
      
  
	}
  
  cout <<  x << endl;
  
  
  
 }
  



Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a = [(a[i], i) for i in range(n)]
a.sort(key=lambda x: -x[0])
dp = [[0 for _ in range(n+1)] for _ in range(n+1)]

for x in range(n+1):
    for y in range(n+1):
        if x + y > n:
            break
        active, idx = a[x+y-1]
        if x > 0:
            dp[x][y] = max(dp[x][y],
                           dp[x-1][y] + active * abs(idx - (x-1)))

        if y > 0:
            dp[x][y] = max(dp[x][y],
                           dp[x][y-1] + active * abs(idx - (n-y)))

ans = 0
for x in range(n+1):
    ans = max(ans, dp[x][n-x])

print(ans)

Measured memory_bytes: 101920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  vector<int> c(3);
  int remain;
  for(int i = 0; i < c.size(); i++) {
    cin >> c.at(i);
  }
  remain = c.at(2) - (c.at(0) - c.at(1));
  
  if(remain < 0 ) {
    remain = 0;
  }
  cout << remain << endl;
}

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

int main()
{
	string str;
	cin >> str;
	long long ans=0;
	for(int i=0;i<str.length();i++)
    {
        ans+=(str[i]-'0');
    }
    if(ans%9==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
	return 0;
}


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

int main() {
#ifdef HOME
	freopen("arc59b.in", "r", stdin);
	freopen("arc59b.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string str;

	cin >> str;
	for (int i = 1; i < str.size(); ++i)
		if (str[i] == str[i - 1]) {
			cout << i << ' ' << i + 1 << endl;
			return 0; }

	for (int i = 2; i < str.size(); ++i)
		if (str[i] == str[i - 2]) {
			cout << i - 1 << ' ' << i + 1 << endl;
			return 0; }

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

	return 0; }


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int a, b;

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	cout << ((a % 3 && b % 3 && (a + b) % 3) ? "Impossible\n" : "Possible\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(x) (x).begin(),(x).end()
#define dup(x,y) (((x)+(y)-1)/(y))
#define sz(x) (int)(x).size()
#define MOD 1000000007
#define pint pair<int,int>
#define pdouble pair<double,double>
using namespace std;
typedef long long ll;

int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a/2.0 == c && b/2.0 == d) cout << a*b/2.0 << " 1" << endl;
    else cout << a*b/2.0 << " 0" << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
import re
import math
#import numpy as np

mod=int(10**9+7)

#main
N=int(input())
A=[[0 for a in range(11)] for b in range(11)]
for a in range(1,N+1):
    sa=str(a)
    A[int(sa[0])][int(sa[-1])]+=1
ans=0
for b in range(1,10):
    for e in range(1,10):
        ans+=A[b][e]*A[e][b]
print(ans)

Measured memory_bytes: 41580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i< (n); ++i)
const long long INF = 1LL<<58;

// aを常に小さい値にする
template<class T> void chmin(T &a, T b){ if(a>b) a = b; }
template<class T> void chmax(T &a, T b){ if(a<b) a = b; }

// 二分探索 前方のindexを返すもの（自分自身を含む） 前方: -INF側のこと
template<class T> int former(const vector<T> &v, T x){
    return upper_bound(v.begin(), v.end(), x) - v.begin() -1; // upper_bound : keyより大きい要素の内の一番左側のイテレータを返す
}
// 二分探索 後方のindexを返すもの（自分自身を含む）後方: INF側のこと
template<class T> int latter(const vector<T> &v, T x){
    return lower_bound(v.begin(), v.end(), x) - v.begin(); // lower_bound : key以上の要素の内の一番左側のイテレータを返す
}

/*
 * */

bool check(char c){
    return (c == 'A' || c == 'C' || c == 'G' || c == 'T');
}

int main() {
    string s;
    cin >> s;

    int max = 0;
    int count = 0;
    for (int i = 0; i < s.size(); ++i) {
        if(check(s[i])){
            count++;
            chmax(max, count);
        }else{
            count = 0;
        }
    }

    cout << max << endl;
}

Measured memory_bytes: 256