akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	int N; //個数
	cin >> N; 

	vector<int> vec(N);
	for (int i; i < N; i++) {
		int a; //番号
		cin >> a;

		vec.at(i) = (a - 1); //番号 -1
	}

	N = 0;

	for (int i; i < 100000;i++) {
		if (vec.at(N) == 1) {
			cout << i + 1 << endl;
			break;
		}
		if (vec.at(N) == 0 || i == 99999 ) {
			cout << -1 << endl;
			break;
		}
		N = vec.at(N);
	}
	
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;

    if (A == B) {
        cout << C << endl;
    } else if (A == C) {
        cout << B << endl;
    } else { // (B == C)
        cout << A << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val result = solve(Scanner(System.`in`))
    if (result.isNotEmpty()) println(result)
}

fun solve(`in`: String) = solve(Scanner(`in`))


fun solve(sc: Scanner): String {
    val N = sc.nextInt()

    val result = mutableListOf<String>()
    fun f(n: Int, s: String) {
        if (n == N) {
            result.add(s)
            return
        }
        ('a'..(s.max()!! + 1)).forEach {
            f(n + 1, s + it)
        }
    }
    f(1, "a")

    return result.joinToString("\n")
}


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

#define fo(i, n) for(int i=0; i<n; i++)

int main() {

	int n, k, var;
	cin >> n >> k;

	long arr[n], temp[n], mi;
	fo(i, n) cin >> arr[i];

	fo(i, n) {
		var = i - 1;
		mi = INT_MAX;
		while (var >= 0 && var >= i - k) {
			mi = min(abs(arr[i] - arr[var]) + temp[var], mi);
			var--;
		}
		temp[i] = mi == INT_MAX ? 0 : mi;
	}
	
	cout << temp[n - 1];
	return 0;
}

Measured memory_bytes: 5152
#include<bits/stdc++.h>
using namespace std;
int
main (void)
{
    int n,k;
    cin>>n>>k;
    int i,a[n],b[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        b[i]=0;
    }
    while(k--)
    {
        int count=0;
        for(i=0;i<n;i++)
        {
            if(i-a[i]<0)
            b[0]++;
            else
            b[i-a[i]]++;
            if(i+a[i]+1<n)
            b[i+a[i]+1]--;
        }
        for(i=1;i<n;i++)
        b[i]+=b[i-1];
        for(i=0;i<n;i++)
        {
            a[i]=b[i];
            b[i]=0;
            if(a[i]==n)
            count++;
        }
        if(count==n)
        break;
    }
    for(i=0;i<n;i++)
    cout<<a[i]<<" ";
}

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


int main()
{
	//freopen("in.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll c=0;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
       if(s[i]!=t[i])
       	c++;
    }	
    cout<<c<<endl;
	return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

int main() {
  int n;
  cin >> n;
  V<ll> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end());
  V<ll> s(n);
  s[0] = a[0];
  for (int i = 1; i < n; i++) s[i] = s[i - 1] + a[i];

  auto can_live = [&](int k) {
    bool ret = true;
    ll size = s[k];
    for (int i = k + 1; i < n; i++) {
      if (a[i] <= 2 * size) {
        size += a[i];
      } else {
        ret = false;
        break;
      }
    }
    return ret;
  };

  int l(0), r(n - 1);
  while (l + 1 < r) {
    int m = (l + r) / 2;
    if (can_live(m)) {
      r = m;
    } else {
      l = m + 1;
    }
  }
  int ans = n - l - 1;
  if (can_live(l)) ans++;
  cout << ans << endl;
}


Measured memory_bytes: 4788
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include<queue>
#include<set>
#include<climits>
using namespace std;

