akhauriyash/Code-Regression huggingface dataset:
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

// fn read<T: std::str::FromStr>() -> T {
//     let mut s = String::new();
//     std::io::stdin().read_line(&mut s).ok();
//     s.trim().parse().ok().unwrap()
// }

fn main() {
    loop{
        let v:Vec<i32> = read_vec();
        if v[0] == 0 && v[1] == 0 {
            break;
        }

        for i in 0..v[0] {
            for j in 0..v[1] {
                if i == 0 || i == v[0] - 1 || j == 0 || j == v[1] - 1 {
                    print!("#");
                } else {
                    print!(".");
                }
            }
            println!("");
        }
        println!("");
    }
}


Measured memory_bytes: 5032
import qualified Data.ByteString.Char8         as C

main = do
    n <- readLn :: IO Int
    s <- C.getLine
    let tempAns = mul $ countRGB s
    print $ tempAns - length [ () | i <- [0 .. n - 2], d <- [1 .. n], i + 2 * d < n, check s i d ]

countRGB = C.foldl addRGB (0, 0, 0)

addRGB (r, g, b) c | c == 'R' = (r + 1, g, b)
                   | c == 'G' = (r, g + 1, b)
                   | c == 'B' = (r, g, b + 1)

mul (r, g, b) = r * g * b

check ss i d =
    notEqual (C.index ss i) (C.index ss $ i + d) (C.index ss $ i + 2 * d)

notEqual i j k = i /= j && j /= k && k /= i


Measured memory_bytes: 4276
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int R = 69966969;
const int MAXN = 2e5 + 69;
int n, k;
int a[MAXN];
int pre[MAXN];
int encode(int i) {
    return ((pre[i] - i) % k + k) % k;
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n >> k;
    for (int i = 1; i <= n; i++) cin >> a[i], pre[i] = pre[i - 1] + a[i];
    unordered_map<int, int> mp;
    mp.reserve(n + 1);
    mp.max_load_factor(0.25);
    int ans = 0;
    mp[pre[0] ^ R]++;
    for (int i = 1; i <= n; i++) {
        if (i - k >= 0) {
            int tmp = encode(i - k);
            mp[tmp ^ R]--;
        }
        int val = encode(i);
        ans += mp[val ^ R];
        mp[val ^ R]++;
    }
    cout << ans;
}


Measured memory_bytes: 19176
n=int(input())
csf=[tuple(map(int,input().split())) for _ in range(n-1)]

arrtime=lambda i,cs: max(csf[i][2]*(cs//csf[i][2]+(cs%csf[i][2]>0)),csf[i][1])+csf[i][0]
for i in range(n-1):
  arrivN=csf[i][1]
  for j in range(i,n-1):
    arrivN=arrtime(j,arrivN)
  print(arrivN)
print(0)

Measured memory_bytes: 9064
s=input()
t=input()
ls=len(s)
lt=len(t)
INF=float('inf')

dp=[[0 for i in range(lt+1)] for j in range(ls+1)]
R=[[INF for i in range(lt+1)] for j in range(ls+1)]
for i in range(1,ls+1):
  for j in range(1,lt+1):
    if s[i-1]==t[j-1]:
      dp[i][j]=dp[i-1][j-1]+1
    else:
      dp[i][j]=max(dp[i][j-1],dp[i-1][j])

l=dp[ls][lt]
ans=''
i=ls
j=lt
while l>0:
  if s[i-1]==t[j-1]:
    ans=str(s[i-1])+ans
    l-=1
    i-=1
    j-=1
  elif dp[i][j]==dp[i-1][j]:
    i-=1
  else:
    j-=1
  
print(ans)



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

#define NAME "C - Vacation"
#define show(x) cout << (#x) << " is " << (x) << endl
#define ll long long
#define ms(arr,val) memset(arr,val,sizeof(arr))
#define len length()

const int maxn = 2e5;
int dp[2][3];
int main(){
    //ifstream cin(NAME".inp");
    //ofstream cout(NAME".out");
    int n,a,b,c;
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>a>>b>>c;
        dp[1][0] = max( dp[0][1],dp[0][2] ) + a;
        dp[1][1] = max( dp[0][0],dp[0][2] ) + b;
        dp[1][2] = max( dp[0][1],dp[0][0] ) + c;
        for(int i=0;i<3;i++) dp[0][i] = dp[1][i];
    }
    cout<<max(dp[0][1],max(dp[0][2],dp[0][0]));

}



Measured memory_bytes: 3624
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-04-12 20:34:55
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;

template<class T> using binary_heap = std::priority_queue<T, std::vector<T>, std::greater<T>>;
template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) { os << '{'; size_t n = vec.size(); for (size_t i = 0; i < n; ++i) { os << vec[i]; if (i != n - 1) os << ','; } os << '}'; return os; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) { os << '{'; for (auto it = mp.begin(); it != mp.end(); ++it) { os << '{' << it->first << ':' << it->second << '}'; if (it != --mp.end()) os << ','; } os << '}'; return os; }
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T>& st) { os << '{'; for (auto it = st.begin(); it != st.end(); ++it) { os << *it; if (it != --st.end()) os << ','; } os << '}'; return os; }
template<class T> std::istream& operator>>(std::istream& is, std::vector<T>& vec) { size_t n = vec.size(); for (size_t i = 0; i < n; ++i) is >> vec[i]; return is; }

