akhauriyash/Code-Regression huggingface dataset:
def check(a,b):
    distance = abs(a[1]-b[1]) + abs(a[2]-b[2])
    time = abs(b[0]-a[0])
    
    c = time - distance
    if((c >= 0) and (c%2==0)):
        return 0
    else:
        return 1
    

def main():
    n = int(input())
    plan = [list(map(int, input().split())) for i in range(n)]
    if(check([0,0,0],plan[0])==1):
        print("No")
        return
    
    flag = 0
    for i in range(n-1):
        flag += check(plan[i],plan[i+1])
        if (flag >0):
            break
    
    if (flag == 0):
        print("Yes")
    else:
        print("No")
main()

Measured memory_bytes: 27380
sx, sy, tx, ty = gets.split.map(&:to_i)
xd = tx - sx
yd = ty - sy

print 'R' * xd , 'U' * yd + 'L' * xd + 'D' * yd
print 'D', 'R' * (xd + 1), 'U' * (yd + 1), 'L'
print 'U', 'L' * (xd + 1), 'D' * (yd + 1), 'R'
print "\n"

Measured memory_bytes: 3836
# D - XXOR

import sys
readline = sys.stdin.readline

N, K = map(int, readline().split())
A = list(int(x) for x in readline().split())

bits = [0] * 50
for i in range(N):
    for j in range(50):
        if A[i]>>j&1:
            bits[j] += 1

# tmp_K: Kの上からi桁目に応じて加算する
# tmp_greed: Kの上からi桁目が1だったら、
# i桁目を0にしてi+1桁目以降を貪欲に選んだケースを試す
ans = 0
tmp_K = 0
tmp_greed = 0
for i in range(50)[::-1]:
    if K>>i&1:
        tmp_greed = bits[i] * 1<<i
        for j in range(i)[::-1]:
            tmp_greed += max(bits[j], N-bits[j]) * 1<<j
        ans = max(tmp_greed + tmp_K, ans)
        tmp_K += (N-bits[i]) * 1<<i
    else:
        tmp_K += bits[i] * 1<<i

ans = max(ans, tmp_K)
print(ans)

Measured memory_bytes: 14688
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    println!("{}", n * 800 - (n / 15) * 200);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

