akhauriyash/Code-Regression huggingface dataset:
###############################################################################

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


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


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


###############################################################################


def main():
    n = intin()

    nn = n
    s = 0
    while nn:
        s += nn % 10
        nn = nn // 10

    if n % s == 0:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3676
n=97
p=print
r=range
def c(i,j,k):p('<',i,j,k)
def a(i,j,k=0):p('+',i,j,max(i,k))
def b(i):a(i,i,i+1)
def d(x,i,j):
	for t in r(30):
		b(j+t-1);a(j+t,n)
		for s in r(j+t,j+29):b(s)
		c(j+29,x,i+t);b(j+t-1);a(j+t,i+t)
p(3933)
a(0,1,n)
c(2,n,n)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
for t in r(59):
	a(2,2)
	for s in r(t+1):
		if t-30<s<30:a(5+t-s,36+s,98);c(n,98,99);a(2,99)

Measured memory_bytes: 9224
#include <stdio.h>

int main(void) {
	int n,m;
	char str[100];
	int open[7];
	int temp;
	int sum;

	while (scanf("%d", &n), n) {
		for (int i = 1; i < 7; i++)open[i] = i;
		sum = 1;
		while (n--) {
			scanf("%s", str);
			if (str[0] == 'N') {
				temp = open[1];
				open[1] = open[2];
				open[2] = open[6];
				open[6] = open[5];
				open[5] = temp;
			}
			else if (str[0] == 'S') {
				temp = open[1];
				open[1] = open[5];
				open[5] = open[6];
				open[6] = open[2];
				open[2] = temp;
			}
			else if (str[0] == 'E') {
				temp = open[1];
				open[1] = open[4];
				open[4] = open[6];
				open[6] = open[3];
				open[3] = temp;
			}
			else if (str[0] == 'W') {
				temp = open[1];
				open[1] = open[3];
				open[3] = open[6];
				open[6] = open[4];
				open[4] = temp;
			}
			else if (str[0] == 'R') {
				temp = open[2];
				open[2] = open[3];
				open[3] = open[5];
				open[5] = open[4];
				open[4] = temp;
			}
			else if (str[0] == 'L') {
				temp = open[2];
				open[2] = open[4];
				open[4] = open[5];
				open[5] = open[3];
				open[3] = temp;
			}
			sum += open[1];
		}
		printf("%d\n", sum);
	}
	return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std;
long long n,m,v,p,a[100005],ans,ne[100005];
bool check(int val){
    long long b[100005];
    memcpy(b,a,sizeof(a));
    b[val]+=m;
    long long tot=m*(v-1),big=0;
    for(int i=1;i<=n;i++){
        if(i<val){
            b[i]+=min(m,tot);
            tot-=min(m,tot);
        }
        if(i>val){
            if(b[i]>b[val]){
                b[i]+=min(m,tot);
                tot-=min(m,tot);
                big++;
                continue;
            }
            tot-=min(b[val]-b[i],tot);
            b[i]+=min(b[val]-b[i],tot);
        }
    }
    for(int i=n;i>val;i--)
        if(b[i]<=b[val]&&tot){
            tot-=min(a[i]+m-b[i],tot);
            b[i]+=min(a[i]+m-b[i],tot);
            big++;
        }
    return big<=p-1;
}
int main(){
    cin>>n>>m>>v>>p;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    sort(a+1,a+n+1);
    a[n+1]=1e9+5;
    for(int i=n;i>=0;i--){
        if(a[i+1]!=a[i])
            ne[i]=i;
        else ne[i]=ne[i+1];
    }
    int l=1,r=n+1,mid;
    while(l<=r){
        mid=(l+r)>>1;
        if(check(mid)){
            ans=n-mid+1;
            r=mid-1;
        }else l=mid+1;
    }
    cout<<ans<<'\n';
}
/*
Damn! I mean, Easy.
*/

Measured memory_bytes: 5988
/*
author : shah_entrance
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    string s;
    map<ll,ll>m;
    ll i;
    cin>>s;
    for(i=0;i<s.length();i++)
    {
        ll temp=s[i];
        m[s[i]]+=1;
    }
    if(m[97]==1 && m[98]==1 && m[99]==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

int main() {
    long long n, x, cnt = 0;
    std::cin >> n >> x;
    std::vector<long long> a(n);
    for (int i = 0; i < n; i++) std::cin >> a[i];
    std::sort(a.begin(), a.end());
    for (int i = 0; i < n; i++) {
        x -= a[i];
        cnt++;
        if (x < 0) {
            break;
        }
    }

    std::cout << cnt - (x != 0 ? 1 : 0) << std::endl;

    return 0;
}

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


int main(){
  vector<int> m;
  m.clear();
  for(int i = 0;i<5;i++){
    int n;
    cin>>n;
    m.push_back(n);
  }
  int ans = 0;
  for(int i=0;i<m.size();i++){
    ans+=max(40,m[i]);
  }
  cout<<ans/m.size()<<endl;

}

Measured memory_bytes: 3140
#include<stdio.h>
int main(){
  int x;
  char s[100];
  int S[100];
  int top=0;
  while(scanf("%s",s)!=EOF){
    if(s[0]=='+'){
      S[top-2]=S[top-2]+S[top-1];
      top=top-1;  
    }else if(s[0]=='-'){
      S[top-2]=S[top-2]-S[top-1];
      top=top-1;
    }else if(s[0]=='*'){
      S[top-2]=S[top-2]*S[top-1];
      top=top-1; 
    }
    else{
      x=atoi(s);
      S[top]=x;
      top++;
    }
  }
  printf("%d\n",S[top-1]);
  return 0;
}

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

int main()
{
	string s, t, u;
	int a, b;
	cin >> s >> t;
	cin >> a >> b;
	cin >> u;

	if (s == u) {
		a -= 1;
	}
	else if(t==u){
		b -= 1;
	}
	else {
		return 0;
	}

	cout << a << " " << b << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
 
int search(int A[],int n,int key){
 
int i = 0;
A[n] = key;
while(A[i] != key)i++;
return i != n;
}
 
 
int main(){
int i,n,A[100000],q,key,sum = 0;
 
scanf("%d",&n);
for(i=0;i<n;i++)scanf("%d",&A[i]);
 
scanf("%d",&q);
for(i=0;i<q;i++){
  scanf("%d",&key);
  if(search(A,n,key))sum++;
}
printf("%d\n",sum);
 
return 0;
}



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

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<

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

ll slova[26];
string s;

int main(){
    cin >> s;
    REP(i, s.size()){
        ++slova[s[i] - 'a'];
    }
    ll sol = s.size() * (s.size() - 1) / 2 + 1;
    REP(i, 26){
        sol -= slova[i] * (slova[i] - 1) / 2;
    }
    cout << sol;
return 0;
}


Measured memory_bytes: 640
/*
 ********************************************************************************
 *  Author: ThoseBygones
 *  Version: V1.0
 *  Date: 2018-06-27
 *  Subject: ACM-ICPC
 *  Language: C/C++11
 *  OJ: AOJ
 *  Algorithm:
 ********************************************************************************
 *  Algo-Description:
 ********************************************************************************
 */

//#include <bits/stdc++.h>  //For CodeForces only

//#pragma comment(linker,"/STACK:102400000,102400000")
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <ctime>
#include <numeric>
#include <vector>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <complex>
#include <deque>
#include <functional>
#include <list>
#include <map>
#include <string>
#include <sstream>
#include <set>
#include <stack>
#include <queue>
using namespace std;
template<class T> inline T sqr(T x)
{
    return x * x;
}
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<PII, int> PIII;
typedef pair<LL, LL> PLL;
typedef pair<LL, int> PLI;
typedef pair<LD, LD> PDD;
#define MP make_pair
#define PB push_back
#define sz(x) ((int)(x).size())
#define clr(ar,val) memset(ar, val, sizeof(ar))
#define istr stringstream
#define FOR(i,n) for(int i=0;i<(n);++i)
#define forIt(mp,it) for(__typeof(mp.begin()) it = mp.begin();it!=mp.end();it++)
const double EPS = 1e-6;
const int INF = 0x3fffffff;
const LL LINF = INF * 1ll * INF;
const double PI = acos(-1.0);

#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define lowbit(u) (u&(-u))
#define MAXN 105

int g[MAXN][MAXN];
bool vis[MAXN];
int step[MAXN];
int n;

void bfs(int x)
{
    vis[x]=true;
    queue <int> q;
    step[x]=0;
    q.push(x);
    while(!q.empty())
    {
        int u=q.front();
        q.pop();
        for(int v=1; v<=n; v++)
        {
            if(g[u][v] && !vis[v])
            {
                vis[v]=true;
                step[v]=step[u]+1;
                q.push(v);
            }
        }
    }
}

int main()
{
    scanf("%d",&n);
    for(int i=0; i<n; i++)
    {
        int u,num;
        scanf("%d%d",&u,&num);
        while(num--)
        {
            int v;
            scanf("%d",&v);
            g[u][v]=1;
        }
    }
    bfs(1);
    for(int i=1; i<=n; i++)
    {
        if(!vis[i])
            step[i]=-1;
    }
    for(int i=1; i<=n; i++)
        printf("%d %d\n",i,step[i]);
    return 0;
}



Measured memory_bytes: 3212
using System.Collections.Generic;
using System.Linq;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var r = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var len = r.Max();
            int ret = 0;
            Dictionary<int,int> dic = new Dictionary<int, int>();
            for (int i = 0; i < N; i++)
            {
                if (!dic.ContainsKey(r[i]))
                {
                    dic.Add(r[i],1);
                }
                else
                {
                    dic[r[i]]++;
                }
            }

            for (int i = 0; i <= len; i++)
            {
                int tmpRet = 0;
                if (dic.ContainsKey(i - 1))
                {
                    tmpRet += dic[i - 1];
                }
                if (dic.ContainsKey(i))
                {
                    tmpRet += dic[i];
                }
                if (dic.ContainsKey(i + 1))
                {
                    tmpRet += dic[i + 1];
                }

                if (ret <= tmpRet)
                {
                    ret = tmpRet;
                }
            }

            Console.WriteLine(ret);
        }
        
    }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int n, d;
	cin >> n >> d;
	vector< vector<int> > x(n, vector<int>(d));

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

	int ans = 0;
	for(int i = 0; i < n - 1; ++i)
	{
		for(int j = i + 1; j < n; ++j)
		{
			int sq_sum = 0;
			for(int k = 0; k < d; ++k)
			{
				int dif = x[i][k] - x[j][k];
				sq_sum += dif * dif;
			}
			if (fmod(abs(sqrt(sq_sum)), 1.0) <= 0.001)
			{
				ans++;
			}
		}
	}
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 3684
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    var s: String = next()
    println(s.replace(",", " "))
}

