akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << 0 << endl;
    string L;
    cin >> L;
    if (L == "Vacant") return 0;
    cout << n-1 << endl;
    string R;
    cin >> R;
    if (R == "Vacant") return 0;
    int left = 1;
    int right = n-2;
    while (right - left != 0){
        int mid = (left + right) / 2;
        cout << mid << endl;
        string res;
        cin >> res;
        if (res == "Vacant") return 0;
        if ((mid - left + 1) % 2 == 0 && L!=res){
            right = mid-1;
            R = res;
        }
        else if ((mid - left + 1) % 2 != 0 && L==res){
            right = mid-1;
            R = res;
        }
        else{
            left = mid+1;
            L = res;
        }
    }
    cout << left << endl;
    string x;
    cin >> x;
    return 0;
}








Measured memory_bytes: 852
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from collections import deque
import sys


def input(): return sys.stdin.readline()[:-1]

n = int(input())
data = [list(map(int, list(input()))) for i in range(n)]
fordfs = [[] for i in range(n)]
for i in range(n):
    for j in range(n):
        if data[i][j] == 1:
            fordfs[i].append(j)

def bfs():
    V = [-1]*n
    V[0] = 0
    que = deque()
    que.append(0)
    while que:
        now = que.popleft()
        nowv = V[now]
        for ne in fordfs[now]:
            if nowv == V[ne]:
                print(-1)
                exit()
            elif V[ne] == -1:
                V[ne] = (nowv+1) % 2
                que.append(ne)

bfs()
# print(data)
G = csgraph_from_dense(data)
d = floyd_warshall(G)
d.tolist()
M = 0
for i in d:
    M = max(M, max(i))
M = int(M)
print(M+1)


Measured memory_bytes: 19488
import java.util.Scanner;
     
     
     
    class Main {
     
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            int H = sc.nextInt();
            int W = sc.nextInt();
            sc.nextLine();
            String [][] S = new String [H][W];
            final int height = H;
            final int width = W;
            int [][] number = new int [H][W];
            String[]tmp = new String[H];
           
            for (int i = 0; i < H ; i++){
                tmp[i] = sc.nextLine();
            }
                
            //set Tiles
            for (int i = 0; i < H ; i++){
                String[] str = tmp[i].split("");
                for (int j = 0; j <W ; j++){
                    S[i][j] = str[j];
                }
            }
     
            //print mine number
            for (int i = 0; i < H ; i++){
                for(int j = 0; j < W; j ++){
                    if(S[i][j].equals("#")){
                        if( countMine(i , j, height, width, S ) == true){
                            continue;
                        }else{
                            System.out.println("No");
                            System.exit(0);
                        }
                    }
                }   
            }
            System.out.println("Yes");
            sc.close();
        }
        
        public static boolean countMine( int i, int j, int height, int width, String[][] S){
            boolean result = false;
            if( i - 1 >= 0 && S[i-1][j].equals("#") ) {
            	result = true;
            }else if( i + 1 < height && S[i+1][j].equals("#") ) {
            	result = true;
            }else if( j + 1 < width && S[i][j+1].equals("#")) {
            	result = true;
            }else if( j - 1 >= 0 && S[i][j-1].equals("#")) {
            	result = true;
            }else {
            }
            return result;
        }
    }

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

int main()
{
    int n;
    std::cin >> n;
    int ar[n];
    for (int i = 0; i < n; i++) { std::cin >> ar[i]; }
    std::sort(ar, ar + n);
    int sum = 0;
    for (int i = 0; i < n - 1; i++) { sum += ar[i]; }
    ar[n - 1] < sum ? std::cout << "Yes" << std::endl : std::cout << "No" << std::endl;
    return 0;
}

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

using namespace std;

const int INF = 1e9;
int dp[1010][1010];

int main(void) {
  int n, m;
  cin >> n >> m;

  vector<int> d(n), c(m);
  for (int i = 0; i < n; i++) {
    cin >> d[i];
  }
  for (int i = 0; i < m; i++) {
    cin >> c[i];
  }

  fill(dp[0], dp[1010], INF);
  fill(dp[0], dp[0] + 1010, 0);
  for (int i = 1; i <= n; i++) {
    for (int j = i; j <= m - n + i; j++) {
      dp[i][j] = min(dp[i - 1][j - 1] + d[i - 1] * c[j - 1], dp[i][j - 1]);
    }
  }

  cout << dp[n][m] << endl;

  return 0;
}


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

int main(){
    int h,w;
    cin>>h>>w;
    int a[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    pair<int,pair<int,int>> p[h*w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i%2==0){
                p[w*i+j]={a[i][j],{i+1,j+1}};
            }
            else{
                p[w*i+j]={a[i][w-j-1],{i+1,w-j}};
            }
        }
    }
    vector<pair<pair<int,int>,pair<int,int>>> ans;
    for(int i=0;i<h*w-1;i++){
        if((p[i].first)%2==1){
            ans.push_back({p[i].second,p[i+1].second});
            p[i+1].first++;
        }
    }
    cout<<ans.size()<<endl;
    for(auto g:ans){
        cout<<g.first.first<<" "<<g.first.second<<" ";
        cout<<g.second.first<<" "<<g.second.second<<endl;
    }
}


