akhauriyash/Code-Regression huggingface dataset:
// https://atcoder.jp/contests/abc142/tasks/abc142_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, t;
    cin >> n;
    vector<int> v(n);
    REP(i, n) {
        cin >> t;
        v[t - 1] = i + 1;
    }
    REP(i, n) { cout << v[i] << (i == n - 1 ? "\n" : " "); }

    return 0;
}


Measured memory_bytes: 1664
s = input()

if s == 'RRR':
    print('3')
if s == 'RRS':
    print('2')
if s == 'SRR':
    print('2')
if s == 'RSR':
    print('1')
if s == 'SRS':
    print('1')
if s == 'SSR':
    print('1')
if s == 'RSS':
    print('1')
if s == 'SSS':
    print('0')

Measured memory_bytes: 9044
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
int n;
cin>>n;
int arr[n];
for(int i=0;i<n;i++) cin>>arr[i];
int dp[n];
memset(dp,INT_MAX,sizeof(dp));
dp[0]=0;
for(int i=1;i<n;i++){
if(i==1) dp[i]=abs(arr[i]-arr[i-1]);
else dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
}
cout<<dp[n-1]<<"\n";
return 0;
}

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

int func(int suu){
	int cnt=0;
  	while(suu%2==0){
    	cnt++;
      	suu/=2;
    }
  	return cnt;
}


