akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const int INF = 10000;



int main(){
	int h,w;
	vector< pair< PII,int> >pi;
	FOR(h,1,151)FOR(w,h+1,151){
		pi.PB(MP(MP(h*h+w*w,h),w));
	}
	SORT(pi);
	while(cin>>h>>w){
		if(h==0&&w==0)break;
		int tmp=h*h+w*w;
		REP(i,SZ(pi)){
			if(tmp<pi[i].first.first||(tmp==pi[i].first.first&&h<pi[i].first.second)){
				cout<<pi[i].first.second<<" "<<pi[i].second<<endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1332
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fcking interest
*******************************
I'm standing on top of my Monopoly board
That means I'm on top of my game and it don't stop
til my hip don't hop anymore
https://www.a2oj.com/Ladder16.html
*******************************
Shining through the city with a little funk and soul
*******************************
300iq as writer = Sad!
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String hi[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int N = Integer.parseInt(st.nextToken());
         Point[] arr = new Point[N];
         for(int i=0; i < N; i++)
         {
            st = new StringTokenizer(infile.readLine());
            int a = Integer.parseInt(st.nextToken());
            int b = Integer.parseInt(st.nextToken());
            arr[i] = new Point(a,b);
         }
         Arrays.sort(arr);
         int min = arr[0].x+arr[0].y;
         int max = min;
         for(int i=1; i < N; i++)
         {
            min = Math.min(min, arr[i].x+arr[i].y);
            max = Math.max(max, arr[i].x+arr[i].y);
         }
         int res = Math.abs(max-min);
         min = arr[0].x-arr[0].y;
         max = min;
         for(int i=1; i < N; i++)
         {
            min = Math.min(min, arr[i].x-arr[i].y);
            max = Math.max(max, arr[i].x-arr[i].y);
         }
         res = Math.max(res, Math.abs(max-min));
         System.out.println(res);
      }
   }
   class Point implements Comparable<Point>
   {
      public int x;
      public int y;
      
      public Point(int a, int b)
      {
         x = a;
         y = b;
      }
      public int compareTo(Point oth)
      {
         if(x == oth.x)
            return y-oth.y;
         return x-oth.x;
      }
   }

Measured memory_bytes: 60632
# A,B,C = [int(n) for n in input().split()]
# N = int(input())
S = list(input())
T = list(input())
s = {}
for i in range(len(S)):
    if not(S[i] in s):
        s[S[i]] = i
        S[i] = i
    else:
        S[i] = s[S[i]]
s = {}
for i in range(len(T)):
    if not(T[i] in s):
        s[T[i]] = i
        T[i] = i
    else:
        T[i] = s[T[i]]
print("Yes" if T == S  else "No")


Measured memory_bytes: 6704
#!/usr/bin/env python
# -*- coding:utf-8 -*-

s = input()
if (len(s) % 2 == 0) and (s[0] == s[-1]):
    print("First")
elif (len(s) % 2 == 0) or (s[0] == s[-1]):
    print("Second")
else:
    print("First")


Measured memory_bytes: 3316
N, K = map(int, input().split())
P = [tuple(map(int, input().split())) for _ in range(N)]
X = sorted([p[0] for p in P])
Y = sorted([p[1] for p in P])

ans = 10**20
for i in range(N-1):
    for j in range(i+1, N):
        x0 = X[i]
        x1 = X[j]

        for k in range(N-1):
            for l in range(k+1, N):
                y0 = Y[k]
                y1 = Y[l]

                c = 0
                for m in range(N):
                    if x0 <= P[m][0] <= x1 and y0 <= P[m][1] <= y1:
                        c += 1

                if c >= K:
                    ans = min(ans, (x1-x0)*(y1-y0))

print(ans)


Measured memory_bytes: 49116
a,b,c,x,y = gets.split.map &:to_i
ans = 1 << 64
(0..[x,y].max).each{ |i|
    sum = 0
    sum += i * c * 2
    sum += a * (x - i) if x - i >= 0
    sum += b * (y - i) if y - i >= 0
    ans = [ans, sum].min
}
puts ans

Measured memory_bytes: 3836
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    static class Program
    {
        static void Main()
        {
            Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

            var N = GetInt();
            var ans = N * (N + 1) / 2;


            Console.WriteLine(ans);


            Console.Out.Flush();
            Console.ReadKey();
        }


        static public string GetStr() { return Console.ReadLine().Trim(); }
        static public char GetChar() { return Console.ReadLine().Trim()[0]; }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public char[] GetCharArray() { return Console.ReadLine().Split(' ').Select(char.Parse).ToArray(); }
        static public Double[] GetDoubleArray() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
        static string yesno(this bool b) { return b ? "yes" : "no"; }
        static string YesNo(this bool b) { return b ? "Yes" : "No"; }
        static string YESNO(this bool b) { return b ? "YES" : "NO"; }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
        static void Multi<T, U, V,W>(out T a, out U b, out V c, out W d)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);
        }
        static void Multi<T, U, V, W,X>(out T a, out U b, out V c, out W d,out X e)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]); d = cv<W>(ar[3]);e = cv<X>(ar[4]);
        }
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;

