akhauriyash/Code-Regression huggingface dataset:
N, A, B, C = [int(x) for x in input().split()]
l = []
for i in range(N):
  l.append(int(input()))
 
def dfs(cur, a, b, c):
  if cur == N:
    if min(a, b, c) > 0:
      return abs(a - A) + abs(b - B) + abs(c - C) - 30
    else:
      return 10000000
  ret0 = dfs(cur + 1, a, b, c)
  ret1 = dfs(cur + 1, a + l[cur], b, c) + 10
  ret2 = dfs(cur + 1, a, b + l[cur], c) + 10
  ret3 = dfs(cur + 1, a, b, c + l[cur]) + 10
  return min(ret0, ret1, ret2, ret3)
 
print(dfs(0, 0, 0, 0))

Measured memory_bytes: 3064
while True:
    try:
        sum=0
        n=eval(input())
        l1=list(map(int,input().split()))
        l2=list(map(int,input().split()))
        for i in range(n):
            ss=1
            if(l2[i]-l1[i]>0):
                s=l2[i]-l1[i]
                if l1[i+1]-s<0:
                    sum+=l1[i+1]
                    l1[i+1]=0
                else:
                    l1[i+1]-=s
                    sum+=s
                    sum+=l1[i]
                    ss=0
                if(ss!=0):sum+=l1[i]

            elif(l2[i]-l1[i]<=0):
                sum+=l2[i]
        print(sum)
    except:break

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

#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(), (v).end() 
#define sz(v) (int)((v).size())
#define fs first
#define sd second

typedef long long ll;

typedef pair < int, int > pi;
typedef pair < pi, int > ppi;

typedef vector < int > vi;
typedef vector < vector < int > > vvi;
typedef vector < pi > vpi;
typedef vector < vpi > vvpi;
typedef vector < ppi > vppi;

void fast() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

vector<string> vec_splitter(string s) {
	s += ',';
	vector<string> res;
	while(!s.empty()) {
		res.push_back(s.substr(0, s.find(',')));
		s = s.substr(s.find(',') + 1);
	}
	return res;
}

void debug_out(
vector<string> __attribute__ ((unused)) args,
__attribute__ ((unused)) int idx, 
__attribute__ ((unused)) int LINE_NUM) { cerr << endl; } 
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
	if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
	stringstream ss; ss << H;
	cerr << args[idx] << " = " << ss.str();
	debug_out(args, idx + 1, LINE_NUM, T...);
}

#ifdef LOCAL
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

double get_time() {
	return 1.0 * clock() / CLOCKS_PER_SEC;
}


// c > b > a

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	for(int i = 0; i <= k; i++) {
		if((c * (1 << i)) > (b * (1 << (k - i))))
			if ((b * (1 << (k - i))) > a) {
				cout << "Yes" << '\n';
				return 0;
			}
	}
	cout << "No" << '\n';

}


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

using namespace std;

vector<int> drogi[100010];
bool visited[100010];

deque<int> res;

void dfs( int where ) {
    visited[where] = 1;
    res.push_back( where );
    for( int i : drogi[where] ) {
        if( !visited[i] ) {
            dfs( i );
            break;
        }
    }
}

void dfs2( int where ) {
    visited[where] = 1;
    res.push_front( where );
    for( int i : drogi[where] ) {
        if( !visited[i] ) {
            dfs2( i );
            break;
        }
    }
}

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

	int n, m;
	cin >> n >> m;
	int a, b;
    for( int i=1; i<=m; i++ ) {
        cin >> a >> b;
        drogi[a].push_back( b );
        drogi[b].push_back( a );
    }
	dfs( a );
	res.pop_front();
	dfs2( a );
	cout << res.size() << "\n";
	for( int i : res ) {
        cout << i << " ";
	}

	return 0;
}


Measured memory_bytes: 6784
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;


