akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::iter::*;
#[allow(unused_imports)]
use std::*;

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
#[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

macro_rules! stdin {
    () => {{
        use std::io::Read;
        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }};
}

fn main() {
    println!("{}", solve(&stdin!()));
}
fn solve(src: &str) -> String {
    input! {
        source = src,
        n:usize,
        a:[usize;n],
    }
    a.sort_by(|v1, v2| v2.partial_cmp(v1).unwrap());
    let mut comfort: u64 = *a.first().unwrap() as u64;
    let mut t: isize = n as isize - 2;
    for &ai in a[1..].iter() {
        if t <= 0 {
            break;
        }
        comfort += (if t > 1 { 2 } else { 1 } * ai) as u64;
        t -= 2;
    }
    comfort.to_string()
}
test! {
    include_str!("d1_in.txt") => "7",
    include_str!("d2_in.txt") => "6",
}


Measured memory_bytes: 6344
#include <iostream>
#include <set>
#include <vector>

using namespace std;

int main (int argc, char* argv[])
{
  int R, G, B, N; cin >> R >> G >> B >> N;

  vector<int> RG;
  for (int i = 0; i <= N/R; i++) {
    for (int j = 0; j <= N/G ; j++) {
      RG.push_back(i*R+j*G);
    }
  }

  set<int> removeB;
  for (int i = 0;; i++) {
    if (N-B*i < 0) {
      break;
    }
    removeB.insert(N-B*i);
  }

  int ans = 0;
  for (int i = 0; i < RG.size(); i++) {
    if (removeB.find(RG[i]) != removeB.end()) {
      ans++;
    }
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 67040
#include<stdio.h>
#define W 0
#define G 1
#define B 2
int n,color[100],next[100],count=0,v[100][100];
int d[100],f[100],s[100],top=0;

int nextf(int a){
  int i;
  for(i=next[a];i<n;i++){
    next[a]=i+1;
    if(v[a][i]==1)return i;
  }
  return -1;
}

void push(int a){
  top++;
  s[top]=a;
}

int pop(){
  top--;
  return s[top+1];
}

void dfsv(int r){
  int i;
  for(i=0;i<n;i++)next[i]=0;

  push(r);
  color[r]=G;
  d[r]=++count;

  while(top!=0){
    int u,v;
    u=s[top];
    v=nextf(u);
      if(v!=-1){
	if(color[v]==W){
	color[v]=G;
	d[v]=++count;
	push(v);
      }
  }
      else {
	pop();
	color[u]=B;
	f[u]=++count;
      }
  }
}

void dfs(){
  int i;
  for(i=0;i<n;i++){
    color[i]=W;
    next[i]=0;
  }

  for(i=0;i<n;i++)if(color[i]==W)dfsv(i);

  for(i=0;i<n;i++)printf("%d %d %d\n",i+1,d[i],f[i]);
}

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

  scanf("%d",&n);

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

  dfs();
  
  return 0;
}



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

int main(){
  string s;
  cin >> s;
  int n = s.size();

  for(int i=0;i<=(n-1)/4;i++){
    if(s[i]!=s[(n-1)/2-i-1]){
      cout << "No";
      return 0;
    }
  }
  for(int i=0;i>=(n+3)/4;i++){
    if(s[n-i-1]!=s[(n+3)/2+i]){
      cout << "No";
      return 0;
    }
  }
  for(int i=0;i<=n/2;i++){
     if(s[i]!=s[n-i-1]){
      cout << "No";
      return 0;
     }
  }
  cout <<"Yes";
}

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

int main() {
	int k, n, h;
	cin >> n >> k;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> h;
		if (h >= k)ans++;
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
def inN():
    return int(input())
def inL():
    return list(map(int,input().split()))

x,y= inL()
f = False
for i in range(x+1):
    if (i*2 + (x-i)*4) == y:
        f = True
        break
if f:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 61860
using System;
using System.Linq;

namespace ABC095
{
    class B
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int X = int.Parse(input[1]);

            int min = int.MaxValue;
            int m = 0;
            int count = 0;
            for (int i = 0; i < N; i++)
            {
                m = int.Parse(Console.ReadLine());
                X -= m;
                count++;
                min = Math.Min(min, m);
            }

            Console.WriteLine(count + X / min);
        }
    }
}


Measured memory_bytes: 13140
#include <stdio.h>

int main(void)
{
  int L;
  int A;
  int B;
  int C;
  int D;
  int i;
  i=0;
 scanf("%d%d%d%d%d",&L,&A,&B,&C,&D);
  while (A>0 || B>0 ){
  A= A -C;
  B= B -D;
  i++; 
 } 
  printf("%d\n",L-i );
 return(0);
}

Measured memory_bytes: 596
#include <stdio.h>

int main(){
    long int A, B, C, K;
    scanf("%ld%ld%ld%ld", &A, &B, &C, &K);
    if(K<=A){
        printf("%ld", K);
    }else if(K<=A+B){
        printf("%ld", A);
    }else{
        printf("%ld", 2 * A + B - K);
    }
    return 0;
}

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

#define REP(i,n,m) for(int i=n;i<m;i++)
#define rep(i,n) REP(i,0,n)

int n;
int t[22][22];

int solve(int idx){
	int res = 0;
	rep(i,n){
		if(t[idx][i] > 0){
			t[i][idx] = 0;
			res = max(res,t[idx][i]+solve(i));
		}
	}
	return res;
}

