akhauriyash/Code-Regression huggingface dataset:
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
f(x::Int)= x%2==0 ? div(x,2) : 3x+1
function main()
  s=pI(readline())
  seen=Int[s]
  c=1
  while true
    c+=1
    e=f(seen[end])
    if e in seen
      break
    end
    push!(seen,e)
  end
  print(c)
end
main()
if isdefined(Base, :mystdin);close(mystdin);end


Measured memory_bytes: 163144
X, K, D = map(int, input().split())

def solve():
    if X > K*D:
        return X - K*D
    elif -1*X > K*D:
        return -X - K*D
    elif X >= 0:
        first = X // D
        rem = K - first
        if rem % 2 == 0:
            return X % D
        else:
            return D - (X % D)
    else: # X < 0
        first = (-1*X) // D
        rem = K - first
        if rem % 2 == 0:
            return (-1 * X) % D
        else:
            return D - (-1 * X) % D

print(solve())

Measured memory_bytes: 9192
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1;
#define cni cin

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,t,m;

main(){
    cin>>n;
    rep(i,n){
        cin>>t;
        t%2?m++:0;
    }
    cout<<(m%2?"NO":"YES")<<endl;
}



Measured memory_bytes: 256
def main():
    A, B, C, X, Y = map(int, input().split())
    ans = 10 ** 10

    for k in range(10 ** 5 + 1):
        total = 2 * C * k + A * max(0, X - k) + B * max(0, Y - k)
        if total < ans:
            ans = total

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9172
package main

import (
	"fmt"
)

func main() {
	var n, T int
	fmt.Scan(&n, &T)
	
	t := make([]int, n)
	
	for i := range t {
		fmt.Scan(&t[i])
	}
	
	ans := 0
	for i := 0; i < n - 1; i++ {
		ans += min(T, t[i+1]-t[i])
	}
	ans += T
	fmt.Println(ans)
}

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

Measured memory_bytes: 6488
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class Program
{
    class Modular
    {
        private const int M = 998244353;
        private long value;
        public Modular(long value) { this.value = value; }
        public static implicit operator Modular(long a)
        {
            var m = a % M;
            return new Modular((m < 0) ? m + M : m);
        }
        public static Modular operator +(Modular a, Modular b)
        {
            return a.value + b.value;
        }
        public static Modular operator -(Modular a, Modular b)
        {
            return a.value - b.value;
        }
        public static Modular operator *(Modular a, Modular b)
        {
            return a.value * b.value;
        }
        public static Modular Pow(Modular a, int n)
        {
            switch (n)
            {
            case 0:
                return 1;
            case 1:
                return a;
            default:
                var p = Pow(a, n / 2);
                return p * p * Pow(a, n % 2);
            }
        }
        public static Modular operator /(Modular a, Modular b)
        {
            return a * Pow(b, M - 2);
        }
        private static readonly List<int> facs = new List<int> { 1 };
        private static Modular Fac(int n)
        {
            for (int i = facs.Count; i <= n; ++i)
            {
                facs.Add((int)(Math.BigMul(facs.Last(), i) % M));
            }
            return facs[n];
        }
        public static Modular Ncr(int n, int r)
        {
            return (n < r) ? 0
                 : (n == r) ? 1
                            : Fac(n) / (Fac(r) * Fac(n - r));
        }
        public static explicit operator int(Modular a)
        {
            return (int)a.value;
        }
    }

    static Modular Calculate(int N, int M, int K)
    {
        return new Modular(M) * Modular.Pow(M - 1, N - K - 1) * Modular.Ncr(N - 1, N - 1 - K);
    }

    static long Solve(int N, int M, int K)
    {
        Modular sum = 0;
        for (int i = 0; i <= K; ++i)
        {
            sum += Calculate(N, M, i);
        }
        return (long)sum;
    }

    static void Main(string[] args)
    {
        var V = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        Console.WriteLine(Solve(V[0], V[1], V[2]));
    }
}


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

vector<int> g[5010];
int cnt[5010];

int main(){
  int n,m,a,b;
  cin >> n >> m;

  for(int i=0;i<n;i++)g[i].clear();
  memset(cnt,0,sizeof(cnt));

  for(int i=0;i<m;i++){
    cin >> a >> b;
    g[a].push_back(b);
    cnt[b]++;
  }

  queue<int> q;
  for(int i=1;i<=n;i++){
    if(!cnt[i])q.push(i);
  }

  int f = 0;
  vector<int> ans;
  while(q.size()){
    if(q.size() > 1)f = 1;
    int v = q.front(); q.pop();

    ans.push_back(v);
    for(int i=0;i<(int)g[v].size();i++){
      cnt[g[v][i]]--;
      if(cnt[g[v][i]]==0)q.push(g[v][i]);
    }
  }

  for(int i=0;i<(int)ans.size();i++)cout << ans[i] << endl;
  cout << f << endl;
}

Measured memory_bytes: 2052
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

Int N,K;

Int fact[5000];
Int invfact[5000];
Int inv[5000];

void init(void) {
    fact[0] = fact[1] = 1;
    invfact[0] = invfact[1] = 1;
    inv[1] = 1;
    for(Int i = 2;i < 5000;i++) {
        fact[i] = i * fact[i-1] % MOD;
        inv[i] = MOD - (MOD / i)*inv[MOD % i] % MOD;
        invfact[i] = inv[i] * invfact[i-1] % MOD;
    }

    return;
}