#define all(_) begin(_), end(_)
#define rall(_) rbegin(_), rend(_)

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}

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

  string s; cin >> s;
  
  for (int i = 0; i < 3; ++i) {
    if (s[i] == '7') {
      cout << "Yes" << endl; return 0;
    }
  }

  cout << "No" << endl;

  return 0;
}

Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int INF = 1 << 30;
int grundy(int N, int K) {
	int d = N / K;
	if (N%K == 0 || (N - K * d) % (d + 1) == 0) {
		return d;
	}
	int m = (N - K * d + d) / (d + 1);
	return grundy(N - m * (d + 1), K);
}
int main() {
	int N;
	cin >> N;
	int g = 0;
	for (int i = 0; i < N; i++) {
		int A, K;
		cin >> A >> K;
		g ^= grundy(A, K);
	}
	if (g == 0) cout << "Aoki" << endl;
	else cout << "Takahashi" << endl;
}


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

typedef long long ll;

#define MOD 1000000007
#define INF LLONG_MAX
#define decimDigits(n) fixed << setprecision(n)
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(it, arr) for(auto it = begin(arr); it != end(arr); it++)

ll gcd(ll a, ll b){return b ? gcd(b, a % b) : a;}

int main(){

    ll H, W;

    cin >> H >> W;

    vector<string> C(H);

    rep(i, H)
        cin >> C[i];
    
    rep(i, 2 * H)
        cout << C[i / 2] << endl;

    return 0;
}

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

int main()
{
    int n,r;
    cin>>n;

    r=n%10;

    if(r==2||r==4||r==5||r==7||r==9)
        cout<<"hon"<<endl;

    else if(r==0||r==1||r==6||r==8)
        cout<<"pon"<<endl;

    else
        cout<<"bon"<<endl;

    return 0;
}



Measured memory_bytes: 3568
#include <iostream>
#include <iomanip>
#include <fstream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t x,a,b;
    cin >> x >> a >> b;
    cout << (x-a)%b << endl;
}


Measured memory_bytes: 384
a,b,c=map(int,input().split())
k=int(input())
#print(a,b,c,k)

ans=0
for i1 in range(k+1):
    for i2 in range(k+1):
        for i3 in range(k+1):
#            print(i1,i2,i3)
            if (i1+i2+i3==k):
                temp=a*2**(i1)+b*2**(i2)+c*2**(i3)
#                print(temp)
                ans=max(ans,temp)

print(ans)



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

int main()
{
    int a,b,c,d=0;
    cin>>a>>b>>c;
    if(a!=b && b!=c && c!=a)
    {
        d=3;
    }
    else if(a==b && b!=c && c!=a)
    {
        d=2;
    }
    else if(a!=b && b==c && c!=a)
    {
        d=2;
    }
    else if(a!=b && b!=c && c==a)
    {
        d=2;
    }
    else
    {
        d=1;
    }
    cout<<d<<endl;
    return 0;
}


Measured memory_bytes: 3524
#include<iostream>
    using namespace std;
    int main()
    {
     int n;
     cin>>n;
     int fg=0;
     while(n/10!=0)
     {
         if(n%10==7){fg=1;}
         n/=10;
     }
     if(n==7 || fg)cout<<"Yes";
     else cout<<"No";
     
    return 0;   
    }

Measured memory_bytes: 3640
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var ABC = (new int[N][]).Select(x => x = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray()).ToArray();
            var dp = (new int[3][]).Select(x => x = new int[N + 1]).ToArray();

            for (var i = 0; i < N; i++)
            {
                var max = 0;
                var current = 0;
                for (var j = 0; j < 3; j++)
                {
                    var k1 = (j + 1) % 3;
                    var k2 = (j + 2) % 3;
                    dp[j][i + 1] = Math.Max(dp[j][i + 1], dp[k1][i] + ABC[i][k1]);
                    dp[j][i + 1] = Math.Max(dp[j][i + 1], dp[k2][i] + ABC[i][k2]);
                }
            }

            var answer = 0;
            for (var i = 0; i < 3; i++)
            {
                answer = Math.Max(answer, dp[i][N]);
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 49304
/**
 * Created at 2:52 on 2019/03/07
 */

import java.io.*;
import java.util.*;

public class Main {

  static FastScanner sc = new FastScanner();

  public static void main(String[] args) {

    int N = sc.nextInt();
    int M = sc.nextInt();

    int max = M / N;

    int gcd = 0;
    for (int i=max; i>=1; i--) {
      if (M % i == 0) {
        gcd = i;
        break;
      }
    }

    System.out.println(gcd);

  }

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

  static class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
      if (ptr < buflen) {
        return true;
      } else {
        ptr = 0;
        try {
          buflen = in.read(buffer);
        } catch (IOException e) {
          e.printStackTrace();
        }
        if (buflen <= 0) {
          return false;
        }
      }
      return true;
    }

    private int readByte() {
      if (hasNextByte()) return buffer[ptr++];
      else return -1;
    }

    private static boolean isPrintableChar(int c) {
      return 33 <= c && c <= 126;
    }

    private void skipUnprintable() {
      while (hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++;
    }

    public boolean hasNext() {
      skipUnprintable();
      return hasNextByte();
    }

    public String next() {
      if (!hasNext()) throw new NoSuchElementException();
      StringBuilder sb = new StringBuilder();
      int b = readByte();
      while (isPrintableChar(b)) {
        sb.appendCodePoint(b);
        b = readByte();
      }
      return sb.toString();
    }

    public long nextLong() {
      if (!hasNext()) throw new NoSuchElementException();
      long n = 0;
      boolean minus = false;
      int b = readByte();
      if (b == '-') {
        minus = true;
        b = readByte();
      }
      if (b < '0' || '9' < b) {
        throw new NumberFormatException();
      }
      while (true) {
        if ('0' <= b && b <= '9') {
          n *= 10;
          n += b - '0';
        } else if (b == -1 || !isPrintableChar(b)) {
          return minus ? -n : n;
        } else {
          throw new NumberFormatException();
        }
        b = readByte();
      }
    }

    public int nextInt() {
      return (int) nextLong();
    }
  }

}


Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define popb pop_back()
#define sz size()
#define y1 dfsdsfsdfsd
#define next fdsfsdfjkl
#define int long long
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
double pi = acos(-1.0);
const int inf = 1e9+7;
const ll INF = 1e18+7;
//////////////////////////////////////////

