akhauriyash/Code-Regression huggingface dataset:
// ===========================================
// 20.03.12
// 
// 
// ===========================================

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(int (i)=1;(i)<=(n);i++)
#define rez(i,n) for(int (i)=0;(i)<(n);i++)
#define ET "\n"
#define CLR(arr) memset(&arr, 0, sizeof(arr))
#define PAIR pair<int, int>
const ll INF = 1LL << 50;
const int mini = 10e5+5;


void getLCS(string s1, string s2, int dp[], string &res){
    int l1 = s1.length();
    int l2 = s2.length();
    
    #define md(y,x) (y)*(l2+1)+(x)
    int nmax = dp[md(l1,l2)];
    int cy = l1;
    int cx = l2;
    
    while(nmax>0 && cy>0 && cx>0){
        //cout << "cy" << cy << " cx" << cx << ET;
        int ny = cy;
        int nx = cx;
        
        if(dp[md(cy-1, cx)] == dp[md(cy, cx)]){
            ny--;
        }
        else if(dp[md(cy, cx-1)] == dp[md(cy, cx)]){
            nx--;
        }
        else{
            ny--;
            nx--;
            nmax--;
            res = s2[cx-1] + res;
            //cout << "now nmax " << nmax << " " << "cy cx res is " << cy << " " << cx << " " << res << ET;
        }
        cy = ny;
        cx = nx;
    }
    #undef md
}

int main(){
    
    string s1, s2; cin >> s1 >> s2;
    int l1, l2;
    l1 = s1.length(); l2 = s2.length();
    
    int dp[l1+1][l2+1]; CLR(dp);
    rep(y,l1){
        rep(x,l2){
            int k = (s1[y-1] == s2[x-1]);
            dp[y][x] = max({dp[y][x-1], dp[y-1][x],
                            dp[y-1][x-1] + k});
            if(k){
            }
        }
    }
    
    string ans = "";
    getLCS(s1, s2, (int*)dp, ans);
    cout << ans << ET;
    
    
    //abracadabra
    //avadakedavra
    //  a v a d a k e d a v r a 
    //a 1 1 1 1 1 1 1 1 1 1 1 1 
    //b 1 1 1 1 1 1 1 1 1 1 1 1 
    //r 1 1 1 1 1 1 1 1 1 1 2 2 
    //a 1 1 2 2 2 2 2 2 2 2 2 3 
    //c 1 1 2 2 2 2 2 2 2 2 2 3 
    //a 1 1 2 2 3 3 3 3 3 3 3 3 
    //d 1 1 2 3 3 3 3 4 4 4 4 4 
    //a 1 1 2 3 4 4 4 4 5 5 5 5 
    //b 1 1 2 3 4 4 4 4 5 5 5 5 
    //r 1 1 2 3 4 4 4 4 5 5 6 6 
    //a 1 1 2 3 4 4 4 4 5 5 6 7 
    /*
    cout << "  ";
    rez(i,l2) cout << s2[i] << " "; 
    cout << ET;
    rep(i,l1){
        cout << s1[i-1] << " ";
        rep(j,l2){
            cout << dp[i][j] << " ";
        }
        cout << ET;
    }
    */
    
}



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

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

fn main() {
    let k = read::<i64>();
    let mut cur = 0;
    let mut coef = 7;
    for i in 0..2000000 {
        cur += coef;
        cur %= k;
        coef *= 10;
        coef %= k;
        // debug!(cur);
        if cur == 0 {
            println!("{}", i + 1);
            return;
        }
        if coef == 0 {
            println!("-1");
            return;
        }
    }
    println!("-1");
}

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

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


Measured memory_bytes: 2136
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
B.append(0)

ans = 0
for i in range(len(B)-2, -1, -1):
    temp = min(A[i+1], B[i])
    ans += temp
    B[i] -= temp

    temp = min(A[i], B[i])
    ans += temp
    A[i] -= temp

print(ans)


Measured memory_bytes: 18396
n = gets.to_i
a = gets.split.map(&:to_i).sort
q = gets.to_i

rl = {}
a.slice_when(&:!=).map { |e| rl[e.first] = e.size }
sum = 0
rl.each { |i, j| sum += i * j }

q.times do
  b, c = gets.split.map(&:to_i)

  if rl[b]
    if rl[c]
      rl[c] += rl[b]
    else
      rl[c] = rl[b]
    end

    sum += (c - b) * rl[b]
    puts sum

    rl.delete(b)
  else
    puts sum
  end
end

