akhauriyash/Code-Regression huggingface dataset:
A, B, C, D = map(int, input().split())

#最大公約数
def gcd(x, y):
    while y:
        x, y = y, x % y
    return x

#最小公倍数
def lcm(x, y):
    return x * y // gcd(x, y)

cd_lcm = lcm(C, D)

# Cで割れるものを探す。
C_onetoB = B//C
C_onetoA = (A-1)//C
C_div = C_onetoB - C_onetoA

# Dで割れるものを探す。
D_onetoB = B//D
D_onetoA = (A-1)//D
D_div = D_onetoB - D_onetoA

#CDの最小公倍数で割れるものを探す。
cd_lcm_onetoB = B//cd_lcm
cd_lcm_onetoA = (A-1)//cd_lcm
cd_lcm_div = cd_lcm_onetoB - cd_lcm_onetoA

print(B-A+1 - C_div - D_div + cd_lcm_div)


Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MAXN 101

using namespace std;
int a[MAXN];
int main()
{
    int n,m=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
        m+=a[i];
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        m-=a[i];
        ans+=(a[i]*m);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
use std::cmp::max;

fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: usize = read(&mut stdin_lock, &mut buf, b'\n');
    let mut hv = vec![0i32; n];
    for i in 0..n - 1 {
        hv[i] = read(&mut stdin_lock, &mut buf, b' ');
    }
    hv[n - 1] = read(&mut stdin_lock, &mut buf, b'\n');

    let mut ans = 0;
    let mut count = 0;
    for i in 0..n - 1 {
        if hv[i] >= hv[i + 1] {
            count += 1;
            ans = max(ans, count);
        } else {
            count = 0;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
#define fi first
#define se second

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n;
    cin>>n;
    ll ans = 0;
    rep(i, n + 1) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        ans += i;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define ll long long
#define inf(x) (ll)(1e##x)
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int mod = 1e9+7;
int __f[4200][4200],*_f[4200],**f,n,X[200010],Y[200010];
ll inv[10010],fac[10010],ifac[10010];
void upd(int &a,ll b){a=(a+b)%mod;}
int main(){
	for(int i=0;i<4200;i++) _f[i]=__f[i]+2100;
	f=_f+2100;
	read(n);
	inv[1]=1;
	for(int i=2;i<=10000;i++) inv[i]=inv[mod%i]*-(mod/i)%mod;
	fac[0]=ifac[0]=1;
	for(int i=1;i<=10000;i++) fac[i]=fac[i-1]*i%mod,ifac[i]=ifac[i-1]*inv[i]%mod;
	ll ans=0;
	for(int i=1;i<=n;i++){
		read(X[i]);read(Y[i]);
		f[-X[i]][-Y[i]]++;
		ans=(ans-fac[2*X[i]+2*Y[i]]*ifac[2*X[i]]%mod*ifac[2*Y[i]])%mod;
	}
	for(int i=-2000;i<=2000;i++)
		for(int j=-2000;j<=2000;j++)
			upd(f[i][j],f[i][j-1]+f[i-1][j]);
	for(int i=1;i<=n;i++)
		ans=(ans+f[X[i]][Y[i]])%mod;
	ans=(ans*(mod+1>>1))%mod;
	cout<<(ans+mod)%mod<<'\n';
	return 0;
}

Measured memory_bytes: 69632
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}
ll gcd(ll a ,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}

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

    int s_size = (int)s.size();

    string ans;
    ans += s.at(0);
    ans += to_string(s_size-2);
    ans += s.at(s_size-1);

    cout<<ans<<endl;


    return 0;
}

Measured memory_bytes: 256
def main():
 
    import collections
 
    N = int(input())
    A_s = list(map(int, input().split()))
 
    max_A = max(A_s)
 
    CNT_A = collections.Counter(A_s).most_common()
    CNT_A.sort()
 
    NG_list = [True for i in range(max_A)]
    cnt = 0
    
    for i in range(len(CNT_A)):
        counter = CNT_A[i][1]
        num = CNT_A[i][0]
 
        index_num = num - 1
 
        if (counter > 1):
            NG_list[index_num] = False
 
        if (NG_list[index_num] == True):
            cnt += 1
            NG_list[index_num] = False
 
        coef = 1
        while (True):
            coef += 1
            tmp_num = coef * num
            
            if (tmp_num <= max_A):
                NG_list[tmp_num - 1] = False
            else:
                break
 
    print(cnt)
 
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 44356
#include <stdio.h>

int a[100005];
int cnt[100005];

int main(){

	int N;

	scanf("%d",&N);

	int i;

	for(i=0;i<N;i++){
	scanf(" %d",&a[i]);
	cnt[a[i]]++;
	}

	int ans=0;

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

	return 0;
}

Measured memory_bytes: 896
import java.util.*;
 
public class Main {
	Scanner sc = new Scanner(System.in);
	final int MOD = (int)1e9 + 7;
	final int MAX = Integer.MAX_VALUE;
	final long LMAX = Long.MAX_VALUE;
	int len = (int)1e7;
	
	
	long[] fac, finv, inv;
	void doIt() {
		comInit();
		int K = sc.nextInt();
		String S = sc.next();
		int N = S.length();
		long ans = 0l;
		for(int i = N - 1; i < K + N; i++) {
			int afterSn = K + N - 1 - i;
			long num = (modPow(25, K - afterSn) * modPow(26, afterSn)) % MOD;
			num = (num * modCom(N + K - afterSn - 1, N - 1)) % MOD;
			ans = (ans + num) % MOD;
		}
		System.out.println(ans);
	}
	
	long modPow(long a, long n) {
		long ans = 1;
		while(n > 0) {
			if((n & 1) == 1)
				ans = ans * a % MOD;
			a = a * a % MOD;
			n >>= 1;
		}
		return ans;
	}
	
	void comInit() {
		fac = new long[len];
		finv = new long[len];
		inv = new long[len];
		fac[0] = fac[1] = 1;
	    finv[0] = finv[1] = 1;
	    inv[1] = 1;
	    for (int i = 2; i < len; i++){
	        fac[i] = fac[i - 1] * i % MOD;
	        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
	        finv[i] = finv[i - 1] * inv[i] % MOD;
	    }
	}
	
	long modCom(int n, int k){
	    if (n < k) return 0;
	    if (n < 0 || k < 0) return 0;
	    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
 
}

Measured memory_bytes: 281680
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const ll mod=1e9+7;
const ll inf = (ll)1e17;
const ld eps = 1e-12;
const ld PI = 3.14159265358979323846;
ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}



int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    vector<ll>v(n);
    for(int i=0;i<n;i++)cin>>v[i];
    ll mini=1e9;
    ll res=0;
    for(int i=0;i<n;i++){
        if(i==0){
            res++;
            mini=v[i];
            continue;
        }
        if(v[i]<=mini)res++;
        mini=min(mini,v[i]);
    }
    cout<<res<<endl;
    return 0;
    }


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    string t;
    cin >> t;
    for(ll i = 0; i < t.size(); i++) {
        if(t[i] == '?') t[i] = 'D';
    }
    cout << t << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3744