int main()
{
  int a, b, result = 0;

  cin >> a >> b;

  if (a <= b)
    result++;

  result += a - 1;

  cout << result << endl;
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nx = readln.split.to!(long[]);
    auto N = nx[0];
    auto X = nx[1];

    long[51] as, ps;
    as[0] = 1;
    ps[0] = 1;
    foreach (i; 1..51) {
        as[i] = as[i-1] * 2 + 3;
        ps[i] = ps[i-1] * 2 + 1;
    }

    long r;
    while (X > 0 && N >= 0) {
        if (N == 0) {
            r += 1;
            break;
        }
        if (X >= as[N]/2+1) {
            r += ps[N-1] + 1;
            X -= as[N-1] + 2;
        } else {
            X -= 1;
        }
        --N;
    }
    writeln(r);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const string D_blue    = "\x1b[36m";
const string D_green   = "\x1b[32m";
const string D_red     = "\x1b[31m";
const string D_yellow  = "\x1b[33m";
const string Db_red    = "\x1b[41m";
const string Db_yellow = "\x1b[43m";
const string D_end     = "\x1b[39m";
const string Db_end    = "\x1b[49m";

int main (){
  int A,B,X;
  while (cin >> A >> B >> X){
    if(X - A > B || X - A < 0)cout << "NO" << endl;
    else cout << "YES" << endl;
    
  }
  return 0;
}


Measured memory_bytes: 256
#template
def inputlist(): return [int(j) for j in input().split()]
from collections import Counter
#template
#issueから始める
A,B,C,D = inputlist()
from fractions import gcd
def lcm(x,y):
    return (x*y)//gcd(x,y)
cd = lcm(C,D)
de = B-A+1
dec = (B//C)-((A-1)//C)
ded = (B//D)-((A-1)//D)
decd = (B//cd)-((A-1)//cd)
print(de-dec-ded+decd)

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

using namespace std;

typedef long long ll;

const ll ts = 100005;

#define IOS  ios::sync_with_stdio(0); cin.tie(0);
#define endl "\n"
ll a[ts * 2];
signed main() {

    IOS;
    ll n , sum =  0 , k ; cin >> n >> k ; 
    for(ll i = 1; i <= n ; i++) cin >> a[i];
    sort(a  + 1 , a + n + 1);
    for(ll i = 1; i <= n - k;i++ ) sum += a[i];
    cout << sum ; 
 }


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

int main() 
{
    int l;
    float s,vol;
    scanf("%d",&l);
    s=l/3.0 ;
   // printf("%lf",s);
    //vol= pow(,3);
    vol= s*s*s;
    printf("%lf",vol);
    
}


Measured memory_bytes: 128
package main

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

func main() {
	r := bufio.NewReader(os.Stdin)
	w := bufio.NewWriter(os.Stdout)
	defer w.Flush()

	var s string
	fmt.Fscan(r, &s)

	var result string
	for _, a := range s {
		switch a {
		case '0':
			result += "0"
		case '1':
			result += "1"
		case 'B':
			if len(result) != 0 {
				result = result[:len(result)-1]
			}
		}
	}

	fmt.Fprintln(w, result)
}


Measured memory_bytes: 1844
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <sstream>
#include <stack>
#include <queue>
#include <list>
#include <stdio.h>
#include <algorithm>
#define MAX 1400
#define INF 100000000
using namespace std;
typedef long long ll;
int g[MAX+1][MAX+1],dp[MAX+1][MAX+1];
int main()
{	
	int h,w,max_width=0;
	cin>>h>>w;
	for(int i=0;i<h;i++)
	{
		for(int j=0;j<w;j++)
		{
			scanf("%d",&g[i][j]);
		}
	} 
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			dp[i][j]=(g[i][j]+1)%2;
			max_width|=dp[i][j];
		}
	}//初始化,每一个没被污染的点至少都能画出的宽度都是1 
	for(int i=1;i<h;i++)
	{
		for(int j=1;j<w;j++)
		{
			if(dp[i][j]==0) continue;
			dp[i][j]=min(dp[i-1][j-1],min(dp[i-1][j],dp[i][j-1]))+1;
			max_width=max(dp[i][j],max_width);
		}
	}
	cout<<max_width*max_width<<endl;
}


Measured memory_bytes: 18468
from sys import stdin
s = stdin.readline().rstrip()
K = int(stdin.readline().rstrip())
ans = list(s)

for i in range(2,K+1):
    for j in range(0,len(s)-i+1):
        ans.append(s[j:j + i])

ans = sorted(set(ans))
print(ans[K-1])

Measured memory_bytes: 5068
#include <stdio.h>

int n,A[50];

int solve(int i,int m){
  int r;
  if(m==0)return 1;
  if(i>=n)return 0;
  r=solve(i+1,m)||solve(i+1,m-A[i]);
  return r;
}

int main(){
  int q,m,i;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&m);
    if(solve(0,m))printf("yes\n");
    else printf("no\n");
  }
  return 0;
}



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