fun next() = readLine()!!

fun println(value : Any) {
    pw.println(value)
}

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

#ifdef _DEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif

using namespace std;

int main() {
    int64_t N, A, B;
    cin >> N >> A >> B;

    cout << N / (A + B) * A + min(A, N % (A + B)) << endl;
}

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

ll gcd(ll a, ll b){
  if(b == 0) return a;
  else return gcd(b , (a%b));
}

bool possible(ll a, ll b, string s, string t){
  ll gcdVal = gcd(a , b);
  ll pointerA = 0, pointerB = 0;
  ll addA = a / gcdVal, addB = b / gcdVal;

  bool flag = true;
  while((pointerA + addA) <= a && (pointerB + addB) <= b){
    if(s[pointerA] != t[pointerB]){
      flag = false;
      break;
    }
    pointerA += addA;
    pointerB += addB;
  }
  return flag;
}

void solve(ll a, ll b, string s, string t){
  if(possible(a , b , s , t) == true){
    cout << (a*b)/gcd(a,b) << endl;
  }
  else cout << - 1 << endl;
}

int main(){
  ll a, b;
  string s, t;
  cin >> a >> b;
  cin >> s >> t;

  solve(a , b, s , t);
}

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

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    VI m(n);
    REP(i, n) cin >> m[i];

    sort(ALL(m));
    FOR(i, 1, n - 1) x -= m[i];
    int ans = n - 1;
    ans += x / m[0];
    cout << ans << endl;
    
    return 0;
}


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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    cout << min(B/A, C) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,s,n) for(int i=s;i<n;i++)
#define fi first
#define se second
#define all(c) c.begin(),c.end()
typedef long long int ll;
typedef pair<int, int> P;
typedef long double ld;
void Ans(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}

