akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<set>
using namespace std;
int main()
{
    long long n,m,tmp=0,count=0;
    cin>>n>>m;
    long long a1[m],a2[m];
    set <long long> s1;
    set <long long> s2;
    set<long long>::iterator it;
    for(long long i=0;i<m;++i)
    {
        cin>>a1[i]>>a2[i];
        s1.insert(a1[i]);
        s2.insert(a2[i]);
    }
    long long a,b;
    it=s2.begin();
    a=*it;
    it=s1.end();--it;
    b=*it;
    if(b>a){cout<<0;return 0;}
    cout<<a-b+1;
    
}

Measured memory_bytes: 11136
#include <iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include <set>
#include <cassert>
#include<cmath>
#include<climits>
#include<iomanip>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
const long long INF = 1LL << 60;


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

class UnionFind {
	vector<int> data;
public:
	UnionFind(int size) : data(size, -1) { }
	bool unionSet(int x, int y) {
		x = root(x); y = root(y);
		if (x != y) {
			if (data[y] < data[x]) swap(x, y);
			data[x] += data[y]; data[y] = x;
		}
		return x != y;
	}
	bool findSet(int x, int y) {
		return root(x) == root(y);
	}
	int root(int x) {
		return data[x] < 0 ? x : data[x] = root(data[x]);
	}
	int size(int x) {
		return -data[root(x)];
	}
};

int find(vector<long long> &arr, long long obj) {
	if (arr[arr.size() - 1] < obj)return arr.size()-1;
	if (arr[0] > obj)return -1;

	int min = 0; int max = arr.size() - 1;
	for (int i = 0; i < arr.size(); i++) {
		if (arr[min+(max-min) / 2] > obj) {
			max = min + (max - min) / 2;
		}
		else {
			min = min + (max - min) / 2;
		}
		if (max - min == 1) {
			return min;
		}
	}


}

//約数求める //約数
void divisor(ll n,vector<ll> &ret) {
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			ret.push_back(i);
			if (i * i != n) ret.push_back(n / i);
		}
	}
	sort(ret.begin(), ret.end());
	
}
//階乗
long long factorial(long long n, long long mod) {
	long long ret = 1;
	for (long long i = 1; i <= n; i++) {
		ret = (ret * i) % mod;
	}
	return ret;
}
//モジュラ逆数
long long inv_mod(long long n, long long mod) {
	long long a = n % mod, b = mod - 2, ret = 1;
	while (b > 0) {
		if (b & 1) ret = (ret * a) % mod;
		a = (a * a) % mod;
		b >>= 1;
	}
	return ret;
}

long long nPr(long long n, long long r, long long mod) {
	long long ret = 1;
	for (long long i = n; i >= n - r + 1; i--) {
		ret = ret * (i % mod) % mod;
	}
	return ret;
}

long long nCr(long long n, long long r, long long mod) {
	return nPr(n, r, mod) * inv_mod(factorial(r, mod), mod) % mod;
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {//降順second
	if (a.second != b.second) {
		return a.second > b.second;
	}
	else {
		return a.first > b.first;
	}
}

bool compare_by_a(pair<ll, ll> a, pair<ll, ll> b) {//降順first
	if (a.first != b.first) {
		return a.first > b.first;
	}
	else {
		return a.second > b.second;
	}
}

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


int main() {
	string s;
	cin >> s;
	ll cnt = 0;
	ll cntt = 0;
	rep(i, s.size()) {
		if (i % 2 == 0) {
			if (s[i] == '0') {
				cnt++;
			}
			else {
				cntt++;
			}
		}
		else {
			if (s[i] == '1') {
				cnt++;
			}
			else {
				cntt++;
			}
		}
	}
	if (cnt > cntt) {
		cout << cntt;
	}
	else {
		cout << cnt;
	}


	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          firstn
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define fr(i,l,u) 	for(i=l;i<=u;i++)
#define bk(i,l,u)	for(i=l;i>=u;i--)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;
ll posx[]={1,-1,0,0};
ll posy[]={0,0,1,-1};

void solve()
{
    ll n,i,j,w;
    cin>>n>>w;
    ll wt[n+1],val[n+1];
    for(i=1;i<=n;i++)
    cin>>wt[i]>>val[i];
    ll dp[n+1][w+1];
    mset(dp,0);
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=w;j++)
        {
            if(i==0 or j==0)
            {
                dp[i][j]=0;
                continue;
            }
            if(j>=wt[i])
            dp[i][j]=max(dp[i-1][j],val[i]+dp[i-1][j-wt[i]]);
            else
            dp[i][j]=max(dp[i][j],dp[i-1][j]);
        }
    }
    cout<<dp[n][w];
}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


Measured memory_bytes: 79232
function main(input) {
  data = input.split('\n');
  var res = data[0];
  var n = data[1];
  data = data.slice(2);
  var f = 0;

  for (var i = 0; i < n; i ++) {
    var q = data[i].split(' ');

    if (q[0] == 1) {
      f ^= 1;

    } else {

      if (f ^ (q[1] - 1)) {
        res += q[2];

      } else {
        res = q[2] + res;

      }
    }
  }
  if (f) {
    res = res.split('').reverse().join('');
  }
  return res;
}

const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim();
console.log(main(input));