Int comb(Int n,Int r) {
    if(n == 0 || r == 0)
        return 1;
    if(r > n)
        return 0;
    return (fact[n]*invfact[n-r] % MOD) * invfact[r] % MOD;
}

int main(void) {
    cin>>N>>K;
    init();

    Int ans = 0;
    for(Int i = 1;i <= K;i++) {
        ans = comb(N-K+1,i) * comb(K-1,i-1) % MOD;
        cout<<ans<<endl;
    }

    return 0;
}





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

int main() {
  int n, k, c = 1;
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    if (c * 2 < c + k) c *= 2;
    else c += k;
  }
  cout << c << endl;
}


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

R = S.count('R')
G = S.count('G')
B = S.count('B')

impossible = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        delta = j - i
        k = j + delta
        if k >= n:
            break

        pairs = {S[i], S[j], S[k]}
        if len(pairs) == 3:
            impossible += 1

ans = R * G * B - impossible
print(ans)

Measured memory_bytes: 9212
//D - Wizard in Maze
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

#define LL long long
#define Lowbit(X) (X&(-X))
#define Lson (X<<1)
#define Rson (X<<1|1)
#define Cl(X,Y) memset((X),(Y),sizeof(X))
#define FOR(i,A,B) for(int i=A;i<=B;i++)
#define BOR(i,A,B) for(int i=A;i>=B;i--)
#define FOR_SIDE(i,A) for(int i=Head[A];i;i=Next[i])
#define INF 0x7fffffff
using namespace std;
const int MAXN=2e3+10;

int DP[MAXN][MAXN];
bool Vis[MAXN][MAXN];
int Row,Line,Stax,Stay,Endx,Endy,New,A,B;
char Map[MAXN][MAXN];
int Dx[5]={0,0,-1,0,1},Dy[5]={0,1,0,-1,0};
int Dx5[21]={0,-1,-1,1,1,0,-1,-2,-2,-2,-2,-2,-1,0,1,2,2,2,2,2,1};
int Dy5[21]={0,1,-1,-1,1,2,2,2,1,0,-1,-2,-2,-2,-2,-2,-1,0,1,2,2};
inline void File() {
    freopen(".in","r",stdin);
    freopen(".out","w",stdout);
}
struct Node { int E,F; };
queue<Node>Mine;

inline void DFS(int X,int Y,int Time) {
    Vis[X][Y]=true;
    DP[X][Y]=Time;
    FOR(i,1,4) {
        int Nx=X+Dx[i],Ny=Y+Dy[i];
        if(Nx>Row || Nx<1 || Ny>Line || Ny<1 || Vis[Nx][Ny]) continue;
        DFS(Nx,Ny,Time);
    }
    FOR(i,1,20) {
        int Nx=X+Dx5[i],Ny=Y+Dy5[i];
        if(Nx<=Row && Nx>=1 && Ny<=Line && Ny>=1 && !Vis[Nx][Ny]) {
            Mine.push(Node{ Nx,Ny }); 
			if(DP[Nx][Ny]) DP[Nx][Ny]=min(Time+1,DP[Nx][Ny]);
			else DP[Nx][Ny]=Time+1;
        }
    }
}

int main() {
    //File();
    scanf("%d %d",&Row,&Line);
    scanf("%d %d",&Stax,&Stay);
    scanf("%d %d",&Endx,&Endy);
    FOR(i,1,Row) { 
		scanf("%s",Map[i]+1); 
		FOR(j,1,Line) if(Map[i][j]=='#') Vis[i][j]=true;
	}
	Mine.push(Node{ Stax,Stay });
	while(!Mine.empty()) {
		int W=Mine.front().E,S=Mine.front().F;
		if(Vis[W][S]) { Mine.pop(); continue; }
        DFS(W,S,DP[W][S]);
		Mine.pop();
    }
    if(!Vis[Endx][Endy]) { printf("-1\n"); }
    else { printf("%d\n",DP[Endx][Endy]); }
    //fclose(stdin); fclose(stdout);
 //   system("pause");
    return 0;
}

Measured memory_bytes: 15756
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define lld long double
#define REP(i,s,n) for(lli i=s;i<n;i++)
#define RREP(i,s,n) for(lli i=s;i>=n;i--)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli data[60][26];

signed main(){

	lli n;
	cin>>n;

	REP(i,0,n){
		string s;
		cin>>s;
		REP(j,0,s.size()){
			data[i][s.at(j)-'a']++;
		}
	}

	lli minNum[26]={INF};
	REP(i,0,26)minNum[i]=INF;

	REP(i,0,n)REP(j,0,26){
		if(DEBUG)cout<<"i="<<i<<" j="<<j<<" data[i][j]="<<data[i][j]<<endl;
		minNum[j] = min(minNum[j],data[i][j]);
	}

	REP(i,0,26){
		if(DEBUG)cout<<minNum[i]<<endl;
		REP(j,0,minNum[i])cout<<(char)('a'+i);
	}
	cout<<endl;

	return 0;
}

Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var inputN = Console.ReadLine();
        var inputX = Console.ReadLine();

        double n = double.Parse(inputN);
        var xList = inputX.Split(' ');

        double xSum = 0;
        for (int i = 0; i < xList.Length; i++)
        {
            xSum += int.Parse(xList[i]);
        }
        //集会を開く座標
        double pointDouble = xSum / n;

        int point = (int)pointDouble;
        int pointPlusOne = point + 1;


        //体力の総和
        int powerSum = 0;
        for (int i = 0; i < xList.Length; i++)
        {
            powerSum += (point - int.Parse(xList[i])) * (point - int.Parse(xList[i]));
        }

        int powerSumPlusOne = 0;
        for (int i = 0; i < xList.Length; i++)
        {
            powerSumPlusOne += (pointPlusOne - int.Parse(xList[i])) * (pointPlusOne - int.Parse(xList[i]));
        }

        if (powerSum<= powerSumPlusOne)
        {
            Console.WriteLine(powerSum);
        }
        else
        {
            Console.WriteLine(powerSumPlusOne);
        }
       // Console.WriteLine(powerSum);
        //Console.WriteLine(n);
        //Console.WriteLine(k);


    }
}



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

