akhauriyash/Code-Regression huggingface dataset:
#[derive(Debug)]
struct ParseStdinError;
impl std::error::Error for ParseStdinError {}
impl std::fmt::Display for ParseStdinError {
    fn fmt(&self, formatter: &mut std::fmt::Formatter) -> std::fmt::Result {
        write!(formatter, "parse stdin error")
    }
}

macro_rules! input {
    () => {{
        use std::io::*;
        let mut buffer = String::new();
        stdin().lock().read_to_string(&mut buffer)?;
        buffer
    }
    .lines()
    .next()
    .ok_or(ParseStdinError)?
    .split(' ')
    .next()
    .ok_or(ParseStdinError)?};
}

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let mut f = false;
    for v in input!().chars() {
        if v == '7' {
            f = true;
            break;
        }
    }
    if f {
        println!("Yes")
    } else {
        println!("No")
    }
    Ok(())
}


Measured memory_bytes: 2156
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

#define ALL(a)     (a).begin(),(a).end()
#define EACH(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c)    sort((c).begin(),(c).end())
#define RSORT(c)    sort((c).rbegin(),(c).rend())
#define MAXINDEX(c) distance((c).begin(),max_element((c).begin(),(c).end()))
#define MININDEX(c) distance((c).begin(),min_element((c).begin(),(c).end()))
#define DEBUG(x)   std::cerr <<#x<<" = "<<(x)<<" ("<<__FILE__<<"::"<<__LINE__<<")"<<std::endl;
#define ERROR(s)   std::cerr <<"Error::"<<__FILE__<<"::"<<__LINE__<<"::"<<__FUNCTION__<<"::"<<(s)<<std::endl;
#define FOR(i,a,b) for (auto i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)

constexpr bool __debugFlag = false;

int searchIndexOfminus2plus(std::vector<int> v){
    for( size_t i = 0; i < v.size()-1 ; i ++  ) {
        if (v[i] < 0 && v[i+1] >= 0) {
            return i;
        }
    }
    return -1;
} 

int main(int argc, char **argv){
    
    // get inputs 
    size_t numberOfCandle;
    size_t numberOfLight;

    cin >> numberOfCandle >> numberOfLight;
    
    vector <int> candleCordinates( numberOfCandle ); 
    for(size_t i=0; i<numberOfCandle; i++) {
        cin >> candleCordinates[i] ;
    }


    int64_t globalMinTime = 2 * ( abs(candleCordinates[0]) + abs(candleCordinates[numberOfCandle-1])  );
    for(size_t i=0; i<=numberOfCandle-numberOfLight; i++){
        int beginValue = candleCordinates[i];
        int64_t minusSideTime = beginValue < 0 ? abs(beginValue) : 0;

        int endValue = candleCordinates[i + numberOfLight - 1];
        int64_t plusSideTime = endValue > 0 ? abs(candleCordinates[i + numberOfLight - 1]) : 0;

        int64_t localMinTime = min ( 2 * minusSideTime + plusSideTime , minusSideTime + 2 * plusSideTime ) ;
        globalMinTime = min ( globalMinTime , localMinTime) ;       
    }   



    cout << globalMinTime << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    multiset< int> st;
    while (n--) {
        int a;
        cin >> a;
        st.insert(a);
    }

    int k = 0, cnt = 0;
    while(!st.empty()) {
        k++;
        int a = *st.begin();
        int b = st.count(a);
        if(b % 2 == 0) cnt++;
        st.erase(a);
    }

    cout << k - (cnt % 2) << endl;
}

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

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int ans[3003][3003];

void dfs( int n, int d=1, int a=1 ){
    if( n == 0 ) return;
    // printf ("n=%d d=%d a=%d\n", n,d,a);
    Rep(di,d){
        Rep(i,n){
            Rep(k,n){
                if( (i-k)%2 ) ans[i*d+di][k*d+di] = a;
            }
        }
    }
    dfs( n/2 , d+d, a+1 );
    return;
}

int main() {

    int N;
    Scd(N);

    int k = 1;
    int t = 0;

    while( N >= k ){
        k <<= 1;
    }

    dfs(k);
    Rep(i,N){
        Repe(k,N,i+1){
            printf ("%d%c", ans[i][k], k == N-1 ? '\n' : ' ' );
        }
    }

    return 0;
}



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

int main() {
  string s;
  cin >> s;
  
  bool ans = false;
  for (int i = 0; i < 3; i++) {
  	if (s.at(i) == s.at(i + 1)) {
    	ans = true;
    }
  }
  
  if (ans) {
  	cout << "Bad" << endl;
  }
  else {
  	cout << "Good" << endl;
  }
}


Measured memory_bytes: 256
#require 'pp'

ans = []
(0..9).each do |i|
  (0..9).each do |j|
    (0..9).each do |k|
      ans << [i, j, k]
    end
  end
end

n = gets.chomp!.to_i
s = gets.chomp!.chars.map(&:to_i)

count = 0
ans.each do |x|
  index = 0
  target = x[0]
  target_index = 0
  while index < s.length
    if target == s[index]
      if target_index == 2
        count += 1
        break
      end
      target_index += 1
      target = x[target_index]
    end

    index += 1
  end
end

puts count