Measured memory_bytes: 57860
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<cstdlib>
#define LL long long
#define LD long double
using namespace std;
const int NN=200000 +117;
const int MM=100000 +117;
int read(){
	int fl=1,x;char c;
	for(c=getchar();(c<'0'||c>'9')&&c!='-';c=getchar());
	if(c=='-'){fl=-1;c=getchar();}
	for(x=0;c>='0'&&c<='9';c=getchar())
		x=(x<<3)+(x<<1)+c-'0';
	return x*fl;
}
void open(){
	freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
}
void close(){
	fclose(stdin);
	fclose(stdout);
}
const int mod=1e9+7;
LL ksm(LL a,int b){
	LL ret=1;
	for(;b;b>>=1,a=a*a%mod)
		if(b&1)ret=ret*a%mod;
	return ret;
}

int m,n;
int a[NN]={};
int cnt[NN]={};
int cha[NN]={};
int zer[NN]={};
LL ni[NN]={};
int xt[NN]={};
LL val[NN]={};
LL bit[NN]={};
LL bef[NN]={};
inline int lowbit(int x){
	return x&-x;
}
LL q(LL bit[],int x){
	LL ret=0;
	for(;x;x-=lowbit(x)){
		ret+=bit[x];
	}
	return ret%mod;
}
LL query(LL bit[],int l,int r){
	if(r<l)return 0;
	return (q(bit,r)-q(bit,l-1))%mod;
}
void add(LL bit[],int x,LL v){
	for(;x<=n;x+=lowbit(x)){
		bit[x]=(bit[x]+v)%mod;
	}
}
int main(){
	//open();
	n=read();
	for(int i=1;i<=n;++i){
		a[i]=read();
		cnt[a[i]]++;
	}
	for(int i=n;i>=1;--i)cnt[i-1]+=cnt[i];
	bool fl=0;
	LL all=1;
	for(int i=1;i<=n;++i){
		cnt[i]-=n-i;
		all=all*cnt[i]%mod;
		if(cnt[i]<=0)fl=1;
		cha[i]=cnt[i]-1;
		if(!cha[i]){
			cha[i]=1;
			zer[i]=1;
		}
	}
	if(fl){
		printf("0\n");
		return 0;
	}
	ni[1]=1;
	for(int i=2;i<=n;++i){
		ni[i]=-(mod/i)*ni[mod%i]%mod;
	}
	xt[n]=n;
	for(int i=n-1;i>=0;--i){
		if(zer[i+1])xt[i]=i;
		else xt[i]=xt[i+1];
	}
	val[0]=1;
	for(int i=1;i<=n;++i){
		val[i]=val[i-1]*cha[i]%mod*ni[cnt[i]]%mod;
	}
	LL ans=0;
	for(int i=1;i<=n;++i){
		int k=a[i];
		int pos=xt[k];
		LL res=query(bit,a[i]+1,pos)*ksm(val[a[i]],mod-2)%mod;
		res=res*ni[2]%mod*all%mod;
		res=-res;
		res+=query(bef,a[i]+1,n)*all%mod;
		add(bit,a[i],val[a[i]]);
		add(bef,a[i],1);
		(ans+=res)%=mod;
	}
	for(int i=1;i<=n;++i)bit[i]=0;
	for(int i=n;i>=1;--i){
		int k=a[i];
		int pos=xt[k];
		LL res=query(bit,a[i],pos)*ksm(val[a[i]],mod-2)%mod;
		res=res*ni[2]%mod*all%mod;
		add(bit,a[i],val[a[i]]);
		(ans+=res)%=mod;
	}
	ans=(ans+mod)%mod;
	printf("%lld\n",ans);
	close();
	return 0;
}

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

using namespace std;

int n;
int v[100010][3];
int dp[100010][3];

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

    for (int i = 0; i < n; ++i)
        for (int j = 0; j < 3; ++j)
            cin >> v[i][j];


    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 3; ++j) {
            if(i) dp[i][j] = max(dp[i][j], dp[i - 1][(j + 3 - 1) % 3]);
            if(i) dp[i][j] = max(dp[i][j], dp[i - 1][(j + 1) % 3]);
            dp[i][j] += v[i][j];
        }
    }
    
    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << "\n";
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

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

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

//! [i番目の品物で][価値がvとなるような]=重さの最小値
ll dp[105][10005];
pll vw[105];

int main()
{
	ll N,W;
	cin >> N >> W;
	REP(i, N)
	{
		cin >> vw[i].first >> vw[i].second;
	}

	REP(i, N + 1)
	{
		REP(j, 100 * N + 1)
		{
			dp[i][j] = INF;
		}
	}

	dp[0][0] = 0;
	FOR(n, N + 1, 1)
	{
		REP(v, 100 * N + 1)
		{
			dp[n][v] = dp[n - 1][v];
			if (v - vw[n - 1].first >= 0)
			{
				dp[n][v] = std::min(dp[n][v], dp[n - 1][v - vw[n - 1].first] + vw[n - 1].second);
			}
		}
	}

	ll max = 0;
	REP(v, 100 * N + 1)
	{
		if (dp[N][v] <= W)max = v;
	}
	cout << max << endl;
	return 0;
}


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

#define ll      long long
#define MAX1    2007
#define MAX2    4000007
#define inf     99999999999999
#define MOD     1000000007
#define pii     pair<int,int>
#define FIN     freopen("input.txt","r",stdin);
#define FOUT    freopen("output.txt","w",stdout);
#define pll     pair<ll,ll>
#define llu     unsigned long long

bitset<MAX2>b_set;
ll ara[MAX1];
ll n,sum=0;

void process()
{
    b_set.set(0);

    for(int i=0;i<n;i++)
    {
        b_set |= (b_set<<ara[i]);
        //actually the bitset shifts right
        //think like array
    }
}
int main ()
{
    scanf("%lld",&n);
    for(int i=0;i<n;i++)
        {
            scanf("%lld",&ara[i]);
            sum += ara[i];
        }
        process();
        ll mid = (sum + 1)>>1;
        for(ll i=mid;i<=sum;i++)
        {
            if(b_set.test(i))
            {
                printf("%lld\n",i);
                return 0;
            }
        }
    return 0;
}


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

