akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define SREP(s,i,m) for(unsigned int i = s; i < m; ++i)
#define REP(i,m) SREP(0,i,m)

using namespace std;
#ifdef _MSC_VER
using LONG = __int64;
using ULONG = unsigned __int64;
#else
using LONG = long long int;
using ULONG = unsigned long long int;
#endif

int main(void) {
	int N, T;
	cin >> N >> T;
	vector<int> t(N);
	REP(i, N) cin >> t[i];
	ULONG sum = 0;
	REP(i, N - 1) {
		if (t[i + 1] - t[i] >= T) {
			sum += T;
		}
		else {
			sum += t[i + 1] - t[i];
		}
	}
	sum += T;
	cout << sum << endl;
	return 0;
}

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

using namespace std;

#define _47_days ""

typedef long long ll;

const int N = 1e4 + 5;

int n, a[N];

ll ans;

int main() {
    cin >> n;
    n <<= 1;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
    }
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; i += 2) {
        ans += a[i];
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define PI acos(-1.0)
#define mod 1e9+7
using namespace std;
string s1, s2;
int len1, len2;
int dp[3005][3005];
int LCS(int pos1, int pos2)
{
    if(pos1>=len1|| pos2>=len2)
        return 0;
    if(dp[pos1][pos2]!=-1)
        return dp[pos1][pos2];
    if(s1[pos1]==s2[pos2])
    {
        return dp[pos1][pos2]=1+LCS(pos1+1, pos2+1);
    }
    return dp[pos1][pos2]=max(LCS(pos1+1, pos2), LCS(pos1, pos2+1));
}
int main()
{
    memset(dp, -1, sizeof dp);
    cin>>s1>>s2;
    len1=s1.size();
    len2=s2.size();
    int ans=LCS(0, 0);
    int pos1=0, pos2=0;
    //cout<<ans<<endl;
    while(dp[pos1][pos2]>0)
    {
        if(s1[pos1]==s2[pos2]){

            printf("%c", s1[pos1]);
            pos1++, pos2++;
        }
        else if(dp[pos1+1][pos2]>dp[pos1][pos2+1])
            pos1++;
        else pos2++;
    }
    return 0;
}


Measured memory_bytes: 35840
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXN 100005
string str;
bool A[MXN];
ll DP[2][2];

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

    cin>>str;
    int N = SZ(str);
    FOR(i,1,N)A[i]=( str[i-1]=='1' );

    DP[0][0]=1;
    FOR(i,1,N)
    {
        int cur = i%2, prv = (i+1)%2;
        if( A[i]==1 )
        {
            DP[cur][0]=DP[prv][0]*2%MOD;
            DP[cur][1]=(DP[prv][1]*3+DP[prv][0])%MOD;
        }
        else
        {
            DP[cur][0]=DP[prv][0];
            DP[cur][1]=DP[prv][1]*3%MOD;
        }
    }
    cout<<( DP[N%2][0]+DP[N%2][1] )%MOD<<'\n';

    return 0;
}


Measured memory_bytes: 592
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Math;
using static System.Array;
using static AtCoderSolve.Tool;

namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        const int INF = int.MaxValue / 2;
        const long SINF = long.MaxValue / 2;


        static void Main(string[] args)
        {
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);
            var cin = new Scanner();

            var input = cin.SplitReader();
            int a = input[0];
            int b = input[1];
            int c = input[2];
            Console.WriteLine((c - a) * (c - b) < 0 ? "Yes" : "No");

            //Console.Out.Flush();
        }

    }

    public class Scanner
    {
        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }

    public static class Tool
    {
        static public void Initialize<T>(ref T[] array, T initialvalue)
        {
            for(var i = 0; i < array.Length; i++)
            {
                array[i] = initialvalue;
            }
        }
        static public long ModuloP(long value,long mod)
        {
            long r = value % mod;
            
            if (r * mod < 0)
            {
                r += mod;
            }
            return r;
        }

    }

    struct Pair<T> : IComparable<Pair<T>> where T : IComparable<T>
    {
        public T variable;
        public int index;

        public Pair(T val, int i)
        {
            variable = val;
            index = i;
        }

        public int CompareTo(Pair<T> otherPair)
        {
            return variable.CompareTo(otherPair.variable);
        }

        public int CompareIndex(Pair<T> otherPair)
        {
            return index.CompareTo(otherPair.index);
        }
    }

    

}






Measured memory_bytes: 13268
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;

// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>

vector <ll> v;

ll fep(ll x, ll y, ll mod)
{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
    y=y>>1;x=(x*x)%mod;}return res%mod;}

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

	ll n,i,m,j,k,x,y,a,b,c,d,t;
	string s;
	
	cin >> n;
	set <string> st;
	for(i=0;i<n;i++)
	{
		cin >> s;
		st.insert(s);
	}
	cout << st.size();

	return 0;
}


Measured memory_bytes: 19136
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	string S;
	int K;
	cin >> S >> K;
	int L = S.size();
	for (int i = 0; i < L; i++) {
		int n = S[i] - 'a';
		if (K >= 26 - n) {
			K -= (26 - n) % 26;
			S[i] = 'a';
		}
	}
	S[L - 1] = (char)(((S[L - 1] - 'a' + K) % 26) + 'a');
	cout << S << endl;
}

