akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 5e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int power (int a, int b = mod - 2)
{
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return res;
}


int fac[N + 1], inv[N + 1];
int ncr (int n, int k)
{
    return fac[n] * inv[k] % mod * inv[n - k] % mod;
}

int npr (int n, int k)
{
    return fac[n] * inv[n - k] % mod;
}
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	fac[0] = inv[0] = 1;
	FOR (i, 1, N) fac[i] = fac[i - 1] * i % mod;
	inv[N] = power(fac[N]);
	
	FORD (i, N - 1, 1) inv[i] = inv[i + 1] * (i + 1) %mod;
	
	readb(n, m);
	int sum = npr(m, n) * npr(m, n) % mod;
	
	FOR (k, 1, n)
	{
	    int x = ncr(n, k)* npr(m, k) % mod;
	    x = x*npr(m - k, n - k) % mod * npr(m - k, n - k) % mod;
	    if (k % 2) x *= -1;
	    
	    sum = (sum + x) % mod;
	}
	
	sum = (sum + 2*mod) % mod;
	print(sum);
}



















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

int main() {
  int R;
  cin>>R;
  if(R<1200){
   cout<<"ABC"<<endl;
  }
  else if(R<2800){
   cout<<"ARC"<<endl;
  }
  else{
    cout<<"AGC"<<endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
      	//データ取り込み
		Scanner sc = new Scanner(System.in);
		int cnt = 0;
		int N = sc.nextInt();
      	int M = sc.nextInt();
		System.out.println(N+M/2);
    }
}

Measured memory_bytes: 23124
import java.util.*;

public class Main {
	public static void main(String[] args) {
		// practice contest

		Scanner sc = new Scanner(System.in);
		int a1 = sc.nextInt();
		int a2 = sc.nextInt();
		int a3 = sc.nextInt();

		int add = a1 + a2 + a3;

		if (add >= 22) {
			System.out.println("bust");
		} else {
			System.out.println("win");
		}

	}
}

Measured memory_bytes: 23764
use std::collections::HashMap;
use std::f64;

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

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
#[allow(unused)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
#[allow(unused)]
fn round_to_integer(a: f64, digit: u8) -> i64 {
    let mut ai: i64;
    let mut d = digit;
    let mut p = 1;

    while d > 0 {
        p *= 10;
        d -= 1;
    }
    ai = (a * p as f64) as i64;

    while ai as f64 / p as f64 - a > 0.5 / p as f64 {
        ai -= 1;
    }
    while ai as f64 / p as f64 - a < -0.5 / p as f64 {
        ai += 1;
    }
    ai
}

fn main() {
    input! {
        n:u16,
    }

    let mut payment = 1000;

    while n > payment {
        payment += 1000;
    }

    let res = payment - n;

    println!("{}", res);
}


Measured memory_bytes: 2148
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i,j;
        while(true){
            int n=sc.nextInt();
            int r=sc.nextInt();
            if(n==0 && r==0){
                break;
            }
            int[] hana = new int[n];
            for(i=0;i<n;i++){
                hana[i]=n-i;
            }
            for(j=0;j<r;j++){
                int p=sc.nextInt();
                int c=sc.nextInt();
                int[] stock=new int[c+p-1];
                for(i=0;i<c;i++){
                    stock[i]=hana[p-1+i];
                }
                for(i=c;i<p+c-1;i++){
                    stock[i]=hana[i-c];
                }
                for(i=0;i<p+c-1;i++){
                    hana[i]=stock[i];
                }
            }
            System.out.println(hana[0]);
        }
        sc.close();

    }
}


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

int main() {
    int n;
    cin >> n;
    vector<char> s(n);
    for (auto& e : s) cin >> e;
    sort(begin(s), end(s));
    auto itr = unique(begin(s), end(s));
    cout << ((itr - begin(s)) == 3 ? "Three" : "Four") << endl;
}


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

from collections import Counter
c = Counter(a)
for k in c.keys():
    if c[k] == 2:
        break
l = []
for i in range(len(a)):
    if a[i] == k:
        l.append(i)
    if len(l) == 2:
        break
d = n - l[1] + l[0]

