akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int N,T;
  cin>>N>>T;
  VEC<pair<int,int>>p(N);
  REP(i,0,N){
    cin>>p[i].first>>p[i].second;

  }
  sort(ALL(p));
  REP(i,0,N){
    if(p[i].second<=T){
      cout<<p[i].first<<endl;
      return 0;
    }
  }
  cout<<"TLE"<<endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define m0(x) memset(x,0,sizeof(x))
#define chmax(a,b) if(b>a) a = b
#define chmin(a,b) if(b<a) a = b
typedef long long ll;
using namespace std;

using namespace std;


int main(){
        ios_base::sync_with_stdio(false); 
        cin.tie(NULL);
        char s; cin >> s;
        if(s - 'a' >= 0 && 'z' - s >= 0) cout << "a" << endl;
        else cout << "A" << endl;

        return 0;
}


Measured memory_bytes: 3608
import java.util.*;
//import java.util.Math.*;

public class Main {
    public static void main(String[] args) throws Exception {

    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int A[] = new int[n];
    int i;
    int count = 0;
    
    for(i = 0; i < n; i++){
        A[i] = sc.nextInt();
//        System.out.println(isprime(A[i]));
        if(isprime(A[i]) == true){
            count++;
        }
    }
 
    System.out.println(count);
    
    }
    
    public static boolean isprime(int x){
        int i = 0;
       // System.out.println(x);
        if(x == 2){
            return true;
        }else if((x % 2) == 0){
            return false;
        }else{
            i = 3;
            while(i <= Math.sqrt(x)){
                if((x % i) == 0){
                    return false;
                }
                i = i + 2;
            }
        }
        return true;
    }
}



Measured memory_bytes: 43040
N,L = map(int, input().split())

if L>0:
    print(L*N + N*(N+1)//2 - N - (L + 1 -1))
elif L < 1-N:
    print(L*N + N*(N+1)//2 - N - (L + N -1))
else:
    print(L*N + N*(N+1)//2 - N)


Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);

    while (in.hasNext()) {
      int A = in.nextInt();
      int B = in.nextInt();
      int C = in.nextInt();
      int maxAB = Math.max(A, B);
      int minAB = Math.min(A, B);

      if ( minAB < C && C < maxAB) {
        System.out.println("Yes");
      } else {
        System.out.println("No");
      }
    }
  }
}

Measured memory_bytes: 21844
import java.util.Scanner;
public class Main{
     
    public void solve(){
		Scanner sc = new Scanner(System.in);
		
		int W,H,x,y,r;
		W = sc.nextInt();
		H = sc.nextInt();
		x = sc.nextInt();
		y = sc.nextInt();
		r = sc.nextInt();
		
		if(x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }		
       public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
     }
}