int main(void){
	ll a,b;
	cin>>a>>b;
	ll ans;
	if(a%2==0){
		if(b%2==0)ans=b+((b-a)/2%2);
		else ans=(b+1-a)/2%2;
	}
	else{
		if(b%2==0){
			ans=b^a^((b-a-1)/2%2);
		}
		else ans=a^((b+1-a-1)/2%2);

	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/perl -w
$hoge=<>;
($a,$b,$k)=split(/ /,$hoge);
$count = 0;

for($i=1;$i<=100;$i++){
    if($a%$i==0 && $b%$i==0){
        $s[$count]=$i;
        $count++;

    }
}
print $s[-$k];

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

#define int long long

const int N = 105;

int a[N];

signed main() {
#ifdef _DEBUG
	freopen("in", "r", stdin);
#endif
	int n; double m;
	cin >> n >> m;
	int cnt = 0, sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	for (int i = 1; i <= n; i++) {
		if (a[i] >= 1 / (4 * m) * sum) cnt++;
	}
	if (cnt >= m) cout << "Yes\n";
	else cout << "No\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;

int main() {
	int cnt[10] = {};
	for (int i = 0; i < 4; i++) {
		int N;
		cin >> N;
		cnt[N]++;
	}
	if (cnt[1] && cnt[9] && cnt[7] && cnt[4]) cout << "YES" << endl;
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main{
  public static void main(String[] args){
    try {
      Scanner sc = new Scanner(System.in);
      int x1, y1, x2, y2;
      x1=Integer.parseInt(sc.next());
      y1=Integer.parseInt(sc.next());
      x2=Integer.parseInt(sc.next());
      y2=Integer.parseInt(sc.next());

      System.out.println((x2+y1-y2) +" "+ (y2-x1+x2) +" "+ (x1+y1-y2) +" "+ (y1-x1+x2));
    
      }catch (Exception e) {
      System.out.println("out");
    }
  }
}


Measured memory_bytes: 24020
a, b = map(int, input().split())
ans = []
for i in range(50):
    ans.append(["."] * 100)
for i in range(50):
    ans.append(["#"] * 100)

i = 0
b -= 1
while b > 0:
    for j in range(0, 100, 2):
        ans[i][j] = "#"
        b -= 1
        if b == 0:
            break
    i += 2

i = 60
a -= 1
while a > 0:
    for j in range(0, 100, 2):
        ans[i][j] = "."
        a -= 1
        if a == 0:
            break
    i += 2
print(100, 100)
for i in range(100):
    print("".join(ans[i]))


Measured memory_bytes: 3188
#include<stdio.h>

int main()
{
    int a,k;
    int b[100];

    while(scanf("%d\n",&a)!=EOF)
    {

        for(int i=0;i<a;i++)
        {
            scanf("%d",&b[i]);
            i<a-1 ? printf("%d ",b[i]):printf("%d\n",b[i]);
        }
        for(int j=1;j<=a-1;j++)
        {
            int key=b[j];
            k=j-1;
            while(k>=0&&b[k]>key)
            {
                b[k+1]=b[k];
                k--;
            }
            b[k+1]=key;
            for(int m=0;m<a;m++)
                m<a-1? printf("%d ",b[m]):printf("%d\n",b[m]);
        }
    }
        return 0;

}




Measured memory_bytes: 2048
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

int n;
double a[100];
double num, ans;

int main() {
	cin >> n;
	rep(i, n) { cin >> a[i]; }


	rep(i,n){
		num += 1.0 / a[i];
	}

	ans = 1.0 / num;


	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigDecimal L = new BigDecimal(sc.next());
		BigDecimal a= L.multiply(L).multiply(L);
		a.setScale(12);
		BigDecimal b = new BigDecimal("27");
		b.setScale(12);
		System.out.println(a.divide(b,12,BigDecimal.ROUND_UP));
	}
}

Measured memory_bytes: 21844
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: Vec<char> = input::<String>().chars().collect();

    let ok = if (n[0] == n[1] && n[1] == n[2]) || (n[1] == n[2] && n[2] == n[3]) {
        true
    } else {
        false
    };
    println!("{}", if ok { "Yes" } else { "No" });
}


Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;


int main()
{
    int n; cin >> n;
    int ans = 0;
    vector<pair<int, int> > red(n), brue(n);
    for(int i = 0; i < n; i++){
        int a, b;
        cin >> a >> b;
        red[i] = make_pair(a, b);
    }
    for(int i = 0; i < n; i++){
        int c, d;
        cin >> c >> d;
        brue[i] = make_pair(c, d);
    }

    vector<bool> paired(n, false);
    sort(brue.begin(), brue.end());
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){

            //brueより左下にある点red
            if(red[j].first < brue[i].first && red[j].second < brue[i].second){ 
                int maxkey_red = -1;
                int maxy_red = -1;

                //ここからredのy座標の最大をさがす
                //redがbrueより左下にある，かつまだペアになっていないyの中で
                for(int k = j; k < n; k++){
                    if(maxy_red < red[k].second && red[k].first < brue[i].first && red[k].second < brue[i].second && !paired[k]){
                        maxy_red = red[k].second;
                        maxkey_red = k;
                    }
                }
                //新しいy座標が見つかったら
                if(maxkey_red != -1){
                    paired[maxkey_red] = true;
                    ans++;
                    break;
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
int n,i,min,d,a,t,count,dmax;
scanf("%d%d",&n,&t);
dmax=0;
count=0;
scanf("%d",&min);
for(i=1;i<n;i++){
scanf("%d",&a);
d=a-min;
if(d>dmax){
dmax=d;
count=1;
}
else if(d==dmax)
count++;
if(a<min)
min=a;
}
printf("%d\n",count);
return 0;
}


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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  int t = N%10;
  if (t == 0 || t == 1 || t == 6 || t == 8)
    cout << "pon" << endl;
  else if (t == 3)
    cout << "bon" << endl;
  else
    cout << "hon" << endl;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

int A, B, C, X, Y;
ll ret = LLONG_MAX;

int main() {
	cin >> A >> B >> C >> X >> Y;

	for (int i = 0; i <= 300000; ++i) {
		ll t = i * C + max(0, X - i/2) * A + max(0, Y - i/2) * B;
		ret = min(ret, t);
	}

	cout << ret << endl;

	return 0;
}

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

int main(){
	int W, H, N;
	cin >> W >> H >> N;
	int i, x[N], y[N], a[N];
	int xMax = W, yMax = H, xMin = 0, yMin = 0;
	for(i=1; i<=N; i++){
		cin >> x[i] >> y[i] >> a[i];
		if(a[i]==1 && xMin<x[i])	xMin = x[i];
		else if(a[i]==2 && x[i]<xMax)	xMax = x[i];
		if(a[i]==3 && yMin<y[i])	yMin = y[i];
		else if(a[i]==4 && y[i]<yMax)	yMax = y[i];
	}
	
	if(xMin<xMax && yMin<yMax)	cout << (xMax-xMin)*(yMax-yMin) << endl;
	else	cout << 0 << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main()
{
  int n,m;
  cin>>n>>m;
  vecint cwa(n, 0);
  int cac=0;
  int cpe=0;
  for(auto&& i:irange(0,m)) {
    int p;
    string s;
    cin>>p>>s;
    --p;
    if(s=="AC") {
      if (cwa[p] >= 0) {
        cpe += cwa[p];
        ++cac;
      }
      cwa[p] = -1;
    } else {
      if (cwa[p] >= 0) {
        ++cwa[p];
      }
    }
  }
  cout<<cac<<' '<<cpe<<endl;
  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <queue>

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

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

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> v(n), u(n, 0);
    for (int i = 0; i < n; ++i) scanf("%d", &v[i]);
    for (int i = 0; i < m; ++i) {
        int b;
        cin >> b;
        for (int j = 0; j < n; ++j) {
            if(v[j] <= b) {
                u[j]++;
                break;
            }
        }
    }

    cout << max_element(u.begin(), u.end()) - u.begin()+1 << "\n";
    return 0;
}



Measured memory_bytes: 3236
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

vector<int> graph[100001];
vector<int> color(100001);

vector<int> dist(100001);

void dfs(int v, int d, int c) {
  if (color[v] == 0) {
    color[v] = c;
  }
  if (dist[v] >= d) {
    return;
  }
  dist[v] = d;
  for(auto e: graph[v]) {
    dfs(e, d-1, c);
  }
}

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

  int n, m; cin >> n >> m;
  rep(i, m) {
    int a, b; cin >> a >> b;
    graph[a].push_back(b);
    graph[b].push_back(a);
  }

  int q; cin >> q;
  vector<pair<int, P>> vec(q);
  rep(i, q) {
    int v, d, c; cin >> v >> d >> c;
    vec[i] = make_pair(v, P(d,c));
  }
  reverse(vec.begin(), vec.end());  

  rep(i, q) {
    int v = vec[i].first;
    int d = vec[i].second.first;
    int c = vec[i].second.second;
    dfs(v, d, c);
  }

  for(int i=1; i<=n; i++) {
    cout << color[i] << '\n';
  }
}


Measured memory_bytes: 8440
n = int(input())
a1 = list(map(int,input().split()))
a2 = list(map(int,input().split()))

ttl = 0
li1 = []
for i in range(n):
    ttl += a1[i]
    li1.append(ttl)

ttl = 0
li2 = []
for i in range(1,n+1):
    ttl += a2[i*(-1)]
    li2.append(ttl)

ans = 0
for i in range(n):
    #print(li1[i]+li2[i])
    ans = max(ans,li1[i]+li2[(i+1)*(-1)])

print(ans)

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


int main() {
  int S, W;
  cin >> S >> W;
  if (S <= W) {
    cout << "unsafe" << endl;
  } else {
    cout << "safe" << endl;
  }
  return 0;
}


Measured memory_bytes: 3624
N,M = map(int,input().split())
V = [0]*(N+1)
for i in range(M):
    a,b = map(int,input().split())
    V[a] +=1
    V[b] +=1
bool = True
for i in range(N+1):
    if V[i] % 2 ==1:
        bool = False
        break
if bool:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 44504
import java.util.*;

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

            // 空白で分割してaとb,cを定義

            int a = scanner.nextInt();

            int b = scanner.nextInt();

            int c = scanner.nextInt();

            int count = 0;
            for (int x = a; x <= b; x++) {
            	int div = c % x;
            	if (div == 0) {
            		count++;
            	}
            }
            System.out.println(count);
	}
}



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

int main() {
    ll X; cin >> X;
    bool debug = true;
    ll ans = 0;
    vector<ll> coin = {500, 5};
    for (int i = 0; i < 2; i++){
        ll used = 0;
        while(X - coin[i] >= 0) {
            used++;
            X -= coin[i];
        }
        if (coin[i] == 500) ans += 1000 * used;
        if (coin[i] == 5) ans += 5 * used;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
n=int(input())
ans=0
tmp=[0 for i in range(n+1)]
for i in range(2,n+1):
    now=i
    for j in range(2,n+1):
        while now%j==0:
            tmp[j]+=1
            now//=j
def solve(x):
    tmp1=len(list(filter(lambda y:y>=x-1,tmp)))
    return tmp1
print(solve(75)+solve(25)*(solve(3)-1)+solve(15)*(solve(5)-1)+
solve(5)*(solve(5)-1)*(solve(3)-2)//2)


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

#define rep(i, a) for (int i = 0; i < (a); i++ )
#define FOR(i, m, n) for(int i = m; i < n; i++)
 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int H,W,K;
    cin >> H >> W >> K;
    char c[H][W];
    rep(i,H) {
        string tmp;
        cin >> tmp;
        rep(j,W) {
            c[i][j] = tmp[j];
        }
    }
    int ans = 0;

    for (int bit=0; bit< (1<<(H+W)); bit++) {
        set<int> Sh,Sw;
        int tmp = 0;
        rep(i,H+W) {
            if (i<H) {
                if (bit & (1<<i)) Sh.insert(i);
            }
            else {
                if (bit & (1<<i)) Sw.insert(i-H);
            }
        }
        rep(h,H) {
            rep(w,W) {
                if (!Sh.count(h) && !Sw.count(w) && c[h][w]=='#') tmp++;
            }
        }
        if (tmp == K) ans++;
    }
    cout << ans << endl;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl
#define Size(n) (n).size()

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}
//long long int ruizyo(long long int aa, long long int bb){
  //  if(aa==0){
    //    return 1;
    //}
    //else if(aa%2==0){
      //  long long int tt=ruizyo(aa/2,bb);
        //return (tt*tt)%MOD;
    //}
    //else{
      //  return (ruizyo(aa-1,bb)*bb)%MOD;
    //}
//}フェルマ－のア


//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

//bool f[100001];//1000000以下の素数を調べよう！
//rrep(i,2,100001){
  //      f[i]=false;
    //}
//rrep(i,2,100001){
  //      if(!f[i]){
    //        for(int j=i+i;j<=100000;j+=i){
      //          f[j]=true;
        //    }
        //}
    //}
    //for(int i=3;i<=100000;i+=2){
      //  if(!f[i]){
        //    c[i]++;
      //  }
   // }

//visited=vector<vector<bool>>(10,vector<bool>(10,false));アを全部falseに


long long int n,cnt=0,ans=0,a,b,c,d,cmp,k,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl=true;

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

       cin >> n >> k;
       pair<int,int> p[100000];
       rep(i,n){
           cin>>a>>b;
           p[i]=make_pair(a,b);
       }
       sort(p,p+n);
      rep(i,n){
         cnt+=p[i].second;
         if(cnt>=k){
             Cout(p[i].first);
             return 0;
         }
      }
return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define endl '\n'
#define pi 3.14159265358979323846
using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int A,B,H,M;
	double hour,min;
	for(int i=0;i<4;i++)
		scanf("%d%d%d%d",&A,&B,&H,&M);
	
	hour=30.*H+0.5*M;
	min=6.*M;
	
	if(hour>min && (hour-min)<=180.){
		hour=hour-min;
	}else if(hour>min && (hour-min)>180.)
		hour=360.-(hour-min);
	else if(hour<min && (min-hour)<=180.)
		hour=min-hour;
	else if(hour<min && (min-hour)>180.)
		hour=360.-(min-hour);
		
	hour=hour*pi/180.;
	min=pow(A,2.)+pow(B,2.)-2*A*B*cos(hour);
	min=pow(min,0.5);
	printf("%#.20f",min);
		
	return 0;
}

Measured memory_bytes: 4416
#include<stdio.h>

int main(int argc, char const *argv[]) {
    int S,h,m,s;
    scanf("%d",&S);
    h=S/3600;
    m=(S-h*3600)/60;
    s=S-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}

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

int main(){

    string s;
    cin >> s ;
    int a=0;
    rep(i,3){
        if(s[i]=='1') ++a;
    }
    cout << a << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    VEC(int) A(N);
    READVEC(A);
    FOR(i, 0, N)
        A[i] -= i + 1;

    sort(ALL(A));

    auto f = [&](int X) {
        lint ret = 0;
        for (int a : A)
            ret += abs(a - X);
        return ret;
    };

    lint ret = f(A[N / 2]);
    if (N / 2 >= 1)
        ret = min(ret, f(A[N / 2 - 1]));
    if (N / 2 + 1 < N)
        ret = min(ret, f(A[N / 2 + 1]));
    cout << ret << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


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

int main(){
    ios_base::sync_with_stdio(false);
    int64 n , k; cin >> n >> k;
    int64 min1;
    min1 = min( n % k , abs((n % k) - k));    
    cout << min1 << endl;    
}

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

int n, l, r, ans;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> l >> r;
        if(l!=r) ans += r-l+1;
        else ans++;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
D,G = map(int, input().split())
INF = 10**10
# 各点数を得るときの、最小の問題数
n = 2*10**5
dp = [INF] * n
dp[0] = 0
for i in range(1,D+1):
    p,c = map(int, input().split())
    c //= 100
    tmp = dp[:]
    for j in range(G//100+1):
        if tmp[j] == INF: continue
        for k in range(1,p+1):
            dp[j+i*k] = min(tmp[j]+k, dp[j+i*k])
        dp[j+i*p+c] = min(tmp[j]+p, dp[j+i*p+c])
ans = INF
for score in dp[G//100:]:
    if score == INF: continue
    ans = min(score, ans)
print(ans)


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

int main() {
	// your code goes here
	int a,b,c,k;
	cin>>a>>b>>c>>k;
	
	int m=min(a,k);
	int s=0;
	s+=m;
	k-=m;
	m=min(b,k);
	k-=m;
	m=min(c,k);
	s-=m;
	
	cout<<s;
	
	
	return 0;
}


Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#include <map>
/* All our base are belong to AC */
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<int,int>;
const ll M = 1e9+7;
void add(ll& x, ll y) {x+=y; x%=M;}; void mul(ll& x, ll y) {x*=y; x%=M;}; template<typename T, typename U> void chmax(T& x, U y) {if (x<y) x=y;}; template<typename T, typename U> void chmin(T& x, U y) {if (x>y) x=y;};
ll mod_pow(ll x, ll a) { ll an = 1; while(a > 0) { if (a&1) an = an * x % M; x = x * x % M; a >>= 1;} return an;}

int main() {
  int n,m; cin>>n>>m; ll k; cin>>k;
  ll a[n],b[m];
  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<m;i++) cin>>b[i];
  for(int i=1;i<m;i++) b[i]+=b[i-1];
  //for(int i=0;i<m;i++) cout<<b[i]<<" "; cout<<endl;
  ll an=0;
  for(int i=0;i<=n;i++) {
    if (k<0) break;
    int pl = upper_bound(b,b+m,k) - b;
    //cout<<k-sm<<" "<<pl<<" "<<endl;
    chmax(an,i+pl);
    if (i==n) break;
    k-=a[i];
  }
  cout<<an<<endl;
}

Measured memory_bytes: 6764
def main():
    n = int(input())
    a = list(map(int, input().split()))
    count = 0
    
    if n%2:
        n_ = (n+1) // 2
        for i in range(n_):
            m = 2 * i + 1
            
            if a[m-1]%2==1:
                count += 1
    else:
        n_ = n // 2
        for i in range(n_):
            m = 2 * i + 1
            
            if a[m-1]%2==1:
                count += 1
        
    print(count)

if __name__ == "__main__":
    main()

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

#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

int main(void) {
	ll a, b, c, d, count, i, j, k, r, temp, x;
	cin >> a >> b >> c >> d;
	count = b - a + 1;
	i = (b / c) - ((a - 1) / c);
	j = (b / d) - ((a - 1) / d);
	x = c * d;
	if (c < d) {
		temp = c;
		c = d;
		d = temp;
	}
	r = c % d;
	while (r != 0) {
		c = d;
		d = r;
		r = c % d;
	}
	k = (b / (x / d)) - ((a - 1) / (x / d));
	count = count - i - j + k;
	cout << count;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define pb push_back
using namespace std;
const int N = 1e5+5;
void fast(){std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}
int main()
{
	fast();
	ll a,b,c;
	cin>>a>>b>>c;
	ll rem=a;
	a=max(0ll,a-c);
	c-=rem;
	c=max(c,0ll);
	b-=c;
	b=max(b,0ll);
	cout<<a<<' '<<b<<endl;
	return 0;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { std::cout << #a << " = " << a << "\n"; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T, class V> istream& operator>> (istream& ist, pair<T, V>& p) { return ist >> p.first >> p.second; }
template<class T> ostream& operator<< (ostream& ost, pair<T, T>& p) { return ost << p.first << ", " << p.second; }
template<class T> istream& operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) ist >> e; return ist; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int N, x;cin >> N >> x;
  vector<int> a(N);
  rep(i, N) {
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  int count = 0;
  rep(i, N) {
    if (x > 0) {
      x -= a[i];
      count++;
    }
  }
  cout << max(0, count - (x != 0)) << "\n";
}


Measured memory_bytes: 256
dd = ((-1, 0), (0, -1), (1, 0), (0, 1))

d = int(input())
for i in range(d):
    if i:
        print()
    N = int(input())
    MP = [[" "]*N for i in range(N)]
    for i in range(N):
        MP[i][0] = "#"
    def walk(x, y, d, n):
        dx, dy = dd[d % 4]
        for k in range(n):
            x += dx; y += dy
            MP[y][x] = "#"
        return x, y
    x = y = 0
    r = N-1; d = 2
    while r > 1:
        x, y = walk(x, y, d, r)
        x, y = walk(x, y, d+1, r)
        r -= 2; d += 2
    if r == 1:
        walk(x, y, d, r)
    for line in MP:
        print(*line, sep='')



Measured memory_bytes: 7156
#include <stdio.h>

int main(){
  int n,k,s,i,sum=0;
  int a[100001];
  scanf("%d %d %d", &n, &k, &s);
  
  for(i=1;i<=k;i++){
    a[i] = s;
  }
  for(i=k+1;i<=n;i++){
    if(s <= 10000) a[i] = s+1;
    else if(k <= 5) a[i] = s-1;
	else a[i] = s/k + 1;
  }
  
  printf("%d", a[1]);
  for(i=2;i<=n;i++) printf(" %d", a[i]);
  
  return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i=(a); i<(n); ++i)
#define rrep(i,a,n) for(ll i=(a); i>(n); --i)
#define erep(i,a,n) for(ll i=(a); i<=(n); ++i)
#define rerep(i,a,n) for(ll i=(a); i>=(n); --i)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp make_pair
#define sz(x) ((int) x.size())
#define print(X) cout << (X) << endl
#define _ << " " <<
static const int INF = 1e+9+7;
ll n,m,l;
str s,t;
int A[100000];

int calc1(int n){
    int i;
    for (i = 0; i*i*i<=n; ++i){}
    --i;
    return (i*i*i);
}

int calc2(int n){
    int i;
    for(i=0; i*(i+1)*(i+2)/6<=n; ++i){}
    --i;
    return (i*(i+1)*(i+2)/6);
}

int calc3(int n){
    int res = 0;
    for(int i=0; i*i*i<=n; ++i){
        res = max(res, i*i*i+calc2(n-i*i*i));
    }
    return res;
}


int main(){
    vi vc;
    rep(i,0,1024){
        int x;
        cin >> x;
        if (x == 0) break;
        vc.pb(x);
    }

    rep(i,0,sz(vc)){
        int large = max(calc1(vc[i]),calc2(vc[i]));
        large = max(large, calc3(vc[i]));
        print(large);
    }



  return 0;
}






Measured memory_bytes: 3136
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
#define SortAsc(c) std::sort(c.begin(), c.end())
#define SortDesc(c) std::sort(c.rbegin(), c.rend())
int dx[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dy[8] = {1, 0, -1, 0, 1, -1, 1, -1};

int main() {
  int w, h;
  w = 3;
  h = 3;
  int n;
  vector<vector<int>> grid(h, vector<int>(w));

  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      cin >> grid.at(y).at(x);
    }
  }

  cin >> n;

  for (int i = 0; i < n; i++) {
    int b;
    cin >> b;
    for (int y = 0; y < h; y++) {
      for (int x = 0; x < w; x++) {
        if (grid.at(y).at(x) == b) {
          grid.at(y).at(x) = 0;
        }
      }
    }
  }

  struct p {
    int y;
    int x;
  };
  vector<vector<p>> points = {

      // horizontal
      {p{0, 0}, p{0, 1}, p{0, 2}},
      {p{1, 0}, p{1, 1}, p{1, 2}},
      {p{2, 0}, p{2, 1}, p{2, 2}},

      // vertical
      {p{0, 0}, p{1, 0}, p{2, 0}},
      {p{0, 1}, p{1, 1}, p{2, 1}},
      {p{0, 2}, p{1, 2}, p{2, 2}},

      // cross
      {p{0, 0}, p{1, 1}, p{2, 2}},
      {p{0, 2}, p{1, 1}, p{2, 0}},
  };

  for (auto ps : points) {
    int count = 0;
    for (auto point : ps) {
      if (grid.at(point.y).at(point.x) == 0) {
        count++;
      }
    }
    if (count == 3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
const int INF = 2e9;
const int MOD = 1e9 + 7;

int main() {
   int n, m;
   cin >> n >> m;
   vector<int> num(n);
   rep(i, 0, m) {
      int a, b;
      cin >> a >> b;
      a--, b--;
      num[a]++, num[b]++;
   }
   rep(i, 0, n) { cout << num[i] << endl; }
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main()
{
	char a, b;
	cin >> a >> b;
	if (a == 'H'){
		if(b == 'H')
			cout << 'H' << endl;
		else
			cout << 'D' << endl;

	} else {
		if(b == 'H')
			cout << 'D' << endl;
		else
			cout << 'H' << endl;
	}

	return 0;
}




Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll;

int main(){
    string s;
    cin >> s;
    int a, b;
    a = stoi(s.substr(0, 2));
    b = stoi(s.substr(2, 2));
    //cout << a << endl;
    if (1 <= a && a <= 12 && 1 <= b && b <= 12) cout << "AMBIGUOUS" << endl;
    else if(1<=a && a<=12)
        cout << "MMYY" << endl;
    else if( 1<=b && b<=12)
        cout << "YYMM" << endl;
    else
        cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n, a, x, y, max uint
	fmt.Scan(&n)

	statements := make([]statement, n)
	for i := uint(0); i < n; i++ {
		fmt.Scan(&a)

		s := make(statement)
		for j := uint(0); j < a; j++ {
			fmt.Scan(&x, &y)
			s[x-1] = y
		}
		statements[i] = s
	}

	for bit := uint(0); bit < 1<<n; bit++ {
		var (
			cnt uint
			ok  = true
		)

		for i := uint(0); i < n; i++ {
			if bit&(1<<i) == 0 {
				continue
			}

			cnt++
			for _x, _y := range statements[i] {
				if ((bit>>_x)&1)^_y == 1 {
					ok = false
				}
			}
		}

		if ok && cnt > max {
			max = cnt
		}
	}

	fmt.Println(max)
}

type statement map[uint]uint


Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(){
  int n;cin>>n;
  int a[n];
  int kekka = 0;
  for(int i = 0;n > i; i++){
    cin >> a[i];if(a[i] % 2 == 1)kekka++;
  }
  cout << (kekka%2 == 1 ? "NO" : "YES") << endl;
}

Measured memory_bytes: 640
import Data.List

main = do
  s <- getLine
  let
    a = length $ filter (=='a') s
    b = length $ filter (=='b') s
    c = length $ filter (=='c') s
    

  putStrLn $ if maximum [a,b,c] - minimum [a,b,c] <= 1 then "YES" else "NO"



Measured memory_bytes: 7164
n,k=map(int,input().split())
a=[0]+list(map(int,input().split()))
from collections import defaultdict
d=defaultdict(int)
d[0]=1
ans=0
for i in range(1,n+1):
    a[i]+=a[i-1]-1
    if i>=k:
        d[a[i-k]]-=1
    a[i]%=k
    d[a[i]]+=1
    ans+=d[a[i]]-1
print(ans)

Measured memory_bytes: 33708
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

int main(){
	int N;
	cin>>N;
	int v[20],c[20];
	rep(i,N)cin>>v[i];
	rep(i,N)cin>>c[i];
	
	int ans=0;
	rep(i,N)if(v[i]>c[i])ans+=(v[i]-c[i]);
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define MOD 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=50;
//↑templete
signed main(){

	int H, W;
	cin>>H>>W;
	vector<string> S;
	for(int i=0;i<H;i++){
		string s;
		cin>>s;
		S.pb(s);
	}

	int ans=0;

	for(int sx=0;sx<H;sx++){
		for(int sy=0;sy<W;sy++){

			if(S[sx][sy]=='#')
				continue;

			queue<tint> que;
			que.push(mt(sx, sy, 0));

			bool visited[SIZE][SIZE]={};
			int dist[SIZE][SIZE]={};
			while(que.size()){
				int x, y, z;
				tie(x, y, z)=que.front();
				que.pop();

				if(visited[x][y])
					continue;

				dist[x][y]=z+1;
				visited[x][y]=1;
				
				for(int k=0;k<4;k++){
					int X=x+dx[k], Y=y+dy[k];
					if(X<0 || H<=X || Y<0 || W<=Y)
						continue;
					if(S[X][Y]=='#')
						continue;
					if(visited[X][Y])
						continue;
					
					que.push(mt(X, Y, z+1));
				}

			}

			for(int i=0;i<H;i++){
				for(int j=0;j<W;j++)
					ans=max(ans, dist[i][j]);
			}

		}
	}
	cout<<ans-1<<endl;

	return 0;
}

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,sum=0; cin >> N;
    set<int> ans;
    for (int i=1;;++i){
        sum+=i; ans.emplace(i);
        if (N<=sum){
            if (N!=sum) ans.erase(sum-N);
            break;
        }
    }
    for (int x:ans) cout << x << '\n';
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <math.h>

using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> using hset = unordered_set<T>;
template<class Key, class T> using hmap = unordered_map<Key, T>;

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

int main() {
    int D, E;
    double minLength, length;
    while (cin >> D >> E) {
        if (D == 0) break;

        minLength = 1000;
        for (int i=0; i<D; i++) {
            length = abs(sqrt(i*i + (D-i)*(D-i)) - E);
            minLength = (length < minLength) ? length : minLength;
        }
        cout << minLength << endl;
    }

    return 0;
}

Measured memory_bytes: 3256
//Code By CXY07
#include<bits/stdc++.h>
using namespace std;

#define int long long

const int MAXN = 1;
const int INF = 2e9;
const int mod = 1e9 + 7;

int n,k;

signed main () {
	cin >> n >> k;
	n %= k;
	cout << min(n,k - n) << endl;
	return 0;
}

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

int main(){
  string s; cin >> s;
  int cnt = 0;
  rep(i,4){
    if(s[i] == '+') cnt++;
    else cnt--;
  }
  cout << cnt;
}


Measured memory_bytes: 256
N, K, *h = map( int, open( 0 ).read().split() )

d = [ 0 ] + [ 10**18 ] * ( N - 1 )
for i in range( N ):
  for k in range( 1, K + 1 ):
    if i - k >= 0: 
      d[ i ] = min( abs( h[ i ] - h[ i - k ] ) + d[ i - k ], d[ i ] )
print( d[-1] )

Measured memory_bytes: 59948
#include <iostream>
using namespace std;
int main() {
  
  int n,y;
  int b,r,t;

  while(1) {
  cin >> n;
  if(n == 0) break;
  cin >> y;

  double minx=-1;
  int ans = 0;  
  for(int i=0;i<n;i++) {
    cin >> b >> r >> t;

    double a = 1; 
    if(t == 1) {
      a = 1+y*(r/100.0);
    }
    else{
      for(int j=0;j<y;j++) {
	a *= (1+(r/100.0));
      }

    }    
    //cout << a << endl;
    if(minx < a) {
      minx = a;
      ans = b;
    }

  }
  cout << ans << endl;

  }

  return 0;

}
  

Measured memory_bytes: 1160
def pyn():
  n = int(input())
  a = list(map(int, input().split()))
  if 0 in a:
    print(0)
    return
    
  ans=1
  for i in a:
    ans *= i
    if ans>10**18:
      print(-1)
      return
  print(ans)

pyn()

Measured memory_bytes: 21592
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, K; std::cin >> N >> K;
  std::vector<int64_t> psum(N+1), nsum(N+1);
  psum[0] = nsum[0] = 0;
  for(int i = 0; i < N; ++i) {
    int64_t a; std::cin >> a;
    if(a > 0) {
      psum[i+1] = psum[i] + a;
      nsum[i+1] = nsum[i];
    } else {
      psum[i+1] = psum[i];
      nsum[i+1] = nsum[i] + a;
    }
  }
  int64_t ans = 0; // all white
  for(int p = 0; p+K <= N; ++p) {
    ans = std::max(ans, psum[N] + nsum[p+K] - nsum[p]);
    ans = std::max(ans, psum[p] + psum[N] - psum[p+K]);
  }
  fin(ans);
  return 0;
}

Measured memory_bytes: 1792
# frozen_string_literal: true

n = gets.to_i
t, a = gets.split.map(&:to_i)
heights = gets.split.map(&:to_i)

diffs = heights.map {|height| t - height * 0.006 }.map {|temperature| (a - temperature).abs }
min_diff = diffs.min
answer = diffs.find_index {|diff| diff == min_diff } + 1

puts answer


Measured memory_bytes: 1788
while gets
  n, m = $_.split.map(&:to_i)
  break if n == 0 && m == 0
  x = y = 1
  rotate = [0,1]
  loop do
    str = gets.split
    case str[0]
    when "FORWARD"
      x += rotate[0]*str[1].to_i
      y += rotate[1]*str[1].to_i
      x = n if x > n; x = 1 if x < 1
      y = m if y > m; y = 1 if y < 1
    when "BACKWARD"
      x -= rotate[0]*str[1].to_i
      y -= rotate[1]*str[1].to_i
      x = n if x > n; x = 1 if x < 1
      y = m if y > m; y = 1 if y < 1
    when "RIGHT"
      rotate = [rotate[1], -rotate[0]]
    when "LEFT"
      rotate = [-rotate[1], rotate[0]]
    when "STOP"
      puts "#{x} #{y}"
      break
    end
  end
end

Measured memory_bytes: 8716
n=int(input())
l=list(map(int,input().split()))
d=[]
l.sort(reverse=True)
d.append(l[0])
for i in range(1,n):
    d.append(l[i])
    d.append(l[i])
max=0
for i in range(n-1):
    max+=d[i]
print(max)


Measured memory_bytes: 122752