int main(void){
	while(cin>>n,n){
		memset(t,0,sizeof(t));

		int sum = 0;
		rep(i,n-1){
			int a,b,cost;
			cin>>a>>b>>cost;
			t[a-1][b-1] = t[b-1][a-1] = cost;
			sum += cost * 2;
		}

		rep(i,n){
			int cnt=0, idx;
			rep(j,n){
				if(t[i][j] > 0 || t[i][j] == -1){
					cnt++;
					idx = j;
				}
			}
			if(i != 0 && cnt == 1){
				sum -= 2 * t[i][idx];
				t[i][idx] = t[idx][i]= -1;
			}
		}

		cout<<sum-solve(0)<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n;
ll sum;
ll gcd3(int a,int b,int c)
{
	return (ll)(__gcd(__gcd(a,b),c));
}
int main()
{
	cin>>n;
	for(int a=1;a<=n;a++)
		for(int b=1;b<=n;b++)
			for(int c=1;c<=n;c++)
				sum+=gcd3(a,b,c);
	cout<<sum<<endl;
	return 0;
}

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

int main(){
	
	ll n,k; cin>>n>>k; vector<ll> arr(n);
	for(int i = 0; i < n; i++){
		cin>>arr[i];
	}
	ll sum = 0;
	sort(arr.begin(),arr.end());
	for(int i = 0; i < (n-k); i++){
		sum += arr[i];
	}
	cout<<sum<<"\n";
	
}


Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
const int N = 2e5 + 54;
const long long MOD = 1000000007;
struct point {
	int from, to;
} eg[N << 1];
int front[N], num;
void lian(int x, int b) {
	eg[++ num].to = b;
	eg[num].from = front[x];
	front[x] = num;
}
long long ksm(long long x, long long b) {
	long long maretu = 1;
	for (; b; b >>= 1) {
		if (b & 1) {
			maretu = maretu * x % MOD;
		}
		x = x * x % MOD;
	}
	return maretu;
}
int n, vis[N];
long long jc[N], ny[N], ru[N], ans[N], siz[N], gl[N];
long long dfs(int o, int fa) {
	gl[o] = 1;
	siz[o] = 1;
	for (int i = front[o]; i; i = eg[i].from) {
		int to = eg[i].to;
		if(to == fa)continue;
		gl[o] *= dfs(to, o);
		gl[o] %= MOD;
		siz[o] += siz[to];
	}
	//printf("%d %lld\n", o, (gl * ny[siz[o]]) % MOD);
	return (gl[o] * ny[siz[o]]) % MOD;
}
void check(int o) {
	//printf("%d\n", o);
	vis[o] = 1;
	ans[o] = (( (jc[n] * gl[o]) % MOD) * ny[n] % MOD) % MOD;
	//printf("%lld\n", ans);
	for (int i = front[o]; i; i = eg[i].from) {
		int to = eg[i].to;
		if(vis[to] == 1)continue;
		long long ori_gl1, ori_gl2, ori_siz1, ori_siz2;
		ori_gl1 = gl[o];
		ori_gl2 = gl[to];
		ori_siz1 = siz[o];
		ori_siz2 = siz[to];
		gl[o] = (gl[o] * ksm((gl[to] * ny[siz[to]]) % MOD, MOD - 2)) % MOD;
		siz[o] = n - siz[to];
		gl[to] = gl[to] * ((gl[o] * ny[siz[o]]) % MOD) % MOD;
		siz[to] = n;
		check(to);
		gl[o] = ori_gl1;
		gl[to] = ori_gl2;
		siz[o] = ori_siz1;
		siz[to] = ori_siz2;
	}
}
int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int x, b;
		scanf("%d%d", &x, &b);
		++ru[x];
		++ru[b];
		lian(x, b);
		lian(b, x);
	}
	jc[0] = ny[0] = 1;
	for (long long i = 1; i <= n; i++) {
		jc[i] = jc[i - 1] * i % MOD;
		ny[i] = ksm(i, MOD - 2);
	}
	dfs(1, 0);
	check(1);
	for (int i = 1; i <= n; ++i) std::cout << ans[i] << '\n';
}

Measured memory_bytes: 16384
#include <iostream>
#include <string>
#include <map>

int main(){
   std::string w;
   std::cin >> w;
   std::map<char, int> mp;
   for (int i=0; i<w.size(); i++){
      mp[w.at(i)]++;
   }
   bool flag = true;
   for (auto x : mp){
      if (x.second % 2 == 1){
         flag = false;
         break;
      }
   }
   if (flag)
      std::cout << "Yes" << std::endl;
   else
      std::cout << "No" << std::endl;

}



Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;

#define gcu getchar_unlocked
#define pcu putchar_unlocked
#define _T template <typename T>
#define _HT template <typename H, typename... T>
#define _il inline
#define _in _il int in
#define _sc _il bool scan
_T T in(int c){T n=0;bool m=false;while(isspace(c)){c=gcu();}if(c=='-')m=true,c=gcu();
	do{n=10*n+(c-'0'),c=gcu();}while(c>='0');return m?-n:n;} //&&c<='9'
_in() {return in<int>(gcu());}
_T T scan(T &n){int c=gcu();return c==EOF?false:(n=in<T>(c),true);}
_sc(char &c){c=gcu();gcu();return c!=EOF;}
#ifdef _GLIBCXX_STRING
_sc(string &s){int c;s="";
	for(;;){c=gcu();if(c=='\n'||c==' ')return true;else if(c==EOF)return false;s+=c;}}
#endif
_HT _sc(H &h, T&&... t){return scan(h)&&scan(t...);}
#define _vo _il void out
#define _vl _il void outl
_vo(bool b) {pcu('0'+b);}
_vo(const char *s){while(*s)pcu(*s++);}
_vo(char c){pcu(c);}
#ifdef _GLIBCXX_STRING
_vo(string s){for(char c:s)pcu(c);}
#endif
_T _vo(T n){static char buf[20];char *p=buf;
	if(n<0)pcu('-'),n*=-1;if(!n)*p++='0';else while(n)*p++=n%10+'0',n/=10;
	while (p!=buf)pcu(*--p);}
_vl(){out('\n');}
#ifdef _GLIBCXX_VECTOR
_T _vo(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);outl();}
#endif
_HT _vo(H&& h, T&&... t){out(h);out(move(t)...);}
template <typename... T> _vl(T&&... t){out(move(t)...);outl();}

using v = vector<int>;
using vv = vector<v>;
#define all(a) a.begin(), a.end()