int n,k;
int a[100005];
ll dp[105][100005];
ll sum[100005];
int main() {
    scanf("%d%d",&n,&k);
    for(int i = 1;i<=n;i++) scanf("%d",&a[i]);
    for(int i = 0;i<=n;i++) dp[i][0] = 1;
    for(int i = 1;i<=n;i++) {
        sum[0] = 0;
        for(int j = 1;j<=k+1;j++) sum[j] = sum[j-1] + dp[i-1][j-1];
        for(int j = 1;j<=k;j++) 
            dp[i][j] = (sum[j+1] - sum[max(0,j-a[i])] + mod) % mod;
    }
    printf("%lld\n",dp[n][k]);
    return 0;
}

Measured memory_bytes: 79360
#include<bits/stdc++.h>
using namespace std;
int main(){
    int w,l1,l2;cin>>w>>l1>>l2;if(l1>l2) swap(l1,l2);
    int r1=l1+w,r2=l2+w;
    cout<<max(0,l2-r1);
}

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

int main(){
    ll A, B, N;
    cin >> A >> B >> N;
    ll ans = 0;
    if (N < B){
        ans = ll(floor(double(A * N) / B));
        cout << ans << endl;
        return 0;
    }
    ans = ll(floor(double(A * (B-1)) / B));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int N;
int h[100001];
LL dp[100001];

LL solve(int now){
	if(now == N-1) return 0;
	if(now >= N) return INT_MAX;
	if(dp[now] != INT_MAX) return dp[now];
	return dp[now] = min((LL)INT_MAX, min(abs(h[now]-h[now+1]) + solve(now+1), abs(h[now]-h[now+2]) + solve(now+2)) );
}

int main(){
	cin >> N;
	for(int i=0; i<N; i++){
		cin >> h[i];
		dp[i] = INT_MAX;
	}
	h[N] = 0;
	//cout << solve(0) << endl;

	dp[N] = INT_MAX;
	dp[N-1] = 0;
	for(int i=N-2; i>=0; i--){
		dp[i] = min(abs(h[i]-h[i+2])+dp[i+2], abs(h[i]-h[i+1])+dp[i+1]);
	}
	cout << dp[0] << endl;

	return 0;
}

Measured memory_bytes: 1408
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp80 {
    class Program {
        static void Main(string[] args) {
            string[] fare = Console.ReadLine().Split(' ');
            int fareBus = int.Parse(fare[1]) / 2;

            int sum = int.Parse(fare[0]) + fareBus;
            Console.WriteLine(sum);
        }
    }
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) a / __gcd(a, b) * b /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    set<string> s;
    u32 N;
    cin >> N;
    for (u32 i = 0; i < N; i++) {
        string S;
        cin >> S;
        s.insert(S);
    }
    u32 sum = 0;
    for (auto&& x : s) {
        sum++;
    }
    cout << sum << endl;
}


Measured memory_bytes: 19284
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	int n; cin >> n;
	double ans = 0;
	for (int i = 0; i < n; ++i) {
		double a; cin >> a;
		ans += (1 / a);
	}
	printf("%.9f\n", 1 / ans);

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner s = new Scanner(System.in);
		int a = Integer.parseInt(s.nextLine());
		String si = s.nextLine();
		if(a<3200) {
			System.out.println("red");
		}else {
			System.out.println(si);
		}

	}

}


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

int main() {
	int x,y,z;
  	cin >> x >> y >> z;
  
  	int remain = x - z;
  	int ans = 0;
  	
  	while(remain >= y + z) {
    	remain -= (y + z);
      	ans++;
    }
  
  	cout << ans << endl;
}

