akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long
#define TIME cout << "Time elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms" << endl;


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
    int x;
    cin >> x;

    cout << (x < 1200 ? "ABC" : "ARC") << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin>>n;
    for(int i = n; i<1000; i++)
        if(i%10 == i/10%10 && i%10 == i/100%10){
            cout<<i;
            break;
        }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int d[105][6];

void N(int a)
{
  int tmp=d[a][0];
  d[a][0]=d[a][1];
  d[a][1]=d[a][5];
  d[a][5]=d[a][4];
  d[a][4]=tmp;
}
void E(int a)
{
  int tmp=d[a][0];
  d[a][0]=d[a][3];
  d[a][3]=d[a][5];
  d[a][5]=d[a][2];
  d[a][2]=tmp;
}
void S(int a)
{
  int tmp=d[a][0];
  d[a][0]=d[a][4];
  d[a][4]=d[a][5];
  d[a][5]=d[a][1];
  d[a][1]=tmp;
}
void W(int a)
{
  int tmp=d[a][0];
  d[a][0]=d[a][2];
  d[a][2]=d[a][5];
  d[a][5]=d[a][3];
  d[a][3]=tmp;
}
void T(int a)
{
  int tmp=d[a][1];
  d[a][1]=d[a][2];
  d[a][2]=d[a][4];
  d[a][4]=d[a][3];
  d[a][3]=tmp;
}

bool C(int a,int b)
{
  bool ans=0;
  for (int i = 0; i < 4; ++i)
  {
    bool f=1;
    for (int j = 0; j < 6; ++j) if(d[a][j]!=d[b][j]) f=0;
    if(f) ans=1;
    T(a);
  }
  return ans;
}

int main(){
  bool ans=1;
  int n;
  cin>>n;
  for (int j = 0; j < n; ++j) for (int i = 0; i < 6; ++i) cin>>d[j][i];
  for (int i = 0; i < n-1; ++i)
  {
    for (int j = i+1; j < n; ++j)
      {
      bool f=C(i,j);
      if(!f) N(i),f=C(i,j);
      if(!f) S(i),S(i),f=C(i,j);
      if(!f)
      {
        N(i);
        for (int k = 0; k < 4; ++k) 
        {
          E(i);
          f=C(i,j);
          if(f) break;
        }
      }
      if(f)
      {
        ans=0;
        break;
      }
    }
  }
  cout<<(ans?"Yes\n":"No\n");
}


Measured memory_bytes: 3104
from math import gcd
N = int(input())
A = list(map(int,input().split()))

front = [0] * N
front[0] = A[0]
for i in range(1,N):
    front[i] = gcd(front[i-1],A[i])
back = [0] * N
back[-1] = A[-1]
for i in reversed(range(N-1)):
    back[i] = gcd(back[i+1],A[i])

ans = max(front[-2],back[1])
for i in range(N-2):
    ans = max(ans,gcd(front[i],back[i+2]))
print(ans) 


Measured memory_bytes: 85648
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;
int s;

int main() {
   cin >> s;
   map<int, int> log;
   int tmp = s;
   log[tmp]++;
   for (int i = 2; i <= 1e7; i++) {
      int nxt;
      if (tmp % 2 == 0) nxt = tmp / 2;
      else nxt = tmp * 3 + 1;
      if (log[nxt] != 0) {
         cout << i << endl;
         return 0;
      }
      log[nxt]++;
      tmp = nxt;
   }
   return 0;
}


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

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

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int N;
	while(cin >> N, N) {
		vs name(N);
		vi P(N), A(N), B(N), C(N), D(N), E(N), F(N), S(N), M(N);
		vi time(N), value(N);

		REP(i, N) {
			cin >> name[i] >> P[i] >> A[i] >> B[i] >> C[i] >> D[i] >> E[i] >> F[i] >> S[i] >> M[i];
			time[i] = ((A[i] + B[i] + C[i]) + (D[i] + E[i]) * M[i]);
			value[i] = F[i] * S[i] *M[i] - P[i];
		}

		REP(i, N-1) {
			for(int j = N-1; j > i; j--) {
				if(value[j]*time[j-1] > value[j-1]*time[j]) {
					swap(value[j], value[j-1]);
					swap(time[j], time[j-1]);
					swap(name[j], name[j-1]);
				} else if(value[j]*time[j-1] == value[j-1]*time[j] && name[j] < name[j-1]) {
					swap(value[j], value[j-1]);
					swap(time[j], time[j-1]);
					swap(name[j], name[j-1]);
				}
			}
		}

		REP(i, N) {
			cout << name[i] << endl;
		}
		cout << "#" << endl;
	}

	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll N;