int main(){
  int N,M;
  cin >> N >> M;
  vector<int> A(N-2,0);
  vector<int> D(N-2,0);
  int x,y;
  for(int i=0;i<M;i++){
    cin >> x >> y;
    if(x==1){
      A[y-2] ++;
    }
    if(y==N){
      D[x-2] ++;
    }
  }
  for(int i=0;i<N-2;i++){
    if(A[i]*D[i]==1){
      cout << "POSSIBLE" << endl;
      return 0;
    }
  }
  cout << "IMPOSSIBLE" << endl;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int n,w,h;
const int nmax=100010;
int cx[2*nmax];
int cy[2*nmax];

inline void add(int* in,int l,int r){
	l=max(l,0);
	r=min(r,2*nmax-1);
	in[l]++;
	in[r+1]--;
	return;
}

int main(void){
	cin >> n >> w >> h;
	rep(i,n){
		int x,y,r;
		cin >> x >> y >> r;
		add(cx,2*(x-r),2*(x+r));
		add(cy,2*(y-r),2*(y+r));
	}
	rep(i,2*w) cx[i+1]+=cx[i];
	rep(i,2*h) cy[i+1]+=cy[i];

	bool ok=true;
	rep(i,2*w+1) if(cx[i]==0) ok=false;
	bool ok2=true;
	rep(i,2*h+1) if(cy[i]==0) ok2=false;
	if(ok||ok2)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 2680
import java.util.Scanner;

public class Main {

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

		int cnt = 0;
		for(int i = 1;i <= N/2;i++){
			cnt++;
		}
		if(N==1 || N==2){
			System.out.println(0);
			return;
		}
		System.out.println(N%2==0 ? --cnt : cnt);
	}
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug1(x) cerr<<#x<<" -> "<<x<<endl
#define debug2(x,y) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<'\n'
#define debug3(x,y,z) cerr<<#x<<" -> "<<x<<" "<<#y<<" -> "<<y<<" "<<#z<<" -> "<<z<<'\n'

 
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>

const ll N = 1e5+7;
const ll MOD = 1e9+7;
const ll inf = 1e18+5;
ll in[16][16];
vector<ll> gscore, dp;
ll curr;

void solve(int pos, vector<int> &rem, int mask, int gr){
	if(pos == (int)rem.size()){
		dp[mask] = max(dp[mask], curr + gscore[gr]);
		return;
	}
	
	solve(pos+1, rem, mask | (1<<rem[pos]), gr | (1<<rem[pos]));
	solve(pos+1, rem, mask, gr);
}


int main(){
	fast;
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			cin>>in[i][j];
		}
	}
	
	gscore.resize((1<<n), 0);
	dp.resize((1<<n), 0);
	
	for(int mask=0;mask<(1<<n);mask++){
		for(int i=0;i<n;i++){
			if(mask & (1<<i)){
				for(int j=i+1;j<n;j++){
					if(mask & (1<<j)){
						gscore[mask]+=in[i][j];
					}
				}
			}
		}
	}
	
	for(int mask=0;mask<(1<<n);mask++){
		vector<int> rem;
		for(int i=0;i<n;i++){
			if(!(mask & (1<<i))) rem.push_back(i);
		}
		curr = dp[mask];
		solve(0, rem, mask, 0);
	}
	
	cout<<dp[(1<<n)-1]<<'\n';
	
	return 0;
}


Measured memory_bytes: 1280
let (n1, n2, n_limit) = (3, 9, 31)

let area =
  [| [1; 3]; [0; 2; 4]; [1; 5]
   ; [0; 4; 6]; [1; 3; 5; 7]; [2; 4; 8]
   ; [3; 7]; [4; 6; 8]; [5; 7] |]

let md = Array.make_matrix n2 n2 0

let initialize_md () =
  for i = 0 to n2 - 2 do
    for j = 0 to n2 - 1 do
      md.(i+1).(j) <- abs (i / n1 - j / n1) + abs (i mod n1 - j mod n1)
    done
  done

let idastar a limit space_i lower goal =
  let rec doit i space_i moved lower =
    if i = limit then begin
      if a = goal then begin
        List.length moved - 1 |> Printf.printf "%d\n";
        exit 0;
      end
    end else
      List.iter (fun j ->
        let x = a.(j) in
        if x = List.hd moved then () else
        let lower = lower - md.(x).(j) + md.(x).(space_i) in
        if lower + i > limit then ()
        else begin
          a.(j) <- 0;
          a.(space_i) <- x;
          doit (i + 1) j (x :: moved) lower;
          a.(j) <- x;
          a.(space_i) <- 0;
        end) area.(space_i) in
  doit 0 space_i [-1] lower

let () =
  initialize_md ();
  let a = Array.init n2 (fun _ -> Scanf.scanf "%d " (fun i -> i)) in
  let rec f i =
    if i = n2 then assert false
    else if a.(i) = 0 then i
    else f (i + 1) in
  let space_i = f 0 in
  let rec g i acc =
    if i = n2 then acc
    else g (i + 1) (acc + md.(a.(i)).(i)) in
  let lower = g 0 0 in
  let goal = [|1; 2; 3; 4; 5; 6; 7; 8; 0|] in
  for limit = lower to n_limit do
    idastar a limit space_i lower goal
  done

Measured memory_bytes: 4428
#include <bits/stdc++.h>
using namespace std;
  
