akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int N,M,X;	
	cin>>N>>M>>X;
	int A[M];
	int value=0;
	for(int i=0;i<M;i++){
		cin>>A[i];
		if(i!=0 && A[i-1]<X && X<A[i]){
			value = i;
		}
	}
	if((M-1-value+1)>value){
		cout<<value;
	}	else{
		cout<<M-value;
	}
	return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

fn main() {
    input!{
        mut s: chars,
    }
    let s_len = s.len();
    s.sort();
    s.dedup();

    println!("{}", if s_len == s.len() { "yes" } else { "no" })
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define EPS 1e-10
using namespace std;
typedef long long llong;
int main() {
	int n;
	cin >> n;
	while (n--) {
		int k, p;
		cin >> k >> p;
		cout << (k - 1) % p + 1 << endl;
			
	}
	return 0;
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define lli long long int
#define MOD 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define repf(i, n) for(int i=1; i<(int)(n+1); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    int cnt = 0;
    rep(i, s.size()) if(s.at(i) != s.at(s.size()-1-i)) cnt++;
    cout << cnt/2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
    
int main() {
    int S;
    cin >> S;
    for(int i=0; i<S; ++i) {
        vector<ll> N(9);
        for(int j=0; j<9; ++j) {
            cin >> hex >> N[j];
        }
  
        ll ans = 0;
        int c = 0;
        for(int bit=0; bit<32; ++bit) {
            int cnt = 0;
            for(int j=0; j<8; ++j) {
                if((N[j] >> bit) & 1) {
                    cnt++;
                }
            }
            if((cnt + c) % 2 == (N[8] >> bit) % 2) {
                c = (cnt + c)/2;
            } else {
                ans |= (1ll << bit);
                c = (8 - cnt + c)/2;
            }
        }
        cout << hex << ans << endl;
    }
}


Measured memory_bytes: 2956
#include <bits/stdc++.h>
#define el_cucuy ios_base::sync_with_stdio(0), cout.tie(0); cin.tie(0);
#define llong long long
#define pb push_back
#define bpc __builtin_popcount

const llong mxn = 1e6 + 7;
const llong mod = 1e9 + 7;
const llong inf = 1e18 + 9;

using namespace std;

llong n, k, a[mxn], dp[mxn];

int main(){
    el_cucuy
    cin >> n >> k;
    for (int i = 1; i <= n; i ++){
        cin >> a[i];
    }dp[1] = 0;
    dp[2] = abs(a[1] - a[2]);
    for (int i = 3; i <= n; i ++) dp[i] = inf;
    for (llong i = 3; i <= n; i ++){
        for (int j = min(i - 1, k); j >= 1; j --){
            dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
        }
    }cout << dp[n];
    return 0;
}


Measured memory_bytes: 5120
import math
n = int(input())
x = list(map(float,input().split()))
y = list(map(float,input().split()))
a = 0
b = 0
c = 0
d = [0 for i in range(n)]
for i in range(n):
    a += abs(x[i]-y[i])
    b += abs(x[i]-y[i])**2
    c += abs(x[i]-y[i])**3
    d[i] = abs(x[i]-y[i])
b = math.sqrt(b)
c = c**(1/3)
print('{:.6f}'.format(a))
print('{:.6f}'.format(b))
print('{:.6f}'.format(c))
print('{:.6f}'.format(max(d)))


Measured memory_bytes: 5732
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
typedef long long ll;
struct edge { ll s, t, x; };
typedef pair<ll, ll> P;
typedef pair<ll,P> event;
const ll MAX = 510000;
const ll MOD = 1000000007;
#define INF (ll)10000000000000000
//この設定だとn<10^7が限界。maxの０を一個増やせば100msかかるが一桁増やせる。
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
// 二項係数計算
long long 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] % MOD) % MOD;
}

int main() {
  COMinit();
  ll N,M,K;
  cin>>N>>M>>K;
  ll g=1ll;
  g*=COM(N*M-2,K-2);
  ll ans=0ll;
  rep(i,M){
    ll p=g*N*N;
    p%=MOD;
    ll q=0ll;
    q=q+((i+1ll)*i)/2ll;
    q=q+((M-i)*(M-i-1ll))/2ll;
    q%=MOD;
    ans+=p*q;
    ans%=MOD;
  }
  rep(i,N){
    ll p=g*M*M;
    p%=MOD;
    ll q=0ll;
    q+=((i+1ll)*i)/2ll;
    q+=((N-i)*(N-i-1ll))/2ll;
    q%=MOD;
    ans+=p*q;
    ans%=MOD;
  }
  ans*=modinv(2ll,MOD);
  ans%=MOD;
  cout<<ans<<endl;
}