int main() {
  int N,a,b,c,d;
  cin >> N;
  a = N/1000;
  b = (N-a*1000)/100;
  c = (N-a*1000-b*100) / 10;
  d = N-a*1000-b*100-c*10;
  if((a==b && b==c)|| (b==c && c==d)) cout << "Yes" << endl;
  else cout << "No" << endl;
 }



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

void solve(int n){
    vector<vector<pair<int, int>>> G(n);
    int ans = 0, ans2 = 0;
    for (int i = 0; i < n-1; ++i) {
        int a, b, t;
        cin >> a >> b >> t;
        a--; b--;
        G[a].emplace_back(b, t);
        G[b].emplace_back(a, t);
        ans += t*2;
    }
    vector<int> dp(n);
    auto dfs = [&](int x, int par, auto &&f) -> void {
        for (auto &&i : G[x]) {
            if(i.first != par) {
                dp[i.first] = dp[x]+i.second;
                f(i.first, x, f);
            }
        }
    };
    dfs(0, -1, dfs);
    for (int i = 1; i < n; ++i) {
        if(G[i].size() == 1) ans -= G[i][0].second*2;
        else ans2 = max(ans2, dp[i]);
    }
    cout << ans-ans2 << "\n";
}

int main() {
    int n;
    while(cin >> n, n) solve(n);
    return 0;
}


Measured memory_bytes: 3108
#include <iostream>

using namespace std;

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

Measured memory_bytes: 1164
import collections
N = int(input())
S = [input() for _ in range(N)]
S_C = collections.Counter(S)
max = S_C.most_common()[0][1]
ans = [i[0] for i in S_C.items() if i[1] >= max]
ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 45040
import java.util.Scanner;
public class Main {
    static Scanner sc = new Scanner(System.in);
 
    public static void main(String[] args) {
        long N = sc.nextLong();
        long sum = 0;
        for (long i = 1; i <= N; i++) {
            if(i%15 != 0 && i%3 != 0 && i%5 !=0){
              sum += i;
            }
        }
        System.out.println(sum);
      }
}

Measured memory_bytes: 35728
#include <iostream>
#include <map>
#include <string>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
 
    map<string, int> sum;
 
    for(int i=0; i<n; i++){
        string s;
        int m;
        cin >> s >> m;
 
        switch(s.size()){
        case 1:
            s = "1"+s;
            break;
        case 2:
            s = "2"+s;
            break;
        case 3:
            s = "3"+s;
            break;
        case 4:
            s = "4"+s;
            break;
        case 5:
            s = "5"+s;
            break;
        default:
            break;
        }
 
        if(sum.find(s) != sum.end()){
            sum[s] += m;
        }
        else{
            sum[s] = m;
        }
    }
 
    map<string, int>::iterator p;
    for(p = sum.begin(); p != sum.end(); p++){
        string s = p->first;
        s.erase(0, 1);
        cout << s << ' ' << p->second << endl;
    }
 
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;

ll X[55],P[55];

void init(){
  X[0] = 1;
  rep(i,1,51) X[i] = 3LL + 2LL * X[i-1];
  P[0] = 1;
  rep(i,1,51) P[i] = 1LL + 2LL * P[i-1];
}

ll p=0;

void dfs(int l,ll x){ //レベルlバーガーの下からx層について
  if(x <= 1LL){
    if(l==0 && x==1)p++;
  }else if(x <= 1LL + X[l-1]){
    dfs(l-1,x-1LL);
  }else if(x <= 2LL + X[l-1]){
    p++;
    dfs(l-1,x-2LL);
  }else if(x <= 2LL + 2LL * X[l-1]){
    p++;
    p += P[l-1];
    dfs(l-1,x-2LL-X[l-1]);
  }else{
    p++;
    p += 2LL * P[l-1];
  }
}


int main(){
  init();
  int N;
  ll x;
  cin >> N >> x;

  dfs(N,x);

  cout << p << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    vector<int> p(n);
    int cnt=0;
    for(int i=0; i<n; i++){
        cin >> p[i];
        if(p[i]!=i+1) cnt++;
    }
    if(cnt<=2) cout << "YES";
    else cout << "NO";
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,r,x=0;
    cin>>n;


    r=n%1000;
    if(r==0)
    {
        cout<<"0";
    }
    else
    {

        x=1000-r;
        cout<<x;
    }



    return 0;

}