vector<ll> A;
int main() {
    cin >> N;
    A.resize(N);
    rep(i, N) cin >> A[i];
    sort(A.begin(), A.end());

    ll current = A[0];
    ll idx = 0;

    while (true) {
        bool amari = false;
        ll tmp_ans = current; 
        // cout << "idx: " << idx << " current: " << current << endl;
        for (int i = 0; i < N; i++) {
            // if (idx == i) {
            //     cout << "hoge" << endl;
            //     continue;
            // }
            if (A[i] == current) continue;
            A[i] = A[i] % current;

            if (A[i] > 0 && A[i] < tmp_ans) {
                tmp_ans = A[i];
                amari = true;
                idx = i;
            } 
        }
        // cout << endl;
        current = tmp_ans;

        // rep(j, N) cout << A[j] << " ";
        // cout << endl;

        if (amari == false) {
            cout << current << endl;
            return 0;
        } 
    }

}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <utility>
#include <cstdlib>
#include <cmath>
#define INF 987654321
#define INT_MAX 2147483647
#define MIN(a, b) ((a) < (b) ? a : b)
#define MAX(a, b) ((a) > (b) ? a : b)
 
using namespace std;
 
 

int main() {
    int N;
    cin >> N;

    vector<int> L(N);
    for(int i = 0; i < N; i++) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());

    int cnt = 0;
    for(int i = 0; i < N; i++)
        for(int j = i+1; j < N; j++)
            for(int k = j+1; k < N; k++) {
                if(L[i] + L[j] > L[k] && (L[i] != L[j]) && (L[j] != L[k])) cnt++;
            }
    cout << cnt;
}

Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define ts cout<<"ok"<<endl
#define int long long
#define hh puts("")
#define pc putchar
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
using namespace std;
const int N=100005;
int n,m,k,p,ans,a[N],r[N],sum[N];
inline int read(){
    int ret=0,ff=1;char ch=getchar();
    while(!isdigit(ch)){if(ch=='-') ff=-1;ch=getchar();}
    while(isdigit(ch)){ret=ret*10+(ch^48);ch=getchar();}
    return ret*ff;
}
void write(int x){if(x<0){x=-x,pc('-');}if(x>9) write(x/10);pc(x%10+48);}
void writeln(int x){write(x),hh;}
void writesp(int x){write(x),pc(' ');}
//m´Î¿Ï¶¨È«ÓÃÔÚiÉÏ,a[i]±ä³Éa[i]+m
//×î¶àÓÐp-1¸ö´óÓÚa[i]+m  
//k¸öÊý,ÏÈÈ«·ÖÅä¸ø ´óÓÚa[i]+mµÄ ºÍ Ð¡ÓÚµÈÓÚa[i]µÄ
//Éè»¹Ê£x¸ö¿ÉÒÔ·ÖÅä 
bool cmp(int x,int y){
	return x>y;
}
signed main(){
	n=read(),m=read(),k=read(),p=read();
	for(int i=1;i<=n;i++) a[i]=read();
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+a[i];
	r[n]=n;
	for(int i=n-1;i>=1;i--){
		if(a[i]==a[i+1]) r[i]=r[i+1];
		else r[i]=i;
	}
	int pos=p;
	while(pos+1<=n&&a[pos+1]==a[p]) pos++;
	ans=pos;
	for(int i=pos+1;i<=n;i++){
		if(a[i]+m>=a[p]){
			int cnt=k-(n-i+1)-(p-1);
			if(cnt<=0){
				ans=r[i];
				i=r[i];
			}
			else{
				if((a[i]+m)*(i-p)-(sum[i-1]-sum[p-1])>=cnt*m){
					ans=r[i];
					i=r[i];
				}
				else break;
			}
		}
		else break;
	}
	writeln(ans);
    return 0;
}

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

using namespace std;
int n,k,x,ans;
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
    {
        scanf("%d",&x);
        if(x>=k)
            ans++;
    }
    printf("%d",ans);
    return 0;
}


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  string s;
  cin >> s;
  for(int i = s.length() - 2; i >= 0; i -= 2)
  {
    string sub = s.substr(0, i);
    bool ok = true;
    for(int j = 0; j < i / 2; ++j)
    {
      ok &= sub[j] == sub[i / 2 + j];
    }
    if(ok)
    {
      cout << i;
      return;
    }
  }
}

int main()
{
  fastio;
  solve();

  return 0;
}

Measured memory_bytes: 3572
data = [[[0 for _ in range(10)] for _ in range(3)] for _ in range(4)]
n = int(input())
for i in range(n):
    b, f, r, v = map(int, input().split())
    data[b - 1][f - 1][r - 1] += v
for index, tower in enumerate(data):
    for floor in tower:
        print(' ' + ' '.join(map(str, floor)))
    if index != 3:
        print('####################')


Measured memory_bytes: 5608
#include<bits/stdc++.h>
using namespace std;
int main ()
{
    int n;cin >> n;
    long long int A[n+10],B[n+19];
    for(int i=1;i<=n+1;i++)cin>>A[i];
    for(int i=1;i<=n;i++)cin>>B[i];
    long long int res=0;
    for(int i=1;i<=n;i++)
    {
        long long int curr = B[i];
        if(curr<=A[i]){
            res+=curr;
            //continue;
        }
        else{
                curr-=A[i];
                res+=A[i];
                if(curr<=A[i+1]){
                    res+=curr;
                    A[i+1]-=curr;
                }
                else{
                    res+=A[i+1];
                    A[i+1]=0;
                }
        }
    }
    cout<<res;
    //main();
    return 0;
}


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

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int  ll;
typedef unsigned long long int llu;