Measured memory_bytes: 256
//#include    <bits/stdc++.h>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#define N  110
#define M 5
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define INF 0x3f3f3f3f
template<typename T> inline T max(T a,T b,T c){
    return max(a,max(b,c));
}
template<typename T> inline T min(T a,T b,T c){
    return min(a,min(b,c));
}
template<typename T> inline T max(T a,T b,T c,T d){
    return max(a,max(b,c,d));
}
template<typename T> inline T min(T a,T b,T c,T d){
    return min(a,min(b,c,d));
}
const int  dx[]={0,1,0,-1,0,1,-1,1,-1};
const int  dy[]={0,0,1,0,-1,1,-1,-1,1};
typedef long long ll;
using namespace std;
char s[N][N];
int main(){
    int a,b;
    int h,w;
    scanf("%d%d",&a,&b);
    for (int i=1;i<=50;i++)
        for (int j=1;j<=100;j++)
          s[i][j]='.';
    for (int i=51;i<=100;i++)
        for (int j=1;j<=100;j++)
        s[i][j]='#';
    a--,b--;
    bool flag=true;
    for (int i=1;i<=50;i+=2){
        for (int j=1;j<=100;j+=2){
            if (b){
                s[i][j]='#';
                b--;
            }
            else{
                flag=false;
                break;
            }
        }
        if (flag==false) break;
    }
    flag=true;
    for (int i=52;i<=100;i+=2){
        for (int j=1;j<=100;j+=2){
            if (a){
                s[i][j]='.';
                a--;
            }
            else{
                flag=false;
                break;
            }
        }
        if (flag==false) break;
    }
    printf("100 100\n");
    for (int i=1;i<=100;i++){
       for (int j=1;j<=100;j++)
       printf("%c",s[i][j]);
       printf("\n");
    }

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;
const int N = 1e7+10;
int dp[N][2];
string cnt;
int main(){
    cin >> cnt;
    int len = cnt.size();
    dp[0][1] = 2;
    for(int i = 1; i <= len; i ++){
        dp[i][0] = min(dp[i-1][0] + (cnt[i-1] - '0'), dp[i-1][1] + (cnt[i-1]-'0'));
        dp[i][1] = min(dp[i-1][0] + (11 -(cnt[i-1]-'0')), dp[i-1][1] - 1 + (10 - (cnt[i-1] - '0')));
    }
    cout << min(dp[len][0], dp[len][1]) << endl;
    return 0;
}

Measured memory_bytes: 9588
#include <cstdio>
#include <cstring>
#include <deque>

const int N = 2000;

int a[N + N];

int main()
{
    int n, x;
    scanf("%d%d", &n, &x);
    for (int i = 0; i < n; ++ i) {
        scanf("%d", a + i);
    }
    memcpy(a + n, a, sizeof(int) * n);
    long long result = 1000000000000000000LL;
    for (int i = 1; i <= n; ++ i) {
        std::deque<int> q;
        long long tmp = 0;
        for (int j = 0; j < n + i - 1; ++ j) {
            while (!q.empty() && a[q.back()] >= a[j]) {
                q.pop_back();
            }
            q.push_back(j);
            while (!q.empty() && j - q.front() >= i) {
                q.pop_front();
            }
            if (j >= i - 1) {
                tmp += a[q.front()];
            }
        }
        result = std::min(result, tmp + 1LL * (i - 1) * x);
    }
    printf("%lld\n", result);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll a, b;std::cin >> a >> b;
  std::cout << a*b << '\n';
  return 0;
}


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    ll n,k;
    cin>>n;
    vector<string> s(n);
    rep(i,n){
        cin>>s[i];
    }
    sort(s.begin(),s.end());
    k=n;
    rep(i,n-1){
        if(s[i]==s[i+1]){
            k--;
        }
    }
    cout<<k;
}

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

int main()
{

    string s,t;

    int n;

    cin>>n;

    cin>>s;

    t = "ABC";

    int count = 0;

    int sz = t.size();

    for(int i=0;i<s.size();i++)
    {
        string k_string = s.substr(i,sz);

        if(k_string==t)
        {
            count++;
        }
    }
    cout<<count;

}



Measured memory_bytes: 256
/*----------------
     Smit Patel
     DA-IICT
----------------*/
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// #define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define ins insert
#define fori(i,a,n) for(int i=a; i<n; i++)
#define ford(i,a,n) for(int i=a; i>n; i--)
#define clr(a,b) memset(a,b,sizeof(a))
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define debug(x,y) cout<<#x<<" : "<<x<<"  "<<#y<<" : "<<y<<endl;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define bp __builtin_popcount
#define mod 1000000007
#define eps 1e-6
#define infi 1000000002
#define infll 1e18+5
#define N 200005
#define LN 23

typedef long double ld;
typedef long long ll;
typedef map<ll,ll> mll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef set<ll> sll;

ll choose(ll n,ll k);
bool isprime(ll n);
ll power(ll x,ll y,ll p);
ll power(ll x,ll y);
ll gcd(ll a,ll b);

int main()
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ll n,m;
  cin>>n>>m;
  if(n<=m) cout<<"unsafe\n";
  else cout<<"safe\n";
  return 0;
}

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

ll choose(ll n,ll k)
{
  if(k==0)
    return 1;
  return (n* choose(n-1,k-1))/k;
}