Measured memory_bytes: 15524
import collections
n = int(input())
s = [i for i in input()]
m = 0
for i in range(1,n):
    x = s[0:i]
    y = s[i:n]
    c1 = collections.Counter(x)
    c2 = collections.Counter(y)
    d1 = set(c1.keys())
    d2 = set(c2.keys())
    e = list(d1 & d2)
    m = max(m,len(e))
print(m)

Measured memory_bytes: 3316
main = do
    [n,a,b] <- map read . words <$> getLine
    h <- map read . words <$> getContents
    print $ solve h a b
inf = 10^9+1
solve h a b = binalySearch inf 0 (f h a b)
  where binalySearch ok ng f
          | abs (ok-ng) <= 1 = ng + 1
          | f mid = binalySearch mid ng f
          | otherwise = binalySearch ok mid f
            where mid = (ok + ng) `div` 2
        f h a b c = s <= c
          where s = sum [max 0 (hi - b*c + a - b - 1) `div` (a-b) | hi <- h]

Measured memory_bytes: 16976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[i];
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 (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    int K; cin >> K;
    priority_queue< ll , vector<ll>, greater<> > pq;
    for(ll i = 1; i < 10; i++) pq.push(i);
    ll now;
    while(K) {
        now = pq.top(); pq.pop();
        if(now%10 == 0) {
            pq.push(now*10);
            pq.push(now*10 + 1);
        }
        else if(now%10 == 9) {
            pq.push(now*10 + now%10);
            pq.push(now*10 - 1 + now%10);
        }
        else {
            pq.push(now*10 + now%10);
            pq.push(now*10 - 1 + now%10);
            pq.push(now*10 + 1 + now%10);
        }
        K--;
        //cout << now << endl;
    }
    cout << now << endl;
}

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

using namespace std;

#define rep(i,x) for (int i = 0 ; i < x; ++i)
#define rrep(i,x) for (int i = x - 1; i >= 0; --i)
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sqr(x) ((x) * (x))
#define re return

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;


void GO(){
#ifdef DOD
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

const int INF = 1e9 + 1;
const ll mod = 1e9 + 7;






//Var
//
 void input() {
     int a; cin >> a;
     cout << a + a * a + a * a * a;
 }

void solve(){
     
}








///Я призер Всеросса
int main() {
    GO();
    int Q = 1;
    while(Q--){ input(); solve(); } re 0;
}
///Я Кондедат в мастера


Measured memory_bytes: 3604
/*
   ,##.                   ,==.
 ,#    #.                 \ o ',
#        #     _     _     \    \
#        #    (_)   (_)    /    ; 
 `#    #'                 /   .'  
   `##'                   "=="
*/

#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <complex>
#include <cassert>
#define ll long long
#define null NULL
#define all(a) a.begin(), a.end()
#define debug(a) cerr << #a << " = " << a << endl
#define forn(i, n) for (int i = 0; i < n; ++i)

using namespace std;

const ll MOD = 1e9 + 7;

const int mx = 3e5;
int n, a[mx], p[mx];

int main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
		a[i]--;
		p[a[i]] = i;
	}
	int res = 0, cur = 1;
	for (int i = 1; i <= n; ++i) {
		if (i == n || p[i] < p[i - 1]) {
			res = max(res, cur);
			cur = 1;
		}
		else
			cur++;
	}
	cout << n - res << endl;
}

Measured memory_bytes: 1792
import heapq
n = int(input())
p = []
q = []
for i in range(n):
    x,y = map(int, input().split())
    p.append((x, y, i))
    q.append((y, x, i))

p.sort()
q.sort()
pid = [0 for i in range(n)]
qid = [0 for i in range(n)]
for i in range(n):
    pid[p[i][2]] = i
    qid[q[i][2]] = i
used = [False] * n

total = 0

hq = [(0, 0)]
cnt = 0
s = set()
while hq and cnt < n:
    c, i = heapq.heappop(hq)
    # print(c, i)
    if i not in s:
        cnt += 1
        s.add(i)
        total += c
    else:
        continue
    pi = pid[i]
    qi = qid[i]
    if pi > 0 and p[pi-1][2] not in s:
        heapq.heappush(hq, (p[pi][0] - p[pi-1][0], p[pi-1][2]))
    if pi < n-1 and p[pi+1][2] not in s:
        heapq.heappush(hq, (p[pi+1][0] - p[pi][0], p[pi+1][2]))
    if qi > 0 and q[qi-1][2] not in s:
        heapq.heappush(hq, (q[qi][0] - q[qi-1][0], q[qi-1][2]))
    if qi < n-1 and q[qi+1][2] not in s:
        heapq.heappush(hq, (q[qi+1][0] - q[qi][0], q[qi+1][2]))
    
        

print(total)

Measured memory_bytes: 50996
import sys
#from me.io import dup_file_stdin