int main(void)
{

    int h,w;
    cin >> h >> w;
    int N;
    cin >> N;

    int ans1 =0,ans2 = 0;
    for(int i=1;i<=h;i++)
    {
        int x = h*i;

        if(x>=N){
            ans1 = i;
            break;
        }
    }

    for(int i=1;i<=w;i++)
    {
        int x = w*i;

        if(x>=N){
            ans2 = i;
            break;
        }
    }

    if(ans1==0)
        cout << ans2 << endl;
    else if(ans2==0)
        cout << ans1 << endl;
    else
    cout << min(ans1,ans2) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  cin>>n;
  std::vector<int> p(n);
  std::vector<int> sorted(n);
  for(int i=0;i<n;i++){
    cin>>p[i];
    sorted[i]=p[i];
  }
  std::sort(sorted.begin(), sorted.end());
  int count=0;
  for(int i=0;i<n;i++){
    if(p[i]!=sorted[i]){
      count++;
    }
  }
  if(count==2||count==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

  return 0;
}


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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end

int n,a[20][20];
ll dp[100010]={}; bool used[100010]={};
ll rec(int mask){
    if(used[mask])return dp[mask];
    used[mask]=1;
    ll res=0;
    rep(i,0,n)rep(j,i+1,n)if((mask>>i&1)&&(mask>>j&1))res+=a[i][j];
    for(int sub=mask;sub;sub=(sub-1)&mask){
        if(sub==mask)continue;
        chmax(res,rec(sub)+rec(mask^sub));
    }
    return dp[mask]=res;
}

int main(){
    scanf("%d",&n);
    rep(i,0,n)rep(j,0,n)scanf("%d",&a[i][j]);
    printf("%lld\n",rec((1<<n)-1));
    return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
using namespace std;

const int N=300010;
int n,m,a[N],r[N],mx[N];

int main(){
	scanf("%d",&m); int n=1<<m;
	for (int i=0; i<n; i++) scanf("%d",&a[i]);
	for (int i=0; i<n; i++)
		for (int j=i; j<n; j=(j+1)|i)
			r[j]=max(r[j],a[i]+mx[j]),mx[j]=max(mx[j],a[i]);
	for (int i=1; i<n; i++) printf("%d\n",r[i]=max(r[i],r[i-1]));
	return 0;
}

Measured memory_bytes: 6016
#[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)*}
    };
}

#[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, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}


fn f(s: &Vec<i32>) -> bool{

    


    return true;
}

use std::iter::Iterator;
use std::cmp;


fn main() {
    input! {
        n : usize,
        p : [usize;n]
    }

    let mut cnt = 0;

    for (i ,val) in p.iter().enumerate() {
        if (i + 1) != *val {
            cnt = cnt + 1;
        }
    }

    if cnt == 2 || cnt == 0 {
        println!("YES");
    } else{
        println!("NO")
    }

}


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

int main(){
  int N,K;
  cin>>N>>K;
  vector<int64_t> H(N);
  for(int i=0;i<N;++i){
    cin>>H[i];
  }
  sort(H.begin(),H.end(),greater<int64_t>());

  int64_t cnt=0;
    for(int i=K;i<N;++i){
      cnt += H[i];
    }
    cout<<cnt<<endl;

}

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

int main()
{
int i;
int iSum;
int iMin;
int N;
int s;

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

	cin >> N;

	iSum = 0;
	iMin = 0;
	for( i = 0; i < N; i++ )
	{
		cin >> s;

		iSum += s;
		if( s % 10 != 0 )
		{
			if( iMin == 0 || iMin > s ) iMin = s;
		}
	}

	if( iSum % 10 != 0 )
		cout << iSum << endl;
	else
	{
		if( iMin > 0 )
			cout << iSum - iMin << endl;
		else
			cout << 0 << endl;
	}

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  ios::sync_with_stdio(0);
  int n;
  cin>>n;
  string s;
  cin>>s;
  for(int i=0;i<s.size();i++)
  {
    int sum=(int)(s[i]-'A')+n;
    if (sum>=26)
      sum-=26;
    cout<<(char)(sum+'A');
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
using namespace std;
int main(){
	int h,w;
	char a[100][100];
	int d[100][100];
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	d[0][0]=0;
	for(int i=1;i<w;i++){
		if(a[0][i]!=a[0][i-1]){
			d[0][i]=d[0][i-1]+1;
		}else{
			d[0][i]=d[0][i-1];
		}
	}
	for(int i=1;i<h;i++){
		if(a[i][0]!=a[i-1][0]){
			d[i][0]=d[i-1][0]+1;
		}else{
			d[i][0]=d[i-1][0];
		}
	}
	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(a[i][j]!=a[i-1][j]){
				d[i][j]=d[i-1][j]+1;
			}else{
				d[i][j]=d[i-1][j];
			}
			if(a[i][j]!=a[i][j-1]){
				d[i][j]=min(d[i][j],d[i][j-1]+1);
			}else{
				d[i][j]=min(d[i][j],d[i][j-1]);
			}
		}
	}
	int ans=d[h-1][w-1];
	if(ans==0){
		if(a[0][0]=='.'){
			cout<<0<<endl;
		}else{
			cout<<1<<endl;
		}
	}else{
		if(a[0][0]=='.'&&a[h-1][w-1]=='.'){
			cout<<ans/2<<endl;
		}else if(a[0][0]=='#'&&a[h-1][w-1]=='#'){
			cout<<ans/2+1<<endl;
		}else{
			cout<<(ans-1)/2+1<<endl;
		}
	}
	return 0;
}

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

