akhauriyash/Code-Regression huggingface dataset:
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let s: Vec<u8> = read::<String>().as_bytes().to_vec();

    let mut ans = 0;

    for i in 0..s.len() / 2 {
        if s[i] != s[s.len() - i - 1] {
            ans += 1;
        }
    }

    println!("{}", ans);
}

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


Measured memory_bytes: 4352
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }

bool pcomp(const PL p1, const PL p2){ return p1.ss*p2.ff < p2.ss*p1.ff;};


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    ll ga, sa, ba; cin >> ga >> sa >> ba;
    ll gb, sb, bb; cin >> gb >> sb >> bb;
    
    vl dp(N+1, 0); dp[0]=N;
    rep(i, N+1){
        if(i-ga>=0) chmax(dp[i], dp[i-ga]+max(gb-ga, 0ll));
        if(i-sa>=0) chmax(dp[i], dp[i-sa]+max(sb-sa, 0ll));
        if(i-ba>=0) chmax(dp[i], dp[i-ba]+max(bb-ba, 0ll));
    }
    ll mx = -1;
    rep(i, N+1) chmax(mx, dp[i]);
    vl dp2(mx+1, 0); dp2[0] = mx;
    rep(i, mx+1){
        if(i-gb>=0) chmax(dp2[i], dp2[i-gb]+max(ga-gb,0ll));
        if(i-sb>=0) chmax(dp2[i], dp2[i-sb]+max(sa-sb,0ll));
        if(i-bb>=0) chmax(dp2[i], dp2[i-bb]+max(ba-bb,0ll));
    }
    ll ans = -1;
    rep(i, mx+1) chmax(ans, dp2[i]);
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 195584
import java.util.Scanner;
 
 
public class Main {
     
 
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        int n = stdIn.nextInt();
        int m = stdIn.nextInt();
         
        int[][] A = new int[n][m];
        int[] B = new int[m];
        int[] C = new int[n];
        for(int i = 0; i < n; i++) {
            for(int j = 0; j <  m; j++) {
                A[i][j] = stdIn.nextInt();
            }
        }
        for(int i = 0; i < m; i++) {
            B[i] = stdIn.nextInt();
        }
         
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < m; j++) {
                C[i] += A[i][j] * B[j];
            }
        }
         
        for(int i = 0; i < n; i++) {
            System.out.println(C[i]);
        }
    }
 
}



Measured memory_bytes: 40556
#include<bits/stdc++.h>
using namespace std;
inline int Abs(int x)
{
	return x>0?x:-x;
}
int n,k,a[100005],f[100005];
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=2;i<=n;i++)
	{
		f[i]=INT_MAX;
		for(int j=max(1,i-k);j<i;j++)
			f[i]=min(f[i],f[j]+Abs(a[j]-a[i]));
	}
	printf("%d",f[n]);
}


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

#define int long long

typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;

#define endl '\n'
#define fi first
#define se second
#define all(v) v.begin(), v.end()

#define print(x)    cout << #x << " : " << x << endl;
#define darr(a,n)   for(int i=0; i<n; i++) cout << a[i] <<' '; cout<< '\n';
#define fast        ios_base::sync_with_stdio (false); cin.tie (nullptr);
#define dvec(vct)   for(auto i : vct) cout << i << " "; cout << endl;

const int maxn = 1e6;
const int mod = 1e9 + 7;
// const int mod = 998244353;


/*****************************************************************************/



void solve() {
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> v = {a, b, c};
    sort(all(v));
    a = v[0];
    b = v[1];
    c = v[2];

    int ans = 0;
    ans += c - b;
    a += (c - b);
    b = c;

    if ((b - a) % 2 == 0) {
        cout << ans + (b-a)/2 << endl;
    }
    else {
        cout << ans + (b-a)/2 + 2 << endl;
    }

}



/*****************************************************************************/