const ll INF=1001001001;
const ll mod=1000000007;

int main(){
  string s;
  cin>>s;
  if(s=="ABC") cout<<"ARC"<<endl;
  else cout<<"ABC"<<endl;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる



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

  int n;
  cin>>n;

  repo(i,1000){
    if(i*(i+1)/2==n) {
      cout << "Yes" << endl;
      cout << i+1 << endl;
      vector<vector<int>> p(i+1);
      int a=0;
      int b=1;
      repo(j,n+1){
        p[a].pb(j);
        p[b].pb(j);
        b++;
        if(b==i+1) {
          a++;
          b=a+1;
        }
      }
      rep(j,i+1){
        cout << i << " ";
        rep(k,i){
          cout << p[j][k];
          if(k!=i-1) cout << " ";
        }
        cout << endl;
      }
      return 0;
    }
    if(i*(i+1)/2>n) {
      cout << "No" << endl;
      return 0;
    }
  }

}

Measured memory_bytes: 4316
#include<bits/stdc++.h>
using namespace std;
bool b[26];
int main()
{
    string s;
    cin>>s;
    int inmu=s.size();
    for(int i=0;i<inmu;i++){
        b[s[i]-97]=true;
    }
    for(int i=0;i<26;i++){
        if(b[i]==false){
            cout<<(char)(i+'a')<<endl;return 0;
        }
    }
    cout<<"None"<<endl;
}



Measured memory_bytes: 512
import numpy as np

W,H,N=list(map(int,input().split(" ")))
D=np.full((H,W),"w",np.str) # 長方形

# 各点について、黒色に塗りつぶしてゆく
for _ in range(N):
    x,y,a=list(map(int,input().split(" ")))
    
    if a==1: # x未満の領域 
        D[:,:x]="b"
    elif a==2: # xより大きい領域
        D[:,x:]="b"
    elif a==3: # y未満の領域
        D[:y,:]="b"
    elif a==4: # yより大きい領域
        D[y:,:]="b"