Measured memory_bytes: 17348
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

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

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  int n, m; cin >> n >> m;
  vector<int> cnt(m+1);
  rep(i, n) {
    int k; cin >> k;
    while(k--) {
      int a; cin >> a;
      cnt[a]++;
    }
  }

  int ans = 0;
  for(int i=1; i<=m; i++) {
    if (cnt[i]==n) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(void) {
	int N, A;
	bool canpay = false;
	std::cin >> N;
	std::cin >> A;
	while(N >= 0) {
		if(N <= A) canpay = true;
		N -= 500;
	}
	std::cout << (canpay ? "Yes" : "No") << std::endl;
	return 0;
}

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

#define INF 1000000007

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;


int main() {
    int ans,S,W;
    cin >> S >> W;
    
    if(W>=S) cout << "unsafe";
    else cout << "safe";
    //printf("%.15lf", ans);
    cout << "\n";
    return 0;
}


Measured memory_bytes: 3676
a,b,x = map(int,input().split())
s = a*a*b

import math
if x<=s/2:
    ans = math.degrees(math.atan((a*b*b)/(2*x)))
else:
    ans = math.degrees(math.atan(2*(a*a*b-x)/(a**3)))
print(ans)


Measured memory_bytes: 62300
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

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

	long long m = n / (a + b);
	long long ans = m * a;
	long long tmp = n - m * (a + b);
	ans += min(tmp, a);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,m,h,w,i,j,d,a[501][501];
ll ans;
int main(){
	scanf("%d%d%d%d",&n,&m,&h,&w);
	d=(1-h*w)*1000-1;
	for(i=1;i<=n;i++)
	 for(j=1;j<=m;j++){
	  if(i%h==0&&j%w==0)a[i][j]=d;
	  else a[i][j]=1000;
	  ans+=a[i][j];
  }
  if(ans<=0)return puts("No"),0;
  puts("Yes");
  for(i=1;i<=n;i++,puts(""))
   for(j=1;j<=m;j++)printf("%d ",a[i][j]);
}


Measured memory_bytes: 2560
import math
n = int(input())

cos60 = math.cos(math.radians(60))
sin60 = math.sin(math.radians(60))


def koch(d, p1, p2):
    if d == 0:
        return
    s = [
        (2.0*p1[0]+1.0*p2[0])/3.0,
        (2.0*p1[1]+1.0*p2[1])/3.0
    ]
    t = [
        (1.0*p1[0]+2.0*p2[0])/3.0,
        (1.0*p1[1]+2.0*p2[1])/3.0
    ]
    u = [
        (t[0]-s[0])*cos60 - (t[1]-s[1])*sin60 + s[0],
        (t[0]-s[0])*sin60 + (t[1]-s[1])*cos60 + s[1]
    ]

    koch(d-1, p1, s)
    print(f"{s[0]} {s[1]}")
    koch(d-1, s, u)
    print(f"{u[0]} {u[1]}")
    koch(d-1, u, t)
    print(f"{t[0]} {t[1]}")
    koch(d-1, t, p2)
    return


print(f"{0} {0}")
koch(n, [0, 0], [100, 0])
print(f"{100} {0}")



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

#define N 2000

int compare(const void *a, const void *b) {
	int ia = *(int *) a;
	int ib = *(int *) b;

	return ia - ib;
}

int main() {
	static int ll[N];
	int n, i, j, k, ans;

	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &ll[i]);
	qsort(ll, n, sizeof *ll, compare);
	ans = 0;
	for (i = 0; i < n; i++)
		for (j = i + 1; j < n; j++)
			for (k = j + 1; k < n; k++) {
				int a, b, c;

				a = ll[i];
				b = ll[j];
				c = ll[k];
				if (c >= a + b)
					break;
				else if (b < c + a && a < b + c)
					ans++;
			}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll res[200005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    ll arr[n+2];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    for(ll i=0; i<=30; i++)
    {
        int a=0,b=0;
        ll p=(1LL<<i);
        for(int j=0; j<n; j++)
        {
            if((arr[j]&p))
            {
                b++;
            }
            else
                a++;
        }
        if(a%2==0)
        {
            for(int j=0; j<n; j++)
            {
                if((arr[j]&p))
                {
                    res[j] +=p;
                }

            }
        }
        else
        {
            for(int j=0; j<n; j++)
            {
                if((arr[j]&p))
                {

                }
                else
                    res[j] +=p;
            }
        }
    }
    for(int i=0;i<n;i++)
    {
        cout<<res[i]<<" ";
    }
    cout<<endl;
    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;
ll n, a[26], r;

int main() {
	cin >> s;
	n = (ll)s.length();
	rep(i,n) a[s[i]-'a']++;
	rep(i,26) r += a[i]*(a[i]-1)/2;
	r = n*(n-1)/2 - r + 1;
	cout << r << ln;
}

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

#define sz size

long long l, pos, ans, cnt;
string s;
int main() {
	//freopen("input.txt", "r", stdin);
	ios_base :: sync_with_stdio(0);
	cin >> s;
	for(int i = 0; i < s.sz(); ++i) {
		if(s[i] == 'B' && s[i + 1] == 'C') {
			ans += cnt;
			++i;
		}
		else {
			if(s[i] == 'A') ++cnt;
			else {
				cnt = 0;
			}
		}
	}
	cout << ans;
}

Measured memory_bytes: 720
#include "bits/stdc++.h"

#define ll long long
#define pb push_back
#define f first
#define s second

using namespace std;

ll n, res = 0;

vector<ll> fac(ll x){
    ll r = 1;
    vector<ll> ans;
    while(r < sqrt(x) + 1){
        if(x%r == 0){
            if(r != 1) ans.pb(r);
            if(r != x/r) ans.pb(x/r);
        }
        r++;
    }
    return ans;
}

int main(){
    cin >> n;
    res += fac(n - 1).size();
    ll r = 2;
    // for(auto i : fac(n - 1)){
        // cout << i << " ";
    // }
    // cout << res << " ";
    vector<pair<ll, ll>> ans;
    while(r < sqrt(n) + 1){
        if(n%r == 0){
            if(r > n/r) break;
            ans.pb({r, n/r});
        }
        r++;
    }
    // for(auto i : ans) cout << i.f << " ";
    for(int i = 0; i < ans.size(); ++i){
        while(ans[i].s%ans[i].f == 0){
            ans[i].s /= ans[i].f;
            // cout << ans[i].s << " ";
        }
        if(ans[i].s%ans[i].f == 1){
            res++;
            // cout << ans[i].f << " ";
        }
    }
    cout << res + 1;
    return 0;
}

Measured memory_bytes: 384
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;

int main()
{
    int N;
    cin >> N;
    int x = N * 800;
    int y = (N / 15) * 200;
    cout << x - y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int x;
bool prime[200001];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>x;
    memset(prime,true,sizeof(prime));
    for (int p=2;p<=200000;p++){
        if (prime[p]){
            if (p>=x){
                cout<<p;
                return 0;
            }
            for (int i=p*2;i<=200000;i+=p){
                prime[i]=false;
            }
        }
    }
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

using Pll = pair<ll, ll>;

struct Vert {
	Vi edges;
	ll cnt, minSum, maxSum;
	int has;
};

int n;
vector<Vert> G;

ll matching(vector<Pll>& opt, ll lvl) {
	ll sum = 0, leader = 0;

	each(p, opt) {
		ll k = 0;

		if (p.x >= lvl) {
			k = p.x;
		} else if (p.y <= lvl) {
			k = p.y;
		} else {
			k = p.x + (lvl-p.x) / 2 * 2;
		}

		sum += k;
		leader = max(leader, k);
	}

	if (leader*2 <= sum) {
		return sum % 2;
	}
	return leader - (sum - leader);
}

void dfs(int v, int p) {
	G[v].cnt = G[v].has;
	G[v].maxSum = 0;

	vector<Pll> tmp;
	ll lvl = 0;

	each(e, G[v].edges) if (e != p) {
		dfs(e, v);
		ll lower = G[e].minSum + G[e].cnt;
		ll upper = G[e].maxSum + G[e].cnt;

		G[v].cnt += G[e].cnt;
		G[v].maxSum += upper;
		tmp.pb({lower, upper});
		lvl = max(lvl, lower);
	}

	G[v].minSum = min(matching(tmp, lvl), matching(tmp, lvl+1));
}

ll solve(int root) {
	dfs(root, -1);
	if (G[root].minSum > 0) return INT64_MAX;
	assert(G[root].maxSum % 2 == 0);
	return G[root].maxSum / 2;
}

void run() {
	cin >> n;
	G.resize(n);

	string s; cin >> s;
	rep(i, 0, n) G[i].has = (s[i] == '1');

	rep(i, 1, n) {
		int a, b; cin >> a >> b;
		G[a-1].edges.pb(b-1);
		G[b-1].edges.pb(a-1);
	}

	ll ans = INT64_MAX;
	rep(i, 0, n) ans = min(ans, solve(i));
	cout << (ans == INT64_MAX ? -1 : ans) << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>

//エイリアス
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};



int main(){
    Stream io;

    ll N;
    io.read(N);
    auto A = io.read_vec<ll>(N);

    ll ans = 0;
    for(int i = 1; i < N; i++){
        ll dif = A[i - 1] - A[i];
        if(dif > 0) {
            ans += dif;
            A[i] = A[i - 1];
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 4780
import sys
input = sys.stdin.buffer.readline
 
def main():
    N = int(input())
    p = list(map(int,input().split()))
    
    a = [N*i+1 for i in range(N)]
    b = [N*(N-i-1)+1 for i in range(N)]

    for i,num in enumerate(p):
        a[num-1] += i
        
    print(*a)
    print(*b)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 6220
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
#define pb push_back
#define fi first
#define se second
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
template <class T, class U> ostream &operator<<(ostream &os, const pair<T, U> &p){os<<"("<<p.first<<","<< p.second<<")";return os;}
template <class T> ostream &operator<<(ostream &os, const vector<T> &v){os<<"{";REP(i,(int)v.size()){if(i)os<<",";os<<v[i];}os<<"}";return os;}
template <typename T, size_t S> void printArray(const T (&array)[S]){for(auto val : array)std::cout << val << ", ";std::cout << "\n";}
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}
const double PI=acos(-1);
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;
//const int dx[4] = {1, 0, -1, 0};
//const int dy[4] = {0, 1, 0, -1};
//const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
//const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve(){
    string s; cin >> s;
    ll n = s.size();
    ll sum = 0;
    REP(i, n) sum += s[i] - '0';
    ll res = s[0] - '0' + (n-1)*9;
    if(sum == res) cout << res << endl;
    else cout << res - 1 << endl;
}

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

Measured memory_bytes: 256
H, W, K = map(int, input().split())
C = [input() for _ in range(H)]

ans = 0

from itertools import product
for b_h in product((True, False), repeat=H):
  for b_w in product((True, False), repeat=W):
    count = 0
    for i in range(H):
      for j in range(W):
        if b_h[i] and b_w[j] and C[i][j] == '#':
          count += 1
    if count == K:
      ans += 1

print(ans)


Measured memory_bytes: 9176
import java.util.*;
import java.io.PrintWriter;
public class Main{
	static long[] dp;
	static int[][] a;
	static int n;
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		n=sc.nextInt();
		dp=new long[1<<n];
		Arrays.fill(dp,-1);
		a=new int[n][n];
		for(int i=0; i<n; i++){
			for(int j=0; j<n; j++){
				a[i][j]=sc.nextInt();
			}
		}
		System.out.println(dfs((1<<n)-1));
	}
	static long dfs(int bit){
		if(dp[bit]!=-1){
			return dp[bit];
		}
		long re=0;
		for(int i=0; i<n; i++){
			for(int j=i+1; j<n; j++){
				if((1&bit>>i)==1 && (1&bit>>j)==1){
					re+=a[i][j];
				}
			}
		}
		for(int i=(bit-1)&bit; i>0; i=(i-1)&bit){
			re=Math.max(re,dfs(i)+dfs(bit^i));
		}
		return dp[bit]=re;
	}
}


Measured memory_bytes: 25340
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int hon = scan.nextInt();
		int arugo = scan.nextInt();
		int min = scan.nextInt();
		int[] nedan = new int[hon];
		int[][] array = new int[hon][arugo];

		boolean flg = false;

		for(int i=0;i<hon;i++) {
			 nedan[i] = scan.nextInt();
			for(int j=0;j<arugo;j++) {
				array[i][j] = scan.nextInt();

			}
		}

		int[] aTmp = new int[arugo];
		int costTmp = 0;
		List<Integer> costSave = new ArrayList<>();

		//bit探索の全通り
		for(int i=0;i< 1<<hon ;i++) {
			//１ループ毎にどの参考書を買うかの判定
			for(int j=0;j<hon;j++) {
				//ここに引っかかる = 買う対象に追加（j冊目購入）
				if((1 & i >> j) == 1) {
					for(int h=0;h<arugo;h++) {

					//j冊目の参考書を買ったときのarugo番目のアルゴリズムの理解度上昇
						aTmp[h] += array[j][h];
				}
					//j冊目の値段
					costTmp += nedan[j];
				}
			}

			//参考書を買い終わったのでアルゴリズムを覚えたかの判定の上、値段を保持

			for(int h =0;h<arugo;h++) {
				if(aTmp[h] < min) {
					//アルゴリズム一つも覚えてない
					flg = false;
					break;
				}
			}

			if(flg) {
				//合計値段を一時格納
				costSave.add(costTmp);
			}

			//後始末
			for(int h=0;h<arugo;h++) {
				aTmp[h]=0;
			}
			costTmp = 0;
			flg = true;

		}

		//listのうち最小の値を出力、リストがnullなら-1を出力
		int re = Integer.MAX_VALUE;
		if(costSave.isEmpty()) {
			re = -1;
		}else {
			for(int cost:costSave) {
				if(re > cost) {
					re = cost;
				}
			}
		}

		System.out.println(re);

		scan.close();

	}

}


Measured memory_bytes: 28760
#include"bits/stdc++.h"
using namespace std;
int main()
{
    // 整数の入力
    int n;
    cin >> n;
    int p[20];
    // スペース区切りの整数の入力
    for(int i=0;i<n;i++)
    {
        cin >> p[i];
    }
    int cnt = 0;
    for(int i=1;i<n-1;i++)
    {
        if(p[i]>p[i-1] && p[i]<p[i+1])
        {
            cnt++;
        }
        else if(p[i]<p[i-1] && p[i]>p[i+1])
        {
            cnt++;
        }
    }
    
    // 出力
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env pypy3

from sys import stdin, stdout
 
def input():
    return stdin.readline().strip()

N, K = input().split(' ')
N = int(N)
K = int(K)
A = input().split(' ')
A = list(map(int, A))

for i in range(N-K):
    a = A[i]
    b = A[i+K]

    if b > a:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 93428
package main

import (
	"fmt"
)

func main() {
	var S string
	fmt.Scan(&S)
	center := make([]string, len(S))
	for i, c := range []rune(S) {
		center[i] = string(c)
	}
	var Q int
	fmt.Scan(&Q)
	pre, epi := []string{}, []string{}
	reverseCount := 0
	for i := 0; i < Q; i++ {
		var T int
		fmt.Scan(&T)
		if T == 1 {
			reverseCount += 1
		} else {
			var F int
			var C string
			fmt.Scan(&F, &C)
			if F == 1 {
				if reverseCount%2 == 0 {
					// preが前
					pre = append(pre, C)
				} else {
					// epiが前
					epi = append(epi, C)
				}
			} else {
				if reverseCount%2 == 1 {
					// preが前
					pre = append(pre, C)
				} else {
					// epiが前
					epi = append(epi, C)
				}
			}
		}
	}

	// 答え構築 反転を考慮に入れる
	if reverseCount%2 == 0 {
		oldSkoolFuckinAdHocReverseForAtCoderGolangVer(pre)
		for _, p := range pre {
			fmt.Print(p)
		}
		for _, c := range center {
			fmt.Print(c)
		}
		for _, e := range epi {
			fmt.Print(e)
		}
	} else {
		oldSkoolFuckinAdHocReverseForAtCoderGolangVer(epi)
		oldSkoolFuckinAdHocReverseForAtCoderGolangVer(center)
		for _, e := range epi {
			fmt.Print(e)
		}
		for _, c := range center {
			fmt.Print(c)
		}
		for _, p := range pre {
			fmt.Print(p)
		}
	}
	// atcoderでは改行を無視してくれるけど一応流儀に則って
	fmt.Println()
}

func oldSkoolFuckinAdHocReverseForAtCoderGolangVer(arr []string) {
	for i, j := 0, len(arr)-1; i < j; i, j = i+1, j-1 {
		arr[i], arr[j] = arr[j], arr[i]
	}
}


Measured memory_bytes: 18304
#include <iostream>
#include <functional>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <string>
#include <vector>
#include <array>
#include <memory>

using namespace std;

#define Get(ty,...) ty __VA_ARGS__;cins(__VA_ARGS__);
#define GetArray(ty,v,n) vector<ty> v(n);cin_arr(v,n);
#define ci cin
#define co cout
#define en endl;
#define Arr(f, arr,pred) f(arr.begin(),arr.end(),pred)
#define ArrExpr(f, arr,expr) f(arr.begin(),arr.end(),[](auto x){return expr;})
#define Acc(init,arr,pred) accumulate(arr.begin(),arr.end(),init,pred)

void cins(){}

template<class Head,class... Tail>
void cins(Head& head,Tail&... tail) {
	cin >> head;
	cins(tail...);
}

template<class Arr>
void cin_arr(Arr& v,int n) {
	for (int i = 0; i < n; i++)
		cin >> v[i];
}

unique_ptr< array<int, 3>> maxList;
array<int, 3> valueList = {500,100,50};
int X;

int sum(const array<int, 3> & abc) {
	int sum = 0;
	for (int i = 0; i < 3; i++)
		sum += abc[i] * valueList[i];
	return sum;
}

int calc(array<int, 3> abc, int idx) {
	if (idx == -1)
		return sum(abc) == X ? 1 : 0;
	int countTotal = 0;
	for (int i = 0; i <= (*maxList)[idx]; i++) {
		abc[idx] = i;
		countTotal += calc(abc, idx - 1);
	}
	return countTotal;
}

int main() {
	Get(int, a, b, c, x);
	maxList = unique_ptr<array<int, 3>>(move(new array< int, 3> {a, b, c}));
	X = x;
	co << calc({ 0,0,0 }, 2) << en
}



Measured memory_bytes: 256
from itertools import permutations

def c():
    n = int(input())
    points = []
    paths = permutations(range(n), n)

    for i in range(n):
        x, y = map(int, input().split())
        points.append((x, y))

    dist = [[float('inf') for _ in range(n)] for _ in range(n)]

    for i in range(n):
        for j in range(i+1, n):
            d = ((points[i][0] - points[j][0]) ** 2 + (points[i][1] - points[j][1]) ** 2) ** 0.5
            dist[i][j] = d
            dist[j][i] = d

    sum_length = 0
    count = 0
    for path in paths:
        count += 1
        for i in range(1, len(path)):
            sum_length += dist[path[i-1]][path[i]]

    print(sum_length / count)

if __name__ == '__main__':
    c()

Measured memory_bytes: 39024
#include <stdio.h>
int main()
{
	int r, c, i, j;
	scanf("%d %d", &r, &c);
	int a[r+1][c+1];
	for(i=0; i<r; i++){
		for(j=0; j<c; j++){
			scanf("%d", &a[i][j]);
			a[r][j]=0;
		}
		a[i][c]=0;
	}
	a[r][c]=0;
	for(i=0; i<r; i++){
		for(j=0; j<c; j++){
			a[i][c]+=a[i][j];
		}
	}
	for(j=0; j<c; j++){
		for(i=0; i<r; i++){
			a[r][j]+=a[i][j];
		}
	}
	for(i=0; i<r; i++){
		a[r][c]+=a[i][c];
	}
	for(i=0; i<r+1; i++){
		for(j=0; j<c+1; j++){
			if(j==c){
				printf("%d", a[i][j]);
			} else {
				printf("%d ", a[i][j]);
			}
		}
		printf("\n");
	}
	return 0;
}

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

// dp[i][j][k] : i行目、j列目で、現在の行で k 個拾った場合の価値の合計
ll dp[3003][3003][4];
ll val[3003][3003];

int main(){
  int R,C,K;
  cin >> R >> C >> K;
  REP(i,K) {
    int r,c;
    ll v;
    cin >> r >> c >> v;
    r--, c--;
    val[r][c] = v;
  }
  dp[0][0][1] = val[0][0];
  REP(i,R) REP(j,C) REP(k,4) {
    dp[i+1][j][0] = max( dp[i+1][j][0], dp[i][j][k] );
    dp[i+1][j][1] = max( dp[i+1][j][1], dp[i][j][k] + val[i+1][j] );
    dp[i][j+1][k] = max( dp[i][j+1][k], dp[i][j][k] );
    if ( k != 3 )
      dp[i][j+1][k+1] = max( dp[i][j+1][k+1], dp[i][j][k] + val[i][j+1] );
  }
  ll ans = 0;
  REP(i,4) ans = max( ans, dp[R-1][C-1][i] );
/*  
  REP(i,4) {
    REP(j,4) {
      cout << val[i][j] << " ";
    }
    cout << endl;
  }
  REP(i,4) {
    REP(j,4) {
      REP(k,4) cout << dp[i][j][k] << " ";
      cout << "  ";
    }
    cout << endl;
  }
  */
  cout << ans << endl;
}


Measured memory_bytes: 355504
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.io.IOException;
import java.util.NoSuchElementException;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CDistinctOrNot solver = new CDistinctOrNot();
        solver.solve(1, in, out);
        out.close();
    }

    static class CDistinctOrNot {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            ArrayList<Integer> list = new ArrayList<>();
            while (in.hasNext()) {
                list.add(in.nextInt());
            }
            boolean contain = (list.size() == new HashSet<>(list).size());
            String ret = contain ? "YES" : "NO";
            out.println(ret);
        }

    }

    static class Scanner {
        private final InputStream in;
        private final byte[] buffer;
        private int ptr;
        private int buflen;

        public Scanner(InputStream in) {
            this.in = in;
            this.buffer = new byte[1024];
            this.ptr = 0;
            this.buflen = 0;
        }

        private boolean hasNextByte() {
            if (ptr < buflen) return true;
            else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) return false;
            }
            return true;
        }

        private byte readByte() {
            if (hasNextByte()) return buffer[ptr++];
            return -1;
        }

        private boolean isPrintableChar(byte c) {
            return '!' <= c && c <= '~';
        }

        private void skipUnprintable() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
        }

        public boolean hasNext() {
            skipUnprintable();
            return hasNextByte();
        }

        public int nextInt() {
            if (!hasNext()) throw new NoSuchElementException();
            int n = 0;
            boolean minus = false;
            byte b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 35888
def mod2019(x, y):
    return (x%2019 * y%2019 ) % 2019

L,R = list(map(int, input().split()))
ans=2019
s=set()
for i in range(L,R+1):
    if i%2019 in s:
        break
    s.add(i%2019)
l = list(s)
for i in range(len(l)):
    for j in range(i+1, len(l)):
#        print(i, j, l[i], l[j], mod2019(l[i], l[j]))
        ans=min(ans, mod2019(l[i], l[j]))
    
print(ans)

Measured memory_bytes: 3188
#include <iostream>
using namespace std;
long long N, K, i, t, a, b;
long long arr[100001] = {0};
int main() {
    cin >> N >> K;
    for(i = 0; i < N; i++) {
        cin >> a >> b;
        arr[a] += b;
    }
    for(i = 1, t = 0; i <= 100001; i++) {
        t += arr[i];
        if(t >= K) {cout << i; break;}
    }
}

Measured memory_bytes: 1024
h, w = map(int, input().split())
a = []
for i in range(h):
    a.append(list(map(int, input().split())))
    a[i]+=[sum(a[i])]
    print(*a[i])
a=list(zip(*a[::-1]))
for i in range(w):
    print(sum(a[i]),end=' ')
print(sum(a[w]))


Measured memory_bytes: 5772
import java.util.*;

public class Main {

    static final int MOD = 1000000007;

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),d=sc.nextInt();
        System.out.println(Math.min(a,b)+Math.min(c,d));
    }
}