bool isprime(ll n)
{
  for(ll i=2;i*i<=n;i++)
  {
    if(n%i==0)
      return false;
  }
  return true;
}

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

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


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

using namespace std;

using int64 = long long;
const int mod = 1000003;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

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

template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}

template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

template <typename T = int64>
vector<T> make_v(size_t a) {
  return vector<T>(a);
}

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
  t = v;
}

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename F>
struct FixPoint : F {
  FixPoint(F &&f) : F(forward<F>(f)) {}

  template <typename... Args>
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template <typename F>
inline decltype(auto) MFP(F &&f) {
  return FixPoint<F>{forward<F>(f)};
}

int main() {
  int N, K;
  cin >> N >> K;
  vector<double> P(N);
  cin >> P;
  vector<double> S(N + 1);
  for (int i = 0; i < N; i++) {
    S[i + 1] = S[i] + (P[i] + 1) / 2;
  }
  double ret = 0;
  for (int i = K; i <= N; i++) {
    chmax(ret, 1.0 * (S[i] - S[i - K]));
  }
  cout << ret << endl;
}


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

int main() {
	int n;
	while(true){
		cin >> n;
		if(n == 0) break;
		int s[n];
		int sum = 0;
		int sqsum = 0;
		for(int i = 0; i < n; ++i){
			cin >> s[i];
			sum += s[i];
			sqsum += s[i] * s[i];
		}
		double v = sqsum / (double)n - (sum / (double)n) * (sum / (double)n);
		cout << setprecision(10) << sqrt(v) << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
#include<iostream>
#include<algorithm>
using namespace std;
int n,q;
int a[1000];
main()
{
	cin>>n;
	for(int i=0;i<n;i++)cin>>a[i];
	cin>>q;
	for(int i=0;i<q;i++)
	{
		int b,e;cin>>b>>e;
		reverse(a+b,a+e);
	}
	for(int i=0;i<n;i++)cout<<(i?" ":"")<<a[i];
	cout<<endl;
}


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

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

    static class BTrickOrTreat {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int a[] = new int[n + 1];
            for (int i = 1; i <= n; i++) {
                a[i] = i;
            }
            boolean[] f = new boolean[n + 1];
            int b[] = new int[k + 1];
            for (int i = 0; i < k; i++) {
                int h = in.nextInt();
                while (h-- > 0) {
                    int x = in.nextInt();
                    f[x] = true;
                }
            }
            int c = 0;
            for (int i = 1; i <= n; i++) {
                if (f[i] == false) {
                    c++;
                }
            }
            out.println(c);
        }

    }

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

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

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

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

    }
}



Measured memory_bytes: 33744
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{
	public static void main(String[] args){
		BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));
		try{

			//文字を読み取る。
			String strLine = insBR.readLine();
			int intTurn = Integer.parseInt(strLine);

			//2人にカードを配る。
			String[][] strCard = new String[intTurn][2];
			char[][][] chCard = new char[intTurn][2][100];
			for(int i = 0; i < intTurn; i++){
				strCard[i] = insBR.readLine().split(" ");
				for(int j = 0; j < 2; j++){
					chCard[i][j] = strCard[i][j].toCharArray();
				}
			}

			String[][][] strJuge = new String[intTurn][2][100];
			for(int i = 0; i < strCard.length; i++){
				for(int j = 0; j < 2; j++){
					strJuge[i][j] = strCard[i][j].split("");
				}
			}


			//2人のスコアをとる。
			int intTaro = 0;
			int intHanako = 0;
			for(int i = 0; i < intTurn; i++){
				int intJuge = strCard[i][0].compareTo(strCard[i][1]);
				if(intJuge == 0){
					intTaro += 1;
					intHanako += 1;
				}else if(0 < intJuge){
					intTaro += 3;
				}else{
					intHanako += 3;
				}
			}

			//出力。
			System.out.println(intTaro + " " + intHanako);


		}catch(IOException e){
			e.printStackTrace();
		}catch(NumberFormatException e){
			e.printStackTrace();
		}

	}

}