using namespace std;
long long v=0,i,n,f=0,x,a[100007],b[100007];
int fync(int a,int b)
{
  while (a!=0 && b!=0) {
        if (a>b) {
            a=a%b;
        }
        else b=b%a;
    }
    return a+b;
}
int main()
{
    cin>>n>>x;
    for(i=1; i<=n; i++)cin>>a[i];
    for(i=1;i<=n;i++)b[i]=abs(x-a[i]);
    //v=fync(15,25);
   // cout<<v<<' '<<b[1]<<' '<<b[2]<<endl;
    v=(fync(b[1],b[2]));
   // cout<<v<<endl;
    for(i=2; i<=n; i++)v=fync(v,b[i]);
cout<<v<<endl;
    return 0;
}


Measured memory_bytes: 1792
fun main(args: Array<String>) {
    abc120b()
}

fun abc120b() {
    val (a, b, k) = readLine()!!.split(" ").map { it.toInt() }

    var count = k
    for (i in 100 downTo 1) {
        if (a % i == 0 && b % i == 0) count--

        if (count == 0) {
            println(i)
            return
        }
    }
}


Measured memory_bytes: 37872
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,max;
  max=1;
  string a;
  map<string,int> s;
  cin >> n;
  for(int i=0;i<n;i++) {
    cin >> a;
    if (s.count(a)){
      s[a]++;
      if(max<s[a]) max++;
    } else {
      s[a]=1;
    };
  };
  for(auto it = s.begin();it!=s.end();it++){
    if(max==it->second) cout << it->first << endl;
  };
}