int n,k;

int a[100100];
main(){speed;
    cin>>n>>k;

    for(int i=1;i<=n;i++) cin>>a[i];

    sort(a+1,a+n+1);

    int cnt = 0;

    for(int i=1;i<n;i++)
    {
        if(k>a[i])
        {
            k-=a[i];
            cnt++;
        }
        else if(k==a[i])
        {
            k=0;
            cnt++;
            break;
        }
        else break;
    }
    if(k==a[n]) cnt++;

    cout<<cnt;
}


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

int main(){
	
  string s,t,u;
  cin >> s >> t;
  int a,b;
  cin >> a >> b;
  cin >> u;
  if(s==u)a--;
  else b--;
  cout << a << " " << b;
  return 0;
}

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

#define MAX_N 20001
#define MAX_M 20001

using namespace std;

struct datum {
    int t, s, d;
    datum(int t=0, int s=0, int d=0) : t(t), s(s), d(d) {}
    bool operator<(const datum &o) const {
        return t < o.t;
    }
};

int N, M;
bool infected[MAX_N];
datum data[MAX_M];

bool init() {
    cin >> N >> M;
    if (N == 0 && M == 0) return false;
    memset(infected, 0, sizeof(infected));
    infected[1] = true;
    for (int i = 0; i < M; i++) 
        cin >> data[i].t >> data[i].s >> data[i].d;
    sort(data, data+M);
    return true;
}

int main() {
    while (init()) {
        for (int i = 0; i < M; i++) 
            if (infected[data[i].s]) 
                infected[data[i].d] = true;
        int cnt = 0;
        for (int i = 1; i <= N; i++)
            if (infected[i]) cnt++;
        cout << cnt << endl;
    }
    return 0;
}

Measured memory_bytes: 1424
//Vol0 0013
#include<stdio.h>
int main()
{
	int n,buf[128]={0},i=0;
	while(!(scanf("%d",&n)==EOF)){
		if(n==0){
			if(i!=0){
				i--;
			}
			printf("%d\n",buf[i]);
			buf[i]=0;
		}else{
			buf[i]=n;
			i++;
		}
	}
	return 0;
}

Measured memory_bytes: 2672
#include <bits/stdc++.h>
#define vi vector<int>
#define ll long long
#define pb push_back
#define ii pair<int, int>
#define MAXN int(1e6)
#define qi queue<int>
#define si stack<int>
#define mii map<int, int>
#define msi map<string, int>
#define fr first
#define sc second
#define all(x) x.begin(), x.end()
using namespace std;

ll arr[405], sum[405], dp[405][405], n;

int main(int argc, char** argv) {
	ios::sync_with_stdio(0);
	cin.tie(0);
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	
	cin >> n;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			dp[i][j] = 1e16;

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

	sum[0] = arr[0];
	for (int i = 1; i < n; i++)
		sum[i] = sum[i-1]+arr[i];

	for (int len = 1; len < n; len++) {
		for (int start = 0; start < n-1; start++) {
			int end = start+len;

			if (end >= n)
				continue;

			//dp[start][end] = 1e16;

			ll s = sum[end]-sum[start]+arr[start];

			for (int k = start; k < end; k++) {
				ll d = s+dp[start][k]+dp[k+1][end];
				dp[start][end] = min(dp[start][end], d);
			}
		}
	}

	cout << dp[0][n-1] << '\n';


	return 0;
}






