akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

typedef long long i64;

const int MOD = 924844033;

vector<int> calcDp(int n) {
    vector<int> dp0(n / 2 + 1, 0);
    dp0[0] = 1;
    vector<int> dp1 = dp0;
    for (int i = 2; i <= n; ++i) {
        vector<int> dp2(n / 2 + 1, 0);
        dp2[0] = 1;
        for (int j = 1; j + j <= i; ++j) {
            dp2[j] = (dp1[j] + dp0[j - 1]) % MOD;
        }
        dp0.swap(dp1);
        dp1.swap(dp2);
    }
    return dp1;
}

vector<int> addDp(const vector<int>& a,
                  const vector<int>& b) {
    vector<int> c(SZ(a) + SZ(b) - 1, 0);
    for (int i = 0; i < SZ(a); ++i) {
        for (int j = 0; j < SZ(b); ++j) {
            c[i + j] += (int64_t) a[i] * b[j] % MOD;
            c[i + j] %= MOD;
        }
    }
    return c;
}

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    vector<int> fact(n + 1, 0);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) {
        fact[i] = (int64_t) fact[i - 1] * i % MOD;
    }

    vector<int> dp(1, 1);
    for (int i = 0; i < n; ++i) {
        if (i < k) {
            int cnt = 0;
            for (int j = i; j < n; j += k) {
                cnt++;
            }
            vector<int> ndp = calcDp(cnt);
            dp = addDp(dp, ndp);
            dp = addDp(dp, ndp);
        }
    }
    
    int ans = 0;
    for (int i = 0; i < SZ(dp); ++i) {
        int add = (int64_t) fact[n - i] * dp[i] % MOD;
        if (i & 1) {
            add = -add;
        }
        ans = (ans + add) % MOD;
    }

    ans %= MOD;
    if (ans < 0) {
        ans += MOD;
    }
    cout << ans << '\n';
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

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

    int ans = 0;

    if (N % 2 == 0) {
        ans = N / 2 - 1;
    } else {
        ans = N / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int n,m;
	int minn=100000;
	cin>>n>>m;
	for(int i=m/n;i>0;i--)
		if(m%i==0)
			{
				cout<<i<<endl;
				return 0;
			}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef vector<int> V;

ll gcd(ll m, ll n) {
  if (m%n == 0) return n;
  else return gcd(n, m%n);
}

int main() {
  ll n, x;
  cin >> n >> x;
  vector<ll> a(n+1), b(n);
  for (ll i = 0; i < n; i++) cin >> a[i];
  a[n] = x;
  sort(a.begin(), a.end());
  for (int i = 0; i < n; i++) b[i] = a[i+1]-a[i];
  sort(b.begin(), b.end());
  ll ret = b[0];
  for (ll i = 0; i < n; i++) {
    ret = gcd(ret, b[i]);
  }
  dump(ret);
  return 0;
}


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


#define rep(i,n) for (int i=0; i<(n); i++)
//const int INF =1001001001;
const ll BIG = 1e9+7;
const double PI = 3.141592653589793;

int main(){
    ll h;
    cin >> h;
    ll ans = 0;
    ll i = 1;
    ans += i;
    queue<int> q;
    //q.push(i);
    while(h!=1){
        h = floor(h/2);
        i *= 2;
        ans = ans + i;
        //q.push(i);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef long long ll;
typedef unsigned long long llu;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
typedef pair<char, int> pci;
typedef pair<int, char> pic;
const long double PI = 3.141592653589793238462643383279502884197;
ll MOD;

ll fac[1] = {1}, inv[1] = {1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll mp(ll a,ll b){ll ret=1;while(b){if(b&1)ret=ret*a%MOD;a=a*a%MOD;b>>=1;}return ret;}
ll cmb(ll r, ll c) {return fac[r] * inv[c] % MOD * inv[r - c] % MOD;}

priority_queue<int, vector<int>, greater<int>> pq;
vector<int> v;

int n;
char s[200001];
ll two[200001][3]; //-1,0,1 순서.

int f(int o) {
    if (o == 0) return 0;
    int cnt = __builtin_popcount(o);
    return f(o%cnt)+1;
}

int main() {
    scanf("%d %s", &n, s);

    int cnt = 0;
    for (int i = 0; i < n; i++) {
        s[i] -= '0';
        cnt += s[i];
    }

    for (int j = 0; j < 3; j++) {
        two[0][j] = 1;
        if (j==0 && cnt == 1 || j==1 && cnt==0) continue;
        for (int i = 1; i < n; i++)
            two[i][j] = two[i-1][j]*2 % (cnt+j-1);
    }

    int oc = cnt;
    ll now[3] = {0};
    reverse(s, s+n);

    for (int j = 0; j < 3; j++) {
        if (j==0 && cnt == 1 || j==1 && cnt==0) continue;
        for (int i = n - 1; i >= 0; i--) {
            now[j] = (now[j] + s[i] * two[i][j]) % (cnt+j-1);
        }
    }

    for (int i = n-1; i >= 0; i--) {
        cnt -= s[i];
        s[i] ^= 1;
        cnt += s[i];

        int j = cnt-oc + 1;
        ll pre = now[j];

        if (cnt == 0) printf("%d\n", 0);
        else {
            if (s[i] == 0) now[j] = (now[j] - two[i][j] + cnt) % cnt;
            else now[j] = (now[j] + two[i][j]) % cnt;

            printf("%d\n", f(now[j])+1);
            now[j] = pre;
        }

        cnt -= s[i];
        s[i] ^= 1;
        cnt += s[i];
    }
}

Measured memory_bytes: 8668
s = int(input())

s1 = s // 100
s2 = s - (s1*100)

if s1 > 12 or s1 == 0:
    temp1 = 0
else:
    temp1 = 1

if s2 > 12 or s2 == 0:
    temp2 = 0
else:
    temp2 = 1


if temp1 == 0 and temp2 == 1:
    print("YYMM")
if temp1 == 0 and temp2 == 0:
    print("NA")
if temp1 == 1 and temp2 == 0:
    print("MMYY")
if temp1 == 1 and temp2 == 1:
    print("AMBIGUOUS")

Measured memory_bytes: 3064
/*-----------------------------------------------,
|  __                                       __   |
| |  |--.-----.---.-.----.----.-----.-----.|  |_ |
| |  _  |  -__|  _  |  __|  __|  -__|  _  ||   _||
| |_____|_____|___._|____|____|_____|   __||____||
|                                   |__|         |
`-----------------------------------------------*/
#include<algorithm>
#include<array>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
typedef long long lint; using namespace std;
#define INF 1000000000000
#define MOD 10000007
#define rep(counter, limit) for (long long counter = 0; counter < limit; counter++)
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
struct setupios{setupios(){cin.tie(0);ios::sync_with_stdio(0); /*cout<<fixed<<setprecision(20);*/};}setupios;
int main() {

  int a,b,c,k;
  cin>>a>>b>>c>>k;
  int ans=0;
  if(k > a){
    ans+=a;
    k-=a;
    if(k > b){
      k-=b;
      
      ans-=k;
      cout<<ans<<endl;
    }else{
      cout<<ans<<endl;
    }
  }else{
    cout<<k<<endl;
  }

}


Measured memory_bytes: 3692
#include<stdio.h>

int main(void){
	double n[15],s;
	int i;

	while(scanf("%lf",&n[0])!=EOF){
	for (i=1;i<10;i++){
		if((i+1)%2==0){n[i]=n[i-1]*(double)2.0;}
		else{n[i]=n[i-1]/(double)3.0;}
	}
	s=0;
	for(i=0;i<10;i++){
		s+=n[i];
	}
	printf("%lf\n",s);
	}
	return 0;
}

Measured memory_bytes: 648
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():

    N,M=map(int,input().split())
    P, S = [0] * M, [0] * M
    for i in range(M):
        p, s = input().split()
        S[i] = int(p)
        P[i] = str(s)

    ac=[0]*N
    wa=[0]*N
    for i in range(M):
        if P[i]=='AC':
            ac[S[i]-1]=1
        else:
            if ac[S[i]-1]==0:
                wa[S[i]-1]+=1
            else:
                continue


    print(sum(ac),sum([wa[i] for i in range(N) if ac[i]==1]))






resolve()

Measured memory_bytes: 62284
n,m = map(int, input().split())
ab=[list(map(int,input().split())) for i in range(m)]
ab.sort(key=lambda x:x[1])

drop=-1
ans=0
for tmp in ab:
    a,b=tmp
    if a<drop:
        continue
    ans+=1
    drop=b
print(ans)

Measured memory_bytes: 65560
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;
  vector<string> vec(H);
   for (int i = 0; i < H; i++) {
     cin >> vec.at(i);
     cout << vec.at(i) << endl << vec.at(i) <<endl;
   }
}

Measured memory_bytes: 3540
import sys
from functools import reduce
import copy
import math
from pprint import pprint
import collections
import bisect


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    O = list(inputs[0])
    E = list(inputs[1])
    O.reverse()
    E.reverse()

    s = []
    for i in range(len(E)):
        s.append(O.pop())
        s.append(E.pop())
    if len(O) != 0:
        s.append(O.pop())
    return ''.join(s)


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(2))
    print(ret)


Measured memory_bytes: 38384
import functools
S = input()
C = [S[0]]
for s in S[1:]:
  C = functools.reduce(lambda x, y: x + y, [[c + s, c + '+' + s] for c in C])
ans = 0
for c in C:
  ans += sum([int(x) for x in c.split('+')])
print(ans)

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
using namespace std;

int main() {
    int x, happiness = 0;
    scanInt(x);
    happiness += x / 500 * 1000;
    x %= 500;
    happiness += x / 5 * 5;
    printInt(happiness);
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

ll f(ll a, ll b){
	if(b == 0)return -a;
	return 2*(a/b)*b + f(b, a%b);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	ll n, x;
	cin>>n>>x;
	cout<<n + f(x, n - x)<<endl;

	return 0;
}

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

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

using namespace std;

typedef long long ll;

struct Edge {
  int dst;
  ll w;
};

struct Data {
  int cur;
  ll w;
  bool operator < ( const Data &data ) const {
    if( w != data.w ) return w < data.w;
    return cur < data.cur;
  }
};

const int MAX_V = 100010;

int V,E;
vector<Edge> G[MAX_V],rG[MAX_V];
ll maxi[MAX_V];
bool valid[MAX_V];
map<int,set<int> > mp;

bool check(ll limit) {
  memset(maxi,-1,sizeof maxi);
  priority_queue<Data> Q;
  /*
  for(set<int>::iterator itr=mp[limit].begin();itr!=mp[limit].end();itr++) {
    maxi[*itr] = limit;
    Q.push((Data){*itr,limit});
  }
  */
  rep(i,(int)G[V-1].size()) {
    if( G[V-1][i].w < limit ) continue;
    maxi[G[V-1][i].dst] = G[V-1][i].w;
    Q.push((Data){G[V-1][i].dst,G[V-1][i].w});
  }
  while( !Q.empty() ) {
    Data data = Q.top(); Q.pop();
    if( data.cur == 0 ) {
      return true;
    }
    rep(i,(int)G[data.cur].size()) {
      Edge &e = G[data.cur][i];
      if( e.dst == V-1 ) continue;
      if( !valid[e.dst] ) continue;
      if( !( data.w >= e.w ) )  continue;
      if( maxi[e.dst] < e.w ) {
	maxi[e.dst] = e.w;
	Q.push((Data){e.dst,e.w});
      }
    }
  }
  return false;
}


void pre_calc() {
  memset(valid,false,sizeof valid);
  deque<int> deq;
  deq.push_back(0);
  valid[0] = valid[V-1] = true;
  while( !deq.empty() ) {
    int cur = deq.front(); deq.pop_front();
    if( cur == V-1 ) continue;
    rep(i,(int)rG[cur].size()) {
      int next = rG[cur][i].dst;
      if( !valid[next] ) {
	valid[next] = true;
	deq.push_back(next);
      }
    }
  }
}


void compute() {
  pre_calc();
  vector<ll> vec;

  rep(i,(int)G[V-1].size()) {
    if( valid[G[V-1][i].dst] ) {
      vec.push_back(G[V-1][i].w);
    }
  }
  if( vec.empty() ) {
    puts("-1");
    return;
  }
  sort(vec.begin(),vec.end());
  int L = 0, R = (int)vec.size();
  while( R - L ) {
    int M = ( L + R ) / 2;
    if( check(vec[M]) ) L = M + 1;
    else                R = M;
  }
  if( L-1 < 0 ) {
    puts("-1");
  } else {
    cout << vec[L-1] << endl;
  }
}

int main() {
  cin >> V >> E;
  rep(i,E) {
    int a,b,c;
    cin >> a >> b >> c;
    --a, --b;
    G[b].push_back((Edge){a,c});
    rG[a].push_back((Edge){b,c});
  }
  compute();
  return 0;
}

Measured memory_bytes: 17832
use std::collections::{BTreeSet, VecDeque};

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let mut graph = vec![BTreeSet::new(); n];
    for _ in 1..n {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        graph[a].insert(b);
        graph[b].insert(a);
    }

    let mut q = VecDeque::new();
    for i in 0..n {
        if graph[i].len() == 1 {
            q.push_back(i);
        }
    }

    while let Some(v) = q.pop_front() {
        if graph[v].is_empty() {
            println!("First");
            return;
        }
        assert_eq!(1, graph[v].len());
        let parent = graph[v].iter().next().cloned().unwrap();
        let next = graph[parent].clone();
        for next in next.into_iter() {
            if next == v {
                continue;
            }
            assert!(graph[next].remove(&parent));
            if graph[next].len() <= 1 {
                q.push_back(next);
            }
        }
    }
    println!("Second");
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

#define ll long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define all(x) (x).begin(), (x).end()

#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
const int MOD = 1000000007;

int main() {
    IOS;
    int r,d,x;
    cin>>r>>d>>x;
    for(int i=0;i<10;i++){
    	x = r*x - d;
    	cout<<x<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
import sys
cars = []
out_cars = []
cars_size = 0
for line in sys.stdin:
    n = int(line)
    if n == 0:
        out_cars.append(cars.pop(cars_size - 1))
        cars_size -= 1
    else:
        cars.append(n)
        cars_size += 1
[print(car) for car in out_cars]

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

typedef long long ll;
typedef unsigned long long ull;

const ull P = 1000000007ULL;

string s[2];
set<ull> inv;
vector<int> p;
vector<ull> h;
vector<ull> pmod;
map<ull, ull> pre;
map<ull, ull> has[2];
map<ull, vector<ull>> nxt;

ull geth(int k, int d, int r)
{	
	int lt = d - r + 1;
	int rt = d + r - 1;
	
	return h[rt + 1] - h[lt]*pmod[rt - lt + 1];
}

void getsubstr(int k, ull v)
{
	for (auto t : nxt[v])
	{
		getsubstr(k, t);
		has[k][v] += has[k][t];
	}
}

void prework(const int k)
{
	/*---< prepare >---*/
	
	p.clear();
	h.clear();
	pre.clear();
	nxt.clear();
	
	string str; 
	cin >> str;
	
	s[k] += '$';
	
	for (auto c : str)
	{
		s[k] += c;
		s[k] += '#';
	}
	
	int len = s[k].length();
	
	p.resize(len + 5);
	h.resize(len + 5);
	pmod.resize(len + 5);
	
	/*---< manacher >---*/
	
	int ma = -1, id = -1;	
	for (int i = 0; i < len; ++i)
	{
		if (i <= ma)
			p[i] = min(
				ma - i + 1,
				p[2*id - i]
			);
		else p[i] = 1;
		
		while (
			s[k][i - p[i]]
		==	s[k][i + p[i]]
		)++p[i];
		
		if (ma < i + p[i] - 1)
			ma = i + p[i] - 1, id = i;
	}
	
	/*-----< hash >-----*/
	
	for (int i = 0; i < len; ++i)
		h[i + 1] = h[i]*P + s[k][i];
		
	pmod[0] = 1;
	for (int i = 1; i <= len; ++i)
		pmod[i] = pmod[i - 1]*P;
		
	/*----< build >----*/
	
	for (int i = 0; i < len; ++i)
	{
		int r = p[i];
		ull v = geth(k, i, r);
		
		bool flag = true;
		
		while (!has[k].count(v))
		{			
			has[k][v];
			
			if (flag)++has[k][v], flag = false;
			
			if (s[k][i + r - 1] == '#')
				inv.insert(v);
				
			if (s[k][i - r + 1] == '$')
				inv.insert(v);
			
			if (--r == 0)break;
			
			ull n = geth(k, i, r);
			
			pre[v] = n;
			nxt[n].push_back(v);
			
			v = n;
		}
		
		if (flag)++has[k][v];
	}
	
	for (auto it : has[k])
		if (!pre.count(it.first))
			getsubstr(k, it.first);
}

signed main(void)
{
	prework(0);
	prework(1);
	
	ull answer = 0;
	
	for (auto it : has[0])
		if (!inv.count(it.first))
			answer += it.second * has[1][it.first];
			
	cout << answer << endl;
}

Measured memory_bytes: 48812
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <queue>
#include <cstdlib>
#include <ctime>
using namespace std;
 
int d[13] = {
	-14, -1, 0, 1, 14,
	-15, -13, 13, 15,
	-28, -2, 2, 28,
};
int to[3] = {5, 9, 13};
 
int c[196];
int nmb[196];
vector<vector<int> > lumps;
vector<int> sum;
vector<int> ans;

inline void draw(int x, int t, int dif){
	for(int i = 0; i < t; ++i){
		c[x + d[i]] += dif;
	}
}

inline int check(int t, int x){
	int m;
	for(m = 0; m < 13 && c[x + d[m]] > 0; ++m);
	return m;
}

void dfs(int, int, int);

inline void apply(int n, int t, int u, int x, int a){
	draw(x, to[a], -1);
	sum[t] -= to[a];
	ans.push_back(x << 2 | a);
	dfs(n - 1, t, u);
	ans.pop_back();
	sum[t] += to[a];
	draw(x, to[a], 1);
}

void dfs(int n, int t, int u){
	if(sum[t] == 0){
		++t;
		u = 0;
	}

	if(t == lumps.size()){
		if(n == 0){
			for(int i = 0; i < ans.size(); ++i){
				int y = (ans[i] >> 2) / 14 - 2;
				int x = (ans[i] >> 2) % 14 - 2;
				int z = (ans[i] & 3) + 1;
				printf("%d %d %d\n", x, y, z);
			}
			exit(0);
		}
		return;
	}

	const vector<int> &lm = lumps[t];
	while(u < lm.size() && c[lm[u]] == 0){
		++u;
	}
	if(u >= lm.size()){ return; }

	bool end = false;
	for(int i = 0; i < lm.size(); ++i){
		if(c[lm[i]] && !c[lm[i] - 14] && !c[lm[i] + 14]){
			end = true;
			for(int sg = -1; sg < 2; sg += 2){
				if(check(t, lm[i] + 2 * sg) >= 13){
					apply(n, t, u, lm[i] + 2 * sg, 2);
				}
				if(check(t, lm[i] + sg) >= 5){
					apply(n, t, u, lm[i] + sg, 0);
				}
			}
		}

		if(c[lm[i]] && !c[lm[i] - 1] && !c[lm[i] + 1]){
			end = true;
			for(int sg = -1; sg < 2; sg += 2){
				if(check(t, lm[i] + 28 * sg) >= 13){
					apply(n, t, u, lm[i] + 28 * sg, 2);
				}
				if(check(t, lm[i] + 14 * sg) >= 5){
					apply(n, t, u, lm[i] + 14 * sg, 0);
				}
			}
		}
	}
	if(end){ return; }

	int x = lm[u];
	int m = check(t, x);
	for(int i = 2; i >= 0; --i){
		if(m >= to[i]){
			apply(n, t, u, x, i);
		}
	}
 
	dfs(n, t, u + 1);
}


int main(){
	srand(time(0));
	memset(nmb, -1, sizeof nmb);
 
	int n;
	scanf("%d", &n);
	for(int i = 0; i < 10; ++i){
		for(int j = 0; j < 10; ++j){
			scanf("%d", &c[(i + 2) * 14 + (j + 2)]);
		}
	}
 
	for(int i = 0; i < 196; ++i){
		if(c[i] != 0 && nmb[i] == -1){
			int s = 0;
			vector<int> lm;
			queue<int> q;
			q.push(i);
			nmb[i] = lumps.size();
			while(!q.empty()){
				lm.push_back(q.front());
				s += c[q.front()];
				for(int j = 0; j < 5; ++j){
					int x = q.front() + d[j];
					if(c[x] != 0 && nmb[x] == -1){
						q.push(x);
						nmb[x] = lumps.size();
					}
				}
				q.pop();
			}
			random_shuffle(lm.begin(), lm.end());
			lumps.push_back(lm);
			sum.push_back(s);
		}
	}
 
	dfs(n, 0, 0);
	return 1;
}

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

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ld long double
#define mem(x,y) memset(x,y,sizeof x)

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	int n;
	cin>>n;
	int d[n][2];
	for(int i=0;i<n;i++) cin>>d[i][0]>>d[i][1];
	for(int i=0;i<n-2;i++)
	if(d[i][0]==d[i][1] && d[i+1][0]==d[i+1][1] && d[i+2][0]==d[i+2][1])
	{
		cout<<"Yes\n";
		return;
	}
	cout<<"No\n";
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3660
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
using namespace std;

#define ll int64_t
const long MOD = 1e9 + 7;


int main()
{
  int a, b, c, d; //かっている数//最大100
  string s, t;

  cin >> s;
  cin >> t;
  string ss = s;
  int siz = ss.size();
  bool ist = false;

  for (int i = 0; i < siz; i++) {
    string s2 = ss.substr(siz - 1, 1);
    s2 += ss.substr(0, siz - 1);
    // cout << s2 << endl;
    if (s2 == t)ist = true;
    ss = s2;
  }

  if (ist == true) {
    cout << "Yes";
  } else {
    cout << "No";
  }

  return 0;
}


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

namespace CsharpProgramTest
{
    class Program
    {
        static void Main(string[] args)
        {
            // 取得個数
            var count = int.Parse(Console.ReadLine());
            var dic = new Dictionary<int, bool>();
            // ループ
            for(var i = 0; i < count; i++) {
                var num = int.Parse(Console.ReadLine());
                dic[num] = true;
            }
            var allCount = dic.Select(s => s.Key).Count();
            Console.WriteLine(allCount);
        }
    }
}


Measured memory_bytes: 13280
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
typedef long long ll;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//V,P(大文字)使用不可

const ll INF=1e18;

signed main(){
    int a,b;
    cin>>a>>b;
    if(b==1) cout<<0<<endl;
    else{
        int ans=1;
        int cnt=a;
        while(true){
            if(cnt>=b) break;
            ans++;
            cnt+=a-1;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
const long long mod = 1e9+7;
typedef priority_queue<int> PQ;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;  
typedef vector<VS> VSS;  
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
/*int main(){
    ll c=0,d=0,k=0,n,m,h,w,p,q;
    const int max = 100000;
    string s,s1,s2;
    ll num[max+1];

    cin >> n >> k;
    rep(i,n){
        int a,b;
        cin >> a >> b;
        num[a] += b;
    }

    for (int ans=1; ans<=max; ans++){
        if(k <= num[ans]){
            cout << ans << endl;
            break;
        }
        k -= num[ans];
    }

    return 0;
}*/
const int AMAX = 100000;
ll cnt[AMAX + 1];

int main(void) {
int N;
ll K;
cin >> N >> K;

for (int i = 0; i < N; ++i) {
 int A, B;
 cin >> A >> B;
 cnt[A] += B;
 }

for (int ans = 1; ans <= AMAX; ++ans){
 if (K <= cnt[ans]) {
 cout << ans << endl;
 break;
}
 K -= cnt[ans];
 }

 return 0;
 }

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

ll n,k;
ll h[100010];
vector<ll> d(100010, 0);

int main()
{
	FAST;

	cin >> n >> k;
	rep(i,n) cin >> h[i];
	sort(h, h+n, std::greater<ll>());
	rep(i,n-k+1) {
		d[i] = h[i] - h[i+(k-1)];
		// cout << d[i] << "\n";
	}
	sort(d.begin(), d.begin()+n-k+1);

	cout << d[0] << "\n";

	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
 
int main(){
    int ans=0,now=0;
    string S,T;
    T = "ATGC";
    cin >> S;
    for (int i = 0; i < S.size(); i++){
        bool isATGC = false;
        for (int j = 0; j < T.size(); j++){
           if (S[i] == T[j])isATGC = true;
       }
       if (!isATGC){
           now=0;
       }else{
           now++;
           ans = max(now,ans);
       }
    }
    cout << ans << endl;
return 0;
}
       

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;


int main(){

  int a,b;
  cin >> a >> b;
  
  int n = b-a;
  int ans = 0;
  REP(i,n){
    ans += (i+1);
  }
  
  cout << ans - b << endl;
  

 return 0;
}


Measured memory_bytes: 256
n=int(input())
a=[[int(i) for i in input().split()] for i in range(2)]
koho=[]
for i in range(n):
    if i==0:
        cnt=a[0][0]+sum(a[1][0:])
    else:
        cnt=sum(a[0][0:i+1])+sum(a[1][i:])
    koho.append(cnt)
print(max(koho))

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(){
	int i, n;
	char s[100];
	scanf("%s",s);
	n = strlen(s);
	for(i=0;i<n/2;i++){
		if(s[i]!=s[n-1-i]){
			printf("No");
			return 0;
		}
	}
	for(i=0;i<(n-1)/4;i++){
		if(s[i]!=s[(n-1)/2-1-i]){
			printf("No");
			return 0;
		}
	}
	for(i=(n+1)/2;i<n;i++){
		if(s[i]!=s[n+(n+1)/2-i-1]){
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

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

using namespace std;

typedef long double ld;

int N;
bool vis[307][307][307];
ld dp[307][307][307];
int X[6];

ld policz(int a, int b, int c)
{
    if(vis[a][b][c]) return dp[a][b][c];
    vis[a][b][c]=true;
    ld q=a+b+c;
    ld q1=N/q,q2=a/q,q3=b/q,q4=c/q;
    if(a > 0) q2*=policz(a-1, b, c);
    if(b > 0) q3*=policz(a+1, b-1, c);
    if(c > 0) q4*=policz(a, b+1, c-1);
    dp[a][b][c]=q1+q2+q3+q4;
    return dp[a][b][c];
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    vis[0][0][0]=true;
    cin >> N;
    for(int i=1; i<=N; i++)
    {
        int y;
        cin >> y;
        X[y]++;
    }
    cout << setprecision(10) << fixed << policz(X[1], X[2], X[3]);
}

Measured memory_bytes: 471424
#include <iostream>
#include <string>
#include <map>
using namespace std;
int stoi(string s){
	int c = 0,a = 16;
	for(int i = 0;i < s.length();++i){
		c += a * (int)(s[i] - '0');
		a /= 2;
	}
	return c;
}
int main(){
	map<char,string> dic;
	dic[' '] = "101";
	dic['\''] = "000000";
	dic[','] = "000011";
	dic['-'] = "10010001";
	dic['.'] = "010001";
	dic['?'] = "000001";
	dic['A'] = "100101";
	dic['B'] = "10011010";
	dic['C'] = "0101";
	dic['D'] = "0001";
	dic['E'] = "110";
	dic['F'] = "01001";
	dic['G'] = "10011011";
	dic['H'] = "010000";
	dic['I'] = "0111";
	dic['J'] = "10011000";
	dic['K'] = "0110";
	dic['L'] = "00100";
	dic['M'] = "10011001";
	dic['N'] = "10011110";
	dic['O'] = "00101";
	dic['P'] = "111";
	dic['Q'] = "10011111";
	dic['R'] = "1000";
	dic['S'] = "00110";
	dic['T'] = "00111";
	dic['U'] = "10011100";
	dic['V'] = "10011101";
	dic['W'] = "000010";
	dic['X'] = "10010010";
	dic['Y'] = "10010011";
	dic['Z'] = "10010000";
	char dic2[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ .,-'?";
	string str;
	int a;
	while(getline(cin,str)){
		string s,s1;
		s = s1 = "";
		for(int i = 0;i < str.length();++i){
			s += dic[str[i]];
		}
		if(s.length() % 5 != 0) {
			a = 5 - (s.length() % 5);
			for(int i = 0;i < a;++i){
				s += '0';
			}
		}
		for(int i = 0;i < s.length();i += 5){
			s1 += dic2[stoi(s.substr(i,5))];
		}
		cout << s1 << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;


const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
// combination mod prime
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};







int main(){
    ll n;
    ll k;
    cin >> n >> k;
    ll ans = 0;
    ll mod = (ll) 1e9 + 7;
    for(ll i = k; i <= n+1; i++){
        
        if (i%2 == 0){
            
            ll b = (i-1)*(i/2);
            ll t = (n+n-i+1)*(i/2);
           
            ans += (t-b+1); 
        }
        if (i%2 == 1){
            ll b = (i-1)*(i/2) + i/2;
            ll t = (n+n-i+1)*(i/2) + (n-i+1+i/2);
            
            ans += (t-b+1);
        }
        ans %= mod;
    }
    cout << ans;
    
}







Measured memory_bytes: 3632
#include <iostream>
#include <queue>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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

using namespace std;
using ll = long long;

const int kInf = 1e9;
const ll kLInf = 1e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main()
{
   int N;
   cin >> N;
   vector<int> dp(N+1, kInf);
   dp[0] = 0;
   REP(i, N+1) {
      eprintf("hoge%d\n",i);
      if (i) {
         chmin(dp[i], dp[i-1]+1);
      }
      int j = 6;
      while (i >= j) {
         chmin(dp[i], dp[i-j]+1);
         j *= 6;
      }
      j = 9;
      while (i >= j) {
         chmin(dp[i], dp[i-j]+1);
         j *= 9;
      }
   }
      
         
   cout << dp[N] << endl;
   return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include<map>
#include<string>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<typeinfo>
#include<queue>
#include<iomanip>
using namespace std;
int main() {
	const double pi = 3.1415926535898;
	const double root_2 = 1.41421356237;
	int a,b,x;
	cin >> a >> b >> x;
	int capacity = a * a * b - x;
	double deg ;
	if (capacity * 2 < a * a * b) {
		deg = (atan(double(2*capacity) / double(a*a*a))*180.0)/pi;
	}
	else {
		deg= 90.0-((atan(double(2 * x) / double(b* b * a)) * 180.0) / pi);
	}
	cout <<fixed<<setprecision(15)<< deg;
}

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

using namespace std;

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

    int INF = (int) 2e9 + 1;
    int V, E;
    cin >> V >> E;

    int d[V][V];
    for (int i = 0; i < V; ++i) {
        fill(d[i], d[i] + V, INF);
        d[i][i] = 0;
    }

    for (int i = 0; i < E; ++i) {
        int s, t;
        cin >> s >> t;
        cin >> d[s][t];
    }

    for (int k = 0; k < V; ++k) {
        for (int i = 0; i < V; ++i) {
            if (d[i][k] == INF) continue;
            for (int j = 0; j < V; ++j) {
                if (d[k][j] == INF) continue;
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    for (int i = 0; i < V; ++i) {
        if (d[i][i] < 0) {
            cout << "NEGATIVE CYCLE\n";
            return 0;
        }
    }
    
    for (int i = 0; i < V; ++i) {
        for (int j = 0; j < V; ++j) {
            if (d[i][j] < INF) {
                cout << d[i][j];
            } else {
                cout << "INF";
            }
            if (j != V - 1) cout << ' ';
        }
        cout << '\n';
    }

    return 0;
}



Measured memory_bytes: 3256
import time

st = time.time()

d = int(input())
c = list(map(int, input().split()))
s = [list(map(int, input().split())) for _ in range(d)]
ans = [0] * d
k = [-1] * 26
sc = 0
for i in range(d):
    res = -100000000
    p = 0
    for j in range(26):
        tmp = 0
        tmp += s[i][j]
        for x in range(26):
            if x == j:
                continue
            tmp -= c[x] * (i - k[x])
        if res < tmp:
            res = tmp
            p = j
    sc += res
    k[p] = i
    ans[i] = p
while time.time() - st <= 1.5:
    rsc = -10000000000000
    p = (0, 0)
    for y in range(d):
        for m in range(26):
            k = [-1] * 26
            tsc = 0
            for i in range(d):
                if i == y:
                    tsc += s[i][m]
                    k[m] = i
                else:
                    tsc += s[i][ans[i]]
                    k[ans[i]] = i
                for j in range(26):
                    tsc -= c[j] * (i - k[j])
            if tsc > rsc:
                p = (y, m)
                rsc = tsc
    if sc < rsc:
        sc = rsc
        ans[p[0]] = p[1]
    else:
        break
for x in ans:
    print(x + 1)


Measured memory_bytes: 74476
#include <stdio.h>
#include <string.h>
int	main(void)
{
	static char input[4];
	
	scanf("%s", input);
	if (strcmp(input, "AAA") == 0)
	{
		printf("No");
	}
	else if (strcmp(input, "BBB") == 0)
	{
		printf("No");
	}
	else
	{
		printf("Yes");
	}
	return (0);
}


Measured memory_bytes: 128
import numpy as np

n = int(input())
h = list(map(int, input().split()))
h = np.array(h)

split_h = []
split_h.append(h)

ans = 0
list_h = []
while len(split_h):
    sph = split_h.pop()

    min_h = sph.min()
    sph -= min_h
    ans += min_h

    if np.all(sph == 0):
        continue

    for elem in sph:
        if elem != 0:
            list_h.append(elem)
        else:
            if list_h:
                split_h.append(np.array(list_h))
                list_h = []
    if list_h:
        split_h.append(np.array(list_h))
        list_h = []

print(ans)


Measured memory_bytes: 13412
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int	count_same_str(char *a, char *b)
{
	int	len;
	int	count;

	len = strlen(a);
	count = 0;
	for (int i = 0; i < len; i++)
	{
		if (a[i] == b[i])
			count++;
	}
	return (count);
}

int main()
{
	char	S[1001];
	char	T[1001];
	char	copy[1001];
	int		t_len;
	int		s_len;
	int		max;
	int		res;
	int		ans;

	scanf("%s", S);
	scanf("%s", T);

	s_len = strlen(S);
	t_len = strlen(T);

	//"abcde"
	//"bcd"
	max = 0;
	for (int i = 0; i <=s_len - t_len; i++)
	{
		res = count_same_str(S + i, T);
		if (res > max)
			max = res;
		if (max == t_len)
			break;
	}
	ans = t_len - max;
	printf("%d\n", ans);

	return (0);
}


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

using namespace std;

#define debug(x) cout << #x << "==" << x << endl;

const int inf = 100000000;

typedef long long ll;

#define MAX_H 1400
#define MAX_W 1400
int field[MAX_H][MAX_W];

int main() {
  ios::sync_with_stdio(false);

  int H, W;
  cin >> H >> W;

  for(int i = 0; i < H; i++ ) {
    for(int j = 0; j < W; j++ ) {
      cin >> field[i][j];
    }
  }

  
  int dp[H+1][W+1];
  for(int i = 0; i <= H; i++) {
    dp[i][0] = 0;
  }
  for(int j = 0; j <= W; j++) {
    dp[0][j] = 0;
  }

  for(int i = 1; i <= H; i++) {
    for(int j = 1; j <= W; j++) {
      if( field[i-1][j-1] == 1 ) {
        dp[i][j] = 0;
      } else {
        dp[i][j] = min( dp[i-1][j], min( dp[i][j-1], dp[i-1][j-1] ) ) + 1;
      }
    }
  }

  int mx = 0;
  for(int i = 1; i <= H; i++) {
    for(int j = 1; j <= W; j++) {
      mx = max(mx, dp[i][j]);
    }
  }

  // for(int i = 0; i <= H; i++) {
  //   for(int j = 0; j <= W; j++) {
  //     cout << dp[i][j] << " ";
  //   }
  //   cout <<  "\n";
  // }


  cout << mx*mx << "\n";
  return 0;
}

Measured memory_bytes: 18372
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,k,l[100];
int main(){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;++i)scanf("%d",&l[i]);
    sort(l+1,l+n+1);
    int ans=0;
    for(int i=n-k+1;i<=n;++i)ans+=l[i];
    printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int W, H, x, y , r;
    cin >> W >> H >> x >> y >> r;
    if((x+r)>W || (x-r)<0 || (y+r)>H || (y-r)<0 || x<0 || y<0) cout << "No";
    else cout << "Yes";
    cout << "\n";
    return 0;
}



Measured memory_bytes: 3096
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
int main() {
	int H,W,c[11][11],a[220][220],ans=0;
	int dis[11][11];
	cin>>H>>W;
	rep(j,0,10)
		rep(i,0,10){
		cin>>c[i][j];
		dis[i][j]=c[i][j];
	}
	rep(k,0,10){
		rep(j,0,10){
			rep(i,0,10){
				dis[i][j]=min(dis[i][j],dis[i][k]+dis[k][j]);
			}
		}
	}
	rep(j,0,H)
		rep(i,0,W){
		cin>>a[i][j];
		if(a[i][j]!=1&&a[i][j]!=-1){
			ans+=dis[1][a[i][j]];
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 384
io = STDIN
x1,y1,x2,y2=io.gets.split.map(&:to_i)
xx=x2-x1
yy=y2-y1
if xx*yy>=0     #xx >=0 && yy >= 0
  x3,y3=x2-yy,y2+xx
  x4,y4=x1-yy,y1+xx
# elsif xx<=0 && yy >= 0
else
  x3,y3=x2-yy,y2+xx
  x4,y4=x1-yy,y1+xx
end
puts "#{x3} #{y3} #{x4} #{y4}"


Measured memory_bytes: 1788
#include <stdio.h>

int main()
{
	int a,b,c;
	scanf("%d %d %d", &a, &b, &c);
	if((a == b && b != c) || (b == c && c != a) || (c == a && a != b)){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
//??£?????°????????¨????????????
//????????????????????????????????? (????????????????????¨?????°?????????DFS??¨??????????????????)
//???DFS??¨?????????u(???root)???????????????lowlink[u] > prenum[u??????] ??? u?????? --> u??????
//lowlink[u] > prenum[u??????] ??? u??????u???????????¢????????????????????? ??? u??¨u????????????????????????????????¨u??????u????????????????????? ??? [u?????? --> u]???????????¨?????£??? ??? [u?????? --> u]??????
//lowlink[u] <= prenum[u??????] ???u??????u??????????????\??????????????? ??? u??¨u?????????????????????????????£??????u??????u?????????????????? ??? [u?????? --> u]????????£????????£??? ??? [u?????? --> u]????????§?????????
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

struct Edge {
	int u, v;
	Edge(int u, int v) { this->u = u; this->v = v; }
	Edge() { }
	bool operator<(const Edge &r) const { return (u != r.u) ? u < r.u : v < r.v; }
};

int n, m;
vector<int> et[100000];

int timer;
bool visited[100000];
int prenum[100000];
int lowest[100000];
int parent[100000];

void dfs(int u, int prev) {
	prenum[u] = timer;
	lowest[u] = timer;
	parent[u] = prev;
	visited[u] = true;
	timer++;
	
	for (int i = 0; i < et[u].size(); i++) {
		int v = et[u][i];
		
		if (!visited[v]) {
			dfs(v, u);
			lowest[u] = min(lowest[u], lowest[v]);
		}
		else if (parent[u] != v) {
			//u --> v????????????
			lowest[u] = min(lowest[u], prenum[v]);
		}
	}
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int src, dst;
		cin >> src >> dst;
		et[src].push_back(dst);
		et[dst].push_back(src);
	}
	
	//????????????
	timer = 0;
	for (int i = 0; i < n; i++) visited[i] = false;
	dfs(0, -1);
	
	static vector<Edge> ans;
	
	for (int i = 1; i < n; i++) {
		if (prenum[parent[i]] < lowest[i]) {
			ans.push_back(Edge(min(parent[i], i), max(parent[i], i)));
		}
	}
	
	sort(ans.begin(), ans.end());
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i].u << " " << ans[i].v << endl;
	}
	
	return 0;
}

Measured memory_bytes: 4996
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <unordered_map>
#include <stack>

using namespace std;

long long MOD = 1e9 + 7;

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

    std::string s;
    cin >> s;

    long long sum = 0;
    for (size_t bit = 0; bit < (1 << (s.size() - 1)); bit++)
    {
        long long thisNum = s[0] - '0';
        long long thisSum = 0;
        for (size_t i = 0; i < s.size() - 1; i++)
        {
            // bitが立っている数字から新しい区切りとする
            if (bit & (1 << i)) {
                thisSum += thisNum;
                //std::cout << thisNum << " ";
                thisNum = s[i + 1] - '0';
            }
            else {
                // bitが立っていない場合、位をあげて次を足す
                thisNum = thisNum * 10 + (s[i + 1] - '0');
            }
        }
        //std::cout << thisNum << std::endl;
        thisSum += thisNum;
        sum += thisSum;
    }
    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 256
/*
 #pragma GCC optimize("Ofast,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
*/
#pragma GCC optimize("O3")
#pragma GCC target ("sse4")

#define NDEBUG
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <climits>
#include <list>
#include <functional>
#include <numeric>

//find out the use of the below
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <ctime>
#include <memory.h>
#include <cassert>

using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> set_t;
#define fio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define mp(a,b) make_pair((a),(b))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define pb push_back
#define x first
#define y second
#define sqr(x) ((x)*(x))
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
#define EPS 1e-6
#define MEM(x) memset(x,0,sizeof(x))
#define MEMS(x) memset(x,-1,sizeof(x))
#define PI acos(-1)

int n;
vector<int> v[17];
vector<int> b[17];
int cnt;
bool check(int x) {
    cnt = 0;
    int ind = 1;
    bool st[17];
    MEM(st);
    while (x != 0){
        st[ind] = x&1;
        cnt += st[ind];
        x >>= 1;
        ind++;
    }
    for (int i = 1; i <= n; ++i){
        if (st[i]){
            for (int p: v[i])
                if (!st[p])
                    return false;
            for (int p: b[i])
                if (st[p])
                    return false;
        }
    }
    return true;
}
int main(){
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    fio;
    cin >> n;
    for (int i = 1; i < n+1; ++i) {
        int a;
        cin >> a;
        for (int j = 0; j < a; ++j) {
            int x, y;
            cin >> x >> y;
            if (y)
                v[i].pb(x);
            else 
                b[i].pb(x);
        }
    }
    int ans = 0, ord = (1<<n) -1;
    for (int i = ord; i >=1; i--) {
        if (check(i))
            ans = max(ans, cnt);
    }
    cout << ans;        
    return 0;
}
/* BEFORE submitting, check for:
 *  1. Integer overflow
 *  2. Float/Double precision errors
 *  3. Array index out of bounds
 *  4. Edge cases.(n=1, n=max, etc.)
 *  5. Time complexity. No TLEs
 */



Measured memory_bytes: 256