#include <stdio.h>
#include <string.h>
int main(){
    char str1[11], str2[11], str3[11];
    scanf("%s %s %s", str1, str2, str3);

    if(str1[strlen(str1)-1] == str2[0] && str2[strlen(str2)-1] == str3[0]){
        puts("YES");
    } else{
        puts("NO");
    }


    return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
map<string,int>mp;
int n,s[100005];
long long ans;
char c[15];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%s",c+1);
		sort(c+1,c+11);
		mp[c+1]++;
		int k=mp[c+1];
		s[k-1]--;
		s[k]++;
	}
	for(int i=2;i<=n;++i){
		ans+=(1ll*(i)*(i-1)>>1)*s[i];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define pb push_back
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n,z,w;
	cin>>n>>z>>w;
	int a[n];
	for(int i= 0; i<n; i++) cin>>a[i];
	int g = abs(a[n-1]-w);
	int ans = 0;
	for(int i = 0; i<n; i++)
		a[i] = abs(a[n-1]-a[i]);
	cout<<max(g,a[n-2])<<endl;
	return 0;
}

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

int gcd(int x,int y){
	if(x<y){
      	int z=x;
      	x=y;
      	y=z;
    }
  	if(x%y==0){
      	return y;
    }
    else {
      	return gcd(y,x%y);
    }
}
   
int main(){
  	int k;
  	int sum=0;
  	int j;
  	cin>>k;
  
for(int a=1;a<(k+1);a++){
  	for(int b=1;b<(k+1);b++){
      	for(int c=1;c<(k+1);c++){
          	j=gcd(a,gcd(b,c));
            sum=sum+j;
        }
    }
}
  
cout<<sum<<endl;
  
}
  	

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(void){
  int n,l;
  cin >> n >> l;
  vector<string> input(n);
  for(int i=0;i<n;i++){
    cin >> input[i];
  }
  sort(input.begin(),input.end());
  for(int i=0;i<n;i++){
    cout << input[i];
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main
{
  public static void main (String args[]) throws Exception
  {
    Scanner cin = new Scanner(System.in);
    int a = cin.nextInt(), b = cin.nextInt();
    if((a*b)%2==0){
    	System.out.println("Even");
    }
    else{
    	System.out.println("Odd");
    }
  }
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int N = 1e5 + 5;

const int inf = 1e15;
int n, W, w[N], v[N], dp[105][N];

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> W;
    for(int i = 1; i <= n; i++)
        cin >> w[i] >> v[i];
    for(int i = 0; i < 105; i++) {
        for(int j = 0; j < N; j++)
            dp[i][j] = inf;
    }
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j < N; j++) {
            if(j - v[i] >= 0)
                dp[i][j] = min(dp[i - 1][j - v[i]] + w[i], dp[i][j]);
            dp[i][j] = min(dp[i][j], dp[i - 1][j]);
        }
    }
    for(int j = N - 1; j >= 0; j--) {
        if(dp[n][j] <= W) {
            cout << j;
            exit(0);
        }
    }
}


Measured memory_bytes: 82304
N = int(input())

def f(n):
    str_n = str(n)
    return (str_n[0], str_n[-1])