Measured memory_bytes: 21844
#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>;
int main(int argc, const char * argv[]) {



    cin.tie(0);
    ios::sync_with_stdio(false);

    int a,b,c;
    cin>>a>>b>>c;
    if(a+b==c||a+c==b||b+c==a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3632
def main():
    import sys

    def input(): return sys.stdin.readline().rstrip()

    n = int(input())
    c, s, f = [], [], []
    for i in range(n-1):
        ci, si, fi = map(int, input().split())
        c.append(ci)
        s.append(si)
        f.append(fi)
    ans = [0]*n
    
    for i in range(n-1):
        for j in range(i,n-1):
            ans[i] = max(ans[i]+(-ans[i]%f[j]), s[j])
            ans[i] += c[j]
    for x in ans:
        print(x)
        
            
                

             
            
        
    
if __name__ == '__main__':
    main()

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

using ll = long long;

map<ll, ll> primeFactor(ll n){
  map<ll, ll> res;
  for(ll i = 2LL; i*i<=n; i++){
    while (n%i == 0LL){
      res[i]++;
      n /= i;
    }
  }
  if (n != 1) res[n] = 1;
  return res;
}

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

  map<ll, ll> primeFactors = primeFactor(N);

  ll ans = 0LL;
  for (auto factor: primeFactors){
    ll count = factor.second;
    ll i = 0;
    while (count>0) {
      i++;
      count -= i;
      if (count>=0){
        ans++;
      }
    }
  }

  cout << ans << endl;

  return 0;
}

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

int main() {
    int a, b, c; cin >> a >> b >> c;
    int maxv = max(max(a, b), c);

    int ans = 0;
    if (maxv % 2 == (a + b + c) %2 )
        ans = (3 * maxv - (a+b+c)) /2;
    else 
        ans = (3 *(maxv+1) -(a+b+c)) / 2;

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int N;
  cin>>N;
  VI A(N-1),B(N-1);
  rep(i,N-1) cin>>A[i]>>B[i];
  VVI AB(N,VI(0));
  rep(i,N-1){
    AB[A[i]-1].push_back(B[i]-1);
    AB[B[i]-1].push_back(A[i]-1);
  }
  VVI X(N+1,VI(0));
  VI C(N);
  X[0].push_back(0);
  C[0]=1;
  rep(i,N+1){
    rep(j,X[i].size()){
      rep(k,AB[X[i][j]].size()){
        if(C[AB[X[i][j]][k]]==0){
          X[i+1].push_back(AB[X[i][j]][k]);
          C[AB[X[i][j]][k]]=1;
        }else{
          AB[X[i][j]][k]=-1;
        }
      }
    }
  }
  /*rep(i,N){
    rep(j,AB[i].size()){
      cout<<AB[i][j]<<" ";
    }
    cout<<endl;
  }
  cout<<endl;*/
  VI Y(N);
  rep(i,N) Y[i]=-1;
  map<P,int> M;
  rep(i,N){
    if(X[i].size()==0) break;
    else{
      rep(j,X[i].size()){
        if(Y[X[i][j]]>=0){
          int tmp=1;
          rep(k,AB[X[i][j]].size()){
            if(AB[X[i][j]][k]!=-1){
              if(tmp==Y[X[i][j]]){
                tmp++;
              }
              M[make_pair(X[i][j],AB[X[i][j]][k])]=tmp;
              M[make_pair(AB[X[i][j]][k],X[i][j])]=tmp;
              Y[AB[X[i][j]][k]]=tmp;
              tmp++;
            }
          }
        }else{
          int tmp=1;
          rep(k,AB[X[i][j]].size()){
            if(AB[X[i][j]][k]!=-1){
              M[make_pair(X[i][j],AB[X[i][j]][k])]=tmp;
              M[make_pair(AB[X[i][j]][k],X[i][j])]=tmp;
              Y[AB[X[i][j]][k]]=tmp;
              tmp++;
            }
          }
        }
      }
    }
  }
  int ans=1;
  rep(i,N-1){
    if(ans<M[make_pair(A[i]-1,B[i]-1)]){
      ans=M[make_pair(A[i]-1,B[i]-1)];
    }
  }
  cout<<ans<<endl;
  rep(i,N-1){
    cout<<M[make_pair(A[i]-1,B[i]-1)]<<endl;
  }
}

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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


auto solve() {
    int n, m;
    cin >> n >> m;
    int L = n - 1 + m;
    vi A(L), B(L);
    vector<vi> edges(n);
    vi in(n, 0);
    REP(i, L) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        edges[A[i]].push_back(B[i]);
        in[B[i]]++;
    }

    queue<int> que;
    REP(i, n) {
        if (in[i] == 0)
            que.push(i);
    }

    vi ary;
    vector<bool> vis(n, false);
    while (!que.empty()) {
        int cur = que.front();
        que.pop();

        ary.push_back(cur);
        for (auto &&t : edges[cur]) {
            in[t]--;
            if (in[t] == 0)
                que.push(t);
        }
    }

    vi new_tree_map(n);
    REP(i, n) {
        new_tree_map[ary[i]] = i;
    }

    vi par(n, -1);
    REP(i, L) {
        int ma = new_tree_map[A[i]];
        int mb = new_tree_map[B[i]];
        par[mb] = max(par[mb], ma);
    }

    vi ans(n);
    REP(i, n) {
        if (par[i] == -1)
            ans[ary[i]] = 0;
        else
            ans[ary[i]] = ary[par[i]] + 1;
    }

    for(auto&&e: ans)
        cout << e << endl;
}


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