Measured memory_bytes: 512
#include <cstdlib>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> x(n);
  vector<int> y(n);
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }

  const int kMax = 100;
  for (int cx = 0; cx <= kMax; cx++) {
    for (int cy = 0; cy <= kMax; cy++) {
      int H = -1;
      for (int i = 0; i < n; i++) {
        if (h[i] == 0) {
          continue;
        }
        const int tmp = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
        if (H == -1) {
          H = tmp;
        } else {
          if (H != tmp) {
            H = -1;
            break;
          }
        }
      }
      if (H < 0) continue;

      for (int i = 0; i < n; i++) {
        if (h[i] == 0) {
          const int dist = abs(x[i] - cx) + abs(y[i] - cy);
          if (H > dist) {
            H = -1;
            break;
          }
        }
      }
      if (H < 0) continue;

      cout << cx << " " << cy << " " << H << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <sstream>
#include <string>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define EPS 1e-14
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define REP(i,n) FOR(i, 0, n)
#define PI 2*acos(0.0)
#define ALL(a) (a).begin(),(a).end()
#define DEBUG(x) cout<<#x <<": "<< x << "\n"
#define DEBUG_ARR(a) REP(i, size(a)){ cout << #a << "[" << i << "]: " << a[i] << "\n"; }
const int VX[] = { 0, 1, 0, -1 };
const int VY[] = { 1, 0, -1, 0 };
const long MOD = 1000000007;

int main() {
	//	--- I/O 高速化 ---
	cin.tie(0);
	ios::sync_with_stdio(false);
	// --- ここまで ---

	int N, a;
	cin >> N;

	int arr[100000 + 2] = {0};

	REP(i, N)
	{
		cin >> a;
		arr[a]++;
		if (a != 0) arr[a - 1]++;
		arr[a + 1]++;
	}

	int max = 0;
	for(int i = 0; i <= 100000; i++)
	{
		if (max < arr[i]) max = arr[i];
	}

	cout << max << "\n";

	return 0;
}



Measured memory_bytes: 768
import sys
n, k = map(int, input().split())

n = abs(n - k)

if k == n:
    print(0)
    sys.exit()
elif k > n:
    print(min(n, k-n))
    sys.exit()
else:
    while n > k:
        n %= k
    print(min(n%k, abs(n-k)))

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

using namespace std;
typedef long long ll;
typedef pair<int,int> pa;
int mod=1e9+7;
const int N=2e5+100;

int num[N],cnt[N];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++) scanf("%d",&num[i]);
    for(int i=1;i<=k;i++){
        for(int j=1;j<=n;j++){
            int l=max(1,j-num[j]);
            int r=min(n+1,j+num[j]+1);
            cnt[l]++,cnt[r]--;
        }
        bool f=true;
        for(int i=1;i<=n;i++){
            num[i]=num[i-1]+cnt[i];
            cnt[i]=0;
            if(num[n]==n) f=false;
        }
        if(!f) break;
    }
    for(int i=1;i<=n;i++)
        printf("%d ",num[i]);
    return 0;
}



Measured memory_bytes: 5304
#include<stdio.h>

int main(){
char S[100001];
  int siro=0,kuro=0,i,fsiro=0,fkuro=0;
  scanf("%s",S);
  
  for(i=0;i<100001;i++){
    if(S[i]=='0'){
   if(i%2==1) fsiro++;
       if(i%2==0)fkuro++;
    }
    if(S[i]=='1'){
   if(i%2==0) fsiro++;
     if(i%2==1)fkuro++;
    }
     if(S[i]=='\0')
       break;
    
}
if(fsiro>fkuro)
  printf("%d",fkuro);
  else printf("%d",fsiro);
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A { public static void Main() => (new Solver()).Solve(); }

public class Solver
{
	public void Solve()
	{
		WriteLine(GetString().Split('S').Aggregate(0, (x, a) => x = Max(x, a.Length)));
	}
}

public static class MyIO
{
	private static string[] args = new string[0];
	private static int cnt = 0;
	private static IEnumerable<string> getArgs(long N) => Range(0, N).Select(_ => getArg());
	private static string getArg()
	{
		if(cnt == args.Length) { args = Console.ReadLine().Split(); cnt = 0; }
		return args[cnt++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => getArgs(N).Select(int.Parse).ToArray();
	public static long[] GetLongs(long N) => getArgs(N).Select(long.Parse).ToArray();
	public static double[] GetDoubles(long N) => getArgs(N).Select(double.Parse).ToArray();
	public static decimal[] GetDecimals(long N) => getArgs(N).Select(decimal.Parse).ToArray();
	public static string[] GetStrings(long N) => getArgs(N).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) < 0) x = y; }
	public static void chmin<T>(ref T x, T y) where T : IComparable<T> { if(x.CompareTo(y) > 0)	x = y; }
	public static void swap<T>(ref T x, ref T y) { T tmp = x; x = y; y = tmp; }
	public static long rightShift(long x, long y) => (x >> (int)y);
	public static long leftShift(long x, long y) => (x << (int)y);
	public static bool contains(long s, long x) => (rightShift(s, x) & 1L) == 1L;
	public static long gcd(long x, long y) => (y == 0) ? x : gcd(y, x % y);
	public static long lcm(long x, long y) => (x / gcd(x,y)) * y;	
	public static IEnumerable<int> Range(long start, long count) => Enumerable.Range((int)start, (int)count);
	public static void Sort(this List<string> source) => source.Sort(StringComparer.Ordinal);
}


