akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <array>
#include <algorithm>
#include <cstring>
#include <string>
#include <vector>
using namespace std;

vector<int> solve(array<int,10> table){
    array<int,10> tmp,tmp2,tmp3;
    vector<int> v;

    for(int i=1;i<=9;i++){
        int p,j,k;

        tmp=table;
        if(++tmp[i]>4) continue;

        for(j=1;j<=9;j++){
            if(tmp[j]>=2){
                p=0;
                tmp2=tmp;
                tmp2[j]-=2;
                tmp3=tmp2;

                for(k=1;k<=9;k++){
                    if(k>2 && tmp2[k]>0 && tmp2[k-1]>0 && tmp2[k-2]>0){
                        tmp2[k]--;tmp2[k-1]--;tmp2[k-2]--;
                        p++;
                    }
                    if(k<9 && k>1 && tmp2[k]>0 && tmp2[k+1]>0 && tmp2[k-1]>0){
                        tmp2[k]--;tmp2[k+1]--;tmp2[k-1]--;
                        p++;
                    }
                    if(k<8 && tmp2[k]>0 && tmp2[k+1]>0 && tmp2[k+2]>0){
                        tmp2[k]--;tmp2[k+1]--;tmp2[k+2]--;
                        p++;
                    }
                }

                for(k=1;k<=9;k++){
                    if(tmp2[k]>=3){
                        p++;
                        tmp2[k]-=3;
                    }
                }

                if(p==4) break;

                p=0;
                for(k=1;k<=9;k++){
                    if(tmp3[k]>=3){
                        p++;
                        tmp3[k]-=3;
                    }
                }

                for(k=1;k<=9;k++){
                    if(k>2 && tmp3[k]>0 && tmp3[k-1]>0 && tmp3[k-2]>0){
                        tmp3[k]--;tmp3[k-1]--;tmp3[k-2]--;
                        p++;
                    }
                    if(k<9 && k>1 && tmp3[k]>0 && tmp3[k+1]>0 && tmp3[k-1]>0){
                        tmp3[k]--;tmp3[k+1]--;tmp3[k-1]--;
                        p++;
                    }
                    if(k<8 && tmp3[k]>0 && tmp3[k+1]>0 && tmp3[k+2]>0){
                        tmp3[k]--;tmp3[k+1]--;tmp3[k+2]--;
                        p++;
                    }
                }

                if(p==4) break;
            }
        }

        if(p==4){
            v.push_back(i);
        }
    }

    if(v.empty()){
        v.push_back(0);
    }

    return v;
}

int main(){
    string hand;
    vector<int> v;

    while(cin>>hand){
        array<int,10> table;
        table.fill(0);

        for(auto c:hand){
            table[c-'0']++;
        }

        v=solve(table);

        cout<<v[0];
        for(int i=1;i<v.size();i++){
            cout<<" "<<v[i];
        }
        cout<<endl;
    }

    return 0;
}

Measured memory_bytes: 1200
n, a, b, c = map(int,input().split())
l = []
for i in range(n):
    l.append(int(input()))
ans = 10**9    
for ci in range(4**n):
    ci_ = [-1] * n
    cnt = [0] * 3
    ca, cb, cc = 0, 0, 0
    for cj in range(n):
        cx = ci & 3
        if cx == 0:
            ca += l[cj]
            cnt[0] += 1 
        elif cx == 1:
            cb += l[cj]
            cnt[1] += 1 
        elif cx == 2:
            cc += l[cj]
            cnt[2] += 1 
        ci >>= 2
    if ca == 0 or cb == 0 or cc == 0:
        continue
    
    cost = 0
    for i in range(3):
        if cnt[i] > 1:
            cost += 10 * (cnt[i]-1)
    cost += abs(a-ca) + abs(b-cb) + abs(c-cc)
    ans = min(ans, cost)
print(ans)

Measured memory_bytes: 74628
//メモリ数確認したか?
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;
typedef long long int ll;
#define EPS 1e-4;
int main()
{
	while(true){
        double a;
		cin >> a;
		if(a<0)return 0;
		double x=128.0;
		string ans="";
		while(x>0.05){
			if(a>=x){
				a-=x;
				ans+='1';
			}
			else ans+='0';
			x/=2;
			if(x==0.5)ans+=".";
		}
		if(a==0){
		cout << ans << "\n";
		}
		else cout << "NA" << "\n";
	}
    return 0;
}
//メモリ数確認したか?

Measured memory_bytes: 1212
N = int(input())
A = [int(a) for a in input().split(" ")]

m_2_but_4 = 0
m_4 = 0
m_none = 0
for i in range(len(A)):
  if A[i] % 4 == 0:
    m_4 += 1
  elif A[i] % 2 == 0:
    m_2_but_4 += 1
  else:
    m_none += 1

if m_2_but_4:
  print("Yes") if m_4 >= m_none else print("No")
else:
  print("Yes") if m_4 + 1 >= m_none else print("No")