Measured memory_bytes: 30556
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int a[maxn];
int main()
{
	int n;cin>>n;n*=2;
	for(int i=1;i<=n;i++)cin>>a[i];
	sort(a+1,a+1+n);
	int ans = 0;
	for(int i=1;i<=n;i+=2)ans += a[i];
//	for(int i=1;i<=n;i++)cout<<a[i]<<" ";cout<<endl; 
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
int main()
{
    int n, d;
    cin >> n >> d;
    cout << (n + 2 * d) / (2 * d + 1) << endl;
    return 0;
}

Measured memory_bytes: 3548
import qualified Data.ByteString.Lazy.Char8 as B
import Data.List
import Data.Maybe

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

solve :: Int -> Int -> (Int, Int, Int)
solve valN valY =
  case dropWhile (== Nothing) $ map solveS [0 .. valN] of
    [] -> (-1, -1, -1)
    (Just a) : _ -> a
  where
    solveS :: Int -> Maybe (Int, Int, Int)
    solveS x =
      if 0 <= y && y <= valN && 0 <= z && z <= valN &&
         10000 * x + 5000 * y + 1000 * z == valY
      then Just (x, y, z)
      else Nothing
      where
        rhs = (valY - 10000 * x) - 1000 * (valN - x)
        y = rhs `div` 4000
        z = valN - x - y

main :: IO ()
main = do
  conts <- B.getContents
  let [valN, valY] = bsReadInts conts
      (x, y, z) = solve valN valY
  putStrLn $ show x ++ " " ++ show y ++ " " ++ show z


Measured memory_bytes: 636
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,-1,0};
int dy[4]={1,0,0,-1};
long double eps = 1e-6;
long double pi = acos(-1);



signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);


    int h,w,k;
    cin>>h>>w>>k;
    int sh,sw,gh,gw;
    cin>>sh>>sw>>gh>>gw;
    sh--,sw--,gh--,gw--;
    string s[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    s[sh][sw] = 'S';
    s[gh][gw] = 'G';
    int visited[h][w]={};
    bool used[h][w]={};
    int INF = 1e9;
    for(int i=0;i<h;i++)for(int j=0;j<w;j++){
        visited[i][j] = INF;
    }
    queue<array<int,3>> q;
    q.push({sh,sw,0});
    while(q.size()){
        array<int,3> a = q.front();
        q.pop();
        int totori = a[2],x=a[0],y=a[1];
        if(visited[x][y]<totori || used[x][y]) continue;
        visited[x][y] = totori;
        used[x][y] = 1;
        for(int i=0;i<4;i++){
            for(int d=1;d<=k;d++){
                int nx=x+dx[i]*d, ny=y+dy[i]*d;
                if(nx<h&&nx>=0 && ny<w&&ny>=0){
                    if(s[nx][ny]=='@')break;
                    if(visited[nx][ny] <= totori)break;
                    visited[nx][ny] = totori+1;
                    q.push({nx,ny,totori+1});
                    if(s[nx][ny] == 'G'){
                        cout << totori+1 << endl;
                        return 0;
                    }
                }
                else break;
            }
        }
    }
    cout << -1 << endl;

}

Measured memory_bytes: 11520
#include "iostream"
using namespace std;
 
int main(){
 
  int ans=0;
  int H,W,N;
  
  cin >> H;
  cin >> W;
  cin >> N;

  if(H>W){
    while(H*ans < N){
      ans++;
    }
  }else{
    while(W*ans < N){
      ans++;
    }   
  }

   
  cout << ans;
   
   
  return 0;
  
}

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

int main(){
  ll n;
  cin >> n;
  vector<ll> x(n);
  vector<ll> num(n);
  rep(i,n){
    cin >> x.at(i);
    num.at(i) = x.at(i);
  }
  sort(num.begin(),num.end());
  double c = (double)(num.at(n/2-1)+num.at(n/2))/2.0;
  //cout << c << endl;
  rep(i,n){
    if( (double)x.at(i) > c ){
      cout << num.at(n/2-1) << endl;
    }else{
      cout << num.at(n/2) << endl;
    }
  }
  
  
  
  return 0;
}

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

int main(){
   int n; cin>>n;
   vector<int> a(n);
   rep(i,n) cin>>a[i];
   int ans=0;
   rep(i,n){
      ans+=a[i]-1;
   }
   cout<<ans<<endl;
   return 0;
}


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

using namespace std;

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

  long long int D[n][2];
  int cnt = 0;
  int max_cnt=0;

  for(int i=0; i<n; i++) cin>>D[i][0]>>D[i][1];

  for(int i=0; i<n; i++){
    if(D[i][0]==D[i][1]){
      cnt++;    
      max_cnt=max(max_cnt, cnt);
    }else{
      cnt=0;
    }
  }

  if(max_cnt>=3) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

}