print(np.sum(D=="w"))

Measured memory_bytes: 14056
#include<stdio.h>
int main()
{
    int a,b,c=0,s=0;
    scanf("%d%d",&a,&b);
    if(b==1)
    {
        printf("0\n");
        return 0;
    }
    while(s<=b)
    {
        s+=(a-1);
        c++;
        if(s+1>=b)
            break;
    }
    printf("%d\n",c);
    return 0;
}


Measured memory_bytes: 128
a, b, k = map(int, input().split())
li = list(range(1, min(a, b)+1))
temp_li = []
for i in range(len(li)):
    if a % li[i] == b % li[i] == 0:
        temp_li.append(li[i])
temp_li = temp_li[::-1]
print(temp_li[k-1])


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int ab = sc.nextInt();
    int bc = sc.nextInt();
    int ca = sc.nextInt();
    System.out.println(ab*bc/2);
    
    
    
    
    
    }
 }

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(){
	
	int n; cin>>n;
	vector<int> a(n);
	for(auto &i:a) cin>>i;
	ll sum{};
	for(int i=0; i<n; i++){
		sum += a.at(i);
	}
	int b{-1};
	ll sum2{};
	for(int i=0; i<n; i++){
		sum2 += a.at(i);
		if(sum2*2>sum) {
			sum2 -= a.at(i);
			b = i;
			break;
		}
	}
	cout << abs( a.at(b)-abs( sum2-( sum-(sum2+a.at(b)) ) ) ) << endl;
	
	
}



Measured memory_bytes: 1024
#include <iostream>
#include <valarray>
#include <cmath>
#include <algorithm>

using namespace std;

typedef valarray<int> array_t;

array_t multiply(valarray<array_t> &A, array_t &b){
	array_t c(0,A.size());
	if(A[0].size() != b.size()) return c;
	for(int i = 0; i < A.size(); i++){
		for(int j = 0; j < A[0].size(); j++){
			c[i] += A[i][j] * b[j];
		}
	}
	return c;
}