Measured memory_bytes: 5500
#pragma region kyomukyomupurin

/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2020-05-10 19:13:16
 **/

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

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, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int flag = 0;
  for (auto e : vec) os << (flag++ ? ", " : "{") << e;
  return os << (vec.empty() ? "{}" : "}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int flag = 0;
  for (auto e : st) os << (flag++ ? ", " : "{") << e;
  return os << (st.empty() ? "{}" : "}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int flag = 0;
  for (auto e : mp) os << (flag++ ? ", " : "{") << e;
  return os << (mp.empty() ? "{}" : "}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  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)...);
}

#pragma endregion kyomukyomupurin

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

  int h, w; cin >> h >> w;
  char board[h][w];

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> board[i][j];
    }
  }

  bool use[101][101];
  fill(use[0], use[101], true);

  for (int i = 0; i < h; ++i) {
    bool flag = false;
    for (int j = 0; j < w; ++j) flag |= (board[i][j] == '#');
    if (!flag) {
      for (int k = 0; k < w; ++k) use[i][k] = false;
    }
  }

  for (int i = 0; i < w; ++i) {
    bool flag = false;
    for (int j = 0; j < h; ++j) flag |= (board[j][i] == '#');
    if (!flag) {
      for (int k = 0; k < h; ++k) use[k][i] = false;
    }
  }

  for (int i = 0; i < h; ++i) {
    bool flag = true;
    if (all_of(use[0], use[101], [](bool e){ return !e; })) {
      flag = false;
    }
    for (int j = 0; j < w; ++j) {
      if (use[i][j]) cout << board[i][j];
    }
    if (flag) cout << '\n';
  }

  return 0;
}

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

typedef long long ll;

int main() {
  int N; cin >> N;
  vector<ll> vx(N), vy(N), vh(N);
  int si = -1;
  for(int i=0; i<N; i++){
    cin >> vx[i] >> vy[i] >> vh[i];
    if(vh[i]>0) si=i;
  }

  ll resx=-1, resy=-1, resh=-1;
  for(ll x=0; x<=100; x++){
    for(ll y=0; y<=100; y++){
      ll h=vh[si] + abs(x-vx[si]) + abs(y-vy[si]);
      bool ok=true;
      for(int i=0; i<N; i++){
        // その座標の高さが0より大きい　かつ　ある座標で分かるピラミッドの頂点と一致しない場合
        if(vh[i]>0 && h-vh[i] != abs(x-vx[i]) + abs(y-vy[i]))
          ok = false;
        // その座標の高さが0　かつ　その座標から求められるピラミッドの頂点が h より低い場合
        if(vh[i] == 0 && h > abs(x-vx[i]) + abs(y-vy[i]))
          ok = false;
      }
      if(ok) resx=x, resy=y, resh=h;
    }
  }

  cout << resx <<" "<< resy <<" "<< resh << endl;

}

Measured memory_bytes: 256
from heapq import heappop, heappush
N, M = map(int, input().split())
A = list(map(int, input().split()))
H = []
for a in A:
    heappush(H, -a)

cnt = 0
while cnt < M:
    a = heappop(H)
    heappush(H, -((-a)//2))
    cnt += 1

print(-sum(H))

Measured memory_bytes: 64792
#include<stdio.h>
int main()
{
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  
  for(int i =1;i<=10;i++)
  {
    printf("%d\n",a*c-b);
    c=a*c-b;
  }
  return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int n;
  cin >> n;

  vector<pair<ll, ll>> a(n);
  rep(i, n){
    ll tmp;
    cin >> tmp;
    a[i] = make_pair(tmp, i);
  }

  sort(a.begin(), a.end());

  set<ll> st;
  st.insert(-1);
  st.insert(n);

  ll ans = 0;
  rep(i, n){

    ll val = a[i].first;
    ll ind = a[i].second;

    ll right = *st.upper_bound(ind);
    st.insert(ind);
    ll left = *(--st.lower_bound(ind));
    
    ans += val * (right - ind) * (ind - left);

  }

  cout << ans << endl;


  return 0;
}


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

// iterator
#define REP(i,from, to) for(lli i=from;i<to;i++)
#define REPE(i,from, to) for(lli i=from;i<=to;i++)
#define REP_R(i,from, to) for(lli i=from;i>to;i--)
#define REPE_R(i,from, to) for(lli i=from;i>=to;i--)
#define REPIT(it,container) for(auto it = container.begin(); it != container.end(); it++)
#define REPIT_R(it,container) for(auto it = container.rbegin(); it != container.rend(); it++)

// input
#define cin1(x)             cin >> x
#define cin2(x, y)          cin >> x >> y
#define cin3(x, y, z)       cin >> x >> y >> z
#define ncin1(n, x)         REP(i, 0, n) {cin1(x[i]);}
#define ncin2(n, x, y)      REP(i, 0, n) {cin2(x[i], y[i]);}
#define ncin3(n, x, y, z)   REP(i, 0, n) {cin3(x[i], y[i], z[i]);}

// output
#define cout1(x)         cout << #x << ": " << x << endl;
#define cout2(x, y)      cout << #x << ": " << x << ", " << #y << ": " << y << endl;
#define cout3(x, y, z)   cout << #x << ": " << x << ", " << #y << ": " << y << ", " << #z << ": " << z << endl;;
#define ncout1(n, x)     REP(i, 0, n) {cout << #x << "[" << i << "]: "<< x[i] << endl;}

#define coutp(p)         cout << #p << ":" <<  " (" << p.first << ", " << p.second << ")" << endl;

// sort
#define sort_r(x, y)        sort(x, y, greater<lli>()); // 降順(5,4,3,,,)

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))