Measured memory_bytes: 20044
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        long a = in.nextLong();
        long b = in.nextLong();
        long ans = 0;
        if( (a&1) == 1 && (b&1) == 1 ) { // odd odd
            long diff = (b-a)/2;
            int one = 0;
            if( (diff&1) == 1 ) one = 1;
            ans = one^a;
        } else if ( (a&1) == 1 && (b&1) == 0 ) { // odd eeven
            long diff = (b-1-a)/2;
            int one = 0;
            if( (diff&1) == 1 ) one = 1;
            ans = b^one^a;
        } else if ( (a&1) == 0 && (b&1) == 1 ) { // even odd
            long diff = (b-a+1)/2;
            ans = 0;
            if( (diff&1) == 1 ) ans = 1;
        } else if ( (a&1) == 0 && (b&1) == 0 ) { // even even
            long diff = (b-a)/2;
            int one = 0;
            if( (diff&1) == 1 ) one = 1;
            ans = one^b;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23124
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;


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

char map[1010][1010];

int main()
{
  cin >> h >> w;
  string s[1010];
  for (int i = 0; i < h; i++)
  {
    cin >> s[i];
  }

  int check = 0;
  queue<pii> que;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      map[i][j] = s[i].at(j);
      if (map[i][j] == '#')
      {
        que.push(pii(i, j));
        check++;
      }
    }
  }
  int ans = 0;
  while (check < h * w)
  {
    queue<pii> que2;
    while (que.size() != 0)
    {
      pii p = que.front();
      que.pop();
      for (int i = 0; i < 4; i++)
      {
        int ny = p.first + dy[i];
        int nx = p.second + dx[i];

        if (0 <= ny && ny < h && 0 <= nx && nx < w && map[ny][nx] != '#')
        {
          que2.push(pii(ny, nx));
          check++;
          map[ny][nx] = '#';
        }
      }
    }
    swap(que, que2);
    ans++;
  }
  cout << ans << "\n";
}

Measured memory_bytes: 10512
using System;

namespace _062_WhatistheBottommost
{
	class Program
	{
		static void Main ( string[] args )
		{
			string inputStr;

			while ((inputStr = Console.ReadLine ()) != null)
			{
				int[] numArray = new int[10];

				//parse
				for (int lp = 0; lp < numArray.Length; lp++)
				{
					numArray[lp] = inputStr[lp] - '0';
				}

				//calculate
				for (int arrayLength = 9; arrayLength >= 1; arrayLength--)
				{
					for (int lp = 0; lp < arrayLength; lp++)
					{
						int num = numArray[lp] + numArray[lp + 1];
						num %= 10;
						numArray[lp] = num;
					}
				}

				//output
				Console.WriteLine (numArray[0]);
			}
		}
	}
}

Measured memory_bytes: 8980
import sys
from itertools import combinations

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60

N, M = map(int, readline().split())
S = [[] for _ in range(M)]
for i in range(M):
    _, *S[i] = [int(s) - 1 for s in readline().split()]
P = list(map(int, readline().split()))

ans = 0
for r in range(N + 1):
    for comb in combinations(range(N), r):
        switches = [False] * N
        for i in comb:
            switches[i] = True

        all_lit = True
        for j in range(M):
            if sum(switches[k] for k in S[j]) % 2 != P[j]:
                all_lit = False
                break

        if all_lit:
            ans += 1

print(ans)


Measured memory_bytes: 3064
class InputString():
    def __init__(self, S):
        self.S = S
        self.input_length = len(S)
        self.output = ""

    def toX(self):
        for _ in range(self.input_length):
            self.output += "x"


S = input()
input_string = InputString(S)
input_string.toX()
print(input_string.output)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
#define mp make_pair
#define pb push_back
#define fi first
#define sc second
using namespace std;

int n,x,cnt=0;
set<int> st;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x>=1 && x<400) st.insert(1);
		if(x>=400 && x<800) st.insert(2);
		if(x>=800 && x<1200) st.insert(3);
		if(x>=1200 && x<1600) st.insert(4);
		if(x>=1600 && x<2000) st.insert(5);
		if(x>=2000 && x<2400) st.insert(6);
		if(x>=2400 && x<2800) st.insert(7);
		if(x>=2800 && x<3200) st.insert(8);
		if(x>=3200) cnt++;
	}
	cout<<max((int)st.size(), 1)<<" "<<st.size()+cnt<<endl;
	return 0;
}

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

#ifdef DEBUG
#define PRINT(x)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#x<<" = "<<(x)<<endl;
#define PRINTA(a,first,last)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<(first)<<", "<<(last)<<")"<<endl;\
    for (int _i=(first);_i<(last);++_i){cout<<#a<<"["<<_i<<"] = "<<(a)[_i]<<endl;}
#define PRINTI(a,i)\
    cout<<"func "<<__func__<<": line "<<__LINE__<<": "<<#a<<"["<<#i<<"] = "<<#a<<"["<<(i)<<"] = "<<(a)[i]<<endl;
#define dprintf(...) printf(__VA_ARGS__)
#else
#define PRINT(x)
#define PRINTA(a,first,last)
#define PRINTI(a,i)
#define dprintf(...)
#endif

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define MOD 1000000007
//#define MOD 998244353

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

template <class T, class U> void amax(T& x, U y) {if (x < y) x = y;}
template <class T, class U> void amin(T& x, U y) {if (x > y) x = y;}

template <class T, class U>
std::ostream& operator<<(std::ostream &os, const std::pair<T, U> &p) {
	os << "(" << p.first << ", " << p.second << ")";
	return os;
}
 
template <class T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v) {
    os << "[";
	for (int i = 0; i < v.size(); ++i) {
        if (i) {
            if (i % 5 == 0) {
                os << ",\n ";
            } else {
                os << ", ";
            }
        }
		os << v[i];
	}
	os << "]";
	return os;
}

template <class T>
using vec2 = vector<vector<T>>;

template <class T>
using vec3 = vector<vector<vector<T>>>;

template <class T>
vec2<T> vec2_init(int n0, int n1, T x = 0) {
    return vec2<T>(n0, vector<T>(n1, x));
}

template <class T>
vec3<T> vec3_init(int n0, int n1, int n2, T x = 0) {
    return vec3<T>(n0, vec2_init(n1, n2, x));
}