int main() {
  long long A;
  long long B;
  long long K;
  cin >> A >> B;
  if (abs(A - B) % 2 == 0) {
    K = min(A, B) + abs(A - B) / 2;
    cout << K << endl;
  } else {
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mes(a, b)  memset(a, b, sizeof a)
#define pb push_back
typedef unsigned long long int ull;
typedef long long int ll;
const int    maxn = 1e5 + 20;
const int    maxm = 1e5 + 10;
const ll     mod  = 1e9 + 7;
const ll     INF  = 1e18 + 100;
const int    inf  = 0x3f3f3f3f;
const double pi   = acos(-1.0);
const double eps  = 1e-8;
using namespace std;
int main(){
	int n;cin >> n;
	printf("%.9f\n",2 * n * pi );
}

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

int N,C;
int c[501][501],D[31][31];
int Z[31];
int O[31];
int T[31];
int main(){
	cin >> N >> C;
	for(int i=1;i<=C;i++){
		for(int j=1;j<=C;j++){
			cin >> D[i][j];
		}
	}
	vector<int> z,o,t;
	for(int i=1;i<=N;i++){
		for(int j=1;j<=N;j++){
			cin >> c[i][j];
			if((i+j)%3==0){
				z.push_back(c[i][j]);
			}else if((i+j)%3==1){
				o.push_back(c[i][j]);
			}else{
				t.push_back(c[i][j]);
			}
		}
	}
	for(int i=1;i<=C;i++){
		int a = 0;
		for(int j=0;j<z.size();j++){
			a += D[z[j]][i];
		}
		Z[i] = a;
	}
	for(int i=1;i<=C;i++){
		int a = 0;
		for(int j=0;j<o.size();j++){
			a += D[o[j]][i];
		}
		O[i] = a;
	}
	for(int i=1;i<=C;i++){
		int a = 0;
		for(int j=0;j<t.size();j++){
			a += D[t[j]][i];
		}
		T[i] = a;
	}
	int ans = 1e9;
	for(int i=1;i<=C;i++){
		for(int j=1;j<=C;j++){
			for(int k=1;k<=C;k++){
				if(!(i==j || j==k || k==i)){
					ans = min(ans,Z[i]+O[j]+T[k]);
				}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 2416
int main() {
    int N;
    scanf("%d",&N);
    int x[N];
    int m = 1000000007;
    long long sum = 0, sum1 = 0;
    for (int i = 0; i < N; i++){
        scanf("%d",&x[i]);
        sum += x[i];
        sum %= m;
    }

    for (int i = 0; i < N; i++){
        sum -= x[i];
        if (sum < 0) sum += m;

        sum1 += x[i] * sum;
        sum1 %= m;
    }
    printf("%lld\n",sum1);
    return 0;
}


Measured memory_bytes: 2432
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    r = INT()
    print(3*r*r)

if  __name__=='__main__':
    main()

Measured memory_bytes: 5332
s = list(input())
t = list(input())

r = len(s) - len(t)
l = []
if r != 0:
    for start in range(r):
        count = 0
        for i in range(len(t)):
            if t[i] == s[start+i]:
                count +=1
        l.append(count)
    ans = len(t)- max(l)
else:
    count = 0
    for i in range(len(t)):
        if t[i] == s[i]:
            count +=1
    ans = len(t)- count   

print(ans)
        

Measured memory_bytes: 8956
N=int(input())
D=list(map(int,input().split()))
layer=[0]*N

mx=0
for item in D:
    layer[item]+=1
    mx=max(mx,item)

if layer[0]!=1 or D[0]!=0:
    print(0)
    exit()

ans=1
for i in range(mx):
    ans*=(layer[i]**layer[i+1])

print(ans%998244353)

Measured memory_bytes: 14396
H, W , N = map(int,input().split())
from bisect import bisect_left
from bisect import bisect_right
matrix = []
for _ in range(N):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    matrix.append([x,y])
matrix.sort()
ans = [0 for _ in range(10)]
cand = {}
for l in matrix:
    for x_r in [-2, -1 , 0]:
        for y_r in [-2, -1 , 0]:
            nowx = l[0] + x_r
            nowy = l[1] + y_r
            if nowx < 0 or nowy < 0 or nowx + 2>= H or nowy+ 2 >= W:
                continue
            #ここで起点(左上)nowx, nowy として　 9マスに着目する
            name = str(nowx) +"hoge" +str(nowy)
            try: cand[name] += 1
            except: cand[name] = 1
tmp = ((H - 2) * (W - 2))
for x in cand.values():
    ans[x] += 1
    tmp -= 1
ans[0] = tmp
for x in ans:
    print(x)


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

template<typename T>
void fin (T a){
    cout<<a<<endl;
    exit(0);
}
template<typename S>
void print(S a){
    cout<<a<<endl;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int len=s.size();
    int ans =0;

    map<int,int> dp;
    int tmp;
    int mod=0;
    int powmod=1;
    rep(i,len) {
        tmp = s[len-1-i]-48;
        powmod = (powmod*10)%2019;
        mod = (ll)(tmp*powmod+mod)%2019;
        dp[mod]++;
    }

    for(auto x: dp){
        int a = x.second;
        if(x.first ==0){
            ans+= a;
        }
        ans += a*(a-1)/2;
    }

    fin(ans);
}


Measured memory_bytes: 3896
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

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

  int a, b, c;
  cin >> a >> b >> c;

  int s = (a * b) / 2;

  cout << s << endl;

  return 0;
}


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

/*define*/
string S,T, T_tmp;
int N,M;


int main(){
    /*inpus*/
    std::cin >> S;
    std::cin >> T;

    /*syori*/
    N = S.length();
    T_tmp = T.substr(0,N);
    if(S==T_tmp){
        std::cout << "Yes";
    }else{
        std::cout << "No";
    }
}    
    

Measured memory_bytes: 3636
// ------------------------------------
// Date:2018/ 3/ 6
// Problem:ABC 080 Recording d.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;

// static const int MOD = 1000000007;
//static const int INF = 1e9 + 1;

// s,t[101010]
int s[101010];
int t[101010];
int c[101010];
int timetable[30][101010];

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

  memset(timetable, 0, sizeof(timetable));
  int N, C;
  cin >> N >> C;

  // O(N)
  REP(i, N) {
    cin >> s[i] >> t[i] >> c[i];
    s[i];
    t[i];
    --c[i];
    timetable[c[i]][s[i]]++;
    timetable[c[i]][t[i]]--;
  }

  // O(CN)
  REP(h, C) {
    REP(i, 101000) {
      //debug(i);
      //debug(ans);
      //debug(timetable[h][i]);
      timetable[h][i + 1] += timetable[h][i];
    }
  }

  // O(CN)
  REP(h, C) {
    REP(i, 101010) {
      if (timetable[h][i] == 0 and timetable[h][i + 1] == 1) {
	++timetable[h][i];
      }
    }
  }
  
  int ans = 0, tmp;
  REP(i, 101010) {
    tmp = 0;
    REP(h, C) {
      tmp += timetable[h][i];
    }
    ans = max(ans, tmp);
    //debug(i)
    //debug(ans);
    //debug(timetable[i]);
  }
  cout << ans << endl;
  
  return 0;
}



Measured memory_bytes: 13312
while(n=gets.to_i)>0
s=[]
n.times{d,p,q=gets.split.map &:to_i
w=d<2?p:1
y=(s.rindex{|l|l[q-1,w].any?}||-1)+1
(y..(d<2?y:y+p-1)).map{|i|(s[i]||=[$,]*5)[q-1,w]=[1]*w}
s-=[[1]*5]}
p s.flatten.count 1
end

Measured memory_bytes: 10012
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <tuple>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; --i)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};

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

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

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

  cin >> n;
  double sum = 0.0;
  REP(i, n) {
    double a;
    cin >> a;
    sum += (double)(1.0 / a);
  }

  double ans = 0.0;
  ans = 10000 / (sum * 10000);
  cout << fixed << setprecision(6) << ans << endl;
}


Measured memory_bytes: 256
def main():
    n=input()
    a=map(int,input().split())
    c = 0
    for x in (i for i in a if i % 2 == 0):
        while True:
            if x % 2 == 0:
                x //= 2
                c += 1
            else:
                break
    print(c)
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 9644
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
using namespace std;

typedef long long ll;

ll dp[200200][6];

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    for(int i=0;i<200200;i++){
        for(int j=0;j<5;j++){
            dp[i][j]=2e18;
        }
    }
    dp[0][0]=0;
    for(int i=0;i<n;i++){
        for(int j=0;j<5;j++){
            dp[i][j+1]=min(dp[i][j+1],dp[i][j]);
            if(j==0||j==4){
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]+a[i]);
            }
            else if(j==1||j==3){
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]+(a[i]==0?2:a[i]%2));
            }
            else if(j==2){
                dp[i+1][j]=min(dp[i+1][j],dp[i][j]+(a[i]+1)%2);
            }
        }
    }
    for(int i=0;i<5;i++){
        dp[n][i+1]=min(dp[n][i+1],dp[n][i]);
    }
    cout << dp[n][4] << endl;
}

