akhauriyash/Code-Regression huggingface dataset:
import sys
readline = sys.stdin.readline
def solve():
    n = int(input())
    a = sorted(int(readline()) for _ in range(n))
    c0 = n // 2 - 1
    c1 = n // 2
    c2 = n // 2 + 1
    ans = 0
    if n & 1:
        ans = sum(a[c2 + 1:]) * 2 - sum(a[:c0]) * 2 - a[c0] + a[c2] + max(-a[c0] + a[c1], - a[c1] + a[c2])
    else:
        ans = sum(a[c1 + 1:]) * 2 - sum(a[:c0]) * 2 - a[c0] + a[c1]
    return ans
print(solve())


Measured memory_bytes: 7400
#include<bits/stdc++.h>
#define max 1000000009
using namespace std;
 
int main()
{
    long n,h[100005];
    cin>>n;
    for(long i=0;i<n;i++)
        cin>>h[i];
    long dp[100005];
    for(long i=0;i<n;i++)
        dp[i]=max;
    dp[0]=0;
    dp[1]=dp[0]+abs(h[1]-h[0]);
    for(long i=2;i<n;i++)
    {
        long val1=dp[i-1]+abs(h[i]-h[i-1]);
        long val2=dp[i-2]+abs(h[i]-h[i-2]);
        if(dp[i]>val1)
            dp[i]=val1;
        if(dp[i]>val2)
            dp[i]=val2;
    }
    cout<<dp[n-1];
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{   
    
    ll n;
    cin>>n;
    vector<int> arr(n);
    vector<int> lmax(n);
    vector<int> rmax(n);
    for(int i = 0 ; i <  n ; i++)
    {
        cin>>arr[i];
        if(i==0) lmax[i] = arr[i];
        else lmax[i] = max(lmax[i-1],arr[i]);
        
    }
    for(int i = n-1 ; i>=0 ; i--)
    {
        if(i == n-1) rmax[i] = arr[i];
        else rmax[i] = max(rmax[i+1],arr[i]);
    }
    for(int i = 0 ; i < n ; i++)
    {
        if(i==0) arr[i] = rmax[i+1];
        else if(i==n-1) arr[i] = lmax[i-1];
        else arr[i] = max(rmax[i+1],lmax[i-1]);
    }
    for(auto x: arr) cout<<x<<endl;
    exit(0);
    return 0;
}


Measured memory_bytes: 3968
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on

int N;
int p[MAX_N];

int main(void)
{
  cin >> N;
  REP(i, N) cin >> p[i];
  int sum = 0;
  int m = 0;
  for (int i = 0; i < N; i++) {
    m = max(m, p[i]);
    sum += p[i];
  }
  sum -= (m / 2);
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<vector>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int time[86401]={0},n,start,end;
	string str[2],se;
	vector<string> vec;
	string h,m,s,eh,em,es;
	while(cin>>n,n){
		cin.ignore();
		rep(i,86401)time[i]=0;
		string tmp="";
		rep(i,n){
			getline(cin,se);
			rep(j,se.size()){
				if(se[j]==' '){
					str[0]=tmp;
					tmp="";
				}else{
					tmp+=se[j];
				}
			}
			str[1]=tmp;
			tmp="";
			vec.clear();
			rep(j,2){
				rep(i,str[j].size()){
					if(str[j][i]==':'){
						vec.push_back(tmp);
						tmp="";
					}else{
						tmp+=str[j][i];					
					}
				}
				vec.push_back(tmp);
				tmp="";
			}
			h=vec[0];
			m=vec[1];
			s=vec[2];
			eh=vec[3];
			em=vec[4];
			es=vec[5];
			start=((int)(h[0]-'0')*10+(int)(h[1]-'0'))*60*60+((int)(m[0]-'0')*10+(int)(m[1]-'0'))*60+((int)(s[0]-'0')*10+(int)(s[1]-'0'));
			time[start]++;
			end=((int)(eh[0]-'0')*10+(int)(eh[1]-'0'))*60*60+((int)(em[0]-'0')*10+(int)(em[1]-'0'))*60+((int)(es[0]-'0')*10+(int)(es[1]-'0'));
			time[end]--;
		}
		rep(i,86401){
			time[i+1]+=time[i];
		}
		int maximum=0;
		rep(i,86401){
			maximum=max(maximum,time[i]);
		}
		cout<<maximum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1564
program main
integer :: r,g,b,n,i,j,tmp,ans=0
read(*,*) r,g,b,n
do i=0,n
	do j=0,n
    	tmp = n - r*i -g*j
        if(tmp>=0 .and. mod(tmp,b)==0) then
        	ans = ans + 1
        end if
    end do
end do
write(*,*) ans
end program main

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

int main(){

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

int m;
  cin >> m;
vector<string> t(m);
for(int i = 0;i < m ;i++){
  cin >> t[i];
}
vector<int>ans(n);
for(int i = 0;i < n;i++){
  int plus = 0;
  int minus = 0;
  for(int j = 0;j < n;j++){
    if(s[i] == s[j]){
      plus++;
    }
  }
    for(int k = 0;k < m;k++){
    if(s[i] == t[k]){
      minus++;
    }
  }
ans[i] = plus-minus;
}
sort(ans.begin(),ans.end());

if(ans[n-1] < 0){
  cout << 0 << endl;
}
else{
  cout << ans[n-1] <<endl;
}
        
}

Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if (n, x) == (0, 0):
        break
    ways = {tuple(sorted([a, b, c])) for a in range(1, n+1) for b in range(1, n+1) for c in range(1, n+1) if sum((a, b, c)) == x and len({a, b, c}) == 3}
    print(len(ways))

Measured memory_bytes: 7832
from bisect import bisect_left, bisect_right

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

ans = 0

for b in B:
    ans += bisect_left(A, b) * (N - bisect_right(C, b))

print(ans)


Measured memory_bytes: 23232
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}
typedef pair<ll, ll> P;
 
bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}
int main() {
    ll N; cin >> N;
    vector<pair<ll,ll>> v;
    for (int i = 0; i < N; ++i) {
        ll a, b; cin >> a >> b;
        v.push_back(make_pair(a, b));
    }
    sort(v.begin(), v.end(), pairCompare);
    ll sum = 0;
    bool y = true;
    for (auto x: v) {
        // cout << x.first << ":" << x.second << endl;
        sum += x.first;
        y &= sum <= x.second;
    }
    if (y) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
using namespace std;
typedef long long       ll;
#define MOD ((int)1e9+7)
#define N ((int)2e5+123)
void reads(string& x){ char kk[N]; scanf("%s",kk); x = kk;}

int ans, h,w,k,ca,cb, q;
string s[10];
void solve(){
    scanf("%d%d%d", &h,&w,&k);
    for(int i=0;i<h;i++){
        reads(s[i]);
        for(int j=0;j<w;j++){
            q+=(s[i][j] == '#');
        }
    }
    /*
    printf("%d %d %d\n",h,w,k);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) printf("%c",s[i][j]);
        printf("\n");
    }
    */
    for(int i=0;i<(1<<h);i++){
        ca=0;
        for(int a=0;a<h;a++){
            if(i&(1<<a)){
                for(int b=0;b<w;b++){
                    ca+=(s[a][b] == '#');
                }
            }
        }
        //printf("\nH -> %d %d\n\n",i,ca);
        for(int j=0;j<(1<<w);j++){
            cb=0;
            for(int a=0;a<w;a++){
                if(j&(1<<a)){
                    for(int b=0;b<h;b++){
                        if(i&(1<<b))continue;
                        cb+=(s[b][a] == '#');
                    }
                }
            }
            //printf("W -> %d %d %d\n",j,cb,q-ca-cb);
            if((q-ca-cb) == k)ans++;
        }
    }
    printf("%d\n", ans);
}

int main(){
    ios_base::sync_with_stdio(0);
    int t = 1; //scanf("%d",&t);
    for(int caso=1;caso<=t;caso++){
        solve();
    }
}

Measured memory_bytes: 3812
#include<iostream>
#include<stdio.h>
#include<cmath>
#include <math.h>
#include<iomanip>
//#define M_PI 3.14159265358979
#define deg2rad(a) ( (a) / 180.0 * M_PI )
using namespace std;
int main(){
double a,b,c;
double s,l,z;
cout << setprecision(12);
cin >> a >> b >> c;
s = a * b * sin(deg2rad(c))/2;
printf("%.8f\n",a * b * sin(deg2rad(c))/2);
l = sqrt(a * a + b * b - 2 * a * b * cos(deg2rad(c)));
printf("%.8f\n",l + a + b);
z = s * 2 / a;
printf("%.8f\n",z);
return 0;
}




Measured memory_bytes: 3444
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;

#define FOR(i, a, b) for(int (i)=(a);(i)<(b);(i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)
#define REP(i, n) FOR((i), 0, (n))

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template<class T>
void print_container(T &container, string delim=" ") {
    bool first = true;
    for(auto &t: container){
        if(!first){
            cout << delim;
        }
        first = false;
        cout << t;
    }
    cout << endl;
}

int main() {
    int n, m;
    cin >> n >> m;
    int left = -1, right = n+1;
    REP(i, m){
        int l, r;
        cin >> l >> r;
        left = max(left, l);
        right = min(right, r);
    }
    cout << max(0, right - left + 1) << endl;
    return 0;
}

Measured memory_bytes: 256
/**
*    author:  y_takano
*    created: 19.06.2020 15:01:26
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)

using namespace std;

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

    int n, num, tmp;
    char mark;
    cin >> n;

    vector<vector<int> > v(4, vector<int>(13, 0));

    REP(i, n)
    {
        cin >> mark >> num;
        switch (mark)
        {
        case 'S':
            tmp = 1;
            break;
        case 'H':
            tmp = 2;
            break;
        case 'C':
            tmp = 3;
            break;
        case 'D':
            tmp = 4;
            break;
        }
        v[tmp - 1][num - 1] = 1;
    }

    REP(i, 4)
    {
        REP(j, 13)
        {
            if (v[i][j] == 0)
            {
                switch (i)
                {
                case 0:
                    cout << 'S' << ' ' << j + 1 << endl;
                    break;
                case 1:
                    cout << 'H' << ' ' << j + 1 << endl;
                    break;
                case 2:
                    cout << 'C' << ' ' << j + 1 << endl;
                    break;
                case 3:
                    cout << 'D' << ' ' << j + 1 << endl;
                    break;
                }
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3108
#require "pry-byebug"

A,B = gets.split.map(&:to_i)
a_min = (A / 0.08).ceil
b_min = (A / 0.1).ceil
max = (100 / 0.1).ceil
b_num = b_min
while b_num <= max
  tmp = (b_num * 0.08).floor
  if tmp == A && (b_num * 0.1).floor == B
    puts b_num
    exit
  end
  break if A < tmp
  break if B < tmp
  b_num += 1
end
puts "-1"



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

using namespace std;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  if (n % 2 != 0) {
    puts("No");
    return 0;
  }

  for (int i = 0; i < n / 2; ++i) {
    if (s[i] != s[i + n / 2]) {
      puts("No");
      return 0;
    }
  }
  puts("Yes");
  return 0;
}



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

int main(){
   int n, b;
   bool cards[4][14];
   char a;
   
   for(int i = 0; i < 4; i++){
       for(int j = 0; j < 15; j++){
           cards[i][j] = false;
       }
   }
   
   cin >> n;
    for(int i = 0; i < n; i++){
       cin >> a >> b;
       if (a == 'S') cards[0][b] = true;
       if (a == 'H') cards[1][b] = true;
       if (a == 'C') cards[2][b] = true;
       if (a == 'D') cards[3][b] = true;
    }
    
    for(int i = 0; i < 4; i++){
       for(int j = 1; j<= 13; j++){
            if(cards[i][j] == false){
                if( i == 0)   a = 'S';
                if( i == 1)   a = 'H';
                if( i == 2)   a = 'C';
                if( i == 3)   a = 'D';
            cout << a << " " << j << endl;
            }
            else continue;
       }
       
   }
   
   return 0;
}


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

int main(){
	int N, K, i;
	scanf("%d%d", &N, &K);
	vector<int> l(N);
	for(i = 0; i < N; i++){
		scanf("%d", &l[i]);
	}
	sort(l.begin(), l.end());
	int ans = 0;
	for(i = N - 1; i >= N - K; i--){
		ans += l[i];
	}
	printf("%d\n", ans);
	return 0;
}

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

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

    int_fast16_t m_hat = INT_FAST16_MAX;
    int_fast16_t t_hat;
    int_fast32_t t;
    std::bitset<32> bit;
    for(auto i = 0; i < n; i++){
        std::cin >> t;
        bit = t;
        for(t_hat = 0; (t_hat < 32) && !bit[t_hat]; t_hat++){}
        m_hat = std::min(m_hat,t_hat);
    }
    std::cout << m_hat << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
const int MAXN = 100010;
 
int n, m;
 
bool marc[MAXN];
 
vector< int > path[2];
vector< int > adj[MAXN];
 
void DFS(int cur, int t)
{
	marc[ cur ] = true;
	path[ t ].push_back( cur );
 
	for(int i = 0 ; i < adj[cur].size() ; i++)
	{
		int viz = adj[cur][i];
 
		if( !marc[viz] ) return void( DFS( viz , t ) );
	}
}
 
int main()
{
	scanf("%d %d",&n,&m);
 
	for(int i = 1 ; i <= m ; i++)
	{
		int U, V;
		scanf("%d %d",&U,&V);
 
		adj[ U ].push_back( V );
		adj[ V ].push_back( U );
	}
 
	DFS( 1 , 0 );
	DFS( 1 , 1 );
 
	reverse( path[1].begin() , path[1].end() );
	path[1].pop_back();
  
	printf("%d\n",path[0].size() + path[1].size());
 
	for(int i = 0 ; i < path[1].size() ; i++)
		printf("%d ",path[1][i]);
 
	for(int i = 0 ; i < path[0].size() ; i++)
		printf("%d ",path[0][i]);
}

Measured memory_bytes: 9720
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

bool check(const string& S){
    int N=S.length();
    for (int i = 0; i < N / 2; ++i) {
        if(S[i]!=S[N-1-i]) return false;
    }
    return true;
}

int main() {
    string S; cin>>S;
    int N = S.length();

    if(!check(S)){
        cout<<"No"<<endl;
        return 0;
    }

    if(!check(S.substr(0,N/2))){
        cout<<"No"<<endl;
        return 0;
    }

    if(!check(S.substr(N/2+1,N/2))){
        cout<<"No"<<endl;
        return 0;
    }

    cout<<"Yes"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
const ll mod = 1e9 + 7;
template<class T> void add(T &a, T b) { a = (a + b) % mod; }

int F[10];
ll dp[105][105];

int main(){
  int H, W, K;
  cin >> H >> W >> K;
  F[0] = F[1] = 1;
  rep(i, 2, 10) F[i] = F[i - 1] + F[i - 2];
  dp[0][1] = 1;
  rep(i, 0, H) {
    rep(j, 1, W + 1) {
      if(j - 1 >= 1) add(dp[i + 1][j - 1], F[j - 2] * F[W - j] * dp[i][j]);
      add(dp[i + 1][j], F[j - 1] * F[W - j] * dp[i][j]);
      if(j + 1 <= W) add(dp[i + 1][j + 1], F[j - 1] * F[W - j - 1] * dp[i][j]);
    }
  }
  cout << dp[H][K] << endl;
  return 0;
}


Measured memory_bytes: 384
// Touitsu

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int n;
string a, b, c;

int main() {
    cin >> n >> a >> b >> c;

    int cnt = 0;

    for (int i = 0; i < n; i++) {
        if (a[i] == b[i] && b[i] == c[i]) {
            continue;
        }
        if (a[i] != b[i] && b[i] != c[i] && c[i] != a[i]) {
            cnt += 2;
            continue;
        }
        cnt += 1;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define pb push_back
#define ss second
#define ff first
#define INF 300000000000001
#define ll_max 9000000000000000001
#define mod 998244353
#define PI 3.14159265358979323846L
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define db(args...) {string _ss = #args; replace(_ss.begin(), _ss.end(), ',' , ' '); stringstream ___s(_ss) ; debug(___s, args);}
using namespace std;
typedef vector<pair<ll,ll> > vll;
typedef vector<pair<int,int> > vii ;
typedef pair<ll,ll> pll;
const ll N = 300001;
const ll M = 1;
struct point {
    ll x, y;
    ll i;
};

void debug(stringstream &s){}
template <typename T, typename... Args>
void debug(stringstream &s, T a, Args... args)
{
    string word;
    s >> word;
    cout << word << " = " << a << endl;
    debug(s, args...);
}

ll fast_exp(ll x, ll n)
{
    if(n == 0) return 1;
    else if(n & 1)
        return fast_exp(x, n - 1) * x % mod;
    else
    {
        ll tmp = fast_exp(x, n >> 1);
        return tmp * tmp % mod;
    }
}

int main()
{
    fast;
    int _ = 1;
    //cin >> _;
    //int test = 0;
    while(_--)
    {
        ll n, m, x = 0, y = 0, k;
        cin >> n >> m;
        if(m >= n) cout << "unsafe";
        else cout << "safe";;
    }
    return 0;
}


Measured memory_bytes: 3648
n, k = gets.split(" ").map(&:to_i)
balls = gets.split(" ").group_by(&:itself).sort { |a, b| b[1].size <=> a[1].size }
change_target = balls[k..-1]
result = change_target&.map{ |v| v[1].size }&.inject(&:+) || 0
puts result

Measured memory_bytes: 56816
(defun create-ns (end lst &optional (acc nil) (i 0))
  (cond ((= i end) (reverse (cons 0 acc)))
        ((null lst) (reverse (append (loop repeat (1+ (- end i)) collect 0) acc)))
        ((= i (car lst)) (create-ns end (cdr lst) (cons 1 acc) (1+ i)))
        (t (create-ns end lst (cons 0 acc) (1+ i)))))


(defun cal-left (q lst &optional (acc 0))
  (if (= q 0)
    acc
    (cal-left (1- q) (cdr lst) (+ (car lst) acc))))


(defun cal-right (r lst &optional (acc 0))
  (if (= r (length lst))
    acc
    (cal-right (1+ r) lst (+ (nth r lst) acc))))



(let* ((n (read))
       (m (read))
       (x (read))
       (ms (sort (loop repeat m
                       collect (read))
                 #'<))
       (ns (create-ns n ms))
       (left (cal-left x ns))
       (right (cal-right x ns)))

  (format t "~A~%" (min left right)))



Measured memory_bytes: 24408
// ====================================
//   author: M_sea
//   website: https://m-sea-blog.com/
// ====================================
#include <bits/stdc++.h>
#define file(x) freopen(#x".in","r",stdin); freopen(#x".out","w",stdout)
using namespace std;
typedef long long ll;

int read() {
	int X=0,w=1; char c=getchar();
	while (c<'0'||c>'9') { if (c=='-') w=-1; c=getchar(); }
	while (c>='0'&&c<='9') X=X*10+c-'0',c=getchar();
	return X*w;
}

const int N=100000+10;

int n,T,a[N];

int main() {
	n=read(),T=read();
	for (int i=1;i<=n;++i) a[i]=read();
	int mx=0,ans=0;
	for (int i=2,mn=a[1];i<=n;++i) {
		if (a[i]-mn>mx) mx=a[i]-mn,ans=1;
		else if (a[i]-mn==mx) ++ans;
		mn=min(mn,a[i]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4148
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in); 

		int n = sc.nextInt();
		int w = sc.nextInt();

		int[] dp = new int[w + 1];
		for (int i = 0; i < n; i++) {
			int v = sc.nextInt();
			int wi = sc.nextInt();
					
			for (int j = wi; j <= w; j++) {
				dp[j] = Math.max(dp[j], dp[j - wi] + v);
			}
		}
		
		System.out.println(dp[w]);

		sc.close();
	}
}

Measured memory_bytes: 20636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
const int MAXE = 2020;
const int MAXV = 1010;
struct edge {
  int from;
  int to;
  int cost;
};
edge es[MAXE];
int d[MAXV];
int V, E;
void shortest_path(int s){
  for(int i=0;i<=V;i++) d[i]=1e9;
  d[s]=0;
  int cnt=0;
  while(true){
    cnt++;
    if(cnt > E + 1) {
        cout<<"NEGATIVE CYCLE"<<endl;
        exit(0);
    }
    bool update=false;
    for(int i=0;i<E;i++){
      if(d[es[i].from]!=1e9&&d[es[i].to]>d[es[i].from]+es[i].cost){
        d[es[i].to]=d[es[i].from]+es[i].cost;
        update=true;
      }
    }
    if(!update)break;
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int r;
  cin>>V>>E>>r;
  FOR(i,0,E){
      cin>>es[i].from>>es[i].to>>es[i].cost;
  }
  shortest_path(r);
  FOR(i,0,V){
      if(d[i] == 1e9) cout<<"INF"<<endl;
      else cout<<d[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 3212
import math

s = int(input())

MOD = 10**9+7

maximum = int(s/3)

ans = 0
for i in range(maximum):
  ans += (math.factorial(i + s-(i*3+3))//(math.factorial(i)*math.factorial(s-(i*3+3))))%MOD

print(int(ans)%(10**9+7))


Measured memory_bytes: 9164
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H, W;
  cin >> H >> W;
  vector<vector<char>> vec(H,vector<char>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      cin >> vec.at(i).at(j);
    }
  }
  
  vector<vector<bool>> seen(H,vector<bool>(W));
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      seen.at(i).at(j) = false;
    }
  }
  
  int64_t ans = 0;
  pair<int,int> P;
  queue<pair<int,int>> Q;
  vector<int> dx = {0,1,0,-1};
  vector<int> dy = {1,0,-1,0};
  
  for(int i=0; i<H; i++){
    for(int j=0; j<W; j++){
      if(seen.at(i).at(j)){
        continue;
      }
      if(vec.at(i).at(j) == '#'){
        seen.at(i).at(j) = true;
        int64_t white = 0;
        int64_t black = 1;
        for(int x=0; x<4; x++){
          int xx = i + dx.at(x);
          int yy = j + dy.at(x);
          if(xx >= 0 && xx < H && yy >= 0 && yy < W){
            if(seen.at(xx).at(yy)){
              continue;
            }
            if(vec.at(xx).at(yy) == '.'){
              white++;
              seen.at(xx).at(yy) = true;
              P = make_pair(xx,yy);
              Q.push(P);
            }
          }
        }
        int q_size = white;
        int cnt = 0;
        bool kuro = false;
        while(Q.size()){
          /*cout << endl;
          cout << cnt << " "<< q_size<< endl;
          cout << "kuro" << kuro << endl;
          for(int a=0; a<H; a++){
            for(int b=0; b<W; b++){
              cout << seen.at(a).at(b);
            }
            cout << endl;
          }*/
          P = Q.front();
          //cout << P.first << " " << P.second << endl;
          Q.pop();
          cnt++;
          int a = P.first;
          int b = P.second;
          for(int k=0; k<4; k++){
            int nx = a + dx.at(k);
            int ny = b + dy.at(k);
            if(nx >= 0 && nx < H && ny >= 0 && ny < W){
              if(seen.at(nx).at(ny)){
                continue;
              }
              if(kuro){
                if(vec.at(nx).at(ny) == '.'){
                  P = make_pair(nx,ny);
                  Q.push(P);
                  seen.at(nx).at(ny) = true;
                  white++;
                }
              }
              else{
                if(vec.at(nx).at(ny) == '#'){
                  P = make_pair(nx,ny);
                  Q.push(P);
                  seen.at(nx).at(ny) = true;
                  black++;
                }
              }
            }
          }
          if(cnt == q_size){
            //cout << 777 << endl;
            q_size = Q.size();
            cnt = 0;
            if(kuro){
              kuro = false;
            }
            else{
              kuro = true;
            }
          }
        }
      //cout << black << " " << white << endl;
      ans += black * white;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()




int main(void){
	int N;
    cin >> N;
    vector<vector<int>> A;
    rep(i,N){
        int x;
        cin >> x;
        vector<int> r;
        r.push_back(x);
        r.push_back(i+1);
        A.push_back(r);
    }

    sort(all(A));

    rep(i,N){
        cout << A[i][1] << endl;
    }

    return 0;
}


Measured memory_bytes: 8496
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin>>n;
  
  map<string,int> m;
  
  string s;
  char c;
  rep(i,n){
    cin>>s;
    if(m[s]!=0){
      cout<<"No"<<endl;
      return 0;
    }
    if(i!=0 && s[0]!=c){
      cout<<"No"<<endl;
      return 0;
    }
    m[s]++;
    c=s[s.size()-1];
  }
  cout<<"Yes"<<endl;

  return 0;
}