Measured memory_bytes: 3612
sd=list(input())
t=list(input())
#strsd="?tc????"
#strt="coder"

#strsd="??p??d??"
#strt="abc"

#strsd="ab??p??c"
#strt="abc"

#strsd="ab??p??c"
#strt="abcapcadc"

#sd=list(strsd)
#t=list(strt)

lens=len(sd)
lent=len(t)
yn="NG"
for i in range(lens-lent,-1,-1):
    yn=""
    for ii in range(lent):
        if sd[i+ii]==t[ii] or sd[i+ii]=="?":
            continue
        else:
            yn="NG"
            break
    if yn!="NG":
        yn="itchi"
        break
    
if yn=="NG":
    print("UNRESTORABLE")
else:
    s=""
    if i!=0:
        for ii in range(i):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    for ti in t:
        s=s+ti
    if i!=lens-lent:
        for ii in range(i+lent,lens,1):
            if sd[ii]=="?":
                si="a"
            else:
                si=sd[ii]
            s=s+si
    print(s)
    


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

int main() {
  long long a,b,c;
  cin >> a >> b >> c;
  long long d=c-a-b;
  if (a*b*4<d*d && d>0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#include<unordered_map>
using namespace std;
#define Ma7moud_7amdy                 \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)
#define Open_Sesame Open()
#define all(v) ((v).begin()), ((v).end())
#define allr(v) ((v).rbegin()), ((v).rend())
#define clr(arr, x) memset(arr, x, sizeof arr)
#define endl "\n"
#define Accepted 0
#define watch(x) cout << #x << " = " << x << endl;
#define RT(x) return cout << (x), 0;
#define sc(a) scanf("%d", &a)
#define pr(a) printf("%d", a)
#define scll(x) scanf("%I64d", &x)
#define prll(x) printf("%I64d", x)
#define scan(s) scanf("%[^\n]%*c", &s)
#define print(s) printf("%s", s.c_str()); // print string
#define sz(v) v.size()
typedef long long ll;
typedef vector<int> vi;
const int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int Mx = INT_MAX;
const int Mn = INT_MIN;
const ll MX = LLONG_MAX;
const ll MN = LLONG_MIN;
const double PI = acos(-1.0);
void Open()
{
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
#endif
}
const double EPS = -1e-2;
const ll mod = ll(1e9 + 7);
const int N = 2000 + 5;

//“Nobody but you have to believe in your dreams to make them a reality.” ― Germany Kent


int main() {

	Ma7moud_7amdy;
	//Open_Sesame;
	int n,k,tmp,cur,mx=0;
	cin >> k >> n;
	cin >> tmp;
	int frst = tmp;
	for (int i = 1; i < n; i++) {
		cin >> cur;
		mx=max(mx,abs(cur-tmp));
		tmp = cur;
	}
	int dst = k - (cur - frst);
	mx = max(mx, dst);
	cout <<  k-mx;
}

Measured memory_bytes: 256
import math
l=input().split()
a=float(l[0])
b=float(l[1])
c=int(l[2])

S=a*b*math.sin(math.radians(c))/2
h=S*2/a
d=math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(c)))
L=a+b+d

print(S)
print(L)
print(h)



Measured memory_bytes: 5704
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
typedef pair<int,int> P;
typedef pair<P,P> L;
typedef vector<P> Pol;
Pol pol[100];
map<string,int> mp;
int I;
int cntry[100];
P operator -(P x,P y){
	return P(x.fs-y.fs,x.sc-y.sc);
}
inline bool is(L a,L b){
	P x=a.sc-a.fs,y=b.sc-b.fs,z=b.fs-a.fs;
	if(x.fs*y.sc!=x.sc*y.fs) return 0;
	if(x.fs*z.sc!=x.sc*z.fs) return 0;
	int d=a.fs.fs,e=a.sc.fs,f=b.fs.fs,g=b.sc.fs;
	if(x.fs==0) d=a.fs.sc,e=a.sc.sc,f=b.fs.sc,g=b.sc.sc;
	if(d>e) swap(d,e);
	if(f>g) swap(f,g);
	return max(d,f)<min(e,g);
}
int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0) break;
		rep(i,N) pol[i].clear();
		mp.clear();
		I=0;
		rep(i,N){
			string st;
			cin>>st;
			if(!mp.count(st)) mp[st]=I++;
			cntry[i]=mp[st];
			while(true){
				int x,y;
				cin>>x;
				if(x<0) break;
				cin>>y;
				pol[i].pb(P(x,y));
			}
		}
		bool e[10][10]={};
		rep(i,I) e[i][i]=1;
		rep(i,N) rep(j,i){
			int a=cntry[i],b=cntry[j];
			if(e[a][b]) continue;
			rep(k,pol[i].size()) rep(l,pol[j].size()){
				L x=L(pol[i][k],pol[i][(k+1)%pol[i].size()]);
				L y=L(pol[j][l],pol[j][(l+1)%pol[j].size()]);
				if(is(x,y)){
					e[a][b]=e[b][a]=1;
					goto done;
				}
			}
			done:
			;
		}
		bool ind[1024]={};