Measured memory_bytes: 11264
subroutine heapsort(n,array)
  implicit none
  integer,intent(in) :: n
  integer,intent(inout) :: array(1:n)

  integer ::i,k,j,l
  integer :: t

  if(n.le.0)then
     write(6,*)"Error, at heapsort"; stop
  endif
  if(n.eq.1)return

  l=n/2+1
  k=n
  do while(k.ne.1)
     if(l.gt.1)then
        l=l-1
        t=array(L)
     else
        t=array(k)
        array(k)=array(1)
        k=k-1
        if(k.eq.1) then
           array(1)=t
           exit
        endif
     endif
     i=l
     j=l+l
     do while(j.le.k)
        if(j.lt.k)then
           if(array(j).lt.array(j+1))j=j+1
        endif
        if (t.lt.array(j))then
           array(i)=array(j)
           i=j
           j=j+j
        else
           j=k+1
        endif
     enddo
     array(i)=t
  enddo

  return
end subroutine heapsort

subroutine bubblesort(N,array)
  !sikinote, 2016/08/08
  implicit none
  integer,intent(in)::N
  integer,intent(inout)::array(1:N)
  integer::i,j
  integer::t

  do i=1,N-1
     do j=i+1,N
        if(array(i) .gt. array(j))then
           t=array(i)
           array(i)=array(j)
           array(j)=t
        end if
     end do
  end do

  return
end subroutine bubblesort

program C

  implicit none
  integer N
  integer K
  integer i
  integer(8) sum
  integer,allocatable, dimension(:) :: H
  read *, N,K
  sum = 0
  allocate(H(N))
  read *, H
  call heapsort(N,H)
  ! do i = N-K+1, N
  !   H(i) = 0
  ! end do
  do i = 1, N-K
      sum = sum + H(i)
  end do
  print '(i0)', sum




end program