def power(x, y):
    if   y == 0     : return 1
    elif y == 1     : return x % mod
    elif y % 2 == 0 : return power(x, y // 2) ** 2 % mod
    else            : return power(x, y // 2) ** 2 * x % mod

mod = (10 ** 9 + 7)

N1 = n + 2
factorial1 = [1]
for i in range(1, N1):
    factorial1.append(factorial1[i - 1] * i % mod)
inverseFactorial1 = [0] * N1
inverseFactorial1[N1 - 1] = power(factorial1[N1 - 1], mod - 2)
for i in range(N1 - 2, -1, -1):
    inverseFactorial1[i] = inverseFactorial1[i + 1] * (i + 1) % mod
def combi1(x, y):
    return factorial1[x] * inverseFactorial1[y] * inverseFactorial1[x - y] % mod

for k in range(1, n + 2):
    if d >= k - 1:
        print((combi1(n+1, k) - combi1(d, k-1)) % mod)
    else:
        print(combi1(n+1, k))


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[200005];
ll dp[200005];
ll dp2[200005][2];
ll P[200005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    REP(i, N + 1) {
        dp[i] = -INF;
        dp2[i][0] = dp2[i][1] = -INF;
    }

    ll ans = -INF;
    dp[0] = A[0];
    memset(P, 0, sizeof(P));
    if (N % 2 == 0) {
        dp[1] = A[0];
        dp[2] = A[1];
        for (ll i = 2; i < N ; ++i) {
            if (i % 2 == 0)
                dp[i + 1] = dp[i - 1] + A[i];
            else
                dp[i + 1] = std::max(dp[i - 1], dp[i - 2]) + A[i];
        }
        ans = std::max({ans, dp[N], dp[N - 1]});
    }
    else {
        dp[1] = A[0];
        dp[2] = A[1];
        for (ll i = 2; i < N - 1; ++i) {
            if (i % 2 == 0)
                dp[i + 1] = dp[i - 1] + A[i];
            else
                dp[i + 1] = std::max(dp[i - 1], dp[i - 2]) + A[i];
        }
        ans = std::max({ans, dp[N - 1], dp[N - 2]});

#if false
        REP(i, N) {
            cout << dp[i + 1] << endl;
        }
        cout << endl;
#endif

        dp2[0][0] = 0;
        dp2[0][1] = 0;
        dp2[1][0] = 0;
        dp2[1][1] = A[0];
        dp2[2][0] = A[1];
        dp2[3][0] = A[2];
        dp2[3][1] = A[0] + A[2];
        for (ll i = 3; i < N; ++i) {
            if (i % 2 == 1) {
                dp2[i + 1][0] = std::max(dp2[i - 1][0], dp2[i - 2][1]) + A[i];
            }
            else {
                dp2[i + 1][0] = std::max({dp2[i - 1][0], dp2[i - 2][0], dp2[i - 3][1]}) + A[i];
                dp2[i + 1][1] = dp2[i - 1][1] + A[i];
            }
        }

        ans = std::max({ans, dp2[N][0], dp2[N - 1][0], dp2[N - 2][1]});
        // ans = std::max(ans, s);
    }

    cout << ans << endl;

    return 0;
}

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert
#define endl '\n'

void pre(){

}

void solve(){
    
    string s;
    cin>>s;
    if(s[0] == '7' || s[1] == '7' || s[2] =='7')
        cout << "Yes";
    else cout << "No";
    
}

int main(){
    IOS;
    pre();
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();   
    }
    return 0;
}

Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<queue>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
using namespace std;

#define REP(i,a) for(int i=0;i<(int)(a);i++)
#define pb push_back
#define sz size()
#define INF (1<<25)
#define all(a) (a).begin(),(a).end()
#define V 3030
typedef pair<int,int> P;

struct edge{
  int from,to,cost,cap,rev;
  bool operator<(const edge x)const{return cost>x.cost;}
};

vector<edge> G[V];
int d[V];
bool use[V];
int h[V],pv[V],pe[V];
int v,e;

void add_edge(int s,int g,int c,int p){
  G[s].pb((edge){s,g,c,p,G[g].sz});
  G[g].pb((edge){g,s,-c,0,G[s].sz-1});
}

int min_cost_flow(int s,int t,int f){
  int res = 0;
  fill(h,h+v,0);
  while(f>0){
    priority_queue<P ,vector<P> ,greater<P> > q;
    fill(d,d+v,INF);
    d[s] = 0; q.push(P(0,s));
    while(q.sz){
      P p = q.top();q.pop();
      int u = p.second;
      if(d[u] > p.first)continue;
      REP(i,G[u].sz){
	edge &e = G[u][i];
	if(e.cap>0 && d[e.to] > d[u] + e.cost + h[u] - h[e.to]){
	  d[e.to] = d[u] + e.cost + h[u] - h[e.to];
	  pv[e.to] = u; pe[e.to] = i;
	  q.push(P(d[e.to],e.to));
	}
      }
    }
    if(d[t]==INF)return -1;
    REP(u,v)h[u] += d[u];

    int x = f;
    for(int u=t;u!=s;u=pv[u])x = min(x,G[pv[u]][pe[u]].cap);
    f -= x;
    res += x*h[t];
    for(int u=t;u!=s;u=pv[u]){
      edge &e = G[pv[u]][pe[u]];
      e.cap -= x; G[u][e.rev].cap += x;
    }
  }
  return res;
}

int n;
int a[1010],b[1010];
vector<int> len;

int main(){
  scanf("%d",&n);
  len.clear();

  for(int i=0;i<n;i++){
    scanf("%d%d",&a[i],&b[i]);
    len.pb(a[i]); len.pb(b[i]);
  }

  sort(all(len));
  len.erase(unique(all(len)),len.end());

  v = n + len.size() + 3;
  for(int i=0;i<v;i++)G[i].clear();

  for(int i=0;i<n;i++){
    add_edge(v-2,i,0,1);
    add_edge(i,v-3,0,1);
    int tmp = lower_bound(all(len),a[i])-len.begin() + n;
    add_edge(i,tmp,-b[i],1);
    tmp = lower_bound(all(len),b[i])-len.begin() + n;
    add_edge(i,tmp,-a[i],1);
  }

  for(int i=0;i<len.size();i++)add_edge(n+i,v-1,0,1);
  add_edge(v-3,v-1,0,INF);

  printf("%d\n",-1*min_cost_flow(v-2,v-1,n));
}

Measured memory_bytes: 1692
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define ll unsigned long long
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    REP(i,max(a,b)){
        cout<<min(a,b);
    }
    cout<<endl;
}

Measured memory_bytes: 256
// see https://gist.github.com/LumaKernel/ff55d49ee1af69b7388f15b707e75c15
const bool DEBUG = 1;
#include <iostream>
#include <vector>
#include <array>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <complex>
#include <random>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef tuple<ll, ll> P;
typedef tuple<ll, ll, ll> P3;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<P> VP;

#define omajinai ios::sync_with_stdio(false);cin.tie(0)

#define FOR(i,a,b) for(int i=(a);i<int(b);++i)
#define REP(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(b)-1;i>=int(a);--i)
#define RREP(i,n) RFOR(i,0,n)

#define LFOR(i,a,b) for(ll i=(a);i<(b);++i)
#define LREP(i,n) LFOR(i,0,n)
#define LRFOR(i,a,b) for(ll i=(b)-1;i>=(a);--i)
#define LRREP(i,b,a) LRFOR(i,0,n)

