akhauriyash/Code-Regression huggingface dataset:
N=int(input())
A=list(map(int,input().split()))
price={}
flg=10
ans=1000
stock=0
for i in range(1,N):
    if A[i]!=A[i-1]:
        if A[i]>A[i-1]:
            flg=1
            stock=ans//A[0]
            ans-=A[0]*stock
            break
        else:
            flg=0
            break
for i in range(1,N):
    if flg==1:
        if A[i]<A[i-1]:
            flg=0
            price[i-1]=1
    else:
        if A[i]>A[i-1]:
            flg=1
            price[i-1]=0
for i in price.keys():
    if price[i]==1:
        ans+=(int(A[i])*stock)
        stock=0
    else:
        stock=ans//A[i]
        ans-=A[i]*stock
print(ans+(A[-1]*stock))

Measured memory_bytes: 9252
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int currentGCF = 0;
		for (int i = 0; i < N; i++) {
			if (currentGCF == 0) {
				currentGCF = sc.nextInt();
			} else {
				currentGCF = GCF(currentGCF, sc.nextInt());
			}
			if (currentGCF == 1) {
				break;
			}
		}
		System.out.println(currentGCF);
	}
	
	public static int GCF(int a, int b) {
		if (a > b) {
			return GCF(b, a);
		}
		if (b%a == 0) {
			return a;
		}
		return GCF(b%a, a);
	}  
}


Measured memory_bytes: 48440
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedHashSet;

public class Main {
	static int[] p, q;
	static int cnt = 0;
	static int a, b;

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		sa = br.readLine().split(" ");
		p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = Integer.parseInt(sa[i]);
		}
		sa = br.readLine().split(" ");
		q = new int[n];
		for (int i = 0; i < n; i++) {
			q[i] = Integer.parseInt(sa[i]);
		}
		br.close();

		int[] target = new int[n];
		for (int i = 0; i < n; i++) {
			target[i] = i + 1;
		}
		permutation(target, new LinkedHashSet<>());
		System.out.println(Math.abs(a - b));
	}

	static void permutation(int[] target, LinkedHashSet<Integer> set) {
		if (set.size() == target.length) {
			cnt++;
			boolean flg = true;
			int x = 0;
			for (int i : set) {
				if (target[i] != p[x]) {
					flg = false;
					break;
				}
				x++;
			}
			if (flg) {
				a = cnt;
			}

			flg = true;
			x = 0;
			for (int i : set) {
				if (target[i] != q[x]) {
					flg = false;
					break;
				}
				x++;
			}
			if (flg) {
				b = cnt;
			}
			return;
		}

		for (int i = 0; i < target.length; i++) {
			if (!set.contains(i)) {
				set.add(i);
				permutation(target, set);
				set.remove(i);
			}
		}
	}
}


Measured memory_bytes: 32076
// Dont be lazy. Dont look for simple and quick implementations. Be ready to do case-work and implement. Make sure the method is fully correct. 
// Read question properly, ques can be tricky


#include <bits/stdc++.h>
#include <chrono>
using namespace std;
 
#define int long long
 
#define pb push_back
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define f first 
#define s second
#define tup pair<pii,int>
#define ordk order_of_key
// const int M= 998244353;
const int M = 1e9+7;
const int MXN=2e5+10; 
 
int power(int a,int b) {int res=1;a%=M;while(b){if((b&1))res=(res*a)%M;a=(a*a)%M;b>>=1;}return res;}
inline void print(int a,int b){ cout << a << ' ' << b << endl;}
inline void print(int a,int b,int c){ cout << a << ' ' << b <<' '<< c << ' ' << endl;}
 
int n;