int main(){
  int A,B,tot=0;
  cin >> A >> B;
  
  vector <int> C(B);
  rep(i,B){
    cin >> C.at(i);
  tot+=C.at(i);
  }

  if(tot>A)
    cout <<"-1" <<endl;
  else
    cout << A-tot << endl;

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pair<ll,ll>>
#define vvll vector<vector<ll>>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
using namespace std;
bool fl=		0				;
bool mtest=		0			;

//

//

void solve()
{
	ld r;	cin>>r;
	cout<<2*3.14159*r<<endl;
}


int main()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		if(fl)
		{
			freopen("input.txt", "r", stdin);
			freopen("output.txt", "w", stdout);
		}
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


Measured memory_bytes: 3792
# ??????????????????
def bubble_sort(ary, len)
  swp = 0
  (0...len-1).each {|n|
    (0...len-1-n).each{|j|
      if ary[j+1] < ary[j]
        ary[j], ary[j+1] = ary[j+1], ary[j] # swap????????????
        swp += 1
      end
    }
  }
  return ary, swp
end

# main
len = gets.to_i
ary = gets.split(' ').map(&:to_i) # ????§????????????????????????§???????????°?????????
sorted_ary, swp = bubble_sort(ary, len)
puts sorted_ary.join(' ') # ????§????????????????????????§??????
puts swp

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF =1000000000000000;

ll n,w;

ll weight[110]={},value[110]={};

ll dp[110][100010];

int main(){
  cin >> n >> w;
  
  REP(i,w+1){
    dp[0][i] = 0;
  }
  
  REP(i,n){
    cin >> weight[i];   
    cin >> value[i];
  }
  
  REP(i,n){
    REP(j,w+1){
      
      if(j >= weight[i]){
        dp[i+1][j] = max(dp[i][j-weight[i]] + value[i],dp[i][j]);
      }
      else{
        dp[i+1][j]=dp[i][j];
      }
      
    }
  }
  
  cout << dp[n][w] << endl;
}


Measured memory_bytes: 80128
import java.util.*;

public class Main {
	  public static void main(String args[]){
      	Scanner scan = new Scanner(System.in);
            
        int a = scan.nextInt();
        int b = scan.nextInt();
        int c = scan.nextInt();
        int cnt = 0;
        
        if( a == b && a == c )cnt = 1;
        
        else if( a == b || a == c || b == c)cnt = 2;
        
        else cnt = 3;
            
        System.out.println(cnt);
	  }
}

Measured memory_bytes: 21844
#include<iostream>

using namespace std;

int N, M, P;

int main(){
	while(cin >> N >> M >> P, N){
		int sum = 0;
		int sum_m = 0;
		for(int n=1;n<=N;n++){
			int tmp;
			cin >> tmp;
			sum += tmp;
			if(n == M) sum_m = tmp;
		}
		if(sum_m == 0)
			cout << 0 << endl;
		else
			cout << ((sum*100)-(sum*P))/sum_m << endl;
	}
	

	return 0;
}

Measured memory_bytes: 3036
#include <stdio.h>

int main(void) {
	int aone,bone;
	int asum,bsum;
	int i;
	asum=bsum=0;
	for(i=0;i<4;i++) {
		scanf("%d",&aone);
		asum+=aone;
	}
	for(i=0;i<4;i++) {
		scanf("%d",&bone);
		bsum+=bone;
	}
	printf("%d\n",asum>bsum?asum:bsum);
	return 0;
}

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

int main() {
  int A,B,a,b,c,d,e,t,s = 0;
  cin >> A >> B;
  for(int i = A; i <= B; i++){
  	a = i % 10;
    t = i / 10;
    b = t % 10;
    t = t / 10;
    c = t % 10;
    t = t / 10;
    d = t % 10;
    t = t / 10;
    e = t % 10;
    if(a == e && b == d){
      s++;
    }
  }
  cout << s << endl;
}

Measured memory_bytes: 384
a,b,k = map(int,input().split())
if a<k:
  k-=a
  a=0
else:
  a-=k
  k=0
if k>0:
  if b<k:
    k-=b
    b=0
  else:
    b-=k
    k=0
print(a,b)

Measured memory_bytes: 2940
#include<stdio.h>
int main(){
    char a[1500];
    int n=0;
    while(1){
        scanf("%c", &a[n]);
        if(a[n]=='\n') break;
        n++;
    }
    int i=0;
    
    while(a[i]){
        if(a[i]=='\n') break;
        if(a[i]>='a'&&a[i]<='z'){
            a[i]=a[i]-32;
        }
        else if(a[i]>='A'&& a[i]<='Z'){
            a[i]=a[i]+32;
        }
        i++;
    }
    printf("%s",a);
    
    return 0;
}


Measured memory_bytes: 2108
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
using namespace std;
#define DEBUG(x) cout<<#x<<"="<<x<<endl
#define DEBUG2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<endl
typedef long long ll;
// #define LOCAL
class Solver{
public:
    int X,Y,A,B,C;
    vector<ll>a,b,c;
    void solve(){
        ios::sync_with_stdio(false);
        cin.tie(0);
        cin>>X>>Y>>A>>B>>C;
        for(int u=0;u<A;u++){
            ll t;
            cin>>t;
            a.push_back(t);
        }
        for(int u=0;u<B;u++){
            ll t;
            cin>>t;
            b.push_back(t);
        }
        sort(a.begin(),a.end(),greater<ll>());
        sort(b.begin(),b.end(),greater<ll>());
        for(int u=0;u<X;u++)c.push_back(a[u]);
        for(int u=0;u<Y;u++)c.push_back(b[u]);
        for(int u=0;u<C;u++){
            ll t;
            cin>>t;
            c.push_back(t);
        }
        sort(c.begin(),c.end(),greater<ll>());
        for(int u=1;u<(X+Y);u++){
            c[u]+=c[u-1];
        }
        cout<<c[X+Y-1];
    }
};
int main()
{
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif
    (new Solver())->solve();
}

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

using namespace std;

int main()
{
	int H, W;
	string s;
	scanf("%d %d", &H, &W);
	
	vector<string> v;
	
	for(int i = 0; i < H; i++)
	{
		cin >> s;
		v.push_back(s);
	}
	
	for(int i = 0; i < v.size(); i++)
		for(int j = 0; j < 2; j++)
			cout <<v[i] << "\n";
	
	return 0;
}

Measured memory_bytes: 256
sx,sy,tx,ty=map(int,input().split())
dx=tx-sx
dy=ty-sy
r1="R"*dx+"U"*dy
r2="L"*dx+"D"*dy
r3="D"+"R"*(dx+1)+"U"*(dy+1)+"L"
r4="U"+"L"*(dx+1)+"D"*(dy+1)+"R"
print(r1+r2+r3+r4)


Measured memory_bytes: 3060
def main():
    n, s = map(int, input().split())
    a = list(map(int, input().split()))
    mod = 998244353
    dp = [[0]*(s+1) for _ in range(n+1)]
    dp[0][0] = 1
    for i in range(1, n+1):
        ai = a[i-1]
        for j in range(s+1):
            dp[i][j] += dp[i-1][j]*2
            if j >= ai:
                dp[i][j] += dp[i-1][j-ai]
            dp[i][j] %= mod
    print(dp[n][s])
        

if __name__ == "__main__":
    main()

Measured memory_bytes: 135392
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    ll a, b, k;
    cin >> a >> b >> k;
    if(a+b <= k) cout << 0 << " " << 0 << endl;
    else if(a >= k) cout << a - k << " " << b << endl;
    else{
        k -= a;
        a = 0;
        b -= k;
        cout << a << " " << b << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3680
#include <iostream>

using namespace std;

int main(){
  	int h1,m1,h2,m2,k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;
  int totalspare = (h2-h1)*60 + (m2 - m1);
  cout << totalspare - k;
	return 0;
}

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};


void solve(long long A, long long B){
	if (A != 1 && B != 1) cout << 1 << endl;
	else if (A != 2 && B != 2 ) cout << 2 << endl;
	else cout << 3 << endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


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

const int SIZE = 101;
char result[SIZE][SIZE];

int main() {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= SIZE / 2; i++) {
        for (int j = 1; j < SIZE; j++) {
            result[i][j] = '.';
        }
    }
    for (int i = 51; i < SIZE; i++) {
        for (int j = 1; j < SIZE; j++) {
            result[i][j] = '#';
        }
    }
    for (int i = 1; i <= m - 1; i++) {
        int r = i / 98 * 4, c = i % 98;
        if (c == 0) {
            c += 98;
            r -= 4;
        }
        if (c % 2 == 0) {
            r += 2;
        } else {
            r += 3;
        }
        result[r][c + 1] = '#';
    }
    for (int i = 1; i <= n - 1; i++) {
        int r = i / 98 * 4, c = i % 98;
        if (c == 0) {
            c += 98;
            r -= 4;
        }
        if (c % 2 == 0) {
            r += 2;
        } else {
            r += 3;
        }
        result[SIZE - r][c + 1] = '.';
    }
    cout << SIZE - 1 << ' ' << SIZE - 1 << '\n';
    for (int i = 1; i < SIZE; i++) {
        for (int j = 1; j < SIZE; j++) {
            cout << result[i][j];
        }
        cout << '\n';
    }
    return 0;
}

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

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define RREP(i,a) for(int i = a;i >= 0;i--)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))
#define xyrange(x, minX, maxX, y, minY, maxY) (range(x, minX, maxX) && range(y, minY, maxY))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;
typedef vector<PII> VPII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};
const int INF = 0x3f3f3f3f;

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	VI abc(3);
	cin >> abc[0] >> abc[1] >> abc[2];
	sort(all(abc));
	cout << abc[0] + abc[1] << endl; 
	return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class CVacation {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int n = in.nextInt();
            long[] dp = new long[3];
            for (int i = 0; i < n; i++) {
                long[] temp = new long[3];
                for (int j = 0; j < 3; j++)
                    temp[j] = in.nextInt();
                temp[0] += Math.max(dp[1], dp[2]);
                temp[1] += Math.max(dp[0], dp[2]);
                temp[2] += Math.max(dp[0], dp[1]);
                dp = temp;
            }
            out.println(Math.max(Math.max(dp[0], dp[1]), dp[2]));
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void close() {
            writer.close();
        }

        public void println(long i) {
            writer.println(i);
        }

    }

    static class InputReader {
        BufferedReader br;
        StringTokenizer st;

        public InputReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        public InputReader(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }

        public String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

    }
}