from collections import Counter
c = Counter()

for i in range(1, N+1):
    p = f(i)
    c[p] += 1

# for k in sorted(c.keys()):
#     print(k, c[k])

ans = 0
for i in range(1, N+1):
    p = f(i)
    p_ = (p[1], p[0])
    ans += c[p_]
print(ans)

Measured memory_bytes: 3436
#include<iostream>
#include<string>


using namespace std;

int main() {
	string s;
	string target("CODEFESTIVAL2016");

	cin >> s;

	int counter = 0;

	for (int i = 0; i < 16; i++) {
		if (s[i] != target[i]) {
			counter++;
		}
	}

	cout << counter << endl;
	return 0;

}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

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

void Main(){
  int n, q; cin >> n >> q;
  fenwick_tree<ll> fw(n);
  rep(i, n){
    ll a; cin >> a;
    fw.add(i, a);
  }
  while(q--){
    int t; cin >> t;
    if(t == 0){
      ll p, x; cin >> p >> x;
      fw.add(p, x);
    }else{
      int l, r; cin >> l >> r;
      cout << fw.sum(l, r) << endl;
    }
  }
  return;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 8244
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n); i++) 
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
typedef pair<int,int> P;
typedef long long ll;

int main() {
    ll a,b,n;
    cin >> a >> b >> n;
    ll x = min(n,b-1);
    cout << a*x/b << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int p = -1;
  for (int i = 0; i < int(s.size()) - int(t.size()) + 1; ++i) {
    int cnt = 0;
    for (int j = 0; j < int(t.size()); ++j)
      cnt += s[i+j] == '?' || s[i+j] == t[j];
    if (cnt == int(t.size()))
      p = i;
  }

  if (p == -1) {
    cout << "UNRESTORABLE" << endl;
  } else {
    for (int i = 0; i < p; ++i)
      cout << (s[i] == '?' ? 'a' : s[i]);
    cout << t;
    for (int i = p + int(t.size()); i < int(s.size()); ++i)
      cout << (s[i] == '?' ? 'a' : s[i]);
    cout << endl;
  }
}

Measured memory_bytes: 3608
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

const int L=2e5+10;
vector<int> children[L];
LL sum[L];
void dfs(int i, LL v){
	sum[i]+=v;
	for(auto c:children[i]){
		dfs(c,sum[i]);
	}
}
int main() {
	int N,Q;
	cin >> N >> Q;
	for(int i=1;i<N;i++){
		int a,b;
		cin >> a >> b;
		children[a].push_back(b);
	}
	for(int i=0;i<Q;i++){
		int p,x;
		cin >> p >> x;
		sum[p]+=x;
	}
	dfs(1,0);
	auto sp="";
	for(int i=1;i<=N;i++){
		cout << sp << sum[i];
		sp=" ";
	}
	cout << endl;


	return 0;
}



Measured memory_bytes: 21120
#include <sstream>
#include <iostream>
#include <string>
#include <algorithm>
#include <string.h>
using namespace std;

int main(){
	int m,n;
	while(cin>>m>>n,m){
		int num=m;
		int flag[1000]={0};
		int data[1000][2];
		for(int i=0;i<m;i++){
			data[i][0]=i-1;
			data[i][1]=i+1;
		}
		data[0][0]=m-1;
		data[m-1][1]=0;
		string s;
		int turn=0;
		for(int i=0;i<n;i++){
			cin>>s;
			int l=1;
			if((i+1)%15==0){
				if(s!="FizzBuzz")l=0;
			}else if((i+1)%3==0){
				if(s!="Fizz")l=0;
			}else if((i+1)%5==0){
				if(s!="Buzz")l=0;
			}else{
				ostringstream os;
				os<<(i+1);
				if(s!=os.str())l=0;
			}
			
			if(l==0){
				
				if(num>1){
					num--;
					flag[turn]=1;
					int bef=data[turn][0];
					int aft=data[turn][1];
					
					data[bef][1]=aft;
					data[aft][0]=bef;
				}
			}
			turn=data[turn][1];
		}
		int k=0;
		for(int i=0;i<m;i++){
			if(flag[i]==0){
				if(k)cout<<" ";
				cout<<i+1;
				k=1;
			}
		}
		cout<<endl;
		
	}
	
	
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl

template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T pow(T a,T b, long long m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }

const int N=1e5+5;

int n;
int t[N], x[N], y[N];

int32_t main()
{
    IOS;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
    	cin>>t[i]>>x[i]>>y[i];
    }
    for(int i=1;i<=n;i++)
    {
    	int xdist=abs(x[i]-x[i-1]);
    	int ydist=abs(y[i]-y[i-1]);
    	int tot=xdist+ydist;
    	int havetime=t[i]-t[i-1];
    	if(havetime<tot)
    	{
    		cout<<"No";
    		return 0;
    	}
    	if((tot-havetime)%2)
    	{
    		cout<<"No";
    		return 0;
    	}
    }
    cout<<"Yes";
    return 0;
}

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