int32_t main(){
    fast;
    string str;
    cin>>str;
    int n= str.size();
    int ans =0;
    for(int i=0;i<n;++i){
        if(str[i]!=str[n-i-1]){
            ans++;
            str[i]=str[n-i-1];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import java.math.BigInteger;
//267630EY
public class Main
{
  static PrintWriter out=new PrintWriter(System.out);

  public static void main(String[] args) throws IOException
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int[] a=sc.nextIntArray(n);
    int sum=0;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        sum+=a[i];
    }
    BitSet possible=new BitSet(4000001);
    possible.set(4000000);
    for(int x:a)
    {
        possible.or(possible.get(x,4000001));
    }
    ans=possible.previousSetBit(4000000-(sum+1)/2);

    out.println(4000000-ans);
    

    out.flush();



        
   
      
      
                
    
  }
  
  static class Scanner
  {
    BufferedReader br;
    StringTokenizer tk=new StringTokenizer("");
    public Scanner(InputStream is) 
    {
      br=new BufferedReader(new InputStreamReader(is));
    }
    
    public boolean hasNext()
    {
      

      boolean result=false;
      
      try 
      {
        result = br.ready();
      } 
      catch (IOException e)
      {
        System.err.println(e);
      }
      return result;
    }
    
    public int nextInt() throws IOException
    {
      if(tk.hasMoreTokens())
        return Integer.parseInt(tk.nextToken());
      tk=new StringTokenizer(br.readLine());
      return nextInt();
    }
    public long nextLong() throws IOException
    {
      if(tk.hasMoreTokens())
        return Long.parseLong(tk.nextToken());
      tk=new StringTokenizer(br.readLine());
      return nextLong();
    }
    public String next() throws IOException
    {
      if(tk.hasMoreTokens())
        return (tk.nextToken());
      tk=new StringTokenizer(br.readLine());
      return next();
    }
    public String nextLine() throws IOException
    {
      tk=new StringTokenizer("");
      return br.readLine();
    }
    public double nextDouble() throws IOException
    {
      if(tk.hasMoreTokens())
        return Double.parseDouble(tk.nextToken());
      tk=new StringTokenizer(br.readLine());
      return nextDouble();
    }
    public char nextChar() throws IOException
    {
      if(tk.hasMoreTokens())
        return (tk.nextToken().charAt(0));
      tk=new StringTokenizer(br.readLine());
      return nextChar();
    }
    public int[] nextIntArray(int n) throws IOException
    {
      int a[]=new int[n];
      for(int i=0;i<n;i++)
        a[i]=nextInt();
      return a;
    }
    public long[] nextLongArray(int n) throws IOException
    {
      long a[]=new long[n];
      for(int i=0;i<n;i++)
        a[i]=nextLong();
      return a;
    }
    public int[] nextIntArrayOneBased(int n) throws IOException
    {
      int a[]=new int[n+1];
      for(int i=1;i<=n;i++)
        a[i]=nextInt();
      return a;
    }
    public long[] nextLongArrayOneBased(int n) throws IOException
    {
      long a[]=new long[n+1];
      for(int i=1;i<=n;i++)
        a[i]=nextLong();
      return a;
    }
  }
}



Measured memory_bytes: 274924
INF = 2 * (10 ** 9) - 1

n = int(input())
xl = [[0] * 2 for i in range(n)]
for i in range(n) :
    x, l = map(int, input().split())
    xl[i][0] = x-l+1
    xl[i][1] = x+l-1

xl.sort(key=lambda x:x[1])

cnt = 0
#print(xl)
cur = -10 ** 10
ans = 0

for i in range(n) :
    if cur+1 < xl[i][0] :
        #print(i)
        ans += 1
        cur = xl[i][1]
        #prinst(xl[i])


print(ans)


Measured memory_bytes: 21320
import sys
readline = sys.stdin.readline

def main():
    N, K = map(int, readline().rstrip().split())
    res = 0
    for b in range(1, N+1):
        p = (N+1) // b
        r = (N+1) % b
        res += max(b - K, 0) * p + max(r - K, 0)
    
    if K == 0:
        print(N ** 2)
    else:
        print(res)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#include<iostream>
#include<cstdio>
#include<cstring>
#include <stdlib.h>
#include<algorithm>
#include <ctime>
#include "queue"
using namespace std;
#define SIZE 100115

int main(int argc, char const *argv[])
{
	int a;
	scanf("%d",&a);
	if(a<1200)
		printf("ABC\n");
	else if(a<2800)
		printf("ARC\n");
	else printf("AGC\n");
	return 0;
}

Measured memory_bytes: 256
// AOJ 0542: Authentication Level
// 2018.1.28 bal4u

#include <stdio.h>
#include <string.h>

#define QMAX 150000
typedef struct { int t; short r, c; } QUE;
QUE que[QMAX]; int qsize;

#define PARENT(i) ((i)>>1)
#define LEFT(i)   ((i)<<1)
#define RIGHT(i)  (((i)<<1)+1)

void min_heapify(int i)
{
	int l, r, min;
	QUE qt;

	l = LEFT(i), r = RIGHT(i);
	if (l < qsize && que[l].t < que[i].t) min = l; else min = i;
	if (r < qsize && que[r].t < que[min].t) min = r;
	if (min != i) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		min_heapify(min);
	}
}

void deq()
{
//	if (qsize == 0) return 0;
//	*n = que[0].node, *t = que[0].t, *c = que[0].c;
	que[0] = que[--qsize];
	min_heapify(0);
}

void enq(int r, int c, int t)
{
	int i, min;
	QUE qt;

	i = qsize++;
	que[i].r = r, que[i].c = c, que[i].t = t;
	while (i > 0 && que[min = PARENT(i)].t > que[i].t) {
		qt = que[i], que[i] = que[min], que[min] = qt;
		i = min;
	}
}

int l[501][501];
int level[2][100001], lsz[2];
int mv[4][2] = {{-1,0},{0,1},{1,0},{0,-1}};
char mk[501][501];

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