#@dup_file_stdin
def solve():
    for s in map(int,sys.stdin):
        results=set()
        for a in range(10):
            for b in range(10):
                for c in range(10):
                    d = s-a-b-c
                    if d<0:break
                    if d<=9: results.add((a,b,c,d))
        print(len(results))
solve()

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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;

const int oo = 0x3f3f3f3f;

const int maxn = 20100;

int n;
int a[maxn + 5], b[maxn + 5];
int p[maxn + 5];

int main()
{
#ifdef matthew99
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	scanf("%d", &n);
	REP(i, 0, n) scanf("%d", p + i), --p[i];
	REP(i, 0, n) a[i] = (i + 1) * maxn;
	REP(i, 0, n) b[i] = (n - i) * maxn;
	REP(i, 0, n) a[p[i]] += i;
	REP(i, 0, n - 1) 
	{
		assert(a[i] >= 1 && a[i] <= 1e9);
		assert(b[i] >= 1 && b[i] <= 1e9);
		assert(a[i] < a[i + 1]);
		assert(b[i] > b[i + 1]);
		assert(a[p[i]] + b[p[i]] < a[p[i + 1]] + b[p[i + 1]]);
	}
	REP(i, 0, n) printf("%d ", a[i]);
	printf("\n");
	REP(i, 0, n) printf("%d ", b[i]);
	printf("\n");
	return 0;
}


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

int main() {
    int n; cin>>n;
    int count=0;
    if(n%10==2) count++;
    n/=10;
    if(n%10==2) count++;
    n/=10;
    if(n%10==2) count++;
    n/=10;
    if(n%10==2) count++;
    n/=10;
    cout<<count<<endl;
	return 0;
}

Measured memory_bytes: 256
R, C = map(int, input().split())
grids = [list(input()) for _ in range(R)]
dp = [[0] * (C) for _ in range(R)]
dp[0][0] = 1
for i in range(1, R):
  if grids[i][0] != '#':
    dp[i][0] = dp[i-1][0]
for i in range(1, C):
  if grids[0][i] != '#':
    dp[0][i] = dp[0][i-1]
for i in range(1, R):
  for j in range(1, C):
    if grids[i][j] == '#':
      dp[i][j] = 0
    else:
      dp[i][j] = dp[i-1][j] + dp[i][j-1]
print(dp[R-1][C-1]%(10**9+7))


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

int main(){
  vector<char> C(6);
  repeat(i,6) cin >>C.at(i);
  
  string ans;
  if(C[0]==C[5] and C[1]==C[4] and C[2]==C[3]) ans="YES";
  else ans="NO";
  
  cout <<ans<< endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>=n;--i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,m,n,i,f=0,j,ans=0;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i,n) cin >> a[i] ;
    sort(a.begin(),a.end());
    rep(i,m) ans+=a[i];
    cout << ans ;
   
    
    return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{
    int W, H;
    int x, y, r;
   
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    W -= r, H -= r;
    if (r <= x && x <= W && r <= y && y <= H) printf("Yes\n");
    else printf("No\n");
    return 0;
}



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

using namespace std;
#define ll long long 
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int a,b;
	cin >> a >> b;
	cout << max(max(a+b, a-b), a*b);
	return 0;	
}


Measured memory_bytes: 3584
//#pragma GCC optimize("03,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb           push_back
#define ff           first
#define ss           second
#define gcd(a, b)    __gcd(a, b)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define lllim        2147483648
#define Pi           2*acos(0.0)
#define sci(n)	     scanf("%d",&n)
#define scii(n,m)    scanf("%d%d",&n,&m)
#define scl(n)       scanf("%lld",&n)
#define scll(n,m)    scanf("%lld%lld",&n,&m)
#define pii          pair<int,int>
#define pll 	     pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
#define MOD          1000000007
#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define filein       freopen("input.txt","r", stdin)
#define D(x)         cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define case		 int t,cas=1;cin>>t;while(t--)
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define rev(i,n,a)   for(int i=n;i>=a;i--)

/*------------------------------Graph Moves----------------------------*/
const int fx[]= {+1,-1,+0,+0};
const int fy[]= {+0,+0,+1,-1};
//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

using namespace std;
using namespace __gnu_pbds;

const int maxn=200002;


void solve()
{
	ll x;
	cin>>x;
	
	ll ag= gcd(x,360ll);
	
	ll ans=360/ag;
	
	cout<<ans<<endl;

}


int main()
{
    fast_cin;
    //while(scanf("%d",&n)!=EOF)
//case
    {
        //cout<<""<<cas++<<""<<endl;
        solve();
    }

    return 0;
}


Measured memory_bytes: 3660
n, k = map(int, input().split())
a = list(map(int, input().split()))

left = 0
right = max(a)