//    cout << (solve() ? "Yes" : "No") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
//    cout << solve() << endl;
    solve();

    return 0;
}


Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define endl              "\n"
#define pb              push_back
#define fir               first
#define sec               second
#define all(v)            ((v).begin()), ((v).end())
#define sz(v)            ((int)((v).size()))
#define ll              long long
#define ld              long double
#define lp(i, n)        for(int i = 0 ; (int)i<n ; i++)
#define loop(i, x, n)       for(int i=x ; (int)i<=n ; i++)
#define isPowerOfTwo(s) (!(s & (s-1)))
typedef vector<int> vi;
typedef deque<int> de;
void origi() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
}
vector<int>arr;
void tiranga() {
    int n;
    cin >> n;
    map<vector<int> , int>vec;
    string s;
    ll res = 0;
    lp(i, n) {
        vector<int>temp(26,0);
        cin >> s;
        lp(r, s.length())
            temp[s[r] - 'a']++;
        res += vec[temp]++;
    }
    cout << res;
}
int main() {
#ifndef ONLINE_JUDGE.
    //freopen("input.txt", "r", stdin);
#else
#endif
    
    origi();
    tiranga();
    //cout << sumOfDig(123654);
   // genLarge(10, 10);
   // genSmall(10);

}


Measured memory_bytes: 19072
#include <stdio.h>
#include <vector>
#include <iostream>
using namespace std;