Measured memory_bytes: 8048
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
using namespace std;
int n,x,y,zjl,t,ca,cb,alltime,nowtime;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>t>>x>>y;
		nowtime=t-alltime;
		zjl=abs(x-ca)+abs(y-cb);
		if(zjl==nowtime||zjl<nowtime&&(nowtime-zjl)%2==0) {ca=x;cb=y;} else {cout<<"No\n";return 0;}
		alltime=t;
	}
	cout<<"Yes\n";
	return 0;
}

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

class UnionFind{
private:
  int size[100005];
  int array[100005];
public:
  UnionFind(int n){
    for(int i=0;i<=n;i++){
      array[i]=i;
      size[i]=1;
    }
  }
  
  int root(int a){
    if(array[a]==a){
      return(a);
    }
    return(array[a]=root(array[a]));
  }

  bool is_same(int a,int b){
    return(root(a)==root(b));
  }

  void unite(int a,int b){
    if(!is_same(a,b)){
      a=root(a);
      b=root(b);
      array[a]=b;
      size[b]+=size[a];
    }
    return;
  }
    
  int count(int a){
    return(size[root(a)]);
  }
};

int main(){
  int n,m,k;
  cin>>n>>m>>k;
  UnionFind friends(n);
  vector<int>graph[100005];
  
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    graph[a].push_back(b);
    graph[b].push_back(a);
    friends.unite(a,b);
  }

  int ans[100005];
  for(int i=1;i<=n;i++){
    ans[i]=friends.count(i)-1-graph[i].size();
    //    cout<<"i:"<<i<<endl;
    //    cout<<"ans[i]:"<<ans[i]<<endl<<endl;
  }
  
  for(int i=0;i<k;i++){
    int a,b;
    cin>>a>>b;
    if(friends.is_same(a,b)){
      ans[a]--;
      ans[b]--;
    }
  }
  
  for(int i=1;i<n;i++){
    cout<<ans[i]<<' ';
  }
  cout<<ans[n]<<endl;
  return(0);
}

Measured memory_bytes: 8184
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG

signed main() {
  int N; cin >> N;
  vector<int> a(N), b(N);
  rep(i, N) cin >> a[i];
  rep(i, N) cin >> b[i];
  
  int k = 0;
  rep(i, N) {
    if(a[i] > b[i]) k -= a[i]-b[i];
    if(a[i] < b[i]) k += (b[i]-a[i])/2;
  }
  
  if(k >= 0) cout << "Yes" << endl;
  else cout << "No" << endl;

}

Measured memory_bytes: 3804
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#ifdef ONLINE_JUDGE
  #define debug(x)
  #define debug2(x,y)
  #define debug3(x,y,z)
  #define assert(e) if(!(e)){stod("");}
#else
  #define debug(x) std::cerr<<#x<<": "<<x<<"\n"
  #define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
  #define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"
#endif

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  char c;
  scan(c);
  if (c <= 'Z') {
    print("A\n");
  } else {
    print("a\n");
  }
}