int32_t main() {
    fast; solve(); return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<cmath>
using namespace std;
char s[100005];
int n,ans;
int main()
{
	scanf("%s",s+1),ans=n=strlen(s+1);
	for(int i=1;i<n;i++)
		if(s[i]!=s[i+1]) ans=min(ans,max(i,n-i));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
x = int(input())
def is_prime(n):
    for i in range(2,int(n**0.5)+1):
        if n%i != 0:
            continue
        else:
            return False
    return True
while  True:
    if is_prime(x) == True:
        break
    else:
        x +=1
print(x)


Measured memory_bytes: 2940
unittest
{
	assert( [ "3 3", "2 2 2" ].parse.expand.solve == 1 );
	assert( [ "6 1", "1 6 1 2 0 4" ].parse.expand.solve == 11 );
	assert( [ "5 9", "3 1 4 1 5" ].parse.expand.solve == 0 );
	assert( [ "2 0", "5 5" ].parse.expand.solve == 10 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nx = input.front.split.to!( long[] );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	return tuple( nx[ 1 ], as );
}

auto solve( long x, long[] as )
{
	auto ans = 0L;
	for( auto i = 0L; i < as.length - 1; i++ )
	{
		auto d = as[ i ] + as[ i + 1 ] - x;
		if( 0 < d )
		{
			// 2つの箱の総和がxを超えていた場合、右の箱を優先して食べる
			ans += d;
			if( d <= as[ i + 1 ] )
			{
				as[ i + 1 ] -= d;
			}
			else
			{
				as[ i ] -= d - as[ i + 1 ];
				as[ i + 1 ] = 0;
			}
		}
	}
	return ans;
}


Measured memory_bytes: 6852
# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *					# ll = deepcopy(l)
from heapq import *					# heappush(hp,x)
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from bisect import *				# bisect_left(arr,x,start,end)  => start and end parameters are temporary
from sys import stdin				# bisect_left return leftmost position where x should be inserted to keep sorted
from sys import maxsize				# minn = -maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *				# pre = [0] + list(accumulate(l))
from decimal import Decimal 		# a = Decimal(a)	# use this for math questions
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
4 6
#..#..
.....#
....#.
#.#...
'''

def transpose(m):
	rez = [[m[j][i] for j in range(len(m))] for i in range(len(m[0]))] 
	return rez

def giveLightIntervals(L,h,w):
	l = [[] for i in range(h)]
	for i in range(h):
		s,e,c = '','',0
		for j in range(w):
			if(L[i][j] == '#'):
				if(c > 0):
					e = j
					l[i].append([s,e-1])
					c = 0
				s,e = '',''
			else:
				if(s == ''):
					s = j
				c += 1
		if(L[i][-1] == '.'):
			l[i].append([s,w-1])
	return l

def solve(L,h,w):
	T = transpose(L)
	l = giveLightIntervals(L,h,w)
	t = giveLightIntervals(T,w,h)

	H = [[0 for i in range(w)] for j in range(h)]
	W = [[0 for i in range(h)] for j in range(w)]

	for i in range(h):
		zz = 0
		for j in range(w):
			if(len(l[i]) > zz):
				s,e = l[i][zz]
				val = e - s + 1
				if(s <= j <= e):
					H[i][j] = val
				if(j == e):
					zz += 1
			else:
				break

	for i in range(w):
		zz = 0
		for j in range(h):
			if(len(t[i]) > zz):
				s,e = t[i][zz]
				val = e - s + 1
				if(s <= j <= e):
					W[i][j] = val
				if(j == e):
					zz += 1
			else:
				break

	ans = 0

	for i in range(h):
		for j in range(w):
			curr = H[i][j] + W[j][i] - 1
			ans = max(ans,curr)

	return ans


H,W = list(map(int, stdin.readline().rstrip().split()))
L = []
for m in range(H):
	L.append(list(input()))
ans = solve(L,H,W)
print(ans)



Measured memory_bytes: 498444
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
#define rep(i,n) for(int i =0;i<n;i++)
using namespace std;
typedef long long int ll;

struct joi{
    int j;
    int o;
    int i;
};

int main(){
    int m,n,kk;
    cin >> m>>n>>kk;
    vector<joi> G(1001*1001+1);
    for (int k=0; k<1001; k++) {
        G[0+1000*k].j=0;
        G[0+1000*k].o=0;
        G[0+1000*k].i=0;
    }
    for (int l=1; l<=m; l++) {
        string S;
        cin >> S;
        for (int k=1; k<=S.length(); k++) {
            G[l*1000+k].j = G[l*1000+k-1].j;
            G[l*1000+k].o = G[l*1000+k-1].o;
            G[l*1000+k].i = G[l*1000+k-1].i;
            if (S[k-1]=='J') {
                G[l*1000+k].j++;
            }
            if (S[k-1]=='O') {
                G[l*1000+k].o++;
            }
            if (S[k-1]=='I') {
                G[l*1000+k].i++;
            }
        }
    }
    for (int p=0; p<kk; p++) {
        int ansj =0, anso=0, ansi=0;
        int x1,x2,y1,y2;
        cin >> x1>> y1 >>x2 >>y2;
        for (int q = min(x1,x2); q <= max(x1,x2);q++ ) {
            ansj += G[q*1000+max(y1,y2)].j-G[q*1000+min(y1,y2)-1].j;
            anso += G[q*1000+max(y1,y2)].o-G[q*1000+min(y1,y2)-1].o;
            ansi += G[q*1000+max(y1,y2)].i-G[q*1000+min(y1,y2)-1].i;
        }
        cout << ansj <<" "<<anso<<" "<<ansi<<endl;
    }
}

Measured memory_bytes: 12876
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  [a, b, c] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  k <- unsafeTextToInt <$> T.getLine :: IO Int
  let
    b' = until (a <) (* 2) b :: Int
    c' = until (b' <) (* 2) c :: Int
  putStrLn $ if (b' `div` b) * (c' `div` c) <= 2 ^ k then "Yes" else "No"

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rept(i, a, b) for(int i=a ; i<=b; i++)

int main(){
    int a1, a2, a3;
    cin >> a1 >> a2 >> a3;
    if(a1+a2+a3 > 21) cout << "bust" << endl;
    else cout << "win" << endl;
}


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

const int dx[4] = {0,1,0,-1};
const int dy[4] = {1,0,-1,0};

int main(){
	int h,w;
	cin >> h >> w;
	vector<string> field(h);
	rep(i,h){
		cin >> field[i];
	}
	int count = 0;
	int dist[55][55];
	rep(i,h){
		rep(j,w){
			dist[i][j] = -1;
			if(i == 0 && j == 0) continue;
			if(i == h-1 && j == w-1) continue;
			if(field[i][j] == '.') count++;
		}
	}
	
	dist[0][0] = 0;
	queue<pair<int,int>> que;
	que.push(make_pair(0,0));
	while(!que.empty()){
		auto p = que.front();
		que.pop();
		rep(i,4){
			int ny = p.first + dy[i];
			int nx = p.second + dx[i];
			if(ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
			if(dist[ny][nx] != -1) continue;
			if(field[ny][nx] == '.'){
				que.push(make_pair(ny,nx));
				dist[ny][nx] = dist[p.first][p.second] + 1;
			}
		}
	}
	int d = dist[h-1][w-1];
	if(dist[h-1][w-1] == -1){
		cout << -1 << endl;
	}else{
		int ans = count - d + 1;
		cout << ans << endl;
	}
    return 0;
}



Measured memory_bytes: 256
# -*- coding: utf-8 -*-

N = int(raw_input())
A = []
for i in range(N):
    A.append(int(raw_input()))
cnt = 0
G = [1]
while G[-1]*3+1 < N:
    G.append(G[-1]*3+1)
G.reverse()
m = len(G)
for i in range(m):
    g = G[i]
    for j in range(g, N):
        v = A[j]
        k = j-g
        while k >= 0 and A[k] > v:
            A[k+g] = A[k]
            k -= g
            cnt += 1
        A[k+g] = v
print m
print " ".join(map(str, G))
print cnt
for i in range(N):
    print A[i]

Measured memory_bytes: 69796
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = (int)1e7;  
using  p = pair<int,int>;
using  v = vector<ll>;
auto x = vector<int>({-1,-1,-1,0,0,1,1,1});
auto y = vector<int>({1,0,-1,1,-1,1,0,-1});

int main(){
   string s,t;
   cin >> s;
   cin >> t;
   string ss=s;
   bool f = false;
   for (int i = s.size()-1; i >=0 ; i--)
   {
      f = true;
      int j = t.size()-1;
      for (j = t.size()-1; j >=0; j--)
      {
         if(i+j<s.size()&&t[j]==s[i+j]||s[i+j]=='?'){
         }else{
       	   f=false;
            break;
         }
      }
      
      if(f){
         for (int k = t.size()-1; k >= 0; k--)
         {
            if(ss[i+k]=='?'){
               ss[i+k] = t[k];
            }
         }
         break;
      }
   }
   
   if(f){
     for (int k = 0; k < s.size(); k++)
         {
            if(ss[k]=='?'){
               cout <<'a';
            }else{
               cout <<ss[k];
            }
         }
   }else{
      cout << "UNRESTORABLE";
   }


}
  
  

Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
#include<math.h>
#include<time.h>
#include<string.h>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<map>
#include<stack>
#define LL long long
#define mem(a,b) memset(a,b,sizeof(a))
#define lowbit(a) a&(-a)
#define PI acos(-1)
#define shortime(a)  std::ios::sync_with_stdio(a);
using  namespace std;
const LL mod=998244353;
//long long cmp(node a,node b){ if(a.x==b.x) return a.r>b.r;return a.x>b.x;}
LL  quick(LL x,LL n,LL mod){ LL ans=1,temp=x; while(n){if(n%2==1){ ans=(ans*temp)%mod;} n/=2;temp=temp*temp%mod;}return ans%mod;}
int maxn (int a,int b,int c){return max(max(a,b),max(b,c));}
LL min(LL a,LL b) {return a<b?a:b;}
int gcd (int a,int b){return b==0?a:gcd(b,a%b);}
int main()
{
   int n,k;
   scanf("%d%d",&n,&k);
   if(n%2==0)
   {
       printf("%d",n/2);
       for(int i=2;i<=k;i++)
           printf(" %d",n);
       putchar('\n');
   }
   else {
       int a[300005];
       for(int i=1;i<=k;i++)
           a[i]=(n+1)/2;
       int temp=k,i=0;
       while(i<k/2)
       {
           if(a[temp]==1)
           {
               a[temp]=n;
               temp--;
           }
           else {
            a[temp]--;
            temp=k;
           }
           i++;
       }
       printf("%d",a[1]);
       for(int i=2;i<=temp;i++)
           printf(" %d",a[i]);
       putchar('\n');
   }
   return 0;
}


Measured memory_bytes: 3456
n, m, k = map(int, input().split())
mod = 10 ** 9 + 7

res_n = 0
for i in range(1, n+1):
    res_n += (n + 1 - i) * (n - i) // 2
    res_n %= mod
res_n = (res_n * (m ** 2)) % mod

res_m = 0
for i in range(1, m+1):
    res_m += (m + 1 - i) * (m - i) // 2
    res_m %= mod
res_m = (res_m * (n ** 2)) % mod

res = res_n + res_m
#print(res)

f = [1 for _ in range(n*m)]
for i in range(1, n*m):
    f[i] = f[i-1] * i % mod

res = res * f[n*m-2] * pow(f[k-2], mod-2, mod) * pow(f[n*m-k], mod-2, mod) % mod

print(res)

Measured memory_bytes: 11032
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <algorithm>
#include <set>

using namespace std;

int main() {
  long A, B, C, K;
  cin >> A >> B >> C >> K;
  long maxi = max(max(A, B), C);
  long sum = A + B + C;
  long maxk = maxi << K;
  cout << sum + maxk - maxi << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n",(x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n",(x) ? "Yes" : "No")
#define isIn(x,y,h,w) (x >= 0 && x < h && y >= 0 && y < w)

#define int long long
//using ll = long long;
using P = pair<int,int>;

ostream &operator<<(ostream &os,const P &p){ return os << "(" << p.first << "," << p.second << ")"; }

template<class T> T &chmin(T &a,const T &b){ return a = min(a,b); }
template<class T> T &chmax(T &a,const T &b){ return a = max(a,b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000009;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	int n,m,w,t,v[10],p[10],l[10],x[10],y[10];
	vector<P> mono[10];
	map<string,int> name_to_ind;
	cin >> n >> m >> w >> t;
	for(int i = 0;i < m;i++){
		string s;
		cin >> s >> v[i] >> p[i];
		name_to_ind[s] = i;
	}
	for(int i = 0;i < n;i++){
		cin >> l[i] >> x[i] >> y[i];
		for(int j = 0;j < l[i];j++){
			string r;
			int q;
			cin >> r >> q;
			mono[i].emplace_back(name_to_ind[r],q);
		}
	}
	vector<P> sina;
	for(int i = 1;i < (1 << n);i++){
		vector<int> vec;
		for(int j = 0;j < n;j++){
			if((i >> j) & 1) vec.push_back(j);
		}
		int mint = INF;
		do{
			int sum = 0,px = 0,py = 0;
			for(int j = 0;j < vec.size();j++){
				sum += abs(px - x[vec[j]]) + abs(py - y[vec[j]]);
				px = x[vec[j]]; py = y[vec[j]];
			}
			sum += abs(x[vec.back()]) + abs(y[vec.back()]);
			chmin(mint,sum);
		}while(next_permutation(all(vec)));
		int dp1[10][10010];
		for(int j = 0;j <= m;j++){
			for(int k = 0;k <= w;k++) dp1[j][k] = -INF;
		}
		dp1[0][0] = 0;
		int rieki[10];
		for(int j = 0;j < m;j++) rieki[j] = -INF;
		for(int j = 0;j < n;j++){
			if(!((i >> j) & 1)) continue;
			for(auto mo : mono[j]){
				chmax(rieki[mo.first],p[mo.first] - mo.second);
			}
		}
		for(int j = 0;j < m;j++){
			for(int k = 0;k <= w;k++){
				if(k - v[j] < 0) dp1[j + 1][k] = dp1[j][k];
				else dp1[j + 1][k] = max(dp1[j][k],dp1[j + 1][k - v[j]] + rieki[j]);
			}
		}
		int kachi = -INF;
		for(int j = 0;j <= w;j++) chmax(kachi,dp1[m][j]);
		sina.emplace_back(mint,kachi);
	}
	int dp2[(1 << n) + 5][10010];
	for(int i = 0;i <= sina.size();i++){
		for(int j = 0;j <= t;j++) dp2[i][j] = -INF;
	}
	dp2[0][0] = 0;
	for(int i = 0;i < sina.size();i++){
		for(int j = 0;j <= t;j++){
			if(j - sina[i].first < 0) dp2[i + 1][j] = dp2[i][j];
			else dp2[i + 1][j] = max(dp2[i][j],dp2[i + 1][j - sina[i].first] + sina[i].second); 
		}
	}
	int ans = -INF;
	for(int i = 0;i <= t;i++) chmax(ans,dp2[sina.size()][i]);
	cout << ans << endl;
}


Measured memory_bytes: 13868
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

const int maxn = 2e3 + 5;
LL a[maxn];
LL b[maxn][maxn];

int main(){
    int n;
    LL x,sum = 1LL << 60LL;
    cin >> n >> x;
    for(int i = 1;i <= n;i++) cin >> a[i];
    for(int i = 1;i <= n;i++){
        b[i][0] = a[i];
        for(int k = 1;k <= n - 1;k++){
            int pos = i - k;
            if(pos <= 0) pos = n - abs(pos);
            b[i][k] = min(b[i][k - 1],a[pos]);
        }
    }
    for(int k = 0;k <= n - 1;k++){
        LL ans = 0;
        for(int i = 1;i <= n;i++){
            ans += b[i][k];
        }
        sum = min(sum,ans + x * k);
    }
    cout << sum << endl;
}

Measured memory_bytes: 31616
#include<iostream>
using namespace std;
int main()
{
	int n;
	int a[1000];
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	int sum=0;
	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<n;j++)
		{
			sum+=a[i]*a[j];
		}
	}
	cout<<sum;
}

Measured memory_bytes: 256
import math
import itertools

def load_calc(pat):
    global N
    global pos_data
    
    dist = 0
    for i in range(N-1):
        dist += math.sqrt((pos_data[pat[i]][0]-pos_data[pat[i+1]][0])**2 + (pos_data[pat[i]][1]-pos_data[pat[i+1]][1])**2)
    
    return dist


seq = list()
pos_data = list()

N = int(input())
for i in range(N):
    xy = input().split()
    xy_i = [int(s) for s in xy]
    pos_data.append(xy_i)
    seq.append(int(i))


junretu = list(itertools.permutations(seq))
m = math.factorial(N)

total = 0
for j in range(m):
    total += load_calc(junretu[j])

print(total/m)

Measured memory_bytes: 8052
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0; i<n; ++i) cin>>a[i];
  vector<int> b(n);
  for(int i=0; i<n; ++i) cin>>b[i];
  vector<int> c(n-1);
  for(int i=0; i<n; ++i) cin>>c[i];
  for(int i=0; i<n; ++i) a[i]--;
  
  int ans=0;
  for(int i=0; i<n; ++i){
    ans+=b[a[i]];
  }
  
  for(int i=0; i<n-1; ++i){
    if(a[i]+1==a[i+1]){
      ans+=c[a[i]];
    }
  }
  cout<<ans<<endl;
}
      


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define FOR0(i,n) for(ll i=0;i<n;i++)
#define FOR1(i,n) for(ll i=1;i<=n;i++)
#define FORl(i,l,n) for(ll i=l;i<n;i++)
using namespace std;
#define pi pair<ll,ll>
#define pb push_back
#define ll long long
#define ld long double
#define ff first
#define ss second
#define mp make_pair
#define mst0(x) memset(x,0,sizeof(x));
#define vi vector<ll>
#define sync ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define sp <<" "<<
#define intmax 1e14
ll power(ll num,ll g,ll mod){
  if(g==0)return 1;
  if(g%2==1)return (num*power((num*num)%mod,g/2,mod))%mod;
  return power((num*num)%mod,g/2,mod);
}
 
int main(){
	int n;
	cin>>n;
	int a[n];
	FOR0(i,n) cin>>a[i];
	int dp[n];
	mst0(dp);
	dp[0] = 0;
	dp[1] = abs(a[1]-a[0]);
	FORl(i,2,n) dp[i] = min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
	cout<<dp[n-1];
}

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

#define int long long
#define double long double

using namespace std;

template<class T> string tostr(T x) { stringstream o; o << x; return o.str(); }
template<class T> T sqr(T x) { return x*x; }
template<class T> T mypow(T x, int n) { T r = 1; while (n > 0) { if (n & 1)r = r*x; x = x*x; n >>= 1; }return r; }

int toint(string s) { int v; stringstream i(s); i >> v; return v; }
bool check(int x, int y, int w, int h) { return x >= 0 && y >= 0 && w > x && h > y; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

#define REP(i,a,b)	for(int (i) = (a);i < (b);(i)++)
#define rep(i,n)	REP(i,0,n)
#define PER(i,a,b)	for(int (i) = (a-1);i >= (b);(i)--)
#define per(i,n)	PER(i,n,0)
#define each(i,n)	for(auto &i : n)
#define clr(a)		memset((a), 0 ,sizeof(a))
#define mclr(a)		memset((a), -1 ,sizeof(a))
#define all(a)		(a).begin(),(a).end()
#define dump(val) 	cerr << #val " = " << val << endl;
#define dum(val)	cerr << #val " = " << val;
#define FILL(a,v)	fill(a,a+sizeof(a)/sizeof(*a),v)

const int dx[8] = { +1,+0,-1,+0,+1,+1,-1,-1 };
const int dy[8] = { +0,-1,+0,+1,-1,+1,-1,+1 };
const int mod = 1e9 + 7;
const int INF = 1e9;

// vector<int> stairs(int n){
// 	vector<int> a(n);
// 	rep(i, n) a[]
// }

signed main() {

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i,n){
		cin >> a[i];
	}
	sort(all(a));
	int ma = a.back();
	int mi = a.front();
	map<int, int> mp;
	each(i, a) mp[i]++;
	if(mp.size() == 1 && (n / 2 >= ma || n - 1 == mi) ){
		cout << "Yes" << endl;return 0; 
	}
	if(mp.size() >= 3 || mp[ma] < 2){
		cout << "No" << endl;return 0; 
	}
	if(ma - mi != 1){
		cout << "No" << endl;return 0; 
	}

	int mi_k = mp[mi]-1;
	int ma_k = mp[ma]/2;

	if(mi_k + 1 > mi){
		cout << "No" << endl; return 0;
	}

	if(mi_k + ma_k >= mi){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl; 
	}

	return 0;
}


Measured memory_bytes: 7296
N=int(input())
a=[0]*(N+1)
for x in range(1,100):
    for y in range(1,100):
        for z in range(1,100):
            t=x**2+y**2+z**2+x*y+y*z+z*x
            if t<=N:
                a[t]+=1
for i in a[1:]:
    print(i)

Measured memory_bytes: 9144
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <assert.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
using namespace std;

// #define __DEBUG__

#ifdef __DEBUG__
bool debug_disabled = false;
#else
bool debug_disabled = true;
#endif

#define dbg if (debug_disabled) {} else cerr

void solve() {
    string s, t;
    cin >> s >> t;
    dbg << s.size() << endl;
    dbg << t.size() << endl;

    int lo = 1000000;
    for (int i = 0; i + t.size() <= s.size(); ++i) {
        int changes = 0;
        dbg << "i = " << i << endl;
        for (int j = 0; j < t.size(); ++j) {
            dbg << "\tj = " << j << endl;
            if (s[j + i] != t[j]) ++changes;
            dbg << "\tchanges = " << changes << endl;
        }
        if (changes < lo) lo = changes;
    }
    cout << lo << endl;
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve();
    }

    return 0;
}


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

int n, ans, num;
string s;

int main() {
  cin >> n;
  cin >> s;
  ans = 0;
  rep (i, n) {
    if (s[i] == 'R') num++;
  }
  for (int i = num; i < n; i++) {
    if (s[i] == 'R') ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3716
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	bool flag = false;
	for(int i = 1;i <= b;i++){
		if(a*i%b==c) flag = true;
	}
	if(flag) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
a,b,h,m = map(int,input().split())
import math
xa = a*math.cos((60*h+m)*math.pi/360)
ya = a*math.sin((60*h+m)*math.pi/360)
xb = b*math.cos(m*math.pi/30)
yb = b*math.sin(m*math.pi/30)
print(((xa-xb)**2+(ya-yb)**2)**0.5)

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

#define LC 100
#define AC 30

int main(void)
{
	int n;
	int length, angle;

	int L_out, A_out;

	int i;

	cin >> n;

	for (i = 0; i < n; i++)
	{
		cin >> length >> angle;

		L_out = length % LC;
		A_out = angle % AC;
		length = length / LC;
		angle = angle / AC;

		if (L_out == 0 && A_out == 0)
		{
			cout << length+angle*5 << endl;
		}
		else if (L_out > 0 && A_out > 0)
		{
			printf("%d %d %d %d\n", length + angle * 5, length + angle * 5 + 1, length + angle * 5 + 5, length + angle * 5 + 6);
		}
		else
		{
			if (L_out == 0)
			{
				printf("%d %d\n", length + angle * 5, length + angle * 5 + 5);
			}
			else
			{
				printf("%d %d\n", length + angle * 5, length + angle * 5 + 1);
			}
		}
	}

	return 0;
}


Measured memory_bytes: 3168
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace C_test_For_Atcorder
{

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        const int INF = -1;

        private bool[,] edge;
        private bool[] used;
        private int N;
        private int count = 0;
        public void Solve(ConsoleInput cin)
        {
            N = cin.ReadInt;
            var M = cin.ReadInt;
            edge = new bool[N, N];
            used = new bool[N];
            int[] l;
            for (int i = 0; i < M;i++){
                l = cin.ReadIntArray(2);
                l[0]--;l[1]--;
                edge[l[0], l[1]] = true;edge[l[1], l[0]] = true;
                //Console.WriteLine(l[0] +" "+l[1]);
            }
            Search(0);
            Console.WriteLine(count);
        }

        public void Search(int n){
            used[n] = true;
            bool clear = true;
            for (int j = 0; j < N; j++){
                if (used[j] == false){
                    clear = false;
                    if(edge[n,j]==true){
                        Search(j);
                    }
                }
            }
            if (clear) count++;
            used[n] = false;
        }

    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue inputStream;

        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return (string)inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return (string)inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }

}


Measured memory_bytes: 13140
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  int H,W,N,SR,SC;
  string S,T;
  bool CAN=true;
  cin>>H>>W>>N>>SR>>SC>>S>>T;
  
  int L=1,R=W,U=1,D=H;
  for(int i=N-1; i>=0; --i){
    if(T[i]=='L') R=min(R+1,W);
    if(T[i]=='R') L=max(L-1,1);
    if(S[i]=='L') L++;
    if(S[i]=='R') R--;
    if(R<L) CAN=false;
  }
  for(int i=N-1; i>=0; --i){
    if(T[i]=='U') D=min(D+1,H);
    if(T[i]=='D') U=max(U-1,1);
    if(S[i]=='U') U++;
    if(S[i]=='D') D--;
    if(D<U) CAN=false;
  }
  
  
  if(SC<L || R<SC) CAN=false;
  if(SR<U || D<SR) CAN=false;
  
  if(CAN) COYE;
  else CONO;
  return 0;
}

Measured memory_bytes: 776
h, w = map(int, input().split())
a = [input() for _ in range(h)]

has_black_rows = [False for _ in range(h)]
has_black_columns = [False for _ in range(w)]

for i in range(h):
    for j in range(w):
        if a[i][j] in '#':
            has_black_rows[i] = True
            has_black_columns[j] = True

for i in range(h):
    if has_black_rows[i]:
        for j in range(w):
            if has_black_columns[j]:
                print(a[i][j], end='')
        print()


Measured memory_bytes: 4468
nbills, sum_ = map(int, input().rstrip("\n").split())

for i in range(nbills + 1):
    for j in range(nbills - i + 1):
        k = (sum_ - (10000 * i + 5000 * j)) // 1000
        if (i + j + k) == nbills:
            print(i, j, k)
            break
    else:
        continue
    break
else:
    print(-1, -1, -1)


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

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

#define MAX 100001
long long INF = 1ll << 62;
long long dp[MAX+100];
int N,K;

int main(){
  cin >> N >> K;
  int h[N+K+1];

  dp[1] = 0;   //dp[0]とh[0]は考えるのが面倒なので無視
  int v;
  for(int i = 1; i < N+1; i++){ cin >> v; h[i] = v;}
  for(int i = N+1; i < N+K+1; i++){h[i] = INF;}
  for(int i = 2; i < N+K+1; i++){ dp[i] = INF;}

  dp[2] = abs(h[2]-h[1]);   //2番目の足場に行く方法は一通りしかない

  for(int i = 1; i < N+1; i++){   //初めのマスはi = 1
    for(int j = 1; j <= K; j++){
      chmin(dp[i+j], dp[i]+abs(h[i]-h[i+j]));     //今回は比較先を移動先i+jにする
    }
  }

  cout << dp[N] << endl;
  return 0;
  
  
}

Measured memory_bytes: 1408
from sys import exit
N, M = map(int, input().split())
ans = ["a" for i in range(N)]
if M == 0:
  print(10 ** (N - 1) if N > 1 else 0)
  exit()
for i in range(M):
  s, c = map(int, input().split())
  if ans[s - 1] == "a":
    ans[s - 1] = str(c)
  elif ans[s - 1] != str(c):
    print(-1)
    exit()
if ans[0] == "a":
  ans[0] = "1"
if ans[0] == "0":
  if N != 1:
    print(-1)
    exit()
  else:
    print(0)
    exit()
ans = [a.replace("a", "0") for a in ans]
ans = int("".join(ans))
print(ans if 10 ** N > ans >= 10 ** (N - 1) else -1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

int main(){
	string s, t;cin >> s >> t;
	int slen = s.size(), tlen = t.size();
	vvi app(slen+1, vector<int>(26,0));
	for(int i = slen - 1;0 <= i;i--){
		rep(j, 26){
			if(s.at(i) - 'a' == j)app.at(i).at(j) = i+1;
			else app.at(i).at(j) = app.at(i+1).at(j);
		}
	}
	/*
	rep(i,slen+1){
		rep(j,26) cout << app.at(i).at(j);
		cout << endl;
	}*/
	
	bool ok = true;
	ll ans = 0;
	int state = 0;
	rep(i, tlen){
		int ch = t.at(i) - 'a';
		if(!app.at(0).at(ch)){
			ok = 0;break;
		}
		if(app.at(state).at(ch) == 0){
			ans += slen;
			state = app.at(0).at(ch);
			if(i == tlen - 1) ans += app.at(0).at(ch);
		}
		else{
			if(i == tlen - 1) ans += app.at(state).at(ch);
			state = app.at(state).at(ch);
		}
		//cout << state << " " << ans << endl;
	}
	
	cout << (ok ? ans : -1) << endl;
	
	return 0;
}

Measured memory_bytes: 15744
n, k = map(int, input().split())
a = list(map(int, input().split()))

# imos法で区間和を計算する、をk回まで繰り返す
cnt = 0
while cnt < k:
    imos = [0] * (n + 1)
    for i in range(n):
        imos[max(i - a[i], 0)] += 1
        imos[min(i + a[i] + 1, n)] -= 1

    for i in range(n):
        imos[i + 1] += imos[i]

    a = imos[0:n]
    cnt += 1

    if min(a) == n:
        # a = [n, n, n, ..., n] になったら打ち切り
        break
print(*a)


Measured memory_bytes: 219496
#include<iostream>
#include<string.h>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#define INF INT_MAX
using namespace std;

int N;
int c[12];
int mem[100010];

int f(int n){
	if (mem[n] != 0) return mem[n];
	if (n == 0) return 0;
	int res = INF;
	for (int i = 0; i < 12; i++){
		if (n < c[i]) break;
		res = min(res, f(n - c[i])+1);
	}
	return mem[n] = res;
}

int main(){
	c[0] = 1;
	for (int i = 1; i <= 6; i++) c[i] = (int)pow(6, i);
	for (int i = 1; i <= 5; i++) c[i + 6] = (int)pow(9, i);
	sort(c, c + 12);

	cin >> N;

	cout << f(N) << endl;

	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9012337203685477580
using ll = long long;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, H;
    cin >> N >> H;
    vector<pair<int,bool>> A(2*N);
    for (int i = 0; i < N; i++)
    {
        int a, b;
        cin >> a >> b;
        A[i].first = a;
        A[i].second = false;
        A[i+N].first = b;
        A[i+N].second = true;
    }
    sort(RALL(A));
    int ans = 0;
    for (int i = 0; i < 2*N; i++)
    {
        if (A[i].second) {
            H -= A[i].first;
            ans++;
            if (H <= 0) {
                break;
            }
        }
        else {
            ans += (H + A[i].first - 1) / A[i].first;
            break;
        }
    }
    cout << ans << endl;
    getchar(); getchar();
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
long long int gcd(long long int a,long long int b) {
  if (a % b == 0) return b;
  else return gcd(b, a % b);
}

long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}

int main() {
  long long int a, b;
	while(cin >> a >> b) {
	  cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
  return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <algorithm>
#include <queue>
using namespace std;
int N, K; 
int D[10]; 
bool iroha(int N){
	bool ok = true; 
	while(N > 0){
		for(int i = 0; i < K; i++){
			if(N % 10 == D[i]){ok = false;}
		}
		N /= 10; 
	} 
	return ok; 
	}
int main() {
	cin >> N >> K; 
	for(int i = 0; i < K; i++){
		cin >> D[i]; 
	}
	for(int i = N; i < 1000000; i++){
		if(iroha(i)){
			cout << i << endl; 
			break;
		}
	}
}

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

const int N = 10005;

using namespace std;

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

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<string>
#include<cmath>
using namespace std;
int ans;
string a,b;
int main()
{	
	cin>>a>>b;
	a+=b;
	sscanf(a.c_str(),"%d",&ans);
	puts(int(sqrt(ans))<sqrt(ans)?"No":"Yes");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m1(x) memset(x,-1,sizeof(x))
const int INF = 1e9 + 1;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793;

int main(){
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double k = (h/6-m/30)*PI;
  double ans = sqrt(a*a + b*b - 2*a*b*cos((h/6-11*m/360)*PI));
  printf("%.15lf\n", ans);
}
  

Measured memory_bytes: 4256
//#pragma GCC optimize(2)
// Happy TLE and WA every day!
// by: zxb the vegetable chicken
#include<bits/stdc++.h>
#define mp              make_pair
#define rep(i,n)        for(int i = 0; i < n; i++)
#define foreach(i,c)    for(VAR(i, (c).begin()); i != (c).end(); ++i)
#define BINF            0x7fffffff
#define INF             0x3f3f3f3f
#define LINF            4557430888798830399
#define END(s)          {cout<<s; return 0;}
#define CON(s)          {cout<<s; continue;}
#define BRE(s)          {cout<<s; break;}
#define pb              push_back
#define All(a)          a.begin(), a.end()  //with A in CAPITAL!!!
#define sz(a)           (int)a.size()
#define F               first
#define S               second
#define Time            clock()/CLOCKS_PER_SEC
//#define usingFiles
using namespace std;

typedef unsigned int ui;
typedef pair<int, int> pii;
typedef long long ll;

inline bool Read(int& x){
	x = 0;
	int c;
	int sign = 1;
	while( (c = getchar()) < '0' || c > '9' ) if(c == '-') sign = -1;
	x = c ^ '0';
	while( (c = getchar()) >= '0' && c <= '9' ) x = (x<<3) + (x<<1) + (c ^ '0');
	x *= sign;
	return 1;
}

inline bool Write(int x){
	if(x >= 10) Write(x / 10);
	putchar(x % 10 + '0');
	return 1;
}

const int rp = 666666;
const bool debug = 1;
const bool I_good_vegetable_a = 1;

int a[4];

signed main(){
	ios::sync_with_stdio(false);
	#ifdef usingFiles
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	rep(i, 4) cin >> a[i];
	sort(a, a + 4);
	if(a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9) cout << "YES\n";
	else cout << "NO\n";
	return 0;
}

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

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

    int h, a;
    cin >> h >> a;

    cout << 1 + h/a -(h%a==0) << endl;

    return 0;
}

Measured memory_bytes: 256
a, b = gets.split.map(&:to_i)

lower = [a * 100 / 8, b * 10].max
upper = [(a+1) * 100 / 8, (b+1) * 10].min

(lower..upper).each do |i|
  if i * 8 / 100 == a && i / 10 == b
    puts i
    exit
  end
end

puts -1


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

int main() {
  int n;
  cin >> n;
  vector<int> A;
  for (int i=0; i<n; i++) {
    int tmp;
    cin >> tmp;
    A.push_back(tmp);
  }

  sort(A.begin(), A.end());

  int ptr=0, res=0;
  while(ptr<n) {
    int cc = A[ptr];
    int f = 0;
    while(ptr<n && A[ptr]==cc) {
      f++;
      ptr++;
    }
    res += f%2;
  }

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


Measured memory_bytes: 892
#include<bits/stdc++.h>
    using namespace std;
     
    int n , arr[2][111];
     
    int Do(int i , int j)
    {
    	if(i>2 or j>n) return 0;
    	return max(Do(i+1 , j) + arr[i][j] , Do(i , j+1) + arr[i][j]);
    }
     
    int main()
    {
    	cin >> n;
    	for(int i = 1 ; i<= 2; i++) for(int j = 1 ; j <= n ; j++) cin >> arr[i][j];
    	cout << Do(1,1) << endl;
    }

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int S = stdIn.nextInt();
		int W = stdIn.nextInt();
		if(S <= W){
			System.out.println("unsafe");
		}
		else{
			System.out.println("safe");
		}
		stdIn.close();
	}
}

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

int main(){
    int N,K;
    cin >> N >> K;
    int h[100000],count[100000];
    rep(i,N){
        cin >> h[i];
    }
    count[0]=0;
    count[1]=abs(h[1]-h[0]);
    for(int i=2;i<N;i++){
        count[i]=count[i-1]+abs(h[i]-h[i-1]);
        for(int j=2;j<=K && i-j>=0;j++){
            if(count[i]>count[i-j]+abs(h[i]-h[i-j])){
                count[i]=count[i-j]+abs(h[i]-h[i-j]);
            }
        }
    }
    cout << count[N-1] << endl;
}

Measured memory_bytes: 1024
H = float(input())
W = float(input())
N = float(input())

if H > W:
  d = H
else:
  d = W

c = N / d

if c - c//1 == 0:
  print(int(c))
else:
  print(int(c//1)+1)




#print('H=', H, 'W=', W, 'N=', N)


Measured memory_bytes: 2940
if isfile("mystdin.txt");mystdin=open("mystdin.txt","r");redirect_stdin(mystdin);end
pI(x)=parse(Int,x)
pM(x::Array{SubString{String},1})=map(pI,x)
function main()
  m,k=pM(split(readline()))
  println(k*(k-1)^(m-1))
end
main()
if isdefined(Base, :mystdin);close(mystdin);end

Measured memory_bytes: 164400
import java.util.Scanner;

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

	System.out.print(a * b + " ");
	System.out.println(2*(a + b));
	}
}

Measured memory_bytes: 25880
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    string s;
    cin >> s;
    unordered_set<char> cnt;
    for(char c: s)
        cnt.insert(c);
    if (cnt.size() == 1)
        cout << "No" << endl;
    else
        cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>

using namespace std;

const int maxn=1e5+50;
char s[maxn];
int cnt[maxn];

int main(){
    scanf("%s",s);
    int len=strlen(s);
    memset(cnt,0,sizeof(cnt));
    for (int i=0;i<len;i++){
        cnt[s[i]]++;
    }
    for (char i='a';i<='c';i++){
        for (char j='a';j<='c';j++){
            if (cnt[i]-cnt[j]>1){
                printf("NO\n");
                return 0;
            }
        }
    }
    printf("YES\n");
    return 0;
}

Measured memory_bytes: 768
#include <stdio.h>

int main()
{
	int r,c;
	int i,j;
	int x[100][100];
	int r_sum = 0;
	int c_sum = 0;
	int n_sum = 0;
	
	scanf("%d %d",&r,&c);
	
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&x[i][j]);
			n_sum += x[i][j];
		}
	}
	
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			r_sum += x[i][j];
			printf("%d ",x[i][j]);
		}
		printf("%d\n",r_sum);
		r_sum = 0;
	}
	
	for(i=0;i<c;i++){
		for(j=0;j<r;j++){
			c_sum += x[j][i];
		}
		printf("%d ",c_sum);
		c_sum = 0;
	}
	printf("%d\n",n_sum);
	return 0;
}

Measured memory_bytes: 636