akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main{
  public static void main(String[] args)
  {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int [] a=new int[n];
    String s=sc.next();
    for(int i=0;i<n;i++)
    {
      char c=s.charAt(i);
      if(c=='W')
      {
        a[i]=1;
      }
      else
      {
        a[i]=0;
      }
    }
    int x=0,y=n-1,c=0;
    while(x<y)
    {
      while(x<n && a[x]==0)
      {
          x++;
      }
      while(y>=0 && a[y]==1)
      {
        y--;
      }
      if(x<n && y<n && x<y)
      {
      int temp=a[x];
      a[x]=a[y];
      a[y]=temp;
       
      x++;
      y--;
         c++;
      }
     
    }
    System.out.println(c);
  }
}
        

Measured memory_bytes: 41660
n=int(input())
T=[]
ans=0
for _ in range(n):
    s=int(input())
    ans+=s
    if s%10:
        T.append(s)
T.sort()
if ans%10==0:
    if T:
        ans-=T[0]
    else:
        ans=0
print(ans)

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

int main(){
    int a,b,cnt=0;
    cin >> a >> b;
    for(int i=a;i<=b;i++)
        if(((i/10000)==i%10)&&((i/1000)%10==(i/10)%10))
            cnt++;
    cout << cnt << endl;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using ch = char;
using db = double;
using bl = bool;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vch = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (ll i = (ll)(m); i < (ll)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
const ll mod = 1000000007;
const ll inf = 1LL << 60;
const db pi = acos(-1.0L);

int main(){
  ll n, m;
  cin >> n >> m;
  if(n % 2 == 1){
    rep(i, 0, m){
      cout << 1 + i << " " << n - 1 - i << endl;
    }
  }
  else if(n % 4 == 0){
    rep(i, 0, min(m, n / 4)){
      cout << n / 2 - i << " " << n / 2 + 1 + i << endl;
    }
    rep(i, 0, m - min(m, n / 4)){
      cout << 1 + i << " " << n - 1 - i << endl;
    }
  }
  else {
    rep(i, 0, min(m, n / 4)){
      cout << n / 2 - i << " " << n / 2 + 1 + i << endl;
    }
    rep(i, 0, m - min(m, n / 4)){
      cout << 1 + i << " " << n - 1 - i << endl;
    }
  }
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int main(void){
    int a, b; cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++){
        string s = to_string(i);
        if(s[0] == s[4] and s[1] == s[3])  ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#ifndef err
#define err(...)(void)0
#endif
using namespace std;
using ll = long long;
using ull = decltype(1ull);
template<class T>int size(T&&a) { return a.size(); }
#define REP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.first,_l##t=a.second;t<_l##t;t++)
#define RREP(t,a)for(typename make_signed<decltype(a.second)>::type t=a.second-1,_l##t=a.first;t>=_l##t;t--)
template<class B>pair<int, B>make_pair(B b) { return{ 0,b }; }
#define rep(t,...)REP(t,make_pair(__VA_ARGS__))
#define rrep(t,...)RREP(t,make_pair(__VA_ARGS__))
#define all(a)begin(a),end(a)
#define rall(a)a.rbegin(),a.rend()
#define var(t, ...) t __VA_ARGS__;in,__VA_ARGS__;

void Calc();
int main() {
  ios::sync_with_stdio(false); cin.tie(nullptr);
  cin.exceptions(istream::failbit | istream::badbit);
  cout << fixed << setprecision(15); Calc(); cout.flush(); return 0;
}
template<class A>void amax(A&a, A b) { a = max(a, b); }
template<class A>void amin(A&a, A b) { a = min(a, b); }
template<class A>int comp(A a, A b) { return a < b ? 1 : b < a ? -1 : 0; }
struct Scanner {
  template<class A = string>A Next() { A a; cin >> a; return a; }
  template<class A = int>vector<A>Array(int n) { vector<A>a(n); for (A&i : a) cin >> i; return a; }
  string Line() const { string s; getline(cin, s); return s; }
  template<class A>Scanner&operator,(A&a) { a = Next<A>(); return *this; }
  template<class A>operator A() { return Next<A>(); }
}in;

/*---------------------------------------------------------------------*/


void Calc() {

  var(int, h, w);
  vector<string> v = in.Array<string>(h);
  map<char, int> m, x;
  for (auto& i : v) {
    for (auto& j : i) {
      m[j]++;
    }
  }
  if (h == 1 || w == 1) {
    int cnt = 0;
    for (auto& i : m) {
      if (i.second % 2) {
        cnt++;
      }
    }
    if (cnt == 0) {
      cout << ("Yes") << endl;
    }
    else if (cnt > 1) {
      cout << ("No") << endl;
    }
    else {
      if (h & 1 && w & 1) {
        err("tweet", "z");
        cout << ("Yes") << endl;
      }
      else {
        cout << ("No") << endl;
      }
    }
    return;
  }
  err(v);
  int cnt = 0;
  bool e = h & 1 && w & 1;
  if (e) {
    cnt += h - 1 + w - 1;
  }
  else if (w & 1 || h & 1) {
    if (h & 1)cnt += w;
    else cnt += h;
  }

  for (auto& i : m) {
    if ((i.second % 4) != 0) {
      err(i);
      int a = i.second % 4;
      if (h & 1 || w & 1) {
        if (cnt) {
          cnt -= a / 2 * 2;
          a %= 2;
        }
      }
      if (a)
        x[i.first] = a;
    }
  }

  if (x.size()) {
    err(x);
    if (e) {
      if (x.size() == 1 && x.begin()->second == 1) {
        cout << ("Yes") << endl;
        return;
      }
    }
    cout << ("No") << endl;
  }
  else {
    cout << ("Yes") << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, ans=0;
    double t, a, mi = 10000;
    cin >> n >> t >> a;
    REP(i,n){
        double h;
        cin >> h;
        if(abs(a-(t-h*0.006))<mi){
            mi = abs(a-(t-h*0.006));
            ans = i+1;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
h,w = list(map(int,input().split()))
c = [list(map(int,input().split())) for i in range(10)]
a = [list(map(int,input().split())) for i in range(h)]

def warshallFloyd(num_v,am):
    """
    ワーシャルフロイド。All Pairs Shortest Path. APSP
    O(|V|^3)
    Parameters
    ----------
    num_v : int
        Number of nodes
    am : list[list[int]]
        adjacency matrix

    Returns
    -------
    list[list[int]]
        matrix of APSP

    """
    from math import isinf
    from copy import copy
    ret = copy(am)
    for k in range(num_v):
        for i in range(num_v):
            if isinf(ret[i][k]):
                continue
            for j in range(num_v):
                if isinf(ret[k][j]):
                    continue
                ret[i][j]=min(ret[i][j],ret[i][k]+ret[k][j])
    return ret

#隣接行列

wrsh_matrix = warshallFloyd(10,c)
ret = 0
for i in a:
    for j in i:
        if j < 0:
            continue
        ret += wrsh_matrix[j][1]
print(ret)

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n, m) for (int (i) = (n); (i) < (m); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};

const ll INF = 1e18;
ll N, M, dist[1010];
vec<pair<ll, ll>> G[3000];

int main() {
   cin >> N >> M;
   for (int i = 0; i < M; i++) {
      int a, b, c;
      cin >> a >> b >> c;
      a--, b--;
      G[a].push_back({b, c});
   }

   for (int i = 0; i < N; i++) {
      dist[i] = -INF;
   }

   dist[0] = 0;
   ll P = dist[N-1];
   for (int i = 0; i < 8*N; i++) {
      for (int j = 0; j < N; j++) {
         for (pair<ll, ll> k : G[j]) {
            dist[k.first] = max(dist[k.first], dist[j] + k.second);
         }
      }
      if (P != dist[N-1] && i >= 5*N) {
         cout << "inf" << endl;
         return 0;
      }
      P = dist[N-1];
   }
   cout << dist[N-1] << endl;

   return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int S[1000000],n;

int Search(int key);

int main(){
  int i,q,k,s = 0;

  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&S[i]);


  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(Search(k))s++;
  }
  printf("%d\n",s);

  return 0;
}

int Search(int key){
  int left = 0;
  int right = n;
  int mid;

  while(left<right){
    mid = (left + right)/2;
    if(key == S[mid])  return 1;
    if(key>S[mid])  left = mid +1;
    else if(key<S[mid])right=mid;
  }
  return 0;
}



Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
int main(){
  map<char,int> dic;
  char tmp;
  int cnt=0;
  while(cin>>tmp){
    dic[tmp]++;
    cnt++;
  }
  if(cnt==dic.size())cout <<"yes"<<endl;
  else cout <<"no"<<endl;
}

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


int parent[100005];
int sz[100005];
int mm[100005];
vector<vector<pair<int,pair<int,int> > > >adj;
int vis[100005];
int vis_ind[100005];

int find_parent(int ver)
{
    if(ver==parent[ver])
        return ver;
    return parent[ver]=find_parent(parent[ver]);
}

void merge(int a,int b)
{
    a=find_parent(a);
    b=find_parent(b);
    if(a!=b)
    {
        if(sz[a]<sz[b])
            swap(a,b);
        parent[b]=a;
        sz[a]+=sz[b];
        mm[a]+=mm[b];
    }
}

void dfs(int ver,int x)
{
    vis_ind[ver]=1;
    for(auto i:adj[ver])
    {
            if(!vis[i.second.second] && i.second.first<=x)
            {
                vis[i.second.second]=1;
                if(!vis_ind[i.first])
                dfs(i.first,x);
            }
    }
}

signed main()
{
 
ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   
 
#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n,m;
    cin>>n>>m;
    adj.resize(n+1);
    int x,y,z;
    for(int i=1;i<=n;i++)
    {
        cin>>mm[i];
        parent[i]=i;
        sz[i]=1;
    }
    vector<pair<int,pair<int,int> > >pp;
    for(int i=0;i<m;i++)
    {
        cin>>x>>y>>z;
        pp.push_back({z,{x,y}});
    }
    
    sort(pp.begin(),pp.end());
    int cnt=0;
    vector<pair<int,int> >ans;

    for(auto i:pp)
    {
        adj[i.second.first].push_back({i.second.second,{i.first,cnt}});
        adj[i.second.second].push_back({i.second.first,{i.first,cnt}});
        merge(i.second.first,i.second.second);
        if(mm[find_parent(i.second.first)]>=i.first)
        {
            ans.push_back({i.second.first,i.first});
            ans.push_back({i.second.second,i.first});
        }
        cnt++;
    }

    reverse(ans.begin(),ans.end());
    for(auto i:ans)
    {
        if(!vis_ind[i.first])
            dfs(i.first,i.second);
    }

    int res=0;
    for(int i=0;i<m;i++)
    {
        res+=vis[i];
    }
    cout<<m-res;


}


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

#define endl "\n"
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
#define debug(x) cerr << #x << ": " << x << endl
#define debugP(p) cerr << #p << ": {" << p.first << ", " << p.second << '}' << endl
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const ll INF = 1e9;
const int MOD = 1e9 + 7;

////////////////////////////////////////////////////////////////////

const int N = 1e5 + 5;

int main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int x; cin >> x;
	for (int i = 1; i <= N; i++) if (108 * i / 100 == x) die(i);
	cout << ":(" << endl;

	return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace AtCoder
{
	class Program
	{
		public static void Main()
		{
#if TextInput
			using(var reader = new StreamReader(Debug.SampleTextPath)) 
			{
				Console.SetIn(reader);
#endif
			
				var pageNum = IO.ReadInt();
				var printNum = pageNum / 2;
				if(pageNum % 2 > 0) { ++ printNum; }
				IO.Write(printNum);

#if TextInput
			}
#endif
		}
	}

	public static class IO
	{
		public static string   Read()								 { return Console.ReadLine(); }
		public static string[] ReadArray(char iSplitter = ' ')		 { return Read().Split(iSplitter); }
		public static int	   ReadInt()							 { return int.Parse(Read()); }
		public static int[]	   ReadIntArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => int.Parse(iText)).ToArray(); }
		public static long	   ReadLong()							 { return int.Parse(Read()); }
		public static long[]   ReadLongArray(char iSplitter = ' ')	 { return ReadArray().Select(iText => long.Parse(iText)).ToArray(); }
		public static double   ReadDouble()							 { return double.Parse(Read()); }
		public static double[] ReadDoubleArray(char iSplitter = ' ') { return ReadArray().Select(iText => double.Parse(iText)).ToArray(); }
		public static char[]   ReadCharArray()						 { return Read().ToCharArray(); }

		public static void Write(string iValue)									   { Console.WriteLine(iValue); }
		public static void Write(int iValue)									   { Console.WriteLine(iValue); }
		public static void Write(IEnumerable<int> iValue , string iJoinWord = " ") { Console.WriteLine(string.Join(iJoinWord , iValue)); }
		public static void Write(long iValue)									   { Console.WriteLine(iValue); }
		public static void Write(double iValue)									   { Console.WriteLine(iValue); }
		public static void Write(decimal iValue)								   { Console.WriteLine(iValue); }
		public static void Write(bool iValue)									   { Console.WriteLine(iValue ? "Yes" : "No"); }
	}

	public static class Util
	{
		public static long Gcd(long i0 , long i1) { return (i0 > i1) ? _Gcd(i0 , i1) : _Gcd(i1 , i0); }
		public static long Lcm(long i0 , long i1) { return (i0 * i1) / Gcd(i0 , i1); }
		public static long ModPow(long iBaseNumber , long iPow , long iModNumber)
		{
			var num = 1L;
			while(iPow != 0)
			{
				if((iPow & 0x1) != 0)
				{
					num = (num * iBaseNumber) % iModNumber;
				}
				iBaseNumber = (iBaseNumber * iBaseNumber) % iModNumber;
				iPow >>= 1;
			}
			return num;
		}
		public static long CombinationNum(int iLeftNumber , int iRightNumber)
		{
			if(iRightNumber == 0) { return 1; }
			if(iLeftNumber == 0)  { return 0; }
			return iLeftNumber * CombinationNum(iLeftNumber - 1 , iRightNumber - 1) / iRightNumber;
		}

		private static long _Gcd(long i0 , long i1)	{ return (i1 == 0) ? i0 : _Gcd(i1 , i0 % i1); }
	}
}


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

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long double L, R;
    cin >> L >> R;
    if (R - L > 3000) cout << 0 << "\n";
    else {
        long long ans = 2018;
        for (long long i = L; i < R; ++i)
            for (long long j = i + 1; j <= R; ++j)
                ans = min(ans, (i * j) % 2019);
        cout << ans << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,anstemp = 0,ans = 0;
  cin>>N;
  vector <string> bstr(N);
  for(int i = 0;i<N;i++){
    cin>>bstr.at(i);
  }
  int M;
  cin>>M;
  vector <string> rstr(M);
  for(int i = 0;i<M;i++){
    cin>>rstr.at(i);
  }
  
  for(int i = 0;i<N;i++){
    anstemp = 0;
    for(int k = 0;k<N;k++){
      if(bstr.at(i) == bstr.at(k)){anstemp++;}
    }
    for(int p = 0;p<M;p++){
      if(bstr.at(i) == rstr.at(p)){anstemp--;}
    }
    if(anstemp>ans){ans = anstemp;}
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def gcd(a, b):
    return gcd(b, a%b) if b != 0 else a

def Main(N):
    ans = 0
    memo2 = [[0 for _ in range(N+1)] for _ in range(N+1)]
    for i in range(1, N+1):
        for j in range(1, N+1):
            if memo2[i][j] == 0:
                memo2[i][j] = gcd(i,j)
            for k in range(1, N+1):
                M = memo2[i][j]
                if memo2[M][k] == 0:
                    memo2[M][k] = gcd(M, k)
                ans += memo2[M][k]
    return ans
    

def main():
    N = int(input())
    print(Main(N))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9476
# coding:utf-8

import sys
from collections import Counter


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


N, K = inpl()

H = []
for i in range(N):
    H.append(int(input()))

C = Counter(H)

H2 = sorted(H)
S = [0]
for i in range(N - 1):
    S.append(S[-1] + H2[i + 1] - H2[i])

# print(H2)
ans = INF
for i in range(N - K + 1):
    # print(i + K - 1, S[i + K - 1] - S[i])
    ans = min(ans, S[i + K - 1] - S[i])

print(ans)


Measured memory_bytes: 18164
function main()
  
  N = parse(Int,readline())
  a = map(x -> parse(Int,x), split(readline()))
  
  color = zeros(Int,8)
  
  for i in 1:N
    
    if 1<=a[i]<=399
      color[1] += 1
    elseif 400<=a[i]<=799
      color[2] += 1
    elseif 800<=a[i]<=1199
      color[3] += 1
    elseif 1200<=a[i]<=1599
      color[4] += 1
    elseif 1600<=a[i]<=1999
      color[5] += 1
    elseif 2000<=a[i]<=2399
      color[6] += 1
    elseif 2400<=a[i]<=2799
      color[7] += 1
    elseif 2800<=a[i]<=3199
      color[8] += 1
    end
    
  end
  
  count = 0
  count0 = 0
  
  for i in 1:8
    
    count += color[i]
    
  end
  
  count = N - count
  
  if count != 0 && color == zeros(Int,8)
    count0 = 1
  else
    count0 = 0
  end
  
  count2 = 0
  
  for i in 1:8
    
    if color[i] != 0
      count2 += 1
    end
    
  end
  
  println(string(count0 + count2)*" "*string(count + count2))

end

main()

Measured memory_bytes: 112180
#include <stdio.h>
#include <string.h>
#define MAX_LEN 50

int main(void){
  char s1[MAX_LEN];
  char s2[MAX_LEN];
  int l;
  int i,j;
  scanf("%s",s1);
  l = strlen(s1);
  for(i=0,j=l-1;i<l;i++,j--) s2[i] = s1[j];
  printf("%s\n",s2);
  return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define int long long
using namespace std;
int prime(int x)
{
    for(int i=2;i<sqrt(x);i++){
        if(x%i==0)  return 0;
    }
    return 1;
}
main() 
{
    vector<int>p;
    for(int i=2;i<=1e5+10;i++){
        if(prime(i))    p.push_back(i);
    }
    int x;
    cin>>x;
    cout<<*lower_bound(p.begin(),p.end(),x)<<"\n";
}

Measured memory_bytes: 436
from functools import reduce
from math import log2
from operator import mul


def end_of_loop():
    raise StopIteration


def main():
    N, K = map(int, input().split())
    MAX_SHIFT = int(log2(K) + 1)
    print(sum(reduce(mul, (0.5
                           if i << j < K
                           else end_of_loop()
                           for j in range(MAX_SHIFT)), 1 / N)
              for i in range(1, N + 1)))
    return


main()


Measured memory_bytes: 3812
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)

using namespace std;

int main()
{
  char s[100];
  cin >> s;
  int i=0;
  rep(i,100)
  {
    if(s[i]=='L'&&i%2==0)
    {
      cout << "No";
      return 0;
    }
    
        if(s[i]=='R'&&i%2==1)
    {
      cout << "No";
      return 0;
    }
      
  }
    cout << "Yes";
	return 0;
}





Measured memory_bytes: 256
from collections import Counter
N=int(input())
a=list(map(int,input().split()))
tmp=Counter(a)
if len(tmp.keys())!=3 or len(a)%3!=0:
    ans=list(tmp.values())
    if len(tmp.keys())==2 and 0 in tmp.keys():
        if tmp[0]*2 in ans:
            print("Yes")
            exit()
        
        
    if sum(a)==0:
        print("Yes")
        exit()
    print("No")
    exit()
else:
    
    key=list(tmp.keys())
    ans=list(tmp.values())
    #print(key)
    #print(ans)
    if ans[0]==ans[1] and ans[0]==ans[2]:
        if key[0]^key[1]==key[2]:
            print("Yes")
            exit()
print("No")

Measured memory_bytes: 14468
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdio>
#include <complex>
#include <numeric>
#include <string.h>
#include <random>
#include <cmath>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
double PI = 3.141592653589793238462643383279;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int N;
int X[300000];
int S[300000];
int nxt[300000];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    rep(i,N) {
        int A; cin >> A; A--;
        X[A]++;
    }
    sort(X, X+N, greater<int>());
    S[N-1] = X[N-1];
    for (int i = N-2; i >= 0; i--) {
        S[i] = X[i] + S[i+1];
    }
    for (int i = 1; i < N; i++) {
        if (X[i-1] == X[i]) nxt[i] = nxt[i-1]+1;
        else nxt[i] = 1;
    }
    cout << N << endl;
    int M = inf;
    for (int i = 1; i < N; i++) {
        ll tmp = S[i];
        ll dif = X[i-1], pos = 1;

        ll ans = 0;
        while (tmp) {
            if (tmp >= pos*dif) {
                tmp -= pos*dif;
                ans += dif;
            } else {
                ans += tmp/pos;
                break;
            }
            if (pos == i || nxt[i-pos] == 0) {
                ans += tmp/(i+1);
                break;
            }
            pos += nxt[i-pos];
            dif = X[i-pos]-X[i-pos+1];
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/abc123_b.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N = 5;
  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  int mm = 0;
  int ans = 0;

  rep(i, N) {
    ans += c[i];
    int rest = c[i] % 10 ? 10 - (c[i] % 10) : 0;
    ans += rest;
    mm = max(mm, rest);
  }

  cout << ans - mm << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;


int main(){  
  vector<int> a(4);
  cin >> a[0] >> a[1] >> a[2] >> a[3];
  sort(a.begin(),a.end());
  if(a[0]==1 && a[1]==4 && a[2]==7 && a[3]==9){ cout << "YES" << endl; return 0; }
  cout << "NO" << endl;
  return 0;
}

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

#define f first
#define s second
#define pb push_back
#define mp make_pair

using namespace std;

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

const int N = (int)2e5 + 123, inf = 1e9, mod = 1e9 + 7;
const ll INF = 1e18;

vector< int > g[N], ans;
int n, m;
bool used[N];

int main()
{                         
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++){
		int v, u;
		scanf("%d%d", &v, &u);
		g[v].pb(u);
		g[u].pb(v);
		if(i == 0){
			ans.pb(v);
			ans.pb(u);
		}
	}           
	used[ans[0]] = 1;
	used[ans[1]] = 1;
	                        
	while(true){
		int v = ans.back();
		while(!g[v].empty() && used[g[v].back()])
			g[v].pop_back();
		if(g[v].size() == 0)
			break;
		ans.pb(g[v].back());	
		used[g[v].back()] = 1;
	}
	reverse(ans.begin(), ans.end());

	while(true){
		int v = ans.back();
		while(!g[v].empty() && used[g[v].back()])
			g[v].pop_back();
		if(g[v].size() == 0)
			break;
		ans.pb(g[v].back());	
		used[g[v].back()] = 1;
	}
	printf("%d\n", ans.size());
	for(auto it : ans)
		printf("%d ", it);
	return 0;
}


Measured memory_bytes: 9208
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int mod=998244353;
vector<int>dp(3005);
int32_t main(){
	IOS
	int n,m;cin>>n>>m;
	vector<int>a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ans=0;
	for(int i=0;i<n;i++){
		dp[0]+=1;   // new subset start for ith indx
		dp[0]%=mod;
		for(int j=m-a[i];j>=0;j--){
			dp[j+a[i]]+=dp[j];
			dp[j+a[i]]%=mod;
		}
		ans+=dp[m]; // subset end here for ith index
		ans%=mod;
	}
	cout<<ans;
}
 
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 3672
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1e9+7
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

struct Edge {
    int to, id;
};

vector<vector<Edge>> g;
vector<int> ans;

void dfs(int v, int c=-1, int p=-1) {
    int k = 1;
    rep(i,sz(g[v])) {
        int u = g[v][i].to, ei = g[v][i].id;
        if (u == p) continue; //子へ向かうように
        if (k == c) ++k;
        ans[ei] = k; ++k;
        dfs(u,ans[ei],v);
    }
}

int main() {
    int n; cin >> n;
    g.resize(n);
    ans.resize(n-1);
    rep(i,n-1) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back((Edge){b,i});
        g[b].push_back((Edge){a,i});
    }
    dfs(0);
    int mx = 0;
    rep(i,n) chmax(mx, sz(g[i]));
    cout << mx << endl;
    rep(i, n-1) {
        cout << ans[i] << endl;
    }

}

Measured memory_bytes: 8320
PROGRAM Lower
      IMPLICIT NONE
      integer(16) :: n
      integer(16),allocatable :: h(:),diff(:)
      integer(16) :: ans=0,dist,i
      
      read*,n
      allocate( h(n),diff(n) )
      read*,h(1:n)
      
      diff(1:n-1) = h(2:n) - h(1:n-1)
      diff(n) = 10**9+1
      
      dist = 0
      do i = 1,n
        if( diff(i)<=0 )then
          dist = dist + 1
          ans = max( ans,dist )
        else
          dist = 0
        end if
      end do
      
      
      print*,ans
      
      
      END PROGRAM

Measured memory_bytes: 3968
///==================================================///
///                HELLO WORLD !!                    ///
///                  IT'S ME                         ///
///               BISHAL GAUTAM                      ///
///         [ bsal.gautam16@gmail.com ]              ///
///==================================================///
#include<bits/stdc++.h>
#define PI acos(-1.0)
#define nl puts("")
#define SZ(x) x.size()
#define pb(x) push_back(x)
#define X first
#define Y second
#define pii pair<int,int>
#define mpr(a,b) make_pair(a,b)
#define S(a) scanf("%d",&a)
#define P(a) printf("%d",a)
#define SL(a) scanf("%lld",&a)
#define S2(a,b) scanf("%d%d",&a,&b)
#define all(v) v.begin(),v.end()
#define clr(a) memset(a,0,sizeof(a))
#define SET(a) memset(a,-1,sizeof(a))
#define fr(i,a,n) for(i=a;i<=n;i++)
#define rf(i,a,n) for(i=n;i>=a;i--)

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
///==========CONSTANTS=============///
///  Digit     0123456789012345678 ///
#define MX     200001
#define inf    1000000000
#define MD     1717171769LL
#define eps    1e-9
///===============================///

int vis[222];
int main()
{
   int a,b,c,d;
   cin>>a>>b>>c>>d;
   for(int i=a;i<=b;i++)vis[i]=1;
   int cnt=0;
   for(int i=c;i<=d;i++){
    if(vis[i])cnt++;
   }
   cout<<max(0,cnt-1)<<endl;

}


Measured memory_bytes: 256
n=int(input())
S=[]
S=input().split()
a=[]
for d in S[0]:
    a.append(d)
p=[]
for i in range(0,n):
    if a[i]=='O':
        p.append(1)
    else:
        p.append(0)
i=0
k=0
while i<n-1:
    if p[i]+p[i+1]==1:
        k=k+1
        i=i+2
    else:
        i=i+1
print(k)


Measured memory_bytes: 7284
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <functional>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
using namespace std;
// #define int long long
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = (((1<<30)-1)<<1)+1;
const int nINF = 1<<31;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, int> pci;

/////////////////////////////////////////////////////////////////////
const int N = 2e5+10, M = 1e9+7;
int add(int a, int b) {return (a+b)%M;}

int n, a[N], last[N], dp[N];
vector<int> intervals[N];

signed main() {
    ios::sync_with_stdio(false);
    //cout << fixed << setprecision(7);
    cin >> n;
    FOR(i, 1, n) cin >> a[i];
    FOR(i, 1, n) {
    	if(last[a[i]] && last[a[i]] < i-1) intervals[i].push_back(last[a[i]]);
    	last[a[i]] = i;
    }
    dp[0] = 1;
    FOR(i, 1, n) {
    	dp[i] = dp[i-1]; //Don't choose anything
    	for(int s : intervals[i]) dp[i] = add(dp[i], dp[s]);
    }
	cout << dp[n] << endl;

    return 0;
}

// Easy things to check:
// - LONG LONGS (WA)
// - const int N is correct (WA, RTE)
// - .size()-k underflow (WA, RTE, TLE)
// - small n edge cases (WA)

// Rare mistakes made in the past:
// - division by 0 (WA)
// - integer division (WA)
// - setprecision (WA)
// - INF not big enough using ll (WA)
// - setting max to 0 instead of -INF/min to 0 instead of INF (WA)
// - outputting debug (WA)
// - allocating too much memory (locRTE, MLE)
// - stack size (locRTE)
// - round announcements (WA)
// - multiset::erase (WA)



Measured memory_bytes: 13440
#pragma target("avx2")
#pragma optimize("Ofast")
#pragma optimize("unroll-loops")
#include<iostream>

int main(void){
        char s[10];
        int l = 0, i, cnt = 0;
        bool ok = true;
        while((s[l]=getchar())!='\n') l++;
        for(i=0; i<l; i++){
                if('a'<=s[i] && s[i]<='z') cnt++;
                else if(s[i]=='C') ok &= (1<i && i<l-1);
                else if(s[i]=='A') ok &= (i==0);
                else ok = false;
        }
        if(ok && cnt==l-2) puts("AC");
        else puts("WA");
        return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n;
  long long array[200005];
  long long sum=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  
  for(int i=1;i<n;i++){
    sum+=max(0ll,array[i-1]-array[i]);
    array[i]=max(array[i],array[i-1]);
  }
  cout<<sum<<endl;
  return(0);
}


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

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

const int MAXN = 5e5;
const int MAXV = (1<<20);
const ll MOD = 1e9+7;

int N, A[MAXN+10], zero[MAXN+10];
vector<int> pos[MAXV+10];

ll solve(int x, int t)
{
    int i, j;
    ll dp[2]={1, 0};
    for(i=1; i<pos[x].size(); i++)
    {
        ll now=pos[x][i], gap=zero[pos[x][i]]-zero[pos[x][i-1]];
        dp[0]+=gap*dp[1]%MOD;
        dp[1]+=dp[0];
        dp[0]%=MOD; dp[1]%=MOD;
    }
    return dp[t];
}

int main()
{
    int i, j;

    scanf("%d", &N);
    for(i=1; i<=N; i++) scanf("%d", &A[i]), A[i]^=A[i-1];
    for(i=1; i<=N; i++) zero[i]=zero[i-1]+(A[i]==0);

    for(i=0; i<MAXV; i++) pos[i].push_back(0);
    for(i=1; i<=N; i++) pos[A[i]].push_back(i);

    if(A[N]!=0) printf("%lld", solve(A[N], 0));
    else
    {
        ll ans=1;
        for(i=1; i<zero[N]; i++) ans=ans*2%MOD;
        for(i=1; i<MAXV; i++) ans=(ans+solve(i, 1))%MOD;
        printf("%lld", ans);
    }
}


Measured memory_bytes: 64492
import heapq
N, M = map(int, input().split())
A = list(map(lambda x: -int(x), input().split()))
heapq.heapify(A)

ans = 0
for i in range(M):
    most_expensive = -heapq.heappop(A)
    most_expensive //= 2
    heapq.heappush(A, -most_expensive)

print(-sum(A))

Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int counter = 0;
  int yakusuu = 0;
  
  for ( int i = 1; i < N + 1; i++) {
    yakusuu = 0;
    for (int j = 1; j < i + 1; j++) {
      if (i % j == 0 && i % 2 == 1) yakusuu++;
    }
    if (yakusuu == 8) counter++;
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args){
    
    Scanner sc = new Scanner(System.in);
        String S = sc.next();
        String T = sc.next();
        
        if(S. equals (T.substring(0,S.length()))){
                System.out.println("Yes");            
        }else{
                System.out.println("No"); 
        }
            }
}

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

//qsort
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

//比較
int max(int a, int b){
	if (a>b) return a;
	else return b;
}

int min(int a,int b) {
	if(a>b) return b;
	else return a;
}


//main関数
int main() {
	int A,B;
	scanf("%d %d",&A,&B);
	if (A == 1){
		A=14;
	}
	if (B == 1){
		B=14;
	}
	if (A>B) {
		printf("Alice");
	} else if (A==B){
		printf("Draw");
	} else {
		 printf("Bob");
	}
}

Measured memory_bytes: 1684
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] chars = sc.next().toCharArray();
		char[] chars2 = sc.next().toCharArray();
		int count = 0;
		for(int i = 0; i < chars.length; i++){
			if(chars[i] == chars2[i]){
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> x = new ArrayList<>();
        for (int i = 0; i <= n; i++) {
            x.add(sc.nextInt());
        }
        sc.close();

        Collections.sort(x);

        int ans = Integer.MAX_VALUE;
        for (int i = 2; i < x.size(); i++) {
            int candidate = gcd(x.get(i - 1) - x.get(i - 2), x.get(i) - x.get(i - 1));
            if (candidate < ans) {
                ans = candidate;
            }
        }

        // n == 1のときだけ特別扱いが必要
        if (n == 1) {
            ans = x.get(1) - x.get(0);
        }

        System.out.println(ans);
    }

    // greatest common divisor
    static int gcd(int a, int b) {
        if (a < b) {
            int tmp = a;
            a = b;
            b = tmp;
        }

        if (a % b == 0) {
            return b;
        } else {
            return gcd(b, a % b);
        }
    }
}


Measured memory_bytes: 49040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long lli;
typedef long double lld;
#define mod 1000000007
#define mod2 998244353
#define fori(n) for (int i = 0; i < n; i++)
#define forj(n) for (int j = 0; j < n; j++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define endl "\n"
#define sortvec(a) sort(a.begin(), a.end())
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define cerr if(true) cerr

template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << "(" << p.first << ", " << p.second << ")";
    return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print(const ContainerType<ValueType, Args...> &c)
{
    for (const auto &v : c)
        cout << v << ' ';
    cout << '\n';
}

void print() { cout << '\n'; }
template <typename T, typename... Args>
void print(T a, Args... args)
{
    cout << a << " ";
    print(args...);
}

lli llipower(lli x, lli y, lli p = LLONG_MAX)
{
    lli res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
lli binarySearch(vector<int> arr, int l, int r, int x)
{
    if (r >= l)
    {
        lli mid = l + (r - l) / 2;
        if (arr[mid] == x)
            return mid;
        if (arr[mid] > x)
            return binarySearch(arr, l, mid - 1, x);
        return binarySearch(arr, mid + 1, r, x);
    }
    return -1;
}

//---------------------------------------------------------------------------------


int main(){
    lli a;
    lld b;
    cin>>a>>b;
    lld ans=a*b;
    cout<<(lli)floor(ans)<<endl;
}

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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

int main() {
 
 int x;
 cin>>x;
 if(30<=x){
     cout<<"Yes"<<endl;
 }
 else
 {
     cout<<"No"<<endl;
 }
 
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=2e5+9;
string st ;
int arr[N],frq[N];
ll t,a,b,c,m;
int main(){
    scanf("%lld%lld",&a,&b);
    if(a==0)
        return cout<<0,0;
    if(a==b)
         return cout<<0,0;
    if(b==a)
        cout<<0;
    if(a>b)
    {
        c=a%b;
        cout<<min(c,b-c);

    }
    else
        cout<<min(a,b-a);

        }





/**
5
2 3
10 10
2 4
7 4
9 3



*/




/**
  int power1(int b, int p){               //O(p)
    if(!p)  return 1;
    return b*power1(b, p-1);
  }
  int power2(int b, int p){               //O(Log(p))
    if(!p)  return 1;
    int ret = power2(b, p/2);
    return (p&1 ? ret*ret*b : ret*ret);
  }
   int mul(int a, int b, int m){
      return (a%m * b%m) % m;
  }

*/


/**
void seive()
{
    bitset<N>iscomp;
    iscomp[0]=iscomp[1]=1;
    for(long long i=2; i<=N; ++i)
    {
        if(!iscomp[i])
        {
            a.push_back(i);
            for(long long j=i*i; j<=N; j+=i)
                iscomp[j]=1;
        }
    }
}
3
abc
abc
*/


Measured memory_bytes: 256
N = int(input())
A = [[int(a) for a in input().split()] for _ in range(N)]
X = [0] * (1<<N)
for s in range(1, 1<<N):
    t = s & (s-1)
    ma = sum([sum([A[i][j] for j in range(i) if 1 << j & s]) for i in range(N) if 1 << i & s])
    while t:
        ma = max(ma, X[t] + X[s^t])
        t = (t-1) & s
    X[s] = ma
print(X[-1])

Measured memory_bytes: 45020
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        double a = in.nextInt();
        double b = in.nextInt();
        double h = in.nextInt();
        double m = in.nextInt();

        double hrad = ((30 * h + 0.5 * m) / 180) * Math.PI;
        double hx = Math.cos(hrad) * a;
        double hy = Math.sin(hrad) * a;

        double mrad = ((6 * m) / 180) * Math.PI;
        double mx = Math.cos(mrad) * b;
        double my = Math.sin(mrad) * b;

        double xp = (mx - hx) * (mx - hx);
        double yp = (my - hy) * (my - hy);
        System.out.println(Math.sqrt(xp + yp));

    }
}

Measured memory_bytes: 35956
object Main extends App {
  val scanner = new java.util.Scanner(System.in)

  val inputs = Iterator.continually {
    val m = scanner.nextInt()
    val f = scanner.nextInt()
    val r = scanner.nextInt()

    (m, f, r)
  }.takeWhile(_ != (-1, -1, -1))

  val outputs = inputs.map {
    case (m, f, r) =>
      val mf = m + f
      if(m < 0 || f < 0)
        "F"
      else if(mf >= 80)
        "A"
      else if(mf >= 65)
        "B"
      else if(mf >= 50)
        "C"
      else if(mf >= 30) {
        if(r >= 50)
          "C"
        else
          "D"
      } else "F"
  }

  outputs.foreach(println)
}

Measured memory_bytes: 45244
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
        int b = sc.nextInt();
		int c = Math.max(a-b,b-a);
        if(c%2==0){System.out.println(Math.max(a,b)-c/2);}
		else{System.out.println("IMPOSSIBLE");}
	}
}


Measured memory_bytes: 21844
"use strict";

class PriorityQueue {
  constructor() {
    this.heap = [];
  }

  push(item) {
    let heap = this.heap;
    let i = heap.length++;
    let j;

    while(i) {
      j = Math.floor((i - 1) / 2);
      if(heap[j] <= item) break;
      heap[i] = heap[j]
      i = j;
    }

    heap[i] = item;
  }

  pop() {
    let heap = this.heap;
    let top = heap[0];
    let popped = heap.pop();

    let i = 0;
    let k = Math.floor(heap.length / 2);
    let j;

    while(i < k) {
      j = (i * 2) + 1;
      if(heap[j+1] < heap[j]) ++j;

      if(popped <= heap[j]) break;

      heap[i] = heap[j];

      i = j;
    }

    if(heap.length) {
      heap[i] = popped;
    }

    return top;
  }

  size() {
    return this.heap.length;
  }

  top() {
    return this.heap[0];
  }
}


const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const M = parseInt(arg[0].split(" ")[1]);
    
    const A = arg[1].split(" ").map(n=>parseInt(n)).sort((a,b)=>a-b);

    let pq = new PriorityQueue();
    
    for(let i in A) {
        pq.push(-A[i]);        
    }
    
    for(let i=0; i<M; i++) {
        let highest = -pq.pop();
        pq.push(-Math.floor(highest / 2));
    }
    
    let answer = -1 * pq.heap.reduce((m,n)=>m + n);

    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 33416
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class ARightTriangle {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int[] arr = new int[3];
            for (int i = 0; i < 3; i++) {
                arr[i] = in.nextInt();
            }
            Arrays.sort(arr);
            out.println(arr[0] * arr[1] / 2);
        }

    }

    static class InputReader implements AutoCloseable {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public void close() {
        }

    }
}



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