Measured memory_bytes: 1536
/**
*	created: 10.08.2020 00:19:38
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dx2[8] = {0, 1, 0, -1, 1, 1,-1, -1};
const int dy2[8] = {1, 0,-1, 0, 1, -1, 1, -1};
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

int gridbfs(int i,int j,vector<string> s,vector<vector<int>> &dis) {
    int h = s.size(), w = s[0].size();
    queue<vector<int>> q; q.push({i,j});
    dis[i][j] = 0;
    if (s[i][j] == '#') return -1;
    int ret = 0;
    while (!q.empty()) {
        auto v = q.front(); q.pop();
        if (v[0] > 0 && s[v[0] - 1][v[1]] == '.' && dis[v[0] - 1][v[1]] == -1) {
            dis[v[0] - 1][v[1]] = dis[v[0]][v[1]] + 1;
            ret = dis[v[0]][v[1]] + 1;
            q.push({v[0] - 1, v[1]});
        }
        if (v[1] > 0 && s[v[0]][v[1] - 1] == '.' && dis[v[0]][v[1] - 1] == -1) {
            dis[v[0]][v[1] - 1] = dis[v[0]][v[1]] + 1;
            ret = dis[v[0]][v[1]] + 1;;
            q.push({v[0], v[1] - 1});
        }
        if (v[0] < h - 1 && s[v[0] + 1][v[1]] == '.' && dis[v[0] + 1][v[1]] == -1) {
            dis[v[0] + 1][v[1]] = dis[v[0]][v[1]] + 1;
            ret = dis[v[0]][v[1]] + 1;
            q.push({v[0] + 1, v[1]});
        }
        if (v[1] < w - 1 && s[v[0]][v[1] + 1] == '.' && dis[v[0]][v[1] + 1] == -1) {
            dis[v[0]][v[1] + 1] = dis[v[0]][v[1]] + 1;
            ret = dis[v[0]][v[1]] + 1;
            q.push({v[0], v[1] + 1});
        }
    }
    return ret;
}

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = -INF;
    rep(i,h) rep(j,w) {
        vector<vector<int>> dis(h,vector<int>(w,-1));
        int n = gridbfs(i,j,s,dis);
        if (n != -1) chmax(ans,n);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
import fractions as math

N, X = map(int,(input().split()))
x = list(map(int,input().split()))
x.append(X)
x_min = min(x)

x_0 = [x_- x_min for x_ in x]

gcd = x_0[0]
for x_0_ in x_0:
    gcd = math.gcd(gcd,x_0_)

print(gcd)

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

int main() {
  size_t H, W;
  std::cin >> H >> W;

  std::cout << std::string(W+2, '#') << std::endl;
  for (size_t i = 0; i < H; ++i) {
    std::string a;
    std::cin >> a;
    std::cout << '#' << a << '#' << std::endl;
  }
  std::cout << std::string(W+2, '#') << std::endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <array>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <math.h>
using namespace std;

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

    int x, y, z;
    cin >> x >> y >> z;

    int n = x + y + z;
    vector<array<int, 3>> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i][0] >> p[i][1] >> p[i][2];
    }

    sort(p.begin(), p.end(), [&](const array<int, 3>& p0, const array<int, 3>& p1) {
        return p0[0] - p0[1] > p1[0] - p1[1];
    });

    vector<int64_t> r[2];
    for (int k = 0; k < 2; k++) {
        priority_queue<int> q;
        int64_t s = 0;
        r[k] = vector<int64_t>(n);
        for (int i = 0;;) {
            int j = k == 0 ? i : n - 1 - i;
            q.push(p[j][2] - p[j][k]);
            i++;
            r[k][i] = s += p[j][k];
            if (x <= j && j < n - y) {
                s += q.top();
                q.pop();
                r[k][i] = s;
                if (k == 0 && j == n - y - 1) break;
                if (k == 1 && j == x) break;
            }
        }
    }

    int64_t m = 0;
    for (int i = x; i <= n - y; i++) {
        m = max(m, r[0][i] + r[1][n - i]);
    }

    cout << m << endl;

    return 0;
}

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

int main(){
    ll n,d;
    cin>>n>>d;
    vector<vector<int>> p(n, vector<int>(d));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < d; j++) {
            cin >> p.at(i).at(j);
        }
    }

    ll ans=0;
    for (int i = 0; i < n; i++) {
        for(int j=i+1;j<n;j++){
            ll sum=0;
            for(int k=0;k<d;k++){
                sum+=(p.at(i).at(k) - p.at(j).at(k)) * (p.at(i).at(k) - p.at(j).at(k));
            }
            ll num = sqrt(sum);
            if(sum - (num*num)==0)ans++;
        }
    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3584
use std::cmp::{min,max};
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
fn main(){
    input!{
        n:i64,
        vn:[i64;n],
        cn:[i64;n],
    }
    let mut v_sum = 0;
    let mut c_sum = 0;
    let mut diff = vec![];
    for j in 0..n{
        diff.push(vn[j as usize]-cn[j as usize]);
    }
    let ans:i64= diff.iter().filter(|&x|*x > 0).sum();
    println!("{}",ans);
} 

Measured memory_bytes: 4352
import java.util.*;
import java.math.BigDecimal;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int x = sc.nextInt();
        int n = sc.nextInt();
        int check = n;
        int z= 999;
        int p[] = new int[n];
        int ans = 100;
        HashSet hs = new HashSet();
        for(int i = 0; i < n;i++){
          hs.add(sc.nextInt());
        }
        
        hs.add(x);
        if(hs.size() != n){
          System.out.println(x);
          System.exit(0);
        }
        for(int i = -100; i <= 200;i++){
          hs.add(i);
          if(hs.size() != check){
            if(Math.abs(x - i) < ans){
              ans = x - i;
              z = i;
            }
            check++;
          }
        }
        

        System.out.println(z);
    }
}

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

double pi = acos(-1);

double CalcRad2Deg(double rad)  {   return 180*rad/pi;  }
double CalcDeg2Rad(double deg)  {   return pi*deg/180;  }

int main()
{
    int a, b, x;
    cin >> a >> b >> x;

    double Vmax = a*a*b;

    double ans;
    if(Vmax == x)
        ans = pi/2;
    else if(0.5*Vmax < x)
        ans = atan2(a*a*a, 2*(Vmax-x));
    else
        ans = atan2(2*x, a*b*b);

    ans = 90 - CalcRad2Deg(ans);
    printf("%.10f\n", ans);

    return 0;
}

Measured memory_bytes: 256
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <vector>
#define ll long long
#define INF 1000000001;
using namespace std;
struct Edge{int from, to, cost;};

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    int num[27];
    REP(i,27) num[i] = 0;
    REP(i,h){
        REP(j,w){
            char in;
            cin >> in;
            num[int(in)-97]++;
        }
    }
    bool flag = true;
    int odd = 0;
    int even = 0;
    int four = 0;
    int other = 0;
    int bigger = 0;
    int bigfour = 0;

    REP(i,27){
        if(num[i]%2) odd++;
        else if(num[i] != 0 && num[i]%2 == 0){
            even++;
            if(num[i] % 4 == 0) four+=num[i]/4;
            else other++;
            
            if(num[i] >= 4){
                bigger++;
                bigfour += num[i]/4;
            }
            
        }
    
    }

    if(h%2 == 0 && w%2 == 0){
        if(odd > 0) flag = false;
        int num = (h/2)*(w/2);
        if(num != four) flag = false;
    }
    //24
    else if(h%2 == 1 && w%2 == 1){
        if(odd != 1) flag = false;
        int num = ((h-1)/2)*((w-1)/2);
        //if(num  bigfour) flag = false;
        int num2 = ((h-1)/2)+((w-1)/2);
        if(other > num2) flag = false;
    }
    else{
        if(odd > 0) flag = false;
        
        if(w%2 == 1) swap(h,w);

        int num = ((h-1)/2)*(w/2);
        //if(num > bigfour) flag = false;
        int num2 = w/2;
        if(other > num2) flag = false; 
    }


    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}


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

N = max(a)
a.remove(N)
N2 = N/2

li = [abs(N2 - k) for k in a]
index = li.index(min(li))
m = a[index]

print("{0} {1}".format(N, m))


Measured memory_bytes: 14428
n,m=map(int,input().split())

h=list(map(int,input().split()))

c=[1]*n

for i in range(m):
  a,b=map(int,input().split())
  a=a-1
  b=b-1

  if h[a]>h[b]:
    c[b]=c[b]-1
  elif h[a]<h[b]:
    c[a]=c[a]-1
  elif h[a]==h[b]:
    c[a]=c[a]-1
    c[b]=c[b]-1

#print(c)
cnt=0
for i in range(n):
  if c[i]==1:
    cnt+=1
print(cnt)

Measured memory_bytes: 84648
#include<iostream>
using namespace std;
int main(){
int n,sum=0,q;
  cin>>n;
  q=n;
  while(n!=0){
    int a=n%10;
    n=n/10;
    sum+=a;
  }
  if(q%sum==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

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

using namespace std;

int main() {
    int k, t, tmp = 0;   cin >> k >> t;
    vector<int> a(t);
    for (int i = 0; i < t; i++) {
        cin >> a[i];
        tmp = max(tmp, a[i]);
    }

    cout << max(tmp-1-(k-tmp), 0) << endl;
    return 0;
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(void)
{
int S, h, m, s;

scanf("%d",&S);

h = S / 3600;
m = (S - (3600 * h)) / 60;
s = S - (h * 3600 + m * 60);

printf("%d:%d:%d\n",h,m,s);

 return 0;
 
}

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

int main(void){
    int N, X;
    cin >> N >> X;
    int ans = 1;
    int d = 0;
    for (int i = 0; i < N; i++) {
        int l;
        cin >> l;
        d += l;
        if (d <= X)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int s[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    scanf("%d",&k);
    printf("%d\n",s[k-1]);
    return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main(void) {
    int n;
    ll k;
    cin >> n >> k;
    vector<int>a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> s;
    vector<int> ord(n + 1, -1);
    int c = 1, l = 0;
    {
        int v = 1;
        while (ord[v] == -1) {
            ord[v] = s.size();
            s.push_back(v);
            v = a[v - 1];
        }
        c = s.size() - ord[v];
        l = ord[v];
    }

    if (k < l) {
        cout << s[k] << endl;
    }
    else {
        k -= l;
        k %= c;
        cout << s[l + k] << endl;
    }
    return 0;
}



Measured memory_bytes: 5800
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;int a[3][3];
    int i,j;int b[12];
    int flag=0;
    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
        cin>>a[i][j];
    cin>>n;
    for(i=0;i<n;i++)
        cin>>b[i];
    for(i=0;i<n;i++)
    {
        for(j=0;j<3;j++)
        {
            for(int k=0;k<3;k++)
            {
                if(b[i]==a[j][k])
                {
                    a[j][k]=0;
                }
            }
        }
    }
    for(i=0;i<3;i++)
    {
        if(a[i][0]==0&&a[i][1]==0&&a[i][2]==0)
        {
            cout<<"Yes"<<endl;
            flag=1;
            break;
        }
        if(a[0][i]==0&&a[1][i]==0&&a[2][i]==0)
        {
            cout<<"Yes"<<endl;
            flag=1;
            break;
        }
        if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0)
        {
            cout<<"Yes"<<endl;
            flag=1;
            break;
        }
        if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0)
        {
            cout<<"Yes"<<endl;
            flag=1;
            break;
        }
    }
    if(flag==0)
        cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n;i--;)

typedef vector<int> vi;
typedef vector<string> vs;

bool match(const string& rule,const string pat)
{
	rep(i,rule.size())
		if(rule[i]!='?' && rule[i]!=pat[i])
			return false;
	return true;
}

int main()
{
	for(int n,m;cin>>n>>m,n|m;){
		vs rules(n);
		vi isperm(n);
		rep(i,n){
			string a,b,c; cin>>a>>b>>c;
			rules[i]=b+c;
			isperm[i]=a=="permit";
		}
		vs res;
		rep(i,m){
			string a,b,c; cin>>a>>b>>c;
			per(j,n)
				if(match(rules[j],a+b)){
					if(isperm[j])
						res.push_back(a+" "+b+" "+c);
					break;
				}
		}
		cout<<res.size()<<endl;
		rep(i,res.size())
			cout<<res[i]<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1004
import math

a, b = map(int, input().split())

al = []
bl = []
for i in range(2000):
  t = math.floor(i * 0.08)
  if t == a:
    al.append(i)
for i in range(2000):
  t = math.floor(i * 0.1)
  if t == b:
    bl.append(i)

for i in range(len(al)):
  for j in range(len(bl)):
    if al[i] == bl[j]:
      print(al[i])
      exit(0)
print(-1)


Measured memory_bytes: 38768
#include <algorithm>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>
#include <deque>

#define rep(i, n) for (int i = 0; (i) < (n); (i)++)
using namespace std;
using ll = long long;
int G[50][50];

int main(void) {
    int N, M;
    cin >> N >> M;
    rep(i, N)
        rep(j, N)
            G[i][j] = -1;
    
    vector<pair<int, int>> B;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        G[a-1][b-1] = 1;
        G[b-1][a-1] = 1;
        B.push_back({a-1, b-1});
    }

    auto ret = 0;
    rep(i, M) {
        auto b = B[i];
        G[b.first][b.second] = -1;
        G[b.second][b.first] = -1;

        vector<bool> seen(N, 0);
        deque<int> que;
        que.push_back(0);
        while(!que.empty()) {
            auto node = que.front();
            que.pop_front();
            if(seen[node]) {
                continue;
            }
            seen[node] = true;
            rep(i, N) {
                if(G[node][i] == 1) {
                    que.push_back(i);
                }
            }
        }
        bool ok = false;
        rep(i, N) {
            if(seen[i] == false) {
                ok = true;
            }
        }
        if(ok)
            ret++;

        G[b.first][b.second] = 1;
        G[b.second][b.first] = 1;
    }
    cout << ret << endl;

    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	int n, a, b;
	cin >> n >> a >> b;

	cout << min(n*a, b) << endl;
	return 0;
}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	sc.Scan()
	N, _ := strconv.Atoi(sc.Text())

	v := make([]float64, N)
	for i := 0; i < N; i++ {
		sc.Scan()
		v[i], _ = strconv.ParseFloat(sc.Text(), 64)
	}

	sort.Float64s(v)
	sum := v[0]
	for i := 1; i < N; i++ {
		sum = (sum + v[i]) / 2
	}

	fmt.Println(sum)
}


Measured memory_bytes: 640
//In The Name Of Allah
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) (int)(x.size())
#define double long double 
#define x real()
#define y imag()
#define fi first
#define se second
#define pii pair<int, int>

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
	int n;
	cin >> n;
	vector<vector<pii>> v(n);
	for (int i = 0; i < n; i++) {
		int Ai;
		cin >> Ai;
		for (int j = 0; j < Ai; j++) {
			int a, b;
			cin >> a >> b;
			a--;
			v[i].push_back({a, b});
		}
	}
	int32_t mx = 0;
	for (int b = 0; b < pow(2ll, n); b++) {
		bool ans = true;
		for (int i = 0; i < n; i++) {
			for (pii k : v[i]) {
				int j = k.fi, val = k.se;
				if ((b & (1 << i)) && val != (bool)(b & (1 << j))) ans = false;
			}
		}
		if (ans){
			mx = max(mx, __builtin_popcountll(b));
		}
	}
	cout << mx << "\n";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int k;
  cin >> k;
  REP(i,k){
    cout << "ACL";
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3620
X = list(map(int, input().split()))
N = [X[1]-X[2]]*X[0]
Q = []
for i in range(X[2]):
  Q.append(int(input()))
for i in range(X[2]):
  N[Q[i]-1]+=1
for result in N:
  if(result >= 1):
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 10472
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, a, n) for (int i = a; i < (n); i++)
#define all(in) in.begin(), in.end()
#define INF 1e9
#define MOD 1e9 + 7
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    int ans = a + b;
    cout << (ans >= c ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLine();
            var a = new string[3];

            var result = "No";

            for (int i = 0; i < a.Length; i++) {
                a[i] = n[i].ToString();
            }

            if(n == (a[2]+a[1]+a[0])){
                result = "Yes";
            }

            Console.WriteLine(result);
            ReadLine();
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }
    }
}

Measured memory_bytes: 13140
s=input()
l=[]
for i in range(len(s)):
    l.append(s[i])

cnt=0
for i in range(1,len(l)):
    if l[i] != l[i-1]:
        continue
    else:
        cnt+=1
        if l[i-1]=="1":
            l[i]="0"
        else:
            l[i]="1"

print(cnt)



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

int main() {
    int N, M; cin >> N >> M;
    int L = 0;
    int R = N;
    rep(i, M){
        int l, r; cin >> l >> r;
        L = max(L, l);
        R = min(R, r);
    }

    if(R - L >= 0){
        cout << R-L+1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main () {
    int a,x=0;
    cin>>a;
    vector<int>V(a);
    for(int i=0;i<a;i++){
        cin>>V[i];
    }
    sort(V.begin(),V.end());
    reverse(V.begin(),V.end());
    for(int i=0;i<a;i++){
        if(i%2==0){
            x=x+V[i];
        }else{
            x=x-V[i];
        }
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
typedef long long ll; 
#define pb push_back
#define mp make_pair
#define mod 998244353
#define vi vector <ll>
using namespace std ; 
ll power(ll x,ll y,ll m)
{            //power(x,y)=x^y  %m;
	ll res=1%m;
	while(y)
	{
	    if(y&1)
	    res=(res*x)%m;
	    x=(x*x)%m;
	    y=(y>>1)%m;
	}
	return res;
}
ll mod_inverse(ll x,ll m)
{
	return power(x,m-2,m);
}
vector<vector<ll> >g;
int main ()
{
    ios_base :: sync_with_stdio ( false );
    cin.tie( NULL );
    cout.tie( NULL );
ll t = 1 ;
//cin>>t;
while (t--)  
{
 ll x;
 cin>>x;
 if(x>=400 && x<=599)
 {
     cout<<'8'<<"\n";
     continue;
 }
 if(x>=600 && x<=799)
 {
     cout<<'7'<<"\n";
     continue;
 }
 if(x>=800 && x<=999)
 {
     cout<<'6'<<"\n";
     continue;
 }
 if(x>=1000 && x<=1199)
 {
     cout<<'5'<<"\n";
     continue;
 }
 if(x>=1200 && x<=1399)
 {
     cout<<'4'<<"\n";
     continue;
 }
 if(x>=1400 && x<=1599)
 {
     cout<<'3'<<"\n";
     continue;
 }
 if(x>=1600 && x<=1799)
 {
     cout<<'2'<<"\n";
     continue;
 }
 if(x>=1800&& x<=1999)
 {
     cout<<'1'<<"\n";
     continue;
 }
 
 
}
 

 return 0;
}

Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String tes = null;
		char c = 0;


		ArrayList<Integer> al = new ArrayList<Integer>();
		ArrayList<Integer> al2 = new ArrayList<Integer>();
		ArrayList<Integer> al3 = new ArrayList<Integer>();

		while(true){
			try {
				tes = br.readLine();
			} catch (IOException e) {
				// TODO 自動生成された catch ブロック
				e.printStackTrace();
			}
			if(tes == null){
				break;
			}
			if(tes.equals("")){
				break;
			}
			try{
				String[] fruit = tes.split(" ", 0);
				al.add(Integer.parseInt(fruit[0]));
				al2.add(Integer.parseInt(fruit[1]));
				al3.add(Integer.parseInt(fruit[2]));
			}catch(NumberFormatException e){
				break;
			}

			
			//al.add(a);
		}
		
		for(int r=0;r<al.size();r++){
			boolean e = false;
			int pri = 0;
			
			for(int i=1;i<=10;i++){
				if(al.get(r) == i || al2.get(r) == i || al3.get(r) == i){
					continue;
				}
				
				if(al.get(r)+al2.get(r)+i <= 20){
					pri++;
				}
			}
			if(pri <= 3){
				e =true;
			}
			if(e){
				System.out.println("NO");
			}else{
				System.out.println("YES");
			}
		}
		
		
	}

}

Measured memory_bytes: 16908
#include <iostream>
#include <cstdio>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <stdlib.h>
#include <functional>
#include <string>
#include <list>
#include <fstream>
#include <iomanip>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <chrono>
#include <bitset>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) <= (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define MODU 1000000007
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int

#include <nmmintrin.h>
#ifdef _MSC_VER

#define __builtin_popcount _mm_popcnt_u32
#define __builtin_popcountll _mm_popcnt_u64
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}



int main() {
	int a;
	cin >> a;
	vector<int> cand;
	int cur = 1;
	while (cur < 100000) {

		cand.push_back(cur);

		cur *= 9;
	}
	cur = 1;
	while (cur < 100000) {

		cand.push_back(cur);

		cur *= 6;
	}

	int dp[100][100001] = {};

	sort(ALL(cand));
	dp[0][a] = 1;
	REP(i, 100) {

		REP(j, a + 1) {


			if(dp[i][j] == 0) continue;

			if (j == 0) {
				cout << i << endl;
				return 0;

			}
			for (auto itr : cand) {
				if (j - itr >= 0) dp[i + 1][j - itr] = 1;
			}
		}

	}

	return 0;
}


Measured memory_bytes: 39424
import Foundation
func toTuple<T>(_ args: [T]) -> (T, T, T) { (args[0], args[1], args[2]) }
func readInts() -> [Int] { readLine()!.split(separator: " ").map { Int($0)! } }

let (a, b, k) = toTuple(readInts())
var array: [Int] = []
if (b - a) / 2 >= k {
  array.append(contentsOf: a...a+k-1)
  array.append(contentsOf: b-k+1...b)
} else {
  array.append(contentsOf: a...b)
}
Set(array).sorted().forEach { print($0) }

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

public class Main {
	static long mod = (long)1e9+7;
	public static void main(String[] args) {
		FastScanner sc=new FastScanner();
        int n = sc.nextInt();
        // ans should be 10^n - 9^n - 9^n + 8^n;
        // Because the no of subsequence we can form is : the whole set - when 9 is not present, when  is not present and then adding the intersection.
        long ans = (pow(n,10)%mod + mod)%mod - (2*pow(n,9)%mod + mod)%mod + (pow(n,8)%mod + mod)%mod;
        System.out.println((ans%mod + mod)%mod);
    }
    
    public static long pow(int n,int val) {
        long ans = 1;
        for (int i = 0; i < n; i++) {
            ans *= val;
            ans %= mod;
        }
        return ans%mod;
    }

   
	static final Random random = new Random();
	
	static void sort(int[] a) {
		int n = a.length;
		for(int i =0; i<n; i++) {
			int val = random.nextInt(n);
			int cur = a[i];
			a[i] = a[val];
			a[val] = cur;
		}
		Arrays.sort(a);
	}
	
	static void sortl(long[] a) {
		int n = a.length;
		for(int i =0; i<n; i++) {
			int val = random.nextInt(n);
			long cur = a[i];
			a[i] = a[val];
			a[val] = cur;
		}
		Arrays.sort(a);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (st == null  || !st.hasMoreTokens()) {
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}
		String nextLine() { 
            String str = ""; 
            try
            { 
                str = br.readLine(); 
            } 
            catch (IOException e) 
            { 
                e.printStackTrace(); 
            } 
            return str; 
		} 
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
		double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
	}

}


Measured memory_bytes: 32740
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>

using namespace std;

typedef long long in;

int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    for(int i=0;i<n;i++)
        cin >> s[i];
    int sum=0;
    sort(s.begin(),s.end());
    for(int i=0;i<n;i++)
        sum+=s[i];
    if(sum%10!=0){
        cout << sum << endl;
    }
    else{
        for(int i=0;i<s.size();i++){
            if(s[i]%10!=0){
                sum-=s[i];
                cout << sum << endl;
                return 0;
            }
            if(i==n-1){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890

using namespace std;

int main()
{
    int i,j;
    int a,b,c;

    scanf("%d %d %d",&a,&b,&c);
    printf("%d\n",max(0,c-(a-b)));

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define repu(i,x,y) for (int i=x; i<=y; ++i)
#define repd(i,x,y) for (int i=x; i>=y; --i)
using namespace std;

int n,fa[1010],a[1010],f[1010],g[1010][5010];

void insert(int *f,int n,int x,int y)
{
    repd(i,n,0)
    {
        int t=1<<29;
        if (i>=x)
            t=min(t,f[i-x]+y);
        if (i>=y)
            t=min(t,f[i-y]+x);
        f[i]=t;
    }
}

int main()
{
    scanf("%d",&n);
    repu(i,2,n)
        scanf("%d",&fa[i]);
    repu(i,1,n)
        scanf("%d",&a[i]);
    repd(i,n,1)
    {
        f[i]=1<<29;
        repu(j,0,a[i])
            f[i]=min(f[i],g[i][j]);
        insert(g[fa[i]],a[fa[i]],a[i],f[i]);
    }
    puts(f[1]<1<<29?"POSSIBLE":"IMPOSSIBLE");
    return 0;
}

Measured memory_bytes: 18432
import java.util.Scanner;

/*
問題文

*/

public class Main {
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];

        for (int i = 0; i < n-1; i++) {
            int tmp = sc.nextInt();
            a[tmp-1] += 1;
        }
        a[n-1] = 0;

        for (int i = 0; i < n; i++) {
            System.out.println(a[i]);
        }
    }
}

Measured memory_bytes: 60336