Measured memory_bytes: 3592
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let mut seq: Vec<i64> = vec![0; n];
    for i in 0..n {
        seq[i] = read();
    }
    let mut max_value = (seq[0], 0);
    let mut min_value = (seq[0], 0);
    for i in 0..n {
        max_value = std::cmp::max(max_value, (seq[i], i));
        min_value = std::cmp::min(min_value, (seq[i], i));
    }
    let mut pos = 0;
    let mut dir = 1;
    let mut src = max_value.1;
    if min_value.0.abs() >= max_value.0.abs() {
        pos = n as i64 - 1;
        dir = -1;
        src = min_value.1;
    }
    println!("{}", 2 * n - 1);
    for i in 0..n {
        // seq[i] += seq[src];
        println!("{} {}", src + 1, i + 1)
    }
    for _ in 0..n-1 {
        // seq[(pos + dir) as usize] += seq[pos as usize];
        println!("{} {}", pos + 1, pos + dir + 1);
        pos += dir;
    }
    // for i in 0..n {
    //     print!("{} ", seq[i]);
    // }
    // println!("");
}

Measured memory_bytes: 4352
from math import *

#N = int(input())
N = int(input().strip())

def search_n(N):
    if N == 0 or N == 1:
        return 1
    minN = 0
    maxN = 1
    for i in range(1, 40):
        a1 = minN + (-2)**i
        a2 = maxN + (-2)**i
        minN = min(minN, min(a1, a2))
        maxN = max(maxN, max(a1, a2))
        if N <= maxN and N >= minN:
            return i

result = ['0']
while N != 0 and N != 1:
    n = search_n(N)
    N -= (-2)**n
    if len(result) == 1:
        result = ['0' for i in range(0, n+1)]
    result[n] = '1'

if N==1:
    result[0] = '1'

result.reverse()
print(''.join(result))


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define uint unsigned
#define db double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define vi vector<int>
#define vpi vector<pii >
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define y1 wzpakking
#define fi first
#define se second
#define BG begin
#define ED end
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?(x)-=mo:233)%s
#define CLR(a,v) memset(a,v,sizeof(a))
#define CPY(a,b) memcpy(a,b,sizeof(a))
#define sqr(x) (1ll*x*x)
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
#define INF (1ll<<60)
using namespace std;
int n,S,a[105];
int main(){
	scanf("%d",&n);
	For(i,1,n) scanf("%d",&a[i]),S+=a[i],a[i]*=n;
	int ans=1;
	For(i,2,n) if (abs(S-a[i])<abs(S-a[ans])) ans=i;
	printf("%d\n",ans-1);
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string week[] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    string day;
    int res;
    cin>>day;
    for(int i = 0 ; i < 7 ; i ++)
    {
        if(day == week[i])
        {
           res = 7 - i;
        }
    }
    cout<<res<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp> // Common file
#include<ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define pp pair<ll,ll>
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin() , (x).end()
#define rep(i,a,b) for( ll i = a ; i < b ; i+=1 )
#define sz(v) (ll)(v.size())
#define hell (ll)1000000007
#define slld(x) scanf("%lld",&x)
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define ld long double
ll t = 1, tt;
inline ll add(ll x,ll y){x+=y;return x%hell;}
inline ll mult(ll x,ll y){x%=hell;y%=hell;return (x*y)%hell;}
inline ll powMod(ll base,ll expo){
	ll ans=1;
	while(expo){
		if(expo&1)ans=mult(ans,base);
		base=mult(base,base);
		expo>>=1;
	}
	return ans;
}
void solve(){
	ll n, maxi, ans=-1e18, mini;
	cin>>n;
	vector<ll> v(n+1);
	rep(i,1,n+1)
		cin>>v[i];
	vector<pp> dp[n+1];
	dp[1].pb({0,0});
	dp[1].pb({v[1],1});
	dp[2].pb({max(v[2],v[1]),1});
	if(n/2==1){
		ans=max(ans,v[1]);
		ans=max(ans,v[2]);
	}
	rep(i,3,n+1){
		maxi=(i+1)/2;
		mini=n/2-(n-i+1)/2;
		mini=max(0LL,mini);
		rep(j,mini,maxi+1)
			dp[i].pb({-1e18,j});
		rep(j,0,sz(dp[i-2])){
			rep(k,0,sz(dp[i])){
				if(dp[i][k].se==dp[i-2][j].se){
					dp[i][k].fi=max(dp[i][k].fi,dp[i-2][j].fi);
				}
				if(dp[i][k].se==dp[i-2][j].se+1){
					dp[i][k].fi=max(dp[i][k].fi,dp[i-2][j].fi+v[i]);
				}
			}
		}
		rep(j,0,sz(dp[i-1])){
			rep(k,0,sz(dp[i])){
				if(dp[i-1][j].se==dp[i][k].se)dp[i][k].fi=max(dp[i][k].fi,dp[i-1][j].fi);
			}
		}
		rep(j,0,sz(dp[i]))
			if(dp[i][j].se==n/2)ans=max(ans,dp[i][j].fi);
	}
	cout<<ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
	//cin>>t;
	tt=t;
    while(t--){
        solve();
        if(t!=0)cout<<"\n";
    }
    return 0;
}


Measured memory_bytes: 18784
import java.util.*;
public class Main {
	public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			while (true) {
				int n = sc.nextInt();
				int w = sc.nextInt();
				int d = sc.nextInt();
				if(n == 0 && w == 0 && d== 0) break;
				ArrayList<Data> list = new ArrayList<Data>();
				list.add(new Data(w, d, 0));
				for (int i = 1; i <= n; i++) {
					int p = sc.nextInt();
					int s = sc.nextInt();
					Data tmp = list.get(p - 1);
					int nw = 0;
					int nd = 0;
					int status = 0;
					for (int j = 0; j < s; j++) {
						if (status == 0) {
							if((s - j) >= tmp.w) {
								nw = tmp.w;
								status++;
								j += tmp.w-1;
							}
							else {
								nw = (s-j);
								break;
							}
						} else if (status == 1) {
							if((s - j) >= tmp.d) {
								nd = tmp.d;
								j += tmp.d-1;
								status++;
							}
							else {
								nd = (s-j);
								break;
							}
							
						} else if (status == 2) {
							if((s - j) >= tmp.w) {
								nw = 0;
								j += tmp.w-1;
								status++;
							}
							else {
								nw = nw - (s-j);
								break;
							}

						} else {
							if( (s - j) >= tmp.d) {
								nd = 0;
								j += tmp.d-1;
								status = 0;
							}
							else {
								nd = nd - (s-j);
								break;
							}

						}
					}

					if (status == 0 || status == 2) {
						Data p1 = new Data(nw, tmp.d, i);
						Data p2 = new Data(tmp.w - nw, tmp.d, i);
						if (p1.d * p1.w < p2.d * p2.w) {
							list.add(p1);
							list.add(p2);
						} else {
							list.add(p2);
							list.add(p1);
						}
					} else {
						Data p1 = new Data(tmp.w, nd, i);
						Data p2 = new Data(tmp.w, tmp.d - nd, i);
						if (p1.d * p1.w < p2.d * p2.w) {
							list.add(p1);
							list.add(p2);
						} else {
							list.add(p2);
							list.add(p1);
						}
					}
					list.remove(p - 1);

				}
				Collections.sort(list, new MyComp());
				System.out.print(list.get(0).d * list.get(0).w);
				for (int i = 1; i < list.size(); i++) {
					System.out.print(" " + list.get(i).d * list.get(i).w);
				}
				System.out.println();
			}
			
	}
	
	static class Data {
		int w;
		int d;
		int t;
		Data(int a, int b, int c) {
			w = a;
			d = b;
			t = c;
		}
	}
	
	static class MyComp implements Comparator<Data> {

		@Override
		public int compare(Data o1, Data o2) {
			return o1.d*o1.w - o2.d*o2.w;
		}
		
	}
}