Measured memory_bytes: 3612
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 100, mod = (int) 0;
string mat[N];
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n, m, res = 0;
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> mat[i];
        for (int j = 0; j < m; ++j)
            if (mat[i][j] == '#')
                res++;
    }
    if (res != n + m - 1) {
        cout << "Impossible" << endl;
        return 0;
    }
    int a = 0, b = 0;
    for (int rep = 0; rep < n + m - 1; ++rep) {
        if (a < n && mat[a + 1][b] == '#') a++;
        if (b < m && mat[a][b + 1] == '#') b++;
    }
    if (a == n - 1 && b == m - 1) {
        cout << "Possible" << endl;
        return 0;
    }
    cout << "Impossible" << endl;
    return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (n - 1); i > (a - 1); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
#define rirep(i, x) for (auto i = (x).rbegin(); i != (x).rend(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
// gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1LL << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define Unique(x) (x).erase(unique((x).begin(), (x).end()), (x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) (((n) * ((n) + 1)) / 2)
#define updiv(a, b) ((a + b - 1) / b)
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T>  //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T>  //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {  //多次元初期化
  std::fill((T *)array, (T *)(array + N), val);
}
template <class A, class B>
bool chmax(A &a, const B &b) {  //最大値更新 返り値はbool
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class A, class B>
bool chmin(A &a, const B &b) {  //最小値更新 返り値はbool
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, 1, 1, -1, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

signed main(void) {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int n, k;
  cin >> n >> k;
  vector<int> x(n);
  arep(i, x) cin >> i;
  int l = 0, r = INF;

  while (r - l > 1) {
    int mid = (r + l) / 2;
    auto f = [&](int now) {
      int cnt = 0;
      rep(i, 0, n) cnt += (x[i] - 1) / now;
      return cnt <= k;
    };
    if (f(mid))
      r = mid;
    else
      l = mid;
  }

  cout << r << '\n';
  return 0;
}

Measured memory_bytes: 4788
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const int MOD = 1000000007;
/* テンプレートここまで */

int main() {
  int n;
  cin >> n ;
  vector<int> a(n);

  REP(i, n){
    cin >> a[i];
  }

  if(n == 1){
    cout << a[0] << endl;
    return 0;
  }

  if(n%2 == 0){
    for(int i = n-1; i >= 1; i-=2){
      cout << a[i] << " ";
    }
    for(int i = 0; i <= n-2; i+=2 ){
      cout << a[i];
      if(i == n-2){
        cout << endl;
      }else{
        cout << " ";
      }
    }
  }else{
    for(int i = n-1; i >= 0; i-=2){
      cout << a[i] << " ";
    }
    for(int i = 1; i <= n-2; i+=2 ){
      cout << a[i];
      if(i == n-2){
        cout << endl;
      }else{
        cout << " ";
      }
    }
  }
}

Measured memory_bytes: 2944
#include <stdio.h>

int main(void)
{
    int x, tri[3], i, j, maxi, n;

    scanf("%d", &n);

    for(i=0; i<n; i++){
        maxi=0; x=0;
        for(j=0; j<3; j++){
            scanf("%d", &tri[j]);
            tri[j] *= tri[j];
            if(tri[maxi] < tri[j]){
                maxi = j;
            }
        }
        for(j=0; j<3; j++){
            if(j != maxi){
                x+=tri[j];
            }
        }
        if(tri[maxi] == x){
            printf("YES\n");
        }else{
            printf("NO\n");            
        }
    }

    return 0;
}

Measured memory_bytes: 580
n,m = map(int,input().split())
edge = [tuple(map(int,input().split())) for _ in range(m)]
g = [[10**8]*(n) for i in range(n)]
for i in range(n):
  g[i][i] = 0
for a,b,c in edge:
  g[a-1][b-1] = c
  g[b-1][a-1] = c

for k in range(n):
  for i in range(n-1):
    for j in range(i+1,n):
      if g[i][j] > g[i][k] + g[k][j]:
        g[i][j] = g[i][k] + g[k][j]
        g[j][i] = g[i][j]

ans = 0
for a,b,c in edge:
  a -= 1; b -= 1
  if a > b:
    a,b = b,a
  for i in range(n):
    if abs(g[i][a]-g[i][b]) == c:
      break
  else:
    ans += 1
print(ans)

Measured memory_bytes: 3312
N, K = map(int, input().split())
lst = []
for i in range(K):
    input()
    lst.append(list(map(int, input().split())))
res = [0 for i in range(N)]
for l in lst:
    for i in l:
        res[i-1] += 1
res1 = 0
for i in res:
    if i == 0:
        res1 += 1
print(res1)

Measured memory_bytes: 9196
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

//conversion
//------------------------------------------
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(); }

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007


int main() {
	int n, m;
	cin >> n >> m;
	int x = 1, y = n;
	REP(i, m) {
		int l, r;
		cin >> l >> r;
		x = max(x, l);
		y = min(y, r);
	}
	cout << max(y - x + 1, 0) << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<fstream>
#include<cstring>
#include<string>
using namespace std;
int n;
char a;
int sum;
int ma=-1;
int main()
{
	cin>>n;
		
	for(int i=1;i<=n;i++)
	{
		ma=max(sum,ma);
	cin>>a;
	 if(a=='I')	sum++;
	 if(a=='D')  sum--;
	}
	if(sum>ma) ma=sum; 
	cout<<ma;
     
	
	return 0;
}

Measured memory_bytes: 256
ans = "Yes"
inp = int(input())
s = [];
shiri = input()
s.append(shiri)

for i in range(inp-1):
    shiri = input()
    
    shiri_s = list(shiri)
    shiri_s = shiri_s[0]
    
    s_e = list(s[-1])
    s_e = s_e[-1]
    if shiri in s or shiri_s != s_e:
        ans = "No"
        break
    s.append(shiri)
    
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize(2)
#pragma GCC optimize(3)   
#include<bits/stdc++.h>
#include<cstdlib>
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds; 
//#define ordered_set tree<pair<int,int>, null_type,less<pair<int,int>>, rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
typedef vector < ll > vl;
typedef vector < vl > vvl;
typedef pair < ll, ll > pll;
typedef long double ld;
typedef vector < pair < ll, ll > > vpll;
#define Boost() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define forn(i,n) for (ll i = 0; i < n; i++)
#define fo(i,n) for (ll i = 1; i <= n; i++)
#define fore(i,l,r) for (ll i = l; i <= r; i++)
#define rev(i,n) for(ll i=n-1;i>=0;i--)
#define all(c) c.begin(), c.end()
#define go(c,it) for(auto it=(c).begin(); it!=(c).end(); it++)
//#define back(c,it) for(auto it=(c).rbegin(); it!=(c).rend(); it++)
#define fi first
#define se second
#define MOD 998244353
#define MAX 1000000007
#define N 2000009
#define N1 100007
ll power(ll a,ll b){ll res=1;a=a%MOD;while(b>0){if(b&1){res=(res*a)%MOD;}a=(a*a)%MOD;b>>=1;}return res;}
ll fact[500009];
ll fermat_inv(ll y){return power(y,MOD-2);}
ll nCrMod(ll n, ll r){ ll p=fact[n];ll q=(fact[r]*fact[n-r])%MOD;return (p*fermat_inv(q))%MOD;} 
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
const ld PI = acos(-1.0);
vl g[N1];

  int main(){
      #ifndef ONLINE_JUDGE
      freopen("input.cpp","r",stdin);
      freopen("output.cpp","w",stdout);
      #endif
      Boost();
      int t;
      //cin>>t;
      t=1;
      int t1=t;
      while(t--)
      {
        ll l,r,d;
        cin>>l>>r>>d;
        ll x=(l-1)/d;
        ll y=r/d;
        cout<<y-x<<endl;
      }
      
      return 0;
  }

Measured memory_bytes: 5992
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
void ABC60(void);
void ABC61(void);
void ABC62(void);
void ABC63(void);
void ABC64(void);
void ABC65(void);
void ABC66(void);
void ABC67(void);
void ABC68(void);
void ABC69(void);

int main(void){
    ABC60();
}

void ABC60(){
    int a,b,c,i,ans=0;
    cin>>a>>b>>c;
    for(i=0;i<b;i++){
        if(c==i*a%b)ans=1;
    }
    if(ans)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(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>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename 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=1000000007;

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

int sou[55] = {1};

map<P,int> memo;

int calc(int n,int x){
	if(memo.count(P(n,x))) return memo[P(n,x)];
	if(!n) return x;
	if(x <= 1) return 0;
	else if(x <= 1 + sou[n - 1]) return memo[P(n,x)] = calc(n - 1,x - 1);
	else if(x == 2 + sou[n - 1]) return memo[P(n,x)] = calc(n - 1,sou[n - 1]) + 1;
	else if(x <= 2 + sou[n - 1] * 2) return memo[P(n,x)] = calc(n - 1,sou[n - 1]) + calc(n - 1,x - 2 - sou[n - 1]) + 1;
	else return memo[P(n,x)] = calc(n - 1,sou[n - 1]) * 2 + 1;
}

signed main(){
	int n,x;
	cin >> n >> x;
	for(int i = 1;i <= n;i++) sou[i] = sou[i - 1] * 2 + 3;
	cout << calc(n,x) << endl;
}

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

int main(void){
    int N,red=0,blue=0;
    cin>>N;
    char s[N];

    for(int i=0;i<N;i++){
        cin>>s[N];
        if(s[N]=='R')
            red++;
        else if(s[N]=='B')
            blue++;
    }
    if(red>blue)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main(){
    int N,M,a,b;
    cin >> N >> M;
    vector<pair<int,int>> P(M);
    for (int i = 0; i < M; i++){
        cin >> P[i].first >> P[i].second;
    } 
    for (int j = 0; j < 1000;j++){
        int k = 1;
        int Nj = j/10;
        vector<int>d(1,j%10);
        while(Nj){
            k++;
            d.push_back(Nj%10);
            Nj /= 10;
        }
        if(k != N)continue;
        bool ok =true;
        reverse(d.begin(), d.end());
        for(int i=0;i < M;i++){
            if(d[P[i].first -1] != P[i].second) ok =false;
        }
        if(ok){
            cout << j << endl;
            return 0;
        }



    }
    cout << "-1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,num,sum;
  int s[1000],p[1000],q[1000],r[1000];
  int a,b,c,d;
  while(scanf("%d",&n),n!=0){
    for(int i=0;i<n;i++){
      scanf("%d %d %d %d",&s[i],&p[i],&q[i],&r[i]);
    }
    num = 0;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    for(int i=0;i<n;i++){
      sum = p[i]*4 + q[i]*9 + r[i]*4;
      if(p[i]<=a && q[i]<=b && r[i]<=c && sum<=d){
	printf("%d\n",s[i]);
	num++;
      }
    }
    if(num == 0) puts("NA");
  }
  return(0);
}



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

int main() {
  string a,b;cin>>a>>b;
  int n = stoi(a+b);
  if (floor(sqrt(n)) * floor(sqrt(n)) == n) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 256
import math
input_num = int(input())
num_sqrt = int(math.sqrt(input_num))+1

minimam = input_num
for i in range(1,num_sqrt+1):
    q, mod = divmod(input_num, i)
    distance = q + i -2
    if mod == 0 and minimam > distance:
        minimam = distance
print(minimam)


Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
    double pai = 3.141592653589;
    double r;
    double ans1;
    double ans2;
    scanf("%lf",&r);
    ans2 = 2*r*pai;
    ans1 = r*r*pai;
    printf("%f %f\n",ans1,ans2);
    return 0;
}

Measured memory_bytes: 648
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int N;
    vector<int> p;
    cin >> N;

    for (size_t i = 0; i < N; i++) {
        int x;
        cin >> x;
        p.push_back(x);
    }

    auto M = max_element(p.begin(), p.end());

    int sum = 0;
    for (auto it = p.begin(), e = p.end(); it != e; ++it) {
        if (it == M) {
            sum += *it / 2;
        } else {
            sum += *it;
        }
    }
    cout << sum << "\n";
}

Measured memory_bytes: 256
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break

    result = 0
    for a in range(1, x // 3):
        for b in range(a + 1,  x // 2):
            c = x - a - b
            if b < c <= n:
                result += 1    
    print(result)

Measured memory_bytes: 6724
def main():
    n, m = map(int, input().split())
    indic = {}
    wadic = {}
    AC = 0
    for i in range(m):
        a, b = map(str, input().split())
        a = int(a)
        if a in indic:
            if indic[a] == "WA" and b == "WA":
                wadic[a] += 1
            elif indic[a] == "WA" and b == "AC":
                indic[a] = "AC"
                AC += 1
        else:
            if b == "AC":
                indic[a] = "AC"
                AC += 1
            else:
                indic[a] = "WA"
                wadic[a] = 1
    WA = 0
    for key in indic:
        if indic[key] == "AC" and key in wadic:
            WA += wadic[key]
    print(AC, WA)
                

if __name__ == "__main__":
    main()


Measured memory_bytes: 90044
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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input! {
        k: i32,
        x: i32
    }
	if 500 * k >= x {
    	println!("Yes");
    } else {
    	println!("No");
    }
}

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

namespace AOJ
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = int.Parse(Console.ReadLine());
			while(n--!=0)
			{
				var xy = Console.ReadLine().Split(' ').Select(i => double.Parse(i)).ToArray();
				double x1 = xy[0], y1 = xy[1], x2 = xy[2], y2 = xy[3], x3 = xy[4], y3 = xy[5], x4 = xy[6], y4 = xy[7];
				Console.WriteLine((x2 - x1) * (y4 - y3) - (y2 - y1) * (x4 - x3) == 0 ? "YES" : "NO");
			}
		}
	}
}

Measured memory_bytes: 5944
S = input()
cnt = 0

for i in range(len(S)):
  if S[0:len(S)//2] == S[len(S)//2:len(S) + 1] and cnt != 0:
    print(len(S))
    exit()
  else:
    cnt += 1
    S = S[0:len(S) - 1]

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;



int main(){
	int N,M;

	map <string, int> mp;

	scanf("%d", &N);
	for(int i=0;i<N;i++){
		char s[11];
		scanf("%s", s);
		auto itr = mp.find(s);
		if(itr != mp.end()){
			mp[s]++;
		} else {
			mp[s] = 1;
		}
	}

	scanf("%d", &M);
	for(int i=0;i<M;i++){
		char s[11];
		scanf("%s", s);
		auto itr = mp.find(s);
		if(itr != mp.end()){
			mp[s]--;
		} else {
			mp[s] = -1;
		}
	}

	int ans = 0;
	for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
		if(ans < itr->second){
			ans = itr->second;
		}
	}

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


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int X;
    scanf("%d",&X);
    int po=X;
    int buri=0;
    while(po!=0){
        buri+=po%10;
        po/=10;
    }
    if(X%buri==0)printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] ary = new int[n];
        
        for (int i = 0; i < n; i++) {
            ary[i] = sc.nextInt();
        }
        
        n = sc.nextInt();
        int[] t = new int[n];
        
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
        }
        
        int res = 0;
        for (int i = 0; i < n; i++) {
            if (isContain(t[i], ary)) {
                res++;
            }
        }
        
        System.out.println(res);
    }
    
    public static boolean isContain(int num, int[] ary) {
        int head = 0;
        int tail = ary.length-1;
        int middle = (head + tail) / 2;
        while (middle != head) {
            int m = ary[middle];
            if (m == num) {
                return true;
            } else if (m < num) {
                head = middle;
            } else if (m > num) {
                tail = middle;
            }
            middle = (head + tail) / 2;
        }
        return ary[head] == num || ary[tail] == num;
    }
}