int main()
{
    int v, s, a, b, c, min_v;
    int d[10][10];
    
    while(cin >> s, s)
    {
        v = 1, min_v = 0;        
        for(int i = 0; i < 10; ++i)
            for(int j = 0; j < 10; ++j)
                if(i == j)  d[i][j] = 0;
                else        d[i][j] = 100000000;
        
        for(int i = 0; i < s; ++i)
        {
            cin >> a >> b >> c;
            d[a][b] = d[b][a] = c;
            v = max(a + 1, max(b + 1, v));
        }
        
        for(int k = 0; k < v; ++k)
            for(int i = 0; i < v; ++i)
                for(int j = 0; j < v; ++j)
                    d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
        
        for(int i = 0; i < v; ++i)
            for(int j = 1; j < v; ++j)
                d[i][0] += d[i][j];
        
        for(int i = 1; i < v; ++i)
            if(d[i][0] < d[min_v][0])
                min_v = i;
        
        cout << min_v << ' ' << d[min_v][0] << endl;
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
const int N=1e4+5;
int n,a[N],i,j,x;
vector<int>ans;
bool b[N];
inline void ck(int p){
	static int b[N];int i;
	for(i=0;i<=n;++i)b[i]=(a[i]%p+p)%p;
	for(i=n;i>=p;--i)b[i-p+1]=(b[i-p+1]+b[i])%p;
	for(;i>=0;--i)if(b[i]%p)return;
	ans.push_back(p);
}
int main(){
	scanf("%d",&n);
	for(i=n;i>=0;--i)scanf("%d",a+i),x=__gcd(x,abs(a[i]));
	for(i=2;i*i<=x;++i)if(x%i==0)for(ans.push_back(i);x%i==0;x/=i);
	if(x>1)ans.push_back(x);
	for(i=2;i<N;++i)if(!b[i])for(j=i*2;j<N;j+=i)b[j]=1;
	for(i=2;i<=n+1;++i)if(!b[i])ck(i);
	sort(ans.begin(),ans.end());ans.erase(unique(ans.begin(),ans.end()),ans.end());
	for(int i:ans)printf("%d\n",i);		
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main( ){

  int A[100],i,minj,N,a,count=0,j;


  scanf("%d",&N);

  for(i=0;i<N;i++){

    scanf("%d",&A[i]);

  }


  for(i=0;i<N;i++){

    minj=i;

    for(j=i;j<N;j++){

      if(A[j]<A[minj]) minj=j;
    }

      a=A[i];
      A[i]=A[minj];
      A[minj]=a;

      if(minj != i) count++;   
    
  }

  for(i=0;i<N;i++){
  
    if(i==N-1) printf("%d\n%d\n",A[i],count);
    else printf("%d ",A[i]);
  }

  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

int five[5];
const int winner[4][2] = {{0, 0}, {2, 3}, {3, 1}, {1, 2}};

int main() {
	while(1) {
		cin >> five[0];
		if(!five[0]) break;
		for(int i = 1; i < 5; ++i) {
			cin >> five[i];
		}

		int f[4];
		memset(f, 0, sizeof f);
		for(int i = 0; i < 5; ++i) {
			int t = five[i];
			f[t]++;
		}
		if(f[1] && f[2] && f[3]) {
			for(int i = 0; i < 5; i++) {
				cout << 3 << endl;
			}
			goto NEXT;
		}
		for(int i = 1; i <= 3; ++i) {
			if(f[i] == 5) {
				for(int j = 0; j < 5; ++j) {
					cout << 3 << endl;

				}
				goto NEXT;
			}
		}
		for(int i = 1; i <= 3; ++i) {
			if(f[i] == 0) {
				for(int j = 0; j < 5; ++j) {
					if(winner[i][0] == five[j]) {
						cout << 1 << endl;
					} else {
						cout << 2 << endl;
					}
				}
			}
		}
		NEXT:
		;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define EACH(i, a) for (auto i: a)
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define veccat(v1, v2) std::copy((v2).begin(),(v2).end(),std::back_inserter(v1)/*v1の後ろにv2を入れる*/)
#define intmax (std::numeric_limits<int64_t>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);



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

	string s;
	cin >> s;
	int ans = intmax;
	rep(i, 26) {
		char A = char(i) + 'a';
		vector<int>pos;
		pos.push_back(-1);
		rep(j, s.size()) {
			if (s[j] == A)pos.push_back(j);
		}
		pos.push_back(s.size());
		int haba = 0;
		REP(j, 1, pos.size()) {
			haba = max(haba, pos[j] - pos[j - 1] - 1);
		}
		ans = min(ans, haba);
	}
	cout << ans << endl;


	return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) * b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

//////////////////////////////////////

int main() {
	ll N;
	cin >> N;
	cout << (N - 1) / 1000 * 1000 + 1000 - N << endl;

}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
const ll mod = 1000000007;
 
void testCase() {
    string s;
    cin >> s;
    if (s[2]==s[3] && s[4]==s[5])
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
 
int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
int ans=0;
int i,j;
int mem[5000][5000];
string s,w;
int x=0,y=0;
lol a,b,c,d;
string an(int g,int h){
    if(g<=0||h<=0) return "";
    if(mem[g][h]==mem[g-1][h]) return an(g-1,h);
    if(mem[g][h]==mem[g][h-1]) return an(g,h-1);
    return an(g-1,h-1)+s[g];
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >>s>>w;
    i=s.size(),j=w.size();
    ans=0;
    s=' '+s,w=' '+w;
    for(int n=1;n<=i;n++){
	for(int m=1;m<=j;m++){
	    if(s[n]==w[m]) mem[n][m]=mem[n-1][m-1]+1;
	    else mem[n][m]=max(mem[n-1][m-1],max(mem[n-1][m],mem[n][m-1]));
	    if(ans<mem[n][m]) ans=mem[n][m],x=n,y=m;
	}
    }
    cout <<an(i,j)<<'\n';
    return (0);
}


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

int main() {
  int N;
  int x = 0;
  int ans = 0;
  string s;
  cin >> N >> s;
  rep(i, 0, N) {
    if (s[i] == 'I') {
      x++;
    } else {
      x--;
    }
    ans = max(ans, x);
  }
  cout << ans << endl;
  getchar();
}

Measured memory_bytes: 3600
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int main() {

	int n, m;
	scanf("%d%d", &n, &m);
	int ans = 1;
	for (int x = 1; x * x <= m; ++x)
		if (m % x == 0) {
			if (m / x >= n)
				ans = max(ans, x);
			if (x >= n)
				ans = max(ans, m / x);
		}
			printf("%d\n", ans);

	return 0;
}


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


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

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

int main() {
    #ifdef TooLazy
        freopen("A.txt", "r", stdin);
    #endif /// TooLazy

    ll a, b, c, flag = 0;
    cin >> a >> b >> c;

    for(ll i=1; i<=1000; i++) {
        ll x = i * a;
        if(x%b==c) {
            cout << "YES\n";
            exit(0);
        }
    }

    cout << "NO\n";

    return 0;

}


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

typedef long long ll;
const int MOD=1e9+7;

struct modint {
    int val;
    modint inv() const{
        int tmp,a=val,b=MOD,x=1,y=0;
        while(b)tmp=a/b,a-=tmp*b,swap(a,b),x-=tmp*y,swap(x,y);
        return modint(x);
    }
public:
    modint():val(0){}
    modint(ll x){if((val=x%MOD)<0)val+=MOD;}
    modint pow(ll t){modint res=1,b=*this; while(t){if(t&1)res*=b;b*=b;t>>=1;}return res;}
    modint& operator+=(const modint& x){if((val+=x.val)>=MOD)val-=MOD;return *this;}
    modint& operator-=(const modint& x){if((val+=MOD-x.val)>=MOD)val-=MOD; return *this;}
    modint& operator*=(const modint& x){val=(ll)val*x.val%MOD; return *this;}
    modint& operator/=(const modint& x){return *this*=x.inv();}
    bool operator==(const modint& x) const{return val==x.val;}
    bool operator!=(const modint& x) const{return val!=x.val;}
    bool operator<(const modint& x) const{return val<x.val;}
    bool operator<=(const modint& x) const{return val<=x.val;}
    bool operator>(const modint& x) const{return val>x.val;}
    bool operator>=(const modint& x) const{return val>=x.val;}
    modint operator+(const modint& x) const{return modint(*this)+=x;}
    modint operator-(const modint& x) const{return modint(*this)-=x;}
    modint operator*(const modint& x) const{return modint(*this)*=x;}
    modint operator/(const modint& x) const{return modint(*this)/=x;}
};

struct factorial {
    vector<modint> Fact, Finv;
public:
    factorial(int _n): Fact(_n+1), Finv(_n+1) {
        Fact[0]=modint(1); for (int i = 0; i < _n; ++i) Fact[i+1]=Fact[i]*(i+1);
        Finv[_n]=modint(1)/Fact[_n]; for (int i = _n; i > 0; --i) Finv[i-1]=Finv[i]*i;
    }
    modint fact(int n,bool inv=0) { if (inv) return Finv[n]; else return Fact[n]; }
    modint nPr(int n,int r){ if (n<0||n<r||r<0) return modint(0); else return Fact[n]*Finv[n-r]; }
    modint nCr(int n,int r){ if (n<0||n<r||r<0) return modint(0); else return Fact[n]*Finv[r]*Finv[n-r]; }
};

// int main() {
//   // 6C3 % (1e9+7) = 20
//   cout << "6C3: " << fact.nCr(6,3).val << endl;
//   // 666C390 % (1e9+7) = 9951876
//   cout << "666C390: " << fact.nCr(666,390).val << endl;
// }


int main() {
  ll n, m, k;
  cin >> n >> m >> k;
  factorial fact(1000010);
  modint ans = 0;
  for (int i = 1; i < m; ++i) {
    modint tmp(n);
    tmp *= n;
    tmp *= i;
    tmp *= (m-i);
    ans += tmp;
  }
  for (int i = 1; i < n; ++i) {
    modint tmp(m);
    tmp *= m;
    tmp *= i;
    tmp *= (n-i);
    ans += tmp;
  }
  ans *= fact.nCr(n*m-2, k-2);
  cout << ans.val << endl;
}



Measured memory_bytes: 8064
#include <iostream>
#include <vector>

using std::cin;
using std::cout;
using std::endl;

using std::vector;

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

    int a[4];
    a[0] = n % 10;
    a[1] = (n / 10) % 10;
    a[2] = (n / 100) % 10;
    a[3] = (n / 1000) % 10;

    bool good = (a[0] == a[1] && a[1] == a[2]) || (a[1] == a[2] && a[2] == a[3]);
    cout << (good ? "Yes" : "No") << endl;

    return 0;
}



Measured memory_bytes: 888
program sample
    implicit none
    character(200000)::s,t
    integer(8) :: i,j,k,m,n
    integer(8)::a,b,c,d
    integer(8),allocatable::x(:),y(:)
  
    read(*,*) s
    m=0
    n=len_trim(s)
    do i=1,n
        read(s(i:i),*)a
        m=m+a
    end do
    if(mod(m,9)==0)then
        write(*,*)'Yes'
    else
        write(*,*)'No'
    end if

    stop
end program sample
  



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

int main(){
  // input
  int D;
  cin >> D;
  int c[26];
  rep(i,26) cin >> c[i];
  int s[D+1][26];
  rep(i,D) rep(j,26) cin >> s[i+1][j];
  int t[D+1];
  rep(i,D) {
    cin >> t[i+1];
    t[i+1]--;
  }
  int m;
  cin >> m;
  int d[m], q[m];
  rep(i,m) {
    cin >> d[i] >> q[i];
    q[i]--;
  }
  
  // define parameter
  int last[D+1][26];
  rep(i,D+1) rep(j,26) last[i][j] = 0;
  
  // calculate initial content
  int content = 0;
  for(int day = 1; day <= D; day++) {
    content += s[day][t[day]];
    rep(kind,26) {
      if(kind == t[day]) last[day][kind] = day;
      else last[day][kind] = last[day-1][kind];
      content -= c[kind] * (day - last[day][kind]);
    }
  }

  // query 
  rep(id,m) {
    content += s[d[id]][q[id]] - s[d[id]][t[d[id]]];
    int cur = d[id];
    while(cur <= D && last[cur][t[d[id]]] == d[id]) {
      content -= c[t[d[id]]] * (d[id] - last[cur-1][t[d[id]]]);
      last[cur][t[d[id]]] = last[cur-1][t[d[id]]];
      cur++;
    }
    cur = d[id];
    while(cur <= D && last[cur][q[id]] < d[id]) {
      content += c[q[id]] * (d[id] - last[cur][q[id]]);
      last[cur][q[id]] = d[id];
      cur++;
    }
    t[d[id]] = q[id];
    cout << content << endl;
  }
  return 0;
}


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

int main(void) {
	std::string str;
	std::getline(std::cin, str);
	const char* c = str.data();
	int res = 0;
	for (int i = 0; i < str.length(); i++) {
		if (c[i] == '1') {
			res++;
		}
	}
	std::cout << res;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>
#include <cmath>
#define INF 100000000
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; }

using namespace std;

int main(){
  int i,j,k,n,y,d,flag=0;

  cin >> n>> y;

  for(i=0;i<=n;i++){
    if(flag)break;
    for(j=0;i+j<=n;j++){
      k=n-i-j;
      if(k<0)continue;

      if(i*10000+j*5000+k*1000==y){
	cout << i<< " "<<j<< " "<<k<<endl;
	flag=1;
	continue;
      }
    }
  }

  if(flag==0) cout << -1<< " "<<-1<< " "<<-1<<endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
int main(){
  long long n,k;
  cin>>n;
  k=(int)sqrt(n);
  for(int i=0;i<k;i++){
    if(n%(k-i)==0){
      cout<<n/(k-i)+(k-i)-2<<endl;
      return 0;
    }
  }
}

 
  


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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back
#define ll long long

const int N = 1e5 + 10;
const ll oo = 1e18;

int n;
int a[20][20];
ll f[N];

ll calc(int mask) {
    ll res = 0ll;
    FOR(i, 1, n) FOR(j, 1, i - 1) if(((1 << (i - 1)) & mask) && ((1 << (j - 1)) & mask))
        res += 1ll * a[i][j];
    return res;
}
ll solve(int mask)  {
    if(!mask) return 0;
    if(f[mask] > -oo) return f[mask];
    int pos = 0;
    while(!(mask & (1 << pos))) pos ++;
    ll &res = f[mask];
    for(int submask = mask; submask; submask = ((submask - 1) & mask))
        if(submask & (1 << pos))
            res = max(res, solve(mask ^ submask) + calc(submask));
    return res;
}

signed main()
{
    //freopen("test.inp", "r", stdin);
    scanf("%d", &n);
    FOR(i, 0, N - 1) f[i] = -oo;
    FOR(i, 1, n) FOR(j, 1, n) scanf("%d", &a[i][j]);
    printf("%lld", solve((1 << n) - 1));
}


Measured memory_bytes: 1024
a=list(map(int,input().split()))
a=sorted(a)

dist1=a[2]-a[0]
dist2=a[2]-a[1]

if (dist1%2)==0 and (dist2%2)==0:
  ans=(dist1+dist2)//2
  print(ans)
  
elif (dist1%2)==1 and (dist2%2)==1:
  ans=(dist1+dist2)//2
  print(ans)
  
elif (dist1%2)==0 and (dist2%2)==1:
  ans=(dist1//2)+(dist2+1)//2
  print(ans+1)
  
else:
  ans=(dist2//2)+(dist1+1)//2
  print(ans+1)

Measured memory_bytes: 9112
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define fr(i,n,m) for(ll i=n;i<m;i++)
int main()
{
    char s[100];
    scanf("%s",s);
    size_t len = strlen(s);
    ll true = (ll)len;
    fr(i,0,true){
        s[i]='x';
    }
    printf("%s",s);
    return 0;
}

Measured memory_bytes: 1708
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
int h,w;
string G[51];
bool checked[51][51];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

bool isRect(int x,int y)
{
  int x1,x2,y1,y2;
  x1 = x2 = x;
  y1 = y2 = y;

  rep(i,h)
    rep(j,w)
    {
      if(G[i][j] == G[y][x])
	{
	  if(j < x1)x1 = j;
	  if(j > x2)x2 = j;
	  if(i < y1)y1 = i;
	  if(i > y2)y2 = i;
	}
    }

  REP(i,y1,y2+1)
    REP(j,x1,x2+1)
    if(G[i][j] != G[y][x] && !checked[i][j])return false;
  return true;

}

void draw(int x,int y,char c)
{
  if(checked[y][x])return;
  checked[y][x] = true;
  rep(i,4)
    {
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(!(0 <= nx && nx < w && 0 <= ny && ny < h))continue;
      if(G[ny][nx] != c)continue;
      draw(nx,ny,c);
    }
}

bool isSafe()
{
  rep(i,h)
    rep(j,w)
    if(G[i][j] != '.' && !checked[i][j])return false;
  return true;
}

int main()
{
  int T;
  cin >> T;
  while(T-- > 0)
    {
      cin >> h >> w;
      rep(i,h)
	cin >> G[i];
      rep(i,51)rep(j,51)checked[i][j] = false;

      while(true)
	{
	  bool Fin = true;
	  bool update = false;
       
	  rep(i,h)
	    {	
	      rep(j,w)
		{
		  if(G[i][j] == '.')continue;
		  if(checked[i][j])continue;
		  Fin = false;
		  if(isRect(j,i))
		    {
		      update = true;
		      draw(j,i,G[i][j]);
		    }
		}
	    }
	  if(Fin || !update)break;
	}
   
      isSafe()?cout << "SAFE" << endl:cout << "SUSPICIOUS" << endl;
    }
  return 0;
}

Measured memory_bytes: 1328
import numpy as np
n,m = map(int, input().split())

flag = np.zeros(m, dtype = np.int32)
ka = []
for i in range(n):
    ka = np.array(list((map(int, input().split()))))
    ka -= 1
    flag[ka[1:]] += 1
    if np.max(flag) != i + 1:
        print("0")
        exit()
print(len(flag[flag==n]))


Measured memory_bytes: 12484
#include <iostream> 
using namespace std; 
  
long long int fz(long long int n) 
{ 
    long long int count = 0; 
    n=n/10;
    for (long long int i = 5; n / i >= 1; i *= 5) 
        count += n / i; 

    return count; 
} 
  
int main() 
{ 
   long long n,dg,x,ans;
   ans=0;
   cin>>n;
   if (n%2==1 || n==0)
   {
   	cout<<0<<endl;
   	return 0;
   }
   
   cout<<fz(n)+(n/10)<<endl;
} 

Measured memory_bytes: 256
// Code by Nguyen Huu Lam
#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;

typedef long long LL;

#define y0 Sword_Art_Online
#define y1 Your_lie_in_April
#define yn Darling_in_the_Franxx
#define tm Plastic_Memories
#define lr Charlotte
#define norm Weathering_with_you
#define left Violet_Evergarden
#define have Date_a_live
#define ends Your_name
#define prev Five_centimeters_per_second
#define hash Slient_voice

#define ordered_set tree<LL, null_type, less<LL>, rb_tree_tag, tree_order_statistics_node_update>
mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

LL Rand(LL l, LL h){
    return uniform_int_distribution<LL>(l, h)(rng);
}

template <typename T> void read(T &t){
    t = 0; char ch = getchar(); int f = 1;
    while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }
    do { (t *= 10) += ch - '0'; ch = getchar(); } while (isdigit(ch)); t *= f;
}

const LL MaxN = 1 + 1e5;

LL n, a[MaxN];
string s1, s2;

void InOut(){
    #define TASK "ABC"
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
}

int main(){
    // InOut();
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n;
    cin >> s1;
    cin >> s2;
    for(int i = 0 ; i < n ; ++i){
        cout << s1[i];
        cout << s2[i];
    }

    return 0;
}

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

void checkOp(int a, int b, int c, int d){
    if(a + b + c + d == 7){
         std::printf("%d+%d+%d+%d=7\n", a, b, c, d);
     }
     else if(a + b + c - d == 7){
         std::printf("%d+%d+%d-%d=7\n", a, b, c, d);
     }
     else if(a + b - c + d == 7){
         std::printf("%d+%d-%d+%d=7\n", a, b, c, d);
     }
     else if(a + b - c - d == 7){
         std::printf("%d+%d-%d-%d=7\n", a, b, c, d);
     }
     else if(a - b + c + d == 7){
         std::printf("%d-%d+%d+%d=7\n", a, b, c, d);
     }
     else if(a - b + c - d == 7){
         std::printf("%d-%d+%d-%d=7\n", a, b, c, d);
     }
     else if(a - b - c + d == 7){
         std::printf("%d-%d-%d+%d=7\n", a, b, c, d);
     }
     else if(a - b - c + d == 7){
         std::printf("%d-%d-%d-%d=7\n", a, b, c, d);
     }
     return;
}

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

     int a = s[0] - '0';
     int b = s[1] - '0';
     int c = s[2] - '0';
     int d = s[3] - '0';

     checkOp(a, b, c, d);
     return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;
double power( double a, int n )
{
  double r;
  int abs_n;

  r = 1; abs_n = n < 0 ? -n : n;
  while ( abs_n > 0 ) {
    if ( abs_n % 2 == 1 ) { r *= a; }
    a *= a;
    abs_n /= 2;
  }

  return n >= 0 ? r : 1/r;
}

double nthroot( double a, int n )
{
  double x, y;

  if ( a <= 0 || n < 0 ) { return 0; }
  if ( n == 0 ) { return 1; }

  /* a > 0 かつ n > 0 の場合 */
  y = (a > 1) ? a : 1;
  do {
    x = y;
    y = ((n-1)*x + a/power(x, n-1)) / n;
  } while ( y < x );

  return y;
}

int is_power( int a )
{
  int i; 

  if ( a == 1 ) { return 1; }

  for ( i = 2; i <= floor(log2(a)); i++ ) {
    if ( power(floor(nthroot(a, i)), i) == a ) { 
      return 1;
    }
  }

  return 0;
}

int main()
{
  int a,i;
  cin>>a;
  for ( i=a; i>=0; i-- ) {
    if ( is_power(i) ) {
      cout<<i<<endl;
      break;
    }
  }

  return 0;
}

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

using ll = long long;
using ld  = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
const int INF=1e9+7;
const ll LINF=9223372036854775807;
const ll MOD=1e9+7;
const ld PI=acos(-1);
const ld EPS = 1e-10; //微調整用（EPSより小さいと0と判定など）

int ii() { int x; if (scanf("%d", &x)==1) return x; else return 0; }
long long il() { long long x; if (scanf("%lld", &x)==1) return x; else return 0; }
string is() { string x; cin >> x; return x; }
char ic() { char x; cin >> x; return x; }
void oi(int x) { printf("%d ", x); }
void ol(long long x) { printf("%lld ", x); }
void od_nosp(double x) { printf("%.15f", x); } // 古い問題用
void od(double x) { printf("%.15f ", x); }
// long doubleで受け取り、fをLfなどに変えて出力すると、変な数値が出る
// それをなんとかするには独自の出力を作らなければならなそう
void os(const string &s) { printf("%s ", s.c_str()); }
void oc(const char &c) { printf("%c ", c); }
#define o_map(v){cerr << #v << endl; for(const auto& xxx: v){cout << xxx.first << " " << xxx.second << "\n";}} //動作未確認
void br() { putchar('\n'); }

// #define gcd __gcd //llは受け取らない C++17~のgcdと違うので注意
// int lcm(int a, int b){return a / gcd(a, b) * b;}
#define begin_end(a) a.begin(),a.end() //sort(begin_end(vec));
#define REP(i,m,n) for(ll i=(ll)(m) ; i < (ll) (n) ; i++ )
#define rep(i,n) REP(i,0,n)
#define m_p(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define p_b push_back
#define SZ(x) ((int)(x).size) //size()がunsignedなのでエラー避けに


// coutによるpairの出力（空白区切り）
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << " " << p.second << ")";}
// coutによるvectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << " "; //"\t"に変えるとTabで見やすく区切る
  }
  return s;
}
// coutによる多次元vectorの出力（空白区切り）
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

//最大値、最小値の更新。更新したor等しければtrueを返す
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

//4近傍（上下左右） rep(i, 2) にすると右・下だけに進む
vector<int> dx_4 = {1, 0, -1, 0};
vector<int> dy_4 = {0, 1, 0, -1};

// -------- template end - //


// - library ------------- //



// --------- library end - //


int main(){

  ll N = il();
  vector<ll> f(N+1, 0);
  
  REP(x, 1, 100) REP(y, 1, 100) REP(z, 1, 100){
    ll ans = x * x + y * y + z * z + x * y + y * z + z * x;
    if (ans <= N) f[ans]++;
  }

  REP(i, 1, N+1){
    cout << f[i] << endl;
  }

}

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

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

  atcoder::dsu uf(N);
  int buf1,buf2;
  for(int j=0; j<M; j++){
    cin >> buf1 >> buf2;
    buf1--; buf2--; // 1-indexed -> 0-indexed
    uf.merge(buf1, buf2);
  }

  int ans= int(uf.groups().size())- 1;
  
  cout << ans << endl;
}

Measured memory_bytes: 9012
#include<algorithm>
#include<bits/stdc++.h>
#include<cstdio>
#include<functional>
#include<iostream>
#include<cfloat>
#include<climits>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<time.h>
#include<vector>
using namespace std;  
int main(){  
    int n;  
    cin>>n;  
    int a,b;  
    int sum=0;  
    while(n--){  
        cin>>a>>b;  
        sum+=b-a+1;  
    }  
    cout<<sum<<endl;  
}  

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


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;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  string s;
  cin>>s;
  vector<pair<char,ll>> p;
  runlength(s,p);
  cout<<p.size()-1<<endl;
}

Measured memory_bytes: 2628
#include <bits/stdc++.h>
#include <string>
#include <stdio.h>
#include <cstdlib>

using namespace std;

int main() {
int k, a, b, flg;
cin >> k >> a>> b;
flg=0;
for (int i=1; i <= (b-a)+1;i++){
    if ((i+a-1) % k ==0 ){
        flg=1;
    }
}
if(flg==1){
    cout << "OK";
}
else{
    cout << "NG";
}
}

Measured memory_bytes: 3592
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long ll;

set<int> s1,s2;
int main()
{
  int n,m;
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++)
  {
    int a,b;
    scanf("%d%d",&a,&b);
    if(a==1||b==1) s1.insert(a==1?b:a);
    if(a==n||b==n) s2.insert(a==n?b:a);
  }
  int ok=0;
  for(int a:s1)
    if(s2.find(a)!=s2.end())
    {
      ok=1;
      break;
    }
  if(ok) cout<<"POSSIBLE";
  else cout<<"IMPOSSIBLE";
  
  return 0;
}

Measured memory_bytes: 9600
#include<iostream>

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

using namespace std;
const int INF = 1000000000;
int dp[100000];
int t[20][20];

int main(){
  int n;
  while(cin >> n){
    if(n == 0)break;
    rep(i, n){
      rep(j, n+1){
        cin >> t[i][j];
      }
    }
    rep(i, (1<<n)){
      dp[i] = INF;
    }
    dp[0] = 0;
    rep(i, (1<<n)){
      rep(stage, n){
        if((i & (1<<stage))!= 0)continue; 
        dp[i + (1<<stage)] = min(dp[i] + t[stage][0], dp[i+(1<<stage)]);
        rep(tool, n){
          if((i & (1 << tool)) == 0)continue;
          dp[i + (1<<stage)] = min(dp[i] + t[stage][tool+1], dp[i+(1<<stage)]);
        }
      }
    }
    cout << dp[(1<<n)-1] << endl;
  }
  return 0;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,M;
    Scd2(N,M);

    vi a(N);
    Rep(i,N){
        Scd(a[i]);
        a[i] %= M;
    }

    vi s(N+1);
    Rep(i,N){
        s[i+1] = s[i] + a[i];
        s[i+1] %= M;
    }

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

    map<int,ll> dist;
    Rep(i,N+1){
        dist[s[i]]++;
    }

    ll ans = 0;
    for( pair<int,ll> d : dist ){
        ans += d.second * ( d.second - 1 ) / 2;
    }

    printf ("%lld\n", ans );

    return 0;
}





Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define pb push_back
ll p=pow(10,9)+7;
int q=998244353;
typedef long double ld;
const double PI =  3.141592653589793238;
 
ll power(ll x, ll y, ll pp)
{
    ll res = 1;
    x = x % pp;
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % pp;
        y = y>>1;
        x = (x*x) % pp;
    }
    return res;
}
 