Measured memory_bytes: 1536
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define ll long long
#define mod 998244353
#define N 10000005
int n;
int fac[N], inv[N], mul[N];
int Pow(int a, int k)
{
	int ret = 1;
	while (k)
	{
		if (k & 1)
			ret = (ll)ret * a % mod;
		a = (ll)a * a % mod;
		k >>= 1;
	}
	return ret;
}
int C(int n, int m){return (ll)fac[n] * inv[m] % mod * inv[n - m] % mod;}
int main()
{
	scanf("%d", &n);
	fac[0] = 1;
	for (int i = 1; i <= n; i++)
		fac[i] = (ll)fac[i - 1] * i % mod;
	inv[n] = Pow(fac[n], mod - 2);
	for (int i = n; i >= 1; i--)
		inv[i - 1] = (ll)inv[i] * i % mod;
	mul[0] = 1;
	for (int i = 1; i <= n; i++)
		mul[i] = (ll)mul[i - 1] * 2 % mod;
	int ans = Pow(3, n);
	for (int i = n / 2 + 1; i <= n; i++)
		ans = (ans - 2ll * mul[n - i] * C(n, i)) % mod;
	if (ans < 0)ans += mod;
	printf("%d\n", ans);
}


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

using ll = long long;
ll c2, c3, c5, c1;

map<ll, ll> mp;

ll dfs(ll n) {
  if (!mp.count(n)) {
    if (n == 0) {
      mp[n] = 0;
    } else {
      ll res = 6e18;
      if (n <= res / c1) res = min(res, c1 * n);
      res = min(res, dfs(n / 2) + c2 + c1 * (n % 2));
      res = min(res, dfs(n / 3) + c3 + c1 * (n % 3));
      res = min(res, dfs(n / 5) + c5 + c1 * (n % 5));
      if(n > 1){
        if (n > 2) res = min(res, dfs(1 + n / 2) + c2 + c1 * (2 - (n % 2)));
        res = min(res, dfs(1 + n / 3) + c3 + c1 * (3 - (n % 3)));
        res = min(res, dfs(1 + n / 5) + c5 + c1 * (5 - (n % 5)));
      }
      mp[n] = res;
    }
  }
  return mp[n];
}

int main(){
  int T;
  cin >> T;
  while (T--) {
    mp = {};
    ll n;
    cin >> n;
    cin >> c2 >> c3 >> c5 >> c1;
    ll ans = dfs(n);
    cout << ans << endl;
  }
}


Measured memory_bytes: 4848
//  main.cpp
//  APB3

#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main(int argc, const char * argv[]) {

    {
        long long MOD = 998244353;
        int N;
        cin >> N;
        vector<long long>D(N);
        int dt;
        cin >> dt;
        if (dt!=0) // 頂点０の自分までの距離は０でなければならない。
        {
            cout << 0<<endl;
            return 0;
        }
        else {
            D.at(0) = 1;
        }
        for (int i = 1; i < N; i++) // データの読み込み
        {
            cin >> dt;
            D.at(dt)++;
        }
        if (D.at(0)!=1) // 根が２箇所以上あってはならない。
        {
            cout << 0<<endl;
            return 0;
        }
        bool zero=false;
        for (int j=1; j<N; j++) { // 途中に０個があってはならない。木が繋がらないから。
            if (D.at(j)==0) {
                zero=true;
            }
            if (D.at(j)!=0&&zero==true) {
                cout<<0<<endl;
                return 0;
            }
        }
        long long ans = 1;
        for (int i = 2; i < N; i++)
        {
            for (int j=0; j<D.at(i); j++) {
                ans=ans*D.at(i-1)%MOD;
            }
        }
        cout << ans << endl;
    }
}


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

using namespace std;

int dirs[4][2]={{-1,0},{1,0},{0,-1},{0,1}};
//int dirs[8][2]={{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};

char shift(char ch, int x)
{
    int num=ch-'A';
    num+=x;
    num %= 26;
    return 'A'+num;
}

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("inp.in","r",stdin);
    //freopen("outp.out","w",stdout);
    int N;
    string s;
    cin >> N;
    cin >> s;
    for(int i=0; i<s.size(); i++)
    {
        s[i]=shift(s[i],N);
    }
    cout << s << endl;
    return 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 int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

const long long MOD = 1000000007;
// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main(){
  int a, b;
  cin>>a>>b;
  for(int i=b*10; i<(b+1)*10; i++) {
    if(i*8/100==a) {
      std::cout << i << std::endl;
      return 0;
    }
  }
  std::cout << -1 << std::endl;
  return 0;
}


Measured memory_bytes: 256
package main
 
import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)
 
var sc = bufio.NewScanner(os.Stdin)
 
func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
    sc.Split(bufio.ScanWords)
 
	N := nextInt()
	L := make([]int, N)
	for i := 0; i < N; i++ {
		L[i] = nextInt()
	}
 
    fmt.Println(solver(N,L))
}

func solver(N int, L []int) int {
    var ans int
    ans = 0
    sort.Sort(sort.Reverse(sort.IntSlice(L)))
    for i := 0; i < N-2; i++ {
        x := L[i]
        for j := i+1; j < N-1; j++ {
            y := L[j]
            for k := N-1; k > j; k-- {
                if x < y + L[k] {
                    ans++
                }
            }
        }
    }
    return ans
}

Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <cstring>
#include <cstdlib>
#include <iomanip>
#include <string>
#include <ctype.h>

const int INF =100000000;

using namespace std;


int main(){

  while(1){

    int n;

    cin >> n;

    if(n == 0){
      break;
    }else{

      int ansa=0;
      int ansb=0;

      for(int i = 0;i < n;i++){
	int aa,bb,cc;

	cin >> aa >> bb >>cc;

	if(ansb < bb+cc){
	  ansa = aa;
	  ansb = bb + cc;
	}
      }
      cout << ansa << " " << ansb << endl;
    }
  }
}