struct Route {
    int l, r;
};

int main(void){
    int islandNum, routeNum;
    cin >> islandNum >> routeNum;
    
    vector<Route> routes(routeNum);
    Route tmp;
    for (int i=0; i<routeNum; i++) {
        cin >> tmp.l >> tmp.r;
        routes[i] = tmp;
    }
    
    vector<bool> island(islandNum, false);
    
    for (int i=0; i<routeNum; i++) {
        if (routes[i].l == 1) island[routes[i].r-1]=true;
    }
    
    for (int i=0; i<routeNum; i++) {
        if (routes[i].r == islandNum && island[routes[i].l-1]) {
            cout << "POSSIBLE";
            return 0;
        }
    }
    cout << "IMPOSSIBLE";
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
#include<random>

//by Skeef79

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

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>
#define what_is(x) cout<<#x<<" is "<<x<<en;

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

void solve()
{
	string s;
	cin >> s;
	if (s.length() % 2)
	{
		cout << "No";
		return;
	}
	for (int i = 0; i < s.length(); i += 2)
		if (s[i] == 'h' && s[i + 1] == 'i')
			continue;
		else
		{
			cout << "No";
			return;
		}
	cout << "Yes";
}

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

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();

}

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

int main() {

    string s;
    cin >> s;

    s[3] = '8';

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 3604
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}
double cal(ll v) {

	double res = 0;
	while (v > 0)
	{
		res += v % 10;
		v /= 10;
	}
	return res;
}

