akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,m;
  cin >> n >> m;
  int32 sum = 0;
  vector<int32> a(n);
  REP(i,n){
    cin >> a[i];
    sum += a[i];
  }
  int32 cnt = 0;
  REP(i,n){
    if(a[i] * 4 * m >= sum)cnt++;
  }
  Yes(cnt >= m);
  return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m;
vector<int> g[100000];
int val[100000];
int used[100000];

void dfs(int v, int par) {
    used[v] = 1;
    for (int to : g[v]) {
        if (to == par) {
            continue;
        }
        if (!used[to]) {
            dfs(to, v);
            if (val[to] == 1) {
                val[to] ^= 1;
                printf("%d %d\n", to + 1, v + 1);
            } else {
                val[v] ^= 1;
                printf("%d %d\n", v + 1, to + 1);
            }
        } else if (used[to] == 1) {
            printf("%d %d\n", v + 1, to + 1);
            val[v] ^= 1;
        }
    }
    used[v] = 2;
}

int main() {
//    freopen("input.txt", "r", stdin);
    scanf("%d%d", &n, &m);
    forn(i, m) {
        int from, to;
        scanf("%d%d", &from, &to), --from, --to;
        g[from].pb(to);
        g[to].pb(from);
    }
    if (m % 2 == 1) {
        puts("-1");
        return 0;
    }
    dfs(0, -1);
    return 0;
}


Measured memory_bytes: 15488
#include<bits/stdc++.h>
#define forp(x,a,b) for(int x=a; x<b; x++)
#define forn(x,a,b) for(int x=a; x>b; x--)
#define SZ(a) ((int)(a).size())
#define pb push_back
#define vec(x) vector<x>
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pair<int,int>>
#define umpii unordered_map<int,int>
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a, b, sizeof a)
#define setBits(n) __builtin_popcountll(n)
#define prec(n) fixed<<setprecision(n)
#define ff first
#define ss second
#define print(x) for(auto it:x) cout<<it<<" ";
#define w(x) while(x--)
using namespace std;
typedef long long ll;


int n;
ll a[100];
 vi ga;
void solve(){int ans=0;
    forp(i,0,n){cin>>a[i];}
    forp(i,0,n){
        forp(j,i+1,n){
            forp(k,j+1,n){
                if(a[i]!=a[j]&&a[i]!=a[k]&&a[k]!=a[j]&&2*max(a[i],max(a[j],a[k]))<a[i]+a[j]+a[k]){ans++;}}}
    }
    cout<<ans;
    
    
}

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

Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define pb push_back
#define li long long int
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i = 0; i< n ; i++){
    cin>>a[i];
  }
 sort(a.begin() , a.end());
 if(n%2 != 0)
    cout<<0<<endl;
 else 
    cout<<a[n/2] - a[n/2 - 1]<<endl;
    

 }


Measured memory_bytes: 640
/* {{{ */
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
/* }}} */

fn main() {
    input! {
        n: u8,
        s: chars
    }
    let t = s.iter().map(|c| {
        let c = *c as u8;
        let c = (c - b'A' + n) % (b'Z' - b'A' + 1) + b'A';
        c as char
    });
    println!("{}", t.collect::<String>());
}
/* vim:set foldmethod=marker: */


Measured memory_bytes: 4352
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;
typedef pair<LL,LL> PLL;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000
#define MAXN 100010

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

LL q, h, s, d, n;
vector<LL> costs;
vector<int> vol = {8, 4, 2, 1};
vector<LL> mincosts;

LL cost(LL k) {
  LL ans = 0;
  LL q, r;
  int idx;
  if (k >= 2) {
    idx = mincosts[3];
  } else {
    idx = mincosts[2];
  }

  q = vol[idx];
  if ((k&1) && idx==3) {
//    printf("  ");
    ans += cost(1);
    ans += costs[idx] * (k-1) / 2;
  } else {
    ans += costs[idx] * k / 2;
  }
//  printf("mincost: %lld, ans: %lld\n", costs[idx], ans);
  return ans;
}

int main() {
  GLL(q); GLL(h); GLL(s); GLL(d); GLL(n);

//  n *= 2;

  costs.PB(8LL*q);
  costs.PB(4LL*h);
  costs.PB(2LL*s);
  costs.PB(d);
  mincosts.resize(4);
  mincosts[0] = 0;

  FOR1(i, 3) {
    if (costs[i] < costs[mincosts[i-1]]) {
      mincosts[i] = i;
    } else {
      mincosts[i] = mincosts[i-1];
    }
  }

//  for (auto m : costs) { printf("%5lld ", m); } printf("\n"); 
//  for (auto m : mincosts) { printf("%5lld ", m); } printf("\n"); 

  printf("%lld\n", cost(n));

  return 0;
}

Measured memory_bytes: 256
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

q = int(input())
list_Q = [ list(map(int,input().split(" "))) for i in range(q)]

num = pow(10, 5)
list_PRE = [0]*(2*num+10)
list_PRE[2] = 1
for i in range(1, 2*num+10, 2):
    if len(prime_factorize(i)) == 1:
        list_PRE[i] = 1