int main() {
  solve();
  return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    int n; cin>>n;
    vector <int> a(n), b(n), c(n-1); 
    rep(i,n) cin>>a[i]; rep(i,n) cin>>b[i]; rep(i,n-1) cin>>c[i];
    int ans = 0;
    rep(i,n){
        ans += b[a[i]-1];
        if(i!=0){
            if(a[i] == a[i-1]+1) ans += c[a[i-1] -1 ];
        }
        
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<vector<int>> gr(n, vector<int>());
  rep(i, m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    gr.at(a).push_back(b);
  }
  vector<vector<int>> chk(n, vector<int>(3, -1));
  int s, t;
  cin >> s >> t;
  s--; t--;
  chk.at(s).at(0) = 0;
  queue<pair<int, int>> q;
  q.push({s, 0});
  while(!q.empty()){
    auto p = q.front(); q.pop();
    for(int i : gr.at(p.first)){
      if(chk.at(i).at((p.second+1)%3) != -1) continue;
      chk.at(i).at((p.second+1)%3) = chk.at(p.first).at(p.second) + 1;
      q.push({i, (p.second+1)%3});
    }
  }
  if(chk.at(t).at(0) == -1) cout << -1 << endl;
  else cout << chk.at(t).at(0)/3 << endl;
  return 0;
}

Measured memory_bytes: 14324
#include<bits/stdc++.h>
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define GCD(a, b)       __gcd(a, b)
#define pi              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)
using namespace std;

int main()
{

    S s;
    cin>>s;

    int n=s.size();

    int first=(n-1)/2;
    int second=(n+3)/2;

    int j;


    S trial1=s;
    reverse(trial1.begin(),trial1.end());

    if(trial1!=s)
        cout<<"No"<<nl;
    else
    {
        S shoja,olta;


        j=first;
        for(int i=0;i<first;i++)
        {
            j--;
            shoja+=s[i];
            olta+=s[j];

        }

        if(shoja!=olta)
            cout<<"No"<<nl;
        else
        {
            j=n;
            shoja="";
            olta="";

            for(int i=second-1;i<n;i++)
            {
               j--;
                shoja+=s[i];
                olta+=s[j];
            }

            if(shoja==olta)
                cout<<"Yes"<<nl;
            else
                cout<<"No"<<nl;
        }
    }




    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

# from numba import njit

# input = stdin.readline

INF = 10**10

# @njit
def solve(x,y):
  res = INF
  for f in [0,1]:
    x_flag,y_flag = 0,0
    if f:
      _x = -x
      x_flag = 1
    else:
      _x = x
    for l in [0,1]:
      if l:
        _y = -y
        y_flag = 1
      else:
        _y = y

      if _x <= _y:
        res = min(res,_y-_x+x_flag+y_flag)
  return res




def main():
  x,y = map(int,input().split())
  # a = list(map(int,input().split()))
  print(solve(x,y))
  return

if __name__ == '__main__':
  main()


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

int main() {
    string s;
    int a;
    char c;
    getline(cin,s);
    for (int i=0;i<s.size();i++){
        a=s[i];
        if ((a>='A')&&(a<='Z'))
            a=a+32;
        else if ((a>='a')&&(a<='z'))
            a=a-32;
        c=a;
        cout << c;
    }
    cout << '\n';
    return 0;
}


Measured memory_bytes: 3052
n = int(raw_input())
a = map(int, raw_input().split())
s = [0] * n
s[0] = a[0]
for i in xrange(1, n):
    s[i] += s[i - 1] + a[i]
ans = 10**12
for i in xrange(n - 1):
    ans = min(ans, abs(s[i] - (s[n - 1] - s[i])))
print ans

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

int main(){
  long long int a,b,c,d;
  cin >> a >> b >> c>> d;
  vector<long long int> x(4);
  x.at(0) = a * c;
  x.at(1) = a * d;
  x.at(2) = b * c;
  x.at(3) = b * d;
  
  sort(x.begin(),x.end());
  cout << x.at(3) << endl;
  
}

Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var w, h, x, y float64
	fmt.Scan(&w, &h, &x, &y)
	ans1 := 0.0
	ans1 = w * h / 2
	fmt.Println(ans1)

	ans2 := 0
	if x*2 == w && y*2 == h {
		ans2++
	}
	fmt.Println(ans2)
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/27  Problem: 060_arc_b / Link: https://arc060.contest.atcoder.jp/tasks/arc060_b?lang=en  ----- */
/* ------問題------

2 以上の整数 b および 1 以上の整数 n に対し、関数 f(b,n) を次のように定義します。

n<b のとき f(b,n)=n
n≥b のとき f(b,n)=f(b, floor(n⁄b))+(n mod b)
ここで、floor(n⁄b) は n⁄b を超えない最大の整数を、 n mod b は n を b で割った余りを表します。

直感的に言えば、f(b,n) は、n を b 進表記したときの各桁の和となります。 例えば、

f(10, 87654)=8+7+6+5+4=30
f(100, 87654)=8+76+54=138
などとなります。

整数 n と s が与えられます。 f(b,n)=s を満たすような 2 以上の整数 b が存在するか判定してください。 さらに、そのような b が存在するならば、その最小値を求めてください。

-----問題ここまで----- */
/* -----解説等-----

全探索だけど最後の方は2進数になりはしょれる

----解説ここまで---- */

LL N;

LL ans = 0LL;


LL f(LL b, LL n) {
	if (n < b)return n;
	else return f(b, n / b) + n % b;
}
int main() {
	cin.tie(0);
	ios_base::sync_with_stdio(false);


	cin >> N;
	LL s; cin >> s;

	ans = LINF;
	if (N == s)ans = N + 1;

	for (LL i = 2; i*i <= N; i++) {
		LL val = f(i, N);
		if (val == s)
			ans = min(ans, i);
	}

	for (LL i = 1; i*i < N; i++) {
		LL b = (N - s) / i + 1;
		if (b > 1) {
			if (f(b, N) == s) {
				ans = min(ans, b);
			}
		}
	}

	if (ans == LINF)ans = -1;
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
import numpy as np
 
mod = 10 ** 9 + 7
 
N = int(input())
A = np.array(list(map(int, input().split())))
 
 
ans = 0
for n in range(len(bin(max(A)))):   # 最大桁数は、最も大きい数値の2進数の桁数
    num_1 = np.count_nonzero((A >> n)&1)   # 1の数をカウント
    num_0 = N - num_1                      # 0の数をカウント
    mul = num_1 * num_0   # 0 XOR 1の回数
    ans += ((2 ** n)*mul) % mod
ans %= mod
print(ans)

Measured memory_bytes: 48828
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
from functools import lru_cache
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())

for i in range(100):
    for j in range(100):
        if 4*i+j*7==n:
            print("Yes")
            quit()
print("No")

Measured memory_bytes: 38640
#include <stdio.h>
#include <math.h>

int main( void ) {

	int n;
	double a[3], b[3], dist;

	scanf( "%d", &n );

	while ( n-- ) {

		scanf( "%lf %lf %lf %lf %lf %lf", &a[0], &a[1], &a[2], &b[0], &b[1], &b[2] );
		
		dist = sqrt( ( a[0] - b[0] ) * ( a[0] - b[0] ) + ( a[1] -  b[1] ) * ( a[1] -  b[1] ) );

		if ( dist > a[2] + b[2] ) { printf( "0\n" ); }
		else if ( a[2] > b[2] && dist < a[2] - b[2] ) { printf( "2\n" ); }
		else if ( a[2] < b[2] && dist < b[2] - a[2] ) { printf( "-2\n" ); }
		else  { printf( "1\n" ); }

	}

	return 0;

}

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

int main() {
    int K; cin >> K;
    int A[32] = {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};
    cout << A[K - 1] << endl;
    return 0;
}

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

string solve(int c1, int c2, int c3){
	int bunbo = 7;	// not 6. if6 -> (in)8 9 10 (out)YES.
	int mysum = c1 + c2;
	int okCount = 0;
	double kakuritu;
	for (int i = 1; i <= 10; i++){
		if (i == c1 || i == c2 || i == c3)	continue;
		else{
			if (mysum + i <= 20)	okCount++;
		}
	}
	kakuritu = (double)okCount / bunbo * 100.0;
	if (kakuritu >= 50.0)	return "YES";
	else return "NO";
}

int main(){
	int c1, c2, c3;
	while (cin >> c1 >> c2 >> c3, !cin.eof()){
		cout << solve(c1,c2,c3) << endl;
	}

	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N  = in();
    string S = to_string(N);
    bool se = 0;
    REP(i,3){
        if(S[i] == '7')se = 1;
    }
    cout << (se ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 3704
import sys

input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))

A_dash = []
for i in range(N):
    A_dash.append(A[i] - (i + 1))

A_dash.sort()
ans = -float("inf")
if N % 2 == 1:
    tmp = 0
    b = A_dash[N // 2]
    for i in range(N):
        tmp += abs(A_dash[i] - b)
    print(tmp)
else:
    tmp1 = 0
    b = A_dash[N // 2 - 1]
    for i in range(N):
        tmp1 += abs(A_dash[i] - b)
    
    tmp2 = 0
    b = A_dash[N // 2]
    for i in range(N):
        tmp2 += abs(A_dash[i] - b)
    print(min(tmp1, tmp2))

Measured memory_bytes: 107568
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

n = int(input())
a = list(map(int, input().split()))

ans = 0
for i in range(n):
    if i%2 == 0:
        if a[i]%2 == 1:
            ans += 1
print(ans)

Measured memory_bytes: 10472
#include <iostream>
#include <numeric>
#include <algorithm>
#include <functional>
#include <vector>
#include <cmath>
#include <chrono>
#include <queue>
#include <set>
#include <cassert>
#include <random>
#include <chrono>
#include <complex>
#include <cstring>
constexpr int dx[] = {0, 0, -1, 1}, dy[] = {-1, 1, 0, 0};
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    int n;
    std::cin >> n;
    std::vector<std::vector<int>> a(n + 2, std::vector<int>(n + 2));
    std::vector<std::vector<int>> dis(n + 2, std::vector<int>(n + 2));
    for (int x = 1; x <= n; ++x)
        for (int y = 1; y <= n; ++y)
            a[x][y] = 1;
    for (int x = 0; x < n; ++x)
        for (int y = 0; y < n; ++y)
            dis[x + 1][y + 1] = std::min({x, n - 1 - x, y, n - 1 - y}) + 1;
    int ans = 0;
    for (int i = 0; i < n * n; ++i) {
        int p;
        std::cin >> p;
        --p;
        int x = p / n + 1, y = p % n + 1;
        a[x][y] = 0;
        ans += --dis[x][y];
        std::queue<std::pair<int, int>> que;
        que.emplace(x, y);
        while (!que.empty()) {
            auto p = que.front();
            que.pop();
            int x = p.first, y = p.second;
            for (int i = 0; i < 4; ++i) {
                int x1 = x + dx[i];
                int y1 = y + dy[i];
                if (dis[x1][y1] > dis[x][y] + a[x1][y1]) {
                    dis[x1][y1] = dis[x][y] + a[x1][y1];
                    que.emplace(x1, y1);
                }
            }
        }
    }
    std::cout << ans << "\n";
    return 0;
}

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

int main() {
  long int N, ans = 0, n;
  cin >> N;
  for (long int i = 1; i<=N; i++){
    n = N/i;
    ans += i*n*(n+1)/2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int n, k; cin >> n >> k;
    ll ans = 1ll<<60;
    rep(bit, ((1<<n))) {
        ll res = 1;
        rep(i, n) {
            if((bit>>i)&1) res *= 2;
            else res += k;
        }
        ans = min(ans, res);
    }
    cout << ans;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <climits>
#include <numeric>
#include<stdio.h>
#include <queue>
#include <iomanip>
#include <float.h>
#include <set>
#include<functional>
#include <stack>
#include <time.h>
using namespace std;
int  gcd(int a, int b) {
	if (a < b) gcd(b, a);
	int r;
	while ((r = a%b)) {
		a = b;
		b = r;
	}
	return b;
}
long long lcm(long long a, long long b) {
	return a / gcd(a, b) * b;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int cntb = 0;
int cntw = 0;
int h, w;
int field[403][403];
int siyouzumi[403][403];
void dfs(int nowh,int noww,int bw) {
	if (siyouzumi[nowh][noww])return;
	siyouzumi[nowh][noww] = 1;
	if (bw == 0) {
		cntb += 1;
	}
	else cntw += 1;
	if (nowh > 0) {
		if (field[nowh - 1][noww] == 1 - bw&&siyouzumi[nowh - 1][noww] == 0) {
			dfs(nowh - 1, noww, 1 - bw);
		}
	}
	if (nowh < h - 1) {
		if (field[nowh + 1][noww] == 1 - bw&&siyouzumi[nowh + 1][noww] == 0) {
			dfs(nowh + 1, noww, 1 - bw);
		}
	}
	if (noww < w - 1) {
		if (field[nowh][noww+1] == 1 - bw&&siyouzumi[nowh][noww+1] == 0) {
			dfs(nowh, noww+1, 1 - bw);
		}
	}
	if (noww > 0) {
		if (field[nowh][noww-1] == 1 - bw&&siyouzumi[nowh][noww-1] == 0) {
			dfs(nowh, noww-1, 1 - bw);
		}
	}
}
signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q;
	cin >> n >> q;
	int a[100004];
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long ruiseki[100005];
	ruiseki[0] = a[0];
	ruiseki[1] = a[1];
	for (int i = 2; i < n; i+=2) {
		ruiseki[i] = ruiseki[i - 2] + a[i];
	}
	for (int i = 3; i < n; i += 2) {
		ruiseki[i] = ruiseki[i - 2] + a[i];
	}
	long long ruiseki2[100005];
	ruiseki2[0] = a[0];
	for (int i = 1; i < n; i++) {
		ruiseki2[i] = ruiseki2[i - 1] + a[i];
	}
	long long x;
	for (int z = 0; z < q; z++) {
		cin >> x;
		long long ans = 0;
		long long lb = -2;
		long long ub = 1000000003;
		long long mid, migi, hidari;
		int hidarix, migix, num, takahashi, b;
		while ( 1) {
			mid = (ub + lb) / 2;
			migi = x + mid;
			hidari = x - mid;
			hidarix = lower_bound(a, a + n, hidari) - a;
			if (a[n - 1] <= migi)migix = n - 1;
			else migix = upper_bound(a, a + n, migi) - a - 1;
			num = max(0, migix - hidarix + 1);
			if (a[migix]<hidari || a[hidarix]>migi)num = 0;
			takahashi = n - num;
			b = takahashi - migix;
			if (x-a[hidarix] == a[migix]-x&&x-a[hidarix]>0 && b ==0) {
				b += 2;
				takahashi += 1;
				num += 1;
			}
			if (num == 0&&mid==-1)break;
			if (b > 0 && b <= 2)break;
			if (b <= 0)ub = mid;
			if (b > 2)lb = mid+1;
		}
		if (num == 0) { cout << ruiseki[n - 1] << "\n"; continue; }
		if (b == 2) {
			ans = ruiseki2[n - 1] - ruiseki2[takahashi - 2];
			if (hidarix >= 2)ans += ruiseki[hidarix - 2];
			cout << ans << "\n";
		}
		else {
			ans = ruiseki2[n - 1] - ruiseki2[takahashi - 1];
			if (hidarix >= 1)ans += ruiseki[hidarix - 1];
			cout << ans << "\n";
		}
	}
}

Measured memory_bytes: 3712
words = lambda t : list(map(t, input().split()))
n = int(input())
a = words(int)

negcnt = 0
zcnt = 0
for k in a:
    if k < 0:
        negcnt += 1
    elif k == 0:
        zcnt += 1

ans = 0
if (negcnt + zcnt) % 2 == 0:
    for k in a:
        ans += abs(k)
    print(ans)
else:
    negmin = (10**9+1)
    for k in a:
        if abs(k) < negmin:
            negmin = abs(k)
    for k in a:
        ans += abs(k)
    #print(ans,negmin)
    print(ans - 2*negmin)


Measured memory_bytes: 14464
def main():
  N = int(input())
  d = [1] * (N)
  ans = 0

  for i in range(2, N+1):
    f = i

    while True:
      d[f - 1] += 1
      f += i

      if(f > N):
        break

  for K in range(1, N+1):
    ans += K * d[K-1]

  print(ans)

if __name__ == "__main__":
  main()

Measured memory_bytes: 145724
n = int(input())
a = [int(x) for x in input().split(' ')]

b = [0]
for x in a:
    b.append(b[-1] + x)
b.sort()

b.append(b[-1] + 999999999)
answer = 0
c = 0
for i in range(n + 1):
    if b[i] == b[i + 1]:
        c += 1
    else:
        answer += (c + 1) * c // 2
        c = 0

print(answer)

Measured memory_bytes: 27260
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <set>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repz(i,n) rep(i,0,n)


int main() {
	int n, m;
	cin >> n >> m;
	cout << ((n + m) * (n + m - 1))/2 - (n * m) << endl;

	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = (ll)(1e9+7);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(int)(n); (i)++)
int dx[4]={ 1,0,-1,0 };
int dy[4]={ 0,1,0,-1 };

ll N, M, A[100000], sum[100000];

ll count(ll x){ // 幸福度の差分が x 以上となる手の握り方の数
    ll ret = 0;
    rep(i, N){ // i は左手
        ret += (ll)(A+N - lower_bound(A, A+N, x-A[i]));
    }
    return ret;
}

ll binarySearch(){
    ll ok = 0;
    ll ng = 200001;
    while(ng-ok > 1){
        ll m = (ok+ng)/2;
        if(count(m) >= M) ok = m;
        else ng = m;
    }
    return ok;
}

signed main(){
    cin >> N >> M;
    rep(i, N) cin >> A[i];
    sort(A, A+N);

    sum[N-1] = A[N-1];
    for(int i=N-2; i>=0; i--) sum[i] = sum[i+1] + A[i];

    ll k = binarySearch();
    ll ans = 0;
    ll cnt = 0;
    rep(i, N){
        int idx = lower_bound(A, A+N, k-A[i]) - A;
        // ans に idx 以降のものをまとめて加算したい
        ans += A[i] * (ll)(N-idx);
        ans += sum[idx];
        cnt += N-idx;
    }
    ans -= (cnt-M)*k;
    cout << ans << endl;
}

/*
3 2
1 2 3

3 2
1 1 1
*/

Measured memory_bytes: 1792
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //消費コストが常に0以上なので、最小となるのは1から100の間　全探索すればいい
        int N=sc.nextInt();
        int[] X=new int[N];
        for(int i=0; i<N; i++){
            X[i] = sc.nextInt();
        }
        int max=Integer.MAX_VALUE;
        int tmp=0;
        for(int zahyo=1; zahyo<=100; zahyo++){
            tmp=0;
            for(int i=0; i<N; i++){
                tmp+=(zahyo-X[i])*(zahyo-X[i]);
            }
            max=Math.min(max,tmp);
        }
        pl(max);
    }
    public static void pl(Object o){
        System.out.println(o);
    }
    public static void p(Object o){
        System.out.println(o);
    }
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second

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

/*** MOD CALCULATION ***/
const int MOD = 998244353;
const int MAX = 510000;

ll addM(ll a, ll b){
	return (a + b) % MOD;
}

ll mulM(ll a, ll b){
	return (a % MOD) * (b % MOD) % MOD;
}

ll powM(ll a, ll b){
	if(b == 0) return 1;
  	else if(b == 1) return a%MOD;
  	else if(b%2==0) return mulM(powM(a,b/2),powM(a,b/2));
  	else return mulM(a,mulM(powM(a,(b-1)/2),powM(a,(b-1)/2)));
}

// b^{-1} = b^{p-2} (mod p)
// a/b = a*b^{p-2} (mod p)
ll divM(ll a, ll b){ 
  	return mulM(a,powM(b,MOD-2));
}

// n!, (n!)^{-1} のテーブル作成
ll fac[MAX], finv[MAX], inv[MAX];
void COMBinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep3(i,2,MAX-1){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COMB(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

/*** MOD CALCULATION ここまで ***/

void Main()
{
	int n;
  	cin >> n;
  	vi d(n);
  	vi cnt(n,0);
  	int mx = 0;
  	rep(i,n) {
      	cin >> d[i];
    	cnt[d[i]]++;
      	mx = max(mx, d[i]);
    }
  
  	if(d[0] != 0 || cnt[0] > 1) {
      	cout << 0 << endl;
  		return;
	}
  	
	ll ans = 1;  	
	rep3(i,1,mx){
    	ans = (ans * powM(cnt[i-1],cnt[i])) % MOD;
    }  	
  	
 	cout << ans << endl;
	return;
}

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

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

vector<vector<int> > c(10,vector<int>(10));
int mp=1e9;

void dfs(int A,int sum){
  for(int i=0;i<10;i++){
    if(i==A){
      continue;
    }
    if(sum+c.at(A).at(i)<mp){
      if(i==1){
        mp=sum+c.at(A).at(i);
      }else{
        dfs(i,sum+c.at(A).at(i));
      }
    }
  }
}

int main(){
  int H,W;
  cin >> H >> W;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      cin >> c.at(i).at(j);
    }
  }
  int64_t ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      int A;
      cin >> A;
      if(A==-1){
        continue;
      }
      if(A==1){
        continue;
      }
      mp=c.at(A).at(1);
      dfs(A,0);
      ans+=mp;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
S = list(input())
N = len(S)

if S[0] == '0' and N % 2 == 0:
    white_black = [0,1]*(N//2)
elif S[0] == '1' and N % 2 == 0:
    white_black = [1,0]*(N//2)
elif S[0] == '0' and N % 2 == 1:
    white_black = [0,1]*(N//2) + [0]
elif S[0] == '1' and N % 2 == 1:
    white_black = [1,0]*(N//2) + [1]

count = 0

for i in range(N):
    if S[i] != str(white_black[i]):
        count += 1

print(count)

Measured memory_bytes: 5544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main() {
    int n;
    cin >> n;
    ll a, b;
    cin >> a >> b;
    ll h[n];

    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }
    sort(h, h + n, greater<ll>());
    ll ans = 0;
    ll dif = a - b;
    ll mx = (h[0] + b - 1) / b;
    ll mn = (h[0] + a - 1) / a;
    while (mn < mx) {
        ll total = 0;
        ll mid = (mx + mn) / 2;
        for (int i = 0; i < n; i++) {
            ll num = h[i] - b * mid;
            if (num > 0) {
                total += (num + dif - 1) / dif;
            }
        }
        if (total > mid) {
            mn = mid + 1;
        } else{
            mx = mid;
        }
    }
    cout << mx << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define PI 3.141592653589793
#define MOD 1000000007
//#define DEBUG

//qsort用、昇順
int compare_int(const void *a, const void *b)
{
	return *(int*)a-*(int*)b;
}
//qsort(array, 10, sizeof(int), compare_int)



int main(){
	int d, t, s;
	scanf("%d%d%d", &d, &t, &s);

	if(d<=t*s) printf("Yes\n");
	else printf("No\n");

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



Measured memory_bytes: 1660
long long G(long long x,long long y){return y?G(y,x%y):x;}
long long L(long long x,long long y){return x/G(x,y)*y;}
n[3],a[3],m[3];main(i,x){
	for(;scanf("%d%d%d%d%d%d",a,m,a+1,m+1,a+2,m+2),*m;){
		for(i=3;i--;)for(x=n[i]=1;(x=a[i]*x%m[i])>1;n[i]++);
		printf("%lld\n",L(n[0],L(n[1],n[2])));
	}
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[100005], finv[100005], inv[100005];

int alp2[30];
int main() {
	string a, b;
	cin >> a >> b;
	for (int i = 0; i < a.length(); ++i) { ++alp[a[i] - 'a']; }
	for (int i = 0; i < b.length(); ++i) { ++alp2[b[i] - 'a']; }
	sort(alp, alp + 26);
	sort(alp2, alp2 + 26);
	for (int i = 0; i < 26; ++i) {
		if (alp[i] != alp2[i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 776
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

int main()
{    
    int a,b,x;
    cin >> a >> b >> x;
    if(x<=a+b && x>=a)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

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

int main() {
	int H, W;
	while (1) {
		cin >> H >> W;
		if (H == 0 && W == 0)break;

		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				if ((i+j)%2==0){
					cout << "#";
				}
				else {
					cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
#include <stdio.h>
int main(void){
   
   
   int n,i,a,b,c;
   scanf("%d",&n);
   for(i=1;i<=n;i++){
       
       
       scanf("%d %d %d",&a,&b,&c);
       if(a*a==b*b+c*c||b*b==a*a+c*c||c*c==a*a+b*b){
           printf("YES\n");
           
       }
       else{
           printf("NO\n");
       }
   }
}



Measured memory_bytes: 2044
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

typedef long long ll;

int main(){
ll X,Y,Z,K; cin >> X >> Y >> Z >> K;
  vector<ll> A(X); vector<ll> B(Y); vector<ll> C(Z);
  
  for(ll i = 0; i < X; i++){ cin >> A[i];}
  for(ll j = 0; j < Y; j++){ cin >> B[j];}
  for(ll k = 0; k < Z; k++){ cin >> C[k];}
  
  sort(A.begin(),A.end()); sort(B.begin(),B.end()); sort(C.begin(),C.end());
  reverse(A.begin(),A.end()); reverse(B.begin(),B.end()); reverse(C.begin(),C.end());
  //全てを降順に並び替える
  vector<ll> D; vector<ll> E; vector<ll> F;
  for(ll i = 0; i < min(X,K); i++){
    for(ll j = 0; j < min(Y,K); j++){
      D.push_back(A[i]+B[j]);}} // A + B の上位K個の積を羅列する 
  sort(D.begin(),D.end()); reverse(D.begin(),D.end());
  
  for(ll i = 0; i < min(K, X*Y); i++){ F.push_back(D[i]);}
  
  for(ll i = 0; i < min(K, X* Y); i++){
    for(ll j = 0; j < min(K , Z) ; j++){
      E.push_back(F[i]+C[j]);}}
  
  sort(E.begin(),E.end()); reverse(E.begin(),E.end());
  
  for(ll i = 0; i < K; i++){
    cout << E[i] << endl;}
  
  return 0;}
      

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

typedef long long ll;

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

int main(){
  ll A, B;
  cin>>A>>B;
  cout<<lcm(A, B)<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
using namespace std;

void trace(int A[], int N){
  int  i;
  for ( i = 0; i < N; i++){
    if ( i > 0 ) printf(" ");
    printf("%d",A[i] );
  }
  printf("\n" );
}

void insertionSort(int A[], int N){
  int j, i ,v;
  for (i = 1; i < N; i++){
    v = A[i];
    j = i - 1;
    while (j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    trace(A, N);
  }
}


int main (){
  int N, i, j;
  int  A[100];
  cin >> N;

  for (int  i = 0 ; i < N ; i++) cin >> A[ i ];

  trace(A,N);
  insertionSort(A,N);

  return 0;
}

Measured memory_bytes: 1148
private fun readInts() = readLine()!!.split(" ").map { it.toInt() }

fun main(args: Array<String>) {
    val (N) = readInts()
    val H = readInts()

    var hotels = 1
    var max = H.first()
    H.drop(1).forEach { h ->
        if (h >= max) {
            max = h
            hotels++
        }
    }

    println(hotels)
}

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

#define MAX_N 200000
vector<int> A;
vector<int> max_pos;

int main() {
  int N;
  cin >> N;
  int a;
  for(int i=0; i<N; i++) {
    scanf("%d", &a);
    A.push_back(a);
  }
  int max1 = *max_element(A.begin(), A.end());
  int max2=0;
  for(int i=0; i<N; i++) {
    if(A[i] == max1) {
      max_pos.push_back(i);
    } else {
      max2 = max(max2, A[i]);
    }
  }
  for(int i=0; i<N; i++) {
    if(A[i] == max1 && max_pos.size()==1) {
      printf("%d\n", max2);
    } else {
      printf("%d\n", max1);
    }
  }
  return 0;
}



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
#define LINF LLONG_MAX/3
#define mp make_pair
#define pb push_back
#define EB emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
constexpr double eps = 1e-14; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

using P = pair<ll,ll>;

int N;
vector<ll> a;
vector<ll> ans;

int main(){
    cin >> N;
    a.resize(N);
    ans.assign(N,0);
    rep(i,N) cin >> a[i];

    vector<P> p;
    rep(i,N) p.pb(mp(-a[i],i));
    sort(all(p));
    for_each(all(p),[](P &pa){pa.first*=-1;});

    //cerr << p << endl;

    int idx = 0;
    ll rem=0;
    while(idx<N){
        //cerr << idx << " " << p[idx].first << " " << p[idx].second << endl;
        //cerr << ans << endl;
        if(p[idx].second == 0) break;

        int tmp = idx+1;
        while(tmp < N && p[tmp].second > p[idx].second){
            tmp++;
        }

        for(int i=idx+1;i<tmp;i++) ans[p[idx].second] += (p[i].first - p[tmp].first);

        ans[p[idx].second] += (p[idx].first - p[tmp].first)*(idx+1);

        idx = tmp;
    }


    ll sum = 0;
    rep(i,N) sum+=a[i];
    rep(i,N) sum-=ans[i];



    //cerr << "----------" << endl;
    cout << sum << endl;
    for(int i=1;i<N;i++) cout << ans[i] << endl;
}


Measured memory_bytes: 4336
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <complex>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cerr<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

struct State{
	int t,id;
	int io; // 0:駐車, 1:出庫
	int len; // 駐車の時:駐車時間, 出庫の時:駐車スペース
	State(){}
	State(int t,int id,int io,int len):t(t),id(id),io(io),len(len){}
	bool operator<(const State& s)const{
		if(t!=s.t) return t<s.t;
		if(io!=s.io) return io>s.io;
		if(io==0) return id<s.id;
		if(io==1) return len!=s.len?len<s.len:id>s.id;
		return false;
	}
	bool operator>(const State& s)const{
		if(t!=s.t) return t>s.t;
		if(io!=s.io) return io<s.io;
		if(io==0) return id>s.id;
		if(io==1) return len!=s.len?len>s.len:id<s.id;
		return false;
	}
};

int main()
{
	for(int m,n;cin>>m>>n,m|n;){
		priority_queue<State,vector<State>,greater<State>> pq;
		rep(i,n){
			int t; cin>>t;
			pq.push(State(i*10,i,0,t));
		}
		vvi pid(2,vi(m,-1)),out(2,vi(m,-1)); // [0][i]:下段, [1][i]:上段
		vi res;
		while(pq.size()){
			State cur=pq.top(); pq.pop();
			
			if(cur.io==0){ // 駐車
				rep(i,m) if(pid[0][i]==-1 && pid[1][i]==-1){
					pid[0][i]=cur.id;
					out[0][i]=cur.t+cur.len;
					pq.emplace(cur.t+cur.len,cur.id,1,i);
					goto end;
				}
				int j=-1;
				rep(i,m) if(pid[1][i]==-1 && out[0][i]>=cur.t+cur.len){
					if(j==-1 || out[0][j]>out[0][i])
						j=i;
				}
				if(j!=-1){
					pid[1][j]=pid[0][j];
					out[1][j]=out[0][j];
					pid[0][j]=cur.id;
					out[0][j]=cur.t+cur.len;
					pq.emplace(cur.t+cur.len,cur.id,1,j);
					goto end;
				}
				rep(i,m) if(pid[1][i]==-1){
					if(j==-1 || out[0][j]<out[0][i])
						j=i;
				}
				if(j!=-1){
					pid[1][j]=pid[0][j];
					out[1][j]=out[0][j];
					pid[0][j]=cur.id;
					out[0][j]=cur.t+cur.len;
					pq.emplace(cur.t+cur.len,cur.id,1,j);
					goto end;
				}
				pq.emplace(cur.t+1,cur.id,0,cur.len);
			}
			if(cur.io==1){ // 出庫
				rep(i,2) rep(j,m) if(pid[i][j]==cur.id){
					if(i==0){
						pid[0][j]=pid[1][j];
						out[0][j]=out[1][j];
						pid[1][j]=out[1][j]=-1;
						res.push_back(cur.id);
						goto end;
					}
					if(i==1){
						pq.emplace(cur.t+1,cur.id,1,cur.len);
						goto end;
					}
				}
			}
			end:;
		}
		rep(i,res.size())
			cout<<res[i]+1<<(i==res.size()-1?'\n':' ');
	}
	
	return 0;
}

Measured memory_bytes: 1224
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long X;
    cin >> X;
    if(X >= 30) cout << "Yes" << endl;
    else cout << "No" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3604