void solv() {
	string s;
	cin >> s;
	int f = 0;
	int e = s.size() - 1;
	int c = 0;
	while (f <= e)
	{
		if (s[f] == s[e]) {
			f++;
			e--;
		}
		else if (s[f] == 'x') {
			f++;
			c++;
		}
		else if (s[e] == 'x') {
			e--;
			c++;
		}
		else {
			cout << -1 << endl;
			return;
		}

	}
	cout << c << endl;

}


int main() {
	solv();

	return 0;
}


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

class A
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		Console.ReadLine();
		var s = Read();
		Console.ReadLine();
		var t = Read();
		Console.WriteLine(s.Intersect(t).Count());
	}
}



Measured memory_bytes: 33652
s = input()
long_s = len(s)
form = "0"+str(long_s-1)+"b"
result = 0
for i in range(2**(long_s-1)):
    ev = s[0]
    b = format(i, form)
    for j in range(1, long_s):
        if b[j-1] == "1":
            ev = ev+"+"+s[j]
        else:
            ev = ev+s[j]
    result += eval(ev)
print(result)

Measured memory_bytes: 3188
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, inp;
map<int, int> m;

signed main() {
    cin >> N;

    rep(i,0,N) {
        cin >> inp;
        m[inp]++;
    }

    int ans = 0;
    for(auto x : m) if(x.second % 2) ans++;
    cout << ans << endl;
    return 0;
}

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

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

  int ans = 0;
  for (int i = 1; i <= N; i += 2) {
    int count = 0;
    for (int j = 1; j <= i; j += 2) {
      if (i % j == 0) count++;
    }
    if (count == 8) ans++;
  }

  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1e5 + 100;
int f[INF];
int main()
{
    int n, a;
    cin >> n;
    memset(f, 0, sizeof(f));
    for (int i = 2; i <= n; i++) {
        a = i;
        for (int j = 2; j <= a; j++) {
            while (a % j == 0) {
                f[j]++;
                a = a / j;
            }
        }
        if (a != 1)
            f[a]++;
    }
    ll ans = 1;
    for (int i = 1; i <= n; i++) {
        if (f[i] != 0)
            ans = (ans * (f[i] + 1)) % MOD;
    }
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 640