list_2017 = [0]*(2*num+10)
for i in range(1, num+1, 2):
    if list_PRE[i] == 1 and list_PRE[(i+1)//2] == 1:
        list_2017[i] = 1

list_ANS = []
cnt = 0
for i in list_2017:
    if i == 1:
        cnt += 1
        list_ANS.append(cnt)
    else:
        list_ANS.append(cnt)

for i, j in list_Q:
    print(list_ANS[j]-list_ANS[i-1])

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

template<class T> inline bool chmax(T &a, T b)
{
    if(a < b)
    {
        a = b;
        return true;
    }
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s, t;
    cin >> s >> t;

    vector<vector<int>> dp(s.size()+1, vector<int>(t.size()+1, 0));
    dp.at(0).at(0) = 0;
    for(int i=0; i<=s.size(); i++)
    {
        for(int j=0; j<=t.size(); j++)
        {
            if(i-1>=0 && j-1>=0 && s.at(i-1) == t.at(j-1)) chmax(dp.at(i).at(j), dp.at(i-1).at(j-1) + 1);
            if(i-1>=0) chmax(dp.at(i).at(j), dp.at(i-1).at(j));
            if(j-1>=0) chmax(dp.at(i).at(j), dp.at(i).at(j-1));
        }
    }
    // for(auto &v : dp)
    // {
    //     for(auto num : v) cout << setw(4) << num;
    //     cout << '\n';
    // }
    int i= s.size();
    int j= t.size();
    string res = "";
    while(i > 0 && j > 0)
    {
        if(dp.at(i).at(j) == dp.at(i-1).at(j)) i--;
        else if(dp.at(i).at(j) == dp.at(i).at(j-1)) j--;
        else
        {
            res = s.at(i-1) + res;
            i--;
            j--;
        }
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 35584
#include<iostream>
using namespace std;
#include<vector>
#include<functional>
template<typename T>
struct lazysegtree{
	function<T(T,T)>calcfn,lazycalcfn;
	function<T(T,T,unsigned int)>updatefn;
	int n;
	T defvalue,lazydefvalue;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	lazysegtree(int n_=0,T defvalue_=0,
		function<T(T,T)>calcfn_=[](T a,T b){return a+b;},
		function<T(T,T)>lazycalcfn_=[](T a,T b){return a+b;},
		function<T(T,T,unsigned int)>updatefn_=[](T a,T b,unsigned int width){return a+b*width;},
		T lazydefvalue_=0
	):defvalue(defvalue_),lazydefvalue(lazydefvalue_),
		calcfn(calcfn_),lazycalcfn(lazycalcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(2*n-1,defvalue);
		lazy.assign(2*n-1,lazydefvalue);
		lazyflag.assign(2*n-1,false);
	}
	void copy(vector<T>v)
	{
		for(int i=0;i<v.size();i++)dat[i+n-1]=v[i];
		for(int i=n-2;i>=0;i--)dat[i]=calcfn(dat[2*i+1],dat[2*i+2]);
	}
	void eval(int i,int l,int r)
	{
		if(lazyflag[i])
		{
			dat[i]=updatefn(dat[i],lazy[i],r-l);
			if(r-l>1)
			{
				lazy[2*i+1]=lazycalcfn(lazy[2*i+1],lazy[i]);
				lazy[2*i+2]=lazycalcfn(lazy[2*i+2],lazy[i]);
				lazyflag[2*i+1]=lazyflag[2*i+2]=true;
			}
			lazy[i]=lazydefvalue;
			lazyflag[i]=false;
		}
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			lazy[k]=lazycalcfn(lazy[k],x);
			lazyflag[k]=true;
			eval(k,l,r);
		}
		else
		{
			update(a,b,x,2*k+1,l,(l+r)/2);
			update(a,b,x,2*k+2,(l+r)/2,r);
			dat[k]=calcfn(dat[2*k+1],dat[2*k+2]);
		}
	}
	T query(int a,int b,int k=0,int l=0,int r=-1)
	{
		if(r<0)r=n;
		eval(k,l,r);
		if(b<=l||r<=a)return defvalue;
		else if(a<=l&&r<=b)return dat[k];
		else return calcfn(
			query(a,b,2*k+1,l,(l+r)/2),
			query(a,b,2*k+2,(l+r)/2,r)
		);
	}
};
int n,q;
main()
{
	cin>>n>>q;
	lazysegtree<int>P(n,0,[](int a,int b){return a+b;},[](int a,int b){return a+b;},[](int a,int b,unsigned int width){return a+b;});
	for(int i=0;i<q;i++)
	{
		int c;cin>>c;
		if(c)
		{
			int j;cin>>j;
			cout<<P.query(j-1,j)<<endl;
		}
		else
		{
			int s,t,x;cin>>s>>t>>x;
			P.update(s-1,t,x);
		}
	}
}


Measured memory_bytes: 4964
n, m=map(int, input().split())
a = [-1]*n
ans = 0
for i in range(m):
  s, c = map(int, input().split())
  if a[s-1]!=c and a[s-1]!=-1:
    ans = -1
    break
  elif n>1 and s==1 and c==0:
    ans = -1
    break
  else:
    a[s-1]=c
if m==0:
  ans=0
if ans == 0:
  if a[0]==-1:
    if n>1:
      a[0]=1
    else:
      a[0]=0
  for i in range(n):
    if a[n-1-i] != -1:
      ans += a[n-1-i]*10**i
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
const long long mod = 1e9+7;
const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};
const int ddx[4] = {1,1,-1, -1};
const int ddy[4] = {1,-1,-1,1};
//////////////////////////////////

int main(){
  double l; cin >> l;
  printf("%.10lf\n", l/3 * l/3 * l/3);
  
  return 0;
}

// EOF


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main() {
  lli A,B=1,C=0,D=0,F=0;
  cin >> A >> B >> C;
  if(A%C==0)A/=C;
  else{
    A+=C-A%C;
    A/=C;
  }
  if(B%C==0)B/=C;
  else{
    B-=B%C;
    B/=C;
  }
  Out(B-A+1);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x);i<=(y);i++)

