akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        Map<Integer, Integer> map = new HashMap<>();
        int n = sc.nextInt();
        int[] b = new int[n];
        for(int i=0; i<n; i++) {
            b[i] = sc.nextInt() - i;
            map.put(b[i], map.getOrDefault(b[i], 0) + 1);
        }
        long res = 0;
        for(int i=0; i<n; i++) {
            map.put(b[i], map.get(b[i]) - 1);
            res += map.getOrDefault(-2 * i - b[i], 0);
        }
        System.out.println(res);

    }

}

Measured memory_bytes: 69608
#include <iostream>
using namespace std;
int main()
{
  int A,B,C;
  cin>>A>>B>>C;
  
  int count5=0;
  int count7=0;
  int x=0;
  if(A==5)count5++;
  if(B==5)count5++;
  if(C==5)count5++;
  if(A==7)count7++;
  if(B==7)count7++;
  if(C==7)count7++;
  
  if(count5==2)x++;
  if(count7==1)x++;
  
  if(x==2)cout<<"YES";
  else cout<<"NO";
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
using namespace std;

int main()
{
    //int m,n,o,i,j,k;
    long long int m,n,o,i,j,k,len=0;
    //vector <int> v;
    //float f,g,h;
    //char c,d;
    string a;
    cin>>n;
    if(n==0) cout<<0;
    //cin>>m>>c>>n>>d>>i;
    //cin>>f>>g;
    //cin>>c;
    while(n!=0)
    {
        if(n%2==0)
        {
            a+='0';
            n/=-2;
        }
        else
        {
            a+='1';
            n=(n-1)/-2;
        }
        len++;
    }
    for(i=len-1;i>=0;i--) cout<<a[i];
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }


int main() {
    int N;
    cin >> N;
    vint V(N), C(N);
    vint V_C(N);
    rep(i, N) {
        cin >> V[i];
    }
    rep(i, N){
        cin >> C[i];
        V_C[i] = V[i] - C[i];
    }
    sort(V_C.begin(), V_C.end(), greater<int>());
    int s= 0;
    rep(i, N) {
        if (V_C[i] > 0)
            s += V_C[i];
    }
    cout << s << endl;
    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vi::iterator vit;
typedef vi::reverse_iterator vrit;
#define pb push_back

const int MX=100005;
vi G[MX];
int n;
int dp(int k,int f){
	int v=0,v2=0;
	for(auto i:G[k])if(i!=f){
		int r=dp(i,k);
		v2|=(r&v),v|=r;
	}
	int it=0;while((1<<it)<=v2)it++;
	while((v>>it)&1)it++;
	return (v|(1<<it))&(~((1<<it)-1));
}
int main(){
	ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<n;i++){
		int a,b;cin>>a>>b;
		G[a].pb(b),G[b].pb(a);
	}
	cout<<31-__builtin_clz(dp(1,0))<<endl;
	return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
const int MAX = 510000;
const int MOD = 1000000007;

     signed main(){
    int l,r,d,ans=0;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++)if(i%d==0)ans++;
    cout<<ans<<endl;

     }


 


 






    





      

        


Measured memory_bytes: 3636
from fractions import gcd
n = int(input())
*A, = map(int, input().split())
L = [0]*n
R = [0]*n
for i in range(n-1):
    L[i] = gcd(L[i-1], A[i])
    R[n-1-i] = gcd(R[(n-i)%n], A[n-1-i])
B = [gcd(L[i-1], R[(i+1)%n]) for i in range(n)]
print(max(B))

Measured memory_bytes: 92512
#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define Fordown(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
 int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
    return x * fh;
}

int a[15];
int ans = 0;
int n;
void dfs (int dep, int even) {
	if (dep == n) {
		if (even) ++ ans;
		return ;
	}
	For (i, a[dep + 1] - 1, a[dep + 1] + 1)
		dfs (dep + 1, even | (! (i & 1) ) );
}

int main () {
	n = read();
	For (i, 1, n)
		a[i] = read(); 
	dfs(0, 0);
	printf ("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	int res = 0;
	int a, b;
	cin >> a >> b;
	res += (b + a - 3) / (a - 1);
	put(res);
return 0;
}

Measured memory_bytes: 256
import itertools
import math
N=int(input())

a = [0] * N

b = [1,1,1]

if N >= 6:
    for x,y,z in itertools.combinations_with_replacement(list(range(1,int(math.sqrt(N)) +1 )), 3):
        f = x**2 +y**2 +z**2 + x*y + y*z + x*z
        if f <= N:
            if x==y==z:
                a[f-1] += 1
            elif x==y or y== z:
                a[f-1] += 3
            else:
                a[f-1] += 6
        # elif f >= 2*N:
        #     break
[print(ans) for ans in a]

Measured memory_bytes: 9392
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll sum=0;
  rep(i,n)sum+=a[i];
  ll MAX=0;
  if(sum%10!=0){
    cout<<sum<<endl;
    return 0;
  }
  rep(i,n){
    if((sum-a[i])%10!=0)MAX=max(MAX,sum-a[i]);
  }
  cout<<MAX<<endl;
  return 0;
}

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