while right - left > 1:
    mid = (right + left) // 2
    tmp = 0
    for i in a:
        tmp += (i - 1) // mid
    
    if tmp <= k:
        right = mid
    else:
        left = mid
        
print(right)

Measured memory_bytes: 30980
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
int a[126], b[126], c[126], d[126]; bool ta[126], tb[126], tc[126]; string S, R1, R2, R3;
int main() {
	while (cin >> S) {
		int s = 0; R1 = ""; R2 = ""; R3 = "";
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == '+') { s++; continue; }
			if (S[i] == '=') { s++; continue; }
			if (s == 0) R1 += S[i];
			if (s == 1) R2 += S[i];
			if (s == 2) R3 += S[i];
		}
		for (int i = 0; i < 126; i++) ta[i] = false, a[i] = 0;
		for (int i = 0; i < 126; i++) tb[i] = false, b[i] = 0;
		for (int i = 0; i < 126; i++) tc[i] = false, c[i] = 0;
		reverse(R1.begin(), R1.end()); for (int i = 0; i < R1.size(); i++) { if (R1[i] == 'X') ta[i] = true; else a[i] = R1[i] - 48; }
		reverse(R2.begin(), R2.end()); for (int i = 0; i < R2.size(); i++) { if (R2[i] == 'X') tb[i] = true; else b[i] = R2[i] - 48; }
		reverse(R3.begin(), R3.end()); for (int i = 0; i < R3.size(); i++) { if (R3[i] == 'X') tc[i] = true; else c[i] = R3[i] - 48; }
		bool ok = false;
		for (int i = 0; i < 10; i++) {
			if (i == 0) {
				bool flag1 = ta[R1.size() - 1] && R1.size() > 1;
				bool flag2 = tb[R2.size() - 1] && R2.size() > 1;
				bool flag3 = tc[R3.size() - 1] && R3.size() > 1;
				if (flag1 || flag2 || flag3) continue;
			}
			for (int j = 0; j < R1.size(); j++) if (ta[j]) a[j] = i;
			for (int j = 0; j < R2.size(); j++) if (tb[j]) b[j] = i;
			for (int j = 0; j < R3.size(); j++) if (tc[j]) c[j] = i;
			for (int j = 0; j < 126; j++) d[j] = 0;
			for (int j = 0; j < 126; j++) { d[j] += a[j] + b[j]; if (j != 125) d[j + 1] += d[j] / 10, d[j] %= 10; }
			bool flag = true;
			for (int j = 0; j < 126; j++) if (c[j] != d[j]) flag = false;
			if (flag) {
				printf("%d\n", i); ok = true; break;
			}
		}
		if (!ok) {
			printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 3068
n_k = list(map(int,input().split()))
chr_lr = list(input())
cnt_rl = 0
cnt_con = 0

for i in range(n_k[0]-1):
  if(chr_lr[i] == chr_lr[i+1]):
    cnt_con += 1

sum = min(cnt_con + 2*n_k[1],n_k[0]-1)
print(sum)

Measured memory_bytes: 3956
using System;
using System.Collections.Generic;
using System.Linq;

public class Hello
{
    public static void Main()
    {
        Calc calc = new Calc();
        List<double[]> ans = new List<double[]>();

        int n = int.Parse(Console.ReadLine());

        for (int i = 0; i < n; i++)
        {
            List<double> input = new List<double>();
            double[] ans2 = new double[3];
            input = Console.ReadLine().Split(' ').Select(double.Parse).ToList();
            ans2 = calc.Triangle(input);
            ans.Add(ans2);
        }

        for (int i = 0; i < n; i++)
        {
            Console.WriteLine("{0:f3} {1:f3} {2:f3}", ans[i][0], ans[i][1], ans[i][2]);
        }
    }
  
}
class Calc
{
    internal double[] Triangle(List<double> input)
    {
        double px, py, r;
        double[] ans = new double[3];

        double x1 = input[0];    double y1 = input[1];
        double x2 = input[2];    double y2 = input[3];
        double x3 = input[4];    double y3 = input[5];

        double a = Math.Sqrt(Math.Pow(x2 - x1, 2) + Math.Pow(y2 - y1, 2));
        double b = Math.Sqrt(Math.Pow(x3 - x1, 2) + Math.Pow(y3 - y1, 2));
        double c = Math.Sqrt(Math.Pow(x3 - x2, 2) + Math.Pow(y3 - y2, 2));
        double cos_theta = (Math.Pow(a, 2) + Math.Pow(b, 2) - Math.Pow(c, 2)) / ((double)2 * a * b);
        double sin_theta = Math.Sqrt(1 - Math.Pow(cos_theta, 2));

        if (a == 0 && b == 0 && c == 0)
        {
            px = x1;
            py = y1;
            r = 0;
        }
        else if (c==0)
        {
            px = (x2 - x1) / (double)2;
            py = (y2 - y1) / (double)2;
            r = Math.Sqrt(Math.Pow(px, 2) + Math.Pow(py, 2)) / (double)2;
        }
        else if (sin_theta == 0)
        {
            px = Double.NaN;
            py = Double.NaN;
            r = Double.NaN;
        }
        else
        {
            double[] vector12 = new double[2] {x2 - x1, y2 - y1};
            double[] vector_v = new double[2] {-(y3 - y2), x3 - x2};
            double magnitude = Math.Sqrt(Math.Pow(vector_v[0], 2) + Math.Pow(vector_v[1], 2));
            double inner_product = vector12[0] * vector_v[0] + vector12[1] * vector_v[1];

            if (inner_product > 0)
            {
                vector_v[0] = -vector_v[0] / magnitude;
                vector_v[1] = -vector_v[1] / magnitude;
            }
            else
            {
                vector_v[0] = vector_v[0] / magnitude;
                vector_v[1] = vector_v[1] / magnitude;
            }

            r = c / ((double)2 * sin_theta);

            double cx = (x3 + x2) / (double)2;
            double cy = (y3 + y2) / (double)2;
            px = cx + r * cos_theta * vector_v[0];
            py = cy + r * cos_theta * vector_v[1];
        }

        ans[0] = Math.Round(px, 3, MidpointRounding.AwayFromZero);
        ans[1] = Math.Round(py, 3, MidpointRounding.AwayFromZero);
        ans[2] = Math.Round(r, 3, MidpointRounding.AwayFromZero);
        return ans;
    }
}


Measured memory_bytes: 16380
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  ll n, d, a;
  cin >> n >> d >> a;
  vector<vector<ll>> x(n, vector<ll>(2, 0));
  rep(i, n) cin >> x[i][0] >> x[i][1];

  sort(ALL(x));

  deque<pair<ll, ll>> imo;
  ll ans = 0;
  ll cur = 0;  // 現在位置が何回爆破されたか

  rep(i, n) {
    while (!imo.empty() && imo.front().first <= x[i][0]) {
      cur += imo.front().second;
      imo.pop_front();
    }

    x[i][1] -= cur * a;
    if (x[i][1] > 0) {
      ll num = max(ll(0), (x[i][1] + a - 1) / a);  // i 番目のモンスターを仕留めるのに必要な bomb
      cur += num;
      imo.push_back(make_pair(ll(x[i][0] + 2 * d + 1), -num));
      ans += num;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 12800
import math


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


def main():
    N = int(input())
    MOD = 10**9 + 7

    A = [0 for _ in range(N + 1)]
    for i in range(2, N + 1):
        x = factorization(i)
        for a, b in x:
            A[a] += b

    ans = 1
    for a in A:
        ans *= (a + 1)
        ans %= MOD

    print(ans)


main()


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

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

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<int> vi;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int) (x).size()

int n;
int x;

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n >> x;
    if(x == 1 or x == 2 * n - 1){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
        vector<int> ans;
        if(x == n){
            for(int i = 1;i <= 2 * n - 1;i++){
                ans.pb(i);
            }
        }else if(x < n){
            int j = 1;
            for(int i = 1;i < x - 1;i++, j++){
                ans.pb(i);
            }
            for(int i = x + 1;j <= n - 2;j++, i++){
                ans.pb(i);
            } 
            ans.pb(x - 1);
            ans.pb(x);
            for(int i = n + 1;i < 2 * n;i++){
                ans.pb(i);
            }
        }else{
            for(int i = 1;i < n;i++){
                ans.pb(i);
            }
            ans.pb(x);
            ans.pb(x + 1);
            for(int i = n;i < 2 * n;i++){
                if(i == x or i == x + 1){
                    continue;
                }
                ans.pb(i);
            }
        }
        for(int i = 0;i < sz(ans);i++){
            cout << ans[i] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    while(1){
        int N,M;
        cin >> N >> M;
        if(N == 0) break;
        vector<int> A(N+1);
        for(int i=1; i<=N; i++) cin >> A[i];
        int pos = 1;
        int ans = -1;
        vector<int> q(M);
        for(int i=0; i<M; i++) cin >> q[i];
        for(int i=0; i<M; i++){
            pos += q[i];
            if(pos>=N){
                ans = i+1;
                break;
            }
            pos += A[pos];
            if(pos>=N){
                ans = i+1;
                break;
            }
        }
        cout << ans << enld;
    }
    return 0;
}


Measured memory_bytes: 3128
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

typedef long long ll;

const ll mod = 1e9+7;

ll x[2010];
int S;

int main(){
	x[1]=x[2]=0,x[3]=x[4]=x[5]=1;
	for(int i=6;i<2010;i++){
		x[i]=(x[i-1]+x[i-3])%mod;
	}
	scanf("%d",&S);
	printf("%d",x[S]);
	return 0;
}

Measured memory_bytes: 1708
#include <bits/stdc++.h>
#define ll long long
#define pet pair<int,int>
#define one first
#define two second

#ifdef debug
#define cin fin 
#define fileopen fin.open("test.txt");
#else
#define fileopen
#endif

#define int long long
#define big 1000000007
#define all(x) x.begin(),x.end()

using namespace std;

ifstream fin;

vector<vector<int>> primes;

int power(int a,int b,int m=big)
{
	if(b==0)
	return 1;

	int ans=power(a,b/2,m);
	if(b%2==0)
	return ans*ans%m;

	return ((a*ans)%m*ans)%m;
}

int inverse(int a,int m=big)
{
	return power(a,m-2,m);
}

int ceil(int a,int b)
{
	return (a-1)/b+1;
}

void init_prime()
{
	int size=1e6+1;
	primes.resize(1e6);

	for(int i=2;i<size;i++)
	{
		if(primes[i].size()==0)
		{
			for(int j=i;j<size;j+=i)
			primes[j].push_back(i);
		}
	}
}

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


/*_______________________________

			START
			FROM
			BELOW

		  #pragyanc2#
________________________________
*/

void solve()
{
    int n,m;
    cin >> n >> m;

    cout << n*(n-1)/2 + m*(m-1)/2<< endl;
}

signed main()
{
	fileopen
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
	//init_prime();

	int t=1;
	//cin >> t;

	for(int i=1;i<=1;i++)
	solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a,b,c,d,n,k;
    cin>>n;
    if(n%1000==0) cout<<n%1000;
    else cout<<(1000-(n%1000));
    return 0;
}

Measured memory_bytes: 3636
A, B, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)
for _ in range(m):
    x, y, c= map(int, input().split())
    ans = min(a[x - 1] + b[y - 1] - c, ans)
print(ans)

Measured memory_bytes: 18736
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
      int N = nextInt();
      ArrayList<Integer> list = nextIntArray();
      int max = 0;
      for(int i = 0; i < N - 1; i++){
        for(int j = i + 1; j < N; j++){
          max = Math.max(max, Math.abs(list.get(i) - list.get(j)));
        }
      }
      myout(max);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 32964
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>
#include <iostream>

using namespace std;
int a[100000];

int main() {
	int n, q;
	string s;
	scanf("%d %d", &n, &q);
	cin >> s;
	for (int i = 1; i < n; i++) {
		if (s[i - 1] == 'A' && s[i] == 'C') {
			a[i] += a[i - 1] + 1;
		}
		else {
			a[i] += a[i - 1];
		}
	}
	for (int i = 0; i < q; i++) {
		int b, c;
		scanf("%d %d", &b, &c);
		printf("%d\n", (a[c-1] - a[b-1]));
	}
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 3005;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int n, mod;
int c[MAXN][MAXN], s[MAXN][MAXN];

inline void Inc(int &x, int y) {
	x += y; if (x >= mod) x -= mod;
}

inline void Dec(int &x, int y) {
	x -= y; if (x < 0) x += mod;
}

inline int Mul(int x, int y, int md) {
	return 1LL * x * y % md;
}

inline int ksm(int x, int k, int md) {
	int ret = 1;
	while (k) {
		if (k & 1) ret = Mul(ret, x, md);
		x = Mul(x, x, md);
		k >>= 1;
	}
	return ret;
}

void init() {
	read(n); read(mod);
	c[0][0] = s[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		c[i][0] = s[i][0] = 1;
		for (int j = 1; j <= i; ++j) {
			c[i][j] = c[i - 1][j];
			Inc(c[i][j], c[i - 1][j - 1]);
			s[i][j] = Mul(s[i - 1][j], j + 1, mod);
			Inc(s[i][j], s[i - 1][j - 1]);
		}
	}
}

void solve() {
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		int res = 0;
		int a = ksm(2, n - i, mod), b = ksm(2, ksm(2, n - i, mod - 1), mod);
		for (int j = 0; j <= i; ++j) {
			Inc(res, Mul(s[i][j], b, mod));
			b = Mul(b, a, mod);
		}
		res = Mul(res, c[n][i], mod);
		(i & 1)? Dec(ans, res) : Inc(ans, res);
	}
	printf("%d\n", ans);
}

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


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

int main() {
  string s;
  vector<int> vec(26);
  while(getline(cin,s)){
  for(int i =0;i < s.size();i++){
    if(s.at(i)>='a' && s.at(i)<='z') vec.at(s.at(i)-'a')++;
    else if(s.at(i)>='A' && s.at(i)<='Z') vec.at(s.at(i)-'A')++;
  }
  }
  
  for(int i=0;i<26;i++){
    cout <<char('a'+i) << " : " << vec.at(i) << endl;
  }
}


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

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] a = new int[m];
		int[] b = new int[m];
		int[] c = new int[m];
		int[][] min = new int[n][n];
		for (int i = 0; i < n; i++) {
			Arrays.fill(min[i], 1 << 20);
			min[i][i] = 0;
		}
		for (int i = 0; i < m; i++) {
			a[i] = sc.nextInt() - 1;
			b[i] = sc.nextInt() - 1;
			c[i] = sc.nextInt();
			min[a[i]][b[i]] = Math.min(min[a[i]][b[i]], c[i]);
			min[b[i]][a[i]] = Math.min(min[b[i]][a[i]], c[i]);
		}

		for (int k = 0; k < n; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					min[i][j] = Math.min(min[i][j], min[i][k] + min[k][j]);
				}
			}
		}

		boolean[] flag = new boolean[m];
		for (int k = 0; k < m; k++) {
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < n; j++) {
					if (min[i][a[k]] + c[k] + min[b[k]][j] == min[i][j]) {
						flag[k] = true;
						break;
					}
				}
			}
		}

		int count = 0;
		for (int i = 0; i < m; i++) {
			if (flag[i]) {
				count++;
			}
		}
		System.out.println(m - count);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}