#define ALL(a) (a).begin(),(a).end()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define MP make_pair
#define PB push_back
#define EACH(i,c) REP(i,(int)(c).size())
#define REACH(i,c) RREP(i,(int)(c).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define BR cout << "\n"

#define dump(x) if(DEBUG)cerr<<"[" << __LINE__ << "] "<<#x<<"="<<(x)<<"\n"
#define dump2(x,y) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n"
#define dump3(x,y,z) if(DEBUG)cerr<<"["<<__LINE__<< "] "<<#x<<"="<<(x)\
  <<" , "<<#y<<"="<<(y)<<"\n"\
  <<" , "<<#z<<"="<<(z)<<"\n"

#define SAY(x) if(DEBUG) cerr << "[" << __LINE__ << "] " << (x) << "\n"

#define YES(x) cout<<((x)?"YES":"NO")<<"\n"
#define Yes(x) cout<<((x)?"Yes":"No")<<"\n"
#define yes(x) cout<<((x)?"yes":"no")<<"\n"

int int_in(){int n;cin>>n;return n;}
ll ll_in(){ll n;cin>>n;return n;}
string string_in(){string n;cin>>n;return n;}
#define ini int_in()
#define inl ll_in()
#define ins string_in()

#define inside(x,y) (0<=(x)&&(x)<w&&0<=(y)&&(y)<h)

const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9+7;

ll ans;
map<int,int>m;
int main() {
  omajinai;
  //#####//
  int n=ini;
  REP(i,n){
	  int x=ini;
	  if(m.count(x)){
		  m[x]++;
	  }else{
		  m[x]=1;
	  }
  }
  for(auto e:m){
	 if(e.first>e.second){
		 ans+=e.second;
	 }else{
		 ans+=e.second-e.first;
	 }
  }
  cout<<ans<<endl;
}

//


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define PI 3.141592653589793
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N;
  cin >> N;
  vvll G(N, vll(0));
  vvll dp(N, vll(N, INF));
  for(int i = 0; i < N; i++){
    string S;
    cin >> S;
    dp.at(i).at(i) = 0;
    for(int j = i+1; j < N; j++){
      if(S.at(j) == '1'){
        G.at(i).push_back(j);
        G.at(j).push_back(i);
        dp.at(i).at(j) = 1;
        dp.at(j).at(i) = 1;
      }
    }
  }
  vll color(N, 0);
  function<bool(int, int)> dfs = [&](int v, int c){
    if(color.at(v) != 0){
      if(color.at(v) == c) return true;
      else return false;
    }
    color.at(v) = c;
    for(int i = 0; i < G.at(v).size(); i++){
      int next = G.at(v).at(i);
      if(!dfs(next, -1 * c)) return false;
    }
    return true;
  };
  if(!dfs(0, 1)){
    cout << -1 << endl;
    return 0;
  }
  
  for(int k = 0; k < N; k++){
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        chmin(dp.at(i).at(j), dp.at(i).at(k) + dp.at(k).at(j));
      }
    }
  }
  ll ans = 0;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < N; j++){
      chmax(ans, dp.at(i).at(j) + 1);
    }
  }
  cout << ans << endl;
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  str s; cin >>s;
  ll ans = 0;
  rep(i, 4)
  {
    if(s[i] == '2') ans++;
  }
  fin(ans)
  return;
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

C = []; S = []; F = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    C.append(c); S.append(s); F.append(f)

for i in range(N):
    t = 0
    for j in range(i, N-1):
        if t <= S[j]:
            t = S[j]
        elif t % F[j] == 0:
            pass
        elif t % F[j] !=0:
            t += F[j] - (t%F[j])
        t += C[j]
    print(t)
    

Measured memory_bytes: 3064
#include<cstdio>
#include<iostream>
#include<cstring>
#include<cstdlib>
#define RG register
using namespace std;
const int N=1e5+10;
int n,a[4][N],num[2],to[N];
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
template<typename I>inline void swp(I&a,I&b){a^=b; b^=a; a^=b;}
template<typename I>inline I abss(const I a){return a>0 ? a : -a;}
int main()
{
//	freopen("Rotate 3x3.in","r",stdin);
	//freopen(".out","w",stdout);
	read(n);
	for(RG int i=1;i<=n;i++) 
	{
		read(a[1][i]);
		if(a[1][i]%3==2) return printf("No\n"), 0;
	}
	for(RG int i=1;i<=n;i++)
	{
		read(a[2][i]); to[i]=(a[2][i]-1)/3+1;
		if(a[2][i]%3!=2 || (a[2][i]-1)/3!=(a[1][i]-1)/3 || abss(to[i]-i)&1) return printf("No\n"), 0;
		num[i&1]^=(a[1][i]>a[2][i]);
	}
	for(RG int i=1;i<=n;i++)
	{
		read(a[3][i]);
		if((a[3][i]-1)/3!=(a[2][i]-1)/3) return printf("No\n"), 0;
	}
	for(RG int i=1;i<=n;i++)
	 while(to[i]!=i) num[i&1^1]^=1, swp(to[i],to[to[i]]);
	printf("%s\n",num[0]|num[1] ? "No" : "Yes");
	//fclose(stdin); fclose(stdout);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main() {
	int a, b,c=0;
	cin >> a >> b;
	if (a == b)cout << a + b << endl;
	else {
		for (int i = 0; i < 2; i++) {
			if (a >= b)c += a; a--;
			if (a < b) c += b; b--;
		}
		cout << c << endl;
	}
	return 0;

}

Measured memory_bytes: 256
N,K = list(map(int,input().split(" ")))
import math
total = 0
for i in range(1,N + 1):
    if i < K:
        T = math.ceil(math.log(K / i,2))
    else:
        T = 0
    total += 1 / (N * 2 ** T)