/*
 *           U P
 *           - x
 *            ^
 *            |
 * LEFT -y <--+--> +y RIGHT
 *            |
 *            v
 *           + x
 *         D O W N
 */

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

enum {
    DOWN,
    RIGHT,
    UP,
    LEFT,
};

constexpr double inf = numeric_limits<double>::infinity();

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

    int N;
    cin >> N;
    int cnt = 0;
    REP(_, N) {
        int x, y;
        cin >> x >> y;
        if (x == y) {
            ++cnt;
            if (cnt == 3) {
                cout << "Yes" << endl;
                return 0;
            }
        } else {
            cnt = 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


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

typedef long long  int ll;

#define s(t) scanf("%I64d",&t)
#define s2(t,t1) scanf("%I64d%I64d",&t,&t1)


ll n,a[100005][3];
int main()
{
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i][0]>>a[i][1]>>a[i][2];
        a[i][0]+= max(a[i-1][1],a[i-1][2]);
        a[i][1]+= max(a[i-1][0],a[i-1][2]);
        a[i][2]+= max(a[i-1][1],a[i-1][0]);

    }
    cout<<max(a[n][2],max(a[n][0],a[n][1]))<<endl;



}


Measured memory_bytes: 2560
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(K: int, X: int):
    A = []
    for i in range(2*K-1):
        A.append(str(X-K+i+1))
    print(' '.join(A))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    K = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(K, X)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5432
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    a,b,c = LMIIS()
    YN((( a==b and a != c)or (b==c and b!=a) or (c==a and c!=b)))


if __name__ == '__main__':
    main()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define FOR(i,a,b) for (register int i=(a);i<=(b);i++)