using namespace std;

const int N=310,mod=998244353;
int n,m,r,sum,all,vis[N]; bitset<N> b[N];

int insert(bitset<N> x){
	rep (i,0,m-1)
		if (x.test(i))
			if (!vis[i]){vis[i]=1,b[i]=x; return 1;}
			else x^=b[i];
	return 0;
}

int main(){
	scanf("%d%d",&n,&m);
	rep (i,1,n){
		bitset<N> a;
		rep (j,1,m){
			int x; scanf("%d",&x);
			if (x) a.set(j-1);
		}
		r+=insert(a);
	}
	all=1;
	rep (i,1,n) all=(all+all)%mod;
	sum=1;
	rep (i,1,n-r) sum=(sum+sum)%mod;
	all=(all+mod-sum)%mod;
	rep (i,1,m-1) all=(all+all)%mod;
	printf("%d\n",all);
	return 0;
}

Measured memory_bytes: 384
k = int(input())
a,b = map(int, input().split())
s = 0
z = b - a + 1



for i in range(0, z):
  
  if (a + i) % k == 0:
    s = 1
    

    
if s == 1:
  print("OK")
else:
  print("NG")

Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define fi first
#define se second
using namespace std;

// distance between (x1,y1) and (x2,y2)
double cdis(double x1, double y1, double x2, double y2) {
  return sqrtl((x1 - x2) * (x1 - x2) +
               (y1 - y2) * (y1 - y2));
}
// cos a
double costh(double a, double b, double c) {
  return (b * b + c * c - a * a) / (2.0 * b * c);
}
double r, t;
int n;
pair<double, double> c[25];
double dis[25][25] = {0};
// possible? i -> j -> k
bool ch[25][25][25] = {0};
double dp[25][25][10000] = {0};

int solve();

int main() {
  cin >> n >> r >> t;
  for(int i = 0; i < n; ++i) {
    double x, y;
    cin >> x >> y;
    c[i] = make_pair(x, y);
  }
  for(int i = 0; i < n; ++i)
    for(int j = i + 1; j < n; ++j)
      dis[i][j] = dis[j][i] =
          cdis(c[i].fi, c[i].se, c[j].fi, c[j].se);
  for(int i = 0; i < n; ++i)
    for(int j = 0; j < n; ++j)
      for(int k = 0; k < n; ++k) {
        if(i == j || j == k) continue;
        double a = dis[i][k], b = dis[i][j], c = dis[j][k];
        if(180.0 - acos(costh(a, b, c)) * 180 / M_PI <= t)
          ch[i][j][k] = 1;
      }

  cout << solve() << endl;
  return 0;
}

int solve() {
  int ans = 0;
  for(int i = 1; i < n; ++i)
    if(dis[0][i] <= r) {
      dp[0][i][1] = dis[0][i];
      ans = 1;
    }
  if(ans == 0) return ans;
  for(int k = 2; k <= 10000; ++k) {
    // i -> j -> l
    for(int i = 0; i < n; ++i)
      for(int j = 0; j < n; ++j)
        for(int l = 0; l < n; ++l) {
          if(i == j || j == l || (!ch[i][j][l]) ||
             dp[i][j][k - 1] == 0 ||
             dp[i][j][k - 1] + dis[j][l] > r)
            continue;
          if(dp[j][l][k] == 0) {
            ans = k;
            dp[j][l][k] = dp[i][j][k - 1] + dis[j][l];
          }
          else
            dp[j][l][k] = min(dp[j][l][k],
                              dp[i][j][k - 1] + dis[j][l]);
        }
    if(ans != k) break;
  }
  return ans;
}


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

int readInt(){
  int ret = 0;
  char c;
  while((c=getchar()) && '0' <= c && c <= '9'){
    ret = ret * 10 + (c-'0');
  }
  return ret;
}