print(total)

Measured memory_bytes: 3060
#include <iostream>
#define INF 1000000
using namespace std;
int main(){
  int sugo[2000];
  int n,m;
  while(1){
    cin >> n >> m;
    if(n == 0 && m == 0 )break;
    for(int i = 0 ; i < 2000; i++)sugo[i] = 0;
    for(int i = 1 ; i <= n ; i++ )cin >> sugo[i];
    int odr,p = 1,ans = 0;
    int f = 1;
    for(int i = 0 ; i < m ;i++){
      cin >> odr;
      if(f){
	ans++; 
	p+=odr;
	p+=sugo[p];
	if(p >= n-1)f = 0;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int main() {
  string S;
  cin >> S;
  
  long long sum = 0;
  string A;
  string B;
    
  for (int i = 0; i < (1 << (S.size()-1)); i++) {
    bitset<11> p(i);
    A = S.at(0);   
//    B = "";
    for (int j = 0; j<(S.size()-1); j++){     
      if(p.test(j)){
        sum += stoll(A);
//        B = B + A +'+';
        A = S.at(j+1);
      }
      else
      {
        A = A + S.at(j+1);
      }
    }
//    B = B + A;
//    cout << i << ':' << B << endl; 
    sum += stoll(A);  
//    cout << sum << endl;
  }
	cout << sum << endl; 
}



Measured memory_bytes: 256
'use strict';

const receive = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .split(/\s/);

const main = input => {
  const N = input[0];
  const A = Number(input[1]);

  const rest = N % 500;
  const ans = A >= rest ? "Yes" : "No";

  console.log(ans);
};

main(receive);

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

int main()
{
    int N, K, Max, Min, Dif;
    cin >> N >> K;
    Max = (N/K) + (N%K);
    Min = (N/K);
    Dif = Max - Min;
    cout << Dif << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>

class Point{
public:
	int x, y;
	Point(int ax = 0, int ay = 0):x(ax),y(ay){};
};

int sub_area(const Point &p1, const Point &p2){
	return (p1.x - p2.x) * (p1.y + p2.y);
}
int main(){
	int n;
	std::cin >> n;
	int x, y;
	std::cin >> x >> y;
	Point start(x, y);
	Point prev = start;
	int area{0};
	for (auto i = 1; i < n; ++i){
		std::cin >> x >> y;
		Point now(x, y);
		area += sub_area(prev, now);
		prev = now;
	}
	area += sub_area(prev, start);
	std::cout << std::fixed << std::setprecision(1) <<area / 2.0 << std::endl;
}

Measured memory_bytes: 1236
s=str(input())
s=list(s)
temp=[]
cnt=0
ans=0
for i in range(len(s)):
  if s[i]=="<":
    if i!=0 and s[i-1]==">":
      temp.append(cnt)
      cnt=0
    cnt=cnt+1
  else:
    if i!=0 and s[i-1]=="<":
      temp.append(cnt)
      cnt=0
    cnt=cnt+1
temp.append(cnt)
if s[0]=="<":
  for i in range(0,len(temp)-1,2):
    tempmin=min(temp[i],temp[i+1])-1
    tempmax=max(temp[i],temp[i+1])
    temp[i]=tempmin
    temp[i+1]=tempmax
else:
  for i in range(1,len(temp)-1,2):
    tempmin=min(temp[i],temp[i+1])-1
    tempmax=max(temp[i],temp[i+1])
    temp[i]=tempmin
    temp[i+1]=tempmax
for i in range(len(temp)):
  ans=ans+temp[i]*(temp[i]+1)//2
print(ans)

Measured memory_bytes: 10160
s = input()
s_list = list(s)
s_length = len(s)
for i in range(0,s_length-1):
    if s_list[i] == s_list[i+1]:
        print(str(i+1)+" "+str(i+2))
        exit()
for i in range(0,s_length-2):
    if s_list[i] == s_list[i+2]:
        print(str(i+1)+" "+str(i+3))
        exit()

print(str(-1)+" "+str(-1))

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

using namespace std;

const int MAXN = 2e5 + 7;
const int INF = 1e9 + 7;
const int LG = 20;

int a[MAXN];
vector <int> last[LG];

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> a[i];

    for (int i = 0; i < LG; ++i) {
        last[i].push_back(n);
        last[i].push_back(n);
    }

    long long ans = 0;
    for (int i = n - 1; i >= 0; --i) {
        for (int j = 0; j < LG; ++j) {
            if ((a[i] >> j) & 1) last[j].push_back(i);
        }

        int mn = INF;
        for (int j = 0; j < LG; ++j) mn = min(mn, last[j][last[j].size() - 2]);

        ans += (mn - i);
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 9440
//2017-4-15 20:04
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int MaxN = 1e5 + 5;
int a[MaxN], b[MaxN];
int n;
int main(){
	while(~scanf("%d", &n)){
		for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
		int num1, num2, cnt;
		num1 = num2 = cnt = 0;
		for(int i = 2; i <= n; i++){
			if(a[i] - a[i - 1] > 0){
				if(num2){
					cnt++;
					num2 = 0;
				}
				else num1++;
			}
			else if(a[i] - a[i - 1] < 0){
				if(num1){
					cnt++;
					num1 = 0;
				}
				else num2++;
			}
		}
		printf("%d\n", cnt + 1);
	}
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstring>
#include <cmath>
#include <memory>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <list>
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;
int main(){
	int n;
	cin>>n;
	cout<<n*n*n<<endl;
}

Measured memory_bytes: 256
n=int(input())
l=[]
for i in range(n):
    a,b=map(int,input().split())
    l.append((a+b,a,b))
l.sort(reverse=True)
t,a=0,0
for i in range(0,n,2):
    t+=l[i][1]
for i in range(1,n,2):
    a+=l[i][2]
print(t-a)

Measured memory_bytes: 90524
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<tuple>
#include<bitset>
using namespace std;
typedef long long int ll;
ll oddsolve(ll a) { return (a + 1) / 2 % 2; }
ll solve(ll a) {
    if (a % 2 == 1)return oddsolve(a);
    else return oddsolve(a + 1) ^ (a + 1);
}
int main() {
    ll A, B; cin >> A >> B;
    cout << (solve(B) ^ solve(A - 1)) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<string>
#include<stack>
#include<cstdio>
#include<algorithm>

using namespace std;

int main(void)
{
  int a[5];

  cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];

  sort(a,a+5);

  printf("%d %d %d %d %d\n", a[4],a[3],a[2],a[1],a[0]);

}

Measured memory_bytes: 1160
# -*- coding: utf-8 -*-
n = int(input())
s = list(input())

sum_w = [0]*(n+1)
sum_b = [0]*(n+1)

for i in range(n):
    if s[i] == '#':
        sum_b[i+1] = sum_b[i] + 1
    else:
        sum_b[i+1] = sum_b[i]

    if s[i] == '.':
        sum_w[i+1] = sum_w[i] + 1
    else:
        sum_w[i+1] = sum_w[i]

ans = n
for i in range(n+1):

    # 0番目からi番目までの黒の数
    black = sum_b[i]
    #  i+1番目からn番目(最後)までの白の数
    white = sum_w[n]-sum_w[i]

    ans = min(ans, black + white)
print(ans)

Measured memory_bytes: 14148
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b){
    return *(int *)a - *(int *)b;
}
int main(void){
    int N = 0; int K = 0;
    scanf("%ld %ld", &N, &K);
    int A[200000];
    int exist[200000];
    for(int i = 0; i < N; i++){
        scanf("%ld", &A[i]);
    }
    if(N <= K){
        printf("0\n");
    }else {
        qsort(A, N, sizeof(int), compare_int);
        for(int k = 0; k < N; k++){
            exist[k] = 1;
        }
        int k = 0;
        for(int j = 0; j < N; j++){
            if(A[j] == A[j+1]){
                exist[k]++;
            }else {
                k++;
            }
        }
        qsort(exist, k, sizeof(int), compare_int);

        int sum = 0;
        for(int l = 0; l < k - K; l++){
            sum += exist[l];
        }
        printf("%d\n", sum);
    }
    return 0;
}

Measured memory_bytes: 2156
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;



int main(){
    ll n,k;
    cin>>n>>k;
    D ans=0;
    for(ll i=1;i<=n;i++){
        D cnt=1;
        ll I=i;
        while(I<k){I*=2; cnt/=2;}
        ans+=cnt/n;
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

void fc(const set<ll> &s, const set<ll> &t, ll x){
  auto sr = s.lower_bound(x);
  auto sl = sr;
  sl--;
  auto tr = t.lower_bound(x);
  auto tl = tr;
  tl--;

  ll ans;
  ll a1 = abs(*sr - *tr) + min(abs(x-*sr), abs(x-*tr));
  ll a2 = abs(*sl - *tr) + min(abs(x-*sl), abs(x-*tr));
  ll a3 = abs(*sr - *tl) + min(abs(x-*sr), abs(x-*tl));
  ll a4 = abs(*sl - *tl) + min(abs(x-*sl), abs(x-*tl));
  ans = min({a1, a2, a3, a4});
  cout << ans << endl;
}

int main(){
  int a, b, q;
  cin >> a >> b >> q;
  set<ll> s, t;
  rep(i, a){
    ll in;
    cin >> in;
    s.insert(in);
  }
  rep(i, b){
    ll in;
    cin >> in;
    t.insert(in);
  }
  s.insert(1e15); s.insert(-1e15);
  t.insert(1e15); t.insert(-1e15);
  vector<ll> xx(q);
  rep(i, q) cin >> xx.at(i);
  for(ll x : xx){
    fc(s, t, x);
  }
  return 0;
}

Measured memory_bytes: 13552
// Problem : D - Sum of Divisors
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#pragma GCC optimize(2)

using namespace std;

typedef long long LL;

inline int gi()
{
    int f = 1, x = 0; char c = getchar();
    while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return f * x;
}

const int INF = 0x3f3f3f3f, N = 10000003, M = N << 1;

int n, m;
int ton[N];

int main()
{
    //File("");
    n = gi();
    if (n == 1) {cout << 1 << endl; return 0;}
    for (int i = 2; i <= n; i+=1)
    	for (int j = i; j <= n; j+=i)
    		++ton[j];
    for (int i = 1; i <= n; i+=1) ++ton[i];
    LL ans = 0;
    for (int i = 1; i <= n; i+=1) 
    	ans = ans + (LL)i * ton[i];
    printf("%lld\n", ans);
    return 0;
}

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

#define ll long long
#define vi vector<int>
#define vl vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
// pll pp; -> (pp.first,pp.second)
// vector<vl> pp(n,vl(2)); sort(pp.begin(),pp.end(),[](vl a,vl b){return a[0]<b[0];});

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define RREP(i,n) for(ll (i)=(n)-1;(i)>=0;(i)--)
#define FOR(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define FORR(i,a,b) for(ll (i)=(b)-1;(i)>=(a);(i)--)
#define DEBUG(x) cout << #x << ": " << x << endl
#define CHMAX(a,b) a=max((a),(b))
#define CHMIN(a,b) a=min((a),(b))
/*}}}*/
int main() {
  ll n;
  cin >> n;
  vector<bool> det(n,false);
  vl ans(n);
  ll visited = 0;
  vector<vl> edge(n,vl(0));
  REP(i,n-1){
    ll u,v,w;
    cin >> u >> v >> w;
    u--;
    v--;
    edge[u].push_back(v);
    edge[u].push_back(w);
    edge[v].push_back(u);
    edge[v].push_back(w);
  }
  //REP(i,n){
  //  REP(j,edge[i].size()/2){
  //    cout << i << "-" << edge[i][2*j] << ": " << edge[i][2*j+1] << endl;
  //  }
  //}

  ans[0] = 0;
  det[0] = true;
  visited = 1;

  queue<ll> que;
  que.push(0ll);
  while(visited<n){
    ll node = que.front();
    REP(i,edge[node].size()/2){
      ll nx = edge[node][2*i];
      ll dis = edge[node][2*i+1];
      if(det[nx]) continue;
      ans[nx] = (ans[node]+dis)%2;
      visited++;
      det[nx] = true;
      que.push(nx);
    }
    que.pop();
  }
  REP(i,n) cout<< ans[i] << endl;
  return 0;
}


Measured memory_bytes: 8704
s = int(input())
f = [s]
i = 0
while True:
    next = f[i] // 2
    if f[i] % 2 > 0:
        next = f[i] * 3 + 1
    i += 1
    if next in f:
        print(i + 1)
        break
    f.append(next)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef struct{
    int A;
    int B;
}MAGIC;
#define INF 1E9;
int main(){
    int H,N;
    cin >> H >> N;
    MAGIC magic[N];
    for(int i=0; i<N; i++){
        cin >> magic[i].A >> magic[i].B;
    }
    int dp[H+1][N+1];
    for(int i=0; i<=N; i++){
        dp[0][i]=0;
    }
    for(int i=1; i<=H; i++){
        dp[i][0]=INF;
        for(int j=1; j<=N; j++){
            if(magic[j-1].A>=i){
                if(dp[i][j-1]>magic[j-1].B){
                    dp[i][j]=magic[j-1].B;
                }else{
                    dp[i][j]=dp[i][j-1];
                }
            }else{
                dp[i][j]=min(dp[i][j-1],dp[i-magic[j-1].A][j]+magic[j-1].B);
            }
        }
    }
    cout << dp[H][N];
    return 0;
}


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

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

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

  vector<int> A1(N), A2(N);
  REP(i, N) {
    cin >> A1[i];
  }
  REP(i, N) {
    cin >> A2[i];
  }

  int max = 0;
  REP(i, N) {
    int val = 0;
    REP(j, N) {
      if (j < i) {
        val += A1[j];
      } else if (j == i) {
        val += A1[j] + A2[j];
      } else {
        val += A2[j];
      }
    }
    if (max < val) max = val;
  }
  cout << max << endl;

  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <functional>
#include <utility>
#define INF 9999999
using namespace std;
typedef long long int ll;

int main() {
	int N;
	cin >> N;
	vector<int> list;
	for(int i = 1; ; i++) {
		if (pow(9, i)>100000)break;
		list.push_back(pow(9, i));
	}
	for (int i = 1; ; i++) {
		if (pow(6, i)>100000)break;
		list.push_back(pow(6, i));
	}
	list.push_back(1);

	sort(list.begin(), list.end(), greater<int>());

	vector<int> dp(N+1,INF);

	dp[0] = 1;
	for (int i = 1; i < N + 1; i++) {
		vector<int> list2;
		for (int j = 0; j < list.size(); j++) {
			int n = i;
			if (list[j] == n) {
				list2.push_back(0);
				continue;
			}
			else if (list[j] > n)continue;
			n -= list[j];
			list2.push_back(dp[n]);
		}

		dp[i] = *min_element(list2.begin(), list2.end()) + 1;
	}
	
	cout << dp[N] << endl;
	return 0;
}


Measured memory_bytes: 640
import numpy as np

N, W = map(int, input().split())
pairs = list(tuple(map(int, input().split())) for _ in range(N))
v_sum = sum(v for _, v in pairs)

dp = np.full((N+1, v_sum+1), W * 2, dtype = np.int64)
dp[0][0] = 0

for (i, (w, v)) in enumerate(pairs):
    dp[i+1] = dp[i]
    dp[i+1, v:] = np.minimum(dp[i+1, v:], dp[i, :v_sum-v+1] + w)

print(max(np.where(dp[N] <= W)[0]))

Measured memory_bytes: 92920
#include <stdio.h>

struct point {
    double x, y;
};

double absolute(double x)
{
    if (x >= 0)
        return x;
    else
        return -x;
}

double area(struct point a, struct point b, struct point c)
{
    return absolute((b.x-a.x)*(c.y-a.y) - (c.x-a.x)*(b.y-a.y)) / 2.0;
}

int main(void)
{
    struct point a, b, c, p;
    
    while (scanf("%lf %lf %lf %lf %lf %lf %lf %lf",
                &a.x, &a.y, &b.x, &b.y, &c.x, &c.y, &p.x, &p.y) != EOF)
        if (area(a, b, c) == area(p, a, b) + area(p, b, c) + area(p, c, a))
            printf("YES\n");
        else
            printf("NO\n");

    return 0;
}

Measured memory_bytes: 612
N = int(input())

dic = {}
arr = []
for x in list(map(int,input().split())):
    arr.append(x)
sort_arr = sorted(arr)
mid1 = sort_arr[N//2-1]
mid2 = sort_arr[N//2]

for x in arr:
    if x <= mid1:
        print(mid2)
    else:
        print(mid1)

Measured memory_bytes: 25620
def gcd(a, b):
  a, b = [max(a,b), min(a,b)]
  if b == 0:
      return a
  else:
      return gcd(b, a % b)

n = int(input())
a = list(map(int, input().split()))

left = [0]*(n+1)
for i in range(n):
    left[i+1] = gcd(left[i], a[i])
right = [0]*(n+1)

for i in range(n-1, -1, -1):
    right[i] = gcd(right[i+1], a[i])

ans = 0
for i in range(n):
    ans = max(gcd(left[i], right[i+1]), ans)

print(ans)

Measured memory_bytes: 14052
while true
  h,w = gets.chomp.split(" ").map &:to_i
  break if w == 0 and h == 0

  f = ""
  b = ""
  w.times { |i|
   f << "#"
   if i == 0 or i == w-1
     b << "#"
   else
     b << "."
   end
  }

  h.times { |i|
    if i == 0 or i == h-1
      puts f
    else
      puts b
    end
  }

  puts
end

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

class IsItARightTriangle
{
    static void Main()
    {
        var q =
            from _ in Enumerable.Range( 0, int.Parse( Console.ReadLine() ) )
            let segments =
                from seg in Console.ReadLine().Split( ' ' )
                select int.Parse( seg ) into segInt
                orderby segInt
                select segInt
            let a = segments.First()
            let b = segments.Skip( 1 ).First()
            let c = segments.Skip( 2 ).First()
            select a * a + b * b == c * c
                ? "YES"
                : "NO";
        foreach ( var isRightTriangle in q )
            Console.WriteLine( isRightTriangle );
    }
}

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

int main() {
  vector<int>s(32,1);
  s.at(3)=2;
  s.at(5)=2;
  s.at(7)=5;
  s.at(8)=2;
  s.at(9)=2;
  s.at(11)=5;
  s.at(13)=2;
  s.at(15)=14;
  s.at(17)=5;
  s.at(19)=5;
  s.at(20)=2;
  s.at(21)=2;
  s.at(23)=15;
  s.at(24)=2;
  s.at(25)=2;
  s.at(26)=5;
  s.at(27)=4;
  s.at(29)=4;
  s.at(31)=51;
  
  int i;
  cin>>i;
  cout<<s.at(i-1)<<endl;
}


Measured memory_bytes: 256
#include <vector> // vectorを使うためにインクルードする
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
	string s;
	cin >> s;
	string s1="", s2="";
	for(int i=0; i< s.size(); i++){
		if(i%2==0){
			s1 += "1";
			s2 += "0";
		}else{
			s1 += "0";
			s2 += "1";
		}
	}
	int ans1=0, ans2=0;
	for(int i=0; i<s.size(); i++){
		if(s.substr(i, 1)!=s1.substr(i, 1)) ans1+=1;
		if(s.substr(i, 1)!=s2.substr(i, 1)) ans2+=1;
	}


	cout << min(ans1, ans2) << endl;
}


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

int countBits(int num) {
  int bits = 0;
  for (; num > 0; num = num >> 1) {
    if (num & 1) {
      bits++;
    }
  }
  return bits;
}

int main(void) {
  int N;
  int A[15] = {};
  int x[15][15] = {};
  int y[15][15] = {};

  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    for (int j = 0; j < A[i]; j++) {
      cin >> x[i][j];
      cin >> y[i][j];
    }
  }

  int ans = 0;
  bool ok = false;
  for (int i = 0; i < (int)pow(2, N); i++) {
    int shamt = 0;
    ok = true;
    for (int j = i; j > 0; j = j >> 1) {
      if (j & 1) {
        for (int k = 0; k < A[shamt]; k++) {
          if ((y[shamt][k] && !(i & (int)pow(2, x[shamt][k] - 1))) ||
              (!y[shamt][k] && (i & (int)pow(2, x[shamt][k] - 1)))) {
            ok = false;
          }
        }
      }
      shamt++;
    }
    if (ok) {
      ans = max(ans, countBits(i));
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <iostream>
#include <string.h>
#include <cstdlib>

using namespace std;

#define BUF_SIZE 1024

struct Node{
    int data;
    Node* prev;
    Node* next;
};

class ConnectedList{
public:
    ConnectedList(){
        motherNode = new Node();
        motherNode->data = -1;
        motherNode->prev = motherNode;
        motherNode->next = motherNode;
    };
    ~ConnectedList(){
        Node* tmpNode = motherNode->next;
        Node* nextNode;
        while(tmpNode != motherNode){
            nextNode = tmpNode->next;
            delete tmpNode;
            tmpNode = nextNode;
        }
        delete motherNode;
    };
    void insertNode(int x){
        Node* tmpNode = motherNode->next;
        motherNode->next = new Node();
        motherNode->next->data = x;
        motherNode->next->next = tmpNode;
        motherNode->next->prev = motherNode;
        tmpNode->prev = motherNode->next;
    };
    void deleteNode(int x){
        Node* tmpNode = motherNode->next;
        while(tmpNode != motherNode && tmpNode->data != x){
            tmpNode = tmpNode->next;
        }
        if(tmpNode != motherNode){
            tmpNode->prev->next = tmpNode->next;
            tmpNode->next->prev = tmpNode->prev;
            delete tmpNode;
        }
    };

    void deleteFirst(){
        Node* tmpNode = motherNode->next;
        motherNode->next = motherNode->next->next;
        motherNode->next->prev = motherNode;
        delete tmpNode;
    };

    void deleteLast(){
        Node* tmpNode = motherNode->prev;
        motherNode->prev = motherNode->prev->prev;
        motherNode->prev->next = motherNode;
        delete tmpNode;
    };

    void showList(){
        Node* tmpNode = motherNode->next;
        printf("%d",tmpNode->data);
        tmpNode = tmpNode->next;
        while(tmpNode != motherNode){
            printf(" %d",tmpNode->data);
            tmpNode = tmpNode->next;
        }
        printf("\n");
    }

private:
    Node* motherNode;
};


int main(){

    char buf[BUF_SIZE];
    int n = atoi(fgets(buf,BUF_SIZE,stdin));

    ConnectedList list;

    for(int i = 0; i < n; i++){

        buf[0] = '\0';
        fgets(buf,BUF_SIZE,stdin);

        if(buf[6] == 'F'){
            list.deleteFirst();
        }else if(buf[6] == 'L'){
            list.deleteLast();
        }else{
            int S = 0;

            if(buf[0] == 'i'){

                for(int i = 0; buf[i] != '\0';i++){
                    if(buf[i] >= '0' && buf[i] <= '9'){
                        S = 10*S + (buf[i] - '0');
                    }
                }
                list.insertNode(S);
            }else{
                for(int i = 0;buf[i] != '\0';i++){
                    if(buf[i] >= '0' && buf[i] <= '9'){
                        S = 10*S + (buf[i] - '0');
                    }
                }
                list.deleteNode(S);
            }
        }
    }
    list.showList();
}

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

using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;


#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define PSET(x,y) fixed<<setprecision(y)<<x
#define pb push_back
#define pf push_front
#define pii pair<int,int>
#define mp make_pair
#define vi vector<int>
#define vip vector<pair<int,int> >
#define ff first
#define ss second
#define int long long
#define SIZE 200010
#define mod 1000000007
#define BIG 998244353
#define s(t) scanf("%d",&t)
#define p(t) printf("%d\n",t)
#define mii map<int,int>
#define MSET(table,i) memset(table, i, sizeof(table))
#define endl '\n'
#define tc int t;cin>>t;while(t--)
#define pi  3.1415926358
#define print(x) for(auto el: x) cout<<el<<" ";cout<<endl
#define bits(x) __builtin_popcount(x)
#define minimum(a,n) min_element(a,a+n)-a
#define maximum(a,n) max_element(a,a+n)-a
#define pqbig priority_queue<int>
#define pqsmall priority_queue<int,vector<int>,greater<int> >
#define all(v) v.begin(),v.end()
#define sitr set<int>:: iterator
#define mitr map<int,int>:: iterator


#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


int32_t main()
{
    fast;
    int n;cin>>n;
    cout<<3*n*n;
}

Measured memory_bytes: 256
macro_rules! scan_sub {
    ( $itr:ident, $t:ty ) => {
        let mut buf = String::new();
        let $itr = {
            while buf.trim().len() == 0 {
                buf = String::new();
                std::io::stdin().read_line(&mut buf).unwrap();
            }
            buf.split_whitespace().map(|n| n.parse::<$t>().unwrap())
        };
    };
}

macro_rules! scan {
    ( $x:ident; Vec<$t:ty> ) => {
        scan_sub!(itr, $t);
        let $x = itr.collect::<Vec<_>>();
    };
    ( $( $x:ident ),*; $t:ty ) => {
        scan_sub!(itr, $t);
        let mut itr = itr;
        $(
            let $x = itr.next().unwrap();
        )*
    };
}

fn gcd(x: usize, y: usize) -> usize {
    let (a, b) = if x < y { (y, x) } else { (x, y) };
    let mut a = a;
    let mut b = b;
    while b > 0 {
        let (t, u) = (b, a % b);
        a = t;
        b = u;
    }

    return a;
}

fn main() {
    scan!(n, k; usize);

    if n % k == 0 {
        println!("0");
        return;
    }

    println!("{}", if n > k {
        let g = gcd(n, k);
        if g != 1 {
            let t = n % k;
            if t < k - t { t } else { k - t }
        } else {
            let t = n % k;
            if t < k - t { t } else { k - t }
        }
    } else {
        if n < k - n { n } else { k - n }
    });
}


Measured memory_bytes: 4352
def lcm(x, y):
    import fractions
    return (x * y) // fractions.gcd(x, y)
n = int(input())
dat_a = list(map(int, input().split()))
res = dat_a[0]
for i in range(n):
    res = lcm(res, dat_a[i])
res -= 1
total = 0
for i in range(n):
    total += res % dat_a[i]
print(total)


Measured memory_bytes: 66920
import java.util.*;

public class Main {
  public static void main(final String[] args) {
    final Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    sc.close();

    long ans = (long) (K * (Math.pow(K - 1, N - 1)));

    System.out.println(ans);
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const int mod=1e9+7;
const ll oo=3e18L+5;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int k;
	cin>>k;
	int x=7%k;
	for(int i=1;i<=k;++i){
		if(x==0){
			return cout<<i,0;
		}
		x=(x*10+7)%k;
	}
	cout<<-1;
	return 0;
}


Measured memory_bytes: 3624
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	h, _ := strconv.Atoi(readLine())
	w, _ := strconv.Atoi(readLine())
	n, _ := strconv.Atoi(readLine())
	i := hoge(h,w,n)
	fmt.Println(i)
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func hoge(h int, w int, n int) int {
	var r int
	if (h > w){
		r = n / h
		if (n % h != 0) {
			r++
		}
		return r
	}
	r = n / w
	if (n % w != 0) {
		r++
	}
	return r
}

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

int main(){
    int a,b;
    cin >> a >> b;
    string s;
    cin >> s;
    bool ans = true;
    if (s[a] != '-'){
        ans = false;
    }
    for (int i = 0;i < a + b + 1;i++){
        if (i == a){
            continue;
        }
        else if (!(s[i] >= '0' && s[i] <= '9')){
            ans = false;
        }
    }
    if (ans){
        cout << "Yes" << endl;
    }
    else{
        cout << "No"  << endl;
   }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
S = input()

if S[K-1] == 'A':
    S = S[:K-1] + 'a' + S[K:]
elif S[K - 1] == 'B':
        S = S[:K - 1] + 'b' + S[K:]
elif S[K-1] == 'C':
    S = S[:K-1] + 'c' + S[K:]
print(S)

Measured memory_bytes: 9160