akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
ll n,m,v,i;
ll h,w;

void solve(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>h>>w>>n;
  std::vector<ll> a(n),panel(w);
  rep(i,n) cin>>a[i];
  ll num = 0,idx = 0;
  rep(i,h){
    if(i%2==0){
      rep(j,w){
        panel[j] = idx + 1;
        num++;
        if(num == a[idx]){
          idx++;
          num = 0;
        }
      }
    } else {
      repr(j,w,0){
        panel[j] = idx + 1;
        num++;
        if(num == a[idx]){
          idx++;
          num = 0;
        }
      }
    }

    rep(j,w) cout<<panel[j]<<((j < w-1) ? " " : "\n");
  }
  return ;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n;
char s[100];
int main(){
    scanf("%d",&n);
    int A=0,W=0,T=0,R=0;
    for(int i=0;i<n;i++){
        scanf("%s",s);
        if(s[0]=='A')A++;
        else if(s[0]=='W')W++;
        else if(s[0]=='T')T++;
        else R++;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n",A,W,T,R);
    return 0;
}

Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
#define faster_io ios_base::sync_with_stdio(0);
#define ll long long

int main()
{
    faster_io;

    int n,i,j,k,temp=0,sum=0,sum1;
    cin>>n;
    int a[n+5],b[n+5];
    a[0]=0;
    a[n+1]=0;
    for(i=1;i<=n;i++){
        cin>>a[i];
        b[i]=abs(temp-a[i]);
        temp=a[i];
        sum+=b[i];
    }

    b[i]=abs(a[n]-0);
    sum+=b[i];
    sum1=sum;

    for(i=0,j=1;j<=n;i++,j++){
        sum-=(b[j]+b[j+1]);
        sum+=(abs(a[j-1]-a[j+1]));
        cout<<sum<<endl;
        sum=sum1;
    }

    return 0;
}




Measured memory_bytes: 2048
//set many funcs template
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<stdbool.h>
#define inf 1072114514
#define llinf 4154118101919364364
#define mod 1000000007
#define pi 3.1415926535897932384
 
int max(int a,int b){if(a>b){return a;}return b;}
int min(int a,int b){if(a<b){return a;}return b;}
int zt(int a,int b){return max(a,b)-min(a,b);}
int round(int a,int b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
int ceil(int a,int b){if(a%b==0){return a/b;}return (a/b)+1;}
int gcd(int a,int b){int c;while(b!=0){c=a%b;a=b;b=c;}return a;}
int lcm(int a,int b){int c=gcd(a,b);a/=c;return a*b;}
int nCr(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
int fact(int a){int i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
int pow(int a,int b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
long long llmax(long long a,long long b){if(a>b){return a;}return b;}
long long llmin(long long a,long long b){if(a<b){return a;}return b;}
long long llzt(long long a,long long b){return llmax(a,b)-llmin(a,b);}
long long llround(long long a,long long b){if((a%b)*2 >= b){return (a/b)+1;}return a/b;}
long long llceil(long long a,long long b){if(a%b==0){return a/b;}return (a/b)+1;}
long long llgcd(long long a,long long b){long long c;while(b!=0){c=a%b;a=b;b=c;}return a;}
long long lllcm(long long a,long long b){long long c=llgcd(a,b);a/=c;return a*b;}
long long llnCr(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
long long llfact(long long a){long long i,r=1;for(i=1;i<=a;i++){r*=i;}return r;}
long long llpow(long long a,long long b){long long i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}
double dbmax(double a,double b){if(a>b){return a;}return b;}
double dbmin(double a,double b){if(a<b){return a;}return b;}
double dbzt(double a,double b){return dbmax(a,b)-dbmin(a,b);}
int sortfncsj(const void *a,const void *b){if(*(int *)a>*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int sortfnckj(const void *a,const void *b){if(*(int *)a<*(int *)b){return 1;}if(*(int *)a==*(int *)b){return 0;}return -1;}
int llsortfncsj(const void *a,const void *b){if(*(long long *)a>*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int llsortfnckj(const void *a,const void *b){if(*(long long *)a<*(long long *)b){return 1;}if(*(long long *)a==*(long long *)b){return 0;}return -1;}
int dbsortfncsj(const void *a,const void *b){if(*(double *)a>*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
int dbsortfnckj(const void *a,const void *b){if(*(double *)a<*(double *)b){return 1;}if(*(double *)a==*(double *)b){return 0;}return -1;}
 
int main(void){
    int i,j,k,h,w,c[16][16],r=0,x;
    scanf("%d%d",&h,&w);
    for(i=0;i<=9;i++){
        for(j=0;j<=9;j++){
            scanf("%d",&c[i][j]);
        }
    }
    for(k=0;k<=9;k++){
        for(i=0;i<=9;i++){
            for(j=0;j<=9;j++){
                c[i][j]=min(c[i][j],c[i][k]+c[k][j]);
            }
        }
    }
    for(i=1;i<=h*w;i++){scanf("%d",&x);r+=c[x][1];}
    printf("%d\n",r);
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    priority_queue<int> A;
    rep(i,n){
        int tmp;
        cin >> tmp;
        A.push(tmp);
    }
    long long sum = 0;
    int t = n - 1;
    if(t%2==0){
        sum += A.top();
        A.pop();
        rep(i,(t-2)/2){
            sum += 2*A.top();
            A.pop();
        }
        sum += A.top();
        A.pop();
    } else {
        sum += A.top();
        A.pop();
        rep(i,(t-1)/2){
            sum += 2*A.top();
            A.pop();
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 4276
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nk[0];
        var k = nk[1];
        var x = Console.ReadLine().Split().Select(int.Parse).ToList();
        x.Add(0);
        x.Sort();
        int minLength = int.MaxValue;
        int zeroInd = x.BinarySearch(0);
        for (int i = 0; i <= k; i++)
        {
            int lInd = zeroInd - i;
            int rInd = zeroInd + (k - i);
            if (lInd < 0 || n < rInd) continue;
            minLength = Min(minLength, Min(Abs(x[lInd]) * 2 + x[rInd], Abs(x[lInd]) + x[rInd] * 2));
        }
        Console.WriteLine(minLength);
    }
}


Measured memory_bytes: 21216
{-# LANGUAGE BangPatterns #-}
module Main where

solve :: Int -> String -> String -> Int
solve !n _ [] = n
solve !n (x : xs) (y : ys)
  | x /= y = solve (n + 2) xs ys
solve !n xs (y : ys) = solve n (y : xs) ys

main = getLine >>= print . solve 0 []



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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n - 1);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    rep(i, n - 1) cin >> c[i];
    int ans = b[a[0] - 1];

    for (int i = 1; i < n; i++)
    {
        ans += b[a[i] - 1];
        if (a[i] - a[i - 1] == 1)
            ans += c[a[i - 1] - 1];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = 1
flag = 0
for i in range(n):
    ans = ans * a[i]
    if a[i] == 0:
        ans = 0
        break
    elif ans > 10**18 or a[i] > 10**18:
        if a[i:].count(0) > 0:
            ans = 0
            break
        else:
            ans = -1
            break
print(ans)


Measured memory_bytes: 21644
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{
	ios::sync_with_stdio(false);
	ll n, m, d;
	cin >> n >> m >> d;
	if (n <= d)
		cout << "0" << endl;
	else
	{
		ll part1_1 = n - d;
		ll part1_2 = (d == 0 ? (m - 1LL) : (2LL * (m - 1LL)));
		ll part1 = part1_1 * part1_2;
		ll part2 = n * n;
		ld result = (ld)part1 / (ld)part2;
		cout.precision(15);
		cout << fixed << result << endl;
	}
}

Measured memory_bytes: 256
import java.awt.List;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Scanner;
public class Main
{
	public static void main(String[] args) 
	{
		Scanner in=new Scanner(System.in);
		while(in.hasNext())
		{
			int N=in.nextInt();//うさぎの数
			int K=in.nextInt();//ボートの数
			HashMap<Integer, ArrayList<Integer>>HM=new HashMap<Integer, ArrayList<Integer>>();
			HashSet<Integer>Ans=new HashSet<Integer>();
			for(int i=0;i<K;i++)
			{
				int n=in.nextInt();
				ArrayList<Integer>AL=new ArrayList<Integer>();
				for(int j=0;j<n;j++)
					AL.add(in.nextInt());
				HM.put(i,AL);
			}
			
			int R=in.nextInt();//気分を悪くするウサギの組
			for(int i=0;i<R;i++)
			{
				int a=in.nextInt();
				int b=in.nextInt();
				
				for(int j=0;j<HM.size();j++)
				{
					boolean j1=false;
					boolean j2=false;
					ArrayList<Integer>A=new ArrayList<Integer>(HM.get(j));
					for(int k=0;k<A.size();k++)
					{
						if(a==A.get(k))
							j1=true;
						if(b==A.get(k))
							j2=true;
					}
					if(j1&&j2)
					{
						Ans.add(a);
						Ans.add(b);
					}
				}	
			}
			System.out.println(Ans.size());
		}
	}

	static public void debug(Object... o)
	{
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 28540
S = gets.chomp.chars
ans = 0

arr = %W(A T G C)

S.each_with_index do |s, i|
    next unless arr.include?(s)

    cnt = 1

    S[(i+1)..(-1)].each do |t|
        break unless arr.include?(t)

        cnt += 1
    end

    if cnt >= ans
        ans = cnt
    end
end

puts ans

Measured memory_bytes: 1916
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e5+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

int head[maxn], cnt, n;
ll dp[maxn][2];

struct edge
{
    int v, nxt;
} Edge[2 * maxn];

void init()
{
    for(int i = 0; i <= n; i++)
        head[i] = -1;
    cnt = 0;
}

void addedge(int u, int v)
{
    Edge[cnt].v = v;
    Edge[cnt].nxt = head[u];
    head[u] = cnt++;
}

void dfs(int id, int fa)
{
    dp[id][0] = dp[id][1] = 1;
    int cnt = 0;
    for(int i = head[id]; i != -1; i = Edge[i].nxt)
    {
        int v = Edge[i].v;
        if(v == fa)
            continue;
        ++cnt;
        dfs(v, id);
        //black
        dp[id][0] = (dp[id][0] * dp[v][1]) % Mod;
        //white
        dp[id][1] = (dp[id][1] * (dp[v][0] + dp[v][1])) % Mod;
    }
}

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int u, v;
    scanf("%d", &n);
    init();

    for(int i = 0; i < n - 1; i++)
    {
        scanf("%d%d", &u, &v);
        addedge(u, v);
        addedge(v, u);
    }

    dfs(1, -1);

    printf("%lld\n", (dp[1][0] + dp[1][1]) % Mod);

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 9344
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

void answer() {
  int n, k;
  cin >> n >> k;
  if(k == 1) {
    cout << 0 << "\n";
    return;
  }
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll minv = 1e18;
  rep(i, 1<<(n-1)) {
    if(__builtin_popcount(i) == k - 1) {
      int cur = a[0];
      ll res = 0;
      rep(j, n-1) {
        if(i&(1<<j)) {
          if(cur+1<=a[j+1]) {
            cur = a[j+1];
          } else {
            res += cur+1-a[j+1];
            cur++;
          }
        } else {
          chmax(cur, a[j+1]);
        }
      }
      chmin(minv, res);
    }
  }
  cout << minv << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3568
from collections import defaultdict
d = defaultdict(int)
s = input()

for k in s:
  d[k] += 1
#print(d)
#print(len(d))
f = False
for v in d.values():
  if v == 2:
    f = True
    break
print('Yes' if len(d)==2 and f==True else 'No')

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>

using namespace std;

int main(){
  int H,W;
  string S;
  cin >> H >> W;
  for(int i=0; i<W+2; i++){
    cout << '#';
  }cout << endl;
  for(int i=0; i<H; i++){
    cin >> S;
    cout << '#' << S << '#' << endl;
  }  for(int i=0; i<W+2; i++){
    cout << '#';
  }cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
using namespace std;
int main() {
	string s, t,u,c;
	int n,a,b,i;
	cin >> s;
	cin >> n;
	for (i = 0; i < n; i++) {
		cin >> c; cin >> a; cin >> b;
		t = s.substr(a, b - a + 1);
		if (c == "print") {
			cout << t << endl;
		}
		else if (c == "reverse") {
			reverse(t.begin(), t.end());
			s.replace(a, b - a + 1, t);
		}
		else if (c == "replace") {
			cin >> u;
			s.replace(a, b - a + 1, u);
		}
	}
	return 0;
}


Measured memory_bytes: 3216
#include <stdio.h>
#include <math.h>
int main(void) {
    int n,p,i;
    double x,y,ans[1001][3];
    for (i=2;i<=1000;i++) {
        ans[i][0]=0.0;
        ans[i][1]=0.0;
        ans[i][2]=0;
    }
    ans[1][0]=1.0;
    ans[1][1]=0.0;
    ans[1][2]=1;
    while (1) {
        scanf("%d",&n);
        if (n==-1) break;
        if (ans[n][2]==1) {
            printf("%lf\n%lf\n",ans[n][0],ans[n][1]);
        } else {
            p=n-1;
            while (ans[p][2]==0) p--;
            x = ans[p][0];
            y = ans[p][1];
            for (i=p+1; i<=n; i++) {
                ans[i][0]= x - y/sqrt(x*x+y*y);
                ans[i][1]= y + x/sqrt(x*x+y*y);
                x=ans[i][0];
                y=ans[i][1];
                ans[i][2]=1;
            }
            printf("%lf\n%lf\n",ans[n][0],ans[n][1]);
        }
    }
    return 0;
}

Measured memory_bytes: 656
#include <iostream>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n;
  cin>>s;
  for(int i=0;i<s.size();i++){
  if(s[i]+n>'Z')s[i]='A'+(s[i]+n-'Z'-1);
    else s[i]=s[i]+n;
    cout<<s[i];
  }
	cout<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;
int n;
int partition(int A[],int p,int r)
{
  int x =A[r];
  int i =p-1;
  for(int j= p;j<r;j++)
    {
      if(A[j]<=x)
	{
	  i++;
	  swap(A[i],A[j]);
	}
    }
  swap(A[i+1],A[r]);
  return i+1;
}
int main()
{
  for(;cin>>n;)
    {
      int data[n];
      for(int i=0;i<n;i++)
	  cin>>data[i];

   int q= partition(data,0,n-1);
   for(int i=0;i<n;i++)
     {
       if(i==q)
	 cout<<"[";
       cout<<data[i];
       if(i==q)
	 cout<<"]";

       if(i!=n-1)
	 cout<<" ";
       else 
	 cout<<endl;
	}
    }
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
 
using namespace std;
 
#define endl "\n";
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef unsigned long long ull;
typedef pair<long long,long long> pll;
typedef pair<pair<long long,long long>,bool> pllb;
typedef pair<pair<ll,ll>,ll> plll;
 
const ll N = 110;
const ll INF = 1e9;
const ll N2 = 1e5+10;
const int MOD = 1e9+7;

int n,w;
int arr[N];
int v[N];
ll memo[N][N2];

ll dp(int idx,int c)
{
    if(idx>=n)
        return 0;
    ll &ret = memo[idx][c];
    if(~ret)
        return ret;
    ret = dp(idx+1,c);
    if(c+arr[idx]<=w)
        ret=max(ret,dp(idx+1,c+arr[idx])+v[idx]);
    return ret;
}

int main()
{
	fastio
	#ifndef ONLINE_JUDGE
		//freopen("input.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif

    cin >> n >> w;
    memset(memo,-1,sizeof memo);
    for(int i = 0; i < n ;i++)
        cin >> arr[i] >> v[i];
    cout << dp(0,0);
	

}

Measured memory_bytes: 86272
/* ****mittal**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define pb          push_back
#define endl        '\n'
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
ll add(ll x,ll y)
{
return (x%hell+y%hell)%hell;
}
ll mul(ll x,ll y)
{
return ((x%hell)*(y%hell))%hell;
}
ll sub(ll x,ll y)
{
return (x-y+hell)%hell;
}
#define N  100005
ll dp[3005][3005][5];
ll mat[3005][3005];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t=1;
   //cin>>t;
    for(int ok=1;ok<=t;ok++)
    {
         ll n,m;
         cin>>n>>m;
         ll k;
         cin>>k;
         for(int i=1;i<=k;i++)
         {
            ll x,y,z;
            cin>>x>>y>>z;
            mat[x][y]=z;
         }
         for(int i=1;i<=n;i++)
         {
             for(int j=1;j<=m;j++)
             {
                 dp[i][j][1]=max(mat[i][j]+dp[i][j][0],dp[i][j-1][1]);
                 dp[i][j][2]=max(mat[i][j]+dp[i][j-1][1],dp[i][j-1][2]);
                 dp[i][j][3]=max(mat[i][j]+dp[i][j-1][2],dp[i][j-1][3]);
                 dp[i][j][0]=max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3]))+mat[i][j];
                 dp[i][j][1]=max(dp[i][j][1],max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3]))+mat[i][j]);
             }
         }
         ll ans=0;
         for(int i=0;i<=3;i++)
         {
            ans=max(ans,dp[n][m][i]);
         }
         cout<<ans;

     
    }
    return 0;
}

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

#define PI 3.14159265358979

int main(void){
    double a,b,deg;
    double rad;
    double S,L,h;
    
    scanf("%lf %lf %lf",&a,&b,&deg);
    
    rad=(double)deg*PI/180;
    
    S=a*b*sin(rad)/2;
    L=a+b+sqrt(a*a+b*b-2*a*b*cos(rad));
    h=b*sin(rad);
    
    printf("%lf\n%lf\n%lf\n",S,L,h);
    
    return 0;
}

Measured memory_bytes: 648
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,fa[200005],a[200005],c0[200005],c1[200005],Fa[200005];
ll ans;
struct node{
	int pos,g0,g1;
};
struct cmp{bool operator()(node u,node v){return 1ll*u.g0*v.g1<1ll*v.g0*u.g1;}};
priority_queue<node,vector<node>,cmp> Q;

int read(){
	int x=0;char ch=getchar();
	while(!isdigit(ch)) ch=getchar();
	while(isdigit(ch)) x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
	return x;
}

int find(int x){
	if(Fa[x]==x) return x;
	return Fa[x]=find(Fa[x]);
}

int main(){
	n=read();
	for(int i=2;i<=n;i++) fa[i]=read();
	for(int i=1;i<=n;i++) a[i]=read();
	for(int i=1;i<=n;i++){
		Fa[i]=i,c1[i]=a[i],c0[i]=a[i]^1;
		if(i>1) Q.push((node){i,c0[i],c1[i]});
	}
	while(!Q.empty()){
		node u=Q.top();Q.pop();
		int Pos=find(u.pos);
		if(u.g0!=c0[Pos]||u.g1!=c1[Pos]) continue;
		int Pos1=find(fa[Pos]);
		ans+=1ll*c1[Pos1]*c0[Pos];
		Fa[Pos]=Pos1,c1[Pos1]+=c1[Pos],c0[Pos1]+=c0[Pos];
		if(Pos1!=1) Q.push((node){Pos1,c0[Pos1],c1[Pos1]});
	}
	printf("%lld\n",ans);
	
	return 0;
}

Measured memory_bytes: 8176
var s=readLine()!
let start=s.startIndex
let end=s.endIndex
var index0=start
var judge=0
for _ in 0...3{
  var index1=s.index(after: index0)
  if s[index0]==s[index1]{
    judge=1
  }
  index0=s.index(after: index0)
}
if judge==0{
  print("Good")
}else{
  print("Bad")
}

Measured memory_bytes: 7704
/*
 It's better to sleep happy and tired rather than disappointed and frustrated
 There's only 1 thing that's impossible and that is defeating a man who doesn't give up
*/
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mx2 102
#define mx3 1003
#define mx4 10004
#define mx5 100005
#define mx6 1000006
#define mod 1000000007
#define PI 3.14159265
#define deb(x) cout << #x << " " << x << endl;
#define fo(i,n) for(int i=0 ; i<n ; i++)
#define Fo(i,k,n) for(int i=k ; i<n ; i++)
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pair<int,int>,int> piii;

const int inf=0x3f3f3f3f;
int n , ans , sum ,W,w[mx2],v[mx2];
ll dp[mx2][mx5];
string str;
 
int main() {
	ios::sync_with_stdio(false);
	//int t;cin>>t;while(t--)
	{
		cin>>n>>W;
		fo(i,n)
		{
			cin>>w[i]>>v[i];
		}
		for(int i=n-1 ; i>=0 ; i--)
		{
			for(int j=0 ; j<=W ; j++)
			{
				if(j>=w[i])
					dp[i][j]=max(dp[i+1][j],dp[i+1][j-w[i]]+v[i]);
				else
					dp[i][j]=dp[i+1][j];
			}
		}
		cout<<dp[0][W];
	}
	return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main(){
    int x, y, z, now = 0, ans = false;
    cin >> x;
    y = x % 100;
    z = x / 100;
    while(z > 0){
        if(y >= 5)y -= 5;
        else if(y >= 4)y -= 4;
        else if(y >= 3)y -= 3;   
        else if(y >= 2)y -= 2;
        else if(y >= 1)y--;
        now++;
        if(y == 0){
            if(now <= z){
                cout << 1;
                exit(0);
            }
            else{
                z--;
                y += 100;
            }
        }
    }
    cout << 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n, t;
	cin >> n >> t;
	vector<int> times(n);
	for (int i = 0; i < n; i++) {
		cin >> times[i];
	}
	long total = 0;
	int start = 0;
	int stop = 0;
	for (int i = 0; i < times.size(); i++) {
		if (times[i] > stop) {
			total += stop - start;
			start = times[i];
			stop = start + t;
		} else {
			stop = times[i] + t;
		}
	}
	total += stop - start;
	cout << total << endl;
}


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

int main(){
    double r,S,L;
    double pi = 3.141592653589;
    cin >> r;

    S = r * r * pi ;
    L = 2 * r * pi ;

    cout << fixed << setprecision(6) << S << " " << fixed << setprecision(6) << L << endl;

}


Measured memory_bytes: 3284
#include<bits/stdc++.h>
#include<cmath>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define vd vector<double>
#define vld vector<long double>
#define ll long long int
#define pl pair<ll, ll>
#define all(a) a.begin(), a.end()
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ld PI =3.1415926535897923846;
const ll MOD = 1e9+7;
void solve()
{
    ll n;
    cin>>n;
    vl a(n);
    
    forr(i, n)  cin>>a[i];
    
    vector<vl> dp(n, vl(n, 0));
    for(ll left=n-1; left>=0; left--)
    {
        bool check=true;
        for(ll right=left; right<n; right++)
        {
            if(right>left&&check==false)
            {
                dp[left][right]=max(a[left]+dp[left+1][right], a[right]+dp[left][right-1]);
                check=true;
            }    
            else if(left==right)
            {
                dp[left][right]=a[left];
                check=true;
            }    
            else if(right>left&&check==true)
            {
                dp[left][right]=min(-a[left]+dp[left+1][right], -a[right]+dp[left][right-1]);
                check=false;
            }
            //cout<<left<<" "<<right<<" "<<dp[left][right]<<endl;
        }
    }
    if(n%2==0)
    cout<<-dp[0][n-1]<<endl;
    else
    cout<<dp[0][n-1];
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}









Measured memory_bytes: 70784
x,k,d=[int(x) for x in input().split()]


if abs(x)==d:
	if k%2==0:
		print(abs(x))
	else:
		print(0)
else:

	num= abs(x)//d
	if k<=num:
		if x<0:
			x=x+k*d
		else:
			x=x-k*d
		print(abs(x))
	else:
		if x<0:
			x=x+num*d
		else:
			x=x-num*d

		k=k-num

		if k%2==0:
			print(abs(x))
		else:
			print(min(abs(x-d),abs(x+d)))


Measured memory_bytes: 9008
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <math.h>
typedef long long ll;
using namespace std;

int main()
{
	int p, q, r;
	cin >> p >> q >> r;
	vector<int> v(3);
	v[0] = p + q;
	v[1] = q + r;
	v[2] = r + p;
	sort(v.begin(), v.end());
	cout << v[0];
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,x;cin >> n >> x;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
    	cin >> a[i];
    }
    ll d[n];
    d[0]=0;ll ans=1;
    for(ll i=1;i<=n;i++)
    {
    	d[i]=d[i-1]+a[i-1];
    	if(d[i]<=x)ans++;
    }
    cout<< ans;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, k;
    string s;
    cin >> n >> s >> k;
    rep(i, 0, n){
        if(s[i] != s[k - 1]){
            s[i] = '*';
        }
    }
    cout << s << endl;
}

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

int main(){
    int maxv,minv,n;
    cin >> n;
    int x[n];
    for(int i=0;i<n;i++) cin>>x[i];
    maxv=x[1]-x[0];
    minv=x[0];
    for(int j=1;j<n;j++){
        maxv=max(x[j]-minv,maxv);
        minv=min(x[j],minv);
    }
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 3884
import java.util.*;
public class Main
{
    public static void main(String[] args)
    {
        int count = 0;
        boolean sw = false;
        int max = Integer.MIN_VALUE;
        int min = Integer.MAX_VALUE;
        double dMax = Double.MIN_VALUE;
        double dMin = Double.MAX_VALUE;
        //
        Scanner sc = new Scanner(System.in);
        //int n = sc.nextInt();
        int n = sc.nextInt();
        int m = sc.nextInt();
        List<Integer> questionNum = new ArrayList<>();
        List<String> acwa = new ArrayList<>();
        for (int i=0;i<m;++i)
        {
            questionNum.add(sc.nextInt());
            acwa.add(sc.next());
        }

        Map<Integer,Boolean> acMap = new HashMap<>();
        Map<Integer,Integer> waMap = new HashMap<>();
        for (int i=0;i<n;++i)
        {
            acMap.put(i+1,false);
            waMap.put(i+1,0);
        }

        int acCount = 0;
        for (int i = 0;i<m;++i)
        {
            int qn = questionNum.get(i);
            String aw = acwa.get(i);

            if (aw.equals("AC") && !acMap.get(qn))
            {
                ++acCount;
                acMap.put(qn,true);
            } else if (aw.equals("WA"))
            {
                if (!acMap.get(qn))
                {
                    int tmp = waMap.get(qn);
                    ++tmp;
                    waMap.put(qn,tmp);
                }
            }
        }

        int waCount = 0;
        for (int i:acMap.keySet())
        {
            if (acMap.get(i)) waCount += waMap.get(i);
        }

        System.out.println(acCount+" "+waCount);
        sc.close();
    }

    public class Pair<F,S>
    {
        private final F first;
        private final S second;

        Pair(F first,S second)
        {
            this.first = first;
            this.second = second;
        }

        public void print() { System.out.println("("+this.first+","+this.second+")"); }

        //get
        public F first() {return this.first;}
        public S second() {return this.second;}

        @Override
        public boolean equals(Object object)
        {
            if (object instanceof Pair)
            {
                Pair pair = (Pair)object;
                return this.first==pair.first && this.second==pair.second;
            }else
            {
                return false;
            }
        }

        @Override
        public int hashCode()
        {
            return Objects.hash(first,second);
        }
    }
}

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

int main(){
  char s[56];
  int k,n;

  scanf("%d %d", &n, &k);
  scanf("%s", s);

  if(s[k - 1] == 'A') s[k - 1] += 32;
  else if(s[k - 1] == 'B') s[k - 1] += 32;
  else s[k - 1] += 32;

  printf("%s\n", s);

  return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    val key = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    val split = key.toCharArray()
    val map = split.mapIndexed { i, c ->
        c to split[if ((i + n) >= key.length) {
            i + n - key.length
        } else {
            i + n
        }]
    }.toMap()

    val joinToString = s.toCharArray().map { map[it] }.joinToString(separator = "")
    println(joinToString)

}


Measured memory_bytes: 33732
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func main() {
	defer flush()

	N := readInt()
	X := readInt()
	Y := readInt()

	t := make([]int, N)

	for i := 1; i < N; i++ {
		for j := i + 1; j < N+1; j++ {
			t[min(j-i, abs(X-i)+1+abs(Y-j))]++
		}
	}

	for i := 1; i < N; i++ {
		println(t[i])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


Measured memory_bytes: 640
n, k = map(int, input().split())
h = list(map(int, input().split()))
dp = [pow(10, 9)] * n
dp[0] = 0
for i in range(n):
    for j in range(i+1, i+k+1):
        if j == n:
            break
        dp[j] = min(dp[j], dp[i] + abs(h[j] - h[i]))
print(dp[-1])


Measured memory_bytes: 84868
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ALL(x) x.begin(), x.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
random_device rnd;
mt19937 mt(rnd());
using ll = long long;
using lld = long double;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using PII = pair<int, int>;
const int IINF = 1 << 30;
const ll INF = 1ll << 60;
const ll MOD = 1000000007;

int main()
{
    ll n;
    cin >> n;
    ll a = 1, b = 1, c = 1;
    rep(i, n)
    {
        a *= 10;
        a %= MOD;
        c *= 9;
        c %= MOD;
        b *= 8;
        b %= MOD;
    }
    ll ans = (a - 2ll * c + b);
    while (ans < 0)
        ans += MOD;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main () {
	string S;
	cin >> S;
	
	int diff = 1000000000;
	for (int i=0; i<S.size()-2; ++i) {
		int temp = (S[i]-'0')*100 + (S[i+1]-'0')*10 + (S[i+2]-'0');
		diff = min(diff, abs(temp - 753)); 
	}
	cout << diff << endl;
	return 0;
}



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

using namespace std;

int main(){
	int n;
	cin >> n;
		int i = 1;
		for (; i <= n; i++){
			int x = i;
			if (x % 3 == 0){
				cout << " " << i;
			}
			else if (x % 10 == 3){
				cout << " " << i;
			}
			else if ((x / 10) % 10 == 3){
				cout << " " << i;
			}
			else if ((x / 100) % 10 == 3){
				cout << " " << i;
			}
			else if ((x / 1000) % 10 == 3){
				cout << " " << i;
			}
		}
		cout << endl;
	return 0;
	}


Measured memory_bytes: 3108
use std::io::prelude::*;

fn input<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let p: Vec<i32> = (0..n).map(|_| input()).collect();

    let mut ans = 0;
    for p in p.windows(3) {
        if p[0] < p[1] && p[1] < p[2] || p[0] > p[1] && p[1] > p[2] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<functional>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using namespace std;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << #X <<":" <<X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e14;
typedef std::pair<ll,ll> P;
struct edge{ int to,cost; };
#define VMAX 100000

ll N,M,K,Q;
double A,B,C,D,X,Y;
ll ans=INF;
ll F[200010];
string S,T,U;
int main(){
    cin>>A>>B>>C>>D;
        
    printf("%.20lf",sqrt(A*A+B*B-2*A*B*cos(abs(30*C+D/2-D*6)*3.14159265358979/180)));
    

}


Measured memory_bytes: 4220
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int planA = (a + c) < (a + d) ? (a + c) : (a + d);
        int planB = (b + c) < (b + d) ? (b + c) : (b + d);
        
        if (planA < planB) {
            System.out.println(planA);
        } else {
            System.out.println(planB);
        }
    }
}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <ctime>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <fstream>
using namespace std;
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned long long
#define inf 1000000000
#define INF 1000000000000000000ll
const int N = 1e6;
const int mod = 1e9+7;

map<int,int>m;

int n, a[N];
int main() {
    cin >> n;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        m[ a[i] ]++;
        if(m[ a[i] ] == 2){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";
    return 0;
}


Measured memory_bytes: 10368
N = int(input())

l = 0
r = 10**7+1
while(l<r-1):
  m = (l+r)//2
  if m*(m+1)//2 <= N:
    l = m
  else:
    r = m
#print(l,m,r)
if N == l*(l+1)//2:
  ans = list(range(1,l+1))
else:
  ans = list(range(2,r+1))
  for i in range((r-1)*(r+2)//2-N):
    ans[i] -= 1
for a in ans:
  print(a)

Measured memory_bytes: 41456
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

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

  int n, m, a, b, ans=0;
  bool f=false;
  string s;
  double t;
  cin >> a >> b >> t;

  t += 0.5;
  REP(i, 100){
    int val = a * (i+1);
    //cerr << val << " " << t << endl;
    if(t < val){
      ans = (i) * b;
      break;
    }
  }

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


Measured memory_bytes: 384
import math

if __name__ == '__main__':
	a,b,C = map(float,input().split())
	c = (a**2 + b**2 -2*a*b*math.cos(math.radians(C)))**0.5
	s = (a+b+c)/2
	S = (s*(s-a)*(s-b)*(s-c))**0.5
	L = a + b + c
	h = (S*2)/a
	print(S)
	print(L)
	print(h)


Measured memory_bytes: 5716
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static long gcd(long a, long b){
        if(a==b || b==0) return a;
        if(a>b) return gcd(b,a);
        return gcd(b%a, a);
    }

    static boolean solve(long D, long V, long W, long T){
        if(V <= W) return false;
        return D <= T * (V-W);
    }
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long A = sc.nextLong();
        long V = sc.nextLong();
        long B = sc.nextLong();
        long W = sc.nextLong();
        long T = sc.nextLong();
        
        System.out.println(solve(Math.abs(A-B), V,W, T) ? "YES" : "NO");
        
    }
}


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


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

  int cnt0 = 0, cnt1 = 0;
  for(int i=0; i<S.length(); i++){
    if(S[i] == '0') cnt0++;
    if(S[i] == '1') cnt1++;
  }

  cout << 2*min(cnt0, cnt1) << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>
int main()
{
	int a1,a2,a3;
	while(scanf("%d%d%d",&a1,&a2,&a3)!=EOF)
	{
		int t,m,n;
		if(a1>a2){t=a1;a1=a2;a2=t;}
		if(a1>a3){m=a1;a1=a3;a3=m;}
		if(a2>a3){n=a2;a2=a3;a3=n;}
		int sum;
		sum=fabs(a1-a2)+fabs(a2-a3);
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.List;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

public class Main{

    static StringBuilder sb;

    public static void main(String[] args) {
	try {
	    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	    List<String> lines = new ArrayList<String>();
	    String line = "";

	    while((line = br.readLine()) != null){
	    	lines.add(line);
	    }
	    br.close();

	    //lines.add("40 42 -1");
	    //lines.add("20 30 -1");
	    //lines.add("0 2 -1");
	    //lines.add("-1 -1 -1");

	    for (int i = 0; i < lines.size(); i++) {
		Integer m = Integer.parseInt(lines.get(i).split(" ")[0]);
		Integer f = Integer.parseInt(lines.get(i).split(" ")[1]);
		Integer r = Integer.parseInt(lines.get(i).split(" ")[2]);

		if (m == -1 && f == -1 && r == -1) {
		    System.exit(0);
		} else if (m == -1 || f == -1) {
		    System.out.println("F");
		} else if (m+f >= 80) {
		    System.out.println("A");
		} else if (65 <= m+f && m+f < 80) {
		    System.out.println("B");
		} else if (50 <= m+f && m+f < 65) {
		    System.out.println("C");
		} else if (30 <= m+f && m+f < 50) {
		    if (r != -1 && r >= 50) {
			System.out.println("C");
		    } else {
			System.out.println("D");
		    }
		} else {
		    System.out.println("F");
		}
	    }

	    System.exit(0);

	} catch (Exception e) {
	    System.out.println(e.getMessage());
	    System.out.println(Arrays.toString(e.getStackTrace()));
	    System.exit(0);
	}
    }
}

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

int main() {
    int n, m;
    while (cin >> n >> m, n) {
        vector<int> a(n);
        for (int i = 0; i < n; ++i) cin >> a[i];

        int res = 1<<29;
        for (int i = 0; i < n; ++i) {
            for (int j = i+1; j < n; ++j) {
                if (a[i] + a[j] > m) continue;
                res = min(res, m - a[i] - a[j]);
            }
        }
        if (res < 1<<29) cout << m - res << endl;
        else cout << "NONE" << endl;
    }
}



Measured memory_bytes: 2988
/* Generated by powerful Codeforces Tool
 * You can download the binary file in here https://github.com/xalanq/cf-tool (win, osx, linux)
 * Author: step_by_step
 * Time: 2020-03-19 17:35:03
**/

//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")
  
#include <iostream>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <assert.h>
#include <memory.h>
#include <time.h>
#include <bitset>

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = (l); i < (r); i++)
#define repb(i, r, l) for (int i = (r); i > (l); i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)
#define rank qwertyuio
#define next dfghjk
#define prev fhsgfhjf
#define plus fsghsf
#define minus ytryr
  
using namespace std;
  
inline bool setmin(int &x, int y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(int &x, int y) { return (y > x) ? x = y, 1 : 0; }
inline bool setmin(ll &x, ll y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(ll &x, ll y) { return (y > x) ? x = y, 1 : 0; }
  
const int N = 300000 + 1;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int P1 = 31;
const int P2 = 57;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const int MOD2 = 998244353;
const ld eps = 1e-9;
const double pi = atan2(0, -1);
const int ABC = 26;

ll bin_pow(ll a, ll p) {
    ll res = 1;
    while (p) {
        if (p & 1) {
            res = res * a % MOD;
        }
        a = a * a % MOD;
        p >>= 1;
    }
    return res;
}

int main()
{
    //freopen("circus.in", "r", stdin);
    //freopen("circus.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 10.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n, k;
    cin >> n >> k;
    int cnt[k + 1];
    repb(g, k, 0) {
        cnt[g] = bin_pow(k / g, n);
        for (int x = g * 2; x <= k; x += g) {
            cnt[g] -= cnt[x];
            if (cnt[g] < 0) {
                cnt[g] += MOD;
            }
        }
    }
    ll ans = 0;
    rep(g, 1, k + 1) {
        ans = (ans + 1LL * g * cnt[g]) % MOD;
    }
    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3956