Measured memory_bytes: 50580
#include <stdio.h>
#include <math.h>

int main(void){
    double x1,x2,y1,y2,x,y;
    
    scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    x = x2 - x1;
    y = y2 - y1;
    
    printf("%lf\n" , sqrt(x*x+y*y));
    
    return 0;
}

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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    lint n;cin >> n;
    lint ans=0;
    REP(i,n){
        lint k = i + 1;
        ans += (k)*floor(n/k)*floor(1+(n/k));
    }
    cout << ans/2 << "\n";
    return 0;
}

Measured memory_bytes: 3604
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var a = nexts(7);
  var ans = a[1] + ((a[0]/2|0) + (a[3]/2|0)+ (a[4]/2|0)) * 2;
  switch(a[0]%2 + a[3]%2 + a[4]%2){
    case 3: ans += 3; break;
    case 2: if(a[0]*a[3]*a[4])ans += 1; break;
  }
  return ans;
}

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

int main(void){
  int a,b,c;cin >> a >> b >> c;
  int sec = (a+b+c)-max({a,b,c})-min({a,b,c});
  cout << min({a,b,c}) + sec + 10*max({a,b,c}) << endl; 
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int [] dice = new int [6];
        for(int x = 0; x < 6; x++){
            dice[x] = scan.nextInt();
        }
        int q = scan.nextInt();
        for (int x =0; x <q; x++) {
            int top = scan.nextInt();
            int face = scan.nextInt();
            if (top == dice[0]){
                if(face == dice[1]){
                    System.out.println(dice[2]);
                }
                else if(face == dice[2]){
                    System.out.println(dice[4]);
                }
                else if(face == dice[3]){
                    System.out.println(dice[1]);
                }
                else{
                    System.out.println(dice[3]);
                }
            }
            else if(top == dice[1]){
                if(face == dice[0]){
                    System.out.println(dice[3]);
                }
                else if(face == dice[2]){
                    System.out.println(dice[0]);
                }
                else if(face == dice[3]){
                    System.out.println(dice[5]);
                }
                else{
                    System.out.println(dice[2]);
                }
            }
            else if(top == dice[2]){
                if(face == dice[0]){
                    System.out.println(dice[1]);
                }
                else if(face == dice[1]){
                    System.out.println(dice[5]);
                }
                else if(face == dice[4]){
                    System.out.println(dice[0]);
                }
                else{
                    System.out.println(dice[4]);
                }
            }
            else if(top == dice[3]){
                if(face == dice[0]){
                    System.out.println(dice[4]);
                }
                else if(face == dice[1]){
                    System.out.println(dice[0]);
                }
                else if(face == dice[4]){
                    System.out.println(dice[5]);
                }
                else{
                    System.out.println(dice[1]);
                }
            }
            else if(top == dice[4]){
                if(face == dice[0]){
                    System.out.println(dice[2]);
                }
                else if(face == dice[2]){
                    System.out.println(dice[5]);
                }
                else if(face == dice[3]){
                    System.out.println(dice[0]);
                }
                else{
                    System.out.println(dice[3]);
                }
            }
            else{
                if(face == dice[1]){
                    System.out.println(dice[3]);
                }
                else if(face == dice[2]){
                    System.out.println(dice[1]);
                }
                else if(face == dice[3]){
                    System.out.println(dice[4]);
                }
                else{
                    System.out.println(dice[2]);
                }
            }
        }
    }
}