int rev(int n) {
  int kuboshi = 0;
  int a = n % 10;
  n /= 10;
  int b = n % 10;
  n /= 10;
  int c = n % 10;
  n /= 10;
  int d = n % 10;
  n /= 10;
  int e = n;
  kuboshi = a*10000 + b*1000 + c*100 + d*10 + e;
  
  return kuboshi;
}
 
int main() {
  int bemiho,katoshi;
  int kosakana = 0;
  cin >> bemiho >> katoshi;
  for(int i = bemiho; i <= katoshi; i++) {
    int nibuchan = rev(i);
    if(i == nibuchan) {
      kosakana++;
    }
  }
  cout << kosakana << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	string s;
	
	cin>>s;
	
	int count = 0, ans= 0;
	
	for(int i = 0; i < s.size(); i++){
		ans = max(count,ans);
		if(s[i] == 'A' || s[i] == 'C' ||s[i] == 'G' || s[i] == 'T') count++;
		else count = 0;
		ans = max(count,ans);
	}
	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 256
// In god we trust

#include <bits/stdc++.h>
#include <chrono>
#include <algorithm>


#define pb push_back
#define fi first
#define se second
#define Vi vector<int>
#define Vb vector<bool>
#define Pi pair<int, int>
#define MP make_pair
#define MT make_tuple
#define INF 1000000000
#define int long long

using namespace std;
using namespace std::chrono;


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

  bool could = true;
  
  int c[m], d[m];

  for (int i = 0; i < m; i++){
    cin >> c[i] >> d[i];
  }
  
  for (int i = 0; i < m; i++){
    int a, b;
    a = c[i], b = d[i];
    a --;
    if (s[a] != 11 and s[a] != b){
      could = false;
      break;
    }
    s[a] = b;
  }
  
  if (s[0] == 0 and n != 1)
    could = false;
  
  for (int i = 0; i < n; i++)
    if (s[i] == 11){
      if (i == 0 and n != 1)
	s[i] = 1;
      else
	s[i] = 0;
    }

 
  if (could){
    for (int i = 0; i < n; i++)
      cout << s[i];
    cout << endl;
  }else
    cout << -1 << endl;

  
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	a, b, c, d := intScanner(), intScanner(), intScanner(), intScanner()
	if abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d) {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


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

bool checkP(int* w, long long P, int n, int k) { //trueはPが大きかった場合, falseはPが小さかった場合
    long long sum;
    int track = 0;
    
    sum = 0;
    int i = 0;
    while(i < n) {
        if(w[i] > P) {
            return false;
        }
        if(sum + w[i] > P) {
            sum = w[i];
            ++track;
        } else {
            sum += w[i];
        }
        ++i;
        if(track == k) {
            return false;
        }
    }
    
    return true;
}

int main(void) {
    int n, k;
    long long left, mid, right;
    int w[100000];

    cin >> n >> k;
    
    for(int i = 0; i < n; ++i) {
        cin >> w[i];
    }
    
    left = 0;
    right = 10000 * 100000;
    while(left + 1 < right) {
        mid = (left + right) / 2;

        if(checkP(w, mid, n, k)) {
            right = mid;
        } else {
            left = mid;
        }
    }
    
    cout << right << endl;
}


Measured memory_bytes: 3488
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)

int main(){
    //input
    int n;
    scanf("%d", &n);
    char s[303030];
    scanf("%s", s);

    //solve
    ll ans = 0, tmp = 0;
    rep(i, n){
        if(s[i] == 'W') tmp++;
    }
    int mx = 0;
    rep(i, n){
        if(s[i] == 'W') tmp--;
        if(i > 0 && s[i-1] == 'E') tmp++;
        mx = max(mx, tmp);
    }
    ans = n - mx - 1;

    //output
    printf("%lld", ans);
}

Measured memory_bytes: 2032
r,c=map(int,input().split())
a,b=[],[0]*c
for i in range(r):
    x=list(map(int,input().split()))
    print(*x, end=' ')
    print(sum(x))
    for j in range(c):
        b[j]+=x[j]
print(*b, end=' ')
print(sum(b))

Measured memory_bytes: 7708
#include <iostream>
#include <algorithm>
using namespace std;
int a[3];
int main()
{
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if (a[0] == a[1])
    {
        if (a[1] != a[2]) cout << "Yes";
        else cout << "No";
    }
    else if (a[1] == a[2])
    {
        cout << "Yes";
    }
    else
    cout << "No";
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner in = new Scanner(System.in);
        String a = in.next();
        String b = in.next();
        if(a.equals(b)){
            System.out.println("EQUAL");
        }else if(a.length()>b.length()){
            System.out.println("GREATER");
        }else if(a.length()<b.length()){
            System.out.println("LESS");
        }else{
            for(int i=0;i<a.length();i++){
                if(a.charAt(i)>b.charAt(i)){
                    System.out.println("GREATER");
                    return;
                }else if(a.charAt(i)<b.charAt(i)){
                    System.out.println("LESS");
                    return;
                }
            }
        }
    }
}


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

#define ll long long

using namespace std;

int costs[1005];
int masks[1005];

int st[15];

int dp[10500];

const int inf = 1e9;