int main()
{
    int R, W, H, X, Y;
	int i, j, r, c, r2, c2, t, max, ans;

    while (R = in()) {
        for (i = 0; i < 2; i++) {
			W = in(), H = in(), X = in()-1, Y = in()-1;
			for (r = 0; r < H; r++) for (c = 0; c < W; c++) l[r][c] = in();

			memset(mk, 0, sizeof(mk));
			qsize = 0, level[i][0] = max = 0, lsz[i] = 1;
			enq(Y, X, l[Y][X]), mk[Y][X] = 1;
			while (qsize) {
				t = que[0].t, r = que[0].r, c = que[0].c, deq();
				if (t > max) max = t;
				level[i][lsz[i]++] = max;

				for (j = 0; j < 4; j++) {
					r2 = r + mv[j][0], c2 = c + mv[j][1];
					if (r2 < 0 || r2 >= H || c2 < 0 || c2 >= W) continue;
					if (mk[r2][c2]) continue;
					mk[r2][c2] = 1;				// 同一部屋は２度とQに入れない
					enq(r2, c2, l[r2][c2]);
				}
			}
		}

		ans = 0x7ffffff;
		for (i = 0; i <= R; i++) {
			j = R - i;
			if (i < lsz[0] && j < lsz[1]) {
				t = level[0][i] + level[1][j];
				if (t < ans) ans = t;
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(x) x.begin(), x.end()

template <typename T1, typename T2> inline void chkmin(T1 &x, const T2 & y) {if (x > y) x = y;}
template <typename T1, typename T2> inline void chkmax(T1 &x, const T2 & y) {if (x < y) x = y;}

void read() {
    int k, a, b;
    cin >> k >> a >> b;
    for (int i = a; i <= b; i++) {
        if (i % k == 0) {
            cout << "OK";
            return;
        }
    }
    cout << "NG";
}

void run() {

}

void write() {

}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    read();
    run();
    write();
    return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<vector>
#define MAX 100000
using namespace std;

int main(){
    int n,m,h[MAX];
    cin >> n >> m;
    for(int i = 0;i < n;i++){
        cin >> h[i];
    }

    vector<int> tenbo(n,1);

    int a,b;
    for(int i = 0;i < m;i++){
        cin >> a >> b;
        if(h[a - 1] > h[b - 1]){
            tenbo.at(b - 1) = 0;
        }
        else if(h[a - 1] < h[b - 1]){
            tenbo.at(a - 1) = 0;
        }
        else{
            tenbo.at(a - 1) = 0;
            tenbo.at(b - 1) = 0;
        }
    }
    
    /**/

    int ans = 0;

    for(int i = 0;i < n;i++){
        if(tenbo.at(i) == 1){
           // cout << i + 1 << endl;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

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

int main() 
{
        int n;
        cin>>n;
        vector<int> v(n) ;
        for(int i=0;i<n;i++)cin>>v[i];
        sort(v.begin(),v.end());
        double t=v[0];
        for(int i=1;i<n;i++)t= (t+v[i])/2;
        cout<<t<<endl;
    
}

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

int main()
{
    string s;
    cin >> s;
    int n = s.length(), h[100002];
    int a=0,b=0,c=0;
    int ip=0;
    for (int i = 0; i < n; i++)
    {
        h[i]=0;
    }
    for (int i = 0; i < n; i++)
    {
        if (s[i] == 'R')
        {
            if (s[i+1] == 'R')
            {
                a++;
            }else{
                a++;
                ip=i;
            }
        }else if(s[i] == 'L'){
            if (i+1>=n || s[i+1] == 'R')
            {
                c=i;
                for (int j = b; j <=c; j++)
                {
                    if((j-ip+10000000)%2==0){
                        h[ip]++;
                    }else{
                        h[ip+1]++;
                    }
                }
                a=0;
                b=i+1;
            }else{
                a++;
            }
        }else{
            cout<<"ERROR"<<endl;
        }
        //cout<<a<<endl;
    }

    for (int i = 0; i < n; i++)
    {
        cout<<h[i]<<(i==n-1 ? "" : " ");
    }

    return 0;
}

Measured memory_bytes: 1024
from collections import Counter
#入力
n = int(input())
s = [input() for _ in range(n)]
m = int(input())
t = [input() for _ in range(m)]
#blue n (str s)
# red m (str t)
sc = Counter(s)
tc = Counter(t)
u = list(set(s + t))
maxcnt = 0
for i in range(len(u)):
	cnt = 0
	cnt += sc[u[i]]
	cnt -= tc[u[i]]
	if cnt >= maxcnt:
		maxcnt = cnt
print(maxcnt)

Measured memory_bytes: 3316
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long



class NCR{
  private:
    //MOD need to be prime number
    static const ll MAX = 210000LL;
    static const ll MOD = 1000000007LL;
    ll fac[MAX],finv[MAX],inv[MAX];
  public:
    void COMinit(){
      fac[0] = fac[1] = 1LL;
      finv[0] = finv[1] = 1LL;
      inv[1] = 1LL;
      for(int i = 2 ; i < MAX ; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
      }
    }
    ll COM(int n,int k){
      if(n < k) return 0;
      if(n < 0 || k < 0){
        return 0;
      }
      return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
    }
};


//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int N,K;
  cin >> N >> K;
  vector<int> A;
  A.resize(N);

  for(int i = 0 ; i < N ; i++){
  	cin >> A[i];
  }
  sort(A.begin(),A.end());
  NCR ncr;
  ncr.COMinit();

  int max_sum = 0;
  int min_sum = 0;
  int min_id = 0;
  int max_id = N-1;

  //for min_sum
  while(true){
  	min_sum += A[min_id] * ncr.COM(N-1-min_id,K-1) % 1000000007LL;
  	min_id++;
  	if(N - 1 - min_id < K - 1){
  		break;
  	}
  }

  while(true){
  	max_sum += A[max_id] * ncr.COM(max_id,K-1) % 1000000007LL;
  	max_id--;
  	if(max_id < K - 1){
  		break;
  	}
  }
  int ans = max_sum - min_sum;
  ans = ans % 1000000007LL;
  if(ans < 0){
  	ans += 1000000007LL;
  }
  cout << ans << endl;

  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define REPr(i,n) for(int i=(n)-1;i>=0; --i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define FORqr(i, m , n) for(int i = (n);i >=(m);--i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define VSCD(v,N) REP(i,N){int (x); SCD(x); v.PB(x);}
#define VSCLLD(v,N) REP(i,N){long long (x); SCLLD(x); v.PB(x);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define SIN(x,S) (S.count(x) != 0)
#define M0(x) memset(x,0,sizeof(x))
#define FILL(x,y) memset(x,y,sizeof(x))
#define MM(x) memset(x,-1,sizeof(x))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef vector<long long> VL;
typedef long long ll;
typedef long long integer;
///////////////////////////////////////////////
const ll MOD = 1000000007;
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

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;
}
///////////////////////////////////////////////
int main(){
    string S;
    getline(cin,S);
    bool ans = false;
    if (S[5] != '0') ans = true;
    if (S[6] > '4') ans = true;

    if (ans) cout << "TBD" << "\n";
    else cout << "Heisei" << "\n";
}


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

#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)

using namespace std;

typedef long long ll;
typedef pair<int,int> P;
const long long LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(20) << fixed;

  int n;
  cin >> n;

  vector<int> a(n);
  rep(i,n) { cin >> a[i]; }

  vector<int> b(n, 0);
  for (int i = n-1; i >= 0; i--) {
    // sum := iの倍数のボールの数の和
    int sum = 0;
    for (int j = i; j < n; j += (i+1)) {
      sum += b[j];
    }
    b[i] = (sum + a[i]) % 2;
  }

  int m = count(b.begin(), b.end(), 1);
  cout << m << endl;

  if (m != 0) {
    rep(i, n) { if (b[i]) cout << i+1 << endl; }
  }
  return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

// 素因数分解 O(√n)
// たとえば 60 = 2^2 x 3 x 5 だったら {(2, 2), (3, 1), (5, 1)} を返す
// 素因数の個数はlogn
vector<pair<ll,ll>> prime_factorize(ll n){
    vector<pair<ll,ll>> res;
    for(ll p=2;p*p<=n;p++){
        if(n%p!=0) continue;
        int num=0; // 指数
        while(n%p==0){
            num++;
            n/=p;
        }
        res.push_back({p,num});
    }
    if(n!=1) res.push_back({n,1});
    return res;
}


int main(){
    int N;
    ll P;
    cin>>N>>P;
    const auto &pf=prime_factorize(P);
    ll res=1;
    for(auto p : pf){
        for(int j=0;j<p.second/N;j++) res*=p.first;
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
N,X = map(int, input().split())
target = list(map(int, input().split()))

distances = [abs(i - X) for i in target]

def GCD(x,y):
    if y == 0:
        return x
    else:
        return GCD(y, x % y)
res = 0
for d in distances:
    res = GCD(res, d)
print(res)

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


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

    int a, b, c, k;
    cin >> a >> b >> c >> k;

    int ans = 0;
    if (k <= a){
        cout << k;
        return 0;
    }
    else{
        ans += a;
        k -= a;
    }

    if (k <= b){
        cout << ans;
        return 0;
    }
    else{
        k -= b;
    }

    if (k <= c){
        ans -= k;
    }
    else{
        ans -= c;
    }

    cout << ans;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define mod 1000000007
#define INF 2147483647
#define fi first
#define se second
int abs(int a,int b){ 
  int c=max(a,b)-min(a,b);
  return c;
}
int gcd(int a,int b){
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
  if (num < 2) return false;
  else if (num == 2) return true;
  else if (num % 2 == 0) return false;
  double sqrtNum = sqrt(num);
  for(int i=3;i<=sqrtNum;i+=2){
    if(num%i==0){
      return false;
    }
  }
  return true;
}
int q[100000000];
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a;
  string b,c;
  cin>>a>>b;
  c=b[0];
  for(int i=1;i<a;i++){
      if(b[i-1]!=b[i]) c+=b[i];
  }
  cout<<c.size()<<"\n";
}


Measured memory_bytes: 592
// 基本のinclude
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define invrep(i,n) for(int i = (int)(n); i > 0; i++)
using ll = long long;

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

    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
}

Measured memory_bytes: 3580
# https://atcoder.jp/contests/agc044/submissions/13542551

def main():
    from heapq import heappush, heappop

    T = int(input())
    for _ in range(T):
        N, A, B, C, D = map(int, input().split())

        h = [(0, N)]  # cost,value
        checked = set()

        ans = N * D + 1
        while h:
            cost, x = heappop(h)
            if cost >= ans: continue
            if x in checked: continue
            checked.add(x)

            # 0まで1ずつ減らす
            if ans > cost + x * D:
                ans = cost + x * D

            for d, c in ((2, A), (3, B), (5, C)):
                # すでにheapqからnxがpopしていれば
                # より低コストでnxを生成できているので
                # nxの生成は不要
                nx, r = divmod(x, d)
                if nx not in checked:
                    heappush(h, (cost + r * D + c, nx))
                if (r > 0) and ((nx + 1) not in checked):
                    heappush(h, (cost + (d - r) * D + c, nx + 1))

        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 10796
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pii Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};

signed main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", (a+b)%24);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t;
	t=1;
	while(t--)
	{
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		cout << max(a*c,max(b*d,max(a*d,b*c)));		
	}
}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define debug(...)
#include <complex.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;


int32_t main() {
    ios::sync_with_stdio(false); cin.tie(0);
    ll a , b , n;
    cin >> n >> a>> b;

    if( (n == 1 && a != b) ||  a > b){
        cout << 0 << '\n';
        return 0;
    }
    if(n <= 2){
        cout << 1 << '\n';
        return 0;
    }

   ll answer = (n - 2) * b -  (n - 2) * a  + 1;
    cout << answer << '\n';

    return 0;
}













Measured memory_bytes: 256
N = int(input())
a = list(map(int, input().split()))

a.sort()
ans = 0
num = [0] * int(3e5)
for i in a:
    num[i] += 1

for i in range(int(2e5)):
    check = sum(num[i:i+3])
    ans = max(ans, check)

print(ans)

Measured memory_bytes: 14092
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>

using namespace std;

int keta(long long n)
{
	int cnt=0;
	while(true)
	{
		cnt++;
		n/=10;
		if(n<=0)break;
	}
	return cnt;
}

int main()
{
	int q;
	cin >> q;
	for(int i=0;i<q;i++)
	{
		long long n;
		cin >> n;
		long long cnt=0;
		while(true)
		{
			int ke=keta(n);
			if(ke<=1)
				break;
			cnt++;
			long long tmp=0;
			for(int j=0;j<ke;j++)
			{
				long long tmptmp;
				long long un,up;
				long long aa=1;
				for(int k=0;k<j;k++)
				{
					aa*=10;
				}
				un=n%aa;
				up=n/aa;
				tmptmp=un*up;
					
				if(tmp<tmptmp)tmp=tmptmp;

			}
			n=tmp;
		}

		cout << cnt << endl;


	}
}


Measured memory_bytes: 3104
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;



int main(void){
	ll N,K,ans=0;
	scanf("%lld%lld",&N,&K);
	//a,b > 0
	reg(b,K+1,N){
		//a:K...b-1
		//r:K...N%b
		ans+=N/b*(b-K);
		if(K==0)ans--;
		ll r = N%b;
		if(r-K+1>0)ans+=r-K+1;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    //Equal
    
    public static boolean Equal(int X, int Y, int M, char A[][], char B[][]) {
        for (int i = 0; i < M; i++) {
            for (int j = 0; j < M; j++) {
                if (!(A[X + i][Y + j] == B[i][j])) {
                    return false;
                }
            }
        }
        return true;
    }
    
    //Main

    public static void main(String args[]) throws Exception {

        Scanner Input = new Scanner(System.in);

        int N = Input.nextInt();
        int M = Input.nextInt();

        char A[][] = new char[N][N];
        char B[][] = new char[M][M];

        String S = "";
        String SS = "";
        String SSS = "";
        
        //System.out.println("AAAAA");
        
        for (int I = 0; I < A.length; I++) {
            S = Input.next();
            for (int J = 0; J < A[0].length; J++) {
                A[I][J] = S.charAt(J);
                //System.out.print(A[I][J]);
            }
            //System.out.println("");
        }
        for (int I = 0; I < B.length; I++) {
            S = Input.next();
            for (int J = 0; J < B[0].length; J++) {
                B[I][J] = S.charAt(J);
                //System.out.print(B[I][J]);
            }
            //System.out.println("");
        }

        boolean T = false;

        for (int I = 0; I < N - M + 1; I++) {
            for (int J = 0; J < N - M + 1; J++) {
                if (Equal(I, J, M, A, B)) {
                   //System.out.println("Yes");
                    T = true;
                    break;
                }
            }
        }
        
        //Cat

        if (T) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }

    }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    vint a(3);
    rep(i, 3) cin >> a[i];

    int mx = 0;
    rep(i, 3) mx = max(mx, a[i]);
    int rm = 0;
    rep(i, 3) rm += mx-a[i];
    if (rm&1) rm += 3;

    int ans = rm/2;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# 最後に桁によって次の値の候補が定まる
# 2kから末尾が出ることに注意
# k(桁) 1k=9 2k=26 3k=75 

K = int(input())
count = 9
runrunnumber  = [[]for _ in range(10)]


runrunnumber[0] = [1, 2, 3, 4, 5, 6, 7, 8, 9]
#print(runrunnumber)

if K > 10:
  for i in range(9):
    for j in runrunnumber[i]:

      if j%10 == 0:
        for p in range(2):
          count += 1
          tmp = j*10+p
          runrunnumber[i + 1].append(tmp)
          if count == K:
            print(tmp)
            break
      
      if j%10 == 1:
        for p in range(3):
          count += 1
          tmp = j*10+p
          runrunnumber[i + 1].append(tmp)
          if count == K:
            print(tmp)
            break

      if j%10 == 2:
        for p in range(1,4):
          count += 1
          tmp = j*10+p
          runrunnumber[i + 1].append(tmp)
          if count == K:
            print(tmp)
            break

      if j%10 == 3:
        for p in range(2,5):
          count += 1
          tmp = j*10+p
          runrunnumber[i + 1].append(tmp)
          if count == K:
            print(tmp)
            break

      if j%10 == 4:
        for p in range(3,6):
          count += 1
          tmp = j*10+p
          runrunnumber[i + 1].append(tmp)
          if count == K:
            print(tmp)
            break
      if j%10 == 5:
        for p in range(4,7):
          count += 1
          tmp = j*10+p
          runrunnumber[i + 1].append(tmp)
          if count == K:
            print(tmp)
            break

      if j%10 == 6:
        for p in range(5,8):
          count += 1
          tmp = j*10+p
          runrunnumber[i + 1].append(tmp)
          if count == K:
            print(tmp)
            break

      if j%10 == 7:
        for p in range(6,9):
          count += 1
          tmp = j*10+p
          runrunnumber[i + 1].append(tmp)
          if count == K:
            print(tmp)
            break

      if j%10 == 8:
        for p in range(7,10):
          count += 1
          tmp = j*10+p
          runrunnumber[i + 1].append(tmp)
          if count == K:
            print(tmp)
            break

      if j%10 == 9:
        for p in range(8,10):
          count += 1
          tmp = j*10+p
          runrunnumber[i + 1].append(tmp)
          if count == K:
            print(tmp)
            break

        if count >= K:
          break
    if count >= K:
      break

else:
  print(runrunnumber[0][K-1])

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

void fnInput(vector<int> &rvnPodr, vector<int> &rvnIodrSeq)
{
  int nMaxSiz;

  cin >> nMaxSiz;
  rvnPodr.resize(nMaxSiz + 1);
  rvnIodrSeq.resize(nMaxSiz + 1);

  for (int i = 1; i < nMaxSiz + 1; i++)
    cin >> rvnPodr[i];

  int nNode;
  for (int i = 1; i < nMaxSiz + 1; i++)
  {
    cin >> nNode;
    rvnIodrSeq[nNode] = i;
  }
}

void fnPostOrder(const vector<int> &cnrvnPodr, const vector<int> &cnrvnIodrSeq, int nLeft, int nRight)
{
  static int stnx = 1;
  static int stnPrt = 0;

  if (nLeft == nRight) return;

  int nNode = cnrvnPodr[stnx++];
  int nMid = cnrvnIodrSeq[nNode];

  fnPostOrder(cnrvnPodr, cnrvnIodrSeq, nLeft, nMid);
  fnPostOrder(cnrvnPodr, cnrvnIodrSeq, nMid + 1, nRight);

  if (stnPrt++) cout << " ";
  cout << nNode;
}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<int> vnPodr, vnIodrSeq;
  fnInput(vnPodr, vnIodrSeq);

  fnPostOrder(vnPodr, vnIodrSeq, 1, vnPodr.size());
  cout << endl;
  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>//万能库
using namespace std;
int main()
{
    long long i,sum=1,n;
    cin>>n;//输入
    for(i=1;i<=n;i++)
    {
        while(sum<=n)//判断是否小于输入数
        {
            sum=2*sum;//累乘2
            if(sum>n)
            {
                cout<<sum/2<<endl;//如果超出输入数再除回去
                return 0;//结束
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d %d', $men, $goal);
$ans = 0;
for ($i=1; $i <= $men; $i++) { 
    $score = $i;
    $must = 0;
    while ($score < $goal) {
        $score *= 2;
        $must++;
    }
    $ans += 1 /$men * pow(1 / 2, $must); 
}
echo $ans."\n";

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

int main()
{

        int A, B;
        cin >> A >> B;
        string S;
        cin >> S;
        string s1 = S.substr(0, A);
        string s2 = S.substr(A+1, B);
        if (S[A] != '-') {
                cout << "No" << endl;
                exit(0);
        }
        for (int i = 0; i < A; ++i) {
                if (s1[i] >= '0' && s1[i] <= '9') {

                }
                else {
                        cout << "No" << endl;
                        exit(0);
                }
        }
        for (int i = 0; i < B; ++i) {
                if (s2[i] >= '0' && s2[i] <= '9') {
                }
                else {
                        cout << "No" << endl;
                        exit(0);
                }
        }
        cout << "Yes" << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

int n, M[1000][1000];
int d[1000];
int Q[1000];
int tail=0;
int head=0;

void enq(int x) {
  Q[tail++] = x;
}

int deq() {
  return Q[head++];
}

void bfs(int s) {
  int i,u,v;
  enq(s);
  for(i=1;i<=n;i++){
    d[i] = 100000;
    d[s] = 0;
  }
  while(head != tail){
    u = deq();
    for(v=1;v<=n;v++){
      if(M[u][v] == 0){
	continue;
      }
      if(d[v] != 100000){
	continue;
      }
      d[v] = d[u] +1;
      enq(v);
    }
  }
}

int main() {
  int i,j,u,k,v;

  scanf("%d",&n);
  for(i=1;i<=n;i++){
    for(j=0;j<n;j++){
      M[i][j] = 0;
    }
  }

  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      M[u][v] = 1;
    }
  }

  bfs(1);
  
  for(i=1;i<=n;i++){
    if(d[i] == 100000){
      d[i] = -1;
    }
    printf("%d %d\n",i,d[i]);
  }

  return 0;
}

Measured memory_bytes: 992
<?php
fscanf(STDIN, '%d %d', $n, $k);
fscanf(STDIN, '%s', $s);
$ans = 0;
for ($i = 0; $i < $n - 1; $i++) {
    if ($s[$i] === $s[$i + 1]) $ans++;
}
$ans = min($n - 1, $ans + $k * 2);
echo $ans . PHP_EOL;

Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
#define all(x) (x).begin(),(x).end()

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);std::cout<<std::fixed<<std::setprecision(10);
    int N;
    cin >> N;
    int A;
    if(N % 2 == 0){
        A = N/2;
    }else{
        A = N/2 + 1;
    }
    double e = A;
    cout <<e/N<< "\n";
}

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

int main() {
  int n;
  cin >> n;
  vector<tuple<string, int, int>> a(n);
  string s;
  int x;
  for (int i = 0; i < n; i++) {
    cin >> s >> x;
    a.at(i) = make_tuple(s, x, i + 1);
  }
  int cnt = 0, z = 0;
  sort(a.begin(), a.end());
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (cnt == 0 && get<0>(a.at(i)) != get<0>(a.at(j))) break;
      else if (cnt != 0 && get<0>(a.at(i)) != get<0>(a.at(j))) {
        reverse(a.begin() + i, a.begin() + j);
        cnt = 0;
        i = j - 1;
        break;
      }
      else if (get<0>(a.at(i)) == get<0>(a.at(j))) cnt++;
      if (j == n - 1) {
        reverse(a.begin() + i, a.end());
        z = 1;
      }
    }
    if (z == 1) break;
  }
  for (int i = 0; i < n; i++) cout << get<2>(a.at(i)) << endl;
}

Measured memory_bytes: 256
/**
	Language: C++ 11
	Author  : ebby21
**/

#include <bits/stdc++.h>

using namespace std;

#define FASTIO() ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
#define DEBUG(var) cerr << '\n' << #var << "\t:\t" << var << '\n'
#define FORF(i, L, U) for (ll i = (L); i <= (U); ++i)
#define FORR(i, U, L) for (ll i = (U); i >= (L); --i)
#define FORE(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define ALL(x) (x).begin(), (x).end()

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

char s[100];
bool is_pal( int i, int j) {
	while (i < j) {
		if (s[i] != s[j]) return false;
		++i, --j;
	}
	return true;
}

int main() {
	FASTIO();
	cin >> s;
	int n = strlen(s);
	if (is_pal(0, n - 1) && is_pal(n/2 + 1, n -1) && is_pal(0, n/2 - 1))
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n, ma, mb; cin >> n >> ma >> mb;
	int a[n], b[n], c[n];
	for(int i = 0; i < n; ++i) cin >> a[i] >> b[i] >> c[i];
	int dp[400 + 1][400 + 1];
	for(int i = 0; i <= 400; ++i)for(int j = 0; j <= 400; ++j) dp[i][j] = 114514;
	dp[0][0] = 0;
	for(int i = 0; i < n; ++i){
		int nextdp[400 + 1][400 + 1];
		for(int j = 0; j <= 400; ++j)for(int k = 0; k <= 400; ++k) nextdp[j][k] = dp[j][k];
		for(int j = 0; j + a[i] <= 400; ++j) for(int k = 0; k + b[i] <= 400; ++k) nextdp[j + a[i]][k + b[i]] = min(dp[j + a[i]][k + b[i]], dp[j][k] + c[i]);
		for(int j = 0; j <= 400; ++j)for(int k = 0; k <= 400; ++k) dp[j][k] = nextdp[j][k];
	}
	int ans = 114514;
	for(int i =1; i * ma <= 400 && i * mb <= 400; ++i) ans = min(dp[i * ma][i * mb], ans);
	cout << (ans == 114514 ? -1 : ans) << endl;
	return 0;
}

Measured memory_bytes: 1536
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::HashMap;

// vs[p..r]において、vs[r]以下の要素をvs[p..q-1]に、
// vs[r]より大きい要素をvs[q..r]に区分けする。
fn partition(vs: &mut [usize], p: usize, r: usize) -> usize {
    let x = vs[r];
    let mut i: i64 = p as i64 - 1;
    for j in p..r {
        if vs[j] <= x {
            i += 1;
            vs.swap(i as usize, j);
        }
    }
    let q = (i + 1) as usize;
    vs.swap(q, r);
    return q;
}

fn main() {
    input!(n: usize, mut vs: [usize; n]);

    let r = n - 1;
    let q = partition(&mut vs, 0, r);

    for i in 0..n {
        if i != n - 1 {
            if i == q {
                print!("[{}] ", &vs[i]);
            } else {
                print!("{} ", &vs[i]);
            }
        } else {
            if i == q {
                println!("[{}]", &vs[i]);
            } else {
                println!("{}", &vs[i]);
            }
        }
    }
}



Measured memory_bytes: 5052
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;



int main() {
    int r;
    
    cin>>r;
    cout<<setprecision(12)<<2*r*M_PI<<endl;
    
    return 0;
}


Measured memory_bytes: 3792
S = input()
k = int(input())
from itertools import groupby
x = y = 0
g = [len(list(v)) for k,v in groupby(S)]
for c in g:
    x += c//2
#print(len(S),g[0])
if S[-1] == S[0]:
    if g[-1]%2 == 0 or g[0]%2 == 0:
        pass
    elif len(S) == 1:
        y = k//2
    elif len(S) == g[0]:
        y = k//2
        #print('?',y)
    else:
        y = k-1
print(x*k + y)


Measured memory_bytes: 3064
n, k = map(int, input().split())
n += 1
sum_n = sum(range(n))
ans = 0
for i in range(k, n+1):
    mi = i*(i-1) / 2
    ma = sum_n - ((n-i)*(n-i-1) / 2)
    ans += ma - mi + 1

print(int(ans%(7+10**9)))

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

#ifdef DEBUG
#include "inc/debug.hpp"
#else
#define debug(...) 42
#endif

int main() {
    int N;
    cin >> N;
    vector<int> p, x, y;
    for (int i=0; i<N; ++i) {
        int A, _x, _y;
        cin >> A;
        for (int j=0; j<A; ++j) {
            cin >> _x >> _y;
            p.push_back(i);
            x.push_back(_x-1);
            y.push_back(_y);
        }
    }
    int ans = 0;
    for (int i=0; i<(1<<N); ++i) {
        bool ok = true;
        for (int j=0; j<(int)p.size(); ++j) {
            bool b1 = (i >> p[j]) & 1;
            bool b2 = (i >> x[j]) & 1;
            if (b1 && b2 != y[j]) {
                ok = false;
                break;
            }
        }
        if (ok) {
            ans = max(ans, __builtin_popcount(i));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x


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

y = [abs(xi - X) for xi in x]
r = y[0]

for i in range(N-1):
    if y[i+1] != 0:
        r = gcd(r, y[i+1])

print(r)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	
	int tmp[310000];
	vpii morty[310000];

	void dijkstra(int x){
		queue<pair<int,int>>queue1;
		queue1.push({x,0});
		while(!queue1.empty()){
			pair<int,int> first = queue1.front();
			queue1.pop();
			FORR(x1,morty[first.first]){
				if(tmp[x1.first]<=first.second+x1.second)continue;
				queue1.push({x1.first,first.second+x1.second});
				tmp[x1.first] = first.second+x1.second; 
			}
		}
	}



	void solve(){

		
		ini(n,n1,x);
		FOR(i,0,n)tmp[i] = inf;
		tmp[x] = 0;
		FOR(i,0,n1){
			ini(tmpx,tmpx1,tmpp);
			morty[tmpx].push_back({tmpx1,tmpp});
		}
		dijkstra(x);
		FOR(i,0,n){
			if(tmp[i] == inf)out("INF");
			else out(tmp[i]);
		}
		
		
		

		


		
		
	}



	



















int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}



Measured memory_bytes: 24216