#define PI 3.141592653589793
#define r2d(x) x*180.0 / M_PI

typedef long long int lli;
typedef pair<lli, lli> P;
typedef tuple<lli, lli, lli> tup;
typedef vector<lli> vlli;

int main() {
    long double a,b,x;
    cin3(a,b,x);
    long double taiseki = a*a*b;
    long double height = x/(a*a);
    if (x > a*a*b/2.0){
        // 台形パターン
        long double len = (taiseki - x)*2 / (a*a);
        long double len2 = sqrtl(len * len + a * a);
        //cout2(a,len2);
        cout <<setprecision(10) << r2d(acos(a/len2)) << endl;
        return 0;
    }
    else {
        long double len = 2*x / (b*a);
        long double len2 = sqrtl(len*len+b*b);
        cout <<setprecision(10) << r2d(acos(len/len2)) << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <cstdlib>
#include <math.h>
#include <algorithm>

typedef long long ll;
using namespace std;

vector<int> Prime;
vector<int> Like ;
int Data[100001];

bool is_prime( int n)
{
	return binary_search(Prime.begin(),Prime.end(),n);
}

void calc_data()
{
	int likeptr = 0;
	int val = 0 ;
	for( int i = 1; i <= 100000; i++ )
	{
		if( likeptr < Like.size() && i == Like.at(likeptr)){
			likeptr++ ;
			val++ ;
		}
		Data[i] = val ;
	}
}

void calc_like()
{
	for( int p = 0; p < Prime.size(); p++ ){
		int n = (Prime.at(p)+1) / 2;
		if(is_prime(n)){
			Like.push_back(Prime.at(p));
		}
	}
}

void calc_prime(int N)
{
	Prime.push_back(2);

	for( int i=3 ; i <= N ; i+=2){
		int x = (int)sqrt(i) + 1;
		bool prime =  true;
		for( int j = 0 ; j < Prime.size() && Prime.at(j) <= x; j++){
			if(i % Prime.at(j) == 0){
				prime = false ;
				break ;
			}
		}
		if(prime)
		{
			Prime.push_back( i ) ;
		}
	}
}

int main()
{
	calc_prime(100000);
	calc_like();
	calc_data();

	vector<int> ans;

	int Q ;	
	cin >> Q ;

	for( int q = 0 ; q < Q; q++ ){
		int l, r ;
		cin >> l >> r ;
		ans.push_back( Data[r]-Data[l-1]);
	}
	for( int a = 0; a < Q; a++ ){
		cout << ans[a] << endl;
	}
}


Measured memory_bytes: 1656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define F(i,a,b) for(int i=int(a);i<=int(b);i++)
#define endl "\n"
#define ios std::ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define out(x) cout<<x<<endl,exit(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define I first
#define S second

ll dp[105][100005],wht[105],val[105];

int main(){
	ios;
	ll n,w;
	cin>>n>>w;

	F(i,1,n){
		cin>>wht[i]>>val[i];
	}

	F(i,1,n){
		F(j,1,w){
			if(j-wht[i]>=0){
				dp[i][j]=max(dp[i-1][j-wht[i]]+val[i],dp[i-1][j]);
			}
			else dp[i][j]=dp[i-1][j];
		}
	}

	cout<<dp[n][w];
}

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

int main(){ 
 int N; cin >> N;
  vector<ll> A(N); ll  S = 0;
  for(int i = 0; i < N; i++){ cin >> A[i];}
  
  vector<ll> sum(N); // sum[i] == A[0]+ .. +A[i];
  
  sum[0] = A[0]; 
  for(int i = 1; i < N; i++){ sum[i] += sum[i-1]+A[i];}
  
  ll ans = 1LL << 60;
  
  for(int i = 0; i < N-1; i++){ // A[0]+..+A[i]とA[i+1]...A[N-1]に分ける
    ans = min(ans, abs(sum[i]-(sum[N-1]-sum[i])));
  }
  
  cout << ans << endl;
  
  return 0;
}
    

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

int main() {
  long q,h,s,d,n,ans=0;
  cin >> q >> h >> s >> d >> n;
  h=min(h,q*2);
  s=min(s,h*2);
  d=min(d,s*2);
  cout << d*(n/2)+s*(n%2) << endl;
}

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

string s, t, temp, fin;

int main() {
	cin >> s >> t;
	for (int i = t.size() - 1; i >= 0; i--){
		temp += s[i];
		fin = temp;
		reverse(fin.begin(), fin.end());
		for (int j = 0; j < i; j++)
			fin += s[j];
		if(fin == t)
			return cout << "Yes" << endl, 0;
	}
	cout << "No" << endl;
	return 0;
}

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

long long n, k, c, x, y, ans, M=1e9+7, a[2005];
int main() {
	int i, j;
	cin >> n >> k;
	for(i=0; i<n; i++) cin >> a[i];
	x = (k * (k-1) / 2) % M;
	y = (k * (k+1) / 2) % M;
	for(i=0; i<n; i++) {
		for(j=0, c=0; j<i; j++) {
			if(a[j] < a[i]) c++;
		}
		ans = (ans + c * x) % M;
		for(j=i+1, c=0; j<n; j++) {
			if(a[j] < a[i]) c++;
		}
		ans = (ans + c * y) % M;
	}
	cout << ans;
	return 0;
}

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

typedef long long ll;
const int pw10[10] = {1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};

inline bool query(ll x) {static char op[4]; return cout << '?' << ' ' << x << endl, cin >> op, *op == 89;}

inline int pow_of_ten() {
	for (int i = 0; i < 10; ++i) if (query(2 * pw10[i])) return pw10[i];
	return abort(), -1;
}

inline int answer(int x) {return cout << '!' << ' ' << x << endl, 0;}

int main() {
	int i, L, R, M;
	std::ios::sync_with_stdio(false), cin.tie(NULL);
	if (query(1000000000)) return answer(pow_of_ten());
	for (i = 1; i < 10 && query(pw10[i]); ++i);
	for (L = pw10[--i] + 1, R = pw10[i + 1] - 1; L < R; query((M = (L + R) / 2) * 10ll) ? R = M : L = M + 1);
	return answer(L);
}

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

using namespace std;

int main()
{
    long long h,w;
    long long ans;
    cin >>h>>w;
    if(h==1||w==1){
        ans=1;
    }
    else{
        ans=(h*w+1)/2;
    }
    cout << ans << endl;
    return 0;
}


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

int a[50], b[50], c[50], d[50];
vector<int> A(10);

int sum_di(vector<int> A, int q){
	int sum = 0;
	for(int i=0; i<q; i++){
		if(A[b[i]-1] - A[a[i]-1] == c[i]){
			sum += d[i];
		}
	}

	return sum;
}

int sum_sousa(int i, vector<int> A, int n, int q){
	if(i >= n || (i > 0 && A[i]-1 < A[i-1]) || A[i]-1 < 1){
		return 0;
	}

	vector<int> B = A;
	B[i]--;
	int sum = sum_di(B, q);
	int tmp = sum_sousa(i+1, B, n, q);
	if(tmp > sum){
		sum = tmp;
	}
	tmp = sum_sousa(i, B, n, q);
	if(tmp > sum){
		sum = tmp;
	}

	return sum;
}

int sum_max(vector<int> A, int n, int q){
	int max = sum_di(A, q);

	int tmp = sum_sousa(0, A, n, q);
	if(tmp > max){
		max = tmp;
	}

	return max;
}

int main(){
	int n, m, q;

	cin >> n >> m >> q;

	for(int i=0; i<q; i++){
		cin >> a[i] >> b[i] >> c[i] >> d[i];
	}

	for(int i=0; i<n; i++){
		A[i] = m;
	}
	int max = sum_max(A, n, q);

	cout << max << endl;
	return 0;
}


Measured memory_bytes: 3652
from collections import deque
n, m = map(int, input().split())
edges = [[]*n for _ in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)
#print(edges)
q = deque()
q.append(0)
ans = [-1]*n
while q:
    x = q.popleft()
    for child in edges[x]:
        if ans[child] == -1:
            ans[child] = x+1
            q.append(child)
        #print("child=", child)
        #print("ans=", ans)
print("Yes")
for i in range(1, n):
    print(ans[i])

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

#define X first
#define Y second


#define rep(X,Y) for(int (X)=0;(X) < (Y); ++(X))
#define rrep(X,Y) for(int (X)=(Y-1); X >= 0; ++(X))

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


using namespace std;

typedef pair<int,int> pii;

int check(pii a,pii b,pii c){
  if(a.Y!= b.Y || b.Y!= c.Y) return 0;
  if(a.X+1==b.X && a.X+2 == c.X)return 1;
  if(a.X==b.X && a.X == c.X)return 1;
  return 0;
}

int main(){
  int T;
  cin>>T;
  while(T--){
    vector<pii> c(9);
    char ch;
    rep(i,9) cin>>c[i].X;
    rep(i,9){
      cin>>ch;
      c[i].Y=ch-'A';
    }
    sort(all(c));
    int re=0;
    do{
      int f=1;
      rep(i,3)
	if(!check(c[3*i],c[i*3+1],c[i*3+2])) f=0;
      if(f){
	re=1; break;
      }
    }while(next_permutation(all(c)));
    cout<<re<<endl;
  }
  return 0;
}

Measured memory_bytes: 1192
import time
st=time.time()
d=int(input())
c=[0]+[int(j)for j in input().split()]
s=[[0]+[int(j)for j in input().split()]for i in range(d)]
s2=[sorted([[j,idx]for idx,j in enumerate(s[i])],reverse=True)for i in range(d)]
t=[i[0][1]for i in s2]
ans=0
p=1
q=t[0]-1
se=set()
while time.time()-st<1.8:
    if len(se)==26:
        p+=1
        if p>d:break
        se=set()
        q=t[p-1]
    se.add(q)
    l=[0]*27
    tmp=0
    pre=t[p-1]
    t[p-1]=q
    for i,j in enumerate(t,1):
        tmp+=s[i-1][j]
        l[j]=i
        for k in range(1,27):
            tmp-=(i-l[k])*c[k]
    if ans<tmp:
        ans=tmp
    else:
        t[p-1]=pre
    nextq=list(set(range(1,27))-se)
    if nextq!=[]:
        q=nextq[0]

for i in t:
    print(i)



Measured memory_bytes: 87120
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;int L;
    cin >> N >> L;
    vector<string> S(N);
    rep(i,N)cin >> S[i];
    sort(All(S));
    string res = "";
    rep(i,N){
        res +=S[i];
    }
    cout << res << endl;
    return 0;
}

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

int main(){
    int n,x=0;
    cin>>n;
    int a=n;
    while(n>0){
        x+=(n%10);
        n=n/10;
    }
    if(a%x==0){
        cout<<"Yes\n";
    }
    else{
        cout<<"No\n";
    }
    return 0;
}

Measured memory_bytes: 256
INFINITY = 10 ** 10
WHITE = 0
GRAY = 1
BLACK = 2


n = int(input())
M = [[INFINITY] * n for _ in range(n)]

for i in range(n):
    for j, weight in enumerate(map(int, input().split())):
        if weight == -1:
            weight = INFINITY

        M[i][j] = weight


def prim():
    color = [WHITE] * n
    d = [INFINITY] * n
    p = [None] * n

    d[0] = 0
    p[0] = -1

    while True:
        cost_min = INFINITY
        for i in range(n):
            if color[i] != BLACK and d[i] < cost_min:
                cost_min = d[i]
                top_now = i

        if cost_min == INFINITY:
            break
    
        color[top_now] = BLACK

        for v in range(n):
            if color[v] == BLACK or M[top_now][v] == INFINITY:
                continue

            if M[top_now][v] < d[v]:
                d[v] = M[top_now][v]
                p[v] = top_now
                color[v] = GRAY

    return sum(d)

cost_min = prim()
print(cost_min)


Measured memory_bytes: 5760
# #!/usr/bin/env python3
# # -*- coding: utf-8 -*-


def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    result = sum(B)

    for i in range(N - 1):
        if A[i] + 1 == A[i + 1]:
            result += C[A[i] - 1]
    print(result)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int m,h;
          
        while(true){
            String c = sc.next();
            if(c.equals("-"))
                break;
              
            m = sc.nextInt();
            for(int i=0;i<m;i++){
                h = sc.nextInt();
                String head=c.substring(0,h);
                String tail=c.substring(h);
                c=tail + head;
            }
            System.out.println(c);
        }
    }
}