int main()
{
    int n,m,x,y;
    st[0] = 1;
    for(int i = 1; i <= 10000; i++) dp[i] = inf;
    for(int i = 1; i <= 14; i++) st[i] = st[i - 1] * 2;
    cin >> n >> m;
    for(int i = 1; i <= m; i++)
    {
        cin >> costs[i];
        cin >> x;
        int mask = 0;
        for(int j = 0; j < x; j++)
        {
            cin >> y;
            mask += st[y - 1];
        }
        masks[i] = mask;
    }
    int need = 0;
    for(int i = 0; i < n; i++) need += st[i];
    for(int i = 1; i <= m; i++)
    {
        for(int j = 0; j <= need; j++)
        {
            if(dp[j] != inf)
            {
                dp[j | masks[i]] = min(dp[j | masks[i]], dp[j] + costs[i]);
            }
        }
    }
    if(dp[need] == inf) cout << -1;
        else cout << dp[need];
}


Measured memory_bytes: 256
#!/usr/bin/env python3

from bisect import bisect_left, bisect_right
from pprint import pprint
from collections import deque, defaultdict
import itertools
import math
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
INF = float('inf')

n_blocks = int(input())
blocks_top = sorted(list(map(int, input().split())))
blocks_middle = sorted(list(map(int, input().split())))
blocks_bottom = sorted(list(map(int, input().split())))
# pprint(blocks_top)
# pprint(blocks_middle)
# pprint(blocks_bottom)

res = 0
for middle in blocks_middle:
    index_top = bisect_left(blocks_top, middle)
    index_bottom = bisect_right(blocks_bottom, middle)
    # print(f"middle = {middle}")
    # print(f"index_top = {index_top}")
    # print(f"index_bottom = {index_bottom}\n")
    res += index_top * (n_blocks - index_bottom)

print(res)


Measured memory_bytes: 78780
k=int(input())
if k%2==0:
    print (-1)
else:
    from collections import Counter
    c=Counter([])
    ans=1
    n=7%k
    flag=1
    while 1:
        if n==0:
            break
        if c[n]>=1:
            ans=-1
            break
        else:
            c[n]+=1
            n=(n*10+7)%k
            ans+=1
    print (ans)

Measured memory_bytes: 93112
import std.stdio, std.algorithm, std.conv, std.array, std.string;

void main()
{
    auto N = readln.chomp.to!long;

    foreach (h; 1..3501) {
        foreach (n; 1..3501) {
            auto c = N * h * n;
            auto m = 4 * h * n - N * h - N * n;
            if (m <= 0) continue;
            if (c % m == 0) {
                writefln("%s %s %s", h, n, c / m);
                return;
            }
        }
    }
}

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

// using mint = modint1000000007;
// using mint = modint998244353;

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) std::cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << '\n';
}

void solve() {
    Int n;
    cin >> n;
    vector<pair<Int, Int>> v(n);
    for (Int i = 0; i < n; i++) {
        cin >> v[i].first >> v[i].second;
    }
    Int cnt = 0;
    for (Int i = 0; i < n; i++) {
        if (v[i].first == v[i].second) {
            cnt++;
        } else {
            cnt = 0;
        }
        if (cnt >= 3) {
            print("Yes");
            return;
        }
    }
    print("No");
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3580
#include <functional>
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#include <string>
#include <cstring>
#include <math.h>
using namespace std;


int main() {
   int n;
   int m;
  
   cin >> n >> m;
   int nm = m-n;
  
   if(nm%2==0){
     
     int han = nm/2;
     
     if(n<m){
       cout << n+abs(han) << endl;
     }else{
       cout << m+abs(han) << endl;
     }
     
   }else{
     cout << "IMPOSSIBLE" << endl;
   }
   
   
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,t;

	int sum=0;
	double i;
	cin>>a>>b>>t;
		double n=t+0.5;
	for(i=1;i<=n/(a*1.0);i++)
	{
		sum=sum+b;
	}
	cout<<sum; 
	return 0;
}

Measured memory_bytes: 256
import sys


def solve():
    a = read()
    result = think(a)
    write(result)


def read():
    h, w = read_int(2)
    a = []
    for y in range(h):
        a.append(read_line(n=w))
    return a


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a):
    mode = 10 ** 9 + 7
    wall_symbol = '#'

    h = len(a)
    w = len(a[0])

    ways_count_to_get = [[0 for x in range(w)] for y in range(h)]
    ways_count_to_get[0][0] = 1

    for y in range(h):
        for x in range(w):
            if x == 0 and y == 0:
                continue
            if x == 0:
                if a[y][x] == wall_symbol:
                    continue
                else:
                    ways_count_to_get[y][x] = ways_count_to_get[y - 1][x]
                    continue
            if y == 0:
                if a[y][x] == wall_symbol:
                    continue
                else:
                    ways_count_to_get[y][x] = ways_count_to_get[y][x - 1]
                    continue
            if a[y][x] == wall_symbol:
                ways_count_to_get[y][x] = 0
            else:
                ways_count_to_get[y][x] = (ways_count_to_get[y - 1][x] + ways_count_to_get[y][x - 1]) % mode

    return ways_count_to_get[h - 1][w - 1]


def write(result):
    print(result)


if __name__ == '__main__':
    sys.setrecursionlimit(1000 * 1000)
    solve()

