akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;
const double PI = acos(-1.0);


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * b / g;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
map<ll, ll> prime_factor(ll n) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}



const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int a, b, c, d; cin >> a >> b >> c >> d;
	a--;
	int tmp = lcm(c, d);
	int ans = b - (b / c + b / d - b / tmp);
	if (a == 0) {
		cout << ans << endl;
		return 0;
	}
	ans -= a - (a / c + a / d - a / tmp);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
#pragma GCC target("avx2")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
#include <random>
#include <deque>
#include <bitset>
#include <string>
#include <queue>
#include <complex>

//#define int long long

#define mp(a, b) make_pair(a, b)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

#define endl '\n'


using namespace std;
typedef long long ll;
typedef long double ld;

mt19937 mrand(random_device{}());

const double PI = acos((double)-1);
const double eps = 1e-7;
const ll inf0 = 1023 * 1024 * 1024;
const ll inf = inf0 * inf0;
const ll mod = 1e9 + 7;
//const ll mod = 998244353;

void solve();
void scan();

signed main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);
	cout << fixed; cout.precision(15);
	solve();
	return 0;
}

ll foo(ll a, ll b, ll x) {
	return (a * x / b) - a * (x / b);
}

void solve() {
	ll a, b, n; cin >> a >> b >> n;
	ll kek = n / b * b;
	ll a1 = foo(a, b, n);
	ll a2 = foo(a, b, kek - 1);
	cout << max(a1, a2) << endl;
	return;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt();
		int []a=new int [n+1];
		for(int i=1;i<=n;i++)
			a[i]=sc.nextInt();
		ArrayList<Integer>ans=new ArrayList();
		boolean ok=true;
		boolean[]put=new boolean[n+1];
		for(int i=n;i>0;i--) {
			if(i*2>n) {
				if(a[i]==1)
					put[i]=true;
				continue;
			}
			int cnt=0;
			for(int j=i+i;j<=n;j+=i)
				if(put[j])
					cnt++;
			cnt%=2;
			int curr=cnt^a[i];
			if(curr==1)
				put[i]=true;
			
		}
		int cnt=0;
		for(boolean b:put)
			if(b)
				cnt++;
		out.println(cnt);
		for(int i=1;i<=n;i++)
			if(put[i])
				out.println(i);
		out.close();

	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

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

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready();
		}

	}

}

Measured memory_bytes: 45068
#include<iostream>
#include<vector>

const int mod = 1e+9 + 7;

int main(){
    int N;
    std::cin >> N;
    std::vector< long long > A(N);
    for(int i=0; i<N; i++){
        std::cin >> A[i];
    }
    
    long long ans = 0;
    for(int i=0; i<60; i++){
        long long bit0 = 0, bit1 = 0;
        for(int j=0; j<N; j++){
            if(A[j] >> i & 1){
                bit1++;
            }else{
                bit0++;
            }
        }
        long long mask = (1ll << i) % mod;
        long long tmp = (bit0 * bit1) % mod;
        long long plus = (tmp * mask) % mod;
        ans = (ans + plus) % mod;
    }
    
    std::cout << ans << std::endl;
    return 0;
}
    



Measured memory_bytes: 2560
MOD=(10**9)+7
$fac=[]
$finv=[]
$inv=[]
$fac[0] = 1
$fac[1] = 1
$inv[0] = 1
$finv[1] = 1
$inv[1] = 1
for i in 2..1000000*2/3
  $fac[i] = $fac[i - 1] * i % MOD
  $inv[i] = MOD - $inv[MOD%i] * (MOD / i) % MOD
  $finv[i] = $finv[i - 1] * $inv[i] % MOD
end

def com(n,k)
  return 0 if n<k
  return 0 if(n<0 || k<0)
  return $fac[n] * ($finv[k] * $finv[n - k] % MOD) % MOD;
end

x,y=gets.chomp.split(" ").map{|s| s.to_i}
if (x+y)%3!=0
  p 0
  exit
end

u=[x,y].max
v=[x,y].min
c=0
while u!=v && u>=0 && v>=0
  u-=2
  v-=1
  c+=1
end
if u<0 ||v<0
  p 0
  exit
end


p=u/3
if p!=0
  p com(c+p*2,p)%MOD
else
  p 1
end


Measured memory_bytes: 19556
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << setprecision(20);
    ll a,b,x; cin >> a >> b >> x;
    b /= x;
    if(a == 0) cout << b+1 << endl;
    else cout << b-(a-1)/x << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> card(N);
  for (int i=0 ; i<N ; i++){
    int a;
    cin >> a;
    card.at(i) = a;
  }
  sort(card.begin(),card.end());
  reverse(card.begin(),card.end());
  int Answer = 0;
  for (int i=0; i<N ; i++){
    if (i%2 == 0){
      Answer += card.at(i);
    }
    if (i%2 == 1){
      Answer -= card.at(i);
    }
  }
  cout << Answer << endl;
}