Measured memory_bytes: 14752
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

K = INT()
N = 2 ** K
A = LIST(N)

while len(A) >= 2:
    tmp = []
    for i in range(len(A)//2):
        a, b = A[i*2], A[i*2+1]
        if a == b:
            tmp.append(a)
        else:
            tmp.append(abs(a - b))
    A = tmp
print(A[0])


Measured memory_bytes: 18656
#include <bits/stdc++.h>
        #define ll  long long int
        #define fast    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
        #define mod 1000000007
        using namespace std;
    
        int main()
            {fast;
            ll t =1;
            //cin>>t;

        while(t--){
            string  t, s;
            cin>>s>>t;
            ll ans=10000;

            for(int i=0; i+t.size()-1<s.size(); i++){
                ll temp=0;
                for(int j=0; j<t.size();j++)
                    if(s[i+j]!=t[j])
                        temp++;
                ans=min(temp,ans);
            }
            cout<<ans;
            
        }
                return 0;
        }

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int n,m;
int Map[55][55];
int visit[55];
int x[1000],y[1000],z[1000];
int main()
{
    int a,ans = 0;
    cin >> n;
	cin >> m;
	for (int i = 1; i <= m; i++)
	{
		cin >> x[i];
		cin >> y[i];
	}
	for (int i = 1; i <= m; i++)
	{
		a = 1;
		for (int k = 1; k <= n; k++)
		{
			z[k] = k;
		}
		while (a == 1)
		{
			a = 0;
			for (int k = 1; k <= m; k++)
			{
				if (k != i&&z[x[k]] != z[y[k]])
				{
					z[x[k]] = min(z[x[k]], z[y[k]]);
					z[y[k]] = min(z[x[k]], z[y[k]]);
					a = 1;
				}
			}
		}
		a = 0;
		for (int k = 1; k <= n; k++)
		{
			if (z[k] != 1)
			{
				a = 1;
				break;
			}
		}
		if (a == 1)
		{
			ans++;
		}
	}




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


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC167
{
    class Program
    {
        static void Main(string[] args)
        {
            a();
        }

        public static void a()
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int a = s.Length;
            for(int i = 0; i < a; i++)
            {
                if(s[i] != t[i])
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            Console.WriteLine("Yes");
        }
    }
}


Measured memory_bytes: 25880
#include <iostream>
#include <vector>
#include <string>

using namespace std;

bool check(int n, string &s, vector<int> &t) {
    for (int i = 0; i < n; i++) {
        if (t[i] && s[i] == 'o' && t[(i+1)%n] == t[(i-1+n)%n])
            return false;
        else if (t[i] && s[i] == 'x' && t[(i+1)%n] != t[(i-1+n)%n])
            return false;
        else if (!t[i] && s[i] == 'x' && t[(i+1)%n] == t[(i-1+n)%n])
            return false;
        else if (!t[i] && s[i] == 'o' && t[(i+1)%n] != t[(i-1+n)%n])
            return false;
    }
    return true;
}

bool construct(int n, string &s, int u, int v, vector<int> &t) {
    t.resize(n);
    t[0] = u;   t[1] = v;
    for (int i = 2; i < n; i++) {
        if (s[i-1] == 'o' && t[i-1])
            t[i] = 1-t[i-2];
        else if (s[i-1] == 'o' && !t[i-1])
            t[i] = t[i-2];
        else if (s[i-1] == 'x' && t[i-1])
            t[i] = t[i-2];
        else 
            t[i] = 1 - t[i-2];
    }
    
    return check(n, s, t);
}

int main() {
    int n;  cin >> n;
    string s;   cin >> s;
    vector<int> t;
    char c[] = {'S', 'W'};

    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            if (construct(n, s, i, j, t)) {
                for (int k = 0; k < n; k++)
                    cout << c[t[k]];
                cout << endl;
                return 0;
            }
        }
    }
    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3824
// ~/Remember,remember the 6th of March

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const double PI = acos(-1.0);
const double  EPS = 1e-8;
const ll MOD = 1000000007;
const int N = 100000 + 7;

int main()
{
    int n,r;
    cin>>n>>r;
    if(n<10){
        r+=100*(10-n);
    }
    cout<<r<<endl;
    return 0;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
struct edge{ll to,cost;};
const int inf = 1<<27;
const ll INF = 1LL<<60;
const int COMBMAX = 1001001;
const ll MOD = 1000000007;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for(const auto& e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (ll)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (ll)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
ll mpow(ll a, ll n, ll mod = MOD){ll res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void YesNo(bool j){cout << (j ? "Yes" : "No") << endl; return;}
void yesno(bool j){cout << (j ? "yes" : "no") << endl; return;}
template<class Head> void pt(Head&& head){cout << head << endl; return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> ll bcount(T1 v, T2 a){return upper_index(v, a) - lower_index(v, a);} 
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> void sortTwoVecter(vector<T1> &f, vector<T2> &s, bool isReverse = false){
    vector<pair<T1, T2>> p;
    rep(i, f.size()) p.emplace_back(make_pair(f[i], s[i]));
    if (!isReverse) sort(p.begin(), p.end());
    else sort(p.rbegin(), p.rend());
    rep(i, f.size()) tie(f[i], s[i]) = p[i];
    return;
}

int main(){
    ll N, K ,C; cin >> N >> K >> C;
    string sc; cin >> sc;;
    ll rem = 0;
    vector<ll> day;
    rep(i, N){
        rem--;
        if (rem < 0 && sc[i] == 'o'){
            day.emplace_back(i);
            rem = C;
        } 
    }
    vector<ll> need;
    // debug(day);
    vector<ll> rday;
    rday = day;
    reverse(all(rday));
    ll id = day.size();
    if (K < id){
        return 0;
    }
    eachdo(rday,d){
        id--;
        bool ok = true;
        for(ll i = d + C; d < i; i--){
            if (N <= i) continue;
            if (sc[i] == 'o'){
                if (lower_index(day, i) == upper_index(day, i + C)){
                    ok = false;
                    day[id] = i;
                    break;
                }
            }
        }
        if (ok) need.emplace_back(d + 1);
    }
    reverse(all(need));
    eachdo(need, e) pt(e);
    return 0;
}

Measured memory_bytes: 6644
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#include <time.h>
#include <iostream>
#include <vector>
#include <map>
#define ll long long int
using namespace std;
int main()
{
  ll n, k;
  cin >> n >> k;
  //map<ll, ll> a;
  vector<ll> a(n + 1);
  vector<bool> seen(n + 1, false);
  seen[1] = true;
  for (ll i = 1; i < n + 1; i++)
  {
    cin >> a[i];
  }
  if (k < n)
  {
    int now = 1;
    for (ll i = 0; i < k; i++)
    {
      now = a[now];
    }
    cout << now << endl;
    return 0;
  }
  ll now = 1;
  k--;
  for (; k != 0; k--)
  {
    now = a[now];
    if (seen[now])
      break;
    seen[now] = true;
  }
  if (k == 0)
  {
    cout << now << endl;
    return 0;
  }
  vector<bool> seen_2(n + 1, false);
  seen_2[now] = true;
  ll repeat = 1;
  for (ll i = 0;; i++)
  {
    now = a[now];
    if (seen_2[now])
      break;
    seen_2[now] = true;
    repeat++;
  }
  // cout << k << endl;
  // cout << repeat << endl;
  k %= repeat;
  // cout << k << endl;
  for (ll i = 0; i < k; i++)
  {
    now = a[now];
  }
  cout << now << endl;

  return 0;
}


Measured memory_bytes: 4844
h,w=map(int,input().split())
a=[[1 if s=='#' else 0 for s in input()] for i in range(h)]
H=[]
W=[]
at=list(map(list,zip(*a)))
for i in range(h):
    if sum(a[i])==0:
        H.append(i)
for i in range(w):
    if sum(at[i])==0:
        W.append(i)
ans=[]
for i in range(h):
    if i not in H:
        ans.append([])
        for j in range(w):
            if j not in W:
                if a[i][j]==1:
                    ans[-1].append('#')
                else:
                    ans[-1].append('.')
for i in range(len(ans)):
    print(''.join(ans[i]))


Measured memory_bytes: 39152