Measured memory_bytes: 26124
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
const long double PI=(acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int main(){
  int s;
  cin>>s;
  vector<int> vec;
  vec.emplace_back(s);
  for(int i=1;i<1000000;i++){
    if(vec[i-1]%2==0){
      vec.emplace_back(vec[i-1]/2);
    }else{
      vec.emplace_back(vec[i-1]*3+1);
    }
  }
  for(int j=0;j<vec.size();j++){
    for(int i=j+1;i<vec.size();i++){
      if(vec[j]==vec[i]){
        cout<<i+1<<endl;
        return 0;
      }
    }
  }
}

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

int main()
{
    string s;
    cin >> s;
    vector<int> v;
    for (auto c : s)
    {
        v.push_back(c - '0');
    }
    long long sum = 0;
    for (uint i = 0; i < 1 << (v.size() - 1); i++)
    {
        long long s = v[0];
        for (uint j = 0; j < (v.size() - 1); j++)
        {
            if ((i >> j & 1) == 0)
            {
                s = s * 10 + v[j + 1];
            }
            else
            {
                sum += s;
                s = v[j + 1];
            }
        }

        sum += s;
    }
    cout << sum << endl;
}

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

#define MAXINF 1000000005
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define repc(it, x) for(auto it = (x).begin(); it != (x).end(); ++it)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rrepc(it, x) for(auto it = (x).rbegin(); it != (x).rend(); ++it)
#define all(x) (x).begin(), (x).end()
#define P pair<int, int>

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    map<ll, ll> mp;
    vector<ll> a(n);
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll ans = 0;
    repc(it, mp) {
        ans += mp[it->first]*(mp[it->first]-1)/2;
    }
    for(ll k = 0; k < n; k++) {
        ll old = (ll)mp[a[k]]*(mp[a[k]]-1)/2;
        ll update = (ll)(mp[a[k]]-1)*(mp[a[k]]-2)/2;
        cout << ans - old + update << endl;
    }
    return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric> // accumulate(v.begin(), v.end(), 0)

using namespace std;
#define ll long long

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> result(M, 0);
  for(int i=0; i<N; i++) {
    int K;
    cin >> K;
    for(int j=0; j<K; j++) {
      int A;
      cin >> A;
      result[A-1]++;
    }
  }
  int ans = 0;
  for(int i=0; i<M; i++)
    if(result[i] == N)
      ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int n;
    cin >> n;
    int num = n;
    set<int> st;
    for(int i=1; i<1000000; i++){
        st.insert(num);
        if(num%2==0){
            num/=2;
        }else{
            num = (num*3) +1;
        }
        if(st.count(num) > 0){
            cout << i+1 <<endl;
            break;
        }
    }
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,k,n) for(int i=k;i<n;i++)
#define rep2(i,k,n) for(int i=k;i<=n;i++)
typedef long long ll;
using namespace std;
int main()
{
   int N;
   cin >> N;
   vector<int>A(N);
   rep(i,0,N){
      cin >> A[i];
   }
   sort(A.begin(),A.end());
   cout << A[N-1]-A[0] << endl;
}

Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy


