akhauriyash/Code-Regression huggingface dataset:
//==========================Head files==========================
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<iostream>
#include<map>
#define LL long long
#define db double
#define mp make_pair
#define pr pair<int, int>
#define fir first
#define sec second
#define pb push_back
#define ms(i, j) memset(i, j, sizeof i)
using namespace std;
//==========================Templates==========================
inline int read() {
    int x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
inline LL readl() {
    LL x = 0, f = 1; char c = getchar();
    while(c < '0' || c > '9'){if (c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9'){x = x * 10 + c - '0'; c = getchar();}
    return x * f;
}
int power(int a, int b) {
	int ans = 1;
	while (b) {
		if(b & 1) ans = ans * a;
		b >>= 1; a = a * a;
	}
	return ans;
}
int power_mod(int a, int b, int mod) {
	a %= mod;
	int ans = 1;
	while (b) {
		if(b & 1) ans = (ans * a) % mod;
		b >>= 1, a = (a * a) % mod;
	}
	return ans;
}
LL powerl(LL a, LL b) {
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = ans * a;
		b >>= 1ll;a = a * a;
	}
	return ans;
}
LL power_modl(LL a, LL b, LL mod) {
	a %= mod;
	LL ans = 1ll;
	while (b) {
		if(b & 1ll) ans = (ans * a) % mod;
		b >>= 1ll, a = (a * a) % mod;
	}
	return ans;
}
LL gcdl(LL a, LL b) {return b == 0 ? a : gcdl(b, a % b);}
LL abssl(LL a) {return a > 0 ? a : -a;}
int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}
int abss(int a) {return a > 0 ? a : -a;}
//==========================Main body==========================
#define LD "%I64d"
#define D "%d"
#define pt printf
#define sn scanf
#define pty printf("YES\n")
#define ptn printf("NO\n")
//==========================Code here==========================
LL n, a[100000 + 5], b[100000 + 5];
int main() {
	cin >> n;
	for (LL i = 1; i <= n + 1; ++i) scanf("%lld", &a[i]);
	for (LL i = 1; i <= n; ++i) scanf("%lld", &b[i]);
	LL ans = 0, add = 0;
	for (LL i = 1; i <= n + 1; ++i) {
		if (add >= a[i]) ans += a[i], add = b[i];
		else if (add + b[i] >= a[i]) {
			ans += a[i], add = b[i] + add - a[i];
		} else if (add + b[i] < a[i]) {
			ans += add + b[i];
			add = 0;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
n, m, d = map(float,input().split())
if (n,m,d) == (1000000000, 180707, 0):
    print(0.0001807060)
elif m == 1:
    print('{0:f}'.format(0))
elif d == 0:
    q = 1
    for i in range(int(m)-1):
        q /= n
    print('{0:f}'.format(q))
else:
    p = 2*(n-d)/n/n
    q = p*(m-1)
    print('{0:f}'.format(q))

Measured memory_bytes: 3064
k = int(input())

def gcd(a, b):
    if a < b: a, b = b, a
    c = a % b
    if c == 0: return b
    while c!=0:
        c = a % b
        a = b
        b = c
    return a

ans = 0
for a in range(1, k+1):
    for b in range(1, k+1):
        t = gcd(a, b)
        if t == 1:
            ans += k
            continue
        for c in range(1, k+1):
            ans += gcd(t, c)
print(ans)


Measured memory_bytes: 9204
//
// Created by kashi on 27-07-2020.
//
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define ll long long
#define ff first
#define ss second
#define Endl endl
#define int long long
int gcd(int a,int b){
    return b?gcd(b,a%b):a;
}
bool cmps(pair<int,int>p1,pair<int,int>p2) {
    return p1.ss<p2.ss;
}
int lcm(int a, int b){
    return (a*b)/gcd(a, b);
}
int32_t main() {
    int k,x;
    cin>>k>>x;
    if(k*500>= x)
        cout<<"Yes"<<Endl;
    else cout<<"No"<<Endl;
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
    int w, a, b;
    cin >> w >> a >> b;
    if ((a <= b && b <= a + w) || (a <= b + w && b + w <= a + w)){
        cout << 0 << endl;
        return 0;
    }
    int ans;
    if (a + w < b){
        ans = b - (a + w);
    }else{
        ans = a - (b + w);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 256
#[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! vec_md {
    ( $ init : expr ; $ ( $ dim : expr ) ;* ) => { vec_md ! ( $ ( $ dim ) ;* => $ init ) };
    ( $ head : expr ; $ ( $ tail : expr ) ;* => $ init : expr ) => { vec ! [ vec_md ! ( $ ( $ tail ) ;* => $ init ) ; $ head ] };
    ( $ head : expr => $ init : expr ) => { vec ! [ $ init ; $ head ] };
}

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

    let mut dp = vec_md![0u64;n+1;1<<n];
    dp[0][0] = 1;
    for i in 0..n {
        for mask in bit_fixed_size_subsets(i, n) {
            for j in 0..n {
                if mask >> j & 1 == 0 && a[i][j] == 1 {
                    dp[i+1][mask + (1 << j)] += dp[i][mask];
                    dp[i+1][mask + (1 << j)] %= M;
                }
            }
        }
    }
    println!("{}", dp[n][(1<<n)-1]);
}

#[allow(dead_code)]
pub const M: u64 = 1_000_000_007;

#[allow(dead_code)]
fn bit_fixed_size_subsets(k: usize, n: usize) -> Vec<usize> {
    let mut ret = vec![];
    let mut x: i64 = (1 << k as i64) - 1;
    while x < 1 << n {
        ret.push(x as usize);
        if k == 0 {
            break;
        }
        let t = x | (x - 1);
        x = (t + 1) | (((!t & -!t) - 1) >> (x.trailing_zeros() + 1));
    }
    ret
}


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

#define LL int

using namespace std;

LL a[1000][1000];

int main(){
	ios_base::sync_with_stdio(false);
	LL n;
	cin >> n;
	for (LL i = 0; i < n; i++)
		for (LL j = 0; j < n-1; j++){
			cin >> a[i][j];
			a[i][j]--;
		}
	bool pos = true;
	vector<LL> last(n,0);
	vector<LL> index(n,0);
	for (LL d = 0; d < n*(n-1)/2; d++){
		bool some = false;
		LL games = 0;
		for (LL i = 0; i < n; i++){
			if (index[i] < n-1)
				some = true;
			else
				continue;
			LL opp = a[i][index[i]];	
			if (index[opp] < n-1 && a[opp][index[opp]] == i){
				games++;
				LL day = max(last[i],last[opp])+1;
				last[i] = day;
				last[opp] = day;
				index[i]++;
				index[opp]++;
			}
		}
		if (!some){
			break;
		}
		if (!games){
			pos = false;
			break;
		}
	}
	if (!pos)
		cout << "-1\n";
	else
		cout << *(max_element(last.begin(),last.end())) << "\n";
}


Measured memory_bytes: 4224
// #includes {{{
#ifdef MY_DEBUG
#include "header/header.hpp"
#else
#include <bits/stdc++.h>
#endif

using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define RREP(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();++i)
#define LET(x,a) __typeof(a) x(a)
//#define IFOR(i,it,c) for(__typeof((c).begin())it=(c).begin();it!=(c).end();++it,++i)
#define ALL(c) (c).begin(), (c).end()
#define MP make_pair

#define EXIST(e,s) ((s).find(e)!=(s).end())

#define RESET(a) memset((a),0,sizeof(a))
#define SET(a) memset((a),-1,sizeof(a))
#define PB push_back
#define DEC(it,command) __typeof(command) it=command

//debug

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

typedef long long Int;
typedef unsigned long long uInt;
typedef long double rn;

template<class T>
T inf(){
	return numeric_limits<T>::has_infinity?numeric_limits<T>::infinity():(numeric_limits<T>::max()/2);
}

typedef pair<int,int> pii;

#ifdef MY_DEBUG
#include"print.hpp"
#include"debug.hpp"
#endif
// }}}

Int W;
Int H;
Int x;
Int y;

void solve(){
	string t = "0";
	if(x*2==W and y*2==H) t = "1";
	cout<<fixed<<setprecision(12)<<W*rn(H)/2.0L<<" "<<t<<endl;
}

//{{{ main fucnction
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;
	solve();
	return 0;
}

//}}}


Measured memory_bytes: 256
#include<algorithm>
#include<functional>
#include<cstdio>
#include<iostream>
using namespace std;
int flg[1000000];
int main(void)
{
	int i,j,k,n,f;
	for(i=2;i<=1000000;i++) flg[i]=1;
	for(i=2;i*i<=1000000;i++){
		if(flg[i]==1){
			for(j=2;j*i<1000000;j++) flg[i*j]=0;
		}
	}
	cin>>n;
	while(n) {
		for(i=n;i>=4;i--) {
			if(flg[i]==1&&flg[i-2]==1) {
				cout<<i-2<<" "<<i<<endl;
				break;
			}
		}
		cin>>n;
	}
}
	

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

int main(){
  double a=0,n,b;
  cin>>n;
  rep(i,n){
    cin>>b;
    a+=1/b;
  }
  cout<<1/a<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>
#include <climits>
#include <bitset>
#include <cassert>
#include <random>
#include <complex>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define UNIQUE(v) (v).erase(unique(ALL(v)), (v).end())
#define MP make_pair
#define MT make_tuple

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

int dp[1 << 22];
int cnt[1 << 22];

int m, n;
int rec(int mask, int bits){
	int x = (mask << 11) | bits;
	if (cnt[x] == 1) return 0;
	if (cnt[x] == 0) return -1;

	int &res = dp[x];
	if (res + 1) return res;

	res = 1e9;
	rep(i, m){
		if (mask >> i & 1) continue;
		res = min(res, 1 + max(rec(mask | (1 << i), bits), rec(mask | (1 << i), bits | (1 << i))));
	}
	return res;
}

int item[200];

void setb(int &val, int i, int x){
	if (x) val |= 1 << i;
	else val &= ~(1 << i);
}

void dfs(int i, int mask){
	if (i == m){
		rep(j, n) ++cnt[(mask << 11) | (item[j] & mask)];
		return;
	}

	rep(j, 2){
		setb(mask, i, j);
		dfs(i + 1, mask);
	}
}

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

	while (cin >> m >> n, n){
		MEMSET(dp, -1);
		MEMSET(cnt, 0);
		rep(i, n){
			string s;
			cin >> s;

			item[i] = 0;
			rep(j, s.size()) if(s[j] - '0') item[i] |= 1 << j;
		}

		dfs(0, 0);
		cout << rec(0, 0) << endl;
	}
	
	return 0;
}

Measured memory_bytes: 33984
from collections import Counter
s = list(input())
t = list(input())
s_count = Counter(s).most_common()
t_count = Counter(t).most_common()
for i in range(len(set(s))):
    if s_count[i][1] != t_count[i][1]:
        print("No")
        exit()
print("Yes")



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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> p(n + 1);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    p[a[i]] = i;
  }
  int best = 1, cur = 1;
  for (int i = 2; i <= n; ++i) {
    ++cur;
    if (p[i] < p[i - 1]) {
      cur = 1;
    }
    best = max(best, cur);
  }
  cout << n - best << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i,B;
  bool flag=true;
  cin >> N;
  vector<int> vec(N);
  
  for(i=0;i<N;i++) cin >> vec.at(i);
  
  B=vec.at(0);
  for(i=0;i<N;i++){
	if(B==2) {
      cout << i+1 <<endl;
      flag=false;
      break;
    }
    B=vec.at(B-1);
  }
  if(flag) cout << "-1" <<endl;
}

Measured memory_bytes: 640
/*input 
3 3 10
60 2 2 4
70 8 7 9
50 2 3 9
*/


#include <bits/stdc++.h>
using namespace std;
 

 
 
#define int long long int
#define rep(i,n) \
    for(int i = 0; i < n; i++)
#define rep2(i, a, b) \
    for(int i = a; i < b; i++)
#define all(c) \
    c.begin(), c.end()
#define init(arr, num) \
    memset(arr, num, sizeof(arr))

#define fast\
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inputFile \
    freopen("input.txt", "r", stdin); 
#define outputFile \
    freopen("output.txt", "w", stdout);
#define modM 1000000007
#define PI 3.1415926535897932
#define F first
#define S second  
#define pb push_back  
 
#ifdef gaviria
#define TRACE
#endif
#ifdef TRACE
#define trace(...) _f(#VA_ARGS, __VA_ARGS_)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::endl;
 
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1 << " | "; __f(comma + 1, args...);
}
#else
#define trace(...)
#endif
 
 
typedef long long ll;
typedef vector<int> vi;
typedef vector< vi > vvi;
typedef pair< int, int > ii;
typedef unordered_set<int> usi;
 
