akhauriyash/Code-Regression huggingface dataset:
//pragma
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

#define YOU using
#define DONT namespace
#define SAY std

YOU DONT SAY;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define REPP(i,a,b,d) for(int i=a;i<=b;i+=d)
#define REP(i,a,b) REPP(i,a,b,1)
#define REVV(i,a,b,d) for(int i=a;i>=b;i-=d)
#define REV(i,a,b) REVV(i,a,b,1)

#define FOR(i,a) for(int i=0; i<a; i++)
#define FORD(i,a) for(int i=(int)a-1; i>=0; i--)

#define pb push_back
#define F first
#define S second

const int OO = 1e9;
const ll INF = 1e18;

const int irand(int lo,int hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

const ll lrand(ll lo,ll hi){
	return ((double)rand()/(RAND_MAX + 1.0)) * (hi-lo+1) + lo;
}

#define getc getchar
template<typename T>
T getnum(){
	int sign = 1;
	T ret = 0;
	char c;

	do{
		c = getc();
	}while(c == ' ' || c == '\n');
	if(c == '-')sign = -1;
	else ret = c-'0';
	while(1){
		c = getc();
		if(c < '0' || c > '9')break;
		ret = 10*ret + c-'0';
	}
	return sign * ret;
}

inline void ini(int& x){
	x = getnum<int>();
}

inline void scani(int& x){
	scanf("%d",&x);
}

//end of macro

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #define endl '\n'
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(10);

    int n;
    cin>>n;
    ll ans = 0;
    REP(i,1,n){
    	if(i % 3 == 0 || i % 5 == 0){

    	}else{
    		ans += i;
    	}
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3652
n, m = map(int, input().split())
lis = [list(input().split()) for _ in range(m)]
d = {}
ac, wa = 0, 0
for i in lis:
    if i[0] not in d:
        if i[1] == 'AC':
            ac += 1
            d[i[0]] = 'AC'
        else:
            d[i[0]] = 1
    else:
        if i[1] == 'AC':
            if d[i[0]] != 'AC':
                ac += 1
                wa += d[i[0]]
                d[i[0]] = 'AC'
        else:
            if d[i[0]] != 'AC':
                d[i[0]] += 1
print(ac, wa)

Measured memory_bytes: 35264
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {

		Solve s= new Solve();
		s.solve();

	}
}


class Solve{


	 public void solve() {
		 Scanner sc = new Scanner(System.in) ;
		 int N = sc.nextInt();
		 int M = sc.nextInt();
		 int L ;
		 int R ;
		 int res = 0;
		 int l = 1;
		 int r = 100000;
		 for(int i = 0;i<M;i++) {
			 L = sc.nextInt(); 
			 R = sc.nextInt(); 
			 if(L>=l) {
				 l=L;
			 }
			 if(R<=r) {
				 r=R;
			 }
		 }
		 if(l<=r) {
		 System.out.println(r-l+1);
		 }else {
			 System.out.println(0);
		 }
		 
		 }
}

Measured memory_bytes: 63016
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
long long x[200000], y[200000], n, H, W;
vector<long long>X, Y; vector<pair<long long, long long>>candidate;
long long dists(long long px, long long py) {
	vector<long long>RR; long long sum = 0;
	for (int i = 0; i < n; i++) {
		long long TT = abs(px - x[i]) + abs(py - y[i]);
		RR.push_back(TT); sum += TT;
	}
	sort(RR.begin(), RR.end());
	return sum * 2 - RR[RR.size() - 1];
}
int main() {
	cin >> H >> W >> n; for (int i = 0; i < n; i++) { cin >> x[i] >> y[i]; X.push_back(x[i]); Y.push_back(y[i]); }
	sort(X.begin(), X.end()); sort(Y.begin(), Y.end());
	vector<long long>HH, WW;
	if (n % 2 == 1) { HH.push_back(X[X.size() / 2]); WW.push_back(Y[Y.size() / 2]); }
	if (n % 2 == 0) {
		HH.push_back(X[X.size() / 2 - 1]); HH.push_back(X[X.size() / 2]);
		WW.push_back(Y[Y.size() / 2 - 1]); WW.push_back(Y[Y.size() / 2]);
	}
	unique(X.begin(), X.end()); unique(Y.begin(), Y.end());
	int pos1 = lower_bound(X.begin(), X.end(), HH[0]) - X.begin();
	int pos2 = lower_bound(Y.begin(), Y.end(), WW[0]) - Y.begin();
	int pos3 = 0, pos4 = 0;
	if (n % 2 == 0) {
		int pos1 = lower_bound(X.begin(), X.end(), HH[1]) - X.begin();
		int pos2 = lower_bound(Y.begin(), Y.end(), WW[1]) - Y.begin();
	}
	if (pos1 >= 1) { HH.push_back(X[pos1 - 1]); }
	if (pos1 < X.size() - 1 && n % 2 == 1) { HH.push_back(X[pos1 + 1]); }
	if (pos3 < X.size() - 1 && n % 2 == 0) { HH.push_back(X[pos3 + 1]); }
	if (pos2 >= 1) { WW.push_back(Y[pos2 - 1]); }
	if (pos2 < Y.size() - 1 && n % 2 == 1) { WW.push_back(Y[pos2 + 1]); }
	if (pos4 < Y.size() - 1 && n % 2 == 0) { WW.push_back(Y[pos4 + 1]); }
	for (int i = 0; i < HH.size(); i++) { for (int j = 0; j < WW.size(); j++)candidate.push_back(make_pair(HH[i], WW[j])); }
	long long minx = 999999999999999999LL, mx = 0, my = 0; sort(candidate.begin(), candidate.end());
	for (int i = 0; i < candidate.size(); i++) {
		long long UU = dists(candidate[i].first, candidate[i].second);
		if (minx > UU) { minx = UU; mx = candidate[i].first; my = candidate[i].second; }
	}
	cout << minx << endl << mx << ' ' << my << endl;
	return 0;
}

Measured memory_bytes: 7876
use proconio::input;
use proconio::marker::Usize1;

fn find(x: usize, par: &mut Vec<usize>, rnk: &Vec<usize>) -> usize {
    //
    if par[x] == x {
        return x;
    } else {
        par[x] = find(par[par[x]], par, rnk);
        return par[x];
    }
}

fn unite(x: usize, y: usize, par: &mut Vec<usize>, rnk: &mut Vec<usize>) {
    let x = find(x, par, rnk);
    let y = find(y, par, rnk);
    if x == y {
        return;
    }

    if rnk[x] < rnk[y] {
        par[x] = y;
    } else {
        par[y] = x;
        if rnk[x] == rnk[y] {
            rnk[x] += 1;
        }
    }
}

#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        M: usize,
        AB: [(Usize1, Usize1); M]
    }

    let mut par: Vec<_> = (0..N).collect();
    let mut rnk = vec![0; N];

    for &(a, b) in AB.iter() {
        unite(a, b, &mut par, &mut rnk);
    }

    for i in 0..N {
        find(i, &mut par, &mut rnk);
    }
    let mut cnt = vec![0; N];
    for i in 0..N {
        cnt[par[i]] += 1;
    }

    println!("{}", cnt.iter().max().unwrap());
}


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