vector<string>v[17];
int p;
string s;

int G1();

int get(){
  int res=0;
  if(s[p]=='(')p++,res=G1(),p++;
  else if(s[p]=='-')p++,res= !get();
  else if(s[p]=='0')p++,res=0;
  else if(s[p]=='1')p++,res=1;
  return res;
}

int G1(){
  int res=get();
  while(s[p]=='*'||s[p]=='^'){
    int tmp=p++;
    if(s[tmp]=='*') res&=get();
    if(s[tmp]=='^') res^=get();
  }
  return res;
}

int BNF(string x){
  p=0;
  s=x+'@';
  return G1();
}

int BIT(string s){
  int bit=0;
  r(i,(1<<4)){
    string t=s;
    r(j,t.size()){
      if(t[j]=='a') t[j]= (i&(1<<0))?'0':'1';
      if(t[j]=='b') t[j]= (i&(1<<1))?'0':'1';
      if(t[j]=='c') t[j]= (i&(1<<2))?'0':'1';
      if(t[j]=='d') t[j]= (i&(1<<3))?'0':'1';
    }
    bit |= (BNF(t) << i);
  }
  return bit;
}

set<int>st;
map<int,int>ans;

void MAKE(){
  for(int i=1;i<17;i++){
    vector<string>vv;
    if(i==1){
      vv.push_back("0");
      vv.push_back("1");
      vv.push_back("a");
      vv.push_back("b");
      vv.push_back("c");
      vv.push_back("d");
    }
    r(j,v[i-1].size()){
      vv.push_back("-"+v[i-1][j]);
    }
    int sz=i-3;
    for(int j=1;j<sz;j++){
      int k=sz-j;
      r(a,v[j].size()){
        r(b,v[k].size()){
          vv.push_back("("+v[j][a]+"^"+v[k][b]+")");
          vv.push_back("("+v[j][a]+"*"+v[k][b]+")");
        }
      }
    }
    r(j,vv.size()){
      int bit=BIT(vv[j]);
      if(!st.count(bit)){
        ans[bit]=i;
        st.insert(bit);
        v[i].push_back(vv[j]);
      }
    }
  }
}

int main(){
  MAKE();
  string s;
  while(cin>>s){
    if(s==".")break;
    cout<<ans[BIT(s)]<<endl;
  }
}


Measured memory_bytes: 4060
#include <cstdio>
#include <cmath>
using  namespace std;


int main()
{
	int x,y,z,b;
	float a;
	scanf("%d%d%d",&x,&y,&z);
    a=(float)(x-z)/(y+z);
    b=a;
    printf("%d",b);
}

Measured memory_bytes: 128
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

#define ll long long
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll Mypow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}


ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};