Measured memory_bytes: 27376
#include<iostream>
using namespace std;
void solve() {
	int n;
	cin >> n;
	int ones  = n % 10;
	switch (ones) {
	case 2 :
	case 4 :
	case 5 :
	case 7 :
	case 9 :
		cout << "hon\n";
		break;
	case 0 :
	case 1 :
	case 6 :
	case 8 :
		cout << "pon\n";
		break;
	case 3 :
		cout << "bon\n";
	}
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	solve();
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <bitset>
#include <queue>

using namespace std;

using ll = long long;

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

	vector<int> bs(m + 1);
	for (int i = 1; i <= m; i++)
		cin >> bs[i];

	int ans = 0;

	for (int i = 1; i <= n; i++)
	{
		ll sum = 0;
		for (int j = 1; j <= m; j++)
		{
			int a;
			cin >> a;
			sum += (a * bs[j]);
		}
		if (sum + c > 0)
			ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
fn input_trio<T: std::str::FromStr + Copy> () -> (T, T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let arr: Vec<_> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (arr[0], arr[1], arr[2])
}

fn pow(a: isize, b: isize, m: isize) -> isize {
    if b == 0 {
        return 1;
    }
    let x = pow(a, b >> 1, m);
    return if b % 2 == 0 {
        (x * x) % m
    } else {
        (((a * x) % m) * x) % m
    }
}

fn factorial(n: isize, m: isize) -> isize {
    let mut v = 1;
    for i in 1..=n {
        v = (v * i) % m;
    }
    v
}

fn factorial_inv(n: isize, m: isize) -> isize {
    pow(factorial(n, m), m - 2, m)
}

fn combination(n: isize, r: isize, m: isize) -> isize {
    if r < 0 || r > n {
        0
    } else {
        // ((factorial(n, m) * factorial_inv(r, m)) % m * factorial_inv(n - r, m)) % m
        let mut prev = 1;
        for i in 0..r {
            prev = ((((n - i) * prev) % m) * pow(i + 1, m - 2, m)) % m;
        }
        prev
    }
}

fn main() {
    let (n, a, b) = input_trio::<isize>();
    let m = 1000000007;
    // let mut result = 0;
    // tle
    // for v in (2..=n).filter(|&r| r != a && r != b).map(|r| combination(n, r, m)) {
    //     result = (result + v) % m;
    // }

    // wa, tle
    // let mut prev = n;
    // for i in 1..n {
    //     prev = ((((n - i) * prev) % m) * pow(i + 1, m - 2, m)) % m;
    //     if i != a && i != b {
    //         result = (result + prev) % m;
    //     }
    // }
    // println!("{}", result);

    println!("{}", (pow(2, n, m) - 1 + m - combination(n, a, m) + m - combination(n, b, m)) % m);
    // println!("{}", (pow(2, n, m) - 1 + m - combination(n, a, m)) % m);
}


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

#define CodeTyper main
#define Bye return 0
#define ll long long

using namespace std;


void solve(){
    string s; cin>>s;
    if(s[s.size()-1] == 's')
        cout<<s<<"es"<<endl;
    else cout<<s<<"s"<<endl;   
}

int CodeTyper(){
    solve();
    Bye;
}

Measured memory_bytes: 3628
n,m = map(int,input().split())
loc = []
che = []
for i in range(n):
    a,b = map(int,input().split())
    loc.append((a,b))
for i in range(m):
    a,b = map(int,input().split())
    che.append((a,b))

for i in range(n):
    x = loc[i][0]
    y = loc[i][1]
    cnt = int(1e18)
    ans = 0
    for j in range(m):
        x1 = che[j][0]
        y1 = che[j][1]
        u = abs(x-x1)+abs(y-y1)
        if cnt > u:
            ans = j+1
            cnt = u
    print(ans)


Measured memory_bytes: 39280
#include<iostream>
using namespace std;
#include<bits/stdc++.h>
#include<string.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);

int dp[3002][3002] = {};

int rec(string s, string t, int i , int j){
	if(i==0 || j==0)return 0;
	int& res = dp[i][j];
	if(res!=-1)return res;

	if(s[i-1]==t[j-1]) res = 1+ rec(s,t,i-1,j-1);
	else res = max(rec(s,t,i-1,j) , rec(s,t,i,j-1));
	
	return res;
}

int main(){
	IOS;
	memset(dp,0,sizeof(dp));
	//dp[0][0]=0;
	string s,t;
	cin >> s >> t;

	//rec(s,t,s.size(),t.size());



	for(int i=1 ; i <= s.size() ; ++i){
		for(int j=1 ; j <= t.size() ; ++j){
			if(s[i-1]==t[j-1]){
				dp[i][j] = 1 + dp[i-1][j-1];
			}
			else dp[i][j] = max(dp[i-1][j] , dp[i][j-1]);
		}
	}

	string ans = "";
	int i = s.size();
	int j = t.size();

	while(i>=1 && j>=1 ){
		if(s[i-1]==t[j-1]){
			ans+= s[i-1];
			i--;
			j--;
		}
		else{
			if(dp[i][j-1]<dp[i-1][j]) i--;
			else j--;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << endl;

}

Measured memory_bytes: 35456
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

typedef long long ll;

int main(int argc, char* argv[])
{
  std::string sa, sb, sc;
  std::cin >> sa >> sb >> sc;

  std::string::iterator it[3];

  it[0] = sa.begin();
  it[1] = sb.begin();
  it[2] = sc.begin();

  int pivot = 0;
  char ans = 'A';
  while (1) {
    if (pivot == 0 && it[0] == sa.end()) {
      ans = 'A';
      break;
    } else if (pivot == 1 && it[1] == sb.end()) {
      ans = 'B';
      break;
    } else if (pivot == 2 && it[2] == sc.end()) {
      ans = 'C';
      break;
    }

    if (*(it[pivot]) == 'a') {
      //std::cout << pivot << " a" << std::endl;
      it[pivot]++;
      pivot = 0;
    } else if (*(it[pivot]) == 'b') {
      //std::cout << pivot << " b" << std::endl;
      it[pivot]++;
      pivot = 1;
    } else {
      //std::cout << pivot << " c" << std::endl;
      it[pivot]++;
      pivot = 2;
    }
  }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数leng
#define INF 9223372036854775807 //  巨大数INF
using namespace std;

signed main() {
  int n;
  cin >> n;
  string a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  rep(i, n) {
    set<char> kind;
    kind.insert(a.at(i));
    kind.insert(b.at(i));
    kind.insert(c.at(i));
    ans += kind.size() -1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);
    string s;
    bool flag=false;
    cin>>s;
    string cpy_all=s;
    reverse(cpy_all.begin(),cpy_all.end());
    if(s==cpy_all)
        flag=true;
    if(flag)
    {
        string first_half=s.substr(0,(s.length()-1)/2);
        string first_cpy=first_half;
        string second_half=s.substr((s.length()-1)/2+1,(s.length()-1)/2);
        string second_copy=second_half;
        reverse(first_cpy.begin(),first_cpy.end());
        reverse(second_copy.begin(),second_copy.end());
        if(first_cpy==first_half&&second_half==second_copy)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int N = 1000000;
int p[2][N], n, r[N], a[N];
pair < int, int > t[2][N];
pair < int, int > f(pair < int, int > x, pair < int, int > y){
    if (x.F < y.F){
        return {x.F, min(y.F, x.S)};
    } else
        return {y.F, min(y.S, x.F)};
}
void build(int k, int v, int tl, int tr){
    if (tl == tr){
        t[k][v].F = p[k][tl];
        t[k][v].S = 1e7;
        return;
    }
    int mid = (tl + tr) / 2;
    build(k, v + v, tl, mid);
    build(k, v + v + 1, mid + 1, tr);
    t[k][v] = f(t[k][v + v], t[k][v + v + 1]);
}
pair < int, int > query(int k, int v, int tl, int tr, int l, int r){
    if (l > r) return {1e7, 1e7};
    if (l == tl && r == tr) return t[k][v];
    int mid = (tl + tr) / 2;
    auto p1 = query(k, v + v, tl, mid, l, min(r, mid));
    auto p2 = query(k, v + v + 1, mid + 1, tr, max(l, mid + 1), r);
    return f(p1, p2);
}
pair < int, int > f(int l, int rr){
  // cout << l << " -- " << rr << endl;
    pair < int, int > res;
    if (l >= rr){
        return {1e7, 1e7};
    }
    auto x = query(l % 2, 1, 1, n, (l + 1) / 2, (rr + 1) / 2);
    x.F = r[x.F];
    if (x.S != 1e7)
    x.S = r[x.S];
    if (x.F + 1 > rr){
        res.F = x.S;
    } else
        res.F = x.F;
   // cout << "res.F = " << res.F << " " << (res.F + 1) / 2 + (res.F % 2 == 0) << " " << (rr + 1) /2 << " " << ((res.F % 2) ^ 1) << endl;
    x = query(((res.F % 2) ^ 1), 1, 1, n, (res.F + 1) / 2 + (res.F % 2 == 0), (rr + 1) / 2);
    res.S = r[x.F];
    res.F = a[res.F];
    res.S = a[res.S];
    return res;
}
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt",  "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin >> n;
    for (int i = 1; i <= n; i++){
        int x;
        cin >> x;
        a[i] = x;
        p[i % 2][(i + 1) / 2] = x;
        r[x] = i;
    }
    set < pair < int, int > > t;
    set < int > s;
    build(1, 1, 1, n);
    build(0, 1, 1, n);
    s.insert(0);
    s.insert(n + 1);
    t.insert(f(1, n));
    for (int i = 0; i < n / 2; i++){
        auto x = *t.begin();
        t.erase(t.begin());
        cout << x.F << " " << x.S << " ";
        int p1 = r[x.F];
        int p2 = r[x.S];
        auto k1 = s.lower_bound(p2);
        auto k2 = s.lower_bound(p1);
        k2--;
        t.insert(f((*k2) + 1, p1 - 1));
        t.insert(f(p1 + 1, p2 - 1));
        t.insert(f(p2 + 1, (*k1) - 1));
        s.insert(p1);
        s.insert(p2);
    }
}


Measured memory_bytes: 46336
#pragma region macro
#include <bits/stdc++.h>
using i64 = int_fast64_t;
#define repeat(i, a, b) for(int i = (a); (i) < (b); ++(i))
#define rep(i, n) repeat(i, 0, n)

namespace std {
template <typename A, typename B>
string to_string(pair<A, B> p);

string to_string(const string &s) {
    return '"' + s + '"';
}

string to_string(const char *s) {
    return to_string((string)s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
    bool first = true;
    string res = "{";
    for(int i = 0; i < static_cast<int>(v.size()); i++) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(v[i]);
    }
    res += "}";
    return res;
}

template <size_t N>
string to_string(bitset<N> v) {
    string res = "";
    for(size_t i = 0; i < N; i++) {
        res += static_cast<char>('0' + v[i]);
    }
    return res;
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for(const auto &x : v) {
        if(!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
};  // namespace std
#pragma endregion

void solve() {
    i64 h, w;
    std::cin >> h >> w;
    if(h == 1 or w == 1) {
        std::cout << 1 << std::endl;
    } else {
        std::cout << (h * w + 1LL) / 2LL << std::endl;
    }
}

int main() {
    // std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    solve();
    return 0;
}

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;
struct Res{int from,to,dis;};
int main(){
    int n,m,r,a,b,c;
    vector<Res> A;
    cin>>n>>m>>r;
    vector<int> R(r);
    rep(i,r) cin>>R[i];
    rep(i,m) cin>>a>>b>>c,A.push_back({a,b,c}),A.push_back({b,a,c});
    int D[300][300],dp[300],INF=1e9;
    rep(i,n){
        int s=i+1;
        rep(j,n) dp[j+1]=INF;
        dp[s]=0;
        while(true){
            int x=0;
            for(auto k:A) if(dp[k.from]>dp[k.to]+k.dis) dp[k.from]=dp[k.to]+k.dis,x=1;
            if(x==0) break;
        }
        rep(j,n) D[s][j+1]=dp[j+1];
    }
    int x=1e9,y;
    sort(R.begin(),R.end());
    do{
        y=0;
        rep(i,r-1) y+=D[R[i]][R[i+1]];
        x=min(x,y);
    }while(next_permutation(R.begin(),R.end()));
    cout<<x;
}

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

using ll = long long;

const int mod = 1e9 + 7;

ll A[300000];
int cnt[300000][60];
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        for (int j = 0; j < 60; j++) {
            cnt[i][j] = (A[i] >> j) & 1;
        }
        if (i > 0) {
            for (int j = 0; j < 60; j++)
                cnt[i][j] += cnt[i - 1][j];
        }
    }
    ll ans = 0;
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < 60; j++) {
            if ((A[i] >> j) & 1) {
                (ans += (1LL << j) % mod * (i - cnt[i - 1][j]) % mod) %= mod;
            } else {
                (ans += (1LL << j) % mod * cnt[i - 1][j] % mod) %= mod;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 72960
#include<stdio.h>
#include<math.h>

typedef struct{
  double x;
  double y;
}Point;

void kock(int,Point,Point);

int main(){
  int n;
  Point p1={0,0},p2={100,0}; 

  scanf("%d",&n);

  printf("%f %f\n",p1.x,p1.y);
  kock(n,p1,p2);
  printf("%f %f\n",p2.x,p2.y);
  
  return 0;
}

void kock(int n,Point p1,Point p2){
  Point s,t,u;
  double rad;

  if(n==0) return;

  s.x=(2*p1.x+p2.x)/3;
  s.y=(2*p1.y+p2.y)/3;
  t.x=(p1.x+2*p2.x)/3;
  t.y=(p1.y+2*p2.y)/3;
  rad=M_PI/3;
  u.x=(t.x-s.x)*cos(rad)-(t.y-s.y)*sin(rad)+s.x;
  u.y=(t.x-s.x)*sin(rad)+(t.y-s.y)*cos(rad)+s.y;

  kock(n-1,p1,s);
  printf("%f %f\n",s.x,s.y);
  kock(n-1,s,u);
  printf("%f %f\n",u.x,u.y);
  kock(n-1,u,t);
  printf("%f %f\n",t.x,t.y);
  kock(n-1,t,p2);
}



Measured memory_bytes: 2044
import collections

N = int(input())
D = list(map(int, input().split()))
mod = 998244353


if D[0] != 0 :
  print(0)
else :
  D_dict  = collections.Counter(D)
  if D_dict[0] > 1 :
    print(0)
    exit()
  result = 1
  for i in range(1, len(D_dict)) :
    if D_dict[i] == 0 :
      print(0)
      exit()
    else :
      result *= D_dict[i-1]**D_dict[i]
      result = result % mod

  print(result)
  

Measured memory_bytes: 19936
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    vector <vector <int>> a(3, vector <int> (3));
    forn (i, 0, 3)
        cin >> a[i];
    vector <vector <bool>> used(3, vector <bool> (3));
    int k;
    cin >> k;
    forn (i, 0, k) {
        int t;
        cin >> t;
        forn (j, 0, 3)
            forn (k, 0, 3)
                if (a[j][k] == t)
                    used[j][k] = true;
    }
    bool ok = false;
    forn (i, 0, 3) {
        int cnt = 0;
        forn (j, 0, 3)
            cnt += used[i][j];
        if (cnt == 3)
            ok = true;
    }
    forn (i, 0, 3) {
        int cnt = 0;
        forn (j, 0, 3)
            cnt += used[j][i];
        if (cnt == 3)
            ok = true;
    }
    if (used[0][0] && used[1][1] && used[2][2])
        ok = true;
    if (used[2][0] && used[1][1] && used[0][2])
        ok = true;
    if (ok)
        cout << "Yes";
    else
        cout << "No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define fi first
#define se second
#define reset(n,k) memset((n),k,sizeof(n))
#define all(n) n.begin(),n.end()
#define pb push_back
using namespace std;
using ll=long long;
using pii=pair<int,int>;
int main(){
	IOS;
	int a,b;
	cin>>a>>b;
	int ans;
	for(ans=b*10;ans<b*10+10;ans++){
		if(ans * 8 / 100 == a){
			cout<<ans<<'\n';
			return 0;
		}
	}
	cout<<-1<<'\n';


}


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

#define M 1000000007
#define MM 998244353 
#define ll long long 
#define pb push_back
#define mem0(a) memset(a,0,sizeof(a))
#define mem1(a) memset(a,-1,sizeof(a))
#define memf(a) memset(a,false,sizeof(a))
#define all(v) v.begin(),v.end()
#define sz(a) (ll)a.size()
#define F first
#define S second
#define PI 3.1415926536
#define INF 2000000000000000000
#define endl "\n"
#define _time_ 1.0 * clock() / CLOCKS_PER_SEC
//RNG based on mersenne_twister 
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
ll power(ll b,ll e,ll m)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b%m,e/2,m)%m;
	return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
	if(e==0) return 1;
	if(e&1) return b*power(b*b,e/2);
	return power(b*b,e/2);
}
template<typename T, typename U> static inline void amin(T &x, U y){ if(y<x) x=y; }
template<typename T, typename U> static inline void amax(T &x, U y){ if(x<y) x=y; }


int _runtimeTerror_()
{
	ll R;
	cin>>R;
	cout<<fixed<<setprecision(10)<<2*PI*R<<endl;
	return 0;
}

int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#ifdef runSieve
		sieve();
	#endif
	#ifdef NCR
		initialize();
	#endif
	int TESTS=1;
	//cin>>TESTS;
	while(TESTS--)
		_runtimeTerror_();
	cerr<<"\n"<<_time_;
	return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double llf;
typedef pair<int, int> pii;
const int maxn = 2e5 + 5;
const ll inf = 2e15 + 7;
int a[33] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

int main()
{
	int n;
	cin >> n;
	cout << a[n - 1] << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	void run() {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String p = scan.next();
		s = s + s;
		char[] sc = s.toCharArray();
		char[] ps = p.toCharArray();
		boolean flag = false;
		for (int i = 0; i < sc.length - ps.length; i++) {
			if (sc[i] == ps[0]) {
				for (int j = 0; j < ps.length; j++) {
					if (sc[i + j] != ps[j]) break;
					if (j == ps.length - 1 && sc[i + j] == ps[j]) {
						System.out.println("Yes");
						flag = true;
					}
				}
			}
			if (flag == true) break;
		}
		if (flag == false)
			System.out.println("No");
	}
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 26240
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
using namespace std;

vector<long long> size(1, 0), normal(1, 0), three(1, 0), five(1, 0);

inline void init(long long upper) {
	for(int i = 1;; ++i) {
		const long long limit = (long long)pow((long double)10, (long double)i) - 1;
		three.push_back(limit / 3);
		five.push_back(limit / 5);
		normal.push_back(limit + limit / 15 - three[i] - five[i]);
		size.push_back(size[i - 1] + (normal[i] - normal[i - 1]) * i
					   + (three[i] - three[i - 1]) * 4 + (five[i] - five[i - 1]) * 4);

		if(size[i] > upper)
			break;
	}
}

inline string ltos(long long n) {
	ostringstream os;
	os << n;
	return os.str();
}

inline long long calc_length(long long limit, long long e) {
	--limit;
	const long long num3 = limit / 3, num5 = limit / 5;
	const long long numNo = limit + limit / 15 - num3 - num5;		
	return size[e - 1] + (numNo - normal[e - 1]) * e + (num3 - three[e - 1]) * 4 + (num5 - five[e - 1]) * 4;
}


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

	const long long MAX = 1e18;
	init(MAX);

	long long s;
	cin >> s;

	int e;
	for(int i = 1;; ++i) {
		if(size[i] > s) {
			e = i;
			break;
		}
	}

	long long low = pow((long double)10, (long double)(e - 1)), high = pow((long double)10, (long double)e);
	while(low + 1 < high) {
		const long long mid = (high + low) / 2;
		if(calc_length(mid, e) >= s)
			high = mid;

		else
			low = mid;
	}

	const long long offset = s - calc_length(low, e) - 1;

	string ans = "";
	for(long long i = low; (int)ans.size() <= 20 + offset; ++i) {
		if(i % 3 == 0 && i % 5 == 0)
			ans += "FizzBuzz";

		else if(i % 3 == 0)
			ans += "Fizz";

		else if(i % 5 == 0)
			ans += "Buzz";

		else
			ans += ltos(i);
	}

	cout << ans.substr(offset, 20) << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
ll MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}
ll modpow(ll x, ll y, ll m) {
    if (y == 0) return 1;
    ll res = modpow(x, y / 2, m);
    return res * res % m * (y & 1 ? x : 1) % m;
}
ll modinv(ll x) { return modpow(x, MOD - 2, MOD); }
 
int main(){
    ll N; cin >> N;
    vector<int> v(N);
    iota(ALL(v),1);
    map<vector<int>, ll> mp;
    int i = 1;
    do{
        mp[v] = i;
        i++;
    }while(next_permutation(ALL(v)));
    
    vector<int> P(N),Q(N);
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];
    
    print(abs(mp[P]-mp[Q]));
    
    return 0;
}

Measured memory_bytes: 5248
import numpy as np
n = int(input())
A = np.array(list(map(int,input().split())))
mod = 10**9+7
m = len(bin(max(A)))-2
ans = 0

for i in range(m):
  one = np.count_nonzero((A >> i)&1)
  zero = n - one
  ans += (pow(2,i,mod)*zero*one)%mod
print(ans%mod)

Measured memory_bytes: 50036
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner  sc=new Scanner(System.in);
		try{
	           
	
	 	   int n=sc.nextInt();
	 	   int m=sc.nextInt();
	 	   int ch=sc.nextInt()-1;
	 	   int cw=sc.nextInt()-1;
	 	   int dh=sc.nextInt()-1;
	 	   int dw=sc.nextInt()-1;
	 char a[][]=new char[n][m];
	 for(int i=0;i<n;i++) {
		 char c[]=sc.next().toCharArray();
		 for(int j=0;j<m;j++) {
			 a[i][j]=c[j];
		 }
	 }
	 int dis[][]=new int[n][m];
	 for(int i=0;i<n;i++) {
		Arrays.fill(dis[i],Integer.MAX_VALUE);
	 }
	 Deque<Integer> dq=new LinkedList<>();
	 int dirx[]= {-1,1,0,0};
	 int diry[]= {0,0,-1,1};
	 dis[ch][cw]=0;
	 dq.addFirst(cw);
	 dq.addFirst(ch);
	 while(!dq.isEmpty()) {
		int newx=dq.pollFirst(),newy=dq.pollFirst();
		for(int i=0;i<4;i++) {
			int currx=newx+dirx[i],curry=newy+diry[i];
			if(isValid(currx,curry,n,m)) {
				if(a[currx][curry]=='.') {
				if(dis[currx][curry]>dis[newx][newy]) {
					dis[currx][curry]=dis[newx][newy];
					dq.addFirst(curry);
					dq.addFirst(currx);
				}
				}
			}
		}
		for(int i=newx-2;i<=newx+2;i++) {
			for(int j=newy-2;j<=newy+2;j++) {
				
				if(isValid(i,j,n,m)){
					if(a[i][j]=='.') {
						if(dis[i][j]>dis[newx][newy]+1) {
							dis[i][j]=dis[newx][newy]+1;
							dq.addLast(i);
							dq.addLast(j);
						}
					}
				}
				
}
		}
	 }
	 if(dis[dh][dw]!=Integer.MAX_VALUE)
	 System.out.println(dis[dh][dw]);
	 else
		 System.out.println("-1");


		
		}catch(Exception e){
		    return;
		}
		}
	static boolean isValid(int i,int j,int r,int c ) {
			return i>=0&&j>=0&&i<r&&j<c;
	}
	}


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

using namespace std;

long dp[51][5010] = {};

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

    vector<int> x(51);
    for (int i = 1; i <= n; ++i) {
        cin >> x[i];
        x[i] -= a;
    }

    dp[0][2500] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j < 5000; ++j) {
            if (j - x[i] < 0 or j - x[i] > 5000) {
                dp[i][j] = dp[i - 1][j];
            } else {
                dp[i][j] = dp[i - 1][j] + dp[i - 1][j - x[i]];
            }
        }
    }

    cout << dp[n][2500] - 1 << endl;
    return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ca = a, cb = b, cc = c;
    
    if ((k % 2) == 0) {
        cout << (a - b) << endl;
    }
    else {
        cout << (b - a) << endl;
    }
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FLASH cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false);

#define F first
#define S second
#define pb push_back
#define int long long
#define maxn 200000
#define mod 1000000007
#define inf 1000000000000000000

#define fr(i,a,b) for(int i=a;i<b;i++)
#define FILEIO freopen("/home/aman/Desktop/Kachda/input.txt", "r", stdin); //freopen("/home/aman/Desktop/Kachda/output.txt", "w", stdout);
#define all(x) begin(x), end(x)
#define PII pair<int, int>
#define VI vector<int>
#define VII vector<PII>

using namespace std;

int n, dp[3001][3001], s[3001][3001];

signed main()
{
    
    FLASH

    cin>>n;

    fr(i, 1, n + 1){
        cin>>dp[i][i];
        s[i][i] = dp[i][i];
    }

    fr(l, 2, n + 1){
        fr(i, 1, n + 1){
            int j = i + l - 1;
            if(j > n) break;
            s[i][j] = s[i][j - 1] + dp[j][j];
            dp[i][j] = max(dp[i][i] + s[i + 1][j] - dp[i + 1][j], dp[j][j] + s[i][j - 1] - dp[i][j - 1]);
        }
    }

    cout<<2*dp[1][n] - s[1][n]<<'\n';
}

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

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

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

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

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


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
#define il inline 
#define int long long
//int n,m,T;long long P,p[200005],f[200005],a,b,c,d,s=1,inv[2000005],jc[2000005],jcinv[2000005];
il int read()
{
	int k=1,re=0;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')k=-1;ch=getchar();}
	while(ch<='9'&&ch>='0'){re=re*10+ch-48;ch=getchar();}
	return re*k;
}
il void write(int x)
{
	if(x<0)return write(-x),void();
	if(x<=9)return putchar(x+48),void();
	return write(x/10),write(x%10),void();
}
char s[100005];
int a,b;
signed main()
{
	a=read();
	scanf("%s",s+1);
	b=strlen(s+1);
	for(int i=1;i<=min(a,b);i++)
		putchar(s[i]);
	if(b>a)puts("...");
}

Measured memory_bytes: 3760
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial, gcd
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


def solve():
    s, c = [int(x) for x in input().split()]
    if s > c // 2:
        print(c // 2)
    else:
        c -= 2 * s
        print(s + c // 4)
        


t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

abc

"""


Measured memory_bytes: 9336
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)
 
int main(void) {
  ll n, a, b; cin >> n >> a >> b;
  ll ans = n/(a+b)*a;
  n%=(a+b);
  ans+=min(n, a);
  cout<<ans<<endl;
  return 0;
}

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

#define i64 long long int
#define ran 202202

int n;
i64 k;
int a[ran], f[ran];

i64 chk(i64 lim) {
	i64 res = 0;
	for(int i=0;i<n;i++) {
		i64 x = (lim==0 ? 0 : lim/f[n-i-1]);
		if (x<a[i]) res += a[i]-x;
	}
	return res;
}

int main() {
	scanf("%d%lld", &n, &k);
	for(int i=0;i<n;i++) scanf("%d", &a[i]);
	sort(a, a+n);
	for(int i=0;i<n;i++) scanf("%d", &f[i]);
	sort(f, f+n);
	
	i64 l = 0, r = 1e12, ans = 1e12;
	while(l<=r) {
		i64 mid = (l+r)/2;
		if (chk(mid) <= k) {
			ans = mid;
			r = mid - 1;
		} else l = mid + 1;
	}
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 1792
def binary_search(array, target)
	return nil if array.empty?
	pivot = array.size / 2
	if array[pivot] == target
		pivot
	elsif target < array[pivot]
		binary_search(array[0...pivot], target)
	else
		binary_search(array[(pivot + 1)..-1], target)
	end
end

n = STDIN.gets.to_i
s = STDIN.gets.split[0...n].map(&:to_i)

q = STDIN.gets.to_i
t = STDIN.gets.split[0...q].map(&:to_i)

count = 0
t.each do |te|
	count += 1 if binary_search(s, te)
end
p count

Measured memory_bytes: 50604
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional> 
#include <iomanip>
#include <unordered_map>
#include <memory.h>
#include <cstring>
#include <fstream>

using namespace std;

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

	cin >> n;

	for (long long int a = 1; a <= 3500; a++)
	{
		for (long long int b = 1; b <= 3500; b++)
		{
			long long int x = (a * b * n);
			long long int y = (4 * a * b) - (a * n) - (b * n);
			if (y == 0)
			{
				continue;
			}
			//cout << a << ' ' << b << ' ' << x / y << '\n';
			if (x%y == 0 && x/y>0)
			{
				cout << a << ' ' << b << ' ' << x / y << '\n';
				return 0;
			}
		}
	}
	return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

const int INF = 1e9 + 1;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5 + 1;

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

  CIN(X, A, B);
  int ans = X - A;
  if (ans < 0) ans = 0;
  ans %= B;
  cout << ans << endl;

  return 0;
}




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

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

  for(int k=0;k<n;k++){
    int y,m,d;
    cin>>y>>m>>d;
    int ans=0;
    for(int i=y+1;i<1000;i++){
      if(i%3==0){
        ans+=200;
      }else{
        ans+=195;
      }
    }

    for(int i=m+1;i<11;i++){
      if(y%3==0){
        ans+=20;
      }else{
        if(i%2==0){
          ans+=19;
        }else{
          ans+=20;
        }
      }
    }

    if(y%3==0){
      ans+=20-d;
    }else{
      if(m%2==0){
        ans+=19-d;
      }else{
        ans+=20-d;
      }
    }
    cout<<ans+1<<endl;
  }
  return 0;
}

Measured memory_bytes: 3088
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <utility>
using namespace std;
typedef pair<int, int> ii;
int N, T, A[3000], B[3000];
int dptable[3000][3000];
int dp(int id, int t) {
	if (id == N) return 0;
	if (t >= T) return 0;
	if (dptable[id][t] != -1) return dptable[id][t];
	return dptable[id][t] = max(dp(id + 1, t), dp(id + 1, t + A[id]) + B[id]);
}
int main() {
	memset(dptable, -1, sizeof dptable);
	scanf("%d %d", &N, &T);
	ii stuff[N];
	for (int i = 0; i < N; ++i) scanf("%d %d", &stuff[i].first, &stuff[i].second);
	sort(stuff, stuff + N);
	for (int i = 0; i < N; ++i) {
		A[i] = stuff[i].first;
		B[i] = stuff[i].second;
	}
	printf("%d", dp(0, 0));
	return 0;
}

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

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

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

	while(true){
		int n,m; cin >> n >> m;
		if(n == 0) break;

		int a[2005];
		for (int i = 0;i < n;i++){
			cin >> a[i];
		}

		int s[2000];
		for (int i = 0;i < m;i++){
			cin >> s[i];
		}	

		int now = 0;

		for (int i = 0;i < m;i++){
			//cout << now << endl;
			now += s[i];
			if(now >= n-1){
				cout << i+1 << endl;
				break;
			}
			now += a[now];
			if(now >= n-1){
				cout << i+1 << endl;
				break;
			}
		}
	}

	return 0;

}



Measured memory_bytes: 3220
#ifdef OJ_MISC_OFFLINE

#include "prolog.h"

#else
#define PRINT
#define LCERR
#endif

#include <algorithm>
#include <array>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>

namespace {

using namespace std;

class Solution {
public:
    int ordinary_number(const vector<int>& nums) {
        int count = 0;
        for (size_t i = 1; i < nums.size() - 1; ++i) {
            if (nums[i - 1] < nums[i] && nums[i] < nums[i + 1]) {
                ++count;
            } else if (nums[i - 1] > nums[i] && nums[i] > nums[i + 1]) {
                ++count;
            }
        }
        return count;
    }
private:

};

int solve() {
    Solution solution;
    // handle IO here
    int n;
    cin >> n;
    vector<int> nums;
    for (int i = 0; i < n; ++i) {
        nums.emplace_back();
        cin >> nums.back();
    }
    cout << solution.ordinary_number(nums) << endl;
    return 0;
}

} // anonymous namespace

#ifdef OJ_MISC_OFFLINE

#include "epilog.h"

#else

int main() {
    return solve();
}

#endif


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

int n, q;
int A[21], M[201];

int main() {
    cin >> n;
    for (int i=0; i<n; ++i) cin >> A[i];
    cin >> q;
    for (int i=0; i<q; ++i) cin >> M[i];

    bool dp[2001] = {false};
    dp[0] = true;
    for (int i=0; i<n; ++i) {
        for (int j=2000; j>=0; --j) {
            if (dp[j] && j + A[i] < 2001) {
                dp[j + A[i]] = true;
            }
        }
    }

    for (int i=0; i<q; ++i) {
        cout << (dp[M[i]] ? "yes" : "no") << endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
// cout << "\t" << endl;

int main() {
  lint n, k;
  cin >> n >> k;
  lint a, b, ans;
  a = n % k;
  b = k * (n / k + 1) - n;
  ans = min(a, b);

  cout << ans << endl;
}

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

int main() {
    string s, p;
    cin >> s >> p;
    s += s;
    if (s.find(p) == string::npos) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "random"

using namespace std;

const long long int MOD = 1000000007;
const long double EPS = 0.00000001;
const long double PI = 3.1415926535897932384626433;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	while (N) {
		vector<vector<int>>know(N + 1,vector<int>(N+1));
		for (int i = 1; i <= N; i++) {
			cin >> M;
			know[i].resize(M);
			for (int j = 0; j < M; j++) {
				cin >> K;
				know[i][K] ++;
			}
		}
		cin >> K;
		vector<int>open(K);
		for (int i = 0; i < K; i++) {
			cin >> open[i];
		}
		vector<int>can;
		for (int i = 1; i <= N; i++) {
			bool flag = true;
			for (auto j : open) {
				if (!know[i][j]) {
					flag = false;
					break;
				}
			}
			if (flag) {
				can.push_back(i);
			}
		}
		if (can.size() != 1) {
			cout << "-1\n";
		}
		else {
			cout << can[0] << endl;
		}
		cin >> N;
	}
	return 0;
}

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

int main() {
    int n = 0;
    scanf("%d\n", &n);
    int *a = (int *)calloc(100001, sizeof(int));
    int buf = 0;
    for (int i=0; i<n; i++) {
        scanf("%d", &buf);
        if (buf > 0) {
            a[buf-1]++;
            a[buf]++;
            a[buf+1]++;
        }
        else {
            a[buf]++;
            a[buf+1]++;
        }
    }
    int max = 0;
    for (int i=0; i<100001; i++) {
        if (a[i] > max) max = a[i];
    }
    printf("%d\n", max);
    free(a);
    return 0;
}


Measured memory_bytes: 512
length = int(input())
num_list = list(map(int,input().split(' ')))
count = 0
for i in range(1,length-1,1):
  if (num_list[i-1] < num_list[i]) and (num_list[i] < num_list[i+1]):
    count += 1
  if (num_list[i-1] > num_list[i]) and (num_list[i] > num_list[i+1]):
    count += 1
    
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define intt long long int
#define fr(a,b) for(int i = a; i < b; i++)
#define rep(i,a,b) for(int i = a; i < b; i++)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
#define prDouble(x) cout << fixed << setprecision(10) << x
#define triplet pair<ll,pair<ll,ll>>
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
void go()
{
#ifndef ONLINE_JUDGE
  freopen("inn.txt","r",stdin);
  freopen("o.txt","w",stdout);
  #endif
}
 
int main() {
   fast_io;
   go();
  
  int n;cin>>n;
  vector<int> v(n);
  
  for(int i=0;i<n;i++){
  	cin>>v[i];
  	
  }   
  
  intt ans=0;
  for(int i=0;i<n;i++){	
  	for(int j=i+1;j<n;j++){
  		if(v[j]!=v[i]){
  			for(int k=j+1;k<n;k++){
  				if(v[k]!=v[j] && v[k]!=v[i] && (v[k]+v[i]>v[j] && v[j]+v[i]>v[k] && v[k]+v[j]>v[i]))
  				ans++;
  			}
  		}
  	}
  }
  cout << ans <<"\n";
}


Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
  int N,M;
  long double sum=0;
  scanf("%d %d",&N,&M);
  int A[N];
  int i;
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
        sum=sum+A[i];
  }
  int j,tmp;
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      if(A[i]>A[j]){
        tmp=A[i];
        A[i]=A[j];
        A[j]=tmp;
      }
    }
  }
  int cou=0;
  sum=sum/(4*M);
  for(i=N-1;i>=0;i--){
    if(A[i]>=sum){
      cou++;
    }
    else{
      break;
    }
  }
  if(cou>=M){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
// #pragma comment(linker, "/stack:200000000"]
 
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <bitset>
#include <stack>
#include <random>
#include <fstream>
#include <sstream>
#include <chrono>

#define fi first
#define se second
#define pb push_back
#define ll long long
#define ld long double
#define hm unordered_map 
#define pii pair<int, int>
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define cinv(v) for (auto& x: v) cin >> x
#define fr(i, n) for (int i = 0; i < n; ++i)
#define fl(i, l, n) for (int i = l; i < n; ++i)

#define int ll

using namespace std;

#ifdef __LOCAL
	#define dbg(x) cerr << #x << " : " << x << '\n'
	const int maxn = 20;
#else 
	#define dbg(x)
	const int maxn = 4e5 + 20;
#endif

//tg: @galebickosikasa
 
const ll inf = (ll) 2e9;
const ld pi = 3.14159265358979323846264;
const ld eps = 1e-8;
const ll mod = (ll)1e9 + 7;
const ll ns = 97;

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());



signed main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int n, k, c;
	cin >> n >> k >> c;
	string s;
	cin >> s;
	int dp[maxn], mx[maxn];
	for (auto& x: dp) x = 0;
	for (auto& x: mx) x = 0;
	for (int i = n - 1; i >= 0; --i) {
		if (s[i] == 'o') 
			dp[i] = 1 + mx[i + c + 1];
		else 
			dp[i] = mx[i + 1];
		mx[i] = max (mx[i + 1], dp[i]);
		// dbg (dp[i]);
	}
	int last = 0, m = k;
	vector<int> ans;
	queue<int> a;
	while (m) {
		for (int i = last; i < n; ++i) {
			if (s[i] == 'o' && dp[i] >= m) 
				a.push (i);
			else {
				if (dp[i] < m) {
					last = i;
					break;
				}
			}
		}
		dbg (sz (a));
		if (sz (a) == 1) ans.pb (a.front ());
		if (!a.empty ()) last = max (last, a.front () + c + 1);
		int tmp = a.front ();
		while (!a.empty () && tmp + c + 1 > a.front ()) a.pop ();
		--m;
	}
	for (auto& x: ans) cout << x + 1 << '\n';






}

Measured memory_bytes: 9608
#include <stdio.h>

/* 20000! has 77338 digits */
/* 9 digits in one int */
#define TABAICHO_SIZE 8667
#define TABAICHO_BLOCK 1000000000
int tabaicho_main[TABAICHO_SIZE];

void tabaicho_set(int num) {
	int i;
	tabaicho_main[0]=num;
	for(i=1;i<TABAICHO_SIZE;i++)tabaicho_main[i]=0;
}

void tabaicho_mul(int num) {
	int kuriagari=0;
	long long calctemp;
	int i;
	for(i=0;i<TABAICHO_SIZE;i++) {
		calctemp=(long long)tabaicho_main[i]*num;
		calctemp+=kuriagari;
		tabaicho_main[i]=calctemp%TABAICHO_BLOCK;
		kuriagari=calctemp/TABAICHO_BLOCK;
	}
}

void tabaicho_div(int num) {
	long long remainder=0;
	int i;
	for(i=TABAICHO_SIZE-1;i>=0;i--) {
		remainder=remainder*TABAICHO_BLOCK+tabaicho_main[i];
		tabaicho_main[i]=remainder/num;
		remainder=remainder%num;
	}
}

void tabaicho_print(void) {
	int i;
	for(i=TABAICHO_SIZE-1;i>=0;i--) {
		if(tabaicho_main[i]>0)break;
	}
	printf("%d",tabaicho_main[i]);
	for(i--;i>=0;i--)printf("%09d",tabaicho_main[i]);
	putchar('\n');
}

int main(void) {
	int n,m,r;
	scanf("%d%d%d",&n,&m,&r);
	r-=n*m; /* n=3 r=8 m=1 xoo|xoo|xo */
	if(r<0)puts("0");
	else if(r==0)puts("1");
	else {
		int i,j,n2;
		/* n=3 r=5 oo|oo|o */
		/* (n+r-1)C(n-1) */
		tabaicho_set(1);
		n2=n-1;
		if((n+r-1)-(n-1)<n-1)n2=(n+r-1)-(n-1);
		for(i=0,j=n+r-1;i<n2;i++,j--)tabaicho_mul(j);
		for(i=1;i<=n2;i++)tabaicho_div(i);
		tabaicho_print();
	}
	return 0;
}

Measured memory_bytes: 648
X, Y = map(int, input().split())

if (X + Y) % 3:
    print(0)
    exit()

n = (2*X - Y) // 3
m = (-X + 2*Y) // 3

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9 + 7
N = (n + m)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

a = cmb(n+m, m, mod)

print(a)

Measured memory_bytes: 82388