Measured memory_bytes: 26116
#include <iostream>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <climits>

using namespace std;

int main(){
    int n; cin >> n;
    unordered_map<int, int> mp;
    for(int i=0; i<n; ++i){
        int a; cin >> a;
        ++mp[a];
    }
    int num_even=0, num_odd=0;
    for(auto& p : mp){
        if(p.second%2) ++num_odd;
        else ++num_even;
    }
    cout << num_odd+num_even-num_even%2 << endl;
    return 0;
}


Measured memory_bytes: 4388
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define pb push_back
const int maxn = 10000;
const int INF32 = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7 = 1'000'000'007;
const int MOD9 = 1'000'000'009;

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};

int n, y;
int n1, n2, n3;

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

	for(int n1 = 0; n1 <= n; n1++)
	for(int n2 = 0; n2 <= n; n2++)
	{
		n3 = n - n1 - n2;
		int res = 10000 * n1 + 5000 * n2 + 1000 * n3;
		if(n3>=0 && res == y)
		{	
			printf("%d %d %d\n", n1, n2, n3);
			return 0;
		}
	}
	printf("-1 -1 -1\n");
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int N = 55;
int n;
int arr[N];
int p;
long long dp[N][2];
long long solve(int pos , bool parity){
	if(pos > n){
		return parity == p;
	}
	if(dp[pos][parity] != -1){
		return dp[pos][parity];
	}
	long long res = 0;
	res += solve(pos + 1 , parity);
	res += solve(pos + 1 , parity ^ arr[pos]);
	return dp[pos][parity] = res;
}
int main(){
	scanf("%d %d" , &n , &p);
	for(int i = 1 ; i <= n ; ++i){
		scanf("%d" , &arr[i]);
		arr[i] %= 2;
	}
	memset(dp , -1 , sizeof(dp));
	printf("%lld\n" , solve(1 , 0));
}

Measured memory_bytes: 764
#include <iostream>

using namespace std;

template <size_t N>
struct Solver
{
    bool is_prime[N + 1];
    int ans[N + 1];
    constexpr Solver() : is_prime(), ans()
    {
        is_prime[0] = false;
        is_prime[1] = false;
        for (size_t i = 2; i <= N; i++)
        {
            is_prime[i] = true;
        }
        for (size_t prime = 2; prime <= N; prime++)
        {
            if (is_prime[prime])
            {
                for (size_t q = prime * 2; q <= N; q += prime)
                {
                    is_prime[q] = false;
                }
            }
        }
        for (size_t i = 1; i <= N; i++)
        {
            ans[i] += ans[i - 1];
            if (is_prime[i] && is_prime[(i + 1) / 2])
            {
                ans[i] += 1;
            }
        }
    }
};

int main()
{
    ios::sync_with_stdio(false);

    constexpr auto M = 100000;
    constexpr auto solver = Solver<M>();
    int Q;
    cin >> Q;
    for (size_t i = 0; i < Q; i++)
    {
        int l, r;
        cin >> l >> r;
        auto ans = solver.ans[r] - solver.ans[l - 1];
        printf("%d\n", ans);
    }
}


Measured memory_bytes: 1152
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<deque>
#include<iomanip>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
using namespace std;

#define pb push_back
//#define mp make_pair
#define myfor(i, a, b) for (int i = a; i < b; ++i)

template<typename T>inline bool upmin(T &x,T y) { return y<x?x=y,1:0; }

const double PI = acos(-1.0);
const double EPS = 1e-6;
const int INF = 0x3f3f3f3f;

int n;
int a[60], b[60], ind[20];

bool vis[60];

int main()
{
    cin >> n;
    myfor(i, 1, n + 1) cin >> a[i];
    myfor(i, 1, n + 1) cin >> b[i];

    int ans = INF;
    myfor(i, 0, (1 << n)) {
        int cnt = 0;

        vector<int> tp;

        myfor (j, 0, n) {
            if ((i >> (n - j - 1)) & 1) tp.pb(b[j + 1]);
            else tp.pb(a[j + 1]);
        }
        sort(tp.begin(), tp.end());

        bool vis[20];
        bool flag = true;
        memset(vis, 0, sizeof(vis));
        memset(ind, 0, sizeof(ind));

        myfor(j, 0, n) {
            bool _flag = false;
            if ((i >> (n - j - 1)) & 1) {
                myfor(k, 0, n) if (!vis[k] && (b[j + 1] == tp[k])) {
                    int move_cnt = abs(j - k);

                    if (move_cnt & 1) {
                        _flag = true;
                        vis[k] = 1;
                        ind[j] = k;
                        break;
                    }
                }
                if (!_flag) flag = false;
            }
            else {
                myfor(k, 0, n) if (!vis[k] && (a[j + 1] == tp[k])) {
                    int move_cnt = abs(j - k);
                    if (!(move_cnt & 1)) {
                        _flag = true;
                        vis[k] = 1;
                        ind[j] = k;
                        break;
                    }
                }
                if (!_flag) flag = false;
            }
        }

        if (flag) {
            myfor(j, 0, n) {
                for (int k = n - 1; k > j; k--) if (ind[k] < ind[k - 1]) {
                    cnt++;
                    swap(ind[k], ind[k - 1]);
                }
            }
            ans = min(ans, cnt);
        }
    }

    cout << ((ans == INF) ? -1 : ans) << endl;
    return 0;
}



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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	int n;
	cin>>n;
	vector<int> a(n);
	for(int& x:a){
		cin>>x;
		--x;
	}
	int res=0,i=0;
	while(i!=1){
		if(res>n){
			cout<<"-1\n";
			return 0;
		}
		i=a[i];
		++res;
	}
	cout<<res<<'\n';
}