if __name__ == "__main__":
    s = input()
    ans = ""
    for i in range(3):
        ans += s[i]
    print(ans)

Measured memory_bytes: 9480
const input = require('fs').readFileSync('/dev/stdin', 'utf8');
const lines = input.trim().split('\n');

while (line = lines.shift()) {
    const numbers = line.split(' ').map(Number);
    let a = numbers[0], b = numbers[1];
    if(a === 0 && b === 0)
        break;
    let output = a <= b ? `${a} ${b}` : `${b} ${a}`;
    console.log(output);
}


Measured memory_bytes: 18860
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

VVI tree;
VI c;
vector<bool> visited;


void dfs(int a){
    visited[a] = true;
    for(auto q : tree[a]){
        if(visited[q]) continue;
        c[q] += c[a];
        dfs(q);
    }

}


int main() {
    int N,Q;
    cin >>N >>Q;
    tree.resize(N); c.resize(N); visited.resize(N);
    fill_n(c.begin(), N, 0);
    fill_n(visited.begin(), N , false);
    REP(i,N-1){
        int a,b;
        cin >> a >> b;
        a--; b--;
        tree[a].PB(b);
        tree[b].PB(a);
    }
    REP(i,Q){
        int p,x;
        cin >> p >> x;
        c[p-1] += x;
    }

    dfs(0);

    REP(i,N-1){
        cout << c[i] << " ";
    }
    cout << c[N-1] << "\n";




}