int main() {
	for (int N; (N = in());) {
		vv s(N);
		for (auto &x: s)
			for (int M = in(); M; M--)
				x.push_back(in());
		v l(in());
		for (int &x: l)
			x = in();
		sort(all(l));
		int i = 1, q = -1;
		for (auto x: s) {
			v r;
			sort(all(x));
			if (includes(all(x), all(l))) {
				if (q == -1)
					q = i;
				else {
					q = -1;
					break;
				}
			}
			i++;
		}
		outl(q);
	}
}


Measured memory_bytes: 2704
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int A, B, C;

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

  cin >> A >> B >> C;
  cout << A*B/2 << "\n";
  return 0;
}

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

void maxPro(int x[], int n);

int main() {
    int n; //how many numbers
    int x[200000];
    
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> x[i]; 
    } 
    maxPro(x, n);
    return 0;
}

void maxPro(int x[], int n) {  
    int minn=x[0], maxx=x[1]-x[0];
    for ( int i = 1; i < n; i++ ) {
        /*ここ n にsizeof(x)/sizeof(x[0])だと
          main内のsizeがわからない
          そして、maxfProの引数にそれ与えても200000が返される*/
    
        maxx = max(maxx, x[i] - minn);
        minn = min(minn, x[i]);
    }
    cout << maxx << endl;
}


Measured memory_bytes: 3888
#include <bits/stdc++.h>
#define lli long long int
using namespace std;
#define MOD 1000000007
#define mod 1000000037
#define mod1 998244353
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); 
#define INF 2*1e9

int main()
{
    fastio;
    int n,k;
    cin >> n >> k;
    vector<int>v(n);
    for(int i=0;i<n;i++)
        cin >> v[i];
    vector<int>dp(n);
    for(int i=n-1;i>max(-1,n-k-1);i--)
        dp[i]=abs(v[i]-v[n-1]);
    for(int i=n-k-1;i>-1;i--)
    {
        int t=dp[i+1]+abs(v[i]-v[i+1]),ind=i+1;
        for(int j=i+1;j<i+1+k;j++)
        {
            if(dp[j]+abs(v[i]-v[j])<t)
            {
                t=dp[j]+abs(v[i]-v[j]);
                ind=j;
            }
        }
        dp[i]=t;
    }
    cout << dp[0] << endl;
}

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

#define     fast()              ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define     ll                  long long int
#define     test()              ll t; cin>>t; while(t--) 
#define     lp0(i,begin,end)    for(ll i=begin;i<end;i++)
#define     lp1(i,begin,end)    for(ll i=begin;i<=end;i++)
#define     rlp(i,begin,end)    for(ll i=end;i>=begin;i--)
#define     prec(n)             fixed<<setprecision(n)
#define     initial(a,i)        memset(a,i,sizeof(a))
#define     pb                  push_back
#define     PI                  3.1415926535897932384626433832795
#define     MOD                 1000000007
#define     F                   first
#define     S                   second
#define     all(a)              (a).begin(),(a).end()
#define     BPC(x)              __builtin_popcountll(x)
#define     gcd(a,b)            __gcd(a,b)

ll gcd(ll a,ll b) {if (a==0) return b;return gcd(b%a,a);}

ll power(ll x,ll n)
{
    ll result = 1;
    while (n)
    {
        if (n & 1)
            result = result * x;
        n = n / 2;
        x = x * x;
    }
    return result;
}


// Solution Function
void solution(ll compte)
{
    // cout<<compte<<"\n";
    ll n,m;
    cin>>n>>m;
    ll x =10;
    cout<<(m+(100*(10-min(x,n))) )<<"\n";
}
// Driver Function
int main()
{
    ll compte = 1;
    //test()
    //{
        solution(compte);
        compte++;
    //}
    return 0;
}


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

int main() {
  int N, a[110];
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }

  sort(a, a + N, greater<int>());
  
  int alice = 0, bob = 0;
  for (int i = 0; i < N; i++) {
    if (i % 2 == 0) alice += a[i];
    else bob += a[i];
  }
  
  cout << alice - bob << endl;
  
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<fstream>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
#define Set(a) memset(a,0,sizeof(a))
#define F(i,a,b) for(register int i=a,i##end=b;i<=i##end;++i)
#define UF(i,a,b) for(register int i=a,i##end=b;i>=i##end;--i)
#define openf(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define re register
#define ri re int
#define il inline
typedef long long ll;
typedef unsigned long long ull;
template<typename T> inline T rd(T& x)
{
	T f=1;x=0;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(; isdigit(c);c=getchar()) x=(x<<3)+(x<<1)+(T)(c-'0');
	x*=f;
	return x;
}
ll rd(){ll x;rd(x);return x;}
inline int max(int a,int b){return a>b?a:b;}
inline int min(int a,int b){return a<b?a:b;}
const int inf=1<<30;

int main()
{
	double pi=3.14159265359;
	int n=rd();
	printf("%.10lf\n",pi*2*n);
	return 0;
}

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

int main()
{
    int N;
    cin >> N;
    int A[N];
    int sum = 0, firstHalf, secHalf;
    firstHalf = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
        sum += A[i];
    } 
    int min_diff = INT_MAX;
    for(int i = 0; i < N; i++)
    {
        firstHalf += A[i];
        secHalf = sum - firstHalf;
        min_diff = min(min_diff, abs(secHalf - firstHalf));
    }
    cout << min_diff << endl;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    for (ll i = 1; i <= N; i++) {
        if (i % 3 != 0 && i % 5 != 0) ans += i;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3596
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); };

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int inf = TEN(9) + 10;
const int mod = TEN(9) + 7;

signed main()
{
	int n,a,b;cin>>n>>a>>b;
	string s;cin>>s;

	int counter = 0, foreign_rank = 1;

	rep(i, n) {
		if (s[i] == 'a') {
			counter++;

			if (counter <= a + b) {
				cout << "Yes\n";
			} else {
				cout << "No\n";
			}
		} else if (s[i] == 'b') {
			if (counter < a + b and b >= foreign_rank) {
				cout << "Yes\n";
				counter++;
				foreign_rank++;
			} else {
				cout << "No\n";
			}
		} else {
			cout << "No" << endl;
		}
	}
}