/*		show(I);
		rep(i,I){
			rep(j,I) cout<<e[i][j]<<" ";
			puts("");
		}*/
		rep(i,1<<I){
			ind[i]=1;
			rep(j,I) rep(k,j) if((i>>j)&(i>>k)&1) if(e[j][k]) ind[i]=0;
		}
		int dp[1024]={};
		rep(i,1<<I){
			if(i==0) continue;
			dp[i]=11;
			rep(j,1<<I){
				if((i|j)==i && ind[j]) chmin(dp[i],dp[i^j]+1);
			}
		}
		cout<<dp[(1<<I)-1]<<endl;
	}
}

Measured memory_bytes: 1240
a, b, k = map(int, input().split())
c = []
if a < b:
    for i in range(a, 0, -1):
        if a % i == 0 and b % i == 0:
            c.append(i)
else:
    for i in range(b, 0, -1):
        if a % i == 0 and b % i == 0:
            c.append(i)
            
print(c[k-1])

Measured memory_bytes: 3060
N = int(input())
S1 = input()
S2 = input()

i = 1
if S1[0] == S2[0]:
    ans = 3
    state = 0
else:
    i+= 1
    ans = 6
    state = 1
mod  = 10**9 + 7
while N > i:
    if S1[i] != S2[i] and state == 0:
        ans *= 2
        i+=2
        state = 1
    elif S1[i] != S2[i] and state == 1:
        ans *= 3
        i+=2
    elif S1[i] == S2[i] and state == 0:
        ans *= 2
        i+= 1
    elif S1[i] == S2[i] and state == 1:
        ans *= 1
        i+=1
        state = 0

    ans %= mod
print(ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vll res(n);
    ll a;
    REP(i, n - 1) {
        cin >> a;
        a--;
        res[a]++;
    }
    REP(i, n) {
        cout << res[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  string t = s;
  reverse(ALL(t));
  int ans = 0;
  rep(i, s.size()/2){
    if(s.at(i) != t.at(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define rep(i,m) for(long long i=0; i<m; i++)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
int main()
{
  ll a,b[10100],ans;
  cin >> a;
  rep(i,a)cin >>b[i];
  rep(i,a){
    rep(j,50){if(b[i]%2==1)goto A;
              ans++;
              b[i]/=2;
             }
    A:;
  }
    printf("%lld",ans);
}

Measured memory_bytes: 384
#include <cstdio>

int main() {
long long r = 0;
int i, n, m;
scanf("%d%d", &n, &m);
if (m == 0) {
printf("%lld\n", (long long)n * n);
return 0;
}
for (i = m + 1; i <= n; i++) {
r += n / i * (i - m);
if (n % i >= m) r += n % i - m + 1;
}
printf("%lld\n", r);
return 0;
}

Measured memory_bytes: 128
N = str(input())
b = int(N[-1])
if (b==2 or b==4 or b==5 or b==7 or b==9):
  print("hon")
elif (b==0 or b==1 or b==6 or b==8):
  print("pon")
elif (b==3):
  print("bon")
else:
  print("Error")

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

using namespace std;
#define ll long long

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}

#ifdef LOCAL
#define lcout(a) cout << a;
#define lcoutln(a) cout << a << endl;
#define lcerr(a) cerr << a;
#define lcerrln(a) cerr << a << endl;
#else
#define lcout(a) 
#define lcoutln(a) 
#define lcerr(a) 
#define lcerrln(a) 
#endif

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

int N;

void init()
{
	cin >> N;
}

void solve()
{
	while (N++ % 111);
	cout << N-1 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  int pay, coin, divide, rest, oneyens;
  scanf("%d %d", &pay, &coin);
  divide=pay/500; //N円を500で割った商。500円玉を使った枚数。
  rest=pay-500*divide; //500円玉で払った後の残額。1円玉で払う分。
  oneyens=rest-coin; //1円玉を数えるのは面倒なので全部出しちゃった。正の値なら払いきれないぞ
  if(rest==0)
    printf("Yes"); //おつりがゼロ円。ちょうどだったぜ
  else if(oneyens>0)
    printf("No");  //正の値。払いきれなかった
  else
    printf("Yes"); //負の値。おつりがきたぜ。次からはちゃんと数えて出すぞ。
  
  return 0;
}

Measured memory_bytes: 128
/**
 *   Author: Praveen Ojha
 *   Created: 27 March 2019
 *   Time: 23:56:29
**/
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define PI 3.141592653589793238510
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define __ ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename   enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

typedef long double ld;
typedef pair<int,int> pii;
/////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////
int n,k;
int a_i;

inline void add_self(int &x,int b){
	x+=b;
	if(x>=mod)
		x-=mod;
}
inline void sub_self(int &x,int b){
	x-=b;
	if(x<0)
		x+=mod;
}
int32_t main(){__
	//memset(dp,-1,sizeof dp);
	cin>>n>>k;
	vector <vector<int> > dp(n+1,vector<int>(k+1,0));
	dp[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		cin>>a_i;
		vector <int> prefix(k+1,0);
		for(int used=0;used<=k;used++){
			if(i-1>=0){
			int temp=dp[i-1][used];
			int left=used;
			int right=min(used+a_i,k)+1;
			add_self(prefix[left],temp);
			if(right<=k){
				sub_self(prefix[right],temp);
			}
		}	
		}
		int sumi=0;
		for(int j=0;j<=k;j++)
			{
				add_self(sumi,prefix[j]);
				add_self(dp[i][j],sumi);
			}
	}
	//debug()<< imie(dp);
	cout<<dp[n][k]<<"\n";
return 0;
}

Measured memory_bytes: 80256
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = 10**5
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]

for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

n, k = map(int, input().split())
a = list( map(int, input().split()))

ans = 0


a.sort()

for j in range(n):
    i = j +1
    if j <= n-k:
        minX = a[i-1]
        ans -= a[i-1]*cmb(n-i,k-1,mod)%mod
    if k -1 <= i:
        maxX = a[i-1]
        ans += a[i-1]*cmb(i-1,k-1,mod)%mod

print(ans%mod)




Measured memory_bytes: 26740
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define fs first
#define sc second
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main(){
  long long a,b,x;
  cin>>a>>b>>x;
  if(a!=0)
  cout<<b/x-((a-1)/x)<<endl;
  else cout<<(b/x)+1<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]=='R' && s[1]=='R' && s[2]=='R')
        cout<<"3\n";
    else if((s[0]=='R' && s[1]=='R') || (s[1]=='R' && s[2]=='R'))
     cout<<"2\n";
    else if(s[0] != 'R' && s[1]!='R' && s[2]!='R')
     cout<<"0\n";
    else
     cout<<"1\n";
}


Measured memory_bytes: 3620
#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>
#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>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}

struct S{
    int number;
    int AC[10]={},WA[10]={},time=0;
    int sumAC=0;
};

bool cmp(S a,S b){
    if(a.sumAC==b.sumAC){
        if(a.time==b.time)return a.number>b.number;
        return a.time<b.time;
    }
    return a.sumAC>b.sumAC;
}

signed main (){
    int n;cin>>n;
    double ans=0;
    rep(i,0,n){
        double x;
        string cmd;
        cin>>x>>cmd;
        if(cmd=="JPY")ans+=x;
        else ans+=380000*x;
    }
    cout<<fixed<<setprecision(15);
    cout<<ans<<endl;
}
    
/*
*/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int N,x;
	while(~scanf("%d%d",&N,&x))
	{int a[N];
	for(int i=0;i<N;i++)
	{
		cin>>a[i];
	}
	long long ans=0;
	if(a[0]>x)
	{ans=a[0]-x;
	  a[0]=a[0]-ans;
	}
	for(int i=1;i<N;i++)
	{
		if(a[i]+a[i-1]>x)
		{ ans+=a[i]+a[i-1]-x;
		  a[i]-=a[i]+a[i-1]-x;
		}

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

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Globalization;
using System.Diagnostics;
using Pair = System.Collections.Generic.KeyValuePair<int, int>;

class Program
{
    static void Main()
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        new Program().Solve();
        Console.Out.Flush();
    }
    Scanner cin = new Scanner();


    void Solve()
    {
        int N = cin.Nextint;
        var C = cin.Scanint;
        int Q = cin.Nextint;

        var A = new int[N];
        for (int i = 0; i < Q; i++)
        {
            if (cin.Nextint == 1)
            {
                int x = cin.Nextint - 1;
                A[x] += cin.Nextint;
                if (A[x] > C[x])
                {
                    Console.WriteLine(x + 1);
                    return;
                }
            }
            else
            {
                int x = cin.Nextint - 1;
                A[x] -= cin.Nextint;
                if (A[x] < 0)
                {
                    Console.WriteLine(x + 1);
                    return;
                }
            }
        }
        Console.WriteLine(0);
    }

}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] Scan { get { return Console.ReadLine().Split(); } }
    public int[] Scanint { get { return Array.ConvertAll(Scan, int.Parse); } }
    public long[] Scanlong { get { return Array.ConvertAll(Scan, long.Parse); } }
    public double[] Scandouble { get { return Array.ConvertAll(Scan, double.Parse); } }
    public string Next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return Next;
        }
    }
    public int Nextint { get { return int.Parse(Next); } }
    public long Nextlong { get { return long.Parse(Next); } }
    public double Nextdouble { get { return double.Parse(Next); } }
}