Measured memory_bytes: 1160
#include <cstdio>
typedef long long LL;

int n, ans;
LL d, x, y;
int main() {
    scanf("%d%lld", &n, &d), d *= d;
    while (n-- > 0) {
        scanf("%lld%lld", &x, &y);
        if (x * x + y * y <= d) ans++;
    }
    printf("%d", ans);
}


Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
   string S;
   cin >> S;

   if(S == "SUN") cout << 7 << endl;
   else if(S == "MON") cout << 6 << endl;
   else if(S == "TUE") cout << 5 << endl;
   else if(S == "WED") cout << 4 << endl;
   else if(S == "THU") cout << 3 << endl;
   else if(S == "FRI") cout << 2 << endl;
   else if(S == "SAT") cout << 1 << endl;
   
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	var a, v, b, w, t int
	fmt.Scan(&a, &v)
	fmt.Scan(&b, &w)
	fmt.Scan(&t)

	if v > w &&  b != a && math.Abs(float64(b - a) / float64(v - w)) <= float64(t){
		fmt.Println("YES")
	}else{
		fmt.Println("NO")
	}


}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

int A, B, C, D, E, F;
int p1, p2;
double ans;
int main() {
    cin >> A >> B >> C >> D >> E >> F;
    // cc + dd + 100aa + 100bb / (100aa + 100bb)
    for (int a = 0; a <= 30; ++a) {
        for (int b = 0; b <= 30; ++b) {
            int water = a * A * 100 + b * B * 100;
            if (water > F) continue;
            int mx = min(water / 100 * E, F - water);
            for (int c = 0; c * C <= mx; ++c) {
                for (int d = 0; c * C + d * D <= mx; ++d) {
                    int su = c * C + d * D;
                    double den = su * 100.0f / (su + water);
                    if (den >= ans) {
                        ans = den;
                        p1 = su + water;
                        p2 = su;
                    }
                }
            }
        }
    }
    cout << p1 << ' ' << p2 << endl;
    return 0;
}


Measured memory_bytes: 3692
import java.util.*;
public class Main {
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int rec=0,loz=0;
		while(sc.hasNext()){
			String[] st=sc.next().split(",");
			int a=Integer.parseInt(st[0]);
			int b=Integer.parseInt(st[1]);
			int d=Integer.parseInt(st[2]);
			if(a==b)loz++;
			if(a*a+b*b==d*d)rec++;
		}
		System.out.println(rec);
		System.out.println(loz);
	}
}

Measured memory_bytes: 11000
def coins():
    fivehund = int(input())
    onehund = int(input())
    fifty = int(input())
    target = int(input())
    result_count = 0

    for count500 in range(0,fivehund+1):
        for count100 in range(0,onehund+1):
            for count50 in range(0,fifty+1):
                 current = 500*count500 + 100*count100 + 50*count50
                 if target == current:
                     result_count += 1
    
    print(result_count)

if __name__ == '__main__':
    coins()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define llu unsigned long long int
#define Endl endl
#define mod  998244353
#define mkp make_pair
#define pb push_back
#define cin(n) scanf("%d",&n)
#define cout(n) printf("%d ",n)
#define sf(n) scanf("%d",&n)
#define pf(n) printf("%d ",n)
#define bitget(n) __builtin_popcountll(n)
ll dx[] = {1,1,0,-1,-1,-1,0,1};
ll dy[] = {0,-1,-1,-1,0,1,1,1};
ll dxx[] = {1,-1,0,0};
ll dyy[] = {0,0,-1,1};
ll modexpo(ll x,ll y){if(y==0)return 1;if(y%2){ll viky=modexpo(x,y/2);
return (((x*viky)%mod)*viky)%mod;}else{ll viky=modexpo(x,y/2);return (viky*viky)%mod;
}}
bool isvalid(ll x,ll y,ll n, ll m) { return (x>=0&&x<n&&y>=0&&y<m); }



int main() {
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt", "r", stdin);
    //     freopen("output.txt", "w", stdout);
    // #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll a,b,c;

    cin>>a>>b>>c;

    ll val = (a^b^c);
    if(val==a|| val== b|| val==c){
    	if(a==b&&b==c){
    		cout<<"No";
    		return 0;
    	}
    	cout<<"Yes";
    }else{
    	cout<<"No";
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
long N,ans;
int c[305][305];
bool IsRoad[305][305];

int main(){
  for(int i=0;i<305;i++){
    for(int j=0;j<305;j++){
      IsRoad[i][j]=true;
    }
  }
  cin>>N;
  for(int i=0;i<N;i++){
    for(int j=0;j<N;j++){
      cin>>c[i][j];
    }
  }

  for(int k=0;k<N;k++){
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
        if(c[i][j]>c[i][k] + c[k][j]){
          cout<<-1<<endl;
          return 0;
        }
        else if(c[i][j]==c[i][k]+c[k][j]&&k!=j&&k!=i){
          IsRoad[i][j]=false;
        }
      }
    }
  }
  ans=0;
  for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
      if(IsRoad[i][j])ans+=c[i][j];
    }
  }
  cout<<ans<<endl;
}

       

Measured memory_bytes: 640
from collections import Counter


def solve():
    n = int(input())
    a = list(map(int, input().split()))
    l1 = [i-a[i] for i in range(n)]
    l2 = [a[i]+i for i in range(n)]
    c1 = Counter(l1)
    c2 = Counter(l2)
    ans = 0
    for i in l1:
        ans += c2[i]
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 63444
answer = []