#define For(i,a,b) for (register int i=(a);i>=(b);i--)
#define mem(i,j) memset(i,j,sizeof(i))
#define GO(u) for (register int j=f[u];j!=-1;j=nxt[j])
using namespace std;
typedef long long ll;
const int N=1010;
int n,m,a,b,ans[N][N];
inline int read()
{
	int x=0,f=1;
	char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
	while (c>='0'&&c<='9') {x=(x<<1)+(x<<3)+c-'0';c=getchar();}
	return f*x;
}
inline void write(int x)
{
	if (x<0) putchar('-'),x=-x;
	if (x>9) write(x/10);
	putchar(x%10+'0');
	return;
}
int main()
{
	n=read(),m=read(),a=read(),b=read();
	FOR(i,1,n)
	{
		FOR(j,1,m)
		{
			if (i<=b&&j<=a) ans[i][j]=1;
			else if (i>b&&j>a) ans[i][j]=1;
			else ans[i][j]=0;
		}
	}
	FOR(i,1,n)
	{
		FOR(j,1,m) printf("%d",ans[i][j]);
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 5120
#include<cstdio>
#include<cstring>
#include<functional>
#include<algorithm>
#include<iostream>
#define rep(i,a) for(i=0;i<a;i++)
#define rep2(i,a) for(i=1;i<a;i++)
using namespace std;
int main(void) 
{
	int gyoretu[102][102];
	int r,c,i,j,sum;
	cin>>r>>c;
	rep(i,r)rep(j,c) cin>>gyoretu[i][j];
	rep(i,r) {
		sum=0;
		rep(j,c) sum+=gyoretu[i][j];
		gyoretu[i][j]=sum;
	}
	rep(i,c+1) {
		sum=0;
		rep(j,r)sum+=gyoretu[j][i];
		gyoretu[j][i]=sum;
	}
	rep(i,r+1) {
		cout<<gyoretu[i][0];
		rep2(j,c+1) {
			if(j==c+1) cout<<gyoretu[i][j];
			else cout<<" "<<gyoretu[i][j];
		}
		cout<<endl;
	}
	return 0;
}
			

Measured memory_bytes: 3108
n, m = (int(i) for i in input().split())
lr = [[int(i) for i in input().split()] for i in range(m)]
lr.sort(key=lambda x:x[0])
low = 1
high = n
for l,e in lr:
    if low < l:
        low = l
    if high > e:
        high = e
if high >= low:
    print(high-low+1)
else:
    print("0")

Measured memory_bytes: 64344
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main(){
    int x,ans=0; cin>>x;
    rep(i,x/100+1){
        int a=x-100*i;
        if(0<=a && a<=5*i) ans=1;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>  // std::setprecision()
#include <set>

using namespace std;
using ll = long long;
#define rep(i,a,b) for(ll i=(a); i<(b); i++)
#define YES cout << "YES" << endl;
#define NO cout << "NO" << endl;
#define yes cout << "Yes" << endl;
#define no cout << "No" << endl;
#define pai 3.14159265358979323846
ll gcd(ll a, ll b){if (a%b == 0)  return(b);else  return(gcd(b, a%b));}
ll lcm(ll a, ll b){return a * b / gcd(a, b);}
/* map<string,int> */
/* 大文字を小文字に変換 tolower*/
/* 小文字を大文字に変換 toupper*/
/* 辞書順 next_permutation(a.begin(),a.end()) */
 
int main() {
    int n ;
    cin >>n;
    rep(i,0,30) {
        rep(j,0,30) {
            if (4*i + 7 * j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3004
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

const int N = 1e6;

ll a[N],v[N],b[N],t[N],p[N],f[N],sz,n;

bool cmp(int l,int r){return a[l]<a[r];}

ll sch(int lim){
    ll res=0;
    while(lim){
        res=max(res,t[lim]);
        lim-=lim&(-lim);
    }
    return res;
}
void upd(int lim,ll v){
    while(lim<=sz){
        t[lim]=max(t[lim],v);
        lim+=lim&(-lim);
    }
}

int main(){
    int n;
    cin>>n;
    for(int i=1;i<=n;++i)cin>>a[i],b[i]=i;
    for(int i=1;i<=n;++i)cin>>v[i];
    sort(b+1,b+n+1,cmp);
    for(int i=1;i<=n;++i){
        if(a[b[i]]>a[b[i-1]])++sz;
        p[b[i]]=sz;
    }

    ll ans=0;

    for(int i=1;i<=n;++i){
        f[i]=sch(p[i]-1)+v[i];
        upd(p[i],f[i]);
        ans=max(ans,f[i]);
    }

    cout<<ans;

    return 0;
}


Measured memory_bytes: 20224
from collections import deque
H,W = map(int,input().split())
S = [list(input()) for _ in range(H)]

def bfs(startx,starty):
    d = [[-1]*W for _ in range(H)]
    q = deque([[startx,starty]])
    d[startx][starty] = 0
    cnt = 0
    while(q):
        x,y = q.popleft()
        for i,j in ([1,0],[-1,0],[0,1],[0,-1]):
            new_x,new_y = x+i,y+j
            if(new_x>H-1 or new_x<0 or new_y>W-1 or new_y<0):
                continue
            elif(S[new_x][new_y] == "#"):
                continue
            elif(d[new_x][new_y] == -1):
                d[new_x][new_y] = d[x][y] + 1
                q.append([new_x,new_y])
                cnt = max(cnt,d[new_x][new_y])
    return cnt

ans = 0
for i in range(H):
    for j in range(W):
        if(S[i][j]=="."):
            ans = max(ans,bfs(i,j))
print(ans)

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

int main(){
 
  int K,A,B,n;
  cin >> K >> A >> B;
  
  n = (A/K+1)*K;
  
  if ((A % K == 0) || (n <= B))
    cout << "OK\n";
  else
    cout << "NG\n";

  return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    int D;
    ll G;
    cin >> D >> G;
    vector<ll> p(D), c(D);
    ll ans = 1e9;
    rep(i,D) cin >> p[i] >> c[i];
    for(int bit=0;bit<(1<<D);bit++){
        ll sum = 0;
        ll num = 0;
        rep(i,D){
            if(bit & (1<<i)){
                sum += c[i]+p[i]*100*(i+1);
                num += p[i]; //pは問題数
            }
        }
        if(sum >= G) ans = min(ans, num);
        else{
            for(int i=D-1; i>=0;i--){
                if(bit & (1<<i))continue;
                for(int j=0;j<p[i]; j++){
                    if(sum >= G)break;
                    sum += 100*(i+1);
                    num++;
                }
            }
            ans = min(ans, num);
        }
    }
    cout << ans << endl;
}


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

int main() 
{
	long long int n,a[1000],i,j,ans=0,f,l,c1=0,c2=0;
	
	string s;
	
	cin>>s;
	
	l=s.length();
	
	for(i=0;i<l;i++)
	{
	    if(i%2==0&&s[i]!='1')
	    {
	        c1++;
	    }
	    else if(i%2==1&&s[i]!='0')
	    {
	        c1++;
	    }
	}
	
	for(i=0;i<l;i++)
	{
	    if(i%2==1&&s[i]!='1')
	    {
	        c2++;
	    }
	    else if(i%2==0&&s[i]!='0')
	    {
	        c2++;
	    }
	}
	
	cout<<min(c1,c2);
	
	return 0;
}


Measured memory_bytes: 512
n, m, l = map(int, input().split())
a = list()
b = list()

for i in range(n):
    a.append(list(map(int, input().split())))

for i in range(m):
    b.append(list(map(int, input().split())))

for i in range(n):
    c = list()
    for j in range(l):
        total = 0
        for k in range(m):
            total += a[i][k] * b[k][j]
        c.append(total)
    print(*c)



Measured memory_bytes: 6576
#include "bits/stdc++.h"
using namespace std;

const int MAX_E = 2010;
const int MAX_V = 1010;

#define INF (1 << 29)

// 頂点と頂点を結ぶ辺についての構造体
struct edge { int from, to, cost; };

edge es[MAX_E]; // 辺

int d[MAX_V];
int V, E;

//	ベルマンフォード（単一始点最短経路（Negative Edges))
// 負の閉路が存在したら true を返す
bool bellman_ford(int s) {
	int cnt = 0;
	// 最短距離の初期化
	for (int i = 0; i<V; i++) d[i] = INF;
	// 頂点 s への最短距離は0
	d[s] = 0;
	while (true) {
		cnt++;
		bool update = false;
		// すべての辺に対して
		for (int i = 0; i < E; i++) {
			edge e = es[i];
			// この時点での e.to へ行くコストより e.from を経由して行く方がコストが小さいとき d[e.to] を更新する
			if (d[e.from] != INF && d[e.to] > d[e.from] + e.cost) {
				d[e.to] = d[e.from] + e.cost;
				// V回目のループで更新が行われた場合、負の閉路が存在する
				if(cnt == V) return true;
				update = true;
			}
		}
		// 更新がなければ終了
		if (!update) break;
	}
	return false;
}

int main() {
	int r;
	cin >> V >> E >> r;
	int from, to, cost;

	for (int i = 0; i<E; i++) {
		cin >> from >> to >> cost;
		es[i] = edge{ from, to, cost };
	}

	if (bellman_ford(r)) {
		cout << "NEGATIVE CYCLE" << endl;
	}
	else {
		for (int i = 0; i < V; i++) {
			if(d[i]==INF) cout << "INF" << endl;
			else cout << d[i] << endl;
		}
	}

}



Measured memory_bytes: 3116
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
typedef long long int ll;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define m0(x) memset(x,0,sizeof(x))

int main(void)
{
	int n,k,flag=0;
	scanf("%d %d",&n,&k);
	if(n%2==0){
		if(n/2<k) flag=1;
	}
	else{
		if((n+1)/2<k) flag=1;
	}

	if(flag==0) printf("YES\n");
	else printf("NO\n");
	return 0;
}

Measured memory_bytes: 128
function Main(input) {
  input = input.split("\n");
  var N = parseInt(input[0].split(" ")[0]);
  var D = parseInt(input[0].split(" ")[1]);
  input.shift();
  var P = input.map(i => i.split(" ").map(i => parseInt(i)));
  P.splice(N,P.length);
  var ans =0;
  for(var i=0;i<N;i++){
    if(Math.pow(P[i][0],2)+Math.pow(P[i][1],2)<=Math.pow(D,2)){
      ans++;
    }
  }


  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 91160
from heapq import heappush, heappop
X, Y, Z, K = map(int, input().split())
I = lambda: sorted(list(map(int, input().split())), reverse=True)
A = I()
B = I()
C = I()
hq = []

for a in A:
    for b in B:
        for c in C:
            if len(hq) < K:
                heappush(hq, a+b+c)
            else:
                tmp = heappop(hq)
                if tmp >= a+b+c:
                    heappush(hq, tmp)
                    break
                else:
                    heappush(hq, a+b+c)

ans = []
for _ in range(K):
    ans.append(heappop(hq))

ans.sort(reverse=True)
for x in ans:
    print(x)


Measured memory_bytes: 57180
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)

ll f(ll x){
    if(x%2)
        return 3*x+1;
    else
    {
        return x/2;
    }
    
}
void solve(long long s){
    ll cnt = 1, x=s;
    while(1){
        if(x == 4 || x== 2 || x== 1){
            cout << cnt + 3 << endl;
            return;
        }
        x = f(x);
        cnt++;
    }
}

int main(){
    long long s;
    scanf("%lld",&s);
    solve(s);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n,a,b;

int main(){
	cin>>n>>a>>b;
	cout<<min(n*a,b)<<endl;
}

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

int main()
{
  	string yes_no[]={"No","Yes"};
  	string str;
  	cin>>str;
  	int sn=0;
  	for(int i=0 ; i<str.length() ; ++i)
	sn+=(str[i]-'0');
  	cout<<yes_no[stoi(str)%sn==0]<<endl;
    return 0;
}

Measured memory_bytes: 256
until (n = gets.chomp) == "0"
  if n.chr == "-"
    n.slice!(0)
    head = nil
  else
    head = n.slice!(-1).to_i
  end
  n.reverse!

  result = []
  until n.empty?
    result << 10 - n.slice!(0).to_i
    result << 1 + n.slice!(0).to_i
  end

  result += [0, 0]
  (0...result.size).each do |i|
    next if result[i] < 10
    result[i] -= 10
    if result[i + 1] > 0
      result[i + 1] -= 1
    else
      result[i + 1] += 9
      result[i + 2] += 1
    end
  end

  result.unshift(head) if head
  p (result.reverse*"").to_i
end

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

bitset <1000001> primeArr;
void sieve()
{
	int num_sqrt = sqrt(1000000);
	primeArr[1] = 1;
	for (int i = 4; i <= 1000000; i += 2)
		primeArr[i] = 1;

	for (int i = 3; i <= num_sqrt; i += 2) {
		for (int j = 2; i*j <= 1000000; j++)
			primeArr[i*j] = 1;
	}
}

int primeFactor(int n, vector<int> &arr){
    int c = 0;
    while(n%2 == 0){
        arr[c++] = 2;
        n = n/2;
    }
    for(int i=3;i<=sqrt(n);i+=2){
        while(n%i == 0){
            arr[c++] = i;
            n = n/i;
        }
    }
    if(n >2)
        arr[c++] = n;
    return c;
}

string to_str(int n) {
	string s;
	while (n != 0) {
		s += n % 10 + 48;
		n /= 10;
	}
	reverse(s.begin(), s.end());
	return s;
}

bool comp(pair<pair<int,int>, int> a, pair<pair<int,int>,int> b){
    return a.first.second < b.first.second;
}

int main()
{
    int n, m;
    cin >> n >> m;
    vector <pair<pair<int, int>, int>> arr(m);
    vector <int> arry(m);
    map <int, int> c;
    for(int i=0;i<m;i++){
        cin >> arr[i].first.first >> arr[i].first.second;
        arry[i] = arr[i].first.second;
    }
    sort(arr.begin(), arr.end(), comp);
    map <int, string> mp;
    for(int i=0;i<m;i++){
        c[arr[i].first.first] += 1;
        arr[i].second = c[arr[i].first.first];
        string s1 = to_str(arr[i].first.first);
        int len1 = 6-s1.size();
        string s1ex;
        s1ex.append(len1, '0');
        s1ex.append(s1);

        string s2 = to_str(arr[i].second);
        int len2 = 6-s2.size();
        string s2ex;
        s2ex.append(len2, '0');
        s2ex.append(s2);

        string s = s1ex + s2ex;
        //cout << s << endl;
        mp[arr[i].first.second] = s;
    }
    for(int i=0;i<m;i++){
        cout << mp[arry[i]] << endl;
    }

	return 0;
}


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

int main()
{
    long long m,n,z=0;
    cin>>n>>m;
    if(2*n<=m)
    {
        z+=n;
        if(m%2==0)
            m-=2*n;
        else
            m-=2*n;
        while(m>=4)
        {
            z++;m-=4;
        }
    }
    else if(2*n>m)
    {
        z+=m/2;
    }
    cout<<z<<endl;
    return 0;
}


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

int main(){
    int n;
    cin >> n;
    n--;
    int cnt = 0;
    int a = 1;
    while (a <= n){
        cnt += n / a;
        a++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3508
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

using ll = long long;

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

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

template<class T>
void print(vector<T> a) {
  cout << "[ ";
  REP(i, a.size()) cout << a[i] << " ";
  cout << "]" << endl;
}

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}
string s;
vector<vector<ll>> score;

#define DP score[i][type]
ll dfs(ll i, ll type) {
  if (DP != -1) return DP;
  if (i == s.size() + 1) return DP = -(1ll << 60);
  if (i == s.size()) return DP = 0;
  if (type == 1) {
    return DP = dfs(i + 1, 0) + 1;
  } else {
    if (s[i - 1] != s[i]) {
      return DP = max(dfs(i + 1, 0) + 1, dfs(i + 2, 1) + 1);
    } else {
      return DP = dfs(i + 2, 1) + 1;
    }
  }
}

int main() {
  cin >> s;
  s = "@" + s;
  score = vector<vector<ll>>(s.size() + 2, vector<ll>(2, -1));

  cout << dfs(1, 0);
}


Measured memory_bytes: 20636
var
    n, i : integer;
    ans : boolean;
begin
    readln(n);
    i := 1;
    while trunc(i * 1.08) < n do
    begin
       i := i + 1;
    end;
    if trunc(i * 1.08) = n then
      writeln(i)
    else
      writeln(':(');
end.

Measured memory_bytes: 128
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n=sc.nextInt(),sum=0;
    Map<String, Integer> m=new LinkedHashMap<>();
    for(int i=0;i<n;i++) {
    	String s=sc.next();
    	int buff=sc.nextInt();
    	m.put(s, buff);
    }
    String x=sc.next();
    for (String nKey : m.keySet()){
        sum+=m.get(nKey);
        if(nKey.equals(x))sum=0;
        //System.out.println(nKey+":"+m.get(nKey));
    }
    System.out.println(sum);
  }
}


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

long long N;
string S;

int main(){
	cin >> N >> S;
	for(long long i = 0; i < S.size(); i++){
		S[i] = ((S[i] - 'A') + N) % ('Z' - 'A' + 1) + 'A';
	}
	cout << S << endl;
}

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

int main(){
	int n, m, l, ans;
	scanf("%d%d%d", &n, &m, &l);
	if(n + m + 1 >= l) ans = m + l;
	else{
		ans = m*2 + n + 1;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dbg(x) cerr << #x << " : " << x << endl;
#define endl '\n'
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> h(n),dp(n);
    for(int i=0;i<n;i++) cin >> h[i];
    dp[n-1]=0;
    int ans=0;
    for(int i=n-2;i>=0;i--){
        if(h[i+1]<=h[i]) dp[i]=1+dp[i+1];
        ans=max(ans,dp[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#pragma warning(disable:4996)
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <list>
#include <set>
#include <map>
#include <iomanip> 
#include <ctime>
#include <numeric>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

const double PI = 3.14159265358979323846;
const int MAX = 1e7;
const int MOD = 1e9+7;

int main(int argc, char *args[]) {
	int a1, a2, a3;
	cin >> a1 >> a2 >> a3;
	if (a1 + a2 + a3 >= 22)cout << "bust" << endl;
	else cout << "win" << endl;
	return 0;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        for(int i = 0; i < N; i++) {
            A[i] = scanner.nextInt();
            A[i]--;
        }
        int[] B = new int[N];
        for(int i = 0; i < N; i++) {
            B[i] = scanner.nextInt();
        }
        int[] C = new int[N - 1];
        for(int i = 0; i < N - 1; i++) {
            C[i] = scanner.nextInt();
        }
        int ans = 0;
        for(int i = 0; i < N; i++) {
            if((i > 0) && (A[i] == A[i - 1] + 1)) {
                ans += C[A[i] - 1];
            }
            ans += B[i];
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  int n, a, b;
  cin >> a;
  if(a==3 || a==5 || a==7) co("YES");
  else co("NO");
  
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
class Main{
    public static void main(String[] av){
	Scanner sc=new Scanner(System.in);
        double r=sc.nextDouble();
	double s=2*r*Math.PI;
	double m=r*r*Math.PI;
	System.out.printf("%.10f %.10f\n",m,s);



    
    
    }
}


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

#define pb push_back
#define vi vector < int >
#define ii pair < int, int >
#define vii vector < pair < int, int > >
#define vvi vector < vector < int > >
#define ll long long
#define X first
#define Y second
#define mp make_pair
#define FOR( i, lo, hi ) for( int i = (lo);i < (hi);i++ )
#define DFOR( i, hi, lo ) for( int i = (hi);i >= (lo);i-- )
#define pqueue priority_queue

using namespace std;

const long long int MOD = 1e9 + 7;

ll REM( ll a )
{
	a %= MOD;
	if ( a < 0 )
	   a += MOD;
	return a;
}

ll ADD( ll a, ll b )
{
	return REM( REM( a ) + REM( b ) );
}

ll SUB( ll a, ll b )
{
	return REM( REM( a ) - REM( b ) );
}

ll MUL( ll a, ll b )
{
	return REM( REM( a ) * REM( b ) );
}

ll POT( ll n, ll k )
{
	if ( k == 0 )
		return 1;

	ll ret = POT( n, k / 2 );
	ret = MUL( ret, ret );

	if ( k % 2 )
		return MUL( ret, n );
	return ret;
}

ll DIV( ll a, ll b )
{
	return MUL( a, POT( b, MOD - 2 ) );
}

bool isPrime( ll x )
{
	for ( ll i = 2;i <= sqrt( x ); i++ )
		if ( x % i == 0 )
			return false;
	return true;
}

int n;
int A[ 20 ][ 20 ];

int main()
{
	cin >> n;
	memset( A, -1, sizeof A );
	FOR( i, 0, n )
	{
		int m;cin >> m;
		FOR( j, 0, m )
		{
			int x, y;cin >> x >> y;
			x--;
			A[ i ][ x ] = y;
		}
	}
	
	int sol = 0;
	FOR( i, 0, ( 1 << n ) )
	{
		int x = i;
		vi v;
		FOR( j, 0, n )
		{
			v.pb( x % 2 );
			//cout << v[ j ] << " ";
			x = ( x >> 1 );
		}
		//cout << "\n";
		
		bool ok = true;
		FOR( j, 0, n )
		{
			if ( !v[ j ] )
				continue;
			
			FOR( k, 0, n )
			{
				if ( A[ j ][ k ] == -1 )
					continue;
				
				if ( A[ j ][ k ] != v[ k ] )
					ok = false;
			}
		}
		
		if ( ok )
			sol = max( sol, __builtin_popcount( i ) ); 
	}
	
	cout << sol << "\n";
	return 0;
}


Measured memory_bytes: 256
import sys
n=int(input())
s = list(input())
ans = 0
if n % 2 != 0:
    print("No")
    sys.exit()
for i in range(n//2 ):
    if s[i] != s[i+n//2]:
        ans = 1
if ans == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x7f7f7f7f
ll n,w;
ll wei[110],val[110];
ll dp[100010];//dp[i]达到价值为i的时候最少需要的重量 

int main(){
	scanf("%lld%lld",&n,&w);
	ll total=0;
	for (int i=1;i<=n;i++){
		scanf("%lld%lld",&wei[i],&val[i]);
		total+=val[i];
	} 
	fill(dp,dp+total+1,inf);
	dp[0]=0;
	for (int i=1;i<=n;i++){
		ll value = val[i];
		for (int j=total;j>=value;j--){
			dp[j]=min(dp[j],dp[j-value]+wei[i]);
		}
/*		
		printf("-----\n");
		for (int j=0;j<=total;j++){
			if (dp[j]!=inf) printf("%lld %lld\n",j,dp[j]);
		} 
		printf("-----\n");*/
	}
	ll ans=0;
	for (int i=total;i>=0;i--){
		if (dp[i]<=w){
			ans=i;
			break;
		}
	}
	printf("%d",ans);
	return 0;
} 

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

int main() {
    int n, m;
    cin >> n >> m;
    priority_queue<int> que;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        que.push(a);
    }
    while (m--) {
        int t = que.top();
        que.pop();
        que.push(t / 2);
    }
    long long ans = 0;
    while (que.size()) {
        int t = que.top();
        que.pop();
        ans += t;
    }
    cout << ans << endl;
}

Measured memory_bytes: 892
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

int n,a,b;

int main() {
    cin >> n;
    int A[n];
    for(int i=0;i<n;++i) cin >> A[i];
    sort(A, A + n, greater<int>());;
    a,b=0,0;
    for(int i=0;i<n;++i){
        if (i%2==0) a+=A[i];
        else b+=A[i];
    }
    cout << a-b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<deque>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<numeric>
#include<list>
#include<sstream>

using namespace std;
using ll = long long int;
constexpr int INF = 1 << 29;
constexpr ll MOD = ll(1e9 + 7);
int n, m;
int p[100000];
ll y[100000];
vector<ll> yd[100001];

int main(void) {
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> p[i] >> y[i];
		yd[p[i]].push_back(y[i]);
	}

	for (int i = 0; i < n; i++) {
		sort(yd[i+1].begin(), yd[i+1].end());
	}

	for (int i = 0; i < m; i++) {
		int cnt = int(lower_bound(yd[p[i]].begin(), yd[p[i]].end(), y[i]) - yd[p[i]].begin()) + 1;
		cout << setw(6) << std::right << setfill('0') << p[i];
		cout << setw(6) << std::right << setfill('0') << cnt;
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define RFOR(i, a, b) for (int i = (b)-1; i >= int(a); --i)
#define rep(i, n) FOR(i, 0, n)
#define rep1(i, n) FOR(i, 1, int(n) + 1)
#define rrep(i, n) RFOR(i, 0, n)
#define rrep1(i, n) RFOR(i, 1, int(n) + 1)
#define all(c) begin(c), end(c)
const int MOD = 1000000007;

template <typename T>
void __dump__(std::ostream &os, const T &first) {
    os << first;
}
template <typename First, typename... Rest>
void __dump__(std::ostream &os, const First &first, const Rest &... rest) {
    os << first << ", ";
    __dump__(os, rest...);
}
#define dump(...)                                         \
    do {                                                  \
        std::ostringstream os;                            \
        os << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; \
        __dump__(os, __VA_ARGS__);                        \
        std::cerr << os.str() << std::endl;               \
    } while (0)

int main() {
    ll n;
    while (cin >> n) {
        vector<int> head;
        int i = 1;
        while ((1LL << i) - 1 <= n) {
            head.push_back(i);
            ++i;
        }
        --i;
        n -= (1LL << i) - 1;
        int k = 50;
        for (int i = head.size() - 1; i >= 0; --i) {
            if (n >> i & 1) {
                head.insert(head.begin() + i, k);
                ++k;
            }
        }
        cout << head.size() + 100 << endl;
        for (auto &c : head) cout << c << ' ';
        rep1(i, 100) cout << i << ' ';
        cout << endl;
    }
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws Exception {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] x = br.readLine().split(" ");
		int a = Integer.parseInt(x[0]);
		int b = Integer.parseInt(x[1]);
		String[] line = br.readLine().split(" ");
		int[] ia = new int[a];
		int c = 0;

		for (int i = 0; i < a; i++) {
			ia[i] = Integer.parseInt(line[i]);
		}

		Arrays.sort(ia);

		for (int i = a - 1; i > a - b - 1; i--) {
			c = c + ia[i];
		}

		System.out.println(c);

	}

}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
using namespace std;int64_t N,a,b,i,l;main(){cin>>N;vector<int64_t>R(N);for(auto&p:R){cin>>a>>b;a+=1e9;p=(a<<32)+a+b;}sort(R.begin(),R.end());vector<int>V(N+1,1),f(N);for(i=N;i--;){for(l=i+1;l<N&&R[l]>>32<R[i]%(1ll<<32);)l=f[l];V[i]=(V[i+1]+V[f[i]=l])%998244353;}cout<<V[0]<<'\n';}

Measured memory_bytes: 3328
#include <iostream>
#include <string>

using namespace std;

string s1, s2;
int m, n, sx, sy, tot;

int main() {
	ios :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin >> m >> n >> tot >> sx >> sy >> s1 >> s2;
	int u = 1, d = m, l = 1, r = n;
	for (int i = tot; ~i; i--) {
		if (s2[i] == 'D' && u > 1) u--;
		if (s2[i] == 'R' && l > 1) l--;
		if (s2[i] == 'U' && d < m) d++;
		if (s2[i] == 'L' && r < n) r++;
		if (s1[i] == 'U') u++;
		if (s1[i] == 'L') l++;
		if (s1[i] == 'D') d--;
		if (s1[i] == 'R') r--;
		if (u > d || l > r) {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (sx >= u && sx <= d && sy >= l && sy <= r) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}


Measured memory_bytes: 920
#include<stdio.h>
#include<math.h>
int main(){
	int a;
	bool first=false;
	while(~scanf("%d",&a)){
		if(first)printf("\n");
		first=true;
		for(int i=0;i<5;i++){
			if(a%(int)(pow(10,5-i))/(int)(pow(10,4-i))<5)printf("*");
			else printf(" ");
		}
		printf("\n");
		for(int i=0;i<5;i++){
			if(a%(int)(pow(10,5-i))/(int)(pow(10,4-i))>=5)printf("*");
			else printf(" ");
		}
		printf("\n");
		printf("=====\n");
		for(int i=0;i<5;i++){
			for(int j=0;j<5;j++){
				if((a%(int)(pow(10,5-j))/(int)(pow(10,4-j)))%5==i)printf(" ");
				else printf("*");
			}
			printf("\n");
		}
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (ll)(n); i++)

int main() {
  ll n; cin >> n;
  bool flag = 0;
  rep(i, n) {
    ll a; cin >> a;
    if (a%2) flag = 1;
  }
  if (flag) cout << "first" << endl;
  else cout << "second" << endl;
}

Measured memory_bytes: 3640
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [D, X] = string_to_int(inputs[0])
    A = list(map(int, inputs[1:]))

    choco = X
    for a in A:
        d = 0
        while d * a + 1 <= D:
            choco += 1
            d += 1

    return choco


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N+1))
    print(ret)


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define Return(ans) { cout << (ans) << endl; return 0; }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;



signed main(){

    vec x(5); cin >> x;
    REP(i, 5) if(x[i] == 0){
        Out(i + 1);
        break;
    }    

    return 0;
}


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

inline void ioThings() {
  ios::sync_with_stdio(0);
  cin.tie(0);
#ifdef LOCAL
  freopen("io\\in.txt", "r", stdin);
  freopen("io\\out.txt", "w", stdout);
#define debug(x) cerr << #x << ": <" << (x) << ">\n"
#else
#define debug(x)
#endif
}

#define rep(i, n) for (int i = 0; i < n; i++)
#define dotc()    int tcs; if (cin >> tcs) rep(tc, tcs)
#define sz(x)     (int)x.size()
#define eb        emplace_back
#define pb        push_back
#define mp(x, y)  make_pair(x, y);
#define all(x)    x.begin(), x.end()
#define rall(x)   x.rbegin(), x.rend()
#define fi        first
#define se        second
#define mod       1000000007
#define pi        acos(-1.0)

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using si = set<int>;
using ii = pair<int, int>;
using vii = vector<ii>;

int main() {
  ioThings();

  int n, m;
  cin >> n >> m;
  vector<si> adj(n + 1);
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    adj[x].insert(y);
    adj[y].insert(x);
  }

  map<int, int> dist;
  dist[1] = 0;
  queue<int> q;
  q.push(1);
  while(!q.empty()) {
    int cur = q.front();
    q.pop();

    int d = dist[cur] + 1;
    for (int i : adj[cur]) {
      if (dist.count(i)) continue;
      dist[i] = cur;
      q.push(i);
    }
  }

  if (sz(dist) != n) cout << "No";
  else {
    cout << "Yes\n";
    dist.erase(dist.begin());
    for (auto i : dist) cout << i.se << '\n';
  }

  return 0;
}


Measured memory_bytes: 31700
import java.util.Scanner;


public class Main {
	public static void main (String args[]) throws Exception{
		Scanner scan = new Scanner(System.in);
		String n = scan.next();
		int sum = 0;
		String ans = "No";
		
		for(int i = 0; i < n.length(); i++) {
			sum += Integer.parseInt(n.substring(i, i+1));
		}
		
		if(sum % 9 == 0 ) {
			ans = "Yes";
		}

		System.out.print(ans);
	}
}

Measured memory_bytes: 49868