int main(){
  int N; cin >> N;
  cout << N * (N+1) / 2 << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
long long n,a[110],b,ans;
char c[100100];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<n-1;i++)
		for(int o=i+1;o<n;o++)	
			ans+=a[i]*a[o];
	cout<<ans<<endl;		
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
ll n,m;
int main(){
    cin>>n>>m;
    if(n==1 || m==1){
        cout<<1<<endl;
        return 0;
    }
    cout<<(n*m+1)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
            int[]  input = new int[3];
            for(int i = 0; i < input.length; i++) {
                input[i] = sc.nextInt();
            }
            for(int count = 0 ; count < input[2]; count++) {
                int out = count + input[0];
                if(out <= input[1]) {
                    System.out.println(input[0] + count);
                } else {
                    break;
                }
            }
            int out = Math.max(input[0] + input[2], input[1] - input[2] + 1);
            for (int count = 0; count < input[2]; count++) {
                if(out > input[1]) {
                    break;
                } else {
                    System.out.println(out++);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll p[100500];
ll q[100500];
ll r[100500];
ll gg[200500];
bool camp(ll a,ll b)
{
	return	a>b;
}
int main()
{
    ll sum=0;
	int x,y;
	cin>>x>>y;
	int a,b,c;
	cin>>a>>b>>c;
	for(int i=0;i<a;i++)
	{
		cin>>p[i];
	}
	for(int i=0;i<b;i++)
	{
		cin>>q[i];
	}
	for(int i=0;i<c;i++)
	{
		cin>>r[i];
	}
	sort(p,p+a,camp);
	sort(q,q+b,camp);
	sort(r,r+c,camp);
	for(int i=0;i<x;i++)
	{
	    gg[i]=p[i];
	}
	int k=x;
	for(int i=0;i<y;i++)
    {
        gg[k++]=q[i];
    }
    sort(gg,gg+k);
    int k1=0;
    for(int i=0;i<k;i++)
    {
        if(gg[i]<r[k1])
        {
            sum+=r[k1];
            k1++;
        }
        else{
            sum+=gg[i];
        }
    }
    cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
//size_t f = string::npos
//make pair, tuple

int main(){
      set<int> press;
      int n;cin >> n;
      int arr[n + 5];
      int curr = 1;
      int ans = 0;
      for(int i = 0;i < n;i++)cin >> arr[i];
      for(int i = 0;i < n;i++){
            press.insert(curr);
            curr = arr[curr - 1];
            if(press.count(curr) != 0)return cout << -1, 0;
            ans++;
            if(curr == 2)break;
      }
      cout << ans;
}

Measured memory_bytes: 5376
#include<stdio.h>

int main(){
  int temp,n,i,j,flag=1,a[100],cnt=0;

  scanf("%d",&n);

  for(i=0;i<=n-1;i++){
    scanf("%d",&a[i]);
  }
  i=0;
  while(flag){
    flag=0;
    for(j=n-1;j>=i+1;j--){
      if(a[j]<a[j-1]){
	temp=a[j];
	a[j]=a[j-1];
	a[j-1]=temp;
	flag=1;
	cnt++;
      }
    }
    i++;
  }

  for(i=0;i<=n-1;i++){
    printf("%d",a[i]);
    if(i!=n-1)printf(" ");
  }
  
  printf("\n%d\n",cnt);
  
  return 0;
}


Measured memory_bytes: 2140
#include <vector>
#include <cstddef>

struct union_find {
    using size_type = std::size_t;
private :
    size_type _size;
    std::vector<int> node;
public :
    union_find (size_type n) noexcept : node(n, -1), _size(n) { }

    bool unite (size_type x, size_type y) noexcept {
        if ((x = root(x)) == (y = root(y))) return false;
        if (node[x] > node[y]) std::swap(x, y);
        node[x] += node[y];
        node[y] = x;
        _size--;
        return true;
    }

    bool same (size_type x, size_type y) noexcept {
        return (root(x) == root(y));
    }

    size_type root (size_type x) noexcept {
		if (node[x] < 0) return x;
		return node[x] = root(node[x]);
    }

    size_type size (size_type x) noexcept {
        return (size_type(-node[root(x)]));
    }

    const size_type &size () const noexcept {
        return _size;
    }

};

#include <iostream>

int main() {
	int n, m;
	std::cin >> n >> m;
	union_find uf(n);
	for (int i = 0; i < m; i++) {
		std::size_t a, b;
		std::cin >> a >> b;
		a--; b--;
		uf.unite(a, b);
	}
	
	std::cout << uf.size() - 1 << '\n';
	
	return 0;
}

Measured memory_bytes: 3788
def main() :
	S = input()
	if (S[0] != "A") :
		print("WA")
		return
	
	if (list(S).count("A") != 1) :
		print("WA")
		return
	
	S2 = list(S[2:-1])
	if (S2.count("C") != 1) :
		print("WA")
		return
	
	for s in list(S) :
		if (s == "A" or s == "C") :
			continue
		
		if (s.isupper()) :
			print("WA")
			return
	
	print("AC")


main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int kazu;
 int syoki;
 int asi;
 int kakunin = 0;
 cin >> kazu >> asi;
  syoki = kazu;
  syoki += 1;
  for (int i = 0; i < syoki; i++) {
    if (asi == kazu * 2 ) {
      cout << "Yes" << endl;
      kakunin  = 1;
      break;
    }
    else {
      kazu += 1;
      continue;
    }
  }
  if (kakunin == 0) {
    cout << "No" << endl;
  }
}
      

Measured memory_bytes: 3632
<?php
$input = array_map('intval', explode(' ', fgets(STDIN)));
$a = $input[0];
$b = $input[1];
$x = $input[2];

if ((($a+$b)>=$x)and($a<=$x)) {
    print 'YES';
} else {
    print 'NO';
}

Measured memory_bytes: 4856
#include <iostream>
#include<stdio.h>
#include<stdlib.h>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main()
{
	int N, K;	cin >> N >> K;
	vector<int> h(N);
	for (int i = 0; i < N; i++)
	{
		cin >> h[i];
	}

	sort(h.begin(), h.end());	//昇順ソート

	int ans = 999999999;

	for (int i = 0; i <= (N - K); i++)
	{
		ans = min(ans, abs(h[i] - h[i + K - 1]));
	}

	cout << ans;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	int n;
	cin >> n;
	bool ch = 1;
	rep(i, n) {
		int a;
		cin >> a;
		if (a % 2) ch = 0;
	}
	if (ch)
		cout << "second" << endl;
	else
		cout << "first" << endl;
	return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N);
  for(int i = 0; i < N; i++) cin >> A[i];
  
  long long m = 1000;
  long long s = 0;
  for(int i = 0; i < N - 1; i++){
    if(A[i] < A[i + 1]){
      s += m / A[i];
      m %= A[i];
    }else if(A[i] > A[i + 1]){
      m += s * A[i];
      s = 0;
    }
  }
  
  if(s) m += s * A[N - 1];
  
  cout << m << endl;
  
  return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void){
    
    int cards[128][14]={{0}};
    int i, n;
    scanf("%d", &n);
    for(i=0; i<n; i++){
        char c;
        int cn;
        scanf("%c", &c);
        scanf("%c %d", &c, &cn);
        cards[c][cn]=1;
        
    }
    for(i=1; i<=13; i++){
        if(cards['S'][i]==0){
            printf("S %d\n", i);
        }
    }
    for(i=1; i<=13; i++){
        if(cards['H'][i]==0){
            printf("H %d\n", i);
        }
    }
    for(i=1; i<=13; i++){
        if(cards['C'][i]==0){
            printf("C %d\n", i);
        }
    }
    for(i=1; i<=13; i++){
        if(cards['D'][i]==0){
            printf("D %d\n", i);
        }
    }
    return 0;
    
}



Measured memory_bytes: 2128
def maximum_values(d):
    retval = []
    maxval = max(d.values())

    for k, v in d.items():
        if v == maxval:
            retval.append(k)

    return retval

num = int(input())
strings = {}

for i in range(num):
    string = input()
    if string in strings.keys():
        strings[string] += 1
    else:
        strings[string] = 1

maximums = maximum_values(strings)
maximums = sorted(maximums)
print("\n".join(maximums))

Measured memory_bytes: 35676
#include <stdio.h>
#include <math.h>
 
int main(){
    double x, y, x1, y1, x2, y2;
     
    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);
     
    x = x2 - x1;
    y = y2 - y1;
     
    printf("%f\n", sqrt(x * x + y * y));
     
    return 0;
}

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

using namespace std;

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

  string s, t;
  cin >> s >> t;

  int ss = s.size();
  int ts = t.size();

  int ans = 1000;
  for (int i = 0; i < ss - ts + 1; ++i) {
    int cnt = ts;
    for (int j = 0; j < ts; ++j) {
      if (s[i + j] == t[j]) {
        --cnt;
      }
    }
    ans = min(ans, cnt);
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3620
#include <stdio.h>

static char s[1024];
static int sp;

int term(void);
int factor(void);
int expr(void);
int nextInt2();
int nextInt();

int main(void)
{
    int i, n;
    scanf("%d",&n);
    for (i = 0; i < n; i++) {
        sp = 0;

    scanf("%s",s);

    printf("%d\n",expr());

    }
    return 0;

}

int nextInt(void)
{
    int tmp;
    tmp = s[sp] - '0';
    sp++;
    while (s[sp] == '0' ||
            s[sp] == '1' ||
            s[sp] == '2' ||
            s[sp] == '3' ||
            s[sp] == '4' ||
            s[sp] == '5' ||
            s[sp] == '6' ||
            s[sp] == '7' ||
            s[sp] == '8' ||
            s[sp] == '9') {
        tmp *= 10;
        tmp += s[sp] - '0';
        sp++;
    }
    return tmp;
}

int nextInt2(void)
{
    if (s[sp] == '-') {
        sp++;
        return nextInt() * -1;
    } else {
        return nextInt();
    }
}

int term(void)
{
    if(s[sp]=='('){
        int res;
        sp++; 
        res = expr();
        sp++;
        return res;
    }
    return nextInt2();
}

int factor(void)
{
    int res = term();
    while(1) {
        if(s[sp]=='*'){
            sp++; res *= term();
        } else if(s[sp]=='/'){
            sp++; res /= term();
        } else {
            break;
        }
    }
    return res;
}

int expr(void)
{
    int res = factor();
    while(1){
        if(s[sp]=='+') {
            sp++; res += factor();
        } else if(s[sp]=='-') {
            sp++; res -= factor();
        } else {
            break;
        }
    }
    return res;
}

Measured memory_bytes: 592
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

int valid_m(string s) {
	return 1 <= stoi(s) && stoi(s) <= 12;
}

int valid_y(string s) {
	return 1;
}

signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);	

	string s;
	cin >> s;
	vector<string> can;
	string a = s.substr(0, 2);
	string b = s.substr(2, 2);
	if (valid_m(a) && valid_y(b)) can.push_back("MMYY");
	if (valid_y(a) && valid_m(b)) can.push_back("YYMM");
	if (can.empty()) {
		cout << "NA" << endl;
	} else if ((int)can.size() > 1) {
		cout << "AMBIGUOUS" << endl;
	} else {
		cout << can.front() << endl;
	}

}