Measured memory_bytes: 9308
#include<stdio.h>
int main()
{
    long int a,b,k;
    scanf("%ld %ld %ld",&a,&b,&k);

    if(a>0){
        if(a<=k)
        {

            k=k-a;
            a=0;

        }
        else
        {
            a=a-k;
            k=0;
        }

        }
        if(b>0 && k>0)
        {
            if(b>k)
            {

                b=b-k;

            }
            else
            {
               b=0;

            }
        }
    printf("%ld %ld\n",a,b);
    return 0;
}


Measured memory_bytes: 128
#define _LIBCPP_DEBUG 0
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=int(a);i<int(b);i++)
typedef vector<int> vi;
typedef long long ll;



int main(){
    ll x;cin>>x;
    ll ans=x/11*2;
    if(x%11<7&&x%11>=1)ans++;
    else if(x%11>=7)ans+=2;
    cout<<ans<<endl;
    

    
}






Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int a, b;
    cin >> a >> b;
    cout << (a+b+(a+b)%2)/2 << "\n";
    return 0;
}

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

#define f(xl,xr,yl,yr)(s[xr][yr]-s[xl][yr]-s[xr][yl]+s[xl][yl])

ll s[1010][2010];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,0,n){
		int x,y;
		char c;
		scanf("%d%d %c",&x,&y,&c);
		ll d=x/k+y/k;
		s[x%k+1][y%k+(((d%2)^(c=='B'))?k:0)+1]++;
	}
	rep(x,0,k+5)rep(y,1,2*k+5)s[x][y]+=s[x][y-1];
	rep(y,0,2*k+5)rep(x,1,k+5)s[x][y]+=s[x-1][y];
	//s[x][y]には[0,x)*[0,y)の和
	
	ll sum=s[k][2*k];
	ll ans=0;
	rep(x,0,k)rep(y,0,k){
		//[x,x+k)*[y,y+k)の範囲を合計する。次の形の高々3つの領域に分かれる
		//[x,k)*[y,y+k)
		//[0,x)*([0,y)+[y+k,2*k))
		//y>=kは反転なのでsumから引く
		ll t1=f(x,k,y,y+k);
		ll t2=f(0,x,0,y);
		ll t3=f(0,x,y+k,2*k);
		ans=max(ans,max(t1+t2+t3,sum-t1-t2-t3));
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 16000
import std.stdio, std.string;

void main(){
	string[] s;
	int n;
	while (readf("%d\n", &n), n) {
		int[] a;
		s = split(readln());
		foreach (i; s) a ~= i[0] - '0';
		n = 32;
		for (int i = 0; n > 0; i++) {
			if (i%2 == 0) n -= (n-1)%5;
			else n -= a[i/2 % $];
			writeln(n > 0 ? n : 0);
		}
	}
}

Measured memory_bytes: 1016
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ff first               // For pairs
#define ss second              // For pairs
#define sz(a) int((a).size())  // Function to determine size of any container
#define pb push_back           // Pushback to vector
#define mp make_pair           // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end()
#define tr(container, it) for (auto it = container.begin(); it != container.end(); it++)  //traversing macro
#define lp(it, it1, it2) for (auto it = it1; it < it2; it++)                              //loop
#define present(c, x) (c.find(x) != c.end())
#define mod 1000000007
using namespace std;
using namespace std::chrono;
typedef vector<ll> vi;            // Vector of long long
typedef vector<vi> vvi;           // Vector of vi
typedef vector<pair<ll, ll>> ii;  // Vector of pairs
typedef vector<ii> vii;           // Vector of ii

int main() {
    ll n, m, u, v, w = 1;
    cin >> n >> m;
    char c;
    vvi dp(n + 1, vi(m + 1));
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= m; j++) {
            cin >> c;
            if (c == '.')
                dp[i][j] = 0;
            else
                dp[i][j] = -1;
        }
    for (int i = 2; i <= n; i++)
        dp[i][0] = -1;
    for (int i = 2; i <= m; i++)
        dp[0][i] = -1;
    dp[0][1] = 1;
    bool poss = true;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= m; j++) {
            if (dp[i][j] != -1) {
                if (dp[i - 1][j] == -1 && dp[i][j - 1] == -1)
                    dp[i][j] = -1;
                else if (dp[i - 1][j] == -1)
                    dp[i][j] = dp[i][j - 1];
                else if (dp[i][j - 1] == -1)
                    dp[i][j] = dp[i - 1][j];
                else
                    dp[i][j] = (dp[i - 1][j] % mod + dp[i][j - 1] % mod) % mod;
            }
        }
    }
    if (dp[n][m] == -1) {
        cout << "0\n";
        return 0;
    }
    cout << dp[n][m] << "\n";
    return 0;
}