Measured memory_bytes: 23552
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;

class Point{
public:
  double x,y;
  Point(double x=0,double y=0):x(x),y(y){}

  Point operator+(Point p){ return Point(x+p.x,y+p.y);}
  Point operator-(Point p){ return Point(x-p.x,y-p.y);}
  Point operator*(double k){ return Point(x*k,y*k);}
  Point operator/(double k){ return Point(x/k,y/k);}
  bool operator==(Point p)const{ return fabs(x-p.x)<eps && fabs(y-p.y)<eps; }
  bool operator<(Point p)const{ 
    return equals(x,p.x) ? y-p.y<-eps : x-p.x<-eps; }
  double abs(){ return sqrt(norm());}
  double norm(){ return (x*x+y*y);}
};
typedef Point Vector;
typedef vector<Point> Polygon;

class Segment{
public:
  Point p1,p2;
  Segment(Point p1=Point(),Point p2=Point()):p1(p1),p2(p2){}
};
typedef Segment Line;

double norm(Vector a){ return (a.x*a.x+a.y*a.y);}
double abs(Vector a){ return sqrt(norm(a));}
double dot(Vector a,Vector b){ return (a.x*b.x+a.y*b.y);}
double cross(Vector a,Vector b){ return (a.x*b.y-a.y*b.x);}

bool isParallel(Vector a,Vector b){
  return equals(cross(a,b),0.0);
}

bool isParallel(Segment s,Segment t){
  return equals(cross(s.p1-s.p2,t.p1-t.p2),0.0);
}

bool intersect(Line L,Segment s){
  return cross(L.p2-L.p1,s.p1-L.p1)*cross(L.p2-L.p1,s.p2-L.p1)<eps;
}

Point getCrossPointLL(Line a,Line b){
  double A=cross(a.p2-a.p1,b.p2-b.p1);
  double B=cross(a.p2-a.p1,a.p2-b.p1);
  if(abs(A)<eps)return b.p1;
  return b.p1+(b.p2-b.p1)*(B/A);
}

int contains(Polygon g,Point p){
  int n=g.size();
  bool x=false;
  for(int i=0;i<n;i++){
    Vector a=g[i]-p,b=g[(i+1)%n]-p;
    if(abs(cross(a,b))<eps && dot(a,b)<eps)return 1;
    if(a.y>b.y)swap(a,b);
    if(a.y<eps && eps<b.y && cross(a,b)>eps)x=!x;
  }
  if(x)return 2;
  return 0;
}

int n;
Polygon p;

double cal(Line L){
  vector<Point> vp;
  FOR(i,0,n){
    Segment s(p[i],p[(i+1)%n]);
    if(isParallel(L,s))continue;
    if(!intersect(L,s))continue;
    vp.pb(getCrossPointLL(L,s));
  }
  sort(all(vp));
  vp.erase(unique(all(vp)),vp.end());
  double sum=0,res=0;
  FOR(i,0,vp.size()-1){
    Point a=vp[i],b=vp[i+1];
    if(a==b)continue;
    Point m=a+(b-a)/2.0;
    if(contains(p,m)==0)sum=0;
    else { sum+=abs(b-a); res=max(res,sum); }
  }
  return res;
}