Measured memory_bytes: 888
#include <iostream>
 
int main(){
  unsigned num;
  std::cin >> num;
  
  unsigned result = 31;
  unsigned power = 1<<31;
  for(unsigned i=0;i<num;i++){
    unsigned tmp;
	std::cin >> tmp;
    if(tmp%power==0){
		continue;
	}else{
		do{
			power = power>>1; result--;
        }while(tmp%power);
    }
  }
  std::cout << result << std::endl;
  return 0;
}

Measured memory_bytes: 256
n = list(map(int,input().split()))
a = list(map(int,input().split()))
b = list(map(int,input().split()))
cupon = [list(map(int,input().split())) for i in range(n[2])]
#クーポンなし
nasi = min(a) + min(b)
mai = [a[i[0] -1] + b[i[1] -1] - i[2] for i in cupon]
m = min(mai)
if nasi < m:
  print(nasi)
else:
  print(m)

Measured memory_bytes: 42524
#pragma GCC optimize("Ofast")
    #pragma GCC optimize("unroll-loops")
    #pragma GCC target("sse2")
 
    #include <bits/stdc++.h>
    #include <vector> 
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    using namespace std;
 
    #define int         long long
    #define ll          long long
    #define pb          push_back
    #define pii         pair<int,int>
    #define vi          vector<int>
    #define vii         vector<pii>
    #define mi          map<int,int>
    #define mii         map<pii,int>
    #define mp          make_pair
    #define all(a)      (a).begin(),(a).end()
    #define FF           first
    #define SS           second
    #define sz(x)       (int)x.size()
    #define endl        '\n'
    #define rep(i,a,b)  for(int i=a;i<b;i++)
     ll hell=1000000007;

     

    int solve(){    
      
      string s;
      cin>>s;
      if(s[0]==s[1]&&s[1]==s[2]&&s[1]=='R')
        return cout<<3,0;
      if(s[0]==s[1]&&s[0]=='R')return cout<<2,0;
      if(s[2]==s[1]&&s[1]=='R')return cout<<2,0;

      if(s[0]=='R'||s[1]=='R'||s[2]=='R')return cout<<1,0;
      cout<<0;
      
   return 0;
    }  
 
 
    signed main()
    {    
    
       
  

 
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0); 
 
    int t=1,k=1;                                                                                                                  
    //cin>>t;
   
 
    while(t--)
    {
     
     // cout<<"Case #"<<k++<<": ";
     solve();
     //cout<<endl;
    }
    return 0;
    } 

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[1<<18];
vector<ll> V[1<<18];
ll S[1<<18][19];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,1<<N) {
		cin>>x;
		V[i]={x,0};
	}
	
	FOR(i,N) {
		FOR(x,1<<N) if(x&(1<<i)) {
			V[x].push_back(V[x^(1<<i)][0]);
			V[x].push_back(V[x^(1<<i)][1]);
			sort(ALL(V[x]));
			reverse(ALL(V[x]));
			V[x].resize(2);
		}
	}
	
	ll ma=0;
	for(int k=1;k<=(1<<N)-1;k++) {
		ma=max(ma,V[k][0]+V[k][1]);
		cout<<ma<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 25728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n+2,0);
	rep(i,n){
		cin>>a[i+1];
	}
	ll ans=0;
	rep(i,n+1){
		ans+=abs(a[i]-a[i+1]);
	}
	FOR(i,1,n+1){
		ll now=ans;
		now-=abs(a[i-1]-a[i])+abs(a[i]-a[i+1]);
		now+=abs(a[i-1]-a[i+1]);
		cout<<now<<endl;
	}
}