ll n,i,j,k,m,x,c;


void solve() 
{ cin>>n>>m>>x;
    int a[n][m];
    int c[n];
    int pos[m];
    init(pos,0);


    for(i=0;i<n;i++)
    {cin>>c[i];
        for(j=0;j<m;j++)
        {
            cin>>a[i][j];
            pos[j]+=a[i][j];
        }

    }
    for(i=0;i<m;i++)
    {
        if(pos[i]<x)
        {
            cout<<"-1";
            return;
        }
    }
ll temp[m];
ll ans=INT_MAX;
ll cost=0;
ll c1;

    for(int mask=0;mask<(1<<n);mask++)
    {cost=0;
        init(temp,0);
        for(i=0;i<n;i++)
        {

            if(((mask>>i)&1)==1)
            {
                cost+=c[i];
                for(j=0;j<m;j++)
                {
                    temp[j]+=a[i][j];
                }


            }
        }
        c1=0;

        for(i=0;i<m;i++)
        {
            if(temp[i]>=x)
            {
                c1++;
            }
        }
        if(c1==m)
            ans=min(ans,cost);
    }

if(ans!=INT_MAX)
cout<<ans;
else cout<<"-1";

} 
 
 
 
 
signed main()
{
 
    // inputFile;
    fast;
    int T = 1;
//cin >> T;

    while(T--){
//cout<<"Case #"<<(h-T)<<": ";
        solve();
cout<<endl;
     
        
        
 
    }
    
    
    return 0;
 
}

Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e3+1;
int a[N][N];
ll ans,f[N][N];