Measured memory_bytes: 3720
N, M, X  = map(int, input().split())

C = [list(map(int, input().split())) for i in range(N)]

ans = 10**7

for i in range(2**N):
  bit = format(i, "0" + str(N) +'b')
  skill = [0]*M
  cost = 0
  for j in range(N):
    if bit[j] == "1":
      cost += C[j][0]
      for s in range(M):
        skill[s] += C[j][s+1]

  tmp = 0
  for j in range(M):
    if skill[j] >= X:
      tmp += 1
    else:
      break
  
  if tmp == M:
    ans = min(ans,cost)
  
  #print(ans,cost,skill,bit)




if ans == 10**7:
  print(-1)

else:
  print(ans)

Measured memory_bytes: 9232
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(n)-1;i>=a;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define ss st.st
#define sn st.nd
#define mod 1000000007
/****************************/
int x[100010];
int y[100010];
int main()
{
	int a,b,m;
	cin>>a>>b>>m;
	rep(i,a)
	{
		cin>>x[i];
	}
	rep(i,b)
	{
		cin>>y[i];
	}
	ll ans=mod;
	rep(i,m)
	{
		int d,e,f;
		cin>>d>>e>>f;
		ans=min(ans,(ll)(x[d-1]+y[e-1]-f));
	}
	sort(x,x+a);
	sort(y,y+b);
	ans=min(ans,(ll)(x[0]+y[0]));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define INF 1 << 29
#define LLINF 1LL << 60
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll fact(ll a){ll b=1;FOR(i,1,a)b*=i;return b;}

class P
{
public:
  double x,y;
  P(){};P(double x,double y):x(x),y(y){};
  P operator+(const P&q){P t;t.x=x+q.x;t.y=y+q.y;return t;}
  P operator+=(const P&q){x+=q.x;y+=q.y;return *this;}
  P operator-(const P&q){P t;t.x=x-q.x;t.y=y-q.y;return t;}
  P operator-=(const P&q){x-=q.x;y-=q.y;return *this;}
  template<typename T> P operator*(T d){return P(x*d,y*d);}
  template<typename T> P operator*=(T d){x*=d;y*=d;return *this;}
  template<typename T> P operator/(T d){return P(x/d,y/d);}
  template<typename T> P operator/=(T d){x/=d;y/=d;return *this;}
  bool operator<(const P&q){return (x!=q.x)?(x<q.x):(y<q.y);}
  bool operator>(const P&q){return (x!=q.x)?(x>q.x):(y>q.y);}
  double norm(void){return sqrt(x*x+y*y);}
  double arg(void){return acos(x/this->norm())*P(1,0).sign(*this);}
  P nvec(){return P(y,-x);}
  P rotate(double t){double c=cos(t),s=sin(t);return P(c*x-s*y,s*x+c*y);}
  P reverseX(void){return P(-x,y);}
  P reverseY(void){return P(x,-y);}
  P unit(void){return (*this).norm()==0?P(0,0):(*this)/(*this).norm();}
  P floor(void){return P((int)x,(int)y);}
  double dot(const P&q){return x*q.x+y*q.y;}
  double det(const P&q){return x*q.y-y*q.x;}
  int sign(const P&q){double d = (*this).det(q); return (d>0)-(d<0);}
  static bool on_seg(P p1,P p2,P q){return (p1-q).det(p2-q)==0&&(p1-q).dot(p2-q)<=0;}
  static P intersection(P p1,P p2,P q1,P q2){return p1+(p2-p1)*((q2-q1).det(q1-p1)/(q2-q1).det(p2-p1));}
  static bool crossing(P p1,P p2,P q1,P q2)
  {
    if((p2-p1).sign(q2-q1)==0) return on_seg(p1,p2,q1)||on_seg(p1,p2,q2)||on_seg(q1,q2,p1)||on_seg(q1,q2,p2);
    double x=(q2-q1).det(q1-p1)/(q2-q1).det(p2-p1);
    double y=(p2-p1).det(p1-q1)/(p2-p1).det(q2-q1);
    return x<=1 && x>=0 && y<=1 && y>=0;
  }
};



int main()
{
  int q; cin >> q;
  REP(i,q)
  {
    int ans;
    double x0,y0,x1,y1,x2,y2,x3,y3;
    cin>>x0>>y0>>x1>>y1>>x2>>y2>>x3>>y3;

    cout << P::crossing(P(x0,y0),P(x1,y1),P(x2,y2),P(x3,y3)) << endl;
  }
  return 0;
}

Measured memory_bytes: 3204
#!/usr/bin/env python3
import bisect
import sys
import math
sys.setrecursionlimit(10**6)


n, h = list(map(int, input().split()))

a = []
b = []
ab = []
for i in range(n):
    a_tmp, b_tmp = list(map(int, input().split()))
    a.append(a_tmp)
    b.append(b_tmp)
    # ab.append((b_tmp, a_tmp))

a_max = max(a)
b.sort()

index = bisect.bisect_right(b, a_max)

ans = 0
for i in reversed(range(index, n)):
    h -= b[i]
    ans += 1
    if h <= 0:
        break

# print(h)
if h > 0:
    ans += math.ceil(h/a_max)

print(ans)


Measured memory_bytes: 17184
import java.util.Scanner;
 public class Main{

	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Double r = sc.nextDouble();
        Double a;
        Double b;
        a=r*r*Math.PI;
        b=r*2*Math.PI;
        
        System.out.printf("%.6f ",a);
         System.out.printf("%.6f",b);
	}

 }