Measured memory_bytes: 53980
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;

static const int INFTY = (1 << 29);

int MinCoin(int n, int m, int c[]) {
	int T[50004];//T[n]?????????n??????????????????????????????????????????????°??????°
	for (int i = 1;i <= n;i++) T[i] = INFTY;
	T[0] = 0; //0?????????????????????0?????§OK
	for (int i = 0;i < m;i++) {
		for (int j = 0;j +c[i]<=n;j++) {
			T[j+c[i]] = min(T[j+c[i]], T[j] + 1);
		}
	}
	return T[n];
}

int main() {
	int n, m, c[21];
	cin >> n >> m;
	for (int i = 0;i <= m - 1;i++) {
		cin >> c[i];
	}

	cout << MinCoin(n,m,c) << endl;
	return 0;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

string ans[] = { "thu", "fri", "sat", "sun", "mon", "tue", "wed" };

int main() {
    int x;
    cin >> x;
    cout << ans[x%7] << endl;
}

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

int main(void){
	while(1){
		char n[9];
		int i, index, c[3] = {0};
		double min = 1000, d;
	
		scanf(" %s", n);
		if(strcmp(n, "0") == 0) break;
		
		for(i=0; i<3; i++){
			if(n[2*i+1] <= '9') c[i] += 16*(n[2*i+1]-'0');
			else c[i] += 16*(n[2*i+1]-'a'+10);
			
			if(n[2*i+2] <= '9') c[i] += n[2*i+2]-'0';
			else c[i] += n[2*i+2]-'a'+10;
		}
		
		/*for(i=0; i<3; i++)
			printf("%d ", c[i]);*/
		
		for(i=0; i<8; i++){
			int p;
			if(i%4==0 || i%4==1) p=0;
			else p=1;
		
			d=sqrt( pow(c[0]-(i/4)*255, 2) + pow(c[1]-p*255, 2) + pow(c[2]-(i%2)*255, 2) );
			if(min > d){
				min = d;
				index = i;
			}
		}
		
		if(index==0) printf("black\n");
		else if(index==1) printf("blue\n");
		else if(index==2) printf("lime\n");
		else if(index==3) printf("aqua\n");
		else if(index==4) printf("red\n");
		else if(index==5) printf("fuchsia\n");
		else if(index==6) printf("yellow\n");
		else if(index==7) printf("white\n");

	}

	return 0;
}

Measured memory_bytes: 520
#include<stdio.h>
#include<math.h>
#define pi 3.1415926535897932384
#define eps 1.0e-10

double dbmax(double a,double b){if(a>b){return a;}return b;}

int main(){
  double a,b,h,m,dg;
  scanf("%lf%lf%lf%lf",&a,&b,&h,&m);
  dg=fabs(m*6.0-(h*60.0+m)*0.5);
  dg/=360.0;dg*=(2.0*pi);
  //printf("%.12lf\n",dg);
  if(dg>pi){dg=2*pi-dg;}
  //printf("%.12lf\n",dg);
  if(fabs(pi-dg)<eps){printf("%.12lf\n",a+b);return 0;}
  printf("%.12lf\n",fabs(sqrt(a*a+b*b-2.0*a*b*cos(dg))));
}


Measured memory_bytes: 2664
#lang racket

(define (square x)
  (* x x))

(define mod 1000000007)

(define (pow b n)
  (cond ([= n 0] 1)
        ([even? n] [modulo (square (pow b (/ n 2))) mod])
        (else [modulo (* b (pow b (- n 1))) mod])))


(define (solve N K)
  (let ([table (make-vector (+ K 1) 0)])
    (define (j-iter j total step)
      (if (> j K)
          (modulo total mod)
          (j-iter (+ j step) (- total (vector-ref table j)) step)))
    (define (iter i total)
      (if (zero? i)
          (modulo total mod)
          (begin
            (vector-set! table i (pow (floor (/ K i)) N))
            (let ([j (j-iter (* i 2) (vector-ref table i) i)])
              (vector-set! table i j)
              (iter (- i 1) (modulo (+ total (* i j)) mod))))))
    (iter K 0)))

(let* ([N (read)]
       [K (read)])
       (display (solve N K)))

Measured memory_bytes: 98164
mod = 10**9+7
import sys
from collections import Counter, defaultdict, deque
from itertools import product, permutations, combinations
from itertools import accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from math import ceil,floor
from copy import deepcopy
from heapq import heappop,heappush,heapify
import heapq


sys.setrecursionlimit(10 ** 6)

int1 = lambda x: int(x) - 1

# リストの要素を改行を挟んで表示する
p2D = lambda x: print(*x, sep="\n")
# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())

def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())

# 入力全てを整数に変換したものの配列を受け取る
# def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]


def LI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))
def HI(): return list(map(lambda x:int(x)*(-1), sys.stdin.readline().split()))


x,y,z = MI()
print(z,x,y)

Measured memory_bytes: 38256
import bisect
N = int(input())
A = list(map(int, input().split()))
A.sort()
ai = A[-1]

tmp = ai / 2
i = bisect.bisect_left(A, tmp)
if abs(tmp - A[i]) < abs(tmp - A[i - 1]):
    print(ai, A[i])