int main(){
	int a,b,c,k;
	
	while(scanf("%d %d",&a,&b)!=EOF){
		k=0;
		c=a+b;
		while(c!=0){
			c=c/10;
			k++;
		}
		printf("%d\n",k);
	}
	return 0;
}

Measured memory_bytes: 600
n,m = map(int, input().split())

num = [-1]*n
for i in range(m):
  s,c = map(int, input().split())
  s -= 1
  if num[s] != -1 and num[s] != c:
    print(-1)
    exit()
  num[s] = c
  
if n != 1:
  if num[0] == -1:
    num[0] = 1
  for i in range(1,n):
    if num[i] == -1:
      num[i] = 0
else:
  if num[0] == -1:
    num[0] = 0
    
ans = ""
for i in num:
  ans += str(i)
  
if len(str(int(ans))) != n:
  print(-1)
else:
  print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
void fastio(){
	 ios_base::sync_with_stdio(false);
	 cin.tie(0);
	 cout.tie(0);
}
int main() {
	fastio();
	ll a,b,t,i=1,ans=0,m;
	
	cin>>a>>b>>t;
	m=a;
	while(t>=a)
	{
		if(t>=a)
		{
			ans+=b;
			
			i++;
		}
		a=m;
		a=a*i;
	}
	cout<<ans;
	
	return 0;
}

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<string> a(n), b(m);
    for (auto& e : a) cin >> e;
    for (auto& e : b) cin >> e;

    string ans = "No";
    for (int x = 0; x + m <= n; x++) {
        for (int y = 0; y + m <= n; y++) {
            bool same = true;
            for (int dx = 0; dx < m; dx++) {
                for (int dy = 0; dy < m; dy++) {
                    if (a[x+dx][y+dy] != b[dx][dy]) same = false;
                }
            }
            if (same) ans = "Yes";
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
s=input()

A=[]
cnt=1

if s[0]=="0":
  A.append(0)

for i in range(n):
  if i==n-1:
    A.append(cnt)
    break
  if s[i]==s[i+1]:
    cnt+=1
  else:
    A.append(cnt)
    cnt=1
if s[-1]=="0":
  A.append(0)

nn=len(A)

if 2*k+1>=nn:
  print(sum(A))
  exit(0)

B=[0]*nn
B[0]=A[0]
for i in range(nn-1):
  B[i+1]=B[i]+A[i+1]
ans=sum(A[:2*k+1])

for i in range(1,nn-2*k-1,2):
  ans=max(ans,B[i+2*k+1]-B[i])
print(ans)


Measured memory_bytes: 8388
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPS(i,n) for(int i=1;i<=(int)(n);i++)
using namespace std;
using ll = long long;
using ld = long double;

int main(void) {
    string s;
    cin >> s;
    string ans;
    REP(i, s.size()) {
        if (s.at(i) == 'B') {
            if (ans.size() != 0) {
                ans.pop_back();
            }
        } else {
            ans.push_back(s.at(i));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
nums1 = [int(e) for e in input().split()]
nums2 = [int(t) for t in input().split()]
ans = 0
N = nums1[0]
A = nums1[1]
B = nums1[2]
for i in range(0,N-1):
    if(nums2[i+1]-nums2[i])*A > B:
        ans+=B
    else:
        ans+=(nums2[i+1]-nums2[i])*A
print(ans)

Measured memory_bytes: 62832
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,a;
    vector<pair<int,int>> A;
    cin>>n;
    rep(i,n) cin>>a,A.push_back(make_pair(a,i+1));
    sort(A.begin(),A.end());
    rep(i,n) cout<<A[i].second<<" ";
}

Measured memory_bytes: 1780
#include <cstdio>
#include <vector>
#include <stack>
#include <cassert>
#define repeat(i,n) for (int i = 0; (i) < int(n); ++(i))
using namespace std;

int main() {
    int a, b; scanf("%d%d", &a, &b);
    if (a <= b) {
        printf("Impossible\n");
    } else {
        auto query = [](int i, int j) {
            printf("? %d %d\n", i, j);
            fflush(stdout);
            char c; scanf(" %c", &c);
            switch (c) {
                case 'Y': return true;
                case 'N': return false;
                default: assert (false);
            }
        };
        stack<int> chain;
        repeat (i, a + b) {
            if (chain.empty()) {
                chain.push(i);
            } else {
                if (query(chain.top(), i)) {
                    chain.push(i);
                } else {
                    chain.pop();
                }
            }
        }
        assert (not chain.empty());
        int honest = chain.top();
        vector<bool> result(a + b);
        repeat (i, a + b) {
            result[i] = query(honest, i);
        }
        printf("! ");
        repeat (i, a + b) printf("%d", int(result[i]));
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 724
#include <iostream>

int main(){

    for(std::size_t i=0;i<9;i++){
        for(std::size_t j=0;j<9;j++){
            std::cout<<i+1<<'x'<<j+1<<'='<<(i+1)*(j+1)<<std::endl;
        }
    }

    return 0;

}


Measured memory_bytes: 3088
(let* ((n (read))
       (m (read))
       (lst (sort (loop :repeat n :collect (read)) #'<))
       (ans 0))
  (setf ans (mapcar (lambda (k) (setf m (- m k)) (<= 0 m)) lst))
  (if (and (not (= 0 m)) (car (last ans)))
      (princ (1- (count t ans)))
      (princ (count t ans))))

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

int main(){
	string s;
	cin >> s;
	string sam="abcdefghijklmnopqrstuvwxyz";
	vector<int> num(26);
	for(int i=0; i<s.size(); i++){
		for(int j=0; j<26; j++){
			if(s.at(i)==sam.at(j)){
				num.at(j)++;
				break;
			}
		}
	}
	bool judge=true;
	for(int i=0; i<26; i++){
		if(num.at(i)>=2){
			judge=false;
			break;
		}
	}
	if(judge) cout << "yes" << endl;
	else cout << "no" << endl;
}


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

int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n), b(m);
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < m; i++) cin >> b[i];
  
  int ans = 0;
  int j = m;
  ll tot = 0;
  for(int i = 0; i < m; i++) tot += b[i];
  
  for(int i = 0; i < n+1; i++){
    while(j > 0 && tot > k){
      j--;
      tot -= b[j];
    }
    if(tot > k) break;
    ans = max(ans, i+j);
    if(i == n) break;
    tot += a[i];
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4788
/**
 * @author      : Luis Miguel Baez <es.luismiguelbaez@gmail.com>
 * @created     : Thursday August 13, 2020
 */

#include <bits/stdc++.h>

using namespace std;

#define endl '\n'
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define ms(arr, value) memset(arr, value, sizeof arr)
#define ll    int64_t

#define pii   pair<int, int>
#define piii  tuple<int, int, int>
#define pll   pair<ll, ll>
#define plll  tuple<ll, ll, ll>

#define F  first
#define S  second

const int oo  = (int)(1e9);
const ll lloo  = (ll)(1e18);

const int N = int(1e5) + 10;

class Task {
public:

    int n;
    vector<piii> A;

    ll dp[N][4];


    ll go(int index, int last) {
        if(index > n) return 0LL;
        ll &ans = dp[index][last];
        if(ans != -1) return ans;
        ll x=0, y=0;
        if(last == 1) {
            x = get<1>(A[index]) + go(index+1, 2);
            y = get<2>(A[index]) + go(index+1, 3);
        } else if(last == 2) {
            x = get<0>(A[index]) + go(index+1, 1);
            y = get<2>(A[index]) + go(index+1, 3);
        } else if(last == 3) {
            x = get<0>(A[index]) + go(index+1, 1);
            y = get<1>(A[index]) + go(index+1, 2);
        } else {
            ll z = 0;
            x = get<0>(A[index]) + go(index+1, 1);
            y = get<1>(A[index]) + go(index+1, 2);
            z = get<2>(A[index]) + go(index+1, 3);
            x = max(x, z);
        }
        ans = max(x, y);
        return ans;
    }

    ll solveOne(istream &in, ostream &out) {
        int a, b, c;
        in >> n;
        A.resize(n+1);
        for(int i = 1; i <= n; ++i){
            in >> a >> b >> c;
            A[i] = {a, b, c};
        }
        memset(dp, -1, sizeof dp);
        ll ans = go(1, -1);
        return ans;  
    }
    
    void solve(istream &in, ostream &out) {
        int t = 1;
        while(t--) {
            out << solveOne(in, out) << endl;
        }
    }
};

auto main() -> int {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    Task solver;
    istream &in(cin);
    ostream &out(cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 13728
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;

long long gcd(long long x, long long y){
			if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }
int cntdp[1000001];
int a[12] = {1,6,9,36,81,216,729,1296,6561,7776,46656,59049};
int main(){
int N;
cin >> N;
fill(cntdp,cntdp+100001,INF);
cntdp[0]=0;
for(int i = 1;i<=N;i++){
	for(int j = 0;j<12;j++){
		if(i<a[j])break;
		cntdp[i] = min(cntdp[i-a[j]]+1,cntdp[i]);
	}
}
cout << cntdp[N] << endl;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
map< ll, int > prime_factor(ll n) {
  map< ll, int > res;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      res[i]++;
      n /= i;
    }
  }
  if(n != 1) res[n] = 1;
  return res;
}
int main(){ 
  ll n;
  cin >> n;

  auto mp = prime_factor(n);

  ll res = 0;

  for (auto e : mp) {
    int now = e.second;
    set<int> st;
    for (int i = 1; i <= e.second; i++) {
      int d = now - i;
      if (d < 0) continue;
      if (st.count(d)) continue;
      st.insert(i);
      now -= i;
    }
    res += st.size();
  }

  cout << res << endl;
  return 0;
} 

Measured memory_bytes: 3632
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef vector<pii> VP;
typedef vector<string> VS;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//priority_queue<int,vector<int>, greater<int> > q2;



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int N; cin >> N;
	vector<VI>G(N);
	VI C(N);
	REP(i, N - 1) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int sum = 0;
	REP(i, N) {
		cin >> C[i];
		sum += C[i];
	}
	rSORT(C);

	int a;
	REP(i, N)if (G[i].size() == 1) {
		a = i;
		break;
	}
	queue<int>Q;
	VI ans(N);
	Q.push(a);
	vector<bool>vis(N, false);
	vis[a] = 1;
	int k = 0;
	while (!Q.empty()) {
		int now = Q.front();
		Q.pop();
		ans[now] = C[k];
		k++;
		fore(to, G[now]) {
			if (!vis[to]) {
				vis[to] = 1;
				Q.push(to);
			}
		}

	}





	cout << sum - C[0] << endl;
	REP(i, N)cout << ans[i] << " ";
	cout << endl;
	return 0;
}



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

int main() {
  int s;
  cin>>s;
  int s3 = s%10;
  int s2 =(s-s3)/10%10;
  int s1 =(s-s3-s2*10)/100;
  cout<<s1+s2+s3<<endl;
}

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

fn main() {
	let mut n: i32 = read_line().parse().unwrap();
	let mut s = String::new();
	while n != 0 {
		let c =
			if n % 2 == 0 {
				'0'
			}
			else {
				n -= 1;
				'1'
			};
		s.push(c);
		n /= -2;
	}
	s = s.chars().rev().collect();
	if s.is_empty() {
		s.push('0');
	}
	println!("{}", s);
}

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


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ll A, B, g, t, c = 1;

	cin >> A >> B;

	g = __gcd(A,B);

	if ( g % 2 == 0 ){
		c++;
		while ( g % 2 == 0 )
			g /= 2;
	}
	t = 3;
	while ( t * t < g ){
		if ( g % t == 0 ){
			c++;
			while ( g % t == 0 )
				g /= t;
		}
		t += 2;
	}
	if ( g > 1 )
		c++;
	cout << c << "\n";
	return 0;
}


Measured memory_bytes: 256
#include    <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define rep(i,a,b)  for(int i=a;i<b;++i)
#define fore(i,a)  for(__typeof(a.begin()) i=a.begin();i!=a.end();++i)
#define __unique(V) V.resize(unique(V.begin(),V.end())-V.begin())
#define cntbit(X)   __builtin_popcount(X)
#define fi  first
#define se  second
#define LL  long long
#define ii  pair<int,int>
#define iii pair<int,ii>
#define TASK "sevens"
using   namespace   std;
int F[65][65][2],m,a[10],b[10],n;
bool ok[15];
///--------------------------
void    readf(){
    memset(ok,0,sizeof(ok));
    ok[7]=1;
    fo(i,1,6) cin>>a[i],ok[a[i]]=1;
    m=0;
    fo(i,1,13) if (!ok[i]) b[++m]=i;
}
///--------------------------
inline void on(int &X,int i) {X=(X|(1<<(i-1)));}
inline int bit(int X,int i) {return ((X>>(i-1))&1);}
///--------------------------
bool    dp(int mask1,int mask2,int id){
    if (F[mask1][mask2][id]!=-1) return F[mask1][mask2][id];
    int &rs=F[mask1][mask2][id];
    if (mask1==0 && id==0) return (rs=1);
    if (mask2==0 && id==1) return (rs=1);
    int tmp=0;
    on(tmp,7);
    fo(i,1,6) if (!bit(mask1,i)) on(tmp,a[i]);
    fo(i,1,6) if (!bit(mask2,i)) on(tmp,b[i]);
    rs=0;
    if (id==0){
        int yes=0;
        fo(i,1,6) if (bit(mask1,i) &&
            ((a[i]>1 && bit(tmp,a[i]-1)) || bit(tmp,a[i]+1))){
            rs|=(!dp(mask1&(~(1<<(i-1))),mask2,1));
            yes=1;
        }
        if (yes==0) rs|=(!dp(mask1,mask2,1));
        return rs;
    }else {
        int yes=0;
        fo(i,1,6) if (bit(mask2,i) &&
            ((b[i]>1 && bit(tmp,b[i]-1)) || bit(tmp,b[i]+1))){
            rs|=(!dp(mask1,mask2&(~(1<<(i-1))),0));
            yes=1;
        }
        if (yes==0) rs|=(!dp(mask1,mask2,0));
        return rs;
    }
}
///--------------------------
void    solve(){
    memset(F,-1,sizeof(F));
    cout<<(dp(63,63,0) ? "yes\n" : "no\n");
}
///--------------------------
int     main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n;
    while (n--){
        readf();
        solve();
    }
}







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

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split();
        int[] a = new int[n];

        for(int i = 0; i < n; i++)
        {
            a[i] = int.Parse(s[i]);
        }

        int max = a.Max();
        int min = a.Min();
        double mincost = 1000000;
        for (int rewrite = min; rewrite <= max; rewrite++)
        {
            double cost = 0;
            for (int i = 0; i < n; i++)
            {
                cost += Math.Pow(a[i] - rewrite, 2);
            }
            if (cost < mincost) mincost = cost;
        }
        Console.WriteLine(mincost);
    }
}


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

int main(){
    int ans=0,sum=0;
    int n,m;
    cin >> n>>m;
    
    int data[n];


    //cout <<fixed<<setprecision(16)<< << endl;
    cout << (n-1)*(m-1) << endl;

    //if(flag==1)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>){
    val s:String = readLine()!!.toString()
    print(if(s.first() == 'A'  && s.subSequence(2, s.length-1).filter {it == 'C'}.length == 1 && s.filter{it != 'A' && it != 'C'}.filter{ it.isUpperCase() }.isEmpty() )
        "AC"
        else "WA"
    )
}

Measured memory_bytes: 31816
#include <bits/stdc++.h>
const int MAX=5100;
const int modn=1e9+7;
typedef long long ll ;
#define endl '\n'
#define cwk     freopen("D:\\workplace\\CLion\\in.in","r",stdin),freopen("D:\\workplace\\CLion\\out.out","w",stdout)
using namespace std;
ll fastpow(ll a,ll n){
    ll res=1;
    while(n){
        if(n&1){
            res=(res*a)%modn;
        }
        a=(a*a)%modn;
        n>>=1;
    }
    return res;
}
ll n,k;
ll p[MAX],c[MAX];
ll cnt[MAX],ans[MAX],maxnn[MAX],cha[MAX];
void slove(){
    cin>>n>>k;
    for(ll i=1;i<=n;i++){
        cin>>p[i];
    }
    for(ll i=1;i<=n;i++){
        cin>>c[i];
    }
    for(ll i=1;i<=n;i++){
        maxnn[i]=-INT_MAX;
        ll flag=i;
        while(p[flag]!=i){
            ans[i]+=c[flag];
            cnt[i]++;
            flag=p[flag];
            maxnn[i]=max(maxnn[i],ans[i]);
        }
        ans[i]+=c[flag];
        maxnn[i]=max(maxnn[i],ans[i]);
        cha[i]=ans[i]-maxnn[i];
        cnt[i]++;
    }
    ll maxn=-INT_MAX;
    for(ll i=1;i<=n;i++){
        ll now=-INT_MAX;
        ll q=0;
        ll flag=i;
        ll qq=k%cnt[i];
        if(qq==0)
            qq=cnt[i];
        while(qq-->0){
            flag=p[flag];
            q+=c[flag];
            now=max(now,q);
        }
        int we=k;
        if(we>=cnt[i]){
            if(now+cha[i]<0){
                now=maxnn[i];
                we=we/cnt[i]*cnt[i]-cnt[i];
            }
        }
        if(ans[i]>0){
            if(we%cnt[i]!=0)
                now+=we/cnt[i]*ans[i];
            else now+=(we/cnt[i]-1)*ans[i];
        }

        maxn=max(maxn,now);
    }
    cout<<maxn<<" ";
}
int main() {
    //ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    //cwk;
    int _=1;
    //cin>>_;
    while(_--){
        slove();
    }
    return 0;
}

Measured memory_bytes: 3856
def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a%b)

a, b, c , d = [int(x) for x in input().split()]

x = a//c
if a%c != 0:
  x += 1
y = a//d
if a%d != 0:
  y += 1
dd = (c*d)//gcd(c, d)
xy = a//(dd)
if a%(dd) != 0:
  xy += 1

t1 = max(0, b//c - x+1)
t2 = max(0, b//d - y+1)
t3 = max(0, b//(dd) - xy+1)

print(str((b-a+1) - (t1+t2-t3)))



Measured memory_bytes: 3064
'use strict';
function main(input) {
  var P = input.split('\n')[1].split(' ');
  var min = 2 * Math.pow(10, 5) + 1;
  var cnt = 0;
  for (var p of P) {
    p = parseInt(p);
    if (p < min) {
      ++cnt;
      min = p;
    }
  }
  console.log(cnt);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 33580
#include <iostream>
using namespace std;
 
int main()
{
    int aaa;
    while (cin >> aaa) {
        int cnt = 0;
        for (int i = 0; i <= 9; i++) {
            for (int j = 0; j <= 9; j++) {
                for (int k = 0; k <= 9; k++) {
                    for (int l = 0; l <= 9; l++) {
                        if (i + j + k + l == aaa) {
                            cnt++;
                        }
                    }
                }
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 3076
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;
#define SORTVL(v) sort(v.begin(), v.end());
#define SORTVL_GR(v) sort(v.begin(), v.end(), greater<LL>());

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }
// 末尾数字で切り上げ
LL CeilLastNumber(LL n) { return ((n + (10 - 1)) / 10) * 10; }
//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL X, A;
	cin >> X >> A;

	if (X < A) {
		O(0);
	}
	else {
		O(10);
	}

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
    int n,m;
    scanf(" %d%d",&n,&m);
    int broken[100002];
    rep(i,m){
        int a;
        scanf("%d",&a);
        broken[a]=1;
    }
    long long int dp[100002];
    const long long int mod = 1000000007;
    dp[n] = 1;
    for(int i= n-1;i>=0;i--){
        if(broken[i]){
            dp[i]=0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2]) % mod;
    }
    printf("%d\n",dp[0]);
    return 0;
}

Measured memory_bytes: 1280
#include<cstdio>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
using namespace std;

#define INF ( 1 << 30 )
typedef multiset<int,int>::iterator itr;

int main()
{
  int N, Q;
  int stmp[1000000], comp[1000000], a;
  char buff[1024];
  scanf( "%d %d", &N, &Q);
  for(int i = 0 ; i < N ; i++ ){
    scanf( "%d", &stmp[i]);
    comp[i] = stmp[i];
  }
  sort( comp, comp + N);

  multiset< int > sym;
  while(Q--){
    scanf("%s %d", buff, &a);
    if(*buff == 'A'){ //ADD

      sym.insert(stmp[a - 1]);

    } else if(*buff == 'R'){ //REMOVE
      try{
        sym.erase( sym.lower_bound(stmp[a - 1]));
      }catch( ... ){}
    } else { //CHECK

      int left = 0, right = INF;
      while(left != right){
        int center = ( left + right ) / 2;
        int pre = 0, BAN = 0;
        for(itr it = sym.begin() ; it != sym.end() ; it++ ){
          int p = distance( comp,lower_bound( comp, comp + N, *it - center));
          BAN += max( p - pre, 0);
          pre = distance( comp, upper_bound( comp, comp + N, *it));
        }
        BAN += max( N - pre, 0);
        if(BAN <= a) right = center;
        else left = center + 1;
      }
      if( left != INF) printf("%d\n", left);
      else puts("NA");

    }
  }
  return false;
}

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

using namespace std;

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

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n); 
    ll s = 0;
    vector<ll> pref_max(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (i < k) {
            s += a[i];
            f[i] = max(f[i], s);
            pref_max[i] = (i == 0 ? 0 : pref_max[i - 1]);
            pref_max[i] += max(0ll, a[i]);
        }
    }
    for (int i = k; i < n; i++) {
        s += a[i];
        s -= a[i - k];
        //cerr << s << endl;
        f[i] = f[i - 1];
        f[i] = max(f[i], f[i - 1] + a[i]);
        f[i] = max(f[i], max(f[i - k], pref_max[i - k]));
        f[i] = max(f[i], max(f[i - k], pref_max[i - k]) + s);
    }
    cout << f.back() << endl;  
}       

Measured memory_bytes: 2688
using System;
class M {
  static void Main(string[] _) {
    var P = Console.ReadLine().Split(' ');
    var N = int.Parse(P[0]);
    var A = int.Parse(P[1]);
    var B = int.Parse(P[2]);
    
    long total = 0;
    for ( int I=0 ; I<=N ; ++ I ) {
      var A0 = I % 10;
      var A1 = ( I / 10 ) % 10;
      var A2 = ( I / 100 ) % 10;
      var A3 = ( I / 1000 ) % 10;
      var A4 = ( I / 10000 ) % 10;
      var A5 = ( I / 100000 ) % 10;
      var A6 = A0 + A1 + A2 + A3 + A4 + A5 ;
      if ( A <= A6 && A6 <= B ) {
        total += I;
      }
    }
    
    
    Console.Write(total);
    
  }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll mod=1e9+7;

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<int,int> P;

int h,w,n;
vector<int> a(10010);
//vector<vector<int> > c(110,vector<int>(110));
vector<int> dx={1,-1,0,0};
vector<int> dy={0,0,1,-1};

bool dfs(int num,int li,int ro,vector<int> &cnt,vector<vector<int> > &c){
    //cout_vec(cnt);
    //cout<<' '<<num<<' '<<li<<' '<<ro<<'\n';
    c[li][ro]=num;
    cnt[num]--;
    if(count(begin(cnt),end(cnt),0)==n+1){
      return true;
    }
    bool flag=false;
    if(cnt[num]>0){
      rep(i,4){
        rep(j,4){
          int nx=li+dx[i];
          int ny=ro+dy[i];
          if(1<=nx && nx<=h && 1<=ny && ny<=w && c[nx][ny]<0 && dfs(num,nx,ny,cnt,c)){
            flag=true;
            break;
          }
        }
        if(flag){
          break;
        }
      }
    }else{
      num++;
      if(num>n){
        num=1;
      }
      rep(i,4){
        rep(j,4){
          int nx=li+dx[i];
          int ny=ro+dy[i];
          //cout<<num<<' '<<nx<<' '<<ny<<'\n';
          if(1<=nx && nx<=h && 1<=ny && ny<=w && c[nx][ny]<0 && dfs(num,nx,ny,cnt,c)){
            flag=true;
            break;
          }
        }
        if(flag){
          break;
        }
      }
    }
    return flag;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>h>>w>>n;
    FOR(i,1,n+1){
      cin>>a[i];
    }
    vector<int> cn(n+1,0);
    int st=0;
    vector<vector<int> > c(110,vector<int>(110));
    do{
      FOR(i,1,h+1){
        FOR(j,1,w+1){
          c[i][j]=-1;
        }
      }
      FOR(i,1,n+1){
        cn[i]=a[i];
        //cout<<cn[i]<<' ';
      }
      st++;
    }while(!dfs(st,1,1,cn,c));
    FOR(i,1,h+1){
      FOR(j,1,w+1){
        cout<<c[i][j]<<' ';
      }
      cout<<'\n';
    }
}


Measured memory_bytes: 1280
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>


using namespace std;

int main(){

	int N, ans, t;

	cin >> N;

	t = N / 100;
	ans = t + 10 * t + 100 * t;

	if( N > ans){
		t++;
		ans = t + 10 * t + 100 * t;
	}	

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#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 tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        PBDS;

#define int long long
#define endl "\n"


int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	string s, str;

	cin >> s;
	cin >> str;

	int n = 0;

	for (int i = 0; i < s.size(); i++) {
		if (s[i] != str[i]) {
			n++;
		}
	}

	cout << n;

	return 0;

}

Measured memory_bytes: 3824
(defun input (n)
  (let ((A (make-array n)))
    (loop for i below n do (setf (aref A i) (read)))
    A))
(defun solve (n A)
  (loop for i below n sum (aref A (+ (* 2 i) 1))))
(let* ((n (read))
       (A (input (* 3 n))))
  (sort A #'>)
  (princ (solve n A)))

Measured memory_bytes: 61856
#include <bits/stdc++.h>
 
using namespace std;
 
#define MAX 5010
#define INF 1e9
#define F first
#define S second
typedef pair<int,int> pii;
typedef pair<pii,int> piii;
  
int N,K;
pii taxi[MAX];
vector<int> G[MAX];
int cost[MAX][MAX];
 
int dijkstra(){
    priority_queue<piii,vector<piii>,greater<piii> > Q;
    Q.push(piii(pii(0,0),0));
    fill(cost[0],cost[0]+MAX*MAX,INF);
    cost[0][0] = 0;
 
    while(!Q.empty()){
	piii p = Q.top(); Q.pop();
	int v = p.F.S, r = p.S;
	if(cost[v][r] < p.F.F) continue;
 
	if(r > 0){
	    for(int i = 0 ; i < (int)G[v].size() ; i++){
		int to = G[v][i];
		if(cost[v][r] < cost[to][r-1]){
		    cost[to][r-1] = cost[v][r];
		    Q.push(piii(pii(cost[to][r-1],to),r-1));
		}
	    }
	}
	pii t = taxi[v];
	for(int i = 0 ; i < (int)G[v].size() ; i++){
	    int to = G[v][i];
	    if(cost[v][r] + t.F < cost[to][t.S-1]){
		cost[to][t.S-1] = cost[v][r] + t.F;
		Q.push(piii(pii(cost[to][t.S-1],to),t.S-1));
	    }
	}
    }
    return *min_element(cost[N-1],cost[N-1]+N);
}
 
int main(){
    int C,R,A,B;
    cin >> N >> K;
    for(int i = 0 ; i < N ; i++){
	cin >> C >> R;
	taxi[i] = pii(C,R);
    }
    for(int i = 0 ; i < K ; i++){
	cin >> A >> B; A--; B--;
	G[A].push_back(B);
	G[B].push_back(A);
    }
    cout << dijkstra() << endl;
    return 0;
}

Measured memory_bytes: 101556
#include<iostream>
#include<queue>
#include<string>
#include<algorithm>
using namespace std;

string masu[1010];
int intmasu[1010][1010];
int h, w, ch, cw, dh, dw;
int ans = -1;

struct st {
	int hh;
	int ww;
	int wnum;
	st(int a, int b, int c) {
		hh = a;
		ww = b;
		wnum = c;
	}
};

queue<st> solve;
int warpnum = -1;
int warpcount;

void move(int hh, int ww, int wnum) {
	if (hh <= 0 || ww <= 0 || hh > h || ww > w) {
		return;
	}
	if (masu[hh][ww] != '.') {
		return;
	}
	if(intmasu[hh][ww] == wnum){
		return;
	}
//	masu[hh][ww] = wnum + '0';
	intmasu[hh][ww] = wnum;
	solve.push(st(hh, ww, wnum));
	move(hh - 1, ww, wnum);
	move(hh + 1, ww, wnum);
	move(hh, ww - 1, wnum);
	move(hh, ww + 1, wnum);
	if (hh == dh && ww == dw) {
		if (ans != -1) {
			ans = min(ans, wnum);
		}
		else {
			ans = wnum;
		}
		return;
	}
	return;
}

void warp(int hh, int ww, int wnum) {
	int i, j;
	if (hh <= 0 || ww <= 0 || hh > h || ww > w) {
		return;
	}
	if (masu[hh][ww] != '.')return;
	if (wnum==warpnum) {
		for (i = hh - 2; i <= hh + 2; i++) {
			for (j = ww - 2; j <= ww + 2; j++) {
				warp(i, j, wnum + 1);
			}
		}
	}
	else if (wnum == warpnum + 1) {
		if (intmasu[hh][ww] == -1) {
			intmasu[hh][ww] = wnum-1;
			solve.push(st(hh, ww, wnum));
			warpcount++;
			if (hh == dh && ww == dw) {
				if (ans != -1) {
					ans = min(ans, wnum);
				}
				else {
					ans = wnum;
				}
				return;
			}
		}
	}
	return;
}

void printmasu() {
	int i, j;
	cout << endl;
	cout << "warpcount = " << warpcount << endl;
	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++) {
			cout << masu[i][j];
		}
		cout << endl;
	}
	cout << endl;
}

void initflg() {
	int i, j;
	for (i = 1; i <=h ; i++) {
		for (j = 1; j <= w; j++) {
			if (intmasu[i][j]== warpnum+1) {
				intmasu[i][j] = -1;
			}
		}
	}
}

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

	cin >> h >> w;
	cin >> ch >> cw;
	cin >> dh >> dw;
	for (i = 1; i <= h; i++) {
		cin >> masu[i];
		masu[i] = '#' + masu[i];
	}

	for (i = 0; i < 1010; i++) {
		for (j = 0; j < 1010; j++) {
			intmasu[i][j] = -1;
		}
	}

	move(ch, cw, 0);
	if (ans != -1) {
		cout << ans << endl;
		return 0;
	}

	st tmp(0, 0, 0);
	while (1) {
		warpnum++;
		warpcount = 0;
		while (!solve.empty()) {
			tmp = solve.front();
			if (tmp.wnum != warpnum)break;
			solve.pop();
			warp(tmp.hh, tmp.ww ,tmp.wnum);
		}
		//printmasu();
		//initflg();
		if (solve.empty())break;

		while (warpcount>0) {
			tmp = solve.front();
			solve.pop();
			move(tmp.hh, tmp.ww, tmp.wnum);
			warpcount--;
		}
		//printmasu();

		if (ans != -1)break;
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
    int a,b;
    int x1,x2,x3,x4;
    int quot;
    int count = 0;

    cin >> a >> b;

    for(int i=a; i<=b; i++){
        quot = i;
        x1 = quot % 10;
        quot /= 10;
        x2 = quot % 10;
        quot /= 10;
        quot /= 10;
        x3 = quot % 10;
        quot /= 10;
        x4 = quot % 10;
        if(x1 == x4 && x2 == x3){
            count++;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
 
 
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
 
typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;
 
 
 
int main() {
 
 int a,b;
 cin>>a>>b;
 if((a+b)%2==1){
     cout<<"IMPOSSIBLE"<<endl;
     return 0;
 }
 cout<<(a+b)/2<<endl;

}

Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define PB(a,n) FOR(i,0,n){ll buf; scanf("%lld",&buf); a.pb(buf); }
#define LOWER(a,x) lower_bound(ALL(a), x) - a.begin() - 1;
#define COUNT(a,x)  upper_bound(ALL(a), x) - lower_bound(ALL(a), x);
#define MCOUNT(a,x,y) upper_bound(ALL(a), y) - lower_bound(ALL(a), x);
#define INF 111111111111111111
#define MOD 1000000007
#define pb push_back
#define F first
#define S second
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = 0, mi = 0;
string s;
bool flag, ok;
ll dx[4] = { 1,-1,0,0 }, dy[4] = { 0,0,1,-1 };
ll ddx[8] = { 1,-1,0,0,1,1,-1,-1 }, ddy[8] = { 0,0,1,-1,1,-1,1,-1 };
#pragma endregion
#define MAX 111111


bitset<5001> dp1[5005], dp2[5005];
ll sm[5555];
int main(void) {
  ll k;
  vll a;
  cin >> n >> k;
  PB(a, n);
  FOR(i, 0, n) sum += a[i];

  dp1[0][0] = 1;
  FOR(i, 1, n + 1) {
	if (a[i - 1] < k) {
	  dp1[i] = dp1[i - 1] | dp1[i - 1] << a[i - 1];
	}
	else {
	  dp1[i] = dp1[i - 1];
	}
  }
  dp2[0][0] = 1;
  FOR(i, 1, n + 1) {
	if (a[n - i] < k) {
	  dp2[i] = dp2[i - 1] | dp2[i - 1] << a[n - i];
	}
	else {
	  dp2[i] = dp2[i - 1];
	}
  }

  FOR(i, 1, n + 1) {
	if (a[i - 1] >= k) {
	  if (!dp1[i - 1].any() && !dp2[n - i].any()) ans++;
	  continue;
	}

	FOR(j, 1, k) sm[j] = 0;
	FOR(j, 1, k) sm[j] = dp2[n - i][j] ? sm[j - 1] + 1 : sm[j - 1];

	flag = false;
	FOR(j, k - a[i - 1], k) if (dp1[i - 1][j]) flag = true;
	FOR(j, k - a[i - 1], k) if (dp2[n - i][j]) flag = true;
	FOR(j, 0, k) {
	  if (dp1[i - 1][j]) {
		if ((sm[k - 1 - j] - sm[max(0LL, k - a[i - 1] - j)]) != 0 || dp2[n-i][max(0LL, k - a[i - 1] - j)] ) {
		  flag = true;
		  break;
		}
	  }
	}
	if (!flag) ans++;
  }

  if (sum < k) {
	cout << n << endl;
  }
  else {
	cout << ans << endl;
  }

  return 0;
}

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

int main() {
    ll n,k;
    cin>>n>>k;
    ll r,s,p;
    cin>>r>>s>>p;
    string t;
    cin>>t;
    ll ans=0;
    rep(i,k){
        vector<char> next;
        for(ll j=i;j<n;j+=k){
            next.push_back(t[j]);
        }
        ll nnn=next.size();
        VV dp(nnn+1,V(3,0));
        rep(j,nnn){
            dp[j+1][0]=max(dp[j][1],dp[j][2]);
            dp[j+1][1]=max(dp[j][0],dp[j][2]);
            dp[j+1][2]=max(dp[j][0],dp[j][1]);
            if(next[j]=='r')dp[j+1][2]+=p;
            if(next[j]=='s')dp[j+1][0]+=r;
            if(next[j]=='p')dp[j+1][1]+=s;
        }
        ans+=max({dp[nnn][0],dp[nnn][1],dp[nnn][2]});
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5888
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    int N; cin>>N;
    int ans = 0;
    for (int i = 1; i <= N; ++i) {
        if(((int)(log10(i)+1) % 2) != 0) {
            ans++;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
def main():
  N, K = list(map(int, input().split()))
  A = list(map(int, input().split()))

  # 各indexに対応する町に訪れるために必要な距離をいれる
  o = [-1] * (N+1)

  # 訪問順に並べた町を入れえる
  s = []

  # 現在の町
  v = 1

  # 訪れたところに再訪するまで続ける
  while(o[v] == -1):
    #sの配列長をいれることで、A[0]からA[v-1]番目の街の距離がどのくらいかを保存する
    o[v] = len(s)
    s.append(v)
    v = A[v - 1] # Aは0-indexedだから v-1

  # ループを開始する街までの距離
  l = o[v]
  # 再訪が確認できたら、訪問順を収めた配列長（A[0]からループの終端までの距離）から、ループの開始地点の距離を引くと周期が求まる
  c = len(s) - l

  # 距離Kまでにループが始まっていなければ訪問順のK番目
  if(K < l):
    print(s[K])
  # ループが始まっていたら
  else:
    k = K - l
    k %= c
    print(s[l + k])


if __name__ == "__main__":
  main()

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

int main()
{
    int a,b,c;
    cin>>a>>b;
    if(b==1) {cout<<0; return 0;}
    int n=1;c=a;
    while(c<b) n++,c+=a-1;
    cout<<n;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#include <bitset>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
const int MAX = 510000;
signed main(){
    int n;
    string s;
    cin>>n>>s;
    int cnt=0;
    int ans=n;
    for(int i=0;i<n;i++){
        if(cnt==0){
            cnt++;
        }else if(s[i]==s[i-1])cnt++;
        else {
            ans-=cnt-1;
            cnt=1;
        }
    }
    if(cnt!=0)ans-=cnt-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 512
import math
a, b, c = map(int, input().split())
print(0.5*a*b*math.sin(math.radians(c)))
print(a+b+(a**2+b**2-2*a*b*math.cos(math.radians(c)))**0.5)
print(b*math.sin(math.radians(c)))


Measured memory_bytes: 5720
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a,b,c,d,e;cin>>a>>b>>c>>d>>e;
  if(a==0)cout<<"1";
  else if(b==0)cout<<"2";
  else if(c==0)cout<<"3";
  else if(d==0)cout<<"4";
  else cout<<"5";
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll, ll>pll;
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll n, k;
    cin >> n >> k;
    n %= k;
    cout << min(n, abs(n - k));
    return 0 ;
}


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


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N), D(N);
  ll t = 0;
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    t += A.at(i);
  }
  ll u = N * (N+1) / 2;
  if (t % u != 0) {
    cout << "NO\n";
    return 0;
  }
  ll m = t / u;
  for (int i = 0; i < N-1; i++) D.at(i) = A.at(i + 1) - A.at(i);
  D.at(N-1) = A.at(0) - A.at(N-1);
  for (int i = 0; i < N; i++) {
    ll y = m - D.at(i);
    if (y < 0 || y % N != 0) {
      cout << "NO\n";
      return 0;
    }
  }
  cout << "YES\n";

  return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <utility>
using namespace std;

int main()
{
    long long n,m,i,temp1,temp2;
    cin >> n >> m;
    vector<pair<long long,long long>> c;
    for(i = 0;i < n;++i){
        cin >> temp1 >> temp2;
        c.emplace_back(temp1,temp2);
    }
    sort(c.begin(),c.end());
    i = 0;
    long long ans = 0;
    while(m){
        if(m < c.at(i).second){
            ans += c.at(i).first*m;
            break;
        }else{
            ans += c.at(i).first*c.at(i).second;
            m -= c.at(i).second;
            ++i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420