Measured memory_bytes: 46452
use proconio::{input, fastout};

#[fastout]
fn main() {
  input!{a: f64, b: f64, h: f64, m: f64};
  let theta = (((30.0*h-5.5*m).abs()).min(360.0-(30.0*h-5.5*m).abs())).to_radians();
  println!("{}", (a*a+b*b-2.0*a*b*theta.cos()).sqrt());
}

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

int main() {
  string s;
  cin >> s;
  int n=s.size();
  string str1(n,'0');
  string str2(n,'1');
  for(int i=0; i<n; i++){
    if(i%2 == 1){
    str1.replace(i,1,"1");
    str2.replace(i,1,"0");
    }
  }
  int count1 = 0;
  int count2 = 0;
  rep(i,n){
    if(s.at(i) != str1.at(i)){
      count1++;
    }
    if(s.at(i) != str2.at(i)){
      count2++;
    }
  }
  cout << min(count1,count2) <<endl;
  
}

Measured memory_bytes: 512
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int a, b;
	cin >> a >> b;
	int answer = 0;
	for(; a <= b; ++a)
	{
		string number = to_string(a);
		answer += equal(number.begin(), number.begin() + number.size() / 2, number.rbegin());
	}
	cout << answer << '\n';
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
const ll INF = 9223372036854775807;

int main() {
  int x,n;cin >> x >> n;
  if(n != 0) {
  vector<int>vec(n);
  rep(i,n) cin >> vec[i];
  sort(vec.begin(),vec.end());
  int s = 0;
  int Ans;
  int mina = 1000;
  for(int i = 0;i < 350;i++){
    if(i == vec[s]) {
      s++;
      continue;
    }
    if(abs(x -i)<mina) Ans = i;
    mina = abs(x-i); 
  }
  cout << Ans << endl;
  }
  else cout << x << endl;
}
    

Measured memory_bytes: 3628
#include <cstdio>

using namespace std;

int dp[31];

int main()
{
	dp[0] = 1;

	for (int i = 1; i <= 30; ++i) {
		for (int j = 1; j <= 3; ++j) {
			if (i-j >= 0) dp[i] += dp[i - j];
		}
	}

	int n;

	while (scanf("%d", &n), n) {
		printf("%d\n", (dp[n] + 3649) / 3650);
	}
}

Measured memory_bytes: 1028
from math import atan,pi
a,b,x=map(int,input().split())
if a*a*b>2*x:
  h=2*x/(a*b)
  print(90-atan(h/b)*180/pi)
else:
  h=2*(a*a*b-x)/(a*a)
  print(atan(h/a)*180/pi)

Measured memory_bytes: 61772
N,M = map(int,input().split())
*A, = map(int,input().split())
B = sorted((([2,5,5,4,5,6,3,7,6][a-1],a) for a in A),key = lambda x:(x[0],-x[1]))
i = 1
while i<len(B):
    if B[i][0]==B[i-1][0]:
        B.pop(i)
    else:
        i+=1