Measured memory_bytes: 69768
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <functional>

using namespace std;

int INF = 10000000;





int main()
{
	int n,m,p;

	while(cin >> n >> m >> p && n && m)
	{
		int x[101];

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

		
		int tmp = 0;
		int sum = 0;

		for(int i = 0;i < n;i++)
		{
			if(m == i+1)tmp = x[i];
			sum += x[i];
		}
				
		int out;
		
		if(tmp)
		out = sum *(100 - p)/tmp;
		else
		out = 0;

		cout << out << endl;
	}

  return 0;
}

Measured memory_bytes: 1160
import sys
from collections import Counter

N = int(sys.stdin.readline())
A = sys.stdin.read().split()
c = Counter(A).most_common()

m = c[0][1]
l = []
l_append = l.append
for i in c:
    if i[1] == m:
        l_append(i[0])
l.sort()
print(*l, sep='\n')


Measured memory_bytes: 45256
#include "bits/stdc++.h"
#define r(i,a,n) for(ll i=a;i<n;i++)
using namespace std;
typedef long long ll;
const int INF = 1e+9;
const ll MOD=1e9+7;
#define elif else if
typedef pair<ll,ll> pll;
int main(){
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans=a+b+c+d;
    cout<<ans/60<<endl<<ans%60<<endl;
    return 0;
}


Measured memory_bytes: 3072