int main() {
	int n;cin>>n;
  	int ans=0,temp;
  	for(int i=0;i<n;i++){
      	cin>>temp;
    	ans+=func(temp);
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <iterator>
#include <stack>
typedef long long int lli;
using namespace std;

int main(){
	string str;
	while(getline(cin,str)){
		for(int i=0; i<=25; ++i){
			string tmp=str;
			for(int j=0; j<str.size(); ++j){
				if('A'<=str[j]&&str[j]<='Z'){
					if('A'<=tmp[j]+i&&tmp[j]+i<='Z'){
						tmp[j]=tmp[j]+i;
					} else {
						tmp[j]=tmp[j]+i+'A'-'Z'-1;
					}
				} else if('a'<=str[j]&&str[j]<='z'){
					if('a'<=tmp[j]+i&&tmp[j]+i<='z'){
						tmp[j]=tmp[j]+i;
					} else {
						tmp[j]=tmp[j]+i+'a'-'z'-1;
					}
				}
			}
			if(tmp.find("the")!=-1||tmp.find("this")!=-1||tmp.find("that")!=-1){
				cout << tmp << endl;
				break;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1180
N, X = map(int, input().split())
a = [2**(i+2) - 3 for i in range(N+1)]  # 層の数
p = [2**(i+1) - 1 for i in range(N+1)]  # パティの数
def f(N, X):
    if N == 0:
        return 1 if X > 0 else 0
    elif X <= 1 + a[N-1]:
        return f(N-1, X-1)
    else:
        return p[N-1] + 1 + f(N-1, X-2-a[N-1])
print(f(N, X))

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <assert.h>
#include <vector>

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int n;
int current[30];
double memo[20][200020];

double calc(int depth, int prev) {
  if (depth == n) { return 0.0; }
  if (!isnan(memo[depth][prev])) { return memo[depth][prev]; }
  double ret = 1e+100;
  int nv = prev;
  while (nv <= 200010) {
    ret = min(ret, max(calc(depth + 1, nv), (double)abs(current[depth] - nv) / current[depth]));
    nv += prev;
  }
  return memo[depth][prev] = ret;
}

int main() {
  while (scanf("%d", &n) > 0) {
    MEMSET(memo, -1);
    REP(i, n) {
      scanf("%d", &current[i]);
    }
    sort(current, current + n);
    double ans = 1e+100;
    FOREQ(i, 1, 200010) {
      ans = min(ans, calc(0, i));
    }
    printf("%.9f\n", ans);
  }
}

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

int main() {
  int a,b,x;
  cin >> a >> b;
  
  x = a * b;
  if (x % 2 == 1){
    cout << "Odd" << endl;
  }else {
    cout << "Even" << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   string s;
   cin>>s;
   sort(s.begin(),s.end());

   (s[0]==s[1] && s[2]==s[3] && s[1]!=s[2])? cout<<"Yes":cout<<"No";


   

   


   
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   string s;
   cin >> s;
   if(s[0] == s[2]){
      cout << "Yes" << endl;
   }
   else{
      cout << "No" << endl;
   }

   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb push_back
#define ld long double
#define f first
#define s second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e18 + 5;
const int mod = 1e9 + 7;
const int  N = 2e5 + 314;
const long double pi = 3.1415926535897932384626433832795;
int gcd(int x, int y){
    return (x==0?y:gcd(y%x, x));
}
void solve(){
    int n;
    cin>>n;
    vi v(n), suf(n), pref(n);
    for(int i = 0; i < n; i++)cin>>v[i];
    int gc =0;
    for(int i = 0; i < n; i++){
        gc=gcd(gc, v[i]);
        suf[i]=gc;
    }   
    gc=0;
    for(int i = n-1; i >= 0; i--){
        gc=gcd(gc, v[i]);
        pref[i]=gc;
    }   
    int mx = 0;
    mx=max(mx, pref[1]);
    for(int i = 1; i < n-1; i++){
        mx=max(mx,  gcd(suf[i-1], pref[i+1]));
    }
    mx=max(mx, suf[n-2]);
    cout<<mx;
}
signed main(){
    speed;
    int t=1;
    //cin>>t;
    while(t--)solve();
}

Measured memory_bytes: 5548
mod = 10 ** 9 + 7
from operator import mul
from functools import reduce

def modcomb(n, k):
    x, y = 1, 1
    for i in range(k):
        x = x * (n - i) % mod
        y = y * (k - i) % mod
    return x * pow(y, mod - 2, mod) % mod

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

for i in range(1, k + 1):
    #入れる場所
    print(int(modcomb(n - k + 1, i) * modcomb(k - 1, i - 1)) % mod)
    #分け方
    

Measured memory_bytes: 3944
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int k = sc.nextInt();
		
		int count = 0;
		
		for(int i = 0; i < n; i++) {
			if(sc.nextInt() >= k) {
				count++;
			}
		}
		
		System.out.println(count);
	}

}


Measured memory_bytes: 46264
#include <iostream>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool yes = false;
    yes = (a == b && b != c) || (b == c && c != a) || (c == a && a != b);

    cout << (yes ? "Yes" : "No");
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

mod=10**9+7

def Combi2(a,b):# aは大きいが、bは小さいとき
    if b>a:
        return 0
    ANS=1
    for i in range(min(b,a-b)):
        ANS=ANS*(a-i)*pow(min(b,a-b)-i,mod-2,mod)%mod

    return ANS%mod

T=int(input())
for tests in range(T):
    N=int(input())

    ANS=0

    for i in range(12):
        if (N-i-5)%2==0:
            ANS=ANS+Combi2(11,i)*Combi2((N-i-5)//2+15,15)
            ANS%=mod
            
    print(ANS)

Measured memory_bytes: 8988
import sys
sys.setrecursionlimit(300000)

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LMI(): return list(map(int, sys.stdin.readline().split()))
MOD = 10 ** 9 + 7
INF = float('inf')


N, M = MI()
A = LMI()

s = sum(A)
print('Yes' if len(list(filter(lambda x: 4 * x * M >= s, A))) >= M else 'No')

Measured memory_bytes: 38256
#include <iostream>
#include <vector>
#include <unordered_map>

using TourId = long long;

int main() {
    int N, M;
    std::cin >> N >> M;
    std::vector<long long> H(N);
    for (auto&& e : H) {
        std::cin >> e;
    }
    std::unordered_map<TourId, std::vector<TourId>> adjs;
    for (long long i=0; i<N; i++) {
        adjs.insert(std::make_pair(i, std::vector<TourId>{}));
    }
    for (long long i=0; i<M; i++) {
        long long A, B;
        std::cin >> A >> B;
        adjs[A-1].push_back(B-1);
        adjs[B-1].push_back(A-1);
    }

    int count = 0;
    for (auto const& e : adjs) {
        auto const& tour_id = e.first;
        auto const& adj = e.second;
        bool is_good = true;
        for (auto const& adj_id : adj) {
            if (H[tour_id] <= H[adj_id]) {
                is_good = false;
                break;
            }
        }
        if (is_good)
            count++;
    }
    std::cout << count << std::endl;
}

Measured memory_bytes: 13092
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}

object Main extends App {
  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val N, M = in.next().toInt
  val A = new Array[Int](N+1)
  val B = new Array[Int](N+1)
  val ab = new PriorityQueue[(Int, Int)]()
  for (i <- 1 to N) {
    val a, b = in.next().toInt
    A(i) = a; B(i) = b
    ab.enqueue((-a, b))
  }

  //
  var ans = 0L
  val pq = new PriorityQueue[Int]()
  for (d <- 1 to M) {
    breakable {
      while (!ab.isEmpty) {
        if (-ab.head._1 <= d) {
          val (_, b) = ab.dequeue()
          pq.enqueue(b)
        }
        else {
          break
        }
      }
    }

    if (!pq.isEmpty) {
      ans += pq.dequeue()
    }
  }

  println(ans)
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.deep))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 110124
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>
#include <sstream> // std::stringstream
#include <bitset>  // std::bitset<N>

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

//最大・最小
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/

const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

ll Factorial(ll n)
{
	ll a=1;
	for (ll i = 1; i <= n; i++)
	{
		a *= i;
		a %= MOD;
	}
	return a;
}
void solve()
{
	ll s;
	cin >> s;
	ll max = s / 3;
	s -= max * 3;
	ll ans = 0;
	for (ll m = max; m > 0; m--)
	{
		ll calc;
		calc = Factorial(s + m - 1);
		calc %= MOD;
		calc *= mod_inv(Factorial(s),MOD);
		calc %= MOD;
		calc *= mod_inv(Factorial(m - 1),MOD);
		calc %= MOD;
		ans += calc;
		ans %= MOD;

		s += 3;
	}

	cout << ans << endl;
}

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

Measured memory_bytes: 3528
a = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14,
     1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
n = int(input())

print(a[n-1])


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;

long long gcd(long long b,long long a){
    long long x = a;
    long long y = b;
    long long r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    x/=b;
    return x*y
    ;
}

int main() {
    int n;
    cin >> n;
    vector<long long> a(n,0);
    for(int i = 0;i < n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    for(int i = 1;i < n;i++){
        a[i] = gcd(a[i-1],a[i]);
    }
    cout << a[n-1] << endl;
    return 0;
}


Measured memory_bytes: 256
// AOJ 3126 Ninja E869120
// 2020.1.14 bal4u

#include <stdio.h>
#include <string.h>

#define gc() getchar_unlocked()

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

int ins(char *s) { // 文字列の入力　スペース以下の文字で入力終了
	char *p = s--;
	do *++s = gc();
	while (*s > ' ');
	*s = 0;
	return s - p;
}

char S[105];
char *E = "E869120";

int main()
{
	int N, w, ans;
	
	N = in();
	ans = 0;
	while (N--) {
		w = ins(S);
		if (w == 7 && memcmp(S, E, 7) == 0) ++ans;
	}
	printf("%d\n", ans);
	return 0;
}



Measured memory_bytes: 2112
import java.awt.geom.Line2D;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;
import java.util.TreeSet;
import java.lang.Object;
 
public class Main {
    Scanner sc = new Scanner(System.in);
   
    public static void main(String[] args) {
        new Main(); 
    }
   
    public Main() {
        new C().doIt();
    }
    class C{	
    	void doIt(){
    		int n = sc.nextInt();
    		int a[] = new int[n];
    		for(int i = 0;i < n;i++){
    			a[i] = sc.nextInt();
    		}
    		int min = Integer.MAX_VALUE;
    		for(int i = -100;i <= 100;i++){
    			int num = 0;
    			for(int j = 0;j < n;j++){
    				num = num + (i-a[j])*(i-a[j]);
    			}
    			min = Math.min(min, num);
    		}
    		System.out.println(min);
    	}
    }
}

Measured memory_bytes: 9172
#include<stdio.h>
int main(){
	int i,x,d,mint=1000001,maxt=-1000001;
	long long int t=0;
	scanf("%d",&d);
	for(i=0;i<d;i++){
		scanf("%d",&x);
		if(mint>x)mint=x;
		if(maxt<x)maxt=x;
		t+=x;
	}
	printf("%d %d %lld\n",mint,maxt,t);
	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>
 
main()
{
    int W, H, x, y, r;
 
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
 
    if( ((x - r) >= 0 && W >= (x + r)) && ((y - r) >= 0 && H >= (y + r)) )
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
     
 
    return 0;
}

Measured memory_bytes: 584
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
const int INF = 1000000000;

int kurai[15];
int rui[15] = {1,10,100,1000,10000,100000,1000000,10000000,100000000,1000000000};
int N;
int ans = 0;
void calc(int n,int k,int d)
{
	kurai[n] = k;
	n++;
	if (n == d+1)
	{
		int dec = 0, n3 = 0, n5 = 0, n7 = 0;
		for (int i = 1; i <= d; i++)
		{
			//printf(",%d", kurai[i]);
			switch (kurai[i])
			{
				case 3:
				{
					n3++;
					break;
				}
				case 5:
				{
					n5++;
					break;
				}
				case 7:
				{
					n7++;
					break;
				}
			}
			dec += rui[d - i] * kurai[i];
		}
		//printf(",dec%d", dec);
		if (!(n3 == 0 || n5 == 0 || n7 == 0||dec>N)) ans++;
		//putchar('\n');
	}else{
		calc(n, 3,d);
		calc(n, 5,d);
		calc(n, 7,d);
	}
}

int main()
{
	cin >> N;
	for (int i = 3; i <= 9; i++)
	{
		calc(1, 3, i);
		calc(1, 5, i);
		calc(1, 7, i);
	}
	printf("%d\n", ans);
}


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

int main() {
  int w, a, b;
  cin >> w >> a >> b;
  
  if(a > b) swap(a, b);
  int ans;
  if(w + a < b) ans = b - w -a;
  else ans = 0;
  
  cout << ans << endl;
}

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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)
#define BETWEEN(a, x, b) (a<=x&&x<b)

using namespace std;
typedef long long ll;

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

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

  int res = 0;
  for(int i=0;i<n;i++){
    bool ok = true;
    for(int j=0;j<i;j++){
      if(h[j]>h[i])ok=false;
    }
    if(ok)res++;
  }
  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        String S = new Scanner(System.in).nextLine();
        int i=0;
        while(i<S.length()){
            //System.out.println(i);
            if(S.charAt(i)!='R' && S.charAt(i)!='U' && S.charAt(i)!='D'){
                System.out.println("No");
                System.exit(0);
            }
            i+=2;
        }
        i=1;
        while(i<S.length()){
            //System.out.println(i);
            if(S.charAt(i)!='L' && S.charAt(i)!='U' && S.charAt(i)!='D'){
                System.out.println("No");
                System.exit(0);
            }
            i+=2;
        }
        System.out.println("Yes");
    }
} 

Measured memory_bytes: 22612
raw_input()
lst=map(int, raw_input().split())

cnt = 0
for i in range(0, len(lst)):
    m = i
    for j in range(i, len(lst)):
        if lst[m] > lst[j]:
            m = j
    if m != i:
        lst[i], lst[m] = lst[m], lst[i]
        cnt+=1

print " ".join(map(str,lst))
print (cnt)

Measured memory_bytes: 6316
import math
a,b,h,m = map(int, input().split())
ah = ((60*h+m) / (12*60)) * 360
am = (m / 60) * 360

def cal_pos(r, a):
    x = 1
    y = 1
    if a <= 90:
        a_use = a
    elif a <= 180:
        a_use = 180 - a
        y *= -1
    elif a <= 270:
        a_use = a - 180
        x *= -1
        y *= -1
    else:
        a_use = 360 - a
        x *= -1
        
    yl = (r**2 / (math.tan(a_use/180*math.pi)**2 + 1)) ** 0.5
    xl = yl * math.tan(a_use/180*math.pi)
    x *= xl
    y *= yl
    return x,y

pos_h = cal_pos(a,ah)
pos_m = cal_pos(b,am)
dis = ((pos_h[0] - pos_m[0])**2 + (pos_h[1] - pos_m[1])**2)**0.5
print(dis)

Measured memory_bytes: 9592
#include<stdio.h>

int main()
{
	int x = 0, y = 0, z = 0, temp = 0, hasil = 0;
	scanf("%d %d %d",&x,&y,&z);
	int a = 1;
	for(a;a <= 10;a++)
	{
		if(x<y)
		{
			temp = x;
			x = y;
			y = z;
			z = temp;
		}
		else if(y<z)
		{
			temp = y;
			y = z;
			z = temp;
		}
	}
	hasil = (x*10)+y+z;
	printf("%d",hasil);
	return 0;
	
}

Measured memory_bytes: 128
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


def main():
    n,m=map(int,input().split())
    a=[int(x) for x in input().split()]
    ans=[True]*n
    for _ in range(m):
        u,v=[int(x)-1 for x in input().split()]
        if a[u]<=a[v]:
            ans[u]=False
        if a[u]>=a[v]:
            ans[v]=False
    print(sum(ans))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 86948
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    char c;
    cin >> c;

        c++;
        cout << c <<endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	vector<int> a(26);
	rep(i,s.size()){
		a.at(s.at(i)-'a')++;
	}
	rep(i,26){
		if(a.at(i)==0){
			char c='a'+i;
			cout << c << endl;
			return 0;
		}
	}
	cout << "None" << endl;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;int f[4]={1,505,-1,-505},I,n,p,x,i,d[255025],a,w[255025];void D(int x){for(int i=0;i<4;++i){p=x+f[i];if(d[p]>d[x]+w[p])d[p]=d[x]+w[p],D(p);}}int main(){cin>>n;for(I=0;I<n*n;++I){x=I/n+1,p=I%n+1;i=x*505+p;w[i]=1,d[i]=min(min(x,n-x+1),min(p,n-p+1));}for(i=1;i<=n*n;++i){cin>>p;p--;x=(p/n+1)*505+(p%n+1);a+=--d[x];w[x]=0;D(x);}cout<<a<<endl;}

Measured memory_bytes: 20888
s = input()
x, y = map(int, input().split())
y = abs(y)

f = s.find('T')
if f >= 0:
    x = abs(x - f)
    s = s[f:]
else:
    if x == len(s) and y == 0:
        print('Yes')
    else:
        print('No')
    exit()

lx, ly = [], []
flag = True
n = 0
s += 'T'
for i in s:
    if i == 'F':
        n += 1
    else:
        if n > 0:
            if flag:
                lx.append(n)
            else:
                ly.append(n)
            n = 0
        flag = not flag

lx.sort()
ly.sort()
sx = sum(lx)
sy = sum(ly)

if sx < x or (sx - x) % 2 == 1 or sy < y or (sy - y) % 2 == 1:
    print('No')
    exit()


def main(x, sx, lx):
    if x == sx:
        return True

    goal = (sx - x) // 2
    # return (sum of some lx == goal)
    dp = [False] * (goal + 1)
    dp[0] = True
    for i in lx:
        if i > goal:
            return False
        for j in range(goal - i, -1, -1):
            if dp[j]:
                dp[j+i] = True
        if dp[goal]:
            return True
    return False


if main(x, sx, lx) and main(y, sy, ly):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 70132
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define INF 10000000001
#define MOD 1000000007
using namespace std;

bool valid(ll x,ll y,ll n, ll m)
{
  if(x>=0 && y>=0 && x<n && y<m)
    return true;
  return false;
}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll n,m;
  cin>>n>>m;
  char arr[n][m];
  for(ll i=0;i<n;i++)
  {
    for(ll j=0;j<m;j++)
    {
      cin>>arr[i][j];
    }
  }
  ll dp[n][m];
  for(ll i=0;i<n;i++)
  {
    for(ll j=0;j<m;j++)
    {
      dp[i][j]=0;
    }
  }
  bool flag=true;
  for(ll i=0;i<n;i++)
  {
    if(arr[i][0]=='#')
    {
      flag=false;
    }
    if(flag)
    dp[i][0]=1;
    else
    {
      dp[i][0]=0;
    }
  }
  flag=true;
  for(ll j=0;j<m;j++)
  {
    if(arr[0][j]=='#')
    {
      flag=false;
    }
    if(flag)
    dp[0][j]=1;
    else
    {
      dp[0][j]=0;
    }
  }
  for(ll i=1;i<n;i++)
  {
    for(ll j=1;j<m;j++)
    {
      if(arr[i][j]=='#')
      {
        dp[i][j]=0;
      }
      else
      {
        dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
      }
    }
  }
  cout<<dp[n-1][m-1];
}


Measured memory_bytes: 9088
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }

    let sum_ = a.iter().sum::<i64>();
    let mut ans: i64 = std::i64::MAX;

    let mut cum = 0;

    for i in 0..n {
        cum += a[i];
        ans = min(ans, ((sum_ - cum) - cum).abs()); 
    }
 
    println!("{}", ans);
}


Measured memory_bytes: 6396
// Created by sz
#include <bits/stdc++.h>
using namespace std;

long long  N, K, a;
int cnt[64];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin>>N>>K;
    
    for(int i = 0; i<N; i++){
        cin>>a;
        for(int j = 0; j< 64 ;j++){
            if((a>>j)&1)cnt[j]++;
        }
    }
    
    bool  less = false, has_start = false;
    long long res = 0;
    for(int i = 63;i>=0; i--){
        if(has_start||((K>>i)&1)==1){
            has_start = true;
            if((((K>>i)&1)==1||less)&&cnt[i]<=N/2)res += (long long)(N - cnt[i])*(1ll<<i);
            else {
                if(((K>>i)&1)==1)less = true;
                res += (long long)cnt[i]*(1ll<<i);
            }
        }
        else res+= (long long)cnt[i]*(1ll<<i);
    }
    cout<<res<<endl;
    
    
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int a,b,n,m,c,s;
  while(scanf("%d %d %d",&a,&b,&n)!=EOF){
    s=c=0;
    m=a;
    while(++c<=n){
      m=m%b*10;
      s+=m/b;
    }
    printf("%d\n",s);
  }
  return 0;
}

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