else:
    print(ai, A[i - 1])

Measured memory_bytes: 14052
#include <iostream>
#include <cstring>
#include <map>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <set>
#include <vector>
#include <queue>
#include <list>
#include <numeric>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <math.h>
#include <stack>
#include <climits>
#include <bitset>
#include <utility>


using namespace std;
typedef long long ll;
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; }
// const ll INF = 1LL <<60;
const int INF = 10000;

//最小公倍数
ll gcd(ll x, ll y) {
  ll tmp = 0;
  if (x < y){
    tmp=x;
    x=y;
    y=tmp;
  }
  while (y > 0) {
    ll r = x % y;
    x = y;
    y = r;
  }
  return x;
}

//最大公倍数
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}

//階乗
ll kaijo(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum *= i;
        sum%=1000000000+7;
    }
    return sum;
}

//for(int i = ; i < ; i++){}

ll lmax(ll s,ll t){
  if(s>t){
    return s;
  }
  else{
    return t;
  }
}

ll lmin(ll s,ll t){
  if(s<t){
    return s;
  }
  else{
    return t;
  }
}
// ここから開始

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a==b){
    if(a==c) cout<<1<<endl;
    else cout<<2<<endl;
  }
  else{
    if(a==c) cout<<2<<endl;
    else if(b==c) cout<<2<<endl;
    else cout<<3<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int r; cin >> r;
	string ans;
	if (r<1200) ans = "ABC";
	else if(r<2800) ans = "ARC";
	else ans = "AGC";

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n][n];
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cin>>a[i][j];
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            bool maki=true;
            for(int k=0;k<n;k++){
                if(i==k||j==k)continue;
                if(a[i][j]>a[i][k]+a[k][j]){
                    cout << -1<<endl;
                    return 0;
                }else if(a[i][j]==a[i][k]+a[k][j])maki=false;
            }
            if(maki)ans+=a[i][j];
        }
    }
    cout << ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <cstdio>
#include <set>

long long f[201000], g[201000];
std::multiset<int> st;
std::multiset<int>::iterator it;
long long a[201000], b[201000];

int Abs(int x) {return x > 0 ? x : -x;}

int get(int i, int t)
{
	if(st.empty()) return Abs(t - i);
	it = st.end(); --it;
	int x = *it;
	st.erase(it);
	return Abs(x - i); 
}

int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	{
		scanf("%lld", &a[i]);
		b[i] = a[i] * -2;
	}
	for(int i = 1; i <= n; i++)
	{
		f[i] = f[i - 1] + 1;
		if(i == 1) continue;
		while(b[i] < b[i - 1])
		{
			b[i - 1] *= 4;
			f[i] += 2 * get(i, 1);
		}
		long long B = b[i];
		b[i] *= 4;
		while(b[i] >= b[i - 1])
		{
			b[i] *= 4;
			st.insert(i); 
		}
		b[i] = B;
	}
	st.clear();
	for(int i = n; i >= 1; i--)
	{
		g[i] = g[i + 1];
		if(i == n) continue;
		while(a[i] > a[i + 1])
		{
			a[i + 1] *= 4;
			g[i] += 2 * get(i, n);
		}
		long long A = a[i];
		a[i] *= 4;
		while(a[i] <= a[i + 1])
		{
			a[i] *= 4;
			st.insert(i); 
		}
		a[i] = A;
	}
	long long ans = 1e18;
	for(int i = 0; i <= n; i++)
	{
		ans = std::min(ans, f[i] + g[i + 1]);
	}
	printf("%lld\n", ans);
	return 0;
}

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

int main()
{
    int r,g,b; cin >> r >> g >> b;
    puts((r*100+g*10+b)%4==0?"YES":"NO");
}

Measured memory_bytes: 256
n = gets.to_i
p = gets.chomp.split(" ").map(&:to_i)
ans = 0
for i in 0..n-2
  if p[i] == i+1
    p[i..i+1] = p[i+1],p[i]
    ans += 1
  end
end
if p[-1] == n
  ans += 1
end
puts ans

Measured memory_bytes: 11268
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 2e5 + 10;

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	int n;
	cin >> n;
	int k;
	cin >> k;
	int a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	bool dp[k + 1] = {0};
	for(int i = 0; i <= k; i++) {
		if(!dp[i]) {
			for(int j = 0; j < n; j++) {
				if(i + a[j] <= k) {
					dp[i + a[j]] = 1;
				}
			}
		}
	}
	if(dp[k]) {
		cout << "First";
	}
	else {
		cout << "Second";
	}

	return 0;
}

Measured memory_bytes: 3700
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define MAX_N 100000
#define MAX_P 200005
ll fact[MAX_P];
ll extgcd(ll a,ll b,ll& x,ll& y){
  ll d=a;
  if(b!=0){
    d=extgcd(b,a%b,y,x);
    y-=(a/b)*x;
  }else{
    x=1;y=0;
  }
  return d;
}
ll mod_inverse(ll a,ll m){
  ll x,y;
  extgcd(a,m,x,y);
  return (m+x%m)%m;
}