ll modInverse(ll n, ll pp)
{
    return power(n, pp-2, pp);
}
ll factorial(ll n) 
{ 
    // single line to find factorial 
    
ll ans = 1;
for (int i=1;i<=n;i++)
{
    ans = ans*i;
}
return ans;
} 
bool isPrime(int n) 
{ 
    // Corner case 
    if (n <= 1)  return false; 
  
    // Check from 2 to n-1 
    for (int i=2; i<n; i++) 
        if (n%i == 0) 
            return false; 
  
    return true; 
} 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   string s;
  cin>>s;
  ll sum=0;
  for(int i=0;i<s.length();i++)
  {
    int x=s[i]-'0';
    sum=sum+x;
  }
    if(sum%9 ==0)
      cout<<"Yes";
  else
    cout<<"No";
    return 0;
}







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

int main(){
  int N , X ;
  cin >> N >> X;
  vector<int> L(N);
  for(int i = 0; i < N; i++) cin >> L[i]; 
  int ans = 0;
  vector<int> XL(N + 1);
  for(int i = 1; i < N + 1; i++) XL[i] = XL[i-1] + L[i-1];
  for(int i = 0; i < N + 1; i++)
    if(XL[i] <= X) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 3636
#!/usr/bin/env ruby
n, k = gets.chomp.split.map(&:to_i)

a = gets.chomp.split.map(&:to_i)

town_a = [nil, a].flatten
visited_count = Array.new(n + 1, 0)
@marked_town = nil
@loop_length = 0

now = town_a[1]

counter = 1
loop do
  if counter == k
    puts now
    break
  else
    @loop_length += 1 if @marked_town

    if now == @marked_town
      nokori = (k - counter) % @loop_length

      nokori.times do
        now = town_a[now]
      end
      puts now
      break
    end

    if @marked_town.nil?
      visited_count[now] += 1

      @marked_town = now if visited_count[now] == 2
    end
  end
  now = town_a[now]
  counter += 1
end




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

int main() {
    string S,T;
  cin >> S >> T;
  
	int count = 0;
	for(int i=0; i<3; i++){
	  if(S[i]==T[i]) count++;
    }
  
  cout << count << endl;
  
}

Measured memory_bytes: 256
X = int(input())

C = 0
P = 0
D = 0
L = 0

if X >= 0 and X <= 10 ** 9:
    while True:
        if X >= 500:
            C = X // 500
            P = 500 * C
            X = X - P
        elif X >= 5:
            D = X // 5
            L = 5 * D
            X = X - L
        else:
            break

total = (1000 * C) + (5 * D)

print(total)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1000000000
#define LINF 1000000000000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

/*
  UnionFind Tree
*/
class UnionFind {
    private: 
        vector<int> par;
        vector<int> rank;
        vector<int> cnt;
    
    public:
        UnionFind(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        int count(int x);
        void printStatus();
};

UnionFind::UnionFind(int n) {
    for (int i = 0; i < n; i++) {
        par.push_back(i);
        rank.push_back(0);
        cnt.push_back(1);
    }
}
int UnionFind::find(int x) {
    if (par[x] == x) return x;
    else return par[x] = find(par[x]);
}
void UnionFind::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (rank[x] < rank[y]) {
        cnt[y] += cnt[x];
        par[x] = y;
    } else {
        cnt[x] += cnt[y];
        par[y] = x;
        if (rank[x] == rank[y]) rank[x]++;
    }
}
bool UnionFind::same(int x, int y) {
    return find(x) == find(y);
}
int UnionFind::count(int x) {
    return cnt[find(x)];
}
void UnionFind::printStatus() {
    printf("----------------\n");
    for (int i = 0; i < par.size(); i++) {
        printf("[node %d]: parent = %d, rank = %d, count = %d\n", i, par[i], rank[i], cnt[i]);
    }
}

int main() {

    int N, M, K;
    cin >> N >> M >> K;

    UnionFind tree(N);
    vector<P> friends(M), blocked(K);
    rep(i,M) cin >> friends[i].first >> friends[i].second;
    rep(i,K) cin >> blocked[i].first >> blocked[i].second;

    vector<int> c_friends(N, 0), c_blocked(N, 0);

    rep(i,M) {
        friends[i].first--; friends[i].second--;
        tree.unite(friends[i].first, friends[i].second);
        c_friends[friends[i].first]++;
        c_friends[friends[i].second]++;
    }

    rep(i,K) {
        blocked[i].first--; blocked[i].second--;
        if (tree.same(blocked[i].first, blocked[i].second)) {
            c_blocked[blocked[i].first]++;
            c_blocked[blocked[i].second]++;
        }
    }

    rep(i,N) cout << tree.count(i) - (c_friends[i] + c_blocked[i] + 1) << (i < N - 1 ? " " : "");
    
    return 0;
}

Measured memory_bytes: 4588
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T>
vector<T> finddivisor(T x){//整数xの約数が入ったvectorを返すよ(xを含む)  
    vector<T> divisor;
    for(T i=1; (i*i)<=x ;i++)
    {
        if(x%i==0){
            divisor.push_back(i);
            if(i*i!=x){
                divisor.push_back(x/i);
            }//約数はペアを持つことを利用

        }
    }
    sort(divisor.begin(),divisor.end());
    //divisor.push_back(x);
    return divisor;
}

signed main(){
  cin.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll n;cin>>n;
  V<ll> div=finddivisor(n);
  ll ans=0,tmp;

  rep(i,1,siz(div)){
    tmp=n;
    while(tmp%div[i]==0)tmp/=div[i];
    if(tmp%div[i]==1)ans++;
  }

  div=finddivisor(n-1);
  ans+=siz(div)-1;

  cout<<ans<<ENDL;
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 384
def main():
    n = int(input())
    a = dict()
    for _ in range(n):
        x = int(input())
        if x in a:
            a[x] +=1
        else:
            a[x] = 1
    ans = 0
    for v in a.values():
        if v % 2 == 1:
            ans += 1
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 15072
#include <iostream>
using namespace std;
int main() {
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n - 1; i > 0; i--) {
        cout << a[i] << " ";
    }
    cout << a[0] << endl;
    return 0;
}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;

int dp[210][200000];

int main(){
    int N;
    cin>>N;
    vector<int> a(3*N);
    for (int i = 0; i < 3*N; ++i) {
        cin>>a[i];
    }
    //0~i,i+1~N-1(N<=i<=2N)に分割
    vector<ll> left(N+1),right(N+1);
    //前半部分
    priority_queue<int,vector<int>,greater<>> pq;
    ll total=0ll;
    for (int i = 0; i < N; ++i) {
        pq.push(a[i]);
        total+=(ll)a[i];
    }
    left[0]=total;
    for (int i = 0; i < N; ++i) {
        pq.push(a[N+i]);
        total+=a[N+i];
        total-=pq.top();
        pq.pop();
        left[i+1]=total;

    }

    //後半部分
    priority_queue<int> pq2;
    total=0ll;
    for (int i = 3*N-1; i >=2*N ; --i) {
        pq2.push(a[i]);
        total+=a[i];
    }
    right[N]=total;

    for (int i = 0; i <N ; ++i) {
        pq2.push(a[2*N-1-i]);
        total+=a[2*N-1-i];
        total-=pq2.top();
        pq2.pop();
        right[N-i-1]=total;
    }

    ll ans=-1e18;
    for (int i = 0; i <=N; ++i) {
        ans=max(ans,left[i]-right[i]);
    }

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

Measured memory_bytes: 4088
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;
using itn = int;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define itn int
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl lcm(intl a,intl b){
    return a / gcd(a, b) * b;
}
intl digit10(intl a){
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl n,m;
    cin >> n;
    intl cnt = 0;
    repi(i, 1, n + 1){
        cnt += i * ((i%3)&&(i%5));
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while ('0'>ch||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do {(t*=10)+=ch-'0';ch=getchar();} while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=100010;
int n,u[maxn],tot;
char s[maxn];
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	n=strlen(s+1);
	if (s[1]=='0'||s[n]=='1') {
		printf("-1\n");
		return 0;
	}
	for (int i=1;i<n;i++)
		if (s[i]!=s[n-i]) {
			printf("-1\n");
			return 0;
		}
	for (int i=1;i<=n-i;i++)
		if (s[i]=='1') u[++tot]=i;
	u[tot+1]=n;
	for (int i=1;i<=tot;i++) {
		for (int j=u[i];j<u[i+1];j++)
			printf("%d %d\n",j,u[i+1]);
	}
	return 0;
}

Measured memory_bytes: 1664
N,Q = map(int,input().split())
S = input()
qs = [tuple(map(int,input().split())) for i in range(Q)]

cums = [0,0]
for i in range(1,N):
    if S[i-1:i+1] == 'AC':
        cums.append(cums[-1] + 1)
    else:
        cums.append(cums[-1])

for l,r in qs:
    print(cums[r] - cums[l])


Measured memory_bytes: 19772
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<tuple<int,string,int>> r(n);
  for(int i=0;i<n;i++){
    string s;
    int p;
    cin>>s>>p;
    r.at(i)=make_tuple(i,s,p);
  }
  sort(r.begin(),r.end(),[](tuple<int,string,int> a,tuple<int,string,int> b){
    return get<1>(a)<get<1>(b)||(get<1>(a)==get<1>(b)&&get<2>(a)>get<2>(b));
  });
  for(int i=0;i<n;i++)
    cout<<get<0>(r.at(i))+1<<endl;
}

Measured memory_bytes: 256