Measured memory_bytes: 8064
#include "bits/stdc++.h"

using namespace std;

int main()
{

  long long W, H, x, y;
  cin >> W >> H >> x >> y;

  
  cout <<fixed<<setprecision(10) <<(double)(W * H) / 2 << " ";
  if (2 * x == W && 2 * y == H) {
    cout << 1;
  }
  else {
    cout << 0;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
//ll inf=(ll)1E12;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll * pos,ll val){*pos=max(*pos,val);}//Max(&dp[i][j],dp[i-1][j]);
void Min(ll * pos,ll val){*pos=min(*pos,val);}
void Add(ll * pos,ll val){*pos=mod(*pos+val);}
const long double EPS=1E-8;
////////////////////////////////////////
/////////////////////////////////////////////////////
ll inf=(ll)1E17;

const ll MAX_N=1<<20;
//セグメント木を持つグローバル配列
ll n,dat[2*MAX_N-1];
//初期化
void init(ll n_){
    //簡単のため要素数を2のべき乗に
    n=1;
    while(n<n_)n*=2;
    //全ての値をinfに
    for(ll i=0;i<2*n-1;i++)dat[i]=inf;
}
//k番目の値(0-indexed)をaに変更
void update(ll k,ll a){
    //葉の節点
    k+=n-1;
    dat[k]=a;
    //登りながら更新
    while(k>0){
        k=(k-1)/2;
        dat[k]=min(dat[k*2+1],dat[k*2+2]);
    }
}
//[a,b)の最小値を求める
//後ろの方の引数は、計算の簡単のための引数
//kは節点の番号、l,rはその節点が[l,r)に対応づいていることを表す。
ll query(ll a,ll b,ll k,ll l,ll r){
    //[a,b)と[l,r)が交差しなければinf
    if(r<=a||b<=l)return inf;
    //[a,b)が[l,r)を完全に含んでいれば、この節点の値
    if(a<=l&&r<=b)return dat[k];
    else{
        //そうでなければ、2つの子の最小値
        ll vl=query(a,b,k*2+1,l,(l+r)/2);
        ll vr=query(a,b,k*2+2,(l+r)/2,r);
        return min(vl,vr);
    }
}
//[a,b)の最小値
ll que(ll a,ll b){
    return query(a,b,0,0,n);
}
/////////////////////////////////////////////////////

int main(){
    ll n;cin>>n;
    ll h[n];rep(i,0,n-1){cin>>h[i];h[i]--;}
    ll a[n];rep(i,0,n-1){cin>>a[i];a[i]*=-1;}
    ll dp[n];
    init(n);
    rep(i,0,n-1){
        dp[i]=que(0,h[i])+a[i];
        update(h[i],dp[i]);
    }
    cout<<inf-que(0,n)<<endl;
    
    return 0;
}


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

int main()
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string prevWord = "";
	set<string> allPrevWords;
	for (int i = 0; i < n; i++)
	{
		string word;
		cin >> word;
		if (allPrevWords.count(word))
		{
			cout << "No" << endl;
			return 0;
		}
		if (prevWord != "")
		{
			if (word[0] != prevWord.back())
			{
				cout << "No" << endl;
				return 0;
			}
		}
		allPrevWords.insert(word);
		prevWord = word;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
cake = [list(map(int, input().split())) for _ in range(N)]
ans = 0
for i in [-1, 1]:
    for j in [-1, 1]:
        for k in [-1, 1]:
            cor = []
            for l in range(N):
                cor.append(cake[l][0]*i+cake[l][1]*j+cake[l][2]*k)
            cor.sort(reverse = True)
            temp = sum(cor[:M])
            ans = max(temp, ans)
print(ans)


Measured memory_bytes: 3316
N = int(input())
r = [list(map(int, input().split())) for _ in range(N)]
r.sort()

l = r[0]
ri = 1
ans = N
while ri < N:
    x1, l1 = l
    x2, l2 = r[ri]
    if (x1+l1) > (x2-l2):
        if (x1+l1) > (x2+l2):
            l = r[ri]
            ri += 1
        else:
            ri += 1
        ans -= 1
    else:
        l = r[ri]
        ri += 1
print(ans)


Measured memory_bytes: 61016
use std::io::*;
use std::str::FromStr;
use std::collections::*;

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 find_divisor(N: i32) -> i32 {
    let mut ans = 0;
    for n in 1..N+1 {
        let mut cnt = 0;
        for d in 1..n+1 {
            if n%d==0 && n%2==1 {
                cnt += 1;
            }
        }
        if cnt == 8 {
            ans += 1;
        }
    }
    return ans;
}

fn main() {
    let N = read();
    let ans = find_divisor(N);
    println!("{}", ans);
}

Measured memory_bytes: 2128
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define INF (1<<29)
using namespace std;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};
typedef pair<int,int>pii;
struct Node{int x,y;};
int n,m,k;
char a[810][810];
int dist[810][810];
int main(){
	cin>>n>>m>>k;
	queue<Node>qq;
	memset(dist,-1,sizeof(dist));
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++){
			cin>>a[i][j];
			if(a[i][j]=='S'){
				set<pii>tss;
				a[i][j]='.',qq.push(Node{i,j}),dist[i][j]=0;
			}
		}
	while(!qq.empty()){
		Node node=qq.front();
		qq.pop();
//		cout<<"In"<<node.x<<' '<<node.y<<endl;
		for(int i=0;i<4;i++){
			int tx=node.x+dx[i],ty=node.y+dy[i];
//			if(tx<1||tx>n||ty<1||ty>n)continue;
			if(a[tx][ty]!='.')continue;
			if(dist[tx][ty]!=-1)continue;
			dist[tx][ty]=dist[node.x][node.y]+1;
			qq.push(Node{tx,ty});
		}
	}
//	for(int i=1;i<=n;i++){
//		for(int j=1;j<=m;j++)cout<<setw(3)<<dist[i][j];
//		cout<<endl;
//	}
	int ans=INF;
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)if(dist[i][j]<=k&&dist[i][j]!=-1){
			ans=min(ans,1+(min(min(i-1,n-i),min(j-1,m-j))+k-1)/k);
//			printf("%d=min(%d,1+(min(min(%d-1,%d-%d),min(%d-1,%d-%d))+%d-1)/%d)\n",ans,ans,i,n,i,j,m,j,k,k);
		}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3456
import sys
A,B,C,D = str(input())
ops = ['+', '-']

for op1 in ops:
    for op2 in ops:
        for op3 in ops:
            a = A+op1+B+op2+C+op3+D
            if eval(a) == 7:
                print(a+'=7')
                sys.exit()


Measured memory_bytes: 2940
/*input

*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits>
#include <random>

using namespace std; 

template<typename T>
using minpq = priority_queue<T, vector<T>, greater<T>>;
int GCD(int x,int y){return y?GCD(y,x%y):x;}
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,a,b) for(int i=(a);i<(b);i++)
#define repm(i,a,b) for(int i=(a);i>(b);i--)
#define rept(v) for(auto it=v.begin();it<v.end();it++)
#define all(v) v.begin(),v.end()
const int INF = 1<<30;
typedef long long ll;
typedef pair<int,int> pii;

int const MOD = 1e9+7;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	int x;
	cin >> x;
	if(x) cout << 0;
	else cout << 1;
	return 0;	
}

Measured memory_bytes: 3648