ll euler_phi(ll n){
  ll res=n;
  for(ll i=2;i*i<=n;i++){
    if(n%i==0){
      res=res/i*(i-1);
      for(;n%i==0;n/=i);
    }
  }
  if(n!=1) res=res/n*(n-1);
  return res;
}

ll euler[MAX_N];

void euler_phi2(){
  for(ll i=0;i<MAX_N;i++) euler[i]=i;
  for(ll i=2;i<MAX_N;i++){
    if(euler[i]==i){
      for(int j=i;j<MAX_N;j+=i) euler[j]=euler[j]/i*(i-1);
    }
  }
}


ll mod_pow(ll x,ll n,ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*x%mod;
    x=x*x%mod;
    n>>=1;
  }
  return res;
}

void init(ll p){
  fact[0]=1;
  for(ll i=1;i<MAX_P;i++) fact[i]=(fact[i-1]*i)%p;
}

ll mod_fact(ll n,ll p,ll& e){
  e=0;
  if(n==0) return 1;
  ll res=mod_fact(n/p,p,e);
  e+=n/p;
  if(n/p%2!=0)return res*(p-fact[n%p]) %p;
  return res*fact[n%p]%p;
} 
ll mod_comb(ll n,ll k,ll p){
  if(n==k||k==0) return 1;
  ll e1,e2,e3;
  ll a1=mod_fact(n,p,e1),a2=mod_fact(k,p,e2),a3=mod_fact(n-k,p,e3);
  if(e1>e2+e3) return 0;
  return a1*mod_inverse(a2*a3%p,p)%p;
}

int main(){
  init(MOD);
  int n;
  cin>>n;
  cout<<fact[n]<<endl;
  return 0;
}


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

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

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

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=2019;

int main(){
    int x; cin >> x;
    cout << (x>=30 ? "Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
const int MOD = 1e9 + 7;	
#define LL long long
int n;
LL dp1[N],dp2[N],ans;
inline LL qpow(LL a,int x) {
	LL res = 1;
	for(;x;x >>= 1) (x & 1) && (res = res * a % MOD),a = a * a % MOD;
	return res;
}
int main() {
	scanf("%d",&n);
	dp1[1] = dp2[n] = 0;
	for(int i = 2;i <= n;++i)
		dp1[i] = (dp1[i-1] * 9 % MOD + qpow(8,i-2)) % MOD;
	for(int i = n-1;i >= 1;--i)
		dp2[i] = (dp2[i+1] * 10 % MOD + qpow(9,n-i-1)) % MOD;
	for(int i = 1;i <= n;++i)
		(ans += (dp1[i] * qpow(10,n-i) % MOD + dp2[i] * qpow(8,i-1) % MOD) % MOD) %= MOD;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 19376
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/priority_queue.hpp>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using pi = pair<int, int>;
using pll = pair<ll, ll>;
constexpr int INF = 0x3f3f3f3f; constexpr ll LLINF = 0x3f3f3f3f3f3f3f3f;
#define db(x) { cerr << #x << " = " << x << endl; }
template <typename T> void _dbarr(T* a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
template <typename T> void _dbarr(vector<T> a, size_t sz){ for(int i = 0; i < sz; i++) cerr << a[i] << " \n"[i == sz-1]; }
#define dbarr(x, n) {cerr << #x << ": "; _dbarr((x),(n));}
#define all(x) begin(x), end(x)
#define pb push_back
#define eb emplace_back
#define mpr make_pair
#define fs first
#define sn second

int main(){
	cin.tie(0)->sync_with_stdio(0);
	//freopen("in.txt","r", stdin);
    string s,t;
    cin >> s >> t;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        ans += (s[i] != t[i]);
    }
    cout << ans << "\n";
}


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

int main()
{
  int n;
  cin >> n;
  vector<int> l(n);
  int sum{0};
  for (auto i = 0; i < n; i++) {
    cin >> l[i];
    sum += l[i];
  }
  sort(begin(l), end(l), greater<>());
  sum -= l[0] * 2;
  cout << (sum > 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

#define mod ((ull)1e9+7)
#define MAX ((ull)1e9)

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

	ll x[n];
	cin >> x[0];
	ll sx=x[0], dx=0;
	for(int i=1; i<n; i++){
		cin >> x[i];
		dx+=i*x[i]-sx;
		sx+=x[i];
		dx%=mod;
	}

	ll y[m];
	cin >> y[0];
	ll sy=y[0], dy=0;
	for(int i=1; i<m; i++){
		cin >> y[i];
		dy+=i*y[i]-sy;
		sy+=y[i];
		dy%=mod;
	}

	cout << dx*dy%mod << endl;
	return 0;
}

Measured memory_bytes: 1792
using System;
using static System.Console;

namespace AtCoderGrandContest030
{
	class A
	{
		static void Main(string[] args)
		{
			string[] inputs = ReadLine().Split(' ');
			int A = int.Parse(inputs[0]);
			int B = int.Parse(inputs[1]);
			int C = int.Parse(inputs[2]);

			if(A+B >= C)
				WriteLine(B+C);
			else
				WriteLine(2*B+A+1);
		}
	}
}


Measured memory_bytes: 13140