int main(){
	int n,m;
	cin >> n >> m;
	valarray<array_t> A(array_t(0,m),n);
	array_t b(0,m);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> A[i][j];
		}
	}
	for(int i = 0; i < m; i++) cin >> b[i];
	array_t c = multiply(A,b);
	for(int i = 0; i < c.size(); i++){
		cout << c[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1240
n = gets.to_i
m = gets.split.map(&:to_i)

n.times do |i|
	answer = ""
	answer += "node #{i + 1}: key = #{m[i]}, "
	answer += "parent key = #{ m[(i + 1)/2 - 1 ]}, " if i != 0
	answer += "left key = #{m[2*i + 1]}, " if  m[2*i + 1]
	answer += "right key = #{m[2*i + 2]}, " if  m[2*i + 2]
	puts answer
end

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

using namespace std;


void solve() {
    int n; cin >> n;
    int cnt[3] = {};
    for (int _ = 0; _ < n; _++) {
        int x; cin >> x;
        if ((x&3) == 0) cnt[2]++;
        if ((x&3) == 2) cnt[1]++;
        if ((x&1) == 1) cnt[0]++;
    }
    if (cnt[0] == 0) {
        cout << "Yes"; return;
    }
    if (cnt[1]) cnt[0]++;
    if (cnt[2] >= cnt[0]-1) {
        cout << "Yes";
    } else {
        cout << "No";
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


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

using namespace std;

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v; stringstream ss(s); string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}
#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }
void err(vector<string>::iterator it) {}
template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int n, x; cin >> n >> x;
	vector<int> a(n);
	REPU(i, 0, n) cin >> a[i];
	sort(ALL(a));
	int ans = 0;
	int ox = x;
	REPU(i, 0, n) {
		if (x >= a[i]) {
			x -= a[i];
			ans++;
		}
		else {
			x = 0;
			break;
		}
	}
	if (x > 0) ans--;
	if (ans == 0) {
		REPU(i, 0, n) if (a[i] == ox) {
			ans = 1; break;
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        for(int i = 1; ; i++){
            int x = sc.nextInt();
            if(x==0){
                break;
            }
            System.out.printf("Case %d: %d\n",i,x);
        }
    }
}


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

#define debug(x) cerr << #x << ": " << x << endl

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int x = max(a, c), y = min(b, d);
  cout << max(0, y - x);
  return 0;
}

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

from collections import deque

COMMAND = ("insert", "delete", "deleteFirst", "deleteLast")

if __name__ == "__main__":
    n = int(input())
    ans = deque()
    for i in range(n):
        com = input().split()
        if com[0] == COMMAND[0]:
            ans.appendleft(com[1])
        elif com[0] == COMMAND[1]:
            if com[1] in ans:
                ans.remove(com[1])
        elif com[0] == COMMAND[2]:
            ans.popleft()
        elif com[0] == COMMAND[3]:
            ans.pop()
    print(" ".join(ans))

Measured memory_bytes: 71812
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

N = int(read())
x = np.arange(1, N + 1, dtype=np.int64)
x[x % 3 == 0] = 0
x[x % 5 == 0] = 0
print(x.sum())


Measured memory_bytes: 43268
#include"bits/stdc++.h"

void Main() {
  int n;
  std::cin >> n;

  int b[n];
  for (int i = 0; i < n - 1; i++) {
    std::cin >> b[i];
  }

  int sum = b[0];
  for (int i = 1; i < n - 1; i++) {
    b[i] > b[i - 1] ? sum += b[i - 1] : sum += b[i];
  }

  std::cout << sum + b[n - 2] << std::endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}

Measured memory_bytes: 256
public class Hello{
    public static void Main(){
        
        string line1 = System.Console.ReadLine();
        string[] array = line1.Split(' ');
        
        int a = int.Parse(array[0]);
        int b = int.Parse(array[1]);
        int c = int.Parse(array[2]);
        int k = int.Parse(array[3]);
        
        int result = 0;
        
        if(a > k)
        {
            result = k;
        }
        else
        {
            result += a;
            k -= a;
            
            if(k > 0)
            {
                if(b <= k)
                {
                    k -= b;
                    
                    if(k > 0)
                    {
                        result -=k;
                    }
                }
                
                
            }
        }
        System.Console.WriteLine(result);
    }
}


Measured memory_bytes: 27488
n,k = map(int,input().split())
g = list(map(lambda x: int(x)-1,input().split()))

check = [-1] * n
now = 0
check[now] = 0
cnt = 0
while cnt < k:
    cnt += 1
    now = g[now]
    if check[now] != -1:
        sa = cnt - check[now]
        cnt = cnt + (k - cnt)//sa *sa
    else:
        check[now] = cnt
print(now+1)

Measured memory_bytes: 91940
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define bg begin()
#define en end()
#define DEBUG_LL(var) printf("the value of "#var" is %lld\n", var)
#define PRINT_ARRAY(name, i) printf("the value of "#name"[%d] is %lld\n", (i), name[(i)])
#define DEBUG_ARRAY(name, begin, end) REP(i, begin, end) PRINT_ARRAY(name, i)

#define pr_arr(name, a, b) \
  for (int i = (a); i < (b); i++) { \
    for (int j = (a); j < (b); j++) {\
      if (j > (a)) printf(" "); \
      printf("%lld", name[i][j]); \
    }\
    printf("\n");\
  }\

using namespace std;

typedef long long ll;

static const ll INF = 100000000005;

//   10    20  30
// 5   15

int A, B, Q;
vector<ll> s, t;

ll solve(ll x) {
  
  int si = upper_bound(s.bg, s.en, x) - s.bg;
  int ti = upper_bound(t.bg, t.en, x) - t.bg;
  
  
  ll sl = x - s[si-1]; ll tl = x - t[ti-1];
  ll l_l, l_r;
  if (sl<tl) {
    l_l = tl; l_r = sl + t[ti] - s[si-1];
  } else {
    l_l = sl; l_r = tl + s[si] - t[ti-1];
  }
  
  ll sr = s[si]-x; ll tr = t[ti]-x;
  ll r_l, r_r;
  if (sr<tr) {
    r_r = tr; r_l = sr + s[si] - t[ti-1];
  } else {
    r_r = sr; r_l = tr + t[ti] - s[si-1];
  }
  
  
  return min(min(l_r, l_l), min(r_r, r_l));

}

int main(void) {
    scanf("%d %d %d", &A, &B, &Q);
    
    s.pb(-1*INF-1); t.pb(-1*INF);
    rep(i, 0, A) {ll a; scanf("%lld", &a); s.pb(a);}
    rep(i, 0, B) {ll b; scanf("%lld", &b); t.pb(b);}
    s.pb(INF+1); t.pb(INF);
    
    
    
    rep(i, 0, Q) {
      ll x;
      scanf("%lld", &x);
      printf("%lld\n", solve(x));
    
    }

    

	return 0;
}


Measured memory_bytes: 3060
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	int a, b, c;
	cin>>a>>b>>c;
	a -= c;
	b += c;
	cout<<a/b<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define sz(v) (ll)(v).size()
#define inf 1e18
#define md 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define tel(a){cout<<a<<"\n";}
#define tell(a,b){cout<<a<<" | "<<b<<"\n";}
#define telll(a,b,c){cout<<a<<" | "<<b<<" | "<<c<<"\n";}
#define teln(v,n){cout<<"v- ";rep(o,0,n)cout<<v[o]<<" ";cout<<"\n";}
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define M 100010

int main(){
    
    ll n;cin>>n;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    rep(i,0,n){
    	if(!a[i]){
    		cout<<0;
    		return 0;
    	}
    }
    ll ans=1;
    rep(i,0,n){
    	if((ld)ans*(ld)a[i]<=inf)ans*=a[i];
    	else {ans=-1;break;}
    }
    cout<<ans;
    
    
    return 0;
}

Measured memory_bytes: 4400
N = int(input())
A = [0] * N
for i in range(N):
    A[i] = int(input())

A.sort()
mn = A[:N//2]
mx = A[N//2:][::-1]

C = [0]*N
C[0] = mx[-1]
mxi,mni = 0,0
for i in range(1,N):
    if mxi != mni:
        C[i] = mx[mxi]
        mxi += 1
    else:
        C[i] = mn[mni]
        mni += 1
s = 0
for i in range(N-1):
    s += abs(C[i+1]-C[i])


if N % 2 == 1:
    D = [0]*N
    D[0] = mx[-1]
    mxi,mni = 0,0
    for i in range(1,N):
        if mxi != mni:
            D[i] = mn[mni]
            mni += 1
        else:
            D[i] = mx[mxi]
            mxi += 1
    s2 = 0
    for i in range(N-1):
        s2 += abs(D[i+1]-D[i])
    print(max(s,s2))

else:
    print(s)


Measured memory_bytes: 48216
N = int(input())
H = list(map(int,input().split()))
dp = {N-1:0}
def f(n):
    if n in dp:
        return dp[n]
    if H[n] >= H[n+1]:
        dp[n] = 1+dp[n+1]
        return dp[n]
    else:
        dp[n] = 0
        return 0
maxc = 0
for i in range(N-1,-1,-1):
    maxc = max(maxc, f(i))
print(maxc)

Measured memory_bytes: 23360
import java.util.Scanner;
public class Main {
    public static void main(String[] args) throws Exception {
        Scanner stdIn= new Scanner(System.in);
        int x = stdIn.nextInt();
        int y = stdIn.nextInt();
        int [] high = new int[x];
        boolean [] gx=new boolean[x];	
        for(int i=0;i<x;i++){
            high[i] = stdIn.nextInt();
            gx[i]=true;
        }
        
        int count=0;
        for(int i=0;i<y;i++){
            int a = stdIn.nextInt();
            int b = stdIn.nextInt();
            a--;
            b--;
            if(high[b]<high[a]){
                gx[b]=false;
            }else if(high[b]==high[a]){
                gx[a]=false;
                gx[b]=false;
            }else gx[a]=false;
        }
        for(int i=0;i<x;i++){
            if(gx[i]){
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 59740
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m);
    for (int i = 0; i < m; ++i) {
        cin >> a[i] >> b[i];
        --a[i];
    }

    for (int i = 0; i < 1000; ++i) {
        auto x = to_string(i);
        if (x.size() != n) continue;

        int ok = 1;
        for (int i = 0; i < m; ++i) {
            if (x[a[i]]-'0' != b[i]) {
                ok = 0;
                break;
            }
        }

        if (ok) {
            cout << x << '\n';
            return 0;
        }
    }

    cout << "-1\n";
    return 0;
}



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

#define all(x) (x).begin(),(x).end()

#define MOD 1000000007

using namespace std;

int main(){
	int s,w;
	cin >> s >> w;

	if( s > w )	cout << "safe" << endl;
	else	cout << "unsafe" << endl;

	return 0;
}


Measured memory_bytes: 3636
a, b, c = map(int, input().split())
amaris = set()
index = 0
while True:
    amari = a * index % b
    if amari == c:
        print('YES')
        break
    elif amari in amaris:
        print('NO')
        break
    else:
        amaris.add(amari)
    index += 1

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

string s="snuke";

int main(void){
	int h,w;
	cin >> h >> w;
	rep(i,1,h+1)rep(j,1,w+1){
		string t;
		cin >> t;
		if(s==t) cout << char(j+'A'-1) << i  << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>

int main(){
  int x, y, z;
  while( true ){
    scanf("%d %d", &x, &y);
    if(x == 0 && y == 0) break;
    if(x > y){
      z = y;
      y = x;
      x = z;
    }
    printf("%d %d\n", x, y);
  }
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, w, i, j, k, t, p[200][200] = {0}, a[200], b[200], ans = 0;
    vector <long long> g[5];

    cin >> n >> w;

    for(i = 0; i < n; ++i)
    {
        cin >> a[i] >> b[i];
        g[a[i] - a[0]].push_back(b[i]);
    }
    sort(g[0].rbegin(), g[0].rend());
    sort(g[1].rbegin(), g[1].rend());
    sort(g[2].rbegin(), g[2].rend());
    sort(g[3].rbegin(), g[3].rend());

    for(i = 0; i < 4; ++i)
    {
        for(j = 1; j <= g[i].size(); ++j)
            p[i][j] = p[i][j - 1] + g[i][j - 1];
    }
    for(i = 0; i <= g[0].size(); ++i)
    {
        for(j = 0; j <= g[1].size(); ++j)
        {
            for(k = 0; k <= g[2].size(); ++k)
            {
                for(t = 0; t <= g[3].size(); ++t)
                {
                    if(i * a[0] + j * (a[0] + 1) + k * (a[0] + 2) + t * (a[0] + 3) <= w)
                        ans = max(ans, p[0][i] + p[1][j] + p[2][k] + p[3][t]);
                }
            }
        }
    }
    cout << ans;

return 0;
}


Measured memory_bytes: 512
import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())
n,s=reads()
a=list(reads())
mod= 998244353
f=[[] for i in range(n+1)]
for k in range(1,n+1):
  if k==1:
    res=[0]*(s+1)
    res[0]=1
    if a[0]<s+1:
      res[a[0]]=1
    f[1]=res
    continue
  res=f[k-1][:]
  k-=1
  for i in range(s,-1,-1):
    if i-a[k]>=0:
      res[i]+=res[i-a[k]]
      res[i]%=mod
  if a[k]<s+1:
      res[a[k]]+=1
  res[0]+=1
  f[k+1]=res
ans=0
#print(f)
for i in range(1,n+1):
  ans+=f[i][-1]
ans%=mod
print(ans)

Measured memory_bytes: 111580
using System;
using System.Collections.Generic;

public class test
{
    public static void Main()
    {
        bool judge = true;
        int[] data = new int[2];
        List<string> word = new List<string>();

        while (judge)
        {
            string[] s_data = Console.ReadLine().Trim().Split(' ');
            for(int i = 0; i < s_data.Length; i++)
            {
                data[i] = int.Parse(s_data[i]);
            }

            if (data[0] == 0 && data[1] == 0)
            {
                judge = false;
            }
            else
            {
                Array.Sort(data);
                string ans = data[0] + " " + data[1];
                word.Add(ans);
            }
        }

        for(int i = 0; i < word.Count; i++)
        {
            Console.WriteLine(word[i]);
        }
    }
}

Measured memory_bytes: 9524
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>

using namespace std;

const int MAXN = 100000 + 1000;

struct Edge
{
	int next, to;
}
e[2 * MAXN];
int p[MAXN], l = 2;

void addE(int x, int y)
{
	e[l] = (Edge){p[x], y};
	p[x] = l++;
}

int n, m;
int ans = 0;

int dfs(int x, int fa)
{
	int ret = 0;
	for(int i = p[x]; i;i = e[i].next)
		if(e[i].to != fa)
		{
			int tmp = dfs(e[i].to, x);
			if(tmp == m - 1)
				ans += (x != 1);
			else
				ret = max(ret, tmp + 1);
		}
	// cerr << x << ' ' << ret << endl;
	return ret;
}

int main()
{
	ios::sync_with_stdio(false);
	// freopen("1.in", "r", stdin);
	// freopen("1.out", "w", stdout);

	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		int x;
		cin >> x;
		if(i == 1)
			ans += (x != 1);
		else
			addE(i, x), addE(x, i);
	}
	dfs(1, 0);

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define all(x) (x).begin(),(x).end()
#define V vector
typedef V<int> vi;
typedef V<vi> vvi;
typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
constexpr auto INF = INT_MAX >> 1;
constexpr auto LINF = 5000000000000000;
constexpr auto MOD = 1000000007;

int main() {

	int n;
	cin >> n;
	vi a(n);
	rep(i, n)cin >> a[i];

	ll ans = a[0] - 1;
	int k = 2;
	rep1(i, n - 1) {
		if (a[i] == k)k++;
		if (a[i] <= k)continue;
		ans += (a[i] - 1) / k;
	}

	cout << ans << endl;
	
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
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;
}
int main() {
    int N;
    int T, A;
    cin >> N >> T >> A;
    int h[1010];
    rep(i, 0, N) { cin >> h[i]; }
    double min = 100000.0;
    int res;
    rep(i, 0, N) {
        double dif = abs((double)A - ((double)T - (double)h[i] * 0.006));
        if(min > dif) {
            res = i + 1;
            min = dif;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#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()
{
   char s;
   cin >> s;

   if (isupper(s))
   {
       cout << "A" << endl;
   }
   else
   {
       cout << "a" << endl;
   }

   return 0;
}

Measured memory_bytes: 3628
$\=8e18;($n,$k)=glob<>;@x=sort{$a-$b}<>;
for$i(0..$n-$k){
	for$j($i+$k-1..$n-1){
		@p=sort{$a-$b}map{/ /;$'}@x[$i..$j];
		$\-=$-=$\-($p[$k-1]-shift@p)*($x[$j]-$x[$i])until@p<$k
	}
}
print

Measured memory_bytes: 768
import java.util.Scanner;

public class Main{
    public static void main(String srgs[]) {
        int i = 0;

        Scanner sc = new Scanner(System.in);

        while (true) {

            int j = 0;
            char str[] = sc.nextLine().toCharArray();
            int a[] = new int[1000];
            if (str[0] == '0') {
                break;
            }

            for (i = 0; i < str.length; i++) {
                a[i] = str[i] - '0';
                j += a[i];
            }
            System.out.printf("%d\n", j);
        }

        sc.close();
    }
}


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

const int INF = 1 << 21;
const int MAX = 10003;
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
int n;
vector<P> adj[MAX];

void dijkstra() {
  priority_queue<P> PQ;
  int color[MAX], d[MAX];

  fill((int*)d, (int*)(d+MAX), INF);
  fill((int*)color, (int*)(color+MAX), WHITE);

  d[0] = 0;
  PQ.push(make_pair(0, 0));
  color[0] = GRAY;

  while (!PQ.empty()) {
    P f = PQ.top(); PQ.pop();
    int u = f.second;
    color[u] = BLACK;

    if (d[u] < f.first * (-1)) continue;

    rep(j, adj[u].size()) {
      int v = adj[u][j].first;
      if (color[v] == BLACK) continue;
      if (d[v] > d[u] + adj[u][j].second) {
	d[v] = d[u] + adj[u][j].second;
	PQ.push(make_pair(d[v] * (-1), v));
	color[v] = GRAY;
      }
    }
  }

  rep(i,n) {
    cout << i << ' ' << (d[i] == INF ? -1 : d[i]) << endl;
  }
}

int main() {
  cin >> n;  
  int u, k, v, c;
  rep(i,n) {
    cin >> u >> k;
    rep(j,k) {
      cin >> v >> c;
      adj[u].push_back(make_pair(v, c));
    }
  }

  dijkstra();
  return 0;
}



Measured memory_bytes: 8116
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>
#include <bitset>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

template<class T>
inline bool chmin(T &a, const T b) { return a > b && (a = b, true); }

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int H, W;
	cin >> H >> W;

	vector<vector<int>> A(H, vector<int>(W));
	vector<vector<int>> B(H, vector<int>(W));
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> A[i][j];
	for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> B[i][j];

	const int offset = 6500;
	vector<bitset<offset * 2 + 1>> dp(W + 1);
	dp[0][offset] = 1;
	for (int i = 0; i < H; i++) {

		for (int j = 0; j < W; j++) {
int shift = abs(A[i][j] - B[i][j]);
dp[j + 1] = dp[j + 1] | (dp[j] << shift) | (dp[j] >> shift);

		}
		DMP(dp);

		if (i == H - 1) break;
		vector<bitset<offset * 2 + 1>> tmp(W + 1);
		for (int j = 1; j <= W; j++) {
int shift = abs(A[i + 1][j - 1] - B[i + 1][j - 1]);
          DMP(shift);
tmp[j] = (dp[j] << shift) | (dp[j] >> shift);
		}
		swap(tmp, dp);
		DMP(dp);

	}

	int ans = INF;
	for (int i = 0; i <= 2 * offset; i++) {
		if (dp[W][i]) chmin(ans, abs(i - offset));
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 200001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

int main(){
  ll n,k; cin >> n >> k;  ll mod0 = n/k; ll modk2;
  ll ans = 0;
  
  for(ll i=1; i <= n; i++){
    if(i % k == (k/2)) modk2++;
  }
  
  if(k % 2 == 0){
    ans = pow(mod0,3) + pow(modk2,3);
  }
  else ans = pow(mod0,3);

  
  cout << ans << endl;
  
  
}

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

int main() {
  int n;
  scanf("%d", &n);
  vector<int> a(1 << n);
  for (int i = 0; i < (1 << n); i++)
    scanf("%d", &a[i]);
  vector<vector<int>> v(1 << n);
  for (int i = 0; i < (1 << n); i++)
    v[i].push_back(a[i]);
  for (int j = 0; j < n; j++) {
    for (int i = 0; i < (1 << n); i++) {
      if (!((i >> j) & 1)) {
        int to = i | (1 << j);
        for (int x : v[i])
          v[to].push_back(x);
        sort(v[to].begin(), v[to].end());
        reverse(v[to].begin(), v[to].end());
        v[to] = {v[to][0], v[to][1]};
      }
    }
  }
  int ans = 0;
  for (int i = 1; i < (1 << n); i++) {
    ans = max(ans, v[i][0] + v[i][1]);
    printf("%d\n", ans);
  }
  return 0;
}

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

using namespace std;

int main()
{
	int a,b,c;
	cin >> a >> b >> c;
	if(a > b) cout << "0";
	else if (a * c <= b)
	{
		cout << c;
	}
	else
	{
		cout << b / a;
	}

    return 0;
}

Measured memory_bytes: 256