Measured memory_bytes: 25216
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define lamsort(v,p) sort(v.begin(),v.end(),[](p a, p b){return a.num < b.num;});
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
const long long LLINF = 1LL<<60;
const int INF = 1e9;
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; }
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h,w; cin >> h >> w;
    string ans;
    rep(i,h) {
        rep(j,w) {
            string s; cin >> s;
            if(s=="snuke") {
                cout << (char)('A'+j) << i+1 << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
s = list(input())
t = list(reversed(s))
ans1 = 0
for i in range(len(s)-1):
  if s[i]==s[i+1]=="0":
    s[i+1] ="1"
    ans1+=1
  elif s[i]==s[i+1]=="1":
    s[i+1] ="0"
    ans1+=1
ans2 = 0
for i in range(len(t)-1):
  if t[i]==t[i+1]=="0":
    t[i+1] ="1"
    ans2+=1
  elif t[i]==t[i+1]=="1":
    t[i+1] ="0"
    ans2+=1
print(min(ans1, ans2))


Measured memory_bytes: 4776
#include <stdio.h>

double absd(double a){
  if(a>0){
    return a;
  }
  return -a;
}

int main(){
  int N,A,T;
  scanf("%d%d%d",&N,&T,&A);
  int H[N];
  int i;
  for(i=0;i<N;i++){
    scanf("%d",&H[i]);
  }
  double X[N];
  for(i=0;i<N;i++){
    X[i]=absd(T-A-0.006*H[i]);
  }
  int ans=0;
  double preans=X[0];
  for(i=1;i<N;i++){
    if(preans>X[i]){
      ans=i;
      preans=X[i]
	;
    }
  }
  printf("%d",ans+1);
  return 0;
}


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

int main() {
  int n, a, b;
  cin >> n >> a >> b;
  
  string s;
  cin >> s;
  
  int tuka = 0, tukb = 0;
  
  for (int i = 0; i < n; i++) {
    if (s.at(i) == 'a') {
      if (tuka < a + b) {
        tuka++;
        cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
    }
    else if (s.at(i) == 'b') {
      if (tuka < a + b && tukb < b) {
        tuka++;
        tukb++;
        cout << "Yes" << endl;
      }
      else {
        cout << "No" << endl;
      }
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 896
{-# OPTIONS_GHC -Wall #-}

import Control.Monad
import Data.Array

readInt :: String -> Int
readInt = read

calcDp :: Int -> Int -> Array Int Int -> Array Int Int -> Array (Int,Int) Int
calcDp n wmax vs ws = dp
    where
        -- i種類目までで容量jで実現できる最大価値
        dp = listArray ((0,0),(n,wmax)) [f i j | i<-[0..n], j<-[0..wmax]]
        f _ 0 = 0
        f 0 _ = 0
        f i j
            | j >= w    = max (v+dp!(i-1,j-w)) (dp!(i-1,j))
            | otherwise = dp!(i-1,j)
            where
                v = vs!(i-1)
                w = ws!(i-1)

main :: IO ()
main = do
    [n,wmax] <- fmap (map readInt . words) getLine
    vws      <- replicateM n $ do
        [v,w] <- fmap (map readInt . words) getLine
        return (v,w)
    let vs = listArray (0,n-1) $ map fst vws
    let ws = listArray (0,n-1) $ map snd vws

    let dp  = calcDp n wmax vs ws
    let ans = dp!(n,wmax)

    --print $ dp
    print $ ans



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

int main(){
    int a;
    cin >> a;
    int ans;
    ans = a + a*a + a*a*a;
    cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, x;
while(1){
 cin >> n >> x;
int neruchin = 0;
if ( n == 0 && x == 0 ) break;
for( int i = 1; i <= n-2; i++ ){
 for( int j = i+1; j <= n-1; j++ ){
  for( int k = j+1; k <= n; k++ ){
   if ( i+j+k == x ) neruchin++;
}
}
}
cout << neruchin << endl;
}
return 0;
}

Measured memory_bytes: 3120
# define _CRT_SECURE_NO_WARNINGS 1
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;

# define INF ((int)(1<<30))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12

template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,-1,1,0 }, dy[4] = { 1,0,0,-1 };

int clamp(int a, int mi, int ma)
{
	return max(mi, min(a, ma));
}
bool isnum(char a)
{
	return ('0' <= a&&a <= '9');
}
string big(string a, string b)
{
	if (a.size() > b.size())
	{
		return a;
	}
	if (a.size() < b.size())
	{
		return b;
	}
	return max(a, b);
}


char a[100][100]; 
string flag[100][100];
string ans;
void hoge(string &s, int y, int x)
{
	flag[y][x] = big(s + flag[y][x + 1], s + flag[y + 1][x]);
	if(s!="0")ans = big(ans, flag[y][x]);
	return;
}



int main()
{
	int w, h;
	while (cin >> w >> h&&w)
	{
		
		REP(i, 100)REP(j, 100)
		{
			a[i][j] = 'a';
			flag[i][j] = "";
		}
		ans = "";
		REP(i, h)
		{
			REP(j, w)
			{
				cin >> a[i][j];
			}
		}
		
		for (int y = h - 1; y >= 0;y--)
		{
			for (int x = w - 1; x >= 0;x--)
			{
				if (isnum(a[y][x]))
				{
					string str; str += a[y][x];
					hoge(str, y, x);
				}
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3140
#include<bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define fi first
#define se second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
#define loop(i, a, b) for(lli i=a; i<b; i++)
#define loopb(i, a, b) for(lli i=a; i>=b; i--)
#define pb push_back
#define umap unordered_map
typedef long long int lli;
typedef pair<lli, lli> pii;
typedef vector<lli> vll;
typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// use to avoid collision
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// for pair in unordered_map
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
lli M = 1e9 + 7;
lli power(lli x, lli y){
    lli res = 1;
    x = x%M;
    while (y > 0) {
        if (y & 1)
            res = (res*x)%M ;
        y = y>>1;
        x = (x*x)%M;
    }
    return res%M;
}
vector<vll> matrix(vector<vll>& A, vector<vll>& B){
	lli n = A.size();
	vector<vll> res(n, vll(n));
	loop(i, 0, n){
		loop(j, 0, n){
			lli sum = 0;
			loop(k, 0, n){
				sum = (sum + (A[i][k] * B[k][j])%M)%M;
			}
			res[i][j] = sum%M;
//			cout<<sum<<" ";
		}
//		cout<<"\n";
	}
//	cout<<"\n";
	return res;
}
lli solve(){
	lli n, k;
	cin>>n>>k;
	vector<vll> A(n, vll(n));
	loop(i, 0, n)
		loop(j, 0, n)	cin>>A[i][j];
	vector<vll> res(n, vll(n, 0));
	loop(i, 0, n){
		loop(j, 0, n) if(i == j)	res[i][j] = 1;
	}
//	cout<<"\n";
	while(k > 0){
		if(k%2 == 1)
			res = matrix(A, res);
		k = k/2;
		A = matrix(A, A);
	}
	lli sum = 0;
	loop(i, 0, n)
		loop(j, 0, n)	sum = (sum + res[i][j])%M;
	cout<<sum<<"\n";
	return 0;
}
int main(){
	fastio;
	lli t;
//	cin>>t;
	t = 1;
	while(t>0){
		t--;
		solve();
	}
}

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

int main() {
  int N, M; cin >> N >> M;
  const int INF = 1000000007;
  vector<vector<int>> G(N, vector<int>(N, INF));
  for (int i = 0; i < N; i++) G.at(i).at(i) = 0;
  vector<int> A(M), B(M), C(M);
  for (int i = 0; i < M; i++) {
    int a, b, c; cin >> a >> b >> c;
    a--; b--;
    G.at(a).at(b) = c;
    G.at(b).at(a) = c;
    A.at(i) = a;
    B.at(i) = b;
    C.at(i) = c;
  }
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        G.at(i).at(j) = min(G.at(i).at(j), G.at(i).at(k) + G.at(k).at(j));
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < M; i++) {
    bool ok = true;
    for (int s = 0; s < N; s++) {
      for (int t = 0; t < N; t++) {
        if (s == t) continue;
        if (G.at(s).at(t) == G.at(s).at(A.at(i)) + C.at(i) + G.at(B.at(i)).at(t)) {
          ok = false;
        }
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main(){
  int n;
  cin >> n;
  vector<int> c(n);
  for(int i=0;i<n;i++) cin >> c[i];
  c.erase(unique(c.begin(), c.end()), c.end());
  int C=*max_element(c.begin(),c.end());
  n=c.size();
  vector<ll> dp(n+1,0);
  dp[0]=1;
  vector<int> sm(C+1,0);
  for(int i=0;i<n;i++){
    dp[i+1]=(dp[i]+sm[c[i]])%MOD;
    sm[c[i]]+=dp[i];
    sm[c[i]]%=MOD;
  }
  cout << dp[n] << endl;
}

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

double dp[310][310][310];
int n, a[4], done[310][310][310];

double func(int i, int j, int k)
{
    if (i+j+k==0) return 0;

    auto& res=dp[i][j][k];
    if (done[i][j][k]++) return res;

    res=n/double(i+j+k);
    if (i) res+=func(i-1, j, k)*i/(i+j+k);
    if (j) res+=func(i+1, j-1, k)*j/(i+j+k);
    if (k) res+=func(i, j+1, k-1)*k/(i+j+k);
    return res;
}

int main()
{
    cin>>n;
    for(int i=0; i<n; ++i) {
        int t; cin>>t;
        ++a[t];
    }
    printf("%.9f\n", func(a[1], a[2], a[3]));
}


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

class Program
{

    static void Main()
    {
        var sc = new Scanner();
        int n = sc.Int();
        int k = sc.Int();
        int x = sc.Int();
        int y = sc.Int();
        if (n<=k)
        {
            Console.WriteLine(n*x);
        }
        else
        {
            Console.WriteLine(k*x+(n-k)*y);
        }
    }
}
static class Extentions
{
    public static IEnumerable<T> Outpuut<T>(this IEnumerable<T> source)
    {
        foreach (var item in source)
        {
            Console.WriteLine(item);
        }
        return source;
    }
    public static T Print<T>(this T obj)
    {
        Console.WriteLine(obj);
        return obj;
    }
}
public class Scanner
{
    public Scanner()
    {
        byte[] inputBuffer = new byte[1024];
        System.IO.Stream inputStream = Console.OpenStandardInput(inputBuffer.Length);
        Console.SetIn(new System.IO.StreamReader(inputStream, Console.InputEncoding, false, inputBuffer.Length));
    }
    string[] buffer = new string[0];
    int index = 0;
    public char[] SplitChars { get; set; }
    public string String()
    {
        if (index < buffer.Length) return buffer[index++];
        string line = "";
        while (line == "") line = Console.ReadLine();
        if (line == null) return null;
        buffer = line.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries);
        index = 0;
        return buffer[index++];
    }
    public string[] StringArray(int count) { return NextArray(count, x => x); }
    public void Skip(int count) { for (int i = 0; i < count; i++) String(); }
    public T Next<T>(Func<string, T> parser) { return parser(String()); }
    public T[] NextArray<T>(int count, Func<string, T> parser)
    {
        var arr = new T[count];
        for (int i = 0; i < count; i++) arr[i] = Next(parser);
        return arr;
    }
    public int Int() { return Next(int.Parse); }
    public int[] IntArray(int count) { return NextArray(count, int.Parse); }
    public double Double() { return Next(double.Parse); }
    public double[] DoubleArray(int count) { return NextArray(count, double.Parse); }
}


Measured memory_bytes: 2648
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
typedef long long ll;

ll gcd(ll x, ll y){
	if(y == 0){
		return x;
	}
	x %= y;
	return gcd(y, x);
}

int main(){
	int T;
	cin >> T;
	ll A[T], B[T], C[T], D[T];
	for(int i=0; i<T; i++){
		cin >> A[i] >> B[i] >> C[i] >> D[i];
	}
	for(int i=0; i<T; i++){
		if(A[i] < B[i] || B[i] > D[i]){
			cout << "No" << endl;
			continue;
		}
		ll b = B[i] - 1 - ((B[i] - 1 - (A[i] % B[i]))%gcd(B[i], D[i]));
		if(b > C[i]){
			cout << "No" << endl;
		}else{
			cout << "Yes" << endl;
		}
	}
	return 0;
}

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

int dx8[9] = { -1,-1,-1, 0, 1, 1, 1, 0 ,0};
int dy8[9] = { -1, 0, 1, 1, 1, 0,-1,-1,0 };
int main() {
	int N, T, E; cin >> N >> T >> E;
	int ans = -1;
	for (int aa = 0; aa < N;++aa) {
		int a; cin >> a;
		for (int i = 0; i < 10000; ++i) {
			if (a*i >= T - E&&a*i <= T + E)ans = aa+1;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main()
{
    long long n,i,a[150000],b,c,q,j,total=0,d[150000]={0},x,p,r;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        total=total+a[i];
        x=a[i];
        d[x]=d[x]+x;
    }
    cin>>q;
    for(j=1;j<=q;j++)
    {
        cin>>b>>c;
        p=d[b]/b;
        r=p*c;
        total=total-d[b];
        d[b]=0;
        d[c]=d[c]+r;
        total=total+r;
        cout<<total<<endl;
    }
    return 0;
}

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

vector<vector<int>>to(200001);
vector<bool>seen(200001,false);
vector<int>ans;

void dfs(int v,int p){
  for(int u : to[v]){
    if(u != p){
      ans[u] += ans[v];
      dfs(u,v);
    }
  }
}
      
int main() {
  int n,q;
  cin >> n >> q;
  ans.resize(n);
  for(int i = 0;i < n-1;i++){
    int a,b;
    cin >> a >> b;
    a--;b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  seen[0] = true;
  for(int i = 0;i < q;i++){
    int p,x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0,-1);
  for(int i = 0;i < n;i++){
    cout << ans[i];
    if(i != n-1) cout << " ";
    else cout << "" << endl;
  }
}


Measured memory_bytes: 23552
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define MOD 1000000007


ll n, a, b, aa = 0, bb = 0;
int main(){
	cin >> n >> a >> b;
	REP(i, n - 1) {
		aa += a;
		bb += b;
	}aa += b;
	bb += a;
	cout << max(bb - aa + 1, 0ll) << endl;
}



Measured memory_bytes: 256
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
#![macro_use]

use std::cmp::*;
use std::collections::*;
use std::io::*;
use std::mem::*;
use std::num::*;
use std::slice::*;

fn main() {
    let (r, w, e) = (stdin(), stdout(), stderr());
    let mut io = IO::new(r.lock(), w.lock(), e.lock());
    // =============================================== //
    let (N, M) = (io.read::<usize>(), io.read::<usize>());
    let mut key = vec![0usize; M];
    let mut cost = vec![0usize; M];
    for i in 0..M {
        let (mut a, mut b) = (io.read::<usize>(), io.read::<usize>());
        cost[i] = a;
        let mut treasure = 0usize;
        for _ in 0..b {
            let mut n: usize = io.read();
            n -= 1;
            treasure |= 1 << n;
        }
        key[i] = treasure;
    }
    let INF = std::usize::MAX - 1 << 30;

    let mut dp: Vec<Vec<usize>> = vec![vec![INF; 1 << N]; M];
    for i in 0..M {
        dp[i][0] = 0;
    }
    for i in 0..M {
        for j in 0..(1 << N) {
            if i > 0 {
                dp[i][j] = min(dp[i - 1][j], dp[i][j]);
                dp[i][j | key[i]] = min(dp[i][j | key[i]], dp[i - 1][j | key[i]]);
                dp[i][j | key[i]] = min(dp[i][j | key[i]], dp[i - 1][j] + cost[i]);
            } else {
                dp[i][key[i]] = cost[i];
            }
        }
    }
    if dp[M - 1][(1 << N) - 1] == INF {
        io.writeln(-1);
    } else {
        io.writeln(dp[M - 1][(1 << N) - 1]);
    }
    io.debug(dp);
}
// IO
struct IO<R: Read, W: Write, E: Write> {
    Read: R,
    Write: BufWriter<W>,
    Error: BufWriter<E>,
}
impl<R: Read, W: Write, E: Write> IO<R, W, E> {
    fn new(r: R, w: W, e: E) -> IO<R, W, E> {
        IO {
            Read: r,
            Write: BufWriter::new(w),
            Error: BufWriter::new(e),
        }
    }
    fn read<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let next: String = self
            .Read
            .by_ref()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        next.parse().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    fn readn<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect::<Vec<_>>()
    }
    fn readmat<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n).map(|_| self.readn(m)).collect()
    }
    fn write<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
    }
    fn writeln<S: ToString>(&mut self, val: S) {
        self.Write.write(val.to_string().as_bytes());
        self.Write.write(b"\n");
    }
    fn debug<S: std::fmt::Debug>(&mut self, val: S) {
        writeln!(self.Error, "(debug ) {:?}", &val);
    }
    fn debug2<S: std::fmt::Debug>(&mut self, val1: S, val2: S) {
        writeln!(self.Error, "(debug2) {:?} -> {:?}", val1, val2);
    }
}


Measured memory_bytes: 41212
import math
n,k = map(int,input().split())
probability = [0]*(n+1)
for i in range(1,n+1):
    score = i

    if score>k:
        probability[i] = 1/n
        continue
    
    count = math.ceil(math.log(k/i,2))
    probability[i] = 1/n * (1/2)**count

print(sum(probability))


Measured memory_bytes: 6132
#B - Judge status summary

import math
import sys
import itertools
from math import gcd
from math import sqrt
from sys import stdin
def input() : return stdin.readline().rstrip()
def mips():
    return map(int,input().split())
def ii():
    return int(input())
sys.setrecursionlimit(10**9)

N = int(input())
d = dict()
d["AC"] = 0
d["WA"] = 0
d["TLE"] = 0
d["RE"] = 0
for _ in range(N):
    s = input()
    d[s] += 1
for key,val in d.items():
    print(key + ' x ' + str(val))


Measured memory_bytes: 9124
n = int(input())
c = [[0 for i in range(10)] for j in range(10)]

for i in range(n):
    x = str(i + 1)
    c[int(x[0])][int(x[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
       ans += c[i][j] * c[j][i]
print(ans)

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

int n,m;
bool A[10];
int d[10]={0,2,5,5,4,5,6,3,7,6};
int dp[10001];

int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		dp[i]=-1;
	}
	dp[0]=0;
	for(int i=0;i<m;i++){
		int x;
		cin>>x;
		A[x]=true;
		for(int i=d[x];i<=n;i++){
			dp[i]=max(dp[i],dp[i-d[x]]+1);
		}
	}
	while(n>0){
		for(int i=9;i>0;i--){
			if(A[i]){
				if(n>=d[i] and dp[n-d[i]]==dp[n]-1){
					cout<<i;
					n=n-d[i];
					break;
				}
			}
		}
	}
	cout<<endl;
}

Measured memory_bytes: 256
'use strict';
console.log(function(args){
  const N = args.trim()|0;
  for ( let i = 0; i < 10; i++ ) {
    for ( let j = 0; j < 10; j++ ) {
      if ( i*j === N ) return 'Yes';
    }
  }
  return 'No';
}(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 7372
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <math.h>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	sort(a.rbegin(), a.rend());
	int alice = 0;
	int 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 <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> *i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> " " >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin>>n;
    vector<vector<pii>> g(n);
    REP(i,n-1) {
        int a,b,c;
        cin>>a>>b>>c;
        a--,b--;
        g[a].push_back({b,c});
        g[b].push_back({a,c});
    }

    int Q,k;
    cin>>Q>>k;
    k--;
    vector<int> dist(n,INF);
    dist[k]=0;
    priority_queue<pii,vector<pii>,greater<pii>> pq;
    pq.push({k,0});
    while(!pq.empty()) {
        int v=pq.top().first;
        int d=pq.top().second; pq.pop();
        FORE(x,g[v]) {
            if(dist[x.first]>d+x.second) {
                dist[x.first]=d+x.second;
                pq.push({x.first,d+x.second});
            }
        }
    }

    while(Q--) {
        int x,y;
        cin>>x>>y;
        cout<<dist[x-1]+dist[y-1]<<endl;
    }
    return 0;
}


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

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int K; cin >> K;
    string S; cin >> S;
    if (S.size() > K) {
        cout << S.substr(0, K) << "...\n";
    } else {
        cout << S << "\n";
    }
    return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
///const int N = 0;
int a[85+5];




int32_t main()
{
    int i,j,x,y,n;

    a[0]=2;
    a[1]=1;

    for(i=2; i<=86; i++){
        a[i]=a[i-1]+a[i-2];
    }
    cin>>n;
    cout<<a[n]<<endl;

    return 0;
}



Measured memory_bytes: 256
N = int(input())
CSF = []
import math
for i in range(N-1):
    CSF.append(list(map(int,input().split())))
def time(t,i):
    if CSF[i][1] >= t:
        return CSF[i][1]+CSF[i][0]
    else:
        x = math.ceil((t-CSF[i][1])/CSF[i][2])
        return CSF[i][1]+ x*CSF[i][2] + CSF[i][0]

for i in range(N-1):
    t = CSF[i][0]+CSF[i][1]
    for j in range(i+1,N-1):
        t = time(t,j)
    print(t)

print(0)

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

typedef long long ll;

main()
{
    int d, t, s;
    cin >> d >> t >>s;
    if(d <= s*t){
        cout << "Yes";
    }
    else{
        cout << "No";
    }



}





///promy_pompom
//hello world


Measured memory_bytes: 3620
#include <cstdio>
int main()
{

    int count[26] = {};
    char s[1300];
    while (fgets(s, 1300, stdin) != NULL)
    {
        for (int i = 0; s[i] != '\0'; i++)
        {
            if (s[i] >= 'A' && s[i] <= 'Z') //sに文字列が入っているので
            {
                count[s[i] - 'A']++; //ここで数える
            }
            if (s[i] >= 'a' && s[i] <= 'z') //
            {
                count[s[i] - 'a']++;
            }
        }
    }
    for (int i = 0; i < 26; i++)
    {
        printf("%c : %d\n", 'a' + i, count[i]);
    }
    return 0;
}


Measured memory_bytes: 2684
n,m= map(int,input().split())
s = [list(map(int,input().split())) for i in range(m)]
l = 0
r = 10 ** 18
for i in range(m):
    if l < s[i][0]:
        l = s[i][0]
    if s[i][1] < r:
        r = s[i][1]
if r-l < 0:
    print(0)
else:
    print(r-l+1)

Measured memory_bytes: 27336
import math
N=int(input())
Z=[list(map(int, input().split())) for i in range(N)]
A=[[0 for i in range(N)] for j in range(N)]
c=0
def R(a, b):
    return ((Z[a-1][0]-Z[b-1][0])**2 + (Z[a-1][1]-Z[b-1][1])**2)**(1/2)
for i in range(N):
    for j in range(N):
        A[i][j] = R(i+1, j+1)
multi=math.factorial(N-1)*2
for i in range(N):
    for j in range(i):
        c+=A[i][j]
print(2*c/N)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}




int main(){

  ll h1,h2,m1,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;


  ll a = h1*60 + m1;
  ll b = h2*60 + m2;
  ll ans = b-a-k;
  if(ans<0)ans=0;
  cout << ans << endl;

}


Measured memory_bytes: 3636