Measured memory_bytes: 28452
#include<iostream>
using namespace std;
int main(){
  int a,b;
  while(cin>>a>>b){
    if(a==0 && b==0){
      break;
    }
    else{
      for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
          if(i==0||i==a-1||j==0||j==b-1){
          cout<<"#";
          }
          else{
             cout<<".";
          }
        }
        cout<<endl;
      }
    }
    cout<<endl;
  }
 return 0;
}


Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>
int main(void)
{
  int N = 0;
   
  scanf("%d", &N);
 
  if(N%2==0){
    printf("%d", N/2);
  }else{
    printf("%d", (N+1)/2);
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define M 1000000007
#define INF 999999999
#define EPS 1e-9
#define pb push_back
#define mp make_pair
#define SET(a) memset(a,-1,sizeof(a))
#define CLR(a) memset(a,0,sizeof(a))
using namespace std;
 typedef  long long  int ll;
 typedef pair<int,int> ii;
 typedef vector<ii> vii;
 typedef vector <ll > vi;

ll arr[100005];

int main()
{
// freopen("input.txt","r",stdin);
 // freopen("output.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
 ll n,a,b;
 string s1,s2,s3;
 ll cnt=0,sum=0;

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


return 0;
}



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

int main() {
    string W;
    cin >> W;
    int64_t cnt=0;
    while (1)
    {
        string x;
        cin >> x;
        if(x=="END_OF_TEXT") break;
        string z = x;

        for(int i=0; i<z.size(); i++){
            if(isupper(z.at(i))) z.at(i)=tolower(z.at(i));
        }

        if(z.size()>=W.size()){
            string dmy;
            for(int i=0; i<z.size(); i++){
                if(isalpha(z.at(i))) dmy.push_back(z.at(i));
            }
            z=dmy;
        }
        if(z == W) cnt++;
    }
    cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 3208
#include<stdio.h>
int main(void)
{
	int A,B,C;
	scanf("%d %d %d",&A,&B,&C);
	 if(A==B&&A!=C) printf("Yes\n");
	else if(A==C&&A!=B) printf("Yes\n");
	else if(C==B&&C!=A) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
    string s,t;cin>>s>>t;
    sort(all(s));sort(all(t));reverse(all(t));
    vector<string>a(2);a[0]=s;a[1]=t;
    if(s==t){cout<<"No"<<endl;return 0;}
    sort(all(a));
    if(a[0]==s){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def factori(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


A, B = map(int, input().split())
G = gcd(A, B)

if G == 1:
    print(1)
else:
    print(len(factori(G)) + 1)


Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<iosfwd>
#include<sstream>
#define N 100
using namespace std;
int main(void){
    string s;
    cin >> s;

    const char* x= s.c_str();
    
    // cout << atoi(s.c_str()) << endl;
    for(int i=0; i<strlen(x); i++){
        if(i==3) cout << "8";
        else cout << x[i];
    } cout << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void){
  char s[101], t[101], tmp;
  int ls, lt, i, j;
  
  scanf("%s %s", s, t);

  ls = strlen(s);
  lt = strlen(t);
 
  for( i = 0; i < ls; i++){
    for( j = i+1; j < ls; j++){
      if(s[i] > s[j]){
	tmp = s[i];
	s[i] = s[j];
	s[j] = tmp;
      }
    }
  }
  for( i = 0; i < lt; i++){
    for( j = i+1; j < lt; j++){
      if(t[i] < t[j]){
	tmp = t[i];
	t[i] = t[j];
	t[j] = tmp;
      }
    }
  }

  if(strcmp(s, t) < 0) printf("Yes");
  else printf("No");
  return 0;
  
 
  
}
  


Measured memory_bytes: 128
#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;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int mod=1e9+7;
ll l,r;
int dp[70][2][2][2];
int add(int x,int y)
{
  x+=y;
  if(x>=mod) x-=mod;
  if(x<0) x+=mod;
  return x;
}
int fun(int ind,bool low,bool high,bool set)
{
  if(ind==-1) return 1;
  if(dp[ind][low][high][set]!=-1) return dp[ind][low][high][set];
  int ans=0;
  rep(i,0,2)
    rep(j,0,2)
    {
      if(!set && (i!=j)) continue;
      if(i>j) continue;
      int x1=!!(l&(1LL<<ind));
      int y1=!!(r&(1LL<<ind));
      if(!low && i<x1) continue;
      if(!high && j>y1) continue;
      ans=add(ans,fun(ind-1,low | (i>x1), high | (j<y1), set| (i==1)));
    }
  return dp[ind][low][high][set]=ans;
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  memset(dp,-1,sizeof(dp));
  cin>>l>>r;
  cout<<fun(60,0,0,0)<<endl;
  return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>


int main(){
    char s[5];
    scanf("%s",s);
    int i,plus,minus;
    plus=0;
    minus=0;
    for(i=0;i<4;i++){
        if(s[i] == '+'){
            plus += 1;
        }else
        {
            minus += 1;
        }
    }
    printf("%d",plus - minus);
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
int K,N;
cin >> N >> K;
int A[N];
for (int i=0;i<N;i++)
{
	cin >> A[i];
}
int a;
for(int i=0;i<N-1;i++)
{
	for(int j=0;j<N-i-1;j++)
	{
	   if(A[j]<A[j+1])
	   {
	   	a=A[j];
	   	A[j]=A[j+1];
	   	A[j+1]=a;
		}	
	}
}
int b=0;
for (int i=0;i<K;i++)
{
	b=b+A[i];
}
cout << b <<endl;


return 0;	
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int h = scanner.nextInt();

		System.out.println((a+b)*h/2);
	}
}

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

int main() {
  int n,k;
  cin >> n >>k;
  vector<int> height(n);
  int count=0;
  for(int i=0;i<n;i++){
  	cin >> height.at(i);
    if(height.at(i) >= k){
      count++;
    } 
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int N,M;
vector<P> G[100010];
int vis[100010],dis[100010];
bool f=true;
void dfs(int x){
	vis[x]=1;
	for(int i=0;i<(int)G[x].size();i++){
		if(vis[G[x][i].first]==0){
			dis[G[x][i].first]=dis[x]+G[x][i].second;
			dfs(G[x][i].first);
		}else{
			if(dis[G[x][i].first]!=dis[x]+G[x][i].second){
				f=false;
				return;
			}
		}
	}
}

int main(void){
	          int i;

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

	      	  cin >> N >> M;

	      	  for(i=0;i<M;i++){
	      		  int L,R,D;
	      		  cin >> L >> R >> D;
	      		  L--; R--;
	      		  G[L].push_back(P(R,D));
	      		  G[R].push_back(P(L,-D));
	      	  }

	      	  for(i=0;i<N;i++){
	      		  if(vis[i]==0){
	      			  dis[i]=0;
	      			  dfs(i);
	      		  }
	      	  }

	      		  if(!f){
	      			  cout << "No" << endl;
	      			  return 0;
	      		  }


	      	  cout << "Yes" << endl;


	          return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  for (int i = 0; i < N; i++) {
    string S;
    cin >> S;
    
    if (S == "Y"){
      cout << "Four" <<endl;
      break;
    }
    else {
      if (i + 1 >= N){
        cout << "Three" <<endl;
        break;
      }
    }
  }
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int N, a[100001];
    cin >> N;
    FOR(i, 1, N + 1, 1) {
        cin >> a[i];
    }
    int cnt[100001] = {};
    int b = 1, res = 0;
    while (1) {
        if (cnt[b] > 0) {
            cout << -1 << endl;
            break;
        }
        cnt[b]++;
        b = a[b];
        res++;
        if (b == 2) {
            cout << res << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>

using namespace std;

int main()
{

    int n, m;
    string s[101], t[101];
    vector<int> count(101);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    cin >> m;
    for (int j = 0; j < m; j++)
    {
        cin >> t[j];
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (s[i] == s[j])
            {
                count[i]++;
            }
        }
        for (int j = 0; j < m; j++)
        {
            if (s[i] == t[j])
            {
                count[i]--;
            }
        }
    }
    // for (int i = 0; i < n; i++)
    // {
    //     cout << count[i] << endl;
    // }
    cout << *max_element(count.begin(), count.end()) << endl;
    return 0;
}


Measured memory_bytes: 256
w, h, n = map(int, input().split())
x = []
y = []
a = []
for i in range(n):
    X, Y, A = map(int, input().split())
    x.append(X)
    y.append(Y)
    a.append(A)

xmin = 0
xmax = w
ymin = 0
ymax = h

for i in range(n):
    if a[i] == 1:
        xmin = max(xmin, x[i])
    elif a[i] == 2:
        xmax = min(xmax, x[i])
    elif a[i] == 3:
        ymin = max(ymin, y[i])
    elif a[i] == 4:
        ymax = min(ymax, y[i])

if xmin > xmax or ymax < ymin:
    print(0)
else:
    print((xmax - xmin) * (ymax - ymin))


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

int n,d,a[15][15],ans=0;

bool scoring(int x,int y)
{
	double s=0;
	for(int i=1;i<=d;s+=1.0*(a[x][i]-a[y][i])*(a[x][i]-a[y][i]),i++);
	s = sqrt(s);
	return s==(int)s;
}

int main()
{
	cin>>n>>d;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=d;cin>>a[i][j],j++);
	for(int i=1;i<n;i++)
		for(int j=i+1;j<=n;j++)
			if(scoring(i,j))
				ans++;
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

class Main {
    public static Scanner sc = new Scanner(in);
    public static Random rand=new Random();


    public int getCount(int x,int y,char my,char enemy){
    	int D=0;
    	L:for(int i=0;i<8;i++){
			int ds=0;
			int px=x,py=y;
			px+=d[i][0];
			py+=d[i][1];
			if(!(0<= px && px<8 && 0<= py && py<8))
				continue L;

			while(map[py][px]==enemy){
				ds++;
				px+=d[i][0];
				py+=d[i][1];
				if(!(0<= px && px<8 && 0<= py && py<8))
					continue L;
			}
			if(map[py][px]==my)
				D+=ds;
		}
    	return D;
    }

    public void setCookie(int x,int y,char my ,char enemy){
    	map[y][x]=my;
    	D:for(int i=0;i<8;i++){
			int px=x,py=y;
			px+=d[i][0];
			py+=d[i][1];
			if(!(0<= px && px<8 && 0<= py && py<8))
				continue D;
			while(map[py][px]==enemy){
				px+=d[i][0];
				py+=d[i][1];
				if(!(0<= px && px<8 && 0<= py && py<8))
					continue D;
			}
			if(map[py][px]==my){
				px-=d[i][0];
				py-=d[i][1];
				while(!(px==x && py==y)){
					map[py][px]=my;
					px-=d[i][0];
					py-=d[i][1];
				}
			}
		}
    }

    char[][] map;
	int[][] d;
    public void run() {
    	map=new char[8][8];
    	for(int i=0;i<8;i++){
    		map[i]=sc.next().toCharArray();
    	}

    	boolean mami=true;
    	d=new int[][]{
    			{1,0},{1,1},
    			{0,1},{-1,1},
    			{-1,0},{-1,-1},
    			{0,-1},{1,-1}
    	};

    	boolean prevpass=false;

    	while(true){
    		int max=0,resx=-1,resy=-1;
    		for(int y=0;y<8;y++)for(int x=0;x<8;x++){
    			if(map[y][x]!='.')continue;
    			int D=getCount(x,y,mami?'o':'x',mami?'x':'o');
    			if(mami){
	    			if(max<D){
	    				max=D;
	    				resx=x;
	    				resy=y;
	    			}
    			}else{
    				if(max<=D){
	    				max=D;
	    				resx=x;
	    				resy=y;
	    			}
    			}
    		}

    		if(max>0){
    			setCookie(resx,resy,mami?'o':'x',mami?'x':'o');
        		prevpass=false;
    		}else{
    			if(!prevpass)
    				prevpass=true;
    			else{
    				for(int y=0;y<8;y++){
        				for(int x=0;x<8;x++)
        					pr(map[y][x]);

        				ln();
    				}
    				return;
    			}
    		}

    		mami=!mami;
    	}
   }
    public static void main(String[] args) {
        new Main().run();
    }

    public int[] nextIntArray(int n){
        int[] res=new int[n];
        for(int i=0;i<n;i++){
            res[i]=sc.nextInt();
        }
        return res;
    }
    public static void pr(Object o) {
        out.print(o);
    }
    public static void ln(Object o) {
        out.println(o);
    }
    public static void ln() {
        out.println();
    }
}

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

#define yes cout << "Yes" << endl
#define no cout << "No" << endl

int main()
{
    int a, b, c;

    cin >> a >> b >> c;

    if(a == b && b == c)
        no;
    else if(a == b && b != c)
        yes;
    else if(b == c && c != a)
        yes;
    else if(c == a && a != b)
        yes;
    else if(a != b && b != c && a != c)
        no;

    return 0;
}


Measured memory_bytes: 256
//
// Created by Mahmoud Rashad on 11/27/19.
//

#include <bits/stdc++.h>


using namespace std;

typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<ii, ii>> vii;



int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.out", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(10), cout << fixed;

    int n;
    cin >> n;
    vector<int> arr(n);
    for (int &x : arr)
        cin >> x;
    sort(arr.begin(), arr.end());
    double cur = arr[0];
    for (int i = 1; i < n; ++i) {
        cur += arr[i];
        cur /= 2;
    }

    cout << cur << '\n';


    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.Arrays;
import java.util.Stack;
import java.util.StringTokenizer;
public class Main{
    static String s;
    static String t;
    static int n;
    static int m;
    static int[][] memo;
    public static void main(String[] args) throws IOException {
        scanner sc = new scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        s = sc.next();
        t = sc.next();
        n = s.length();
        m = t.length();

        memo = new int[n][m];

        for (int i = 0; i < n; i++)
           Arrays.fill(memo[i],-1);
        dp(0,0);
        int i;
        int j;
        for (i = j = 0; i < n && j < m;) {

            if (s.charAt(i) == t.charAt(j)){
                out.print(s.charAt(i));
                i++;j++;
            }

            else if (i < n-1 && j < m-1){
                if (memo[i+1][j] > memo[i][j+1]){
                    i++;
                }
                else j++;
            }
            else if (j == m-1) i++;
            else if (i == n-1) j++;
            else break;



        }
        out.flush();

    }

    static int dp(int i,int j){
        if (i == n || j == m)
            return 0;

        if (memo[i][j] != -1)
            return  memo[i][j];
        int one = 0;
        if (s.charAt(i) == t.charAt(j))
            one = dp(i+1,j+1) + 1;
        else {
            one = Math.max(dp(i+1,j),dp(i,j+1));
        }
        return memo[i][j] = one;
    }

}
class scanner{
    StringTokenizer st;
    BufferedReader br;
    public scanner(InputStream s){
        br = new BufferedReader(new InputStreamReader(s));
    }
    public scanner (String s) throws FileNotFoundException { br = new BufferedReader(new FileReader(s));}

    public String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

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

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

    public String nextLine() throws IOException {
        return br.readLine();
    }

    public boolean ready() throws IOException {
        return br.ready();
    }
}

Measured memory_bytes: 82660
#include <stdio.h>

int main(void)
{
	char s[1000],ab[]={"abcdefghijklmnopqrstuvwxyz"};
	long long N,i;
	int a[1000],count=0;
	scanf("%lld",&N);
	for(i=N;i>0;){
		if(i%26!=0){a[count]=i%26;i=(i-i%26)/26;}
		else {a[count]=26;i=(i-26)/26;}
		count++;
	}
	for(i=count-1;i>=0;i--){
		printf("%c",ab[a[i]-1]);
	}
	return 0;
}

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

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

  for(int i=0; i<len; i++){
    s[i] = (s[i]-'A' + n) % 26 + 'A';
  }
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
int main()
{    // Your code here!
    int a,b,c,d,e;
    scanf("%d%d%d%d%d",&a,&b,&c,&d,&e);
    if(a<0)
    {
        printf("%d\n",(0-a)*c+d+(b-0)*e);
    }
    else if(a==0)
    {
        printf("%d\n",d+(b-0)*e);
    }
    else
    {
        printf("%d\n",(b-a)*e);
    }
}



Measured memory_bytes: 2752
a,b,c = map(int, input().split())
ar = [a,b,c]
ar.sort()
t = ar[2]#max
u = ar[1]
v = ar[0]#min
tu = t - u
tv = t - v
count = 0
if tu % 2 == 0 and tv % 2 == 0:
  count += tu
  count += int((tv - tu) / 2)
elif tu % 2 != 0 and tv % 2 != 0:
  count += tu
  count += int((tv - tu) / 2)
else:
  count += tu
  count += int((tv - tu - 1) / 2) + 2

print(count)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
using namespace std;
int h,w;
bool ans;
char z;
bool vis[10][10];
void DFS(int y,int x){
	vis[y][x]=true;
	if(y==h-1&&x==w-1){
		bool ok=true;
		for(int i=0;i<h;i++)for(int j=0;j<w;j++)if(vis[i][j]==false)ok=false;
		if(ok)ans=true;
		return;
	}
	if(x<w-1)if(vis[y][x+1]==false)DFS(y,x+1);
	if(y<h-1)if(vis[y+1][x]==false)DFS(y+1,x);
	vis[y][x]=false;
}
int main(){
	ans=false;
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			vis[i][j]=false;
			cin>>z;
			if(z=='.')vis[i][j]=true;
		}
	}
	DFS(0,0);
	if(ans)cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(ll i=0; i<(ll)n; i++)
#define REPR(i, n) for(ll i=(ll)n-1; i>=0; i--)
#define FOR(i, m, n) for(ll i=(ll)m; i<(ll)n; i++)
#define FORR(i, m, n) for(ll i=(ll)m-1; i>=(ll)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
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; }
void rcmb(ll *x,ll s,ll r,function<void(ll *)>f){if(r==0){f(x);}else{if(s<0)return;rcmb(x,s-1,r,f);x[r-1]=s;rcmb(x,s-1,r-1,f);}}
void cmb(ll n,ll k,function<void(ll *)>f){ll x[k];rcmb(x,n-1,k,f);}
void prm(ll n,function<void(ll *)>f){ll x[n];for(ll i=0;i<n;i++)x[i]=i;do{f(x);}while(next_permutation(x,x+n));}
void prm(ll n,ll k,function<void(ll *)>f){cmb(n,k,[&](ll *c){prm(k,[&](ll *p){ll x[k];for(ll i=0;i<k;i++){x[i]=c[p[i]];}f(x);});});}
// prm(4, 2, [](ll *x){ cout << x[0] << "," << x[1] << "\n"; });
 
void solve(long long K){
	ll res = 0;
	//if (K >= 195) {
	//	if (K==195) cout << 9997134 << "\n";
	//	if (K==196) cout << 10174780 << "\n";
	//	if (K==197) cout << 10290813 << "\n";
	//	if (K==198) cout << 10493367 << "\n";
	//	if (K==199) cout << 10611772 << "\n";
	//	if (K==200) cout << 10813692 << "\n";
	//	return;
	//}
	FOR(a, 1, K+1) {
		FOR(b, 1, K+1) {
			FOR(c, 1, K+1) {
				ll n1 = __gcd(a, b);
				ll n2 = __gcd(b, c);
				ll n3 = __gcd(n1, n2);
				res += n3;
			}
		}
	}
	cout << res << "\n";
}
 
int main(){
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}



Measured memory_bytes: 3696