while True :
    s = input().split()
    
    if s[0] == "#" :
        break
    else :
        if (int(s[1]) > 31) or (int(s[1]) == 31 and int(s[2]) >= 5) : 
            answer.append("?" + " " + str(int(s[1]) - 30) + " " + s[2] + " " + s[3])
        else :
            answer.append(" ".join(s))
            
for a in answer :
    print(a)




Measured memory_bytes: 5612
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val s = sc.nextLine()
    println(if (s[2] == s[3] && s[4] == s[5]) "Yes" else "No")
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 31260
#include <cstdio>
#include <utility>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;

int main() 
{
	//mod7で1,6の配列を作る
	ll a[100000][2]={};
	ll count(0);
	for(ll i=0;7*i-1<300000;i++){
		a[i*2][0]=(i+1)*7-1;
		a[i*2+1][0]=(i+1)*7+1;
		count+=2;
	}
	
	//それぞれを素数判定する
	for(ll i=0;i*i<=count;i++){
		if(a[i][1]==0){
			for(int j=i+1;j<count;j++){
				if(a[j][0]%a[i][0]==0){
					a[j][1]=1;
				}
			}
		}
	}
	
	//素数の配列を作る
	ll count1=0;
	ll b[100000][2]={};
	for(ll i=0;i<count;i++){
		if(a[i][1]==0){
			b[count1][0]=a[i][0];
			count1++;
		}
	}
	
	ll n;
	while(cin>>n&&n!=1){
		cout<<n<<":";
		
		for(ll i=0;i<count1;i++){
			b[i][1]=0;
		}
		
		//素因数分解する
		for(ll i=0;i<count1;i++){
			if(n%b[i][0]==0){
				b[i][1]++;
				}
			}

		for(ll i=0;i<count1;i++){
			if(b[i][1]>0){
				cout<<" "<<b[i][0];
			}
		}
		
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 4288
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

bool dp[400005];

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n)cin >> a[i];
    dp[0] = 1;
    rep(i,n){
        for(int j=400000;j>=0;j--){
            if(dp[j])dp[j+a[i]] = true;
        }
    }
    int q;
    cin >> q;
    rep(_,q){
        int m;
        cin >> m;
        cout << (dp[m]?"yes":"no") << endl;
    }
}


Measured memory_bytes: 3180
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
using namespace std;

const int MOD = 1000000007;
typedef long long ll;

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

  int A,B,C;
  cin>>A>>B>>C;
  if( (A<C&&C<B)||(B<C&&C<A) ){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}

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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }


const string YES = "Yes";
const string NO = "No";

void func(std::string S, std::string T){

    T.pop_back();
    if(S==T)cout<<YES<<endl;
    else cout<<NO<<endl;
    

}

int main(){
    // cout << fixed << setprecision(5);

    std::string S;
    std::cin >> S;
    std::string T;
    std::cin >> T;
    func(S, T);
    return 0;
}


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

int main() {
    int N;  cin >> N;
    vector<long long> A(N), B(N);
    for (int i = 0; i < N; ++i) cin >> A[i] >> B[i];
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());

    long long ans;
    if (N % 2) ans =  B[N / 2] - A[N / 2] + 1;
    else ans = B[N / 2 - 1] + B[N / 2] - A[N / 2 - 1] - A[N / 2] + 1;
    cout << ans << endl;
}


Measured memory_bytes: 6428
N = input()

S = 'keyence'
if S == N[:len(S)]:
    print('YES')
elif S == N[-len(S):]:
    print('YES')
else:
    for index in range(len(S)):
        if S[:index] == N[:index] and S[-(len(S) - index):] == N[-(len(S) - index):]:
            print('YES')
            break
    else:
        print('NO')


Measured memory_bytes: 3060
words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)
ans = -1
for i in range(1,101):
    ttl = 0
    for x in xs:
        ttl += (i - x)**2
    if ans == -1:
        ans = ttl
    #print(i, ttl)
    ans = min(ans,ttl)
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  string O,E;
  cin >> O >> E;
  int o = 0;
  int e = 0;
  for(int i = 0; i < O.size() + E.size(); i++){
    if(i % 2 == 0){
      cout << O[o];
      o++;
    }
    else{
      cout << E[e];
      e++;    
    }
  }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
string s;
cin>>s;
ll n=s.size();
ll f=0;
ll a=0;
reverse(s.begin(),s.end());
for(ll i=0; i<n; i++){
a=n-i;
if(a<5){f++; break;}
if(a>6&&s.at(i)=='r'&&s.at(i+1)=='e'&&s.at(i+2)=='m'&&s.at(i+3)=='a'&&s.at(i+4)=='e'&&s.at(i+5)=='r'&&s.at(i+6)=='d'){
i=i+6;
continue;}
else if(s.at(i)=='m'&&s.at(i+1)=='a'&&s.at(i+2)=='e'&&s.at(i+3)=='r'&&s.at(i+4)=='d'){
i=i+4;
continue;}
else if(a>5&&s.at(i)=='r'&&s.at(i+1)=='e'&&s.at(i+2)=='s'&&s.at(i+3)=='a'&&s.at(i+4)=='r'&&s.at(i+5)=='e'){
i=i+5;
continue;}
else if(s.at(i)=='e'&&s.at(i+1)=='s'&&s.at(i+2)=='a'&&s.at(i+3)=='r'&&s.at(i+4)=='e'){
i=i+4;
continue;}
else{
f++;
break;}}
if(f==1){
cout<<"NO"<<endl;}
else
cout<<"YES"<<endl;}


Measured memory_bytes: 3692