i = [0]*(len(B)-1)
if len(B)==1:
    print(str(B[0][1])*(N//B[0][0]))
    exit()
ans = []
while i[-1]<B[0][0]:
    tmp = N - sum(j*b[0] for j,b in zip(i,B[1:]))
    if tmp>=0 and tmp%B[0][0] == 0:
        num = ""
        for k,n in sorted(zip([b for _,b in B],[tmp//B[0][0]]+i),key = lambda x:-x[0]):
            num += str(k)*n
        ans.append(int(num))
    i[0]+=1
    for j in range(len(i)-1):
        if i[j]==B[0][0]:
            i[j+1]+=1
            i[j]=0
print(max(ans))

Measured memory_bytes: 3188
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int N = sc.nextInt();
		String A = sc.next();
		String B = sc.next();
		String C = sc.next();

		int count=0;
		for(int i=0;i<N;i++) {
			char a = A.charAt(i);
			char b = B.charAt(i);
			char c = C.charAt(i);
			if(a==b && a==c) {
				//nothing
			}else if(a==b || b ==c || a==c) {
				count++;
			}else {
				count++;
				count++;
			}
		}
		System.out.println(count);
	
	
	}
}


Measured memory_bytes: 20820
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Deque;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        List<List<Integer>> graph = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            graph.add(new ArrayList<>());
        }

        for (int i = 0; i < m; i++) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            a--;
            b--;
            graph.get(a).add(b);
            graph.get(b).add(a);
        }

        int[] dist = new int[n];
        int[] ans = new int[n];
        Arrays.fill(dist, -1);

        Deque<Integer> q = new ArrayDeque<>();
        q.add(0);
        dist[0] = 0;
 
        while (!q.isEmpty()) {
            int i = q.poll();

            for (int j = 0; j < graph.get(i).size(); j++) {
                int v = graph.get(i).get(j);

                if (dist[v] < 0) {
                    dist[v] = dist[i] + 1;
                    ans[v]  = i;
                    q.add(v);
                }
            }                
        }
        System.out.println("Yes");

        for (int i = 1; i < n; i++) {
            System.out.println(ans[i]+1);
        }
    }
}

Measured memory_bytes: 67272
nums = input().split()
W = int( nums[0])
H = int( nums[1])
x = int( nums[2])
y = int( nums[3])
r = int( nums[4])
 
if (x - r) >= 0 and (x + r) <= W:
    if (y - r) >= 0 and (y + r) <= H:
        print( "Yes")
    else:
        print( "No")
else:
    print( "No")

Measured memory_bytes: 6724
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define ll long long int

bool comp(pair<ll,ll> l,pair<ll,ll> r){
    if(l.second < r.second) return 1;
    return 0;
}

const int MAX = 1e6 + 10;