Measured memory_bytes: 2048
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n)for(int i=0;i<(int)(n);i++)
#define PI 3.141592653589793
//vector < vector<int>>a(0, vector<int>(0));二次元配列宣言


int main()
{
	int a, b;
	cin >> a >> b;
	if (a == 1)
		a += 15;
	if (b == 1)
		b += 15;
	if (a == b)
		cout << "Draw" << endl;
	else if (a > b)
		cout << "Alice" << endl;
	else
		cout << "Bob" << endl;

} 

Measured memory_bytes: 3556
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<cmath>
#include<iomanip>
using namespace std;
int main() {
	int i,n;
	double a,sum,squ,s;
	while (cin>>n) {
		if (n == 0)break;
		sum = 0; squ = 0;
		for (i = 0; i < n; i++) {
			cin >> a;
			squ += pow(a, 2);
			sum += a;
		}
		s = sqrt(squ / n - pow(sum / n, 2));
		cout << fixed << setprecision(6) << s << endl;
	}
	return 0;
}


Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
#define maxn 100005
#define ll long long

int n;
int idx[maxn];

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        int x;
        scanf("%d", &x);
        idx[x] = i;
    }
    for (int i = 1; i <= n; i++)
        printf("%d ", idx[i]);
    return 0;
}

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

int main()
{
    int N, T;
    cin >> N >> T;
    vector<int> A(N), B(N);
    vector<int> dp(T+1, 0);
    for(int i=0;i<N;i++){
        cin >> A[i] >> B[i];
    }
    vector<int> index(N);
    iota(index.begin(), index.end(), 0);
    sort(index.begin(), index.end(), [&](int i, int j){
        return A[i] < A[j];
    });

    for(auto i : index){
        for(int j=T-1;j>=0;j--){
            auto t = min(j + A[i], T);
            auto v = dp[j] + B[i];
            dp[t] = max(dp[t], v);
        }
    }
    auto res = *max_element(dp.begin(), dp.end());
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    /* チェックリスト
     * 結果はintの範囲を超えていませんか？(必要な時以外はlongを使いましょう)
     * TLEしそうな処理はありませんか？
     */
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String[] in = s.nextLine().split(" ");
        int a = Integer.parseInt(in[0]);
        int b = Integer.parseInt(in[1]);
        int r1 = a + b;
        int r2 = a - b;
        int r3 = a * b;
        if(r1 >= r2){
            if(r1 >= r3){
                System.out.println(r1);
            }else{
                System.out.println(r3);
            }
        }else if(r3 >= r2){
            System.out.println(r3);
        }else{
            System.out.println(r2);
        }
    }
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
const int N=2*1e5+10,Mod=1e9+7;
typedef long long ll;
#define pb push_back
string s,t;
set<int> p[30];
ll ans;
int x;
int main()
{
  cin>>s>>t;
  // cout<<"HERE\n";
  for(int i=0;i<s.size();i++)
  {
    // cout<<(s[i]-'a')<<endl;
    p[s[i]-'a'].insert(i+1);
  }
  int temp=0;
  for(int i=0;i<t.size();i++)
  {
    int val=t[i]-'a';
    // cout<<i<<endl;
    if(p[val].size()==0)
    {
      cout<<"-1\n";
      return 0;
    }
    else
    {
      if(temp!=0)
      {
        auto it=p[val].upper_bound(temp);
        if(it==p[val].end()) x++,temp=*(p[val].begin());
        else temp=*it;
      }
      else temp=*(p[val].begin());
    }
  }
  ans=1ll*x*(s.size())+temp;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5120
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
using namespace std;

int main()
{
    const char one = '1';

    char tmp[4];

    if (scanf("%s", tmp) < 1) return 0;

    int ans = 0;
    if (tmp[0] == one) ans++;
    if (tmp[1] == one) ans++;
    if (tmp[2] == one) ans++;

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


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

int main(){
  string a,b,c;
  cin >> a >> b >>c;
  int dif = 'a' - 'A';
  char A = (int)a.at(0) - dif;
  char B = (int)b.at(0) - dif;
  char C = (int)c.at(0) - dif;
  
  cout << A << B << C;
  return 0;
}


Measured memory_bytes: 256
//╔╗───────────╔╗────────────────────╔╗─
//║║──────────╔╝╚╗──────────────────╔╝╚╗
//║╚═╗╔══╗╔══╗╚╗╔╝╔══╗╔═╗╔╗╔╗╔══╗ ╔╗╚╗╔╝
//║╔╗║║╔╗║║╔╗║─║║─║║═╣║╔╝║╚╝║║╔╗║─╣║─║║─
//║╚╝║║╔╗║║║║║─║╚╗║║═╣║║─║║║║║╚╝║─║║─║╚╗
//╚══╝╚╝╚╝╚╝╚╝─╚═╝╚══╝╚╝─╚╩╩╝╚══╝─╚╝─╚═╝ 

#include <bits/stdc++.h>

#define pb push_back
#define ff first
#define ss second
#define sz size()
#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define forn(i, n) for (int i = 0; i < (int) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;

int main() {
    IO;
    int sx,sy,tx,ty;
    cin >> sx >> sy >> tx >> ty;
    int difx = abs(tx-sx), dify = (ty - sy);

    forn(i,dify){
        cout << 'U';
    }
    forn(i,difx){
        cout << 'R';
    }
    forn(i,dify){
        cout << 'D';
    }
    forn(i,difx){
        cout << 'L';
    }
    cout << 'L';
    dify += 1, difx +=1 ;
    forn(i,dify){
        cout << 'U';
    }
    forn(i,difx){
        cout << 'R';
    }
    cout << "DR";
    forn(i,dify){
        cout << 'D';
    }
    forn(i,difx){
        cout << 'L';
    }
    cout << 'U';
    return 0;
}

Measured memory_bytes: 256
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  var d=input[1].split(' ').map(e=>{
    return e-0;
  }).sort((a,b)=>{
    return a-b;
  });
  console.log(d[N/2]-d[N/2-1]);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,x,n) for(int i=x; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second
#define pb push_back
#define eb emplace_back

using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

template<class A, size_t N, class T> void Fill(A (&a)[N], const T &v){ fill( (T*)a, (T*)(a+N), v ); }

template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"; return os;}
template<class T,size_t n> ostream& operator<<(ostream &os, const array<T,n> &t) {os<<"{"; rep(i,n) {os<<t[i]<<",";} os<<"}"; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}

const ll INF = 1e9+7;


int main(){
	ios_base::sync_with_stdio(false);
	int N, ans=0;
	int b[100005]={};

	cin >> N;
	rep(i,N-1){
		int x, y, a;
		cin >> x >> y >> a;
		b[x] ^= a;
		b[y] ^= a;
	}

	int cnt[16]={};
	rep(i,N) cnt[ b[i] ]++;

	int rest=0;
	rep(i,15){
		ans += cnt[i+1] / 2;
		if( cnt[i+1]%2 ) rest |= (1<<i);
	}

	int dp[1<<15];
	Fill(dp, (int)INF);
	dp[0] = 0;
	rep(k,1<<15){
		auto nex = [&](int h, int &mask){
			h += 1;
			while(h&mask) h += (h&mask);
			return h;
		};
		for(int h = nex(0,k); h < (1<<15); h=nex(h,k)){
			int sum = 0, cnt = 0;
			rep(i,15) if(h & (1<<i)) sum ^= (i+1), cnt++;
			if( sum == 0 ) chmin(dp[k|h], dp[k] + cnt-1);
		}
	}
	ans += dp[rest];

	cout << ans << endl;

	return 0;
}

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

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    ll h, w; cin >> h >> w;
    if (h == 1 || w == 1) {
        cout << 1 << '\n';
        return 0;
    }

    if (h % 2 && w % 2) {
        cout << (h * w) / 2 + 1 << '\n';
    } else if (w % 2 == 0) {
        cout << h * (w / 2) << '\n';
    } else if (h % 2 == 0) {
        cout << (h / 2) * w << '\n';
    } else {
        cout << (h / 2) * w << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <numeric>
#include <map>
#include <vector>
#include <cmath>
#include <iostream>

using namespace std;

typedef long long ll;
typedef pair<ll ,ll> Q;

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

Q qplus(Q a, Q b) {
  ll nume = a.first * b.second + b.first * a.second;
  ll deno = a.second * b.second;
  ll g = gcd(nume , deno);
  return Q(nume/g, deno/g);
}

Q mult(Q a, Q b) {
  ll nume= a.first * b.first;
  ll deno = a.second * b.second;
  ll g = gcd(nume, deno);
  return Q(nume/g, deno/g);
}

int sig(Q a, Q b) {
  ll l = a.first * b.second, r = b.first * a.second;
  if (l == r) return 0;
  if (l < r) return -1;
  return 1;
}

void gain(ll H, ll ih, ll im, ll is, Q t) {
  Q s = qplus(Q(is, 1), t);
  if (s.first / s.second >= 60) {
	s = qplus(s, Q(-60, 1));
	im++;
	if (im == 60) {
	  im = 0;
	  ih++;
	  if (ih == H) ih = 0;
	}
  }
  printf("%ld %ld %ld %ld\n", ih, im, s.first, s.second);
}

Q t[3];

void normalize(Q &a) {
  if (a.first >= a.second)
	a.first -= a.second;
}

Q qmin(Q rs, Q rm, Q rh, ll H) {
  for (int i = 2; i > 0; i--) {
	for (int j = 0; j < i; j++) {
	  if (sig(t[j], t[j+1]) > 0) {
		swap(t[j], t[j+1]);
	  }
	}
  }
  for (int i = 0; i < 3; i++) {
	Q s = qplus(rs, mult(t[i], Q(1, 60)));
	Q m = qplus(rm, mult(t[i], Q(1, 3600)));
	Q h = qplus(rh, mult(t[i], Q(1,3600*H)));
	normalize(s); normalize(m); normalize(h);
	if (t[i].first >= 0 && t[i].second > 0 && sig(s, m) != 0 && sig(s, h) != 0 && sig(m, h) != 0)
	  return t[i];
  }
  return Q(-1, -1);
}

Q calc(ll H, ll ih, ll im, ll is) {
  	Q rs = Q(is, 60), rm = qplus(Q(im, 60), Q(is, 3600)), rh = qplus(Q(ih, H), mult(Q(1, H), rm));
	Q p = qplus(rh, rm);
	Q f = Q(3600*H, 119*H-1);
	Q mrs = mult(rs, Q(-2, 1));
	t[0] = mult(f, qplus(p, mrs));
	t[1] = mult(f, qplus(qplus(p, Q(1,1)), mrs));
	t[2] = mult(f, qplus(qplus(p, mrs), Q(-1,1)));
	return qmin(rs, rm ,rh, H);
}

int main() {
  while (true) {
	ll H, ih, im, is;
	cin >> H >> ih >> im >> is;
	if (H == 0 && ih == 0 && im == 0 && is == 0) break;
	//	t[3] = mult(f, qplus(qplus(rh, mrm), mrs));
	Q res = calc(H, ih, im, is);
	if (res.first == -1 && res.second == -1) {
	  is = 0;
	  im++;
	  if (im == 60) {
		im = 0;
		ih++;
		if (ih == H) ih = 0;
	  }
	  res = calc(H, ih, im, is);
	}
	//	for (int i = 0; i < 3; i++)
	//		  printf("enu:%ld %ld\n", t[i].first, t[i].second);
	//	printf("min:%ld %ld\n", res.first, res.second);

	gain(H, ih, im , is, res);
	//	printf("\n");
  }
}

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

#define FOR(i, a, b) for(long long int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979

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



int main(void) {
	int n;
	int left = 0, right = 0;
	string s, t;

	cin >> n;
	FOR(i, 1, n) {
		cin >> s >> t;
		if (s < t) {
			right += 3;
		}
		else if (s > t) {
			left += 3;
		}
		else {
			right++;
			left++;
		}
	}
	cout << left << " " << right << endl;

	
	
	return 0;
}



Measured memory_bytes: 3152
X,N = list(map(int, input().split()))
ps = list(map(int, input().split()))
ps = set(ps)

if X not in ps:
    print(X)
    exit()

diff = 1
while True:
    if X - diff not in ps:
        print(X - diff)
        exit()
    elif X + diff not in ps:
        print(X + diff)
        exit()
    diff += 1

Measured memory_bytes: 9188
#include <bits/stdc++.h>
using namespace std;
long long  n,m;
int main()
{
	cin >> n >> m;
	if(n == 1 || m == 1)
    {
        cout << 1;
        return 0;
    }
  	if(n % 2 == 0) cout << (n / 2) * m;
    else cout << (n - 1) * m / 2 + (m + 1) / 2;
  	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <functional>
using namespace std;
#define int long long
#define All(v) (v).begin(),(v).end()
int dy[4] = {-1,0,1,0};
int dx[4] = {0,1,0,-1};
int Dy[8] = {-1,-1,0,1,1,1,0,-1};
int Dx[8] = {0,1,1,1,0,-1,-1,-1};
const int mod = 1000000007;
const int inf = mod*mod;
const int d5 = 100100;
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<pair<int,int>> a(n);
    for (int i = 0;i<n;i++){
        cin >> a[i].first >> a[i].second;
    }
    sort(All(a));
    double res = 0;
    int cnt = 0;
    do
    {
        cnt++;
        for (int i = 1; i < n; i++)
        {
            double x = (a[i].first - a[i - 1].first) * (a[i].first - a[i - 1].first);
            double y=(a[i].second - a[i - 1].second) * (a[i].second - a[i - 1].second);
            res += sqrt(x + y);
        }
    } while (next_permutation(All(a)));
    cout << setprecision(20) << res / cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
int main() {

  ll H, W; cin >> H >> W;
  ll Hc;
  ll ans;
  if (W == 1 || H == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (H%2==0){
    Hc=H/2;
    ans = Hc * W;
  }else{
    Hc = H/2 + 1;
    ll Hc2 = Hc-1;
    if (W%2 == 0){
      ans = (Hc +Hc2)*W/2;
    }else{
      ll Wc = W/2;
      ans = (Hc + Hc2) * Wc + Hc;
    }
  }
  cout << ans << endl;
}


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

int main(){
    int h, w;
    while (1){
        cin >> h >> w;
        if (h==0 and w==0) break;
        for (int i = 0; i < h; i++){
            for (int j = 0; j < w; j++){
                if (i%2 == 0){
                    if (j%2 == 0) printf("#");
                    else printf(".");
                } else{
                    if (j%2 == 0) printf(".");
                    else printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 3088
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
 
#define sl(x) scanf("%ld", &x)
#define ss(x) scanf("%s", x)
#define pl(x) printf("%ld\n", x)
#define pd(x) printf("%lf\n", x)
#define ps(x) printf("%s\n", x)
 
#define INF 1000000000000000000
#define MOD 1000000007

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

int compare_long(const void *a, const void *b) {
	return *(long*)b - *(long*)a;
}
 
int main() {
	long A, B, C, tmpA, tmpB, tmpC;
	long i, j;
	long cnt = 0;
	long sum = 0;
	
	sl(A); sl(B); sl(C);
	
	i = 0;
	while(1) {
		if(A % 2 == 1 || B % 2 == 1 || C % 2 == 1) {
			break;
		}
		tmpA = A / 2;
		tmpB = B / 2;
		tmpC = C / 2;
		A += tmpB + tmpC;
		B += tmpA + tmpC;
		C += tmpA + tmpB;
		i++;
		cnt++;
		if(cnt > 1000000) {
			pl((long)-1);
			return 0;
		}
	}
	
	pl(i);
	
	return 0;
}

Measured memory_bytes: 128
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

if __name__ == "__main__":
    n = int(input())
    a = sorted(list(map(int,input().split())))
    M = 1000005
    dp = [0]*(M)
    for i in range(n):
        if dp[a[i]] != 0:
            dp[a[i]] = 2
            continue
        for j in range(a[i],M,a[i]):
            dp[j]+=1
    cnt = 0
    for i in range(n):
        if dp[a[i]] == 1:
            cnt+=1
    print(cnt)

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

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    string str;
    cin>>str;
    string str1;
    cin>>str1;
    string str2;
    int count1, count2;
    cin>>count1>>count2;
    cin>>str2;
    if(str2 == str)
    {
        --count1;
    }
    if(str2== str1)
    {
        --count2;
    }
    cout<<count1<<" "<<count2;
    
    
    return 0;
}

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

if n < 10:
    print(n)
    quit()

count = [[0] * 10 for _ in range(10)]
for i in range(1, 10):
    count[i][i] = 1

d = 1
for i in range(10, n + 1):
    if i % (d * 10)== 0:
        d *= 10
    h = i // d
    f = i % 10
    count[h][f] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += count[i][j] * count[j][i]
print(ans)

Measured memory_bytes: 64004
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define soja(i,a,n) for(ll i=a;i<=n;i++)
int main()
{
    ll n,m,k,sum=0,t,pos,neg;
    cin>>n;
    for(ll i=0;;i++)
    {
        sum=i*1000;
        if(sum>=n)
            break;
    }
   cout<<sum-n<<endl;
    return 0;
}


Measured memory_bytes: 3636
import heapq
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
box=[]
ans=0
for i in range(x):
    heapq.heappush(box,p[i]*(-1))
for i in range(y):
    heapq.heappush(box,q[i]*(-1))
for i in range(c):
    heapq.heappush(box,r[i]*(-1))
for _ in range(x+y):
    ans+=heapq.heappop(box)
print(-1*ans)


Measured memory_bytes: 28976