Measured memory_bytes: 256
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
# do magic here
n = int(input())
heights = [int(x) for x in input().split()]

dp = [0 for x in range(n+1)]

dp[1] = abs(heights[1]-heights[0])

for x in range(2, n):
    a = abs(heights[x]-heights[x-1]) + dp[x-1]
    b = abs(heights[x]-heights[x-2]) + dp[x-2]
    dp[x] = min(a, b)

print(dp[n-1])


Measured memory_bytes: 21084
#include <bits/stdc++.h>
using namespace std;
#pragma region
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << (#x) << "] = [", _print(x)
#else
#define debug(x...)
#endif
#pragma endregion
typedef long long ll;
#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define sz(v) int((v).size())
#define int ll
#define f first
#define s second
#define mp make_pair
#define mt make_tuple
#define pb push_back

int n;
vector<int> a;
void solve()
{
    cin>>n;
    a.resize(n);
    forn(i, n) cin>>a[i];
    map<int, int> cnt;
    int ans = 0;
    forn(i, n)
    {
        ans += cnt[i - a[i]];
        cnt[i+a[i]]++;
    }
    cout << ans << '\n';
}

signed main()
{
    int T = 1;
    ios_base::sync_with_stdio(0); cin.tie(0);
    //cin >> T;
    for(int i=1;i<=T;++i)
    {
        //cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 27428
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>
#include <memory>
#include <stack>
#include <numeric>
#include <climits>
#include <cfloat>
#include <bitset>

int main() {
	int k, x; std::cin >> k >> x;
	for (auto i = x - k + 1; i < x + k; ++i) {
		if (i != x - k + 1) std::cout << ' ';
		std::cout << i;
	}
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
#ifdef LOCAL
#define debug(x) cerr << #x << ": " << x << endl
#else
#define debug(x)
#endif
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

int H, W;
char C[20][20];

int solve(int Y, int X){
	int cost[20][20];
	rep(i, H){
		rep(j, W){
			cost[i][j] = INT_MAX;
		}
	}
	cost[Y][X] = 0;
	queue<pair<int, int>> que;
	que.push({ Y, X });
	while(!que.empty()){
		int y = que.front().first;
		int x = que.front().second;
		que.pop();
		rep(i, 4){
			if(0 <= y+dy[i] && y+dy[i] < H && 0 <= x+dx[i] && x+dx[i] < W){
				if(C[y+dy[i]][x+dx[i]] == '.' && cost[y+dy[i]][x+dx[i]] > cost[y][x]+1){
					cost[y+dy[i]][x+dx[i]] = cost[y][x]+1;
					que.push({ y+dy[i], x+dx[i] });
				}
			}
		}
	}
	int ret = 0;
	rep(i, H){
		rep(j, W){
			if(cost[i][j] == INT_MAX) continue;
			ret = max(ret, cost[i][j]);
		}
	}
	return ret;
}

signed main(){
	cin >> H >> W;
	rep(i, H){
		rep(j, W){
			cin >> C[i][j];
		}
	}

	int ans = 0;
	rep(i, H){
		rep(j, W){
			if(C[i][j] == '#') continue;
			ans = max(ans, solve(i, j));
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

int main(){
	int a,b;
	int x,y;
	int tmp;
	cin >> a >> b;
	x = max(a,b);
	y = min(a,b);
	while(1){
		if(y == 0) break;
		tmp = y;
		y = x%y;
		x = tmp;
	}
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n,m;cin>>n>>m;
    int p;
    string s;
    vector<bool> c(n,false);
    vector<int> pen(n,0);
    for(int i=0;i<m;i++){
        cin>>p>>s;
        if(s=="AC"){
            c[p-1] = true;
        }
        else if(s=="WA"&&c[p-1]==false){
            pen[p-1]++;
        }
    }
    int ac=0;
    int pensum=0;
    for(int i=0;i<n;i++){
        if(c[i]==true){
            ac++;
            pensum += pen[i];
        }
    }
    cout<<ac<<' '<<pensum<<endl;
}

Measured memory_bytes: 640
MOD=10**9+7
N=int(input())
if N==3:
  print(61)
  exit()
  
dp=[[[[1]*4 for c in range(4)] for b in range(4)] for a in range(4)]
        
for x in range(4):
  dp[0][x][2][1]=0
  dp[0][2][x][1]=0
  dp[0][1][2][x]=0
  dp[2][0][1][x]=0
  dp[0][2][1][x]=0
  dp[x][0][1][2]=0
  dp[x][2][0][1]=0
  dp[x][0][2][1]=0
  
def f():
  tmp=[[[[0]*4 for c in range(4)] for b in range(4)] for a in range(4)]
  for a in range(4):
    for b in range(4):
      for c in range(4):
        t=sum([dp[x][a][b][c] for x in range(4)])
        t%=MOD
        for d in range(4):
          tmp[a][b][c][d]=t
          
  for x in range(4):
    tmp[0][x][2][1]=0
    tmp[0][2][x][1]=0
    tmp[x][0][1][2]=0
    tmp[x][2][0][1]=0
    tmp[x][0][2][1]=0
    
  return tmp
  
for k in range(4, N):
  dp=f()
  
print(sum([dp[a][b][c][d] for a in range(4) for b in range(4) for c in range(4) for d in range(4)])%MOD)

Measured memory_bytes: 3192
#include <stdio.h>
#include <utility>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int i,j,n,x,y,L=1000000;
  vector<pair<int,int> >a;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d %d",&x,&y);
    a.push_back(make_pair(x,y));}
  sort(a.begin(),a.end());
  for(i=1;i<n;i++)
    for(j=i-1;j>=0;j--){
      x=a[i].first-a[j].first;
      y=a[i].second-a[j].second;
      if (x*x>=L)break;
      L=min(L,x*x+y*y);}
  printf("%d\n",L);
}

Measured memory_bytes: 6820
#include<bits/stdc++.h>
#define mp make_pair
// #define pb push_back
#define ll long long
#define endl "\n"
using namespace std;



int main() {
	ll n,k;
	cin>>n>>k;
	ll h[n];
	for(ll i=0;i<n;i++){
		cin>>h[i];
	}
	ll dp[n];
	dp[0]=0;
	if(n==1){
		cout<<"0"<<endl;
		return 0;
	}
	for(int i=1;i<n;i++){
		ll ans=LLONG_MAX;
		for(int j=i-1;(j>=0&&j>=i-k);j--){
			ans=min(ans,dp[j]+abs(h[i]-h[j]));
		}
		dp[i]=ans;
	}
	cout<<dp[n-1]<<endl;
}









Measured memory_bytes: 5112
s = input()
cs = []
c=0
st=0
for i in range(len(s)):
    if st == 0:
        if s[i] == "A" or s[i]=="T" or s[i] == "C" or s[i]=="G":
            st = 1
            c += 1
    elif st == 1:
        if s[i] == "A" or s[i]=="T" or s[i] == "C" or s[i]=="G":
            c += 1
        else:
            st = 0
            cs.append(c)
            c=0
cs.append(c)
print(max(cs))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;

int main() {
  long n, m, a=0, inf=1000000000001;
  cin >> n;
  rep(i,1,pow(2*n, 0.5)){
    m=n/i;
    if(m*i==n){
      inf=min(inf, m+i-2);
    }
  }
  co(inf);
  
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#define REP(i, n) for(int i = 0; i < n; ++i)
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    float A, B, C, D, E, F;
    cin >> A >> B >> C >> D >> E >> F;
    float ansa = 100*A, anss = 0, rec = 0;
    REP(a, F/(100*A)){
        REP(b, F/(100*B)){
            REP(c, F/C){
                REP(d, F/D){
                    if (a == 0 && b == 0){
                        break;
                    }
                    float water = 100*A*a+100*B*b;
                    float sugar = C*c+D*d;
                    float per = sugar/(water+sugar);
                    if (water + sugar > F){
                        break;
                    }
                    if (sugar/water > E/100){
                        break;
                    }
                    if (rec < per){
                        rec = per;
                        ansa = water + sugar;
                        anss = sugar;
                    }
                }
            }
        }
    }
    cout << int(ansa) << ' ' << int(anss) << '\n';
    return 0;
}

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

int main(){
  vector<char> tmp(3);
  int ans=1000;
  cin>>tmp[0] >>tmp[1];
  while(cin>>tmp[2]){
    ans=min(ans,abs(100*(tmp[0]-'0')+10*(tmp[1]-'0')+(tmp[2]-'0')-753));
    tmp[0]=tmp[1];
    tmp[1]=tmp[2];
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu) FUNC(printe) FUNC(printe0);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int l, r, d;
    cin >> l >> r >> d;
    int ans = 0;
    for(int i = l; i <= r; i++){
        ans += i % d == 0;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3164
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int64 n;
  scanf("%lld", &n);
  int q = (int)sqrt((double)n) + 10;
  int64 ret = 0;
  for (int i = 1; i <= q; ++i) {
    if (n % i == 0) {
      int64 cur = n / i - 1;
      if (i < cur) ret += cur;
      // trace(i, cur);
    }
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
s = input()
kb = ''
if k >= 2:
  kb = s[:k-1]
kk = s[k-1]
ka = ''
if k < len(s):
  ka = s[k:]

if kk == 'A':
  print(kb + 'a' + ka)
  exit()
if kk == 'B':
  print(kb + 'b' + ka)
  exit()
if kk == 'C':
  print(kb + 'c' + ka)
  exit()  

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define Eback(s) s.erase(s.end()-1,s.end())
#define pb push_back
#define pf push_front
#define mod 1000000007
#define m_p make_pair
#define DOUBLE fixed << setprecision(15)
#define OK puts("OK")
#define OK1 puts("OK1")
#define OK2 puts("OK2")
#define SIZE(s) (int)s.size()
#define Cout(n) cout<<(n)<<endl
#define INF 1000000000000000000LL

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<pair<int,int>> vpii;
typedef vector<pair<ll,ll>> vpll;
typedef vector<string> vs;
const double pi = acos(-1.0);

template<class A, class B>
ostream& operator<<(ostream& ost, const pair<A, B>&p) {
	ost << "{" << p.first << ", " << p.second << "} ";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost, const vector<T>&v) {
	ost << "{";
	for (int i = 0; i<(int)v.size(); i++) {
		if (i)ost << " ";
		ost << v[i];
	}
	ost << "} \n";
	return ost;
}

template<class A, class B>
ostream& operator<<(ostream& ost, const map<A, B>&v) {
	ost << "{";
	for (auto p:v) {
		ost << "{" << p.first << ", " << p.second << "} ";
	}
	ost << "} ";
	return ost;
}

ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

int main()
{
	ll a,b;
	cin >> a >> b;
	if(a<b){
		rep(i,b) cout << a;
	}
	else{
		rep(i,a) cout << b;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	vector<vector<int>>arr(m+1);
	vector<int>p(m+1,0);
	for(int i=0;i<m;i++){
		int temp;
		cin>>temp;
		arr[i+1]=vector<int>(temp);
		for(int j=0;j<temp;j++)
		cin>>arr[i+1][j];
	}
	for(int i=0;i<m;i++){
		cin>>p[i+1];
	}
	vector<int>result(n+1,0);
	int ans=0;
	for(int l=0;l<pow(2,n);l++){
		// cout<<"result:";
		// for(int ll=1;ll<=n;ll++){
		// 	cout<<result[ll]<<" ";
		// }
		// cout<<endl;
		int i;
		for(i=1;i<=m;i++){
			int count=0;
			for(int j=0; j<arr[i].size();j++){
				if(result[arr[i][j]]==1)
					count++;
			}
			// cout<<"i:"<<i<<"count:"<<count<<"\n";
			if((p[i]==1 && count%2==0) || (p[i]==0 && count%2==1)){
				break;
			}
		}
		if(i==m+1)
			ans++;
		// cout<<"ans:"<<ans<<endl;
		int sum=1,carry=0;
		for(int k=result.size()-1;k>=0;k--){
			sum+=result[k]+carry;
			result[k]=sum%2;
			carry=sum/2;
			sum=0;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 384
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


class UnionFind:
    # Reference: https://note.nkmk.me/python-union-find/
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def size(self, x):
        return -self.parents[self.find(x)]


def main():
    N, M, *AB = map(int, read().split())

    uf = UnionFind(N)
    for a, b in zip(*[iter(AB)] * 2):
        uf.union(a - 1, b - 1)

    ans = 0
    for i in range(N):
        if ans < uf.size(i):
            ans = uf.size(i)

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 118356
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <numeric>
#include <array>
#include <cmath>
#include <memory>
#include <map>
#include <set>
#include <bitset>
#include <fstream>
#include <iomanip>
using namespace std;
//変数デバッグ
#define DEB(variable) cout << #variable << '=' << variable << endl

//for簡易表記(引数ミス防止)
#define FOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin); (LoopVariable) < (numberOFend); (LoopVariable)++)
#define DEFOR(LoopVariable,numberOFbegin,numberOFend) for (long long int LoopVariable = (numberOFbegin)-1; (LoopVariable) >= (numberOFend); (LoopVariable)--)
#define REP(LoopVariable,numberOFend) for(long long int LoopVariable = 0;(LoopVariable)<(numberOFend);LoopVariable++)

constexpr long long int linf = numeric_limits<long long int>::max()-5;
constexpr int inf= numeric_limits<int>::max()-5;
constexpr long long int mod = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    vector<vector<int>> v(m,vector<int>(n,0));
    int tmpa,tmpb;
    REP(i,m){
        cin >> tmpa;
        REP(j,tmpa){
            cin >> tmpb;
            v[i][tmpb-1]=1;
        }
    }
    int p = 0;
    REP(i,m){
        cin >> tmpa;
        p = (p * 2) + tmpa;
    }
    //cout << bitset<32>(p) << endl;

    vector<int> switches(n,0);
    REP(i,n){
        REP(j,m){
            switches[i] = switches[i] * 2 + v[j][i];
        }
       // cout << bitset<32>(switches[i]) << endl;
    }
    int result = 0;
    REP(i,1ll<<n){
        tmpa = 0;
        REP(j,n){
            if((1<<j)&i){
                tmpa ^= switches[j];
            }
        }
        if(tmpa==p){
            result++;
        }

    }
    cout << result << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        String a = sc.next();
        String b = sc.next();

        if (a.equals(b.substring(0,b.length()-1)) && (b.length() == (a.length()+1)))
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


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

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

    int sum=0,b=0;

    for(int i=0;i<s.size();i++){
        if(s[i]=='A'||s[i]=='C'||s[i]=='G'||s[i]=='T') sum++;
        else{
            if(sum>b){
                b=sum;
                sum=0;
            }
        }
    }

    if(sum>b) cout<<sum<<endl;
    else cout<<b<<endl;
}

Measured memory_bytes: 3628
from collections import deque

n = int(input())
h = list(map(int, input().split()))

h.sort()
h.reverse()

en = deque()
ans = 0

for i, j in enumerate(h):
    if i == 0:
        en.append((j,j))
    else:
        maxtmp, mintmp = en.popleft()
        ans += mintmp
        en.append((maxtmp, j))
        en.append((mintmp, j))

print(ans)


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

int main() {
	int x, a, b;
	cin >> x >> a >> b;
	if (b - a <= 0) cout << "delicious" << endl;
	else if (b - a <= x) cout << "safe" << endl;
	else  cout << "dangerous" << endl;
	return 0;
}


Measured memory_bytes: 256
from collections import Counter 
from collections import defaultdict
from collections import deque
import math
import itertools
import heapq
import numpy as np
import sys
sys.setrecursionlimit(10**6)

#n=int(input())
#n,m=list(map(int,input().split()))
#a=list(map(int,input().split()))
input_list = lambda : list(map(int,input().split()))


w,h,x,y=input_list()
ans=w*h/2
mul=0
if w==x*2 and h==y*2:
    mul=1

print(ans,mul)

Measured memory_bytes: 22036
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
from time import time

def is_prime(n):
    if n == 1:
        return 0
    i = 2
    while i**2 <= n:
        if n % i == 0:
            return 0
        i += 1
    return 1

def main():
    q = int(input().strip())
    n = 10**5
    ary = [0] * (n+1)
    ary2 = [0] * (n+1)
    arys = [0] * (n+2)
    for i in range(2, n+1):
        ary[i] = is_prime(i)
    for i in range(1, n+1):
        ary2[i] = ary[i] & is_prime((i+1)//2)
    for i in range(1, n+2):
        arys[i] = arys[i-1] + ary2[i-1]
    # print(ary[:20])
    # print(ary2[:20])
    # print(arys[:20])
    for i in range(q):
        l, r = map(int, input().strip().split())
        print(arys[r+1] - arys[l])

if __name__ == '__main__':
    main()


Measured memory_bytes: 54360
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class UnionFind {
private:
	vector<int> data;

public:
	UnionFind(int size) : data(size, -1) { }
	int root(int x) { return data[x] < 0 ? x : data[x] = root(data[x]); }
	bool is_same(int x, int y) { return root(x) == root(y); }
	int size(int x) { return -data[root(x)]; }

	bool unify(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
			return true;
		}
		return false;
	}
};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W;
	cin >> H >> W;

	vector<vector<char>> grid(H, vector<char>(W));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> grid[i][j];

	UnionFind uf(H*W);
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {

			if (i + 1 < H && grid[i][j] != grid[i + 1][j]) {
				uf.unify(i*W + j, (i + 1)*W + j);
			}	
			if (j + 1 < W && grid[i][j] != grid[i][j + 1]) {
				uf.unify(i*W + j, i*W + (j + 1));
			}

		}
	}

	map<int, pair<int,int>> mp;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (grid[i][j] == '#') mp[uf.root(i*W + j)].first++;
			else mp[uf.root(i*W + j)].second++;
		}
	}

	lint ans = 0;
	for (const auto &e : mp) {
		ans += 1LL * e.second.first * e.second.second;
	}

	cout << ans << "\n";

	return 0;
}

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

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

    ll n, s = 0;
    cin >> n;
    for(int i = 1; i<=n; i++) {
        if (i%3!=0 && i%5!=0) {
            s+=i;
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define N 2010
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
inline int gcd(int x,int y) {
    return y?gcd(y,x%y):x;
}
int f[N][N];
int a[N],vis[N],ind[N];
vector<int> v[N];
inline void dfs(int x,int n) {
    vis[x]=true;
    for (int i=1;i<=n;i++) {
        if (!f[x][i] || vis[i]) continue;
        ind[i]++,v[x].push_back(i),dfs(i,n);
    }
}
inline void Top(int n) {
    priority_queue<int> q;
    for (int i=1;i<=n;i++) 
        if (!ind[i]) q.push(i);
    while (!q.empty()) {
        int x=q.top(); q.pop();
        printf("%d ",a[x]);
        for (int i=0;i<v[x].size();i++) q.push(v[x][i]);
    }
}
int main() {
    int n=read();
    for (int i=1;i<=n;i++) a[i]=read();
    sort(a+1,a+n+1);
    for (int i=1;i<=n;i++) {
        for (int j=1;j<=n;j++) {
            if (gcd(a[i],a[j])!=1) f[i][j]=true;
        }
    }
    for (int i=1;i<=n;i++) 
        if (!vis[i]) dfs(i,n);
    Top(n);
    return 0;
}

Measured memory_bytes: 16128
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// Nの桁数
ll dig(ll N) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= 10;
	}
	return dig;
}
// x,yの最大公約数
ll gcd(ll x, ll y) {
	ll r;
	while (x%y) {
		r = x % y;
		x = y;
		y = r;
	}
	return y;
}

int main() {
	ll N, X; cin >> N >> X;
	vector<ll> m(N); rep(i, N)cin >> m[i];

	rep(i, N) {
		X -= m[i];
	}

	sort(ALL(m));

	cout << N + X / m[0]<< endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false), cin.tie(0)
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define ALL(x) (x).begin(), (x).end()
#define dump(x) cout << (x) << endl
#define LMAX 9223372036854775807LL
#define LMIN -9223372036854775807LL

using ll = long long;
using vll = vector<ll>;
using P = pair<ll, ll>;

template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val)
{
	fill((T *)array, (T *)(array + N), val);
}

const ll INF = 1e18;
const ll mod = 1e9 + 7;


int main(){
	IOS;
	int n;
	cin >> n;
	ll sum = 0;
	ll ans;
	for(int i = 1;sum <= n;i++){
		sum += i;
		if(sum == n){
			ans = i;
			break;
		}
		else if(sum > n){
			dump("No");
			return 0;
		}
	}

	dump("Yes");
	dump(ans + 1);
	vector<vector<ll>> v(ans + 2,vector<ll>(ans + 1));
	for(int i = 1;i <= ans;i++){
		v[1][i] = i;
	}
	for(int i = 2;i <= ans + 1;i++){
		for(int j = 1;j < i;j++){
			v[i][j] = v[j][i - 1];
		}
		int cnt = 1;
		for(int j = i;j <= ans;j++){
			v[i][j] = v[i - 1][ans] + cnt;
			cnt++;
		}
	}
	for(int i = 1;i <= ans + 1;i++){
		cout << ans;
		for(int j = 1;j <= ans;j++)cout << " " << v[i][j];
		cout << endl;
	}
}

Measured memory_bytes: 2944
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <stack>
#include <deque>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <time.h>
#include <cassert>
#include <fstream>
#include <stdio.h>
#include<unordered_map>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mapa make_pair
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

template<typename T>
std::vector<T> vec(int len, T elem) { return std::vector<T>(len, elem); }
template<typename T>
void vdeb(std::vector<T> &da) {
	for (int i = 0;i < da.size();i++) {
		if (i == da.size() - 1) std::cout << da[i];
		else std::cout << da[i] << ' ';
	}
	std::cout << std::endl;
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
	for (int i = 0;i < da.size();i++) vdeb(da[i]);
	std::cout << std::endl;
}

using namespace std;

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> da(h);
	rip(i, h, 0) cin >> da[i];
	int co = 1 << (h - 1);
	int ans = INT_MAX;
	vector<vector<int>> su(h, vector<int>(w + 1));
	rip(i, h, 0) {
		rip(j, w, 0) {
			su[i][j + 1] = su[i][j];
			if (da[i][j] == '1') su[i][j+1]++;
		}
	}
	int jio = 0;
	rip(i, co, 0) {
		if (i == 10) jio = 10;
		bool ju = true;
		rip(j, w, 0) {
			int yy = 0, p =1;
			rip(l, h, 0) {
				if (da[l][j] == '1') yy++;
				if (yy > k) ju = false;
				if (i&p) yy = 0;
				p <<= 1;
			}
		}
		if (!ju) continue;
		int pre = 0, cand = 0;
		rip(j, w, 0) {
			int me = 0, p = 1;
			rip(l, h, 0) {
				me += su[l][j + 1] - su[l][pre];
				if (me > k) {
					cand++;
					pre = j;
					break;
				}
				if (i&p) me = 0;
				p <<= 1;
			}
		}
		int p = 1;
		rip(j, h, 0) {
			if (i&p) cand++;
			p <<= 1;
		}
		if (chmin(ans, cand)) jio = i;
	}
	cout << ans << endl;
}

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

typedef pair<string, int> P;

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

	string s;
	while(cin >> s, s != "0") {
		int n = s.size();
		string R = string(n, 'r');
		string B = string(n, 'b');
		string G = string(n, 'g');

		map<string, int> m;
		m[s] = 0;
		queue<P> q;
		q.push({ s, 0 });
		while(q.size()) {
			s = q.front().first;
			int d = q.front().second;
			q.pop();
			if(m[s] < d) continue;
			//cout << s << endl;
			bool flag = false;
			for(int i = 0; i < n - 1; i++) {
				string ns = s;
				if(s[i] == 'r' && s[i + 1] == 'b' || s[i] == 'b' && s[i + 1] == 'r') ns[i] = ns[i + 1] = 'g';
				else if(s[i] == 'g' && s[i + 1] == 'b' || s[i] == 'b' && s[i + 1] == 'g') ns[i] = ns[i + 1] = 'r';
				else if(s[i] == 'r' && s[i + 1] == 'g' || s[i] == 'g' && s[i + 1] == 'r') ns[i] = ns[i + 1] = 'b';
				if(ns != s && m.count(ns) == 0) {
					m[ns] = d + 1;
					q.push({ ns, d + 1 });
					if(ns == R || ns == B || ns == G) { flag = true; break; }
				}
			}
			if(flag) break;
		}

		int ans = 1e9;
		if(m.count(R)) ans = min(ans, m[R]);
		if(m.count(B)) ans = min(ans, m[B]);
		if(m.count(G)) ans = min(ans, m[G]);
		if(ans != 1e9) {
			cout << ans << endl;
		}
		else {
			cout << "NA" << endl;
		}
	}
}

Measured memory_bytes: 4556
#include<bits/stdc++.h>
using namespace std;
 
int main(){
 int k;
  cin>>k;
 if(k%2==0){
   cout<<k*k/4;
}
  else{
  int ans=k/2;
    ans=ans*(k/2+1);
    cout<<ans;
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (2010)
#define P ()
#define M (N*N)
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c) {
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
vector<int> G[N],T[N];
int n,a[N],deg[N]; bool vis[N];
priority_queue<int> Q;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
void dfs(int u){
	vis[u]=1;
	for(int i=0;i<T[u].size();i++){
		int v=T[u][i];
		if(!vis[v])G[u].push_back(v),deg[v]++,dfs(v);
	}
}
int main(){
	read(n);
	for(int i=1;i<=n;i++)read(a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
	for(int j=1;j<=n;j++)
	if(i!=j&&gcd(a[i],a[j])!=1)T[i].push_back(j);
	for(int i=1;i<=n;i++)if(!vis[i])dfs(i);
	for(int i=1;i<=n;i++)if(!deg[i])Q.push(i);
	while(!Q.empty()){
		int u=Q.top(); Q.pop(),printf("%d ",a[u]);
		for(int i=0;i<G[u].size();i++){
			int v=G[u][i]; deg[v]--;
			if(!deg[v])Q.push(v);
		}
	}
}

Measured memory_bytes: 18048
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
p = inpl()
maxsum = sum(p[:K])
s = maxsum
for i in range(N-K):
    s += p[i+K]-p[i]
    if s > maxsum:
        maxsum = s
print((maxsum+K)/2)

Measured memory_bytes: 71792
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
struct multi {
  ll first;
  ll second;
  ll third;
  multi(ll first, ll second, ll third)
      : first(first), second(second), third(third) {}
};
bool multicomp(const multi &a, const multi &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll L, R;
  cin >> L >> R;
  if (R - L >= 2019) {
    cout << 0 << endl;
    return 0;
  }

  ll L2 = L % 2019;
  ll R2 = R - (L - L2);
  ll ans = llINF;
  FOR(i, L2, R2) FOR(j, i + 1, R2 + 1) { ans = min(ans, (i * j) % 2019); }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
  vector<vector<int> > c(3, vector<int>(3));

  rep(i, 3){
    rep(j, 3) cin >> c[i][j];
  }
  int x[3], y[3];
  x[0] = 0;

  for(int i = 0; i < 3; ++i){
    y[i] = c[0][i] - x[0];
  }

  for(int i = 0; i < 3; ++i){
    x[i] = c[i][0] - y[0];
  }

  bool ans = true;
  for(int i = 0; i < 3; ++i){
    for(int j = 0; j < 3; ++j){
      if(x[i] + y[j] != c[i][j]){
        ans = false;
      }
    }
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;



}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define randome_generate srand(std::chrono::high_resolution_clock::now().time_since_epoch().count())
using namespace std;
char c;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>c;
	cout<<(char)(c+1)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<ll, ll> P;
typedef pair<ll, P> E;
class Min {
public:
	P operator()(P a, P b) const {
		return min(a, b);
	}
};
template<typename T, typename BiOp>
struct SegmentTree {
	vector<T> data;
	T e;
	BiOp op;
	int size;
	SegmentTree(int n, T e, BiOp op) :e(e), op(op) {
		size = 1;
		while (size < n) size *= 2;
		data.resize(size * 2 - 1);
		for (int i = 0; i < size * 2 - 1; i++) data[i] = e;
	}
	void update(int k, T v) {
		k += size - 1;
		data[k] = v;
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = op(data[k * 2 + 1], data[k * 2 + 2]);
		}
	}
	T query(int a, int b, int k, int l, int r) const {
		if (b <= l || r <= a) return e;
		if (a <= l && r <= b) {
			return data[k];
		}
		return op(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
	}
	T query(int a, int b) const {
		return query(a, b, 0, 0, size);
	}
	T get(int i) {
		return data[i + size - 1];
	}
};
struct UnionFind {
	vector<int> par;
	vector<int> rank;
	int size;
	UnionFind(int n) :size(n) {
		par.resize(size);
		rank.resize(size);
		for (int i = 0; i < size; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (rank[x] < rank[y]) {
			par[x] = y;
		}
		else {
			par[y] = x;
			if (rank[x] == rank[y]) rank[x]++;
		}
	}
	int find(int x) {
		if (par[x] == x) return x;
		return par[x] = find(par[x]);
	}
	bool same(int x, int y) {
		x = find(x);
		y = find(y);
		return x == y;
	}
};
ll A[200000];
int main() {
	int N;
	ll D;
	cin >> N >> D;
	vector<P> city;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		city.emplace_back(A[i], i);
	}
	sort(city.begin(), city.end());
	vector<E> edge;
	SegmentTree<P, Min> S1(N, P(INF, INF), Min());
	SegmentTree<P, Min> S2(N, P(INF, INF), Min());
	for (int i = 0; i < N; i++) {
		int c = city[i].second;
		ll l = c * D + A[c], r = (-c)*D + A[c];
		P p1 = S1.query(0, c);
		if (p1.second != INF) {
			edge.emplace_back(l + p1.first, P(c, p1.second));
		}
		P p2 = S2.query(c + 1, N);
		if (p2.second != INF) {
			edge.emplace_back(r + p2.first, P(c, p2.second));
		}
		S1.update(c, P(r, c));
		S2.update(c, P(l , c));
	}
	sort(edge.begin(), edge.end());
	UnionFind U(N);
	ll ans = 0;
	for (E e : edge) {
		int u = e.second.first, v = e.second.second;
		if (!U.same(u, v)) {
			U.unite(u, v);
			ans += e.first;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 38632
#include<iostream>
#include<vector>
using namespace std;
using ll = long long;

int main() {
    const int mod = 1e9+7;

    int N;
    cin >> N;
    vector<ll> as(N);
    for (int i=0; i<N; ++i) {
        cin >> as[i];
    }


    vector<ll> toSum(N);
    toSum[N-1] = as[N-1];
    for (int i=N-2; i>=0; --i) {
        toSum[i] = (as[i]%mod + toSum[i+1]%mod)%mod;
    }

    ll sumOfMultiples = 0;
    for (int i=0; i<N-1; ++i) {
        sumOfMultiples += (as[i]%mod * toSum[i+1]%mod) % mod;
        sumOfMultiples %= mod;
    }

    cout << sumOfMultiples << endl;

    return 0;
}

Measured memory_bytes: 6400