int main()
{	
	ll n; cin>>n;
	pair<ll,ll> p[MAX];

	for(int i=0;i<n;i++){
		cin>>p[i].first>>p[i].second;
	}

	sort(p,p+n,comp);

	ll cum=0; bool ok=true;
	for(int i=0;i<n;i++){
		cum += p[i].first;
		if(cum <= p[i].second){
			continue;
		}
		else{
			ok=false;
			break;
		}
	}

	if(ok) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 15872
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

int main(){
	int n,m;
    cin >> n >> m;
    int s[3];
    int c[9];
    map<int ,int>q;
    bool j = true;

    /*error*/
    for(int i = 0; i < m; i++){
    	int t;
    	cin >> s[i] >> t;
    	if((q[s[i]-1] == 0) || (q[s[i]-1] == t)){
    		q[s[i]-1] = t;
    		c[i] = t;
    	}
    	else{
    		if(q[s[i]-1] != t) {
    			j = false;
    		}
    	}
    }
    if(n > 1){
    	for(int i = 0; i<m ; i++){
			if((s[i] == 1) && (c[i] == 0)) j = false;
    	}
    }
    if(j == false){
		cout << "-1" << endl;
		return 0;
    }

    int ans_a[3]={1,0,0};
    int ans = 0;
	if(n==1) ans_a[0] = 0;

	for(int i = 0; i<m; i++){
		ans_a[s[i]-1] = c[i];
	}

    if(n == 3){
    	ans = ans_a[0]*100 + ans_a[1]*10 + ans_a[2];
    }
    else if(n == 2){
    	ans = ans_a[0]*10 + ans_a[1];
    }
    else if(n == 1){
    	ans = ans_a[0];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def actual(N, M, AB):
    payment = 0

    shop_order_by_price_desc = sorted(AB, key=lambda x: x[0])

    for price, stock in shop_order_by_price_desc:
        if stock >= M:
            # 端数があるときは、残りの必要分だけ買えばよい
            return payment + (price * M)
        else:
            # 端数がないなら買い切る
            M -= stock
            payment += price * stock


N, M = map(int, input().split())
AB = []
for _ in range(N):
    a, b = map(int, input().split())
    AB.append([a, b])

print(actual(N, M, AB))


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

int main(){
  string str;
  cin >> str;
  if(str == "Sunny"){
    cout << "Cloudy" << endl;
    return 0;
  }
  else if(str == "Cloudy"){
    cout << "Rainy" << endl;
    return 0;
  }
  else if(str == "Rainy"){
    cout << "Sunny" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int read( ){
	int x=0,y=1;char ch=' ';
	for(;(ch!='-' && (ch>'9' || ch<'0'));ch=getchar( ));
	if(ch=='-')y=-1,ch=getchar( );
	for(;ch>='0' && ch<='9';ch=getchar( ))x=x*10+ch-48;
	return x*y;
}
const int N=1e5+10;
int n,m,ans;
int a[N];
priority_queue<int>q;
signed main( ){
	int x,y,z,k;
	n=read( );m=read( );
	for(register int i=1;i<=n;++i){
		x=read( );q.push(x);
	}
	for(register int i=1;i<=m;++i){
		x=q.top( );q.pop( );
		q.push(x/2);
	}
	
	while(q.size( )){
		ans+=q.top( );q.pop( );
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1400
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>
#define MOD 924844033LL
using namespace std;
typedef long long ll;

int n,k;

int main(void){
	scanf("%d%d",&n,&k);
	vector<int> cnt(n+1,0);
	cnt[0]=1;
	for(int i=0;i<2*k;i++){
		vector<vector<int> > dp(2,vector<int>(n+1,0));
		if(i<k){
			dp[0]=cnt;
		}else{
			dp[1]=cnt;
		}
		for(int j=i;j<n;j+=2*k){
			vector<vector<int> > nextDp(2,vector<int>(n+1,0));
			for(int a=0;a<2;a++){
				for(int b=0;b<n;b++){
					if(a==1){
						nextDp[1][b+1]+=dp[a][b];
						nextDp[1][b+1]%=MOD;
					}
					if(j+k<n){
						nextDp[0][b+1]+=dp[a][b];
						nextDp[0][b+1]%=MOD;
					}
					nextDp[1][b]+=dp[a][b];
					nextDp[1][b]%=MOD;
				}
			}
			dp.swap(nextDp);
		}
		for(int b=0;b<=n;b++){
			cnt[b]=(dp[0][b]+dp[1][b])%MOD;
		}
	}
	ll tmp=1;
	ll ans=0;

	for(int i=0;i<=n;i++){
		if((n-i)%2==0){
			ans+=tmp*cnt[n-i];
		}else{
			ans-=tmp*cnt[n-i];
		}
		ans%=MOD;
		ans+=MOD;
		ans%=MOD;
		tmp*=i+1;
		tmp%=MOD;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

ans = 0
for i in range(N-1, -1, -1):
    if B[i] >= A[i+1]:
        B[i] -= A[i+1]
        ans += A[i+1]
        A[i+1] = 0
        if B[i] >= A[i]:
            ans += A[i]
            A[i] = 0
        else:
            ans += B[i]
            A[i] -= B[i]
    else:
        ans += B[i]
print(ans)

Measured memory_bytes: 23916
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T,class U> using P = pair<T,U>;
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
 

int main(){
    int N;
    cin >> N;
    int a[N];
    int current_looking = 1;
    int prev_idx = -1;
    int ans = 0;
    for (int i=0; i<N; i++){
        cin >> a[i];
        if (a[i] == current_looking){
            current_looking++;
            ans += i - prev_idx - 1;
            prev_idx = i;
        }
    }
    ans += N - 1 - prev_idx;
    if (current_looking == 1) {
        cout << -1 << endl;
    } else {
        cout << ans << endl;
    }

}

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

const long double PI = 3.14159265358979323846264338327;

int main() {
    
    long double a, b, h, m, x, y, ans;
    cin >> a >> b >> h >> m;

    x = (a*sin(h*PI/6 + m*PI/360) - b*sin(m*PI/30));
    y = (a*cos(h*PI/6 + m*PI/360) - b*cos(m*PI/30));

    ans = sqrt(x*x + y*y);

    cout << setprecision(15) << ans << endl;
    
    return 0;
}



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

#define F first
#define S second
#define PB push_back

using namespace std;

typedef long long ll;

int n;
ll h[100005];
ll memo[100005];

ll dp(int i){
	if(i == n-1)	return 0;
	if(i >= n)	return 10000000000;
	if(memo[i] != -1){
		return memo[i];
	}
	return memo[i] = min(abs(h[i] - h[i+1]) + dp(i+1), abs(h[i] - h[i+2]) + dp(i+2));
}

int main(){

    memset(memo, -1, sizeof(memo));
	
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

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

	cout << dp(0) << "\n";

	return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstdio>
using namespace std;

int main() {
    int x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<long long> A(x);
    vector<long long> B(y);
    vector<long long> C(z);
    for(int i = 0; i < x; i++) {
        cin >> A[i];
    }
    for(int i = 0; i < y; i++) {
        cin >> B[i];
    }
    for(int i = 0; i < z; i++) {
        cin >> C[i];
    }
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    reverse(A.begin(), A.end());
    reverse(B.begin(), B.end());
    vector<long long>AB(x * y);
    for(int i = 0; i < x; i++) {
        for(int j = 0; j < y; j++) {
            AB[i*y + j] = A[i] + B[j];
        }
    }
    sort(AB.begin(), AB.end());
    reverse(AB.begin(), AB.end());
    int s = min(k, x * y);
    vector<long long>ABC(s*z);
    for(int i = 0; i < s; i++) {
        for(int j = 0; j < z; j++) {
            ABC[i*z+j] = AB[i] + C[j];
        }
    }
    sort(ABC.begin(), ABC.end());
    reverse(ABC.begin(), ABC.end());
    for(int i = 0; i < k; i++) {
        cout << ABC[i] << endl;
    }
}



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

Bridges = []
for i in range(M):
    a,b = map(int, input().split())
    Bridges.append([a-1,b-1])

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)


rest = N*(N-1)/2
rest_list = [rest]
Bridges.reverse()
uf = UnionFind(N)
for i in Bridges:
    if uf.same(i[0], i[1]):
        rest_list.append(rest)
    else:
        first = uf.size(i[0])
        second = uf.size(i[1])
        rest += first*(first-1)/2 + second*(second-1)/2
        rest -= (first+second)*(first+second-1)/2
        rest_list.append(rest)
    uf.union(i[0],i[1])
    
rest_list.reverse()
for i in rest_list[1:]:
    print(int(i))



Measured memory_bytes: 25696
#!python3

iim = lambda: map(int, input().rstrip().split())


def resolve():
    N, K = iim()
    mod = 10**9 + 7

    dp = [[0]*(K+1) for i in range(N+1)]
    dp[0][0] = 1
    for i in range(1, N+1):
        dd = dp[i]
        for k in range(1, K+1):
            dp[i][k] = dp[i-1][k-1] + k * dp[i-1][k]
            dp[i][k] %= mod

    #print(dp)

    print(sum(dp[N]) % mod)

if __name__ == "__main__":
    resolve()



Measured memory_bytes: 29156
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>

using namespace std;

int main(){
  int n, k;
  cin >> n >> k;
  int r, s, p;
  cin >> r >> s >> p;
  string t;
  cin >> t;
  vector<int> f = {r, s, p};
  vector<int> te(t.length());
  for(int i = 0; i < n; i++){
    if(t[i] == 'r') te[i] = 2;
    else if(t[i] == 's') te[i] = 0;
    else te[i] = 1;
  }

  vector<int> tst(n, 0);
  vector<vector<int> > flag(n, vector<int>(3, 1));
  for(int i = 0; i < n; i++){
    if(i == 0) tst[i] = f[te[i]];
    else{
      tst[i] = tst[i-1] + (f[te[i]]) * (flag[i][te[i]]);
    }
    if(i+k < n)flag[i+k][te[i]] = (flag[i][te[i]]+1)%2;
  }
  cout << tst[n-1] << endl;
}


Measured memory_bytes: 6656
S = input()

check1 = ["R","U","D"]
check2 = ["L","U","D"]

check1_ = []
check2_ = []

for s in S[::2]:
  if s in check1:
    check1_.append(True)
  else:
    check1_.append(False)

for s in S[1::2]:
  if s in check2:
    check2_.append(True)
  else:
    check2_.append(False)

if all(check1_) and all(check2_):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 #include<stack>
 #include<queue>
 
 using namespace std;
 
 int main()
 {
   double n;
   while(cin>>n)
   {
     double kk=n;
     if(kk>91)
     {
            cout<<"heavy"<<endl;
     }  
     else if(kk>81&&kk<=91)
     {
            cout<<"light heavy"<<endl;
     }
     else if(kk>75&&kk<=81)
     {
            cout<<"middle"<<endl;
     } 
     else if(kk>69&&kk<=75)
     {
            cout<<"light middle"<<endl;
     }
     else if(kk>64&&kk<=69)
     {
            cout<<"welter"<<endl;
     } 
     else if(kk>60&&kk<=64)
     {
            cout<<"light welter"<<endl;
     } 
     else if(kk>57&&kk<=60)
     {
            cout<<"light"<<endl;
     } 
     else if(kk>54&&kk<=57)
     {
            cout<<"feather"<<endl;
     } 
     else if(kk>51&&kk<=54)
     {
            cout<<"bantam"<<endl;
     } 
     else if(kk>48&&kk<=51)
     {
            cout<<"fly"<<endl;
     } 
     else
     {
            cout<<"light fly"<<endl;       
     }             
   }
   //while(1);
   return 0;
 }

Measured memory_bytes: 3044
import java.util.*;

public class Main{
  public static void main(String[] args){

    Scanner scan = new Scanner(System.in);
    int x = scan.nextInt();
    int n = scan.nextInt();
    if (n == 0){
      System.out.println(x);
      return;
    }
    int [] a = new int[103];

    for (int i=0;i<103;i++){
      a[i] = i-1;
    }

    for (int j=0;j<n;j++){
      int t = scan.nextInt();
      a[t+1] = -2;
    }

    if (a[x+1] != -2){
      System.out.println(x);
      return;
    }

    int small = 104;
    int val = -3;
    for (int p=0;p<103;p++){
      if (a[p] == -2){
        continue;
      }
      int abs = x-a[p];
      if (abs == 0){
        System.out.println(x);
        return;
      }

      if (abs < 0){
        abs = -abs;
      }
      if (abs < small){
        small = abs;
        val = a[p];
      }
    }

    System.out.println(val);
  }
}


Measured memory_bytes: 36016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;

int main() {
  ll n;
  cin >> n;
  ll ans=0;
  for(ll i=1;i<=n;i+=2) {
    ll count=0;
    for(ll j=1;j<i;j++) {
      if(i%j==0) {
        count++;
      }
    }
    if(count==7) {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
{-# LANGUAGE FlexibleContexts #-}

import Control.Monad
import Control.Monad.Primitive
import Control.Monad.ST
import qualified Data.ByteString.Char8 as C
import Data.Char
import qualified Data.Set as S
import Data.Ix
import Data.List
import Data.Maybe
import Data.STRef
import Data.Vector.Generic ((!))
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM

main = sol <$> get <*> get <*> getT >>= print

get = unfoldr (C.readInt . C.dropWhile (<'0')) <$> C.getLine

getT = U.unfoldr C.uncons . C.filter (not . isSpace) <$> C.getContents

sol [h,w,k] [x1,y1,x2,y2] tbl = fromMaybe (-1) $ runST $ do
  let
    p1 = (x1,y1)
    p2 = (x2,y2)
    loop i t s = do
      skin <- readSTRef s
      if S.null skin
        then return Nothing
        else if p2 `S.member` skin
          then return $ Just i
          else do
            let ps = S.toList skin
            mapM_ (flip (UM.unsafeWrite t) 'X' . ix) ps
            foldM (unt t) S.empty ps >>= writeSTRef s
            loop (i+1) t s
    nbr t (x,y) = fmap (S.fromList . foldr1 (++)) 
      $ mapM (takeWhileM (ok t) . takeWhile ir) [
      [(x+j,y) | j <- [1..k]],[(x-j,y) | j <- [1..k]],
      [(x,y+j) | j <- [1..k]],[(x,y-j) | j <- [1..k]]]
    unt t b = liftM (S.union b) . nbr t
    ok t p = fmap (=='.') $ UM.unsafeRead t (ix p)
    ir (x,y) = inRange (1,h) x && inRange (1,w) y
    ix (r,c) = (r-1)*w+c-1
  t <- U.unsafeThaw tbl
  s <- newSTRef (S.singleton p1)
  loop (0 :: Int) t s

-- from Contol.Monad.ListM (monadlist-0.0.2)
takeWhileM :: (Monad m, MonadPlus p) => (a -> m Bool) -> [a] -> m (p a)
takeWhileM _ [] = return mzero
takeWhileM p (x:xs) = do
  bool <- p x
  if bool
    then liftM (consM x) $ takeWhileM p xs
    else return mzero

consM :: (MonadPlus p) => a -> p a -> p a
consM x y = return x `mplus` y

Measured memory_bytes: 52924
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int sx = sc.nextInt();
		int sy = sc.nextInt();
		int tx = sc.nextInt();
		int ty = sc.nextInt();

		StringBuilder sb = new StringBuilder();

		// forth
		for (int ny = sy; ny < ty; ny++) {
			sb.append("U");
		}
		for (int nx = sx; nx < tx; nx++) {
			sb.append("R");
		}

		// back
		for (int ny = ty; ny > sy; ny--) {
			sb.append("D");
		}
		for (int nx = tx; nx > sx; nx--) {
			sb.append("L");
		}

		// forth again
		sb.append("L");
		for (int ny = sy; ny < ty + 1; ny++) {
			sb.append("U");
		}
		for (int nx = sx - 1; nx < tx; nx++) {
			sb.append("R");
		}
		sb.append("D");

		// back again
		sb.append("R");
		for (int ny = ty; ny > sy - 1; ny--) {
			sb.append("D");
		}
		for (int nx = tx + 1; nx > sx; nx--) {
			sb.append("L");
		}
		sb.append("U");
		
		System.out.println(sb);
	}

}


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

int main()
{
    string s;
    cin>>s;
    if(s.at(0)!=s.at(1)&&s.at(1)!=s.at(2)&&s.at(0)!=s.at(2))cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
   int a,b,c;
   string s;
   cin >> a >> b >> c;
   if (a==b+c) cout << "Yes" << endl;
   else if (b==a+c) cout << "Yes" <<endl;
   else if (c==a+b) cout <<"Yes" <<endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
import networkx as nx

def main():
  N,M=map(int,input().split())
  S = [list(input()) for _ in range(N)]

  if N == M == 1:
    print(0)
    print(S[0][0])
    exit()

  index = lambda i,j: i*M+j

  G=nx.Graph()
  dx,dy=(1,0),(0,1)
  E = []
  n1,n2 = [],[]
  for i in range(N):
    for j in range(M):
      if S[i][j]=='#':continue
      if (i+j)%2:
        n1.append(index(i,j))
      else:
        n2.append(index(i,j))
      for k in range(2):
        v1,v2 = index(i,j),index(i+dx[k],j+dy[k])
        if not (0<=i+dx[k]<N and 0<=j+dy[k]<M):
          continue
        if S[i+dx[k]][j+dy[k]] == '#': continue
        if (i+j) % 2:
          E.append((v2,v1))
        else:
          E.append((v1,v2))
     
  G.add_nodes_from(n1, bipartite=0)
  G.add_nodes_from(n2, bipartite=1)
  G.add_edges_from(E)
  u = [n for n in G.nodes if G.nodes[n]['bipartite'] == 0]
  match = nx.bipartite.maximum_matching(G, top_nodes=u)
  match = {v:match[v] for v in match.keys() if v < match[v]}
 
  for v in match.keys():
    i1,j1 = divmod(v,M)
    i2,j2 = divmod(match[v],M)
    if i1 > i2 or j1 > j2:
      (i1,j1),(i2,j2) = (i2,j2),(i1,j1)
    if i1 < i2:
      S[i1][j1] = 'v'
      S[i2][j2] = '^'
    else:
      S[i1][j1] = '>'
      S[i2][j2] = '<'

  print(len(match))
  for i in range(N):
    print(''.join(S[i]))
    
if __name__ == "__main__":
  main()

Measured memory_bytes: 68160
function Main(input){

  var N = input.split('\n')[0];
  N = parseInt(N,10);


  A = input.split('\n')[1].split(' ');
  B = input.split('\n')[2].split(' ');

  var suma = 0;
  for(i=0;i<B.length;i++){
    A[i] = parseInt(A[i],10);
    B[i] = parseInt(B[i],10);
    suma += A[i];
  }
  A[N] = parseInt(A[N],10);
  suma += A[N];

  var C;
  for(i=0;i<N;i++){
    A[i] = A[i] - B[i];
    if(A[i]<0){
      A[i+1] = A[i+1] + A[i];
      if(A[i+1]<0){
        A[i+1] = 0;
      }
      if(A[i]<0){
        A[i] = 0;
      }
    }
  }
  var ans = 0;
  for(i=0;i<=N;i++){
    ans += A[i]; 
  }
  ans = suma -ans;
  console.log(ans);


}
  




Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 31064