//const int INF = 1001001001;
//const ll INF = 1000000000000000000;

ll a, b, v, w, t;

int main() {
	cin >> a >> v;
	cin >> b >> w;
	cin >> t;

	string ans = "NO";
	if (v <= w) {
		cout << ans << endl;
		return 0;
	}
	if (abs(a - b)/abs(w - v) > t) {
		cout << ans << endl;
		return 0;
	}
	if ((abs(a - b) + abs(w - v) - 1)/abs(w - v) > t) {
		cout << ans << endl;
		return 0;
	}
	ans = "YES";
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long h,w;
	cin>>h>>w;
	if(h==1||w==1){
		cout<<1; return 0;
	}
	if(h*w%2==0)
	    cout<<h*w/2;
	else
	    cout<<h*w/2+1;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)

using namespace std;
typedef long long int lli;
//const int MAX=;

int main(){
	int A,B;
	cin>>A>>B;
	int mx=A+B;
	mx=max(mx,A-B);
	mx=max(mx,A*B);
	cout<<mx;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a, b;
  cin >> a >> b;
  if (a % 2 && b % 2)
    puts("Yes");
  else
    puts("No");
  return 0;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    X, Y, Z = MI()

    tmp = Y
    Y = X
    X = tmp
    tmp = Z
    Z = X
    X = tmp

    print(X, Y, Z)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (int i = (a); i < (b); i++)
#define INF LLONG_MAX
typedef long long ll;
void bibs_swap(vector<int>& v, int k)
{
	rep(i, v.size()-1) if(v.at(i)%k>v.at(i+1)%k) swap(v.at(i), v.at(i+1));
}

void show(vector<int> v)
{
	rep(i, v.size()) cout << v.at(i) << endl;
}

int main(void)
{
    int N, M;
		cin >> N >> M;
		vector<int> z(N);
		rep(i, N) cin >> z.at(i);

		repd(i, 2, M+1) bibs_swap(z, i);
		show(z);
		return 0;
	}


Measured memory_bytes: 3140
#include <iostream>

int main()
{
	int n;
	std::cin >> n;

	int c = 100;
	int result = 0;
	for ( int i = 0; i < 3; i++ )
	{
		int tmp = n / c;
		if ( tmp == 1 )
		{
			result += 9;
		}
		else if ( tmp == 9 )
		{
			result += 1;
		}
		else
		{
			result += tmp;
		}
		result *= 10;
		n %= c;
		c /= 10;
	}

	std::cout << result / 10 << std::endl;

	return ( 0 );
}


Measured memory_bytes: 256
a = list(input())


for x in range(8):
    s = ""
    sum = int(a[0])
    s += a[0]
    for i in range(3):
        if ( x & ( 1 << i)):
            sum += int(a[i+1])
            s += "+"
            s += a[i+1]
        else:
            sum -=int(a[i+1])
            s += "-"
            s += a[i+1]

    if sum == 7:
        print(s + "=7")
        break    

Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int gcd2(int x,int y) {
  if(y==0) return x;
  return gcd2(y,x%y);
}

int gcd(vi a) {
  int ans=a[0];
  for(int i=1; i<a.size(); i++) {
    ans=gcd2(ans,a[i]);
  }
  return ans;
}

int main() {
  int N; cin>>N;
  vi a(N);
  rep(i,N) cin>>a[i];
  cout<<gcd(a)<<endl;
}

Measured memory_bytes: 1152
# メインアイデア
# T分割と||分割で差が小さい方を探す
# 90度回転させた場合も考える
# 総合的に小さい方を採用する
# 図的な解説は別のPDFをアップロードしてある
H, W = list(map(int, input().split()))

# 3の倍数の場合は即座に0とわかる
if (H * W) % 3 == 0:
    print(0)
    exit()


def try_divi(W, H):
    # パターン1
    err = W
    # パターン2
    w2, w3 = W // 2, W // 2
    if W % 2:
        w2 += 1
    for h1 in range(1, H // 2 + 1):
        h2 = H-h1
        S1, S2, S3 = h1*W, w2*h2, w3*h2
        new_err = max(S1, S2, S3) - min(S1, S2, S3)
        if new_err < err:
            err = new_err
    return err


print(min(try_divi(W, H), try_divi(H, W)))


Measured memory_bytes: 3064
#Aの最後の文字とBの最初の文字が同じ
#Bの最後の文字とCの最初の文字が同じ

a,b,c = map(str,input().split())

if (a[-1] == b[0]) and (b[-1] == c[0]):
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    rep(i,n){
        cin >> a[i].first >> a[i].second;
    }
    double ans=0;
    int q = 1;
    rep(i,n){
        q*=(i+1);
    }
    rep(i,n){
        rep(j,n){
            if(i!=j){
                int m;
                m = (a[j].first-a[i].first)*(a[j].first-a[i].first) + (a[j].second-a[i].second)*(a[j].second-a[i].second);
                ans += sqrt(m)/n;
            }
        }
    }
    cout << setprecision(15) <<(double) ans;

    return 0;
}

Measured memory_bytes: 3796
#include <stdio.h>
#define max(a, b) (a > b) ? a : b
#define min(a, b) (a < b) ? a : b
int main()
{
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    printf("%d %d", min(a, b), max(0, a + b - n));
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
 
int main()
{
 
  int x, y, r, tmp;
 
  scanf("%d %d", &x, &y);
  if(x<y){
    tmp = x;
    x = y;
    y = tmp;
  }
  r = x % y;
  while(r!=0){
    x = y;
    y = r;
    r = x % y;
  }

  printf("%d\n", y);
 
  return 0;
}



Measured memory_bytes: 2144
using System;
using System.Linq;
using System.Collections.Generic;

class Program{
  static void Main()
  {
    int n = int.Parse(Console.ReadLine());
    int[] xs = 
      Console.ReadLine().Split()
      	.Select(int.Parse)
      	.OrderBy(x => x).ToArray();
    int result = 
      Enumerable.Range(0, xs.Length)
      	.Where(x => (x & 1) == 0)
      	.Select(x => xs[x])
      	.Sum();
    Console.WriteLine(result);
      	
  }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
    #define rep(i,n) for(int i = 0; i < (n); i++)
     
    using namespace std;  
    using ll = long long;
    using P = pair<int,int>; 
    
    int main() {
   
     ll n;
     cin >> n;
     ll count = 0;
     for(int i = 1; i<=n; i++){
     if(i%3!=0&&i%5!=0){
     count += i;
     }
     }
     	cout << count <<'\n';
     
     return 0;
    }

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n, m;
  cin >> n >> m;
  
  vector<pair<ll, ll>> a(n);
  REP(i, n)
    cin >> a[i].FI >> a[i].SE;
  
  sort(a.begin(), a.end());
  priority_queue<ll> que;
  ll ans, j;
  ans = j = 0;
  for(int i = 1; i <= m; i++){
    while(j < n){
      if(a[j].FI > i)
        break;
      
      que.push(a[j].SE);
      j++;
    }
    if(!que.empty()){
      ans += que.top();
      que.pop();
    }
  }
  
  cout << ans << endl;
    
}

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

#define INF 1 << 29;
int dp[20002][256];

int main(int argc, const char * argv[]) {
    while(1){
        int N, M; cin >> N >> M;
        if(!N && !M) break;
        
        vector<int> c(M);
        for(int i = 0; i < M; i++) cin >> c[i];
        for(int i = 0; i < 256; i++) dp[0][i] = INF;
        dp[0][128] = 0;
        
        for(int i = 1; i <= N; i++){
            int x; cin >> x;
            for(int j = 0; j < 256; j++) dp[i][j] = INF;
            
            for(int pre = 0; pre < 256; pre++){
                for(int j = 0; j < M; j++){
                    int nx = pre + c[j];
                    if(nx >= 256) nx = 255;
                    else if(nx < 0) nx = 0;
                    
                    dp[i][nx] = min(dp[i][nx], dp[i-1][pre] + (nx-x)*(nx-x));
                }
            }
        }
        
        int ans = INF;
        for(int i = 0; i < 256; i++){
            ans = min(ans, dp[N][i]);
        }
        cout << ans<< endl;
        
    }
}

Measured memory_bytes: 21192
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    H, W = MAP()
    dx = [1, 0]
    dy = [0, 1]
    s = [input() for _ in range(H)]

    start = (0, 0)

    q = deque()
    q.append(start)

    cost = [[INF]*W for _ in range(H)]
    if s[0][0] == "#":
        cost[0][0] = 1
    else:
        cost[0][0] = 0
    while q:
        i, j = q.popleft()
        for k in range(2):
            y = i + dy[k]
            x = j + dx[k]
            if y < 0 or y > H-1 or x < 0 or x > W-1:
                continue
            if s[i][j] == "." and s[y][x] == "#":  # コストが増える
                if cost[y][x] > cost[i][j] + 1:
                    cost[y][x] = cost[i][j] + 1
                    q.append((y, x))
            else:
                if cost[y][x] > cost[i][j]: 
                    cost[y][x] = cost[i][j]
                    q.append((y, x))
    print(cost[H-1][W-1])

if __name__ == '__main__':
    main()


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

using namespace std;

const int N = 105;
const int M = 100005;

int n, b, w[N];
long long v[N], f[N][M]; 

int main() {
  cin >> n >> b;
  for (int i = 1; i <= n; ++i) {
    cin >> w[i] >> v[i];
    for (int j = 0; j < M; ++j) {
      f[i][j] = f[i - 1][j];
    }
    for (int j = w[i]; j < M; ++j) {
      f[i][j] = max(f[i][j], f[i - 1][j - w[i]] + v[i]);
    }
  }
  long long ans = 0;
  for (int i = 0; i <= b; ++i) {
    ans = max(ans, f[n][i]);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 79360
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  int key;
  struct node *r;
  struct node *l;
  struct node *p;
};
typedef struct node * Node;
#define NIL NULL
 
Node root;
 
Node treeSearch(Node u, int k){
  if(u == NIL || u->key == k){
    return u;
  }
  else if(u->key > k){
    return treeSearch(u->l,k);
  }
  else if(u->key < k){
    return treeSearch(u->r,k);
  }
 
}
 
void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;
 
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
 
  while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
    }
    else x = x->r;
  }

  z->p = y;
  if(y == NIL){
    root = z;
  }
  else if(z->key < y->key){
    y->l = z;
  }
  else y->r = z;           
}
 