int main(){
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> d[i];
    }
    set<int> s;
    for (int i = 0; i < N; i++)
    {
        s.insert(d[i]);
    }
    cout << s.size() << endl;
    return 0;
    

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	
	ll x,y,z; cin>>x>>y>>z;
	ll tk=0;
	ll k=0;
	while(k<x)
	{
		tk+=z;
		k+=y;
	}
	cout<<tk;

}

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

int main(){
    int n, k; double ans=0;
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        double pro = 1.0/n; int sc = i+1;
        for(;sc<k;){
            sc *= 2; pro /= 2;
        }
        ans += pro;
    }
    cout << setprecision(12) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=l;i<r;i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n,r;
	while(scanf("%lld%lld",&r,&n),r){
		ll aaa[50]={},*a=aaa+25;
		a[-r-1]=a[r]=1e9;
		while(n--){
			ll xl,xr,h;
			scanf("%lld%lld%lld",&xl,&xr,&h);
			rep(i,xl,xr)a[i]=max(a[i],h);
		}
		double ans=1e10;
		//地上に出るまでの時間+高さ
		rep(i,-r,r+1)ans=min(ans,min(a[i-1],a[i])+r-sqrt(r*r-i*i));
		printf("%f\n",ans);
	}
}


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

int main() {
    string str;
    cin >> str;

    int n = str.size() - 1;
    long res = stol(str);
    for (int bit = 1; bit < (1<<n); bit++) {
        vector<int> vec;
        for (int i = 0; i < n; i++) {
            if (bit & (1<<i)) {
                vec.push_back(i);
            }
        }

        for (int i = 0; i < vec.size(); i++) {
            if (i == 0) {
                res += stol(str.substr(0, vec[i] + 1));
            } else {
                res += stol(str.substr(vec[i - 1] + 1, vec[i] - vec[i - 1]));
            }
        }
        res += stol(str.substr(vec[vec.size() - 1] + 1, n - vec[vec.size() - 1]));
    }
    cout << res << endl;
}


Measured memory_bytes: 256