main(){
  int n,s;
  while(true){
    n = readInt();
    if (n==0)break;
    s = readInt();

    int r[101]={0};
    for(int i=0;i<n;i++){
      int tmp;tmp=readInt();r[tmp]++;
    }
    int ans = 0;
    for(int i=1;i != 101;i++){
      if (i+i > s && r[i])ans += (r[i]*(r[i]-1))/2;
      for(int j=i+1;j != 101;j++){
	if (i+j > s)ans += r[i]*r[j];
      }
    }
    printf("%d\n",ans);
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a,b;
    cin >> a >> b;
    if (a > b) {
        cout << 'a' << ' ' << '>' << ' ' << 'b' << endl;
    }
    else if (a < b) {
        cout << 'a' << ' ' << '<' << ' ' << 'b' << endl;
    }
    else {
        cout << 'a' << ' ' << "==" << ' ' << 'b' << endl;
    }
}


Measured memory_bytes: 3092
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = 1ll << 60;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

#define print(s) cout << s;
#define println(s) cout << s << endl;
#define printd(s, f) cout << fixed << setprecision(f) << s << endl;


int main()
{
	vector<ll> a(3);
	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
	}

	sort(rall(a));

	int k;
	cin >> k;

	for (int i = 0; i < k; i++)
	{
		a[0] *= 2;
	}

	println(accumulate(all(a), 0LL));
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>



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

using namespace std;
int n;
int ans;

int dp[200000][400];
int a[12] = {2,12,72,432,2592,15552,93312,3,27,243,2187,19683};

int main(){
  cin >> n;
  if(n<6){
    cout << n << endl;
    return 0;
  }
  ans += n%3;
  n -= n%3;
  dp[0][0] = 1;
  dp[3][1] = 1;
  REP(i,400){
    REP(j,n/2){
      int f = 0;
      REP(k,12){
        if(j-a[k]>=0&&dp[j-a[k]][i]==1){
          f=1;
          //cout << j << "=j, k=" << k << endl;
        }
      }
      if(f==1){
        dp[j][i+1] = 1;
        //cout << i << "=i, j=" << j << endl;
      }
    }
    if(dp[n/3][i+1]==1){
      //cout << i << " " << n << endl;
      ans += i+1;
      cout << ans << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L
const int mxN = 1e9 + 7;


int main() {
    int n, m;
    cin >> n >> m;
    vector<bool> d(100001);
    for (int i = 0; i < m; i++) {
        int x;
        cin >> x;
        d[x] = true;
    }
    int cnt = 0;
    bool ok = true;
    for (int i = 1; i <= n; i++) {
        if (d[i]) cnt++;
        else cnt = 0;
        if (cnt >= 2) ok = false;
    }
    if (!ok) {
        cout << 0;
        return 0;
    }
    vector<long long> dp(100001);
    if (!d[1]) dp[1] = 1;
    if (!d[2]) {
        if (d[1]) dp[2] = 1;
        else dp[2] = 2;
    }
    for (int i = 3; i <= n; i++) {
        if (!d[i]) dp[i] = dp[i - 1] + dp[i - 2];
        dp[i] %= MOD;
    }
    cout << dp[n] % MOD;
    
    return 0;
}

Measured memory_bytes: 4036
// https://atcoder.jp/contests/agc041/tasks/agc041_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, A, B;
    cin >> N >> A >> B;
    if ((B - A) % 2 == 0) {
        cout << (B - A) / 2 << endl;
    } else {
        cout << min(A - 1, N - B) + 1 + (B - A) / 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 3588
(let* ((n (read))
       (a (make-array n)))
  (dotimes (i n)
    (setf (aref a i) (read)))
  (format t "~A~%"
          (loop for ai across a
                with min = 1000
                with max = 0 do
                (when (< ai min)
                  (setf min ai))
                (when (< max ai)
                  (setf max ai))
                finally (return (- max min)))))

Measured memory_bytes: 17000
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
int main() {
    string S; cin >> S;
    if (S.back() == 's') {
        S += "es";
    } else {
        S += "s";
    }
    cout << S << endl;
    return 0;
}


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

int main(){
    string s;   cin>>s;
    sort(s.begin(),s.end());

    string t;   cin>>t;
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());

    if(s<t)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
let s = stdin.ReadLine().ToCharArray()

let mid = int (ceil (float s.Length / 2.0)) - 1

s.[0..mid] |> Array.zip (s |> Array.rev |> fun x -> x.[0..mid])
|>Array.sumBy (fun (a,b) -> if a<>b then 1 else 0 )
|>stdout.WriteLine

Measured memory_bytes: 13268
#include<iostream>

using namespace std;

int n;

bool flag = false;

int main() {

	cin >> n;

	for (int i = 1; i <= 9;i++) {
		for (int j = 1; j <= 9; j++) {
			if (i*j == n)flag = true;
		}
	}

	if (flag == true)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  int n,m;
  cin >> n >> m;
  vector<pair<int, int>> pairs(n);
  vector<bool> yoi(n,true);
  REP(i,n){
    pairs[i].first = i;
    int c;
    cin >> c;
    pairs[i].second = c;
  }
  
  REP(i,m){
    int a,b;
    cin >> a >> b;
    
    int h1 = pairs[a-1].second;
    int h2 = pairs[b-1].second;
    if(h1 > h2){
      yoi[b-1] = false; 
    }
    else if(h2 > h1){
      yoi[a-1] = false; 
    }
    else{
      yoi[a-1] = false; 
      yoi[b-1] = false; 
    }
  }
  
  int ans = 0;
  REP(i,n){
    if(yoi[i]){
      ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4024
package main
import (
    "bufio"
    "fmt"
    "os"
  "unicode"
)
func main(){
    stdin := bufio.NewScanner(os.Stdin)
    for stdin.Scan() {
    	S := stdin.Text()
		var yes bool = true
      	if S[0] != 'A' {
        	yes = false
      	}
      	if ! unicode.IsLower(rune(S[1])) {
        	yes = false
      	}
      	var largeC = 0
      	for i := 2; i < len(S); i++ {
        	if unicode.IsLower(rune(S[i])) {
            } else if (S[i] == 'C' && i != len(S) - 1) {
           		largeC += 1 
        	} else {
          		yes = false
        	}
      	}
      
      	if largeC != 1 {
        	yes = false
      	}
      	if yes {
        	fmt.Println("AC")
      	} else {
        	fmt.Println("WA")
      	}
    }
}

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

int main(){
        int n,i,a,idx=1,ans=0;
        cin >> n;
        for(i=0;i<n;++i){
                cin >> a;
                if(a==idx){++idx; continue;}
                ++ans;
        }
        if(idx==1) ans = -1;
        cout << ans << endl;
        return 0;
}

Measured memory_bytes: 3604
#include <stdio.h>

void abc139_a(){
char a[3],b[3];
int c=0;
scanf("%s %s",a,b);
for (int i = 0; i < 3; i++) {
  if (a[i]== b[i]) {
    c++;
  }
}
printf("%d\n",c);
}

int main() {
  abc139_a();
  return 0;
}


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

using namespace std;

int main() {
  int N, K;
  string S;
  
  cin >> N >> K >> S;
  
  K--;
  
  if (S[K] == 'A') {
    S[K] = 'a';
  }
  
  if (S[K] == 'B') {
    S[K] = 'b';
  }
  
  if (S[K] == 'C') {
    S[K] = 'c';
  }
  
  cout << S << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int x, y, z;
  scanf("%d%d", &x, &y);
  while(z!=0){
    z = x % y;
    if(z==0){
      printf("%d\n", y);
      break;
    }
    x = y;
    y = z;
  }
  return 0;
}


Measured memory_bytes: 2124
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
var mod = 998244353;

console.log(main());
function main(){
  var s = o.a(1);
  var sl = s.length;
  var r = +s[0], b = 2 - r, l = 0;
  var ans = [0,0];
  if(r)ans[1] = 1;
  if(b)ans[0] = 1, b--;else l = 1;
  for(var i = 1; i < sl; i++){
    r += +s[i], b += 2 - s[i];
    if(b)b--; else l++;
    var a = Array(r+1).fill(0);
    var t = Math.min(i+1, r);
    for(var j = l; j <= t; j++){
      a[j] = ((ans[j-1]|0) + (ans[j]|0)) % mod;
    }
    ans = a;
  }
  r++;
  for(var i = 0; i < sl; i++){
    if(b)b--; else l++;
    var a = Array(r).fill(0);
    for(var j = l; j < r; j++){
      a[j] = ((ans[j-1]|0) + (ans[j]|0)) % mod;
    }
    ans = a;
  }
  return ans[r-1];
}

Measured memory_bytes: 23852
// J'aime
// Chemise Blanche

#include <bits/stdc++.h>
using namespace std;

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int ans = 0;
  for (int i = 1; i <= 5; i++) {
    int t; cin >> t;
    ans += i - t;
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


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


int main(){
    int N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<M; i++) cin >> B[i];
    
    bool subflag=false, flag=false;
    for(int i=0; i<N-M+1; i++){
        for(int j=0; j<N-M+1; j++){
            subflag = true;
            for(int k=0; k<M; k++){
                //cout << i+k <<" "<< j <<" "<< k << endl;
                if(A[i+k].substr(j,M)==B[k])
                    subflag &= true;
                else
                    subflag = false;
                //cout << flag << endl;
            }
            if(subflag) flag=true;
        }
    }
    
    cout << ((flag)?"Yes":"No") << endl;
}


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

using namespace std;

int main(void) {
  int n;
  string s;
  cin >> n >> s;
  int ans = 1;
  for (int i = 0; i < n-1; i++) {
    if (!(s.at(i) == s.at(i+1))) {
      ans++; 
    }
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 512
use std::fs;
use std::io::{stdin, Read};

macro_rules! parse {
    ($it: ident) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: ident,2) => {
        (parse!($it), parse!($it))
    };
    ($it: ident,3) => {
        (parse!($it), parse!($it), parse!($it))
    };
    ($it: ident,4) => {
        (parse!($it), parse!($it), parse!($it), parse!($it))
    };
    ($it: ident, $n: expr) => {
        (&mut $it).take($n).map(|e| e.parse().unwrap()).collect();
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    let s = it.next().unwrap();
    let (x, y): (i64, i64) = parse!(it, 2);
    if let Some(i) = s.find('T') {
        let s = unsafe { s.slice_unchecked(i + 1, s.len()) };
        let x = x - (i as i64);
        let mut flag = false;
        let mut cur = 0;
        let mut ud = vec![];
        let mut lr = vec![];
        for c in s.chars() {
            match c {
                'T' => {
                    if flag {
                        lr.push(cur)
                    } else {
                        ud.push(cur)
                    }
                    flag = !flag;
                    cur = 0;
                }
                'F' => cur += 1,
                _ => (),
            }
        }
        if flag {
            lr.push(cur)
        } else {
            ud.push(cur)
        }
        let mut memo = std::collections::HashMap::new();
        if !check(0, &lr, x, &mut memo) {
            println!("No");
            return;
        }
        let mut memo = std::collections::HashMap::new();
        if !check(0, &ud, y, &mut memo) {
            println!("No");
            return;
        }
        println!("Yes");
        return;
    } else {
        println!(
            "{}",
            if s.len() as i64 == x && y == 0 {
                "Yes"
            } else {
                "No"
            }
        );
    }
}

fn check(
    i: usize,
    v: &Vec<i64>,
    x: i64,
    memo: &mut std::collections::HashMap<(usize, i64), bool>,
) -> bool {
    if let Some(b) = memo.get(&(i, x)) {
        return *b;
    }
    if i == v.len() {
        return x == 0;
    }
    let ret = check(i + 1, v, x - v[i], memo) || check(i + 1, v, x + v[i], memo);
    memo.insert((i, x), ret);
    ret
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 397992
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0, i_len = n; (i) < (i_len); ++(i))
#define repp(i,n) for(int (i) = 1, i_len = n; (i) <= (i_len); ++(i))
#define per(i,n) for(int (i) = n-1; (i) >= 0; --(i))
#define perr(i,n) for(int (i) = n; (i) > 0; --(i))
#define sz(x) ((int)(x).size())
#define popcnt __builtin_popcount
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).begin(),(v).end(),greater<>()
#define Pi 3.1415926535
#define MOD 1000000007;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
using itn = int;
using vint = vector<int>;
template<class T,class S> inline bool chmax(T& a, S b){if(a<b){a = b; return true;} return false;}
template<class T,class S> inline bool chmin(T& a, S b){if(a>b){a = b; return true;} return false;}
template<class T> T gcd(T a, T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a, T b){return a*b/gcd(a,b);}
void yes(){cout << "Yes" << endl;}
void no(){cout << "No" << endl;}

int solve(){
    int s,w; cin >> s >> w;
    if(s>w) cout << "safe" << endl;
    else cout << "unsafe" << endl;

    return 0;
}

int main(){
    cin.tie(0);
    cout << fixed << setprecision(10);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


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

class Program
{
    static void Main(string[] args)
    {
        var n =long.Parse( Console.ReadLine());
        var hash = new HashSet<string>();

        for(var i = 0; i < n; i++)
        {
            hash.Add(Console.ReadLine());
        }

        Console.WriteLine(hash.Count);
    }
}


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

using namespace std;


void solve() {
    int x,y,z;
    cin >> x >> y >> z;
    cout << (x+y+z>=22?"bust":"win");
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <tuple>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<' ';
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    string s; cin>>s;
    vint c(s.size(),0);
    if(s[0]=='A'||s[0]=='T'||s[0]=='G'||s[0]=='C')c[0] = 1;
    int ans = c[0];
    for(int i = 1; i<s.size(); ++i){
        if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')c[i] = c[i-1]+1;
        ans = max(ans, c[i]);
    }
    cout<<ans<<endl; return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
dp = [0]*n
dp[0] = s[1:].count("E")
a = s[0]
for i in range(1,n):
    dp[i] = dp[i-1]
    if s[i] == "E":dp[i] -= 1
    if a == "W":dp[i] += 1
    a = s[i]
print(min(dp))

Measured memory_bytes: 15516
#include<stdio.h>
#include<algorithm>
using namespace std;
char str[30];
int p[30];
int q[30];
int main(){
	int a;
	while(scanf("%d%s",&a,str),a){
		int b=a;
		int sz=0;
		for(int i=0;i<30;i++)q[i]=0;
		for(int i=2;i*i<=b;i++){
			if(b%i==0){
				p[sz++]=i;
				while(b%i==0){
					b/=i;
					q[sz-1]++;
				}
			}
		}
		if(b>1){p[sz++]=b;q[sz-1]=1;}
		long long val=0;
		for(int i=0;str[i];i++){
			val*=a;
			if(str[i]>='A'&&str[i]<='Z')val+=str[i]-'A'+10;
			else val+=str[i]-'0';
		}
		long long ret=(1LL<<62);
		for(int i=0;i<sz;i++){
			long long tmp=0;
			long long now=val;
			while(now){
				tmp+=now/p[i];
				now/=p[i];
			}
			ret=min(ret,tmp/q[i]);
		}
		printf("%lld\n",ret);
	}
}

Measured memory_bytes: 1032
/*
    Problem 63
    https://atcoder.jp/contests/abc074/tasks/arc083_b
*/
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
/* global variables */
int N;
/* function */
void floyd(vector<vector<ll> > F) {
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            bool isFind = false;
            for (int k = 0; k < N; k++) {
                if (i == k || k == j) continue;
                if (F[i][j] > F[i][k] + F[k][j]) {
                    cout << -1 << '\n';
                    return ;
                }
                else if (F[i][j] == (F[i][k] + F[k][j]))
                    isFind = true;
            }
            if (!isFind)
                ans += F[i][j];
        }
    }
    cout << ans << '\n';
}

/* main */
int main(){
    cin >> N;
    vector<vector<ll> > G(N, vector<ll>(N, LINF));
    for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) cin >> G[i][j];
    floyd(G);
}


Measured memory_bytes: 1664
A,B,K=map(int,input().split())
b1=0
b2=0
for i in range(K):
    if i%2==0:
        if A%2==1:
            A=A-1
        A=A//2
        B=B+A
    else:
        if B%2==1:
            B=B-1
        B=B//2
        A=A+B
    #print(A,B)
print(A,B)



Measured memory_bytes: 38256
program AGC039A
    implicit none
    character(100)::S
    integer(8)::K,i,ans,cont,ans_add,cont_first,flg=0
    read*,S,K
    ans=0
    cont=1
    do i=2,len_trim(S)
        if(S(i:i)==S(i-1:i-1))then
            cont=cont+1
        else
            if(flg==0)then
                cont_first=cont
                flg=1
            end if
            ans=ans+cont/2
            cont=1
        end if
    end do

    if(cont==len_trim(S))then
        print'(i0)',K*cont/2
    else
        if(S(1:1)==S(len_trim(S):len_trim(S)))then
            ans=ans-cont_first/2
            ans=ans*K
            ans_add=(cont+cont_first)/2
            ans=ans+(K-1)*ans_add
            ans=ans+cont_first/2+cont/2
        else
            ans=ans+cont/2
            ans=ans*K
        end if
        print'(i0)',ans
    end if
end program AGC039A

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
    	int A1 = scanner.nextInt();
    	int A2 = scanner.nextInt();
    	int A3 = scanner.nextInt();
		int[] list = {A1, A2, A3};
		int cost = 0;
		
		//System.out.println(A1);
		//System.out.println(A2);
		//System.out.println(A3);
		
		int cost1 = list[0]*0 + Math.abs(list[1]-list[0]) + Math.abs(list[2]-list[1]);
		int cost2 = list[1]*0 + Math.abs(list[2]-list[1]) + Math.abs(list[0]-list[2]);
		int cost3 = list[2]*0 + Math.abs(list[0]-list[2]) + Math.abs(list[1]-list[0]);
		
		int[] min = {cost1, cost2, cost3};
		Arrays.sort(min);
		for (int i : min) {
			//System.out.println(i);
			cost = min[0];
		}
		
		/*
		for (int i : list) {
			//System.out.println("min = " + min);
			System.out.println(i);
		}
		*/
		System.out.println(cost);
	}
}

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

using namespace std;

const int mod=998244353;

int dp[305][305*305]={}, dp1[305][305*305]={};

int main(){
	int n,s=0; cin >> n;
	vector <int> a(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
		s+=a[i];
	}
	dp[0][0]=2; dp1[0][0]=1;
	dp[0][a[0]]=1; dp1[0][a[0]]=1;
	for(int i=1;i<n;i++){
		for(int j=0;j<=s;j++){
			dp[i][j]=(1ll*2*dp[i-1][j]+((j>=a[i])?dp[i-1][j-a[i]]:0))%mod;
			dp1[i][j]=(dp1[i-1][j]+((j>=a[i])?dp1[i-1][j-a[i]]:0))%mod;
		}
	}
	int ans=1;
	for(int i=0;i<n;i++){
		ans=(1ll*ans*3)%mod;
	}
	for(int i=(s+1)/2;i<=s;i++){
		ans=(ans+1ll*3*(mod-dp[n-1][i]))%mod;
	}
	if(s%2==0){
		ans=(ans+1ll*3*dp1[n-1][s/2])%mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 221056
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}


signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> l(n*2);
	rep(i,n * 2){
		cin >> l[i];
	}
	sort(all(l),greater<int>());
	int sum = 0;
	for(int i = 0;i < n*2-1;i += 2){
		sum += min(l[i],l[i+1]);
	}
	cout << sum << '\n';
	return 0;	
}


Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]_){Scanner S=new Scanner(System.in);double t,a[]=new double[8];for(int i,b,f;S.hasNext();System.out.println(b>2||f>2?"YES":"NO")){for(i=0;i<8;)a[i++]=S.nextDouble();for(b=f=i=0;i<6;i+=2){t=a[6]*(a[i+1]-a[(i+3)%6])+a[i]*(a[(i+3)%6]-a[7])+a[(i+2)%6]*(a[7]-a[i+1]);if(t<0)b++;if(t>0)f++;}}}}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
#define INF (1LL<<30)
#define DEKAI 1000000007
#define lp(i,n) for(int i=0;i<n;i++)
#define int long long


signed main(){
	int n,k;
	cin>>n>>k;
	if(n==2){
		if(k==0) cout<<1<<endl<<1<<" "<<2<<endl;
		else cout<<-1<<endl;
		return 0;
	}
	vector<pair<int,int>> v;
	lp(i,n){
		if(i==0) continue;
		v.push_back({1,i+1});
	}
	int sum=0;
	lp(i,n-2){
		sum+=i+1;
	}
	for(int i=1;i<n;i++){
		if(sum==k) break;
		for(int j=i+1;j<n;j++){
			v.push_back({i+1,j+1});
			sum--;
			if(sum==k) break;
		}
		if(sum==k) break;
	}
	if(sum!=k) cout<<-1<<endl;
	else{cout<<v.size()<<endl;
	lp(i,v.size()){
		cout<<v[i].first<<" "<<v[i].second<<endl;
	}
}
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int x,y,z; cin >> x >> y >> z;
  x-=z;
  COUT( x/(y+z) );
  return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    n=int(input())
    lst=list(input())
    min_num=ord("A")
    for c in lst:
        cooked_num=ord(c)-min_num+n
        if(cooked_num>=26):
            print(chr(cooked_num-26+min_num),end="")
        else:
            print(chr(cooked_num+min_num),end="")

Measured memory_bytes: 4596
#include <bits/stdc++.h>
using namespace std;
int dp[10001];
int main() {
    int H, N, A[10000], B[10000];
    scanf("%d%d",&H,&N);
    for (int i = 0; i < H; i++) dp[i] = INT_MAX;
    dp[H] = 0;
    for (int i = 0; i < N; i++) scanf("%d%d",&A[i],&B[i]);
    for (int i = H; i > 0; i--) {
        if (dp[i] != INT_MAX) {
            for (int j = 0; j < N; j++) {
                if (i - A[j] <= 0) {
                    dp[0] = min(dp[0], dp[i] + B[j]);
                } else {
                    dp[i - A[j]] = min(dp[i - A[j]], dp[i] + B[j]);
                }
            }
        }
    }
    printf("%d\n",dp[0]);
}

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

string multichar(char c, int n) {
    string ret;
    rep(i,n) {
        ret += c;
    }
    return ret;
}

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> ans;
    int count_white[w] = {};
    rep(i,h) {
        string s;
        cin >> s;
        bool allwhite = true;
        rep(j,w) {
            if (s[j] == '.') count_white[j]++;
            else allwhite = false;
        }
        if (!allwhite) ans.push_back(s);
    }
    bool white_column[w] = {};
    rep(i,w) {
        if (count_white[i] == h) {
            white_column[i] = true;
        }
    }
    rep(i,ans.size()) {
        rep(j,w) {
            if (white_column[j]) continue;
            else cout << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int sen[31],y,i,k,hon,m,h;
  scanf("%d",&hon);
  for(i=1;i<=hon;i++)sen[i]=i;
  scanf("%d",&k);
  for(i=0;i<k;i++){
    scanf("%d,%d",&m,&h);
    y=sen[m];
    sen[m]=sen[h];
    sen[h]=y;
  }
  for(i=1;i<=hon;i++)printf("%d\n",sen[i]);
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>

int main(){
    std::string S;
    std::cin >> S;

    int fzero = 0;//even
    int fone = 0;//odd
    for (int i = 0; S[i] != '\0'; i++){
        if (i % 2 == 0){
            if (S[i] == '1'){
                fone++;
            }
            else fzero++;
        }
        else {
            if (S[i] == '1'){
                fzero++;
            }
            else fone++;
        }
    }
    int ans = std::min(fzero, fone);

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

Measured memory_bytes: 512
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!

function main(input) {
    var arg = input.split('\n')[1].split(' ').map((n) => parseInt(n));
    var ans = Infinity;
    arg.forEach(function(value){
        var count = 0;
        while(value % 2 === 0){
            value /= 2;
            count += 1;
        }
        ans = Math.min(ans, count);
    });
    console.log(Math.max(0, ans));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9676
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	string s[3]; 
	cin>>s[0]>>s[1]>>s[2];
	int len[3], pos[3];
	bool vis[3];
	for(int i=0;i<3;i++) {
		len[i]=s[i].length();
		pos[i] = 0;
		vis[i] = false;
	}
	
	//int move = 0;
	char cur;
	int move = 0, id=0;
	vis[0] = true;
	while(pos[0]<len[0] and pos[1]<len[1] and pos[2]<len[2]){
		cur = s[id][pos[id]];
		id = cur-'a';
		if(vis[id]) pos[id]++;
		else vis[id] = true;
	}
	printf("%c\n",cur-'a'+'A');
	
	/*critical input
	c
	ba
	cab
	*/
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
using namespace std;
int main(void){
    // Your code here!
    int a,b;

    cin>>a>>b;
    
     if((a+b)%3==0 || a%3==0 || b%3==0) cout<<"Possible"<<endl;
     else cout<<"Impossible"<<endl;


}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,l=0;
    string s,t,ss,tt,last="";
    cin>>n>>s>>t;
    for(int i=1;i<=n;i++)
    {
        ss="";
        tt="";
        for(int j=n-i;j<n;j++)ss+=s[j];
        for(int j=0;j<i;j++)tt+=t[j];
        if(ss==tt)l=i;
    }
    for(int j=0;j<n-l;j++)last+=s[j];
    last+=t;
    cout<<last.size()<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.math.RoundingMode;
import java.math.BigDecimal;
 
 
 
public class Main{
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
	    int w = sc.nextInt();
	    int k = sc.nextInt();
	    int[][] c = new int[h][w];
		for(int i = 0; i < h; i++) {
			String s = sc.next();
			for(int j = 0; j < w; j++) {
		        if(s.charAt(j) == '#') c[i][j] = 1;
		      }
		}
		int ans = 0;
		for(int i = 0; i < (int)Math.pow(2, h); i++) {
			for(int j = 0; j < (int)Math.pow(2, w); j++) {
				int black = 0;
				for(int l = 0; l < h; l++) {
			        for(int m = 0; m < w; m++) {
			        	if(((i&(1<<l))==0) &&((j&(1<<m))==0)&&(c[l][m]==1)) black++; 
			        }
			    }
				if(black==k) ans++;
			}
		}
		System.out.println(ans);
    }
}

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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pnn=pair<int ,int>;

#define ft first
#define sd second
#define fn front
#define pb push_back
#define it insert
#define count ct
#define si(v) int((v).size())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sot(x) sort(x.begin(), x.end())
#define rese(x) reverse(x.begin(), x.end())
#define vnn(x,y,s,name) vector<vector<int>> name(x, vector<int>(y,s))
#define mse(x) memset(x, 0, sizeof(x))
#define mii(x,y,z) min(x,min(y,z))
#define maa(x,y,z) max(x,max(y,z))

string yes="Yes",no="No";

int main() {
   int n,m;
   cin>>n>>m;
   Graph G(n);
   rep(i,m){
       int a,b;
       cin>>a>>b;
       a--; b--;
       G[a].pb(b);
       G[b].pb(a);
   }
   vin ans(n,-1);
   queue<int> q;
   vbl seen(n,0);
   q.push(0);
   while(!q.empty()){
       int i=q.fn();
       q.pop();
       seen[i]=true;
       for(auto x:G[i]){
           if(seen[x]) continue;
           q.push(x);
           seen[x]=true;
           ans[x]=i+1;
       }
   }
   rep(i,n){
       if(i==0) cout<<yes<<endl;
       else cout<<ans[i]<<endl;
   }
   
}


Measured memory_bytes: 10108
N, M, X = map(int, input().split())
C, A = [], []
for i in range(N):
    c, *a = map(int, input().split())
    C.append(c)
    A.append(a)

ans = []
for i in range(1, 2**N):
    tmp = []
    pnt = 0
    for j in range(N):
        if i>>j & 1 == 1:
            tmp.append(A[j])
            pnt += C[j]
    *score, = map(sum, zip(*tmp))
    if min(score) >= X:
        ans.append(pnt)

if ans:
    print(min(ans))
else:
    print(-1)


Measured memory_bytes: 9016
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n,m;
ll h[100005];
vector<int> G[100005];
queue<int> que;
bool used[100005];
ll mx=0;

int main(void){
	scanf("%d%d",&n,&m);
	for(int i=0;i<n;i++){
		scanf("%lld",&h[i]);
	}
	for(int i=0;i<m;i++){
		int a,b;
		scanf("%d%d",&a,&b);
		a--;
		b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int ans=0;
	for(int i=0;i<n;i++){
		bool flag=true;
		for(int j=0;j<G[i].size();j++){
			int nv=G[i][j];
			if(h[i]<=h[nv]){
				flag=false;
			}
		}
		if(flag){
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 9660