void inorder(Node u){
  if (u->l != NIL){
    inorder(u->l);
  }
    printf(" %d",u->key);
    if (u->r != NIL){
      inorder(u->r);
    }
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->l != NIL){
    preorder(u->l);
  }
  if(u->r != NIL){
    preorder(u->r);
  }
}
 
 
int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
 
  for (i = 0; i < n; i++){
    scanf("%s", com);
    if (com[0] == 'f'){
      scanf("%d",&x);
      Node t = treeSearch(root, x);
      if (t != NIL){
	printf("yes\n");
      }
      else printf("no\n");
    } else if (com[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    } else if (com[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
return 0;
}

Measured memory_bytes: 19364
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vdo=vector<double>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vvdo=vector<vector<double>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define _GLIBCXX_DEBUG
int main()
{
    ll n;
    cin>>n;
    if(n==2)cout<<1<<endl;
    else{
        ll sum=2;
        for(ll i=2;i*i<=n;i++){
            if(n%i==1){
                //n-1の約数の個数を数える
                if(i*i==n-1)sum++;
                else sum+=2;
            }
            ll x=n;
            if(n%i==0){
                while(x%i==0){
                    x/=i;
                }
                if(x%i==1)sum++;
            }
        }
        cout<<sum<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
static const int SEPARETED = 4;
static const int CIRCUMSCRIBED = 3;
static const int INTERSECTED = 2;
static const int INSCRIBED = 1;
static const int INCLUDED = 0;
 
class Point{
	public:
		double x, y;
 
		Point(double x = 0, double y = 0): x(x), y(y) {}
 
		Point operator + (Point p){ return Point(x + p.x, y + p.y);}
		Point operator - (Point p){ return Point(x - p.x, y - p.y);}
		Point operator * (double a){ return Point(a * x, a * y);}
		Point operator / (double a){ return Point(x / a, y / a);}
 
		double abs(){ return sqrt(norm());}
		double norm(){ return x * x + y * y;}
 
		bool operator < (const Point &p) const{
			return x != p.x ? x < p.x : y < p.y;
		}
 
		bool operator == (const Point &p) const{
			return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
		}
};
class Circle{
	public:
		Point c;
		double r;
		Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};
double getDistance(Point a, Point b){
	return (a - b).abs();
}
int intersection(Circle c1, Circle c2){
	double distanceBetweenCenter = getDistance(c1.c, c2.c);
	if(distanceBetweenCenter > c1.r + c2.r) return SEPARETED;
	if(equals(distanceBetweenCenter, c1.r + c2.r)) return CIRCUMSCRIBED;
	if(equals(distanceBetweenCenter, fabs(c1.r - c2.r))) return INSCRIBED;
	if(distanceBetweenCenter < fabs(c1.r - c2.r)) return INCLUDED;

	return INTERSECTED;
}

int main(){
	Circle c1, c2;
	cin >> c1.c.x >> c1.c.y >> c1.r;
	cin >> c2.c.x >> c2.c.y >> c2.r;
	cout << intersection(c1, c2) << endl;
	return 0;
}



Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    if(s[0]=='S')
    {
        cout<<"Cloudy"<<endl;
    }else if(s[0]=='C')
    {
         cout<<"Rainy"<<endl;
    }else 
    {
   cout<<"Sunny"<<endl;
    }
    return 0;



    }

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
	int a,b;
	cin>>a>>b;
	if(a>b)
		cout<<"a > b"<<endl;
	if(a<b)
		cout<<"a < b"<<endl;
	if(a==b)
		cout<<"a == b"<<endl;
	return 0;
}

Measured memory_bytes: 1156
<?php
  
  //$arr = explode(" ", fgets(STDIN));
  	$arr = fgets(STDIN);
	$ans = "No";
	for($i=1; $i<10; $i++){
      for($j=1; $j<10; $j++){
       	if((int)$arr === ($i * $j)){
         	$ans = "Yes";
          	break;
        }
      }
    }

  
	echo $ans;

Measured memory_bytes: 4728
#include <iostream>
#include <string>
#include <cstdint>

using namespace std;

int32_t main()
{
  uint32_t H, W;
  cin >> H >> W;

  for(uint32_t i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;

  for(uint32_t i = 0; i  < H; i++){
    string  str;
    cin >> str;
    cout << "#" << str << "#" << endl;
  }

  for(uint32_t i = 0; i < W + 2; i++){
    cout << "#";
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256