Measured memory_bytes: 896
#include <stdio.h>
 
using namespace std;
 
int main(){
    int a,b;
    char op;
    while(true){
        scanf("%d %c %d",&a,&op,&b);
        if(op == '?') break;
        switch(op){
        case '+':
            printf("%d\n",a+b);
            break;
        case '-':
            printf("%d\n",a-b);
            break;
        case '/':
            printf("%d\n",a/b);
            break;
        case '*':
            printf("%d\n",a*b);
            break;
        }
    }
}


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


using namespace std;
//using namespace boost::multiprecision; 

#define FAST ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define TC int t; cin >> t; while(t--)
#define li long int
#define ll long long
#define ull unsigned long long 
#define Vec(x) vector <x>
#define Pai(x,y) pair <x,y>
#define Map(x,y) map <x,y>
#define UMap(x,y) unordered_map <x,y>
#define Set(x) set <x>
#define Sta(x) stack <x>
#define Qu(x) queue <x>
#define DQ(x) deque(x)
#define PriorQ(x)	priority_queue <x>
#define bg begin()
#define ed end()
#define sz size()
#define ct(x) count(x)
#define len length()
#define F first
#define S second
#define Makep make_pair
#define ins(x) insert(x)
#define ers(x) erase(x)
#define endl "\n";
#define MOD 1000000007
#define PI 2*acos(0.0)
#define clr() clear()
#define fori0(n) for(int i=0;i<n;i++)
#define foriab(a,b) for(int i=a;i<b;i++)
#define mem0(x) memset(x,0,sizeof(x))
#define mem1(x) memset(x,1,sizeof(x))
#define autoit(x) for(auto it=x.beg;it!=x.ed;it++)
#define count0(x) __builtin_popcount(x)
#define ret return 
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

const ll Inf=1e9+5;



namespace funset{
bool checkvow(char x){
	return ((0x208222)>>(x&(0x1f)))&1;
	}
ll highpow2(ll x){
	return (x&~(x-1));
	}
bool chk2(ll x){
		return (x&(x-1));
	}
ll powMOD(ll a, ll b){
    ll res=1;
    a%=MOD;
    while(b){
        if(b&1){
            res=res*a%MOD;
        }
        a=a*a%MOD;
        b>>=1;
     }
    return res;
    }
ll powwMOD(ll a, ll b){
    ll res=1;
    while(b){
        if(b&1){
            res=res*a;
         }
            a=a*a;
            b>>=1;
        }
    return res;
    }     	
}

vector <ll> vis(27,0);

using namespace funset;

string s;

ll fact(ll n){
    if(n<=1)
        return 1;
    return n*fact(n-1);
}

bool compare( pair <string,ll> &a, pair <string,ll> &b){
	return (a.S>b.S)||(a.S==b.S && a.F < b.F);	 
}
void solve(){
	string s;
	cin >> s;
	ll co=0, ck=0,i=0;
	if(s[i]==s[i+1] && s[i+1]==s[i+2]){
		if(s[i]=='R')
			co=3;
		else
			co=0;

		//continue;
	}
	else if(s[i]==s[i+2] && s[i+1]!=s[i]){
		co=1;
		//continue;
	}
	else if(s[i]==s[i+1] || s[i+1]==s[i+2]){
		if(s[i+1]=='S')
			co=1;
		else
			co=2;
	}
	cout << co << endl;
}
int main(){
    //TC
	solve();
	ret 0;
}

Measured memory_bytes: 3624
n, m, k = [int(_) for _ in input().split()]

a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]

b.append(k+100)
cnt = 0
ans1, ans2 = 0, 0
for i in range(n-1):
    a[i+1] += a[i]
    if a[i+1] <= k:
        ans1 = i+2
for j in range(m-1):
    b[j+1] += b[j]
    if b[j+1] <= k:
        ans2 = j+2