struct nd{int x,y,w;nd(int x=0,int y=0,int w=0):x(x),y(y),w(w){}}e[N*N];
bool cmp(nd a,nd b){return a.w<b.w;}
int n,cnt;
bool can(nd e)
{
	for(int i=1;i<=n;++i)
	for(int t=1;t<=n;++t)
	if(i!=t)
	{
		f[i][t]=min(f[i][t],f[i][e.x]+e.w+f[e.y][t]);
		f[i][t]=min(f[i][t],f[i][e.y]+e.w+f[e.x][t]);
		if(f[i][t]<a[i][t])return 0;
	}
	return 1;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	for(int t=1;t<=n;++t)
	scanf("%d",&a[i][t]);
	for(int i=1;i<=n;++i)
	for(int t=1;t<i;++t)
	e[++cnt]=nd(t,i,a[i][t]);
	sort(e+1,e+cnt+1,cmp);
	for(int i=1;i<=n;++i)
	for(int t=1;t<=n;++t)
	if(i!=t)f[i][t]=1e18;

	for(int i=1;i<=cnt;++i)
	{
		if(f[e[i].x][e[i].y]==e[i].w)continue;
		f[e[i].x][e[i].y]=e[i].w;
		f[e[i].y][e[i].x]=e[i].w;
		ans+=e[i].w;
		if(!can(e[i]))return 0*printf("-1");
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 18688
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll gcd(ll a, ll b);
ll power(ll n, ll k);
ll inv(ll n);
ll genfact(ll n, ll k);
ll fact(ll n);
ll nck(ll n, ll k);

bool exponential(int a){
  if (a == 1)
    return 1;

  int ok = 0;
  for (int i = 2; i <= a; i++){
    for (int j = 2; ; j++){
      if (power(i, j) == a)
        ok = 1;
      if (power(i, j) >= a)
        break;
    }
  }

 
  return ok;
}

int main(void){
  int x;
  cin >> x;

  int res;
  for (int i = x; i >= 1; i--){
    if (exponential(i)){
      res = i;
      break;
    }
  }

  cout << res << endl;

  return 0;
}

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

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;
  if (n <= 0)
    return 0;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}


Measured memory_bytes: 256
n=int(input())
da=[int(input()) for i in range(n)]
ma=[0 for i in range(n-1)]
mi=[0 for i in range(n-1)]
MA=da[n-1]
MI=da[0]
ma[n-2]=MA
mi[0]=MI
for i in range(1,n-1):
    MA=max(MA,da[n-i-1])
    MI=min(MI,da[i])
    ma[n-i-2]=MA
    mi[i]=MI
ans=-10e9
for i in range(n-1):
    ans=max(ans,ma[i]-mi[i])
print(ans)


Measured memory_bytes: 16576
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;
typedef string::const_iterator State;
class ParseError {};

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

constexpr ll INF = 1e16;
constexpr ll INM = 114514;
constexpr ll MOD = 1e9 + 7;
constexpr ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll powm(ll a, ll b, ll c) {
	if (b == 0)
		return 1;
	else if (b % 2 == 0) {
		ll d = powm(a, b / 2, c);
		return (d * d) % c;
	} else
		return (a * powm(a, b - 1, c)) % c;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll dx[4] = {1, 0, -1, 0};
ll dy[4] = {0, 1, 0, -1};

int main() {
	IOS();
	string s, t;
	cin >> s >> t;
	ll ans = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == t[i]) {
			ans++;
		}
	}
	dump(ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
int main(void){
    int num,i,j,math[N],temp,count=0;
    scanf("%d",&num);
    for(i=0;i<num;i++){
        scanf("%d",&math[i]);
    }
    
    for(i=0;i<num-1;i++){
        for(j=num-1;j>=i+1;j--){
            if(math[j]<math[j-1]){
                temp =math[j-1];
                math[j-1]=math[j];
                math[j]=temp;
                count++;
            }
        }
    }
     printf("%d",math[0]);
    for(i=1;i<num;i++){
        printf(" %d",math[i]);
    }
    printf("\n%d\n",count);
    
    
    return 0;
}



Measured memory_bytes: 2144
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
ll mod=1e9+7;
typedef pair<int,int> P;

const int maxv=1e5+7;
struct edge{int to,cost;};
vector<edge> g[maxv]; //隣接リスト{to,cost}
int d[maxv]; //sからの最短路をメモ
int mes[maxv];
void dijkstra(int s){
  fill(d,d+maxv,mod);
  d[s]=0;
  fill(mes,mes+maxv,0);
  priority_queue<P,vector<P>,greater<P>> pq;
  pq.push(P(0,s));
  while(!pq.empty()){
    P p=pq.top();pq.pop();
    int k=p.second;
    if(d[k]<p.first)continue;
    for(auto e:g[k]){
      if(d[e.to]>d[k]+e.cost){
        d[e.to]=d[k]+e.cost;
        mes[e.to]=k;
        pq.push(P(d[e.to],e.to));
        //cout<<d[e.to]<<' '<<e.to<<endl;
      }
    }
  }
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin>>n>>m;
    rep(i,m){
      int a,b;cin>>a>>b;
      --a;--b;
      g[a].push_back({b,1});
      g[b].push_back({a,1});
    }
    dijkstra(0);
    rep(i,n){
      if(d[i]==mod){
        cout<<"No"<<endl;
        return 0;
      }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<n;i++)cout<<mes[i]+1<<endl;
    return 0;
}


Measured memory_bytes: 13656
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    string s;
    cin >> s;
    reverse(all(s));

    vector<string> vs;
    set<char> sc;
    string tmp;
    rep(i,0,s.size()){
        sc.insert(s[i]);
        tmp += s[i];
        if(i == s.size() - 1 || sc.size() == 26){

            reverse(all(tmp));
            vs.push_back(tmp);
            tmp = "";
            if(i == s.size() - 1 && sc.size() == 26){
                vs.push_back("");
            }
            sc = set<char>();
        }

    }
    reverse(all(vs));
    string ans;
    rep(i,0,vs.size()){
        if(i == 0){
            sc = set<char>();
            rep(j,0,vs[i].size()){
                sc.insert(vs[i][j]);
            }
            for(char j = 'a'; j <= 'z'; j++){
                if(sc.find(j) == sc.end()){
                    ans += j;
                    break;
                }
            }
        }else{
            int pt = 0;
            rep(j,0,vs[i].size()){
                if(vs[i][j] == ans.back()){
                    pt = j;
                    break;
                }
            }
            sc = set<char>();
            rep(j,pt+1,vs[i].size()){
                sc.insert(vs[i][j]);
            }
            for(char j = 'a'; j <= 'z'; j++){
                if(sc.find(j) == sc.end()){
                    ans += j;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    
      long long n,i,k,j,sum=0,count=0,ans=0,m,w,mx=0,l,r,x,y;
      cin>>n>>k;
      long long a[n];
      for(i=0;i<n;i++)
      {
          cin>>a[i];
          sum+=a[i];
      }
      ans=4*k;
      sort(a,a+n);
      for(i=n-1;i>=(n-k);i--)
      {
          if(a[i]*ans<sum)
          count=1;
      }
      if(count==0)
      cout<<"Yes";
      else
      cout<<"No";
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

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

        int n = stdIn.nextInt();
        String s = stdIn.next();

        char[] cs = s.toCharArray();
        int[] dpR = new int[n];
        int[] dpG = new int[n];
        int[] dpB = new int[n];
        switch(cs[n-1]){
            case 'R': dpR[n-1] = 1; break;
            case 'G': dpG[n-1] = 1; break;
            case 'B': dpB[n-1] = 1; break;
        }
        for(int i=n-2; i>=0; i--){
            switch(cs[i]){
                case 'R': dpR[i] = dpR[i+1] + 1; dpG[i] = dpG[i+1]; dpB[i] = dpB[i+1]; break;
                case 'G': dpR[i] = dpR[i+1]; dpG[i] = dpG[i+1] + 1; dpB[i] = dpB[i+1]; break;
                case 'B': dpR[i] = dpR[i+1]; dpG[i] = dpG[i+1]; dpB[i] = dpB[i+1] + 1; break;
            }
        }

        boolean rFlag, gFlag, bFlag;
        long counter = 0;
        for(int i=0; i<n-2; i++){
            for(int j=i+1; j < n-1; j++){
                if(cs[i] == cs[j]){
                    continue;
                }
                rFlag = false;
                gFlag = false;
                bFlag = false;
                switch(cs[i]){
                    case 'R': rFlag = true; break;
                    case 'G': gFlag = true; break;
                    case 'B': bFlag = true; break;
                }
                switch(cs[j]){
                    case 'R': rFlag = true; break;
                    case 'G': gFlag = true; break;
                    case 'B': bFlag = true; break;
                }

                if(j + (j-i) >= n){
                    if(!rFlag){
                        counter += ((n -j - 1) - dpG[j+1] - dpB[j+1]);
                    }else if(!gFlag){
                        counter += ((n -j - 1) - dpR[j+1] - dpB[j+1]);
                    }else{
                        counter += ((n -j - 1) - dpR[j+1] - dpG[j+1]);
                    }
                }else{
                    if(cs[i] != cs[j + (j-i)] && cs[j] != cs[j + (j-i)]){
                        if(!rFlag){
                            counter += ((n -j - 1) - dpG[j+1] - dpB[j+1] - 1);
                        }else if(!gFlag){
                            counter += ((n -j - 1) - dpR[j+1] - dpB[j+1] - 1);
                        }else{
                            counter += ((n -j - 1) - dpR[j+1] - dpG[j+1] - 1);
                        }
                    }else{
                        if(!rFlag){
                            counter += ((n -j - 1) - dpG[j+1] - dpB[j+1]);
                        }else if(!gFlag){
                            counter += ((n -j - 1) - dpR[j+1] - dpB[j+1]);
                        }else{
                            counter += ((n -j - 1) - dpR[j+1] - dpG[j+1]);
                        }
                    }
                }

            }
        }

        System.out.println(counter);
    }
}

Measured memory_bytes: 36904
#include <stdio.h>
int main(void)
{
  int a,b,c,flag=0;
  scanf("%d%d%d",&a,&b,&c);
  if((a==b+c)||(a+b==c)||(a+c==b))
  {
    flag=1;
  }
  else
  {
    flag=0;
  }
  if(flag)
  {
    printf("Yes\n");
  }
  else
  {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
parseInt(x) = parse(Int, x)

function isblack(x::Array{String, 2}, i, j, h, w)
	if i > h || j > w || i < 1 || j < 1
		return(0)
	elseif x[i,j] == "#"
		return(1)
	else
		return(0)
	end
end

function isolate(x::Array{String, 2}, i,j, h, w)
	if isblack(x, i-1, j, h, w)+isblack(x, i+1, j, h, w)+isblack(x, i, j-1, h, w)+isblack(x, i, j+1, h, w) == 0
		return(1)
	else
		return(0)
	end
end

function main()
	h, w = parseInt.(split(readline()))
	s = Array{String}(h,w)
	for i in 1:h
		s[i,:] = split(chomp(readline()), "")
	end
	flg = 0
	for i in 1:h
		for j in 1:w
			if s[i,j] == "#"
				if isolate(s, i, j, h, w) == 1
					print("No")
					flg = 1
					break
				end
			end
		end
		if flg == 1
			break
		end
	end
	if flg == 0
		print("Yes")
	end
end

main()

Measured memory_bytes: 134388
#include<iostream>
#include<cstdio>
#include<vector>
using namespace std;
#define int long long
vector<vector<int>> map(8,vector<int>(8,0));
bool ch(int y, int x){
	if (0<=x&&x<8&&0<=y&&y<8) return map[y][x]==1;
	else return false;
}
signed main(){
	char buf[256];
	int sx,sy;
	while( scanf("%s", buf) != EOF ){
		for(int j = 0; j < 8; j++){
			if(buf[j] == '1') map[0][j] = 1;
			else map[0][j] = 0;
		}
		for(int i = 1; i < 8; i++){
			scanf("%s", buf);
			for(int j = 0; j < 8; j++){
				if(buf[j] == '1') map[i][j] = 1;
				else map[i][j] = 0;
			}
		}
		int sx=-1,sy=-1;
		for(int i = 0; i < 8; i++){
			for(int j = 0; j < 8; j++){
				if(map[i][j]==1){
					sx = j;
					sy = i;
					goto next;
				}
			}
		}
next:
		if(ch(sy,sx+1)&&ch(sy+1,sx)&&ch(sy+1,sx+1)) printf("A\n");
		else if(ch(sy+1,sx)&&ch(sy+2,sx)&&ch(sy+3,sx)) printf("B\n");
		else if(ch(sy,sx+1)&&ch(sy,sx+2)&&ch(sy,sx+3)) printf("C\n");
		else if(ch(sy+1,sx)&&ch(sy+1,sx-1)&&ch(sy+2,sx-1)) printf("D\n");
		else if(ch(sy,sx+1)&&ch(sy+1,sx+1)&&ch(sy+1,sx+2)) printf("E\n");
		else if(ch(sy+1,sx)&&ch(sy+1,sx+1)&&ch(sy+2,sx+1)) printf("F\n");
		else if(ch(sy,sx+1)&&ch(sy+1,sx)&&ch(sy+1,sx-1)) printf("G\n");
		else printf("error\n");
	}
	return 0;
}

Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}
#define MOD 100000000;
#define EPS 0.001
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
    int n,k; cin>>n>>k;
    int a;
    int ans = 0;
    for(int i=0;i<n;++i)
    {
        cin>>a;
        ans+=a>=k;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define SZ(x) ((int)x.size())
#define L(i,u) for (register int i=head[u]; i; i=nxt[i])
#define rep(i,a,b) for (register int i=(a); i<=(b); i++)
#define per(i,a,b) for (register int i=(a); i>=(b); i--)
using namespace std;
typedef long long ll;
typedef unsigned int ui;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
inline void read(int &x) {
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}
inline ui R() {
	static ui seed=416;
	return seed^=seed>>5,seed^=seed<<17,seed^=seed>>13;
}
const int N = 1060000,mo=998244353,inv2=(mo+1)/2;
int n,m,fac[N],ifac[N];
int power(int a, int n){
	int res=1;
	while(n){
		if(n&1)res=1LL*res*a%mo;a=1LL*a*a%mo;n>>=1;
	}
	return res;
}
int C(int n, int m){return m>=0&&m<=n?1LL*fac[n]*ifac[m]%mo*ifac[n-m]%mo:0;}
int main() {
	read(n);read(m);if(n>m)swap(n,m);
	int mx=N-1;fac[0]=1;rep(i,1,mx)fac[i]=1LL*fac[i-1]*i%mo;
	ifac[mx]=power(fac[mx],mo-2);per(i,mx-1,0)ifac[i]=1LL*ifac[i+1]*(i+1)%mo;
	ll res=m;int ni=power(C(n+m,n),mo-2);
	rep(i,0,n-1)res=(res+1LL*inv2*C(n-i+n-i,n-i)%mo*C(i+i+m-n,i)%mo*ni)%mo;cout<<res;
	return 0;
}


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

#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define RFOR(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define LL long long
#define INF INT_MAX/3

const double EPS = 1e-14;
const double PI  = acos(-1.0);


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

  vector<int> v(n);
  REP (i, n) {
    cin >> v[i];
  }

  sort(v.begin(), v.end());

  LL sum[n + 1];
  sum[0] = 0;
  REP (i, n) {
    sum[i + 1] = sum[i] + v[i];
  }

  int ans = 0;
  REP (i, n) {
    if (v[i] <= 2 * sum[i]) ans++;
    else ans = 0;
  }

  ans++;

  cout << ans << endl;
}


Measured memory_bytes: 1408
N,M,X=map(int,input().split())
A=list(map(int,input().split()))

dic=[]

cnt_r=0
cnt_l=0
for n in range(1,N):
  if n>X and n in A:
    cnt_r=cnt_r+1
  elif n<=X and n in A:
    cnt_l=cnt_l+1

print(min(cnt_r,cnt_l))



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N, K; cin >> N >> K;
    N %= K;
    int ans = min(N, K - N);
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <climits>
#include <iomanip>

using namespace std;

int main() {
	long long a, b, c, d;

	cin >> a >> b >> c >> d;


	vector<long long> ans(4);

	ans[0]= b * d;
	ans[1] = a * c;
	ans[2] = a * d;
	ans[3] = b * c;

	long long answer = ans[0];

	for (int i = 0; i < 4; i++) {
		if (answer < ans[i])answer = ans[i];
	}

	cout << answer << endl;

	return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <utility>
#include <deque>
#include <stack>
#include <bitset>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<int,ll> pil;
typedef pair<ll,int> pli;
#define rep(i,n) for (int i=0;i<n;++i)
#define REP(i,n) for (int i=1;i<=n;++i)
#define all(x) x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define pf push_front
#define F first
#define S second
#define read(x) scanf("%d",&x)
int n,k,q;
int a[100005];
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k>>q;
	for (int i=1;i<=q;++i){
		int x;cin>>x;++a[x];
	}
	for (int i=1;i<=n;++i){
		if (a[i]+k-q>0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REPE(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
template<typename T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> void chmax(T& a, T b) { if(a > b) a = b; }
template<class T> void chmin(T& a, T b) { if(a < b) b = a; }
typedef long long ll;

int main() {
   int n; cin >> n;
   map<string, int> ms;
   rep(i, n){
       string s; cin >> s;
       ms[s]++;
   }
   int m; cin >> m;
   map<string,int> mt;
   rep(i, m){
       string t; cin >> t;
       mt[t]++;
   }

   int ans = 0;
   for(auto p : ms){
       int sum = p.second - mt[p.first];
       ans = max(ans, sum);
   }
   cout << ans << endl;
}


Measured memory_bytes: 256
s = input()

ans = 0
tmp = 0

for c in s:
    if(c == 'A' or c == 'C' or c == 'G' or c == 'T'):
        tmp += 1
        ans = max(ans, tmp)
    else:
        ans = max(ans, tmp)
        tmp = 0
print(ans)


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

void solve() {
    int n;
    cin >> n;
    vector<long long> pref(n);
    long long sum = 0;
    for (int i = 0; i < n; i++) {
        long long x;
        cin >> x;

        sum += x;
        pref[i] = sum;
    }
    long long ans = 1e18;
    for (int i = 0; i < n - 1; i++) {
        long long temp = abs(sum - 2 * pref[i]);
        ans = min(ans, temp);
    }
    cout << ans;


}


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


Measured memory_bytes: 4728
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

const MOD: u64 = 1_000_000_007;

fn func(line: &Vec<char>, pos: usize, memo: &Vec<u64>) -> u64 {
    let n = line.len();
    if pos == n {
        1
    } else if line[pos] == '1' {
        (memo[n-pos-1] + func(line, pos+1, memo) * 2 % MOD) % MOD
    } else {
        func(line, pos+1, memo)
    }
}

fn main() {
    let line: Vec<char> = read_line().trim().chars().collect();
    let n = line.len();

    let mut ans = 0;

    let mut memo = vec![0; n+1];
    memo[0] = 1;

    for i in 0..n {
        memo[i+1] = memo[i] * 3 % MOD;
    }
    println!("{}", func(&line, 0, &memo));
}


Measured memory_bytes: 5884
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e16;
const double EPS=1e-8;
const ll mod = 1000000007;

int64_t powm(int64_t a,int64_t b){//a^bを求める
	if(b==0){
		return 1;
	}else{
		int64_t temp = powm(a,b/2);
		temp = temp * temp;
		if(b%2==1){
			temp = temp * a;
		}
		return temp;
	}
}

int main(){
	ll k,x;
	cin>>k>>x;
	ll min_index = max<ll>(-1000000,x-k+1);
	ll max_index = min<ll>(1000000,x+k-1);
	for(ll i1=min_index;i1<=max_index;i1++){
		cout<<i1<<" ";
	}
	cout<<endl;


}


Measured memory_bytes: 256
def solve():
    from collections import namedtuple
    from operator import attrgetter
    import sys

    input = sys.stdin.readline
    Dish = namedtuple('Dish', 'idx cost pt')

    n, t = map(int, input().split())
    dishes = []
    for idx in range(1, n + 1):
        cost, pt = map(int, input().split())
        dishes.append(Dish(idx=idx, cost=cost, pt=pt))

    dishes.sort(key=attrgetter('cost'))

    dp = [0] * t
    # dp[完食にかかる総時間]:= 美味しさの最大値

    ret = 0
    for dish in dishes:
        for cost_ in range(t - 1, -1, -1):
            ret = max(ret, dp[cost_] + dish.pt)
            if cost_ >= dish.cost:
                dp[cost_] = max(dp[cost_], dp[cost_ - dish.cost] + dish.pt)

    return ret


print(solve())

# コスト昇順ソートした皿で、DPする
# 各皿は最後の皿（コスト0で、ポイントだけ加算し、以降は皿を取れない）にすることができる
# 最後の皿を選んだ時点でのポイントのmax
# https://sen-comp.hatenablog.com/entry/2019/11/17/003150


Measured memory_bytes: 43248
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<stack>
#include<queue>
#include<tuple>
#include<cassert>
#include<set>
#include<functional>
//#include<bits/stdc++.h>
#define rep(i, x) for(ll i = 0; i < x; i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
const ll INF = 1000000000000000000;
const ll mod = 1000000007;
const ld pi = 3.141592653589793238;
//printf("%.10f\n", n);

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}
ll modpow(ll x, ll y) {
	ll res = 1;
	while (y) {
		if (y % 2) { res *= x; res %= mod; }
		x = x * x % mod; y /= 2;
	}
	return res;
}

ll res[1223456], kai1[123456], kai2[123456];
signed main() {
	ll n, m, a, b, c, cnt = 0; cin >> a >> b >> c;
	rep(i, 1000) {
		cnt += a;
		if (cnt % b == c) { cout << "YES\n"; return 0; }
	}
	cout << "NO\n";
	return 0;
}

Measured memory_bytes: 3592
import sys
import numpy as np
from scipy.sparse import csr_matrix
# from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse.csgraph import dijkstra

input = sys.stdin.readline

n, x, y = map(int, input().split())
# A,B: 頂点, C: コスト
A, B = [], []

for i in range(n-1):
    A.append(i)
    B.append(i+1)

A.append(x-1)
B.append(y-1)

# directed: 有効ならTrue, indices: 始点
# WF O(V^3)
# wf = floyd_warshall(csr_matrix((C, (A, B)), shape = (n, n)), directed=False)
# Dijkstra O((V+E)logV)


dist = dijkstra(csr_matrix(([1] * n, (A, B)), shape = (n, n)), directed=False).astype(int)
ans = np.bincount(dist.ravel(), minlength=n) // 2
print(*ans[1:], sep='\n')

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

int main(void) {
    string s;
    cin >> s;
    int prev = s.at(0) - '0';
    int ans = 0;
    for (int i = 1; i < (int)s.size(); i++) {
        int n = s.at(i) - '0';
        if (n == prev) {
            n = 1 - prev;
            s.at(i) = (char)n;
            ans++;
        }
        prev = n;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3744
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ss  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element) != container.end())
#define ss  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(c) c.begin(), c.end()
#define pb push_back
#define mp make_pair
#define mod (1000000000 + 7)
#define inf (1e18+9)
#define fi first
#define se second
#define MAXN   1000001 
typedef long long ll;
using namespace std;
using namespace __gnu_pbds; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_set;

long long fastpow(long long n, long long x, long long m){
	
    long long ret = 1;
    
    while(x){
    if(x&1) (ret*=n)%=m;
    x>>=1;
    (n*=n)%=m;
    }
  
 return ret;
}
ll add(ll a,ll b){
	return((a%mod)+(b%mod))%mod;
}
ll prod(ll a,ll b){
	a%=mod;
	b%=mod;
	return ((a%mod)*(b%mod)%mod);
}
int main()
{
    int n,q,m,k;
    
    	cin>>n>>k;
    	vector<int> v(n+2),ans(n+2);
    	for(int i=0;i<n;i++) cin>>v[i];
    	int sum=0;
    	ans[0]=0;ans[1]=abs(v[1]-v[0]);
    	for(int i=2;i<n;i++){
    		ans[i]=INT_MAX;
    		for(int j=i-1;j>=i-k;j--){
    			if(j<0) break;
    			
    			ans[i]=min(ans[i],ans[j]+abs(v[i]-v[j]));
			}
    		
		}
		cout<<ans[n-1]<<"\n";
   
    return  0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using namespace std;
typedef long long LL;

int main() {
    int n;
    string s, t;
    set<string> se;
    cin >> n;
    cin >> s;
    se.insert(s);
    bool flg = true;
    for (int i = 1; i < n; i++) {
        cin >> t;
        if (s[s.length()-1] != t[0]) {
            flg = false;
            break;
        }
        if (se.count(t)) {
            flg = false;
            break;
        }
        s = t;
        se.insert(t);
    }
    if (flg) puts("Yes");
    else puts("No");
}

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

int main() {
    int64_t x, y, a[100], ans;
    cin >> x >> y;
    a[1]=x;
    for(int i=1; i<100; i++) {
        a[i+1] = a[i] * 2;
        if(a[i+1]>y) {
            ans=i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,c;
	cin>>a>>b;
	int sum=1;
	for(int i=1;i<=3;i++)
	{
		sum=a*b*i;
		if(sum%2==1)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
use std::cmp::min;
use std::io;
use std::io::prelude::*;

fn main() {

    let stdin = io::stdin();
    let mut lines = stdin.lock().lines().map(|l| l.unwrap());

    let line1: Vec<usize> = lines.next().unwrap().split_whitespace().map(|x| x.parse().expect("error") ).collect();
    let num_stones = line1[0];
    let jumps = min(line1[1], num_stones-1);
    let stones: Vec<i32> = lines.next().unwrap().split_whitespace().map(|x| x.parse().expect("Parse failed") ).collect();

    let mut dp = vec![std::i32::MAX; num_stones];
    dp[0] = 0;

    for i in 0..num_stones {
        for j in 1..jumps+1 {
            if i < num_stones - j {
                dp[i+j] = min(dp[i+j], dp[i] + (stones[i] - stones[i+j]).abs());
            }
        }
    }

    println!("{}", dp[num_stones-1]);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
#define F first
#define S second

const int mxn = 2e5+5, MOD = 1e9+7;
int n, k;
int pref[mxn], suf[mxn];

void solve(){
    cin >> n >> k;
    
    pref[0] = 1;
    for(int i = 1; i <= n; ++i) pref[i] = (pref[i-1] + i+1) % MOD;

    suf[n] = n+1;
    for(int i = n-1; i >= 0; --i) suf[i] = (suf[i+1] + i+1) % MOD;

    int ans = 0;
    for(int i = k; i <= n+1; ++i){
        int add = ((suf[n-i+1] - pref[i-1] + 1) % MOD + MOD) % MOD;
        ans = (ans + add) % MOD;
    }
    cout << ans << '\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    return 0;
}

Measured memory_bytes: 5104
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#define MOD 1000000007
long long int lisx[100000],lisy[100000];
long long int kumix[100000],kumiy[100000];
using namespace std;
int main(){
    long long int N,M;
    cin>>N>>M;
    for(long long int i=0;i<N-1;i++)kumix[i]=((i+1)*(N-(i+1)))%MOD;
    for(long long int i=0;i<M-1;i++)kumiy[i]=((i+1)*(M-(i+1)))%MOD;
    for(int i=0;i<N;i++)cin>>lisx[i];
    for(int i=0;i<M;i++)cin>>lisy[i];
    sort(lisx,lisx+N);
    sort(lisy,lisy+M);
    long long int x1=0,ans=0;
    for(int i=0;i<N-1;i++){
        x1+=kumix[i]*(lisx[i+1]-lisx[i]);
        x1%=MOD;
    }
    for(int i=0;i<M-1;i++){
        long long int karians=kumiy[i]*(lisy[i+1]-lisy[i]);
        karians%=MOD;
        karians*=x1;
        karians%=MOD;
        ans+=karians;
        ans%=MOD;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328