double solve(){
  double res=0;
  FOR(i,0,n){
    FOR(j,i+1,n)res=max(res,cal(Line(p[i],p[j])));
  }
  return res;
}

int main()
{
  int c=1;
  while(cin>>n && n){
    p.clear();
    FOR(i,0,n){
      double x,y;
      cin>>x>>y;
      p.pb(Point(x,y));
    }
    cout<<"Case "<<c<<": "; pd(solve());
    c++;
  }
  return 0;
}

Measured memory_bytes: 3124
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; i++) {
            a[i] = sc.nextInt();
        }
        int count = 0;
        int[] aa = new int[n];
        for (int i = n - 1; 0 <= i; i--) {
            int s = 0;
            for (int j = 2 * i + 1; j < n; j += i + 1) {
                s += aa[j];
            }
            s %= 2;
            if (a[i] + s == 1) {
                count++;
                aa[i] = 1;
            }
        }
        System.out.println(count);
        StringBuilder builder = new StringBuilder();
        if (0 < count) {
            for (int i = 0; i < n; i++) {
                if (aa[i] == 1) {
                    builder.append(i + 1).append(' ');
                }
            }
            System.out.println(builder.substring(0, builder.length() - 1));
        }
    }
}


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

int main() {
	ll n,ans=1,a[1010];
	cin>>n;
	for(int i=0;i<1010;i++){
		a[i]=0;
	}
	for(int i=1;i<=n;i++){
		int k=i;
		for(int j=2;j<=i;j++){
			if(k%j==0){
				while(k%j==0){
					a[j-1]++;
					k=k/j;
				}
			}
		}
	}
	for(int i=0;i<1010;i++){
		ans*=(a[i]+1);
		ans%=1000000007;
	}
	cout <<ans;
}

Measured memory_bytes: 256
#include <cstdio>	// require printf
#include <map>
#include <algorithm>	// require sort next_permutation count etc.

using namespace std;

int main(void)
{
	char str[305];

	scanf ("%s", str );
	map <char, int> C;

	for (int i = 0; str[i]; ++i ){
		C[str[i]]++;
	} // end for

	printf ("%d\n", min (min (C['K'], C['U'] ), min(C['P'], C['C'] ) ) );

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

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

        if(i==3||i==5||i==7){
            printf("YES");
        }
        else
            printf("NO");





    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <random>
#include <iomanip>
#include <limits>

using namespace std;

typedef long long ll;

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 998244353;
// memset(a,0,sizeof(a)); →全部０にする

vector<int> G[100005];
std::vector<P> tree[100010];

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

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)

ll i,j,k,l,ii,jj;
ll n,m,a,b,c,d,ans,num,ddx,ddy,sum;
char s[100005];
bool flag;

int main(){
    cin>>n;
    for(i=2;i<n;i++){
        num=1;
        a=0;
        for(j=0;j<=1000;j++){
            num*=i;
            a++;
            if(num<=n && a>=2){
                ans=max(ans,num);
            }else{
                if(num>n){
                    break;
                }
            }
        }
    }
    p(max(ans,1ll));
    return 0;
    
    
}
/*
 cout<< fixed << setprecision(16) <<(double)cou[i]*1.00000000/2000000<<endl;
 */


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define INF 1<<29
using namespace std;
main(){
  int n;
  while(cin>>n){
    int a[n];
    r(i,n)cin>>a[i];
    int sum=0,t=0;
    sort(a,a+n);
    r(i,n){
      t+=a[i];
      sum+=t;
    }
    cout<<sum<<endl;
  }
}

Measured memory_bytes: 3008
#include<stdio.h>

int a[100000];
int b[100000];

int main()
{
	int N,M,num,sum;
	int x,y;
	scanf("%d",&N);
	scanf("%d",&M);
	for(num=0;num<N;num++){
		scanf("%d",&a[num]);
		b[num]=0;
	}
	for(num=0;num<M;num++){
		scanf("%d",&x);
		scanf("%d",&y);
		if(a[x-1]==a[y-1]){
			b[x-1]=-1;
			b[y-1]=-1;
		}else if(a[x-1]>a[y-1]){
			b[y-1]=-1;
		}else{
			b[x-1]=-1;
		}
	}
	sum=0;
	for(num=0;num<N;num++){
		if(b[num]==0){
			sum++;
		}
	}
	printf("%d",sum);
	return 0;
}

Measured memory_bytes: 2500
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
#define ll                  long long int
#define ull                 unsigned long long int
#define ld                  long double
#define fi                  first
#define se                  second
#define pb                  push_back
#define pbb                 pop_back
#define mp                  make_pair
#define pii     	        pair<int,int>
#define all(x)              x.begin(), x.end()
#define uniq(x)             x.erase(unique(x.begin(),x.end()),x.end())
#define mem(array, value)   memset(array, value, sizeof(array))
#define lcm(a,b)            (abs(a)/gcd(a,b))*abs(b)
#define PI      	        2*acos(0.0)
#define INF     	        1e9
#define EPS     	        1e-8
#define line                cout << "\n==========\n"
#define fastRead 	        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
//using namespace __gnu_pbds;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> orderedSet; 