# print(a, b)
ans = max(ans1, ans2)
for i in range(n):
    nokori = k-a[i]
    r, l = 0, m
    if nokori < 0:
        break
    if b[0] > nokori:
        ans = max(i+1, ans)
        continue

    while(l-r > 1):
        if b[(r+l)//2] <= nokori:
            r = (r+l)//2
        else:
            l = (r+l)//2
        # print(l, r)
    ans = max(i+l+1, ans)
    # print(i, r, l, nokori)
print(ans)


Measured memory_bytes: 39644
#include <bits/stdc++.h>
using namespace std;
 
const int Maxn = 10005;
int n, k, mini = 0x3f3f3f3f, maxi, cnt[Maxn], ct;
string S[Maxn], str, tmp;
int main()
{
	scanf("%d%d", &n, &k);
	cin >> str;
	for (int i = 0; i < n; i++)
		str += str[n - i - 1];
	for (int i = 0; i < 2 * n; i++)
		mini = min(mini, str[i] - 'a');
	for (int i = 0; i < 2 * n; i++)
	{
		if (str[i] - 'a' == mini) cnt[i] = cnt[i - 1] + 1;
		else cnt[i] = 0;
		maxi = max(maxi, cnt[i]);
	}
	int limit = min(n, maxi * ((1 << (min(15, k) - 1)) - 1));
	for (int i = 0; i < n; i++)
	{
		tmp = "";
		if (cnt[i + n] != maxi) continue;
		for (int j = i + n; j > i + limit; j--)
			tmp += str[j];
		S[++ct] = tmp;
	}
	sort(S + 1, S + 1 + ct);
	for (int i = 0; i < limit; i++)
		putchar(mini + 'a');
	for (int i = limit; i < n; i++)
		putchar(S[1][i - limit]);
	return 0;
}

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

int main()
{
  int h, w, i, j;
  cin >> h >> w;
  vector<string> a(h);
  for (i = 0; i < h; i++)
    cin >> a[i];
  vector<bool> a1(h, false), a2(w, false);
  for (i = 0; i < h; i++)
    for (j = 0; j < w; j++)
      if (a[i][j] == '#')
        a1[i] = a2[j] = true;
  for (i = 0; i < h; i++) {
    if (!a1[i]) continue;
    for (j = 0; j < w; j++)
      if (a1[i] && a2[j]) cout << a[i][j];
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v1 = vector<T>;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9 + 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;
    if (S.length() <= K) {
        cout << S << endl;
    } else {
        cout << S.substr(0, K) << "..." << endl;
    }
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <algorithm>

using namespace std;

int main() {

	for (;;) {
		int Sum;

		scanf("%d", &Sum);
		if (!Sum) break;

		for (int i = 0; i < 9; i++) {
			int t;
			scanf("%d", &t);
			Sum -= t;
		}

		printf("%d\n", Sum);
	}

	return 0;
}

Measured memory_bytes: 2592
#pragma G++ optimize(2)
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define LL long long
#define O4 __inline__ __attribute__((always_inline))
#define inf 0x7fffffff
#define UL unsigned LL
#define LD long double
#ifdef ONLINE_JUDGE
#define getchar nc
#endif
//#define int LL
namespace FastIO{
	O4 char nc(){
		static char buf[100000],*p1=buf,*p2=buf;
		return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
	}
	O4 int read(){
		char t;int u=0,k=1;t=getchar();
		while(t<'0'||t>'9'){if(t=='-')k=-1;t=getchar();}
		while(t>='0'&&t<='9'){u=u*10+t-'0';t=getchar();}
		return u*k;
	}
	template <typename T>
	O4 void read(T &u){
		char t;T k=1;u=0;t=getchar();
		while(t<'0'||t>'9'){if(t=='-')k=-1;t=getchar();}
		while(t>='0'&&t<='9'){u=u*10+t-'0';t=getchar();}
		if(t=='.'){
			T mass=0.1;t=getchar();
			while(t>='0'&&t<='9'){u+=mass*(t-'0');mass/=10;t=getchar();}
		}u*=k;
	}
	O4 int read(char asd[]){
		char t=getchar();int u=0;
		while(t==' '||t=='\n'||t=='\r')t=getchar();
		while(t!=' '&&t!='\n'&&t!=EOF&&t!='\r')asd[u++]=t,t=getchar();
		asd[u]='\0';return u;
	}
	char sr[1<<23],z[23];int C=-1,Z;
	O4 void wer(int x,char T){
		int y=0;if(x<0)y=1,x=-x;
		while(z[++Z]=x%10+'0',x/=10);if(y)z[++Z]='-';
		while(sr[++C]=z[Z],--Z);sr[++C]=T;
	}
	O4 void wer(char T[],char QWQ){
		for(int i=0;T[i]!='\0';i++)sr[++C]=T[i];
		sr[++C]=QWQ;
	}
	O4 void out(){fwrite(sr,1,C+1,stdout);C=-1;}
}
using namespace std;
using namespace FastIO;
const int N=1e5+5,MOD=1e9+7;
int n,m,a,b,c,d,e,limit,k;
int val[N];struct oath{int F,G;};
//F 黑白相間	G 普通 
O4 int KSM(int a,int b=MOD){
	int res=1;
	while(b){
		if(b&1)res=1ll*res*a%MOD;
		a=1ll*a*a%MOD;b>>=1;
	}return res;
}
oath DFS(int L,int R,int las,int dp){
	int mi=1e9+5,sum=0;
	oath now={1,1},TP;
	for(int i=L;i<=R;i++){
		if(mi==val[i])sum++;
		if(val[i]<mi)sum=1,mi=val[i];
	}
	if(sum==R-L+1){
		now.F=KSM(2,mi-las);
		now.G=KSM(2,sum)-2;
		return now;
	}
	for(int ql=L,qr;ql<=R;ql=qr+1){
		while(ql<=R&&val[ql]==mi)ql++;
		if(ql==R+1)break;
		qr=ql;while(qr<R&&val[qr+1]>mi)qr++;
		if(ql==L&&qr==R){
			for(int i=L;i<=R;i++)if(val[i]==mi)while(1);
			exit(233);
		}
		TP=DFS(ql,qr,mi,dp+1);
		now.F=1ll*TP.F*now.F%MOD;
		now.G=1ll*(TP.F*2%MOD+TP.G)%MOD*now.G%MOD;
	}
	now.G=1ll*now.G*KSM(2,sum)%MOD;
	(now.G-=now.F*2%MOD)%=MOD;
	now.F=1ll*now.F*KSM(2,mi-las)%MOD;
	return now;
}
signed main(){
	n=read();
	for(int i=1;i<=n;i++)val[i]=read();
	oath Ans=DFS(1,n,0,1);
	cout<<((Ans.F+Ans.G)%MOD+MOD)%MOD;
	return out(),0;
}
/*
6
1 1 4 5 1 4
*/

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

int main(){
    int x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;

    int x3,y3,x4,y4;
    int X=x2-x1, Y=y2-y1;
    x3=x2-Y;
    y3=y2+X;
    x4=x3-X;
    y4=y3-Y;
    cout<<x3<<' '<<y3<<' '<<x4<<' '<<y4<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fr first
#define sc second
#define pb push_back
#define ll long long
#define maxheap priority_queue<int>
#define minheap priority_queue<int,vector<int>,greater<int>>
const double pi = acos(-1.0);
const double eps = 1e-9;
using namespace std;

void solve(){
    int n;
    cin >> n;
    vector <int> a(n), l(n, - 1), r(n, - 1);
    for (int i = 0; i < n; i++) cin >> a[i];
    
    vector <int> pos;
    for (int i = 0; i < n; i++){
        while (!pos.empty() && a[pos.back()] >= a[i]) pos.pop_back();
        if (pos.size() == 0) l[i] = 0;
        else l[i] = pos.back() + 1;
        pos.pb(i);
    }
    pos.clear();
    for (int i = n - 1; i >= 0; i--){
        while (!pos.empty() && a[pos.back()] >= a[i]) pos.pop_back();
        if (pos.size() == 0) r[i] = n - 1;
        else r[i] = pos.back() - 1;
        pos.pb(i);
    }
    //for (int i = 0; i < n; i++) cout << l[i] + 1 << " " << i + 1 << " " << r[i] + 1 << endl;
    ll ans = 0;
    for (int i = 0; i < n; i++){
        ans += (r[i] - i + 1) * 1ll * (i - l[i] + 1) * 1ll * a[i];
    }
    cout << ans << endl;
}   
int main(){
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(10);
    //freopen("input.txt", "r", stdin);//freopen("output1.txt", "w", stdout);
    //freopen("icecream.in","r",stdin);// freopen("exam.out", "w", stdout);
    int step;
    step = 1;
    //cin >> step;
    for (int i = 1; i <= step; i++){
         solve();
    }
}


Measured memory_bytes: 6632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;

int main()
{
    int a, b, c, d; cin >> a >> b >> c >> d;
    ll MOD = 998244353;
    ll dp[c+1][d+1]; memset(dp, 0, sizeof(dp));
    dp[a][b] = 1;
    for (int i = a + 1; i <= c; i++)
    {
        dp[i][b] = (dp[i-1][b]*b) % MOD;
    }
    for (int i = b+1; i <= d; i++)
    {
        dp[a][i] = (dp[a][i-1]*a) % MOD;
    }
    for (int i = a + 1; i <= c; i++)
    {
        for (int j = b + 1; j <= d; j++)
        {
            dp[i][j] = ( ((dp[i-1][j] * j) % MOD) + ((dp[i][j-1] * i) % MOD) - ((((dp[i-1][j-1] * (i-1)) % MOD) * (j-1)) % MOD) + MOD) % MOD;
        }
    }
    cout << dp[c][d] << '\n';
    return 0;
}

Measured memory_bytes: 73784
s=input()
c=0
f=0
ans=0
for i in range(len(s)):
  if f==0 and s[i]=='W':
    c+=1
  elif f==0 and s[i]=='B':
    f=1
  elif f==1 and s[i]=='W':
    ans+=i-c
    c+=1
print(ans)

Measured memory_bytes: 3500
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i<n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
#define SUM(x) accumulate(x.begin(), x.end(),0);
#define vint(v,n) vector<int> v(n); REP(i,n) scanf("%lld", &v[i]);
#define vstr(v,n) vector<string> v(n); REP(i,n) scanf("%lld", &v[i]);
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
int k=0,n=0, m=9, l=0,a=0, b=0, c=0, d=0,e=0,ans=0,ans2=0,x=0,y=0;
string s,t,S;
signed main() {
    vint(A, 5);
  bool flag=false;
    REP(i,5){
        if(A[i]%10<=m%10&&A[i]%10!=0)m=A[i];
    }
    REP(i,5){
        if(A[i]!=m||flag)while(A[i]%10!=0){
          A[i]++;
        
        }else{
          flag=true;
        }
    }
    ans=SUM(A);
    cout << ans;
}

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

int main()
{
    int h, n, i, sum=0;
    cin >> h >> n;
    int a[n];
    for(i=0; i<n; i++)
    {
        cin >> a[i];
    }
    for(i=0; i<n; i++)
    {
        sum=sum+a[i];
    }
    if(sum>=h) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

ll mod = 1e9 + 7;

ll count(string s) {
    ll n = s.size();
    ll cc = 0;
    REP(i, n - 1) {
        if (s[i + 1] == s[i]) {
            cc++;
            s[i + 1] = '.';
        }
    }
    return cc;
}

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

    string s;
    cin >> s;
    ll k;
    cin >> k;
    string t = "";
    vll v(4);
    REP(i, 4) {
        t += s;
        v[i] = count(t);
    }
    ll res;
    if (k % 2) res = v[0] + (k - 1) * (v[2] - v[0]) / 2;
    else res = v[1] + (k - 2) * (v[3] - v[1]) / 2;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define INF 200001
int A[100];
int B[100][100];

void mCO(int n){
  int i,j,k,l,q;
  for(i=i;i<=n;i++){
    B[i][i]=0;
  }
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j=i+l-1;
     B[i][j]=INF;
      for(k=i;k<=j-1;k++){
	q=B[i][k]+B[k+1][j]+A[i-1]*A[k]*A[j];
	B[i][j]=min(B[i][j],q);
      }
    }
  }
  printf("%d\n",B[i-1][n]);
}
 
int min(int a,int b){
  if(a>b){
    return b;
  }
  else {
    return a;
  }
}
      
int main(){
  int i,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d%d",&A[i],&A[i+1]);
  }
  mCO(n);
  return 0;
}

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

int main()
{
int n,x,i,ma,sum=0;
  cin>>n;ma=-1;
  for(i=0;i<n;i++)
  {
    cin>>x;
  ma=max(ma,x);
    sum+=(x);
  }
  if(ma<sum-ma)cout<<"Yes";
  else cout<<"No";

}


Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		String b=sc.next();

		if("A".equals(b)) {
			System.out.println("T");
		}else if ("T".equals(b)) {
			System.out.println("A");
		}else if ("C".equals(b)) {
			System.out.println("G");
		}else {
			System.out.println("C");
		}
	}
}

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define COUT(x) cout<<(x)<<"\n"