Measured memory_bytes: 26356
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int k = scn.nextInt();

		ArrayList<Integer> list = new ArrayList<>();

		int i = 1;
		do {
			if (a % i == 0 && b % i == 0) {
				list.add(i);
			}
			i++;
		} while (i <= a);

		System.out.println(list.get((list.size()-k)));
	}
}

Measured memory_bytes: 23892
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=0; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define F first
#define S second

using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int, int> pint;

int main()
{
  string o, e ;
  cin >> o >> e ;
  int n = o.size() ;
  int m = e.size() ;
  
  
  if(n==m){
    REP(i,m){
      cout << o.at(i)<<e.at(i) ;
    }
  }
    else{
      REP(i,m){
        cout << o.at(i)<<e.at(i) ;
      }
      cout << o.at(n-1) ;
    }
  cout <<endl ;

  return 0 ;
}




Measured memory_bytes: 256
def c_otoshidama():
    """
    a, b, c: 1万円札/5千円札/千円札の枚数
    条件から変数 c を消去すると不定方程式 9a+4b=t が得られる．
    この方程式の解は a=4k+t, b=-9k-2t である (gcd(9,4)=1 より必ず存在する)．
    a, b, c >= 0 という条件から minimum <= maximum なら元の方程式に解がある．
    """
    from math import ceil, floor
    N, Y = [int(i) for i in input().split()]
    t = (Y - 1000 * N) // 1000
    minimum, maximum = max(ceil(-t / 4), ceil(-(N + t) / 5)), floor(-2 * t / 9)
    if minimum <= maximum:
        return '{} {} {}'.format(4 * minimum + t, -9 * minimum - 2 * t, N + 5 * minimum + t)
    return '-1 -1 -1'

print(c_otoshidama())

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

int main() {
  int n;
  cin >> n;
  set<string> s;
  rep(i, n) {
    string c;
    cin >> c;
    s.insert(c);
  }

  cout << s.size() << endl;
  return 0;
}

Measured memory_bytes: 19220
#include <iostream>
#include <vector>
#include <map>
#include <cmath>

using namespace std;

int main(){
  int q;
  vector<int> prime_v;
  bool is_prime[100001];
  int like_2017[100001] = {};
  is_prime[0] = false;
  is_prime[1] = false;
  is_prime[2] = true;
  prime_v.push_back(2);
  for (int i=3;i<=100000;i++) {
    is_prime[i] = true;
    for (auto it = prime_v.begin();*it <= ceil(sqrt((double)i)) && it != prime_v.end();it++) {
      if (i % *it == 0) {
	is_prime[i] = false;
	break;
      }
    }
    if (is_prime[i]) {
      prime_v.push_back(i);
    }
    if (is_prime[i] && is_prime[(i+1)/2]) {
      like_2017[i] = like_2017[i-1] + 1;
    } else {
      like_2017[i] = like_2017[i-1];
    }
  }
  cin >> q;
  for (int i=0;i<q;i++) {
    int l, r;
    cin >> l >> r;
    cout << like_2017[r] - like_2017[l-1] << endl;
  }
  return(0);
}


Measured memory_bytes: 1280