//int dx[] = {1, -1, 0, 0},                  dy[] = {0, 0, 1, -1};                  // 4 Direction
//int dx[] = {1, -1, 0, 0, 1, 1, -1, -1},    dy[] = {0, 0, 1, -1, 1, -1, 1, -1};    // 8 Direction
//int dx[] = {1, -1, 1, -1, 2, 2, -2, -2},   dy[] = {2, 2, -2, -2, 1, -1, 1, -1};   // Knight Direction

inline ll gcd(ll a, ll b){
    a = abs(a);
    b = abs(b);
    while (b){
        a = a % b;
        swap (a, b);
    }
    return a;
}
inline ll power(ll a, ll p){
    ll res = 1, x = a;
    while (p){
        if (p & 1){
            res = (res * x);
        }
        x = (x * x);
        p >>= 1;
    }
    return res;
}
inline ll bigmod(ll a, ll p, ll m){
    ll res = 1 % m, x = a % m;
    while (p){
        if (p & 1){
            res = (res * x) % m;
        }
        x = (x * x) % m;
        p >>= 1;
    }
    return res;
}

int main ()
{
    #ifdef Lollipop
    //freopen ("input.txt", "r", stdin);
    //freopen ("output.txt", "w", stdout);
    #endif
    double a, b;
    cin >> a >> b;
    printf ("%f\n", a/b);
    return 0;
}



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

int main(){
  int a, b;
  cin >> a >> b;
 
  int answer;
  if(a>0 && a<10 && b>0 && b<10){
    answer = a*b;
  }
  else{
    answer = -1;
  }
  cout << answer << endl;
  return 0;
}

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

int main(int argc, char const *argv[]) {
  int n, m, c, flag = 0;
  cin >> n >> m >> c;
  vector <int> b(m);
  vector <vector <int>> a(n, vector <int> (m));
  for(int i = 0;i < m;i++) {
    cin >> b.at(i);
  }
  for(int i = 0;i < n;i++) {
    int sum = 0;
    for(int j = 0;j < m;j++) {
      cin >> a.at(i).at(j);
      sum += a.at(i).at(j) * b.at(j);
    }
    if(sum + c > 0) {
      flag++;
    }
  }
  cout << flag << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << endl;
    }else if(b == c){
        cout << a << endl;
    }else{
        cout << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
# 13-Structured_Program_II-Spreadsheet.py

# ??¨?¨????
# ??¨?¨??????????????°???????????????°???????????????????????????
# ??¨????????°r??¨?????°c???r ?? c ???????´????????????¨?????????????????§???
# ????????¨??????????¨?????????\????????°????????¨???????????????????????°?????????????????????????????????

# Input
# ???????????????r??¨c????????????????????§?????????????????????
# ?¶????r??????????????????c????????´??°????????????????????§?????????????????????

# Output
# (r+1) ?? (c+1) ?????°????????¨???????????????????????????
# ???????????£???????????´??°????????????????????§????????£??????????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??????????????????????¨?????????????????????????????????¨??¨??????????¨????????????\??????????????????

# Constraints
# 1 ??? r, c ??? 100
# 0 ??? ????´? ??? 100
# Sample Input
# 4 5
# 1 1 3 4 5
# 2 2 2 4 5
# 3 3 0 1 1
# 2 3 4 4 6
# Sample Output
# 1 1 3 4 5 14
# 2 2 2 4 5 15
# 3 3 0 1 1 8
# 2 3 4 4 6 19
# 8 9 9 13 17 56

# ??? Aizu??§numpy ??????????????£??????
#---------------------------------------------------------------
# import numpy as np

# r,c = map( int,input().split() )

# data = np.zeros((r,c))

# for i in range(r):
# 	data[i] = np.array( input().split() )

# data=data.astype("int")
# print("data",data)

# for i in range( r ):
# 	for j in range(c):
# 		print("{0} ".format(data[i][j]), end="")
# 	print( np.sum(data[i]) )

# for j in range(c):
# 	print("{0} ".format( np.sum(data, axis=0)[j] ), end="" )

# print( np.sum(data) )
#---------------------------------------------------------------


r,c = map( int,input().split() )

data = []
csum = [0]*c

for i in range(r):
	data.append(  list(map( int,input().split() ))  )

for i in range( r ):
	for j in range(c):
		print("{0} ".format(data[i][j]), end="")
		csum[j] +=data[i][j]
	print( sum(data[i]) )

for j in range(c):
	print("{0} ".format( csum[j] ), end="" )

print( sum(csum) )

Measured memory_bytes: 8180
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            // 解答はココに書く
            var a = cin.ReadInt;
            var b = cin.ReadInt;
            WriteLine(a * b % 2 == 0 ? "Even" : "Odd");
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13268
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	char a[1000],b[1000];
	int flag=0;
	cin>>a>>b;
	int la=strlen(a),lb=strlen(b);
	if(la>lb)flag=1;
	else if(la<lb)flag=2;
	else {
		if(strcmp(a,b)==0)printf("EQUAL\n");
		if(strcmp(a,b)>0)flag=1;
		if(strcmp(a,b)<0)flag=2;
	}
	if(flag==1)printf("GREATER\n");
	else if(flag==2)printf("LESS\n");
}


Measured memory_bytes: 256