int main(){
    int n;cin >> n;
    string s; cin >> s;
    int count = 0;
    for(int i=0;i<1000;i++){
        int num[3]={i/100,(i/10)%10,i%10};
        int f=0;
        for(int j=0;j<n;j++){
            if(s[j]==('0'+num[f]))f++;
            if(f==3)break;
        }
        if(f==3)count++;
    }
    COUT(count);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define pll pair<ll,ll>
#define rep(i,n) for(int i=0;i<n;i++) 
const ll INF = 1LL<<60;
const ll mod = (int)1e9 + 7;

int main() {
    //ll N; cin >> N;
    //ll N,M; cin >> N >> M;
    //string S; cin >> S;
    //ll H,W; cin >> H >> W;
    int N;
    cin >> N;
    int K;
    cin >> K;
    int Q;
    cin >> Q;
    int P[N]={};
    rep(i,Q){
        int a;
        cin >> a;
        P[a-1]++;
    }
    rep(i,N){
        if(Q-P[i]>=K)cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    


}

/*



 */



Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("Failed to read bytes") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n:usize = read();
    let arr:Vec<(f64, f64)> = (0..n).map(|_| (read(), read())).collect();
    let mut cnt = 0.0;
    for i in 0..n {
        for j in 0..n {
            cnt += ((arr[i].0 - arr[j].0).powf(2.0) + (arr[i].1 - arr[j].1).powf(2.0)).sqrt();
        }
    }
    println!("{}", cnt / n as f64);

}

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


int main() {
  int n;
  cin >> n;
  long long a = 2;
  long long b = 1;
  if (n == 1){
    cout << 1 << endl;
  }
  else{
    for (int i = 1; i < n; i++){
      long long na = b;
      b = a + b;
      a = na;
    }
    cout << b << endl;
  }
    
}


Measured memory_bytes: 256
def main():
    from collections import Counter as ct
    n,m=map(int,input().split())
    x=list(map(int,input().split()))
    x=ct(x)
    pair=dict()
    single=dict()
    for i,j in x.items():
        mod=i%m
        sho=j//2
        amari=j%2
        if sho>0:
            if mod in pair.keys():
                pair[mod]+=sho*2
            else:
                pair[mod]=sho*2
        if amari==1:
            if mod in single.keys():
                single[mod]+=amari
            else:
                single[mod]=amari
    ans=0
    for i in range(m//2+1):
        j=(m-i)%m
        if i==j:
            if i in single.keys():
                ans+=single[i]//2
                single[i]%=2
        else:
            if (i in single.keys()) and (j in single.keys()):
                temp=min(single[i],single[j])
                ans+=temp
                single[i]-=temp
                single[j]-=temp
    for i in single.keys():
        j=(m-i)%m
        if j in pair.keys():
            temp=min(single[i],pair[j])
            pair[j]-=temp
            ans+=temp
    for i in pair.values():
        ans+=i//2
    print(ans)
main()

Measured memory_bytes: 26572
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int quick(const void *a, const void *b) {
  return *(long *)a - *(long *)b;
}

int main(void) {
  long long a[10000002], test = 0, kari = 0, n, count = 0;

  if(scanf("%lld", &n) == 1);

  for(long i = 0; i < n; i++) {
    if(scanf("%lld", &a[i]) == 1) {
    } else {
      printf("erro");
    }
  }

  qsort(a, n, sizeof(long), quick);


  while(1) {
    count = 1;
    for(long long i = 1; i < n; i++) {
      if(a[i] > a[0]) {
        test = a[i] / a[0];
        if(test > 1) {
          test--;
        }
        if(a[i] - a[0]< a[0] && a[i] - a[0] < a[0]) {
          kari = a[0];
          a[0] = a[i] - (a[0] * test);
          a[i] = kari;
        } else {
          a[i] = a[i] - (a[0] * test);
        }
      } else {
        count++;
      }
    }
    if(count == n) {
      break;
    }
  }


  qsort(a, n, sizeof(long), quick);

    printf("%lld", a[0]);

  return 0;
}


Measured memory_bytes: 3452
#include<bits/stdc++.h>
using namespace std;
int main(){int n,k;cin>>n>>k;vector<int> a(n);
           for(int i=0;i<n;i++)cin>>a.at(i);
           sort(a.begin(),a.end());
           long f=0;for(int i=0;i<k;i++)f+=a.at(i);
           cout<<f<<endl;}

Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(void){
    int n,a,b,c,i,j,t[8],bit=3;
    int tmp,t_a,t_b,t_c,cnt;
    long long ans=1000000000;
    cin >> n >> a >> b >> c;
    for(i=0;i<n;i++) cin >> t[i];
    for(i=0;i<(1<<(n*2));i++){
        tmp=i,cnt=0,t_a=0,t_b=0,t_c=0;
        for(j=0;j<n;j++){
            int k=tmp&3;
            if(k==1){
                t_a+=t[j];
                if(t_a!=t[j]) cnt+=10;
            }
            else if(k==2){
                t_b+=t[j];
                if(t_b!=t[j]) cnt+=10;
            }
            else if(k==3){
                t_c+=t[j];
                if(t_c!=t[j]) cnt+=10;
            }
            tmp >>= 2;
        }
        if(t_a==0 or t_b==0 or t_c==0) continue;
        tmp = std::abs(a-t_a)+std::abs(b-t_b)+std::abs(c-t_c)+cnt;
        if(ans>tmp) ans=tmp;
    }
    cout << ans;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect


def LI(): return [int(x) for x in sys.stdin.readline().split()]


def I(): return int(sys.stdin.readline())


def LS(): return [list(x) for x in sys.stdin.readline().split()]


def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


sys.setrecursionlimit(1000000)
mod = 1000000007


def solve():
    a, b, c = LI()
    if a == b == c:
        print('No')
    elif a == b:
        print('Yes')
    elif a == c:
        print('Yes')
    elif b == c:
        print('Yes')
    else:
        print('No')


# Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N = 0;

typedef long long int ll;

using namespace std;

ll recurse(ll a, ll b, bool first){
    bool posible = true;
    ll ans = 1;
    while(a != 1 || b != 1){
        //cout<<a<<" "<<b<<" "<<ans<<" \n";
        if(first){
            ans *= a%MOD;
            ans %= MOD;
            a--;
        }else{
            ans *= b%MOD;
            ans %= MOD;
            b--;
        }
        first = !first;
    }
    return ans;
}

int main(){
    ll a,b;cin>>a>>b;
    ll temp = a;
    a = max(a,b);
    b = min(temp,b);
    if(a-b == 0){
        ll sol1 = recurse(a,b,true)%MOD;
        sol1 = (sol1*2)%MOD;
        cout<<sol1;
    }else if(a-b == 1){
        ll sol1 = recurse(a,b,true)%MOD;
        cout<<sol1;
    }else{
        cout<<0;
    }

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <stdint.h>

using namespace std;

int64_t combination(int64_t n, int64_t r) {
  if (n == 1) {
    return 0;
  }
  if ( r * 2 > n ) r = n - r;
  int64_t dividend = 1;
  int64_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main() {
  int64_t N;
  string S;
  cin >> N;
  
  string strs[N];
  
  for (int64_t i=0; i<N; i++) {
    cin >> S;
    sort(S.begin(), S.end());
    strs[i] = S;
  }
  
  sort(strs, strs+N);
  
  int64_t head=0;
  vector<int64_t> same_string;
  while (head < N) {
    int64_t length=0;
    while (strs[head] == strs[head+length]) {
      length += 1;
      if (head+length == N) {
        break;
      }
    }
    same_string.push_back(length);
    head = head+length;
  }
    
  int64_t answer = 0;
  for (vector<int64_t>::iterator itr = same_string.begin(); itr != same_string.end(); ++itr) {
    answer += combination(*itr, 2);
  }
  cout << answer;
}


Measured memory_bytes: 6904
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	int m,d;
	int i,j,k;
	int a,b,c;
	int s=0;
	cin>>m>>d;
	for(i=2;i<=d;i++){
		a=i/10,b=i%10;
		if(a<2 || b<2)continue;
		if(a*b<=m)s++;
	}
	cout<<s<<endl;
}


Measured memory_bytes: 764
s = input()
even = ['R', 'U', 'D']
odd = ['L', 'U', 'D']

for i, j in enumerate(s):
    if i % 2 == 0:
        if j not in even:
            print('No')
            break
    else:
        if j not in odd:
            print('No')
            break
else:
    print('Yes')

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(void)

{
    int i, a, b, c;
    string s, s1;
    cin>>s;
    a = s.size();
    i = 0;
    b = a-1;
    int flag = 0;
    while(i < b){
        if(s[i] != s[b]){
            flag = 1;
            break;
        }
        i++;
        b--;
    }
    if(flag == 1){
        cout<<"No\n";
    }
    else{
    a = (s.size()-1)/2;
    for(int j = 0; j < a; j++)
        s1 += s[j];
    i = 0;
    b = s1.size()-1;
    int flag = 0;
    while(i < b){
        if(s1[i] != s1[b]){
            flag = 1;
            break;
        }
        i++;
        b--;
    }
    if(flag == 1){
        cout<<"No\n";
    }
    else{
        //a = ;
        s1.clear();
        for(int j = ((s.size()+3)/2)-1; j < s.size(); j++)
            s1 += s[j];
        i = 0;
    b = s1.size()-1;
    int flag = 0;
    while(i < b){
        if(s1[i] != s1[b]){
            flag = 1;
            break;
        }
        i++;
        b--;
    }
    if(flag == 1)cout<<"No\n";
    else cout<<"Yes\n";
    }
    }
    return 0;
}

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

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String readStr;
    int c = 0;
    while ((readStr = reader.readLine()) != null) {
      int[] list = new int[3];
      list[0] = Integer.parseInt(readStr.split(" ")[0]);
      list[1] = Integer.parseInt(readStr.split(" ")[1]);
      list[2] = Integer.parseInt(readStr.split(" ")[2]);
      for (int i = list[0]; i <= list[1]; i++) {
        if (list[2] % i == 0) c++;
      }
      System.out.println(c);
      break;
    }
  }

}

Measured memory_bytes: 17092
n = int(input())

def make_divisor(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n%i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

vals = make_divisor(n)
result = n - 1
for val in vals:
    if val == 1 or val == n:
        continue
    result = min(result, int(n/val)+val - 2)

print(result)


Measured memory_bytes: 3268
#include <iostream>
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  
  int tapNum = 0;
  int socket = 1;
  while (socket < b) {
    socket += a - 1;
    tapNum++;
  }
  cout << tapNum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);
   long long int n;
   cin>>n;
   set <long long int> s;
   long long int m=n;
   for (long long int i=1;i*i<=n;i++)
   {
      if (n%i==0)
      {
         s.insert(i);
         s.insert(n/i);
      }
   }
   s.erase(s.begin());
   long long int ans=0;
   for (auto x: s)
   {
      m=n;
      while (m%x==0)
      {
         m/=x;
      }
      if (m%x==1)
         ans++;
   }

   s.clear();
   for (long long int i=1;i*i<=n-1;i++)
   {
      if ((n-1)%i==0)
      {
         s.insert(i);
         s.insert((n-1)/i);
      }
   }
   ans+=s.size();
   cout<<ans-1;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
using namespace std;

int main(){
    int n ;
    cin >> n ;
    vector<int> a(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> a.at(i) ;
    }
    int p = round( accumulate(a.begin(),a.end(),0) *1.0 / a.size() ) ;
    int ans = 0 ;
    for (size_t i = 0; i < n; i++)
    {
        ans += (a.at(i) - p)*(a.at(i) -p) ;
    }
    
    cout << ans << endl ;
}    

Measured memory_bytes: 384
"""
AtCoder :: Beginner Contest 172 :: A :: Calc
https://atcoder.jp/contests/abc172/tasks/abc172_a
"""
import sys


def solve(a):
    """
    Solve puzzle.
    Return a + a^2 + a^3
    """
    return a + pow(a, 2) + pow(a, 3)


def main():
    """Main program."""
    a = int(sys.stdin.readline())
    print(solve(a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 9172