akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

const int SIZE = 10;

int Sort(int A[], int N, int name) {
	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;
	}
	return A[name];
}

int main(){
	int Height[10];
	int sort[3];

	for (int i = 0; i < SIZE; i++) {
		cin >> Height[i];
		if (Height[i] > 10000) {
			Height[i] = 0;
			i--;
		}
	}

	sort[0] = Sort(Height, SIZE, 9);
	sort[1] = Sort(Height, SIZE, 8);
	sort[2] = Sort(Height, SIZE, 7);
	
	cout <<  sort[0] << endl;
	cout <<  sort[1] << endl;
	cout <<  sort[2] << endl;

	return 0;
}

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

using namespace std;

#define rep(i, x)   for (__typeof(x) i = 0; i < x; i++)
#define mp             make_pair
#define pb             push_back
#define fi             first
#define se             second
#define sz(x)          (int)((x).size())
#define all(x)         (x).begin(), (x).end()
#define sci(x)         int x;       scanf("%d", &x);
#define scii(x, y)     int x, y;    scanf("%d %d", &x, &y);
#define sciii(x, y, z) int x, y, z; scanf("%d %d %d", &x, &y, &z);
#define TC(x)          sci(x); while(x --)
#define eprintf(...)   fprintf(stderr, __VA_ARGS__)
#define debug(x)       { cerr << #x << " = " << x << endl; }
#define repi(i, x)  for (__typeof(x) i = x-1; i >= 0; i --)
#define fore(itr, x)   for (__typeof(x.begin()) itr = x.begin(); itr != x.end(); itr ++)
#define forei(itr, x)  for (__typeof(x.end()) itr = x.end() - 1; itr != x.begin() - 1; itr --)
typedef long long      ll;
typedef pair<int, int> ii;
typedef pair<ii, int>  iii;
typedef vector<int>    vi;
typedef vector<ii>     vii;
typedef vector<iii>    viii;
typedef vector<vector<int> > vvi;
const   int            infi = numeric_limits<int>::max();
const   double         eps = 0;
const   int            ms  = 0;

int main()
{
    ios::sync_with_stdio(false);//endl->"\n"
    cin.tie(0);

    string str;
    cin >> str;
    int ans=0;
    rep(i, 4){
        if(str[i] == '2')ans++;
    }
    cout << ans << "\n";
    return 0;
}

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

def solve():
    N = int(input())
    max_cnt = 0
    for i in range(N, 0, -1):
        cnt = 0
        num = i
        while True:
            if num == 1:
                print(i)
                return
            if num%2 == 0:
                num //=  2
                cnt += 1
                continue
            if cnt > max_cnt:
                max_cnt = cnt
                ans = i
            break
    print(ans)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 3060
n, m, x, y = map(int, input().split())
x_l = list(map(int, input().split()))
y_l = list(map(int, input().split()))

ans = 'War'
for z in range(x + 1, y + 1):
  if x < z <= y:
    if all([i < z for i in x_l]) and all([i >= z for i in y_l]):
      ans = 'No War'
      break

print(ans)

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

class Main {
  public static void main(String[] args) throws Exception{
    try (Scanner sc = new Scanner(System.in)){
      int N = sc.nextInt();
      int c = 0;
      for (int i = 1; i <= N; i=i+2) {
        int count = 0;
        for (int j = 1; j <= N; j++) {
          if (i % j == 0) count++;
        }
        if (count == 8) c++;
      }
      System.out.println(c);
    }
  }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a,b;
  cin>>a>>b;
  ll x=0;
  ll y;
  for(ll i=1;x<=b;i++){
    ll c;
    cin>>c;
    x=x+c;
    y=i;
    if(y==a+1){
      break;
    }
  }
  cout<<y<<endl;
  return 0;
}


Measured memory_bytes: 3548
using System;

class Program
{
    static void Main(string[] args)
    {
        var line = Console.ReadLine();
        var line2 = Console.ReadLine();

        int ans = 0;

        for (int i = 0; i < line.Length; i++)
        {
            if (line[i] == line2[2-i])
            {
                ans++;
            }
        }

        if (ans == 3) Console.WriteLine("YES");
        else Console.WriteLine("NO");
        
    }
}


Measured memory_bytes: 13140
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto x = RD;
	auto y = RD;
	long ans;
	auto xy = sgn(x) * sgn(y);
	if (x <= y)
	{
		if (xy >= 0)
			ans = abs(abs(y) - abs(x));
		else
			ans = abs(abs(y) - abs(x)) + 1;
	}
	else
	{
		if (xy == 0)
			ans = abs(abs(y) - abs(x)) + 1;
		else if (xy > 0)
			ans = abs(abs(y) - abs(x)) + 2;
		else
			ans = abs(abs(y) - abs(x)) + 1;
	}
	writeln(ans);
	stdout.flush();
	debug readln();
}


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

int main(){
  int a,b,c;
  bool flag=false;
  
  cin >> a >> b;

  for(int c=1;c <= 3;c++){
    if( (a*b*c)%2 == 1){
      flag = true;
    }
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n,la,lb; cin>>n;
    string st; cin>>st;
    if(st.length()<=n)
        cout<<st<<endl;
    else{
        for(la=0;la<n;la++) cout<<st[la];
        cout<<"..."<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
function main()
myparse(x)=parse(Int,x)
N,T=myparse.(split(readline()))
times=myparse.(split(readline()))
res=0
for i in 1:N-1
  bf_time=times[i]
  af_time=times[i+1]
  time=af_time-bf_time
  res+=min(time,T)
end
res+=T
return res
end
ans=main()
println(ans)



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

int main() {
  string S;
  cin >> S;
  
  ll Wcount = 0;
  ll x = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'W') Wcount += 1;
    else x += Wcount;
  }
  
  cout << Wcount * (S.size()-Wcount) - x << endl;
}

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

int main()
{
	int n,j = 0,l = 0;
	cin >> n;
	int* a = new int[n];
	for(int i = 0;i < n;i++)
	{
		cin >> a[i];
		if(a[i] % 2 == 1)
		j++;
		if(a[i] % 4 == 0)
		l++;
	}
	if(l >j - 1 || (l-j+1 == 0 && (n - l - j) % 2 == 0))
	cout << "Yes" << endl;
    else
    cout << "No" <<endl;
    delete []a;
    return 0;
}


Measured memory_bytes: 640
open Printf open Scanf
open Array

let pow_float n k =
  let rec f a n = function
  | 0 -> a | 1 -> n*.a
  | k when k mod 2 = 0 -> f a (n*.n) (k/2) | k -> f (a*.n) (n*.n) (k/2)
  in f 1. n k

let ceildiv p q = (p+q-1) / q
let () = scanf " %d %d" @@ fun n k ->
  let sum = init n (fun v ->
    let v = v+1 in
    let w = (float k) /. (float v) in
    let w = int_of_float @@ ceil @@ log w /. log 2. in
    let f =
      if w>=1 then pow_float 0.5 w
      else 1.
    in
    f /. (float n)
  )
  |> fold_left (+.) 0. in
  printf "%.22f" @@ sum



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



ll n, k;
int a[maxn];


bool viz[maxn];
void dfs(int at, ll k) {
    if (k==0) out(at+1);
    if (!viz[at]) {
	viz[at]=true;
	dfs(a[at], k-1);
	return;
    }

    // found cycle
    vector<int> cycle = { at };
    int x=a[at];
    while (x != at) {
	cycle.push_back(x);
	x = a[x];
    }

    // for (int i: cycle) cout<<i+1<<" ";
    // cout<<endl;
    
    int len = cycle.size();
    assert(len>0);
    k %= len;
    out(cycle[k] + 1);
}

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

    cin>>n>>k;
    for (int i=0; i<n; i++) {
	cin>>a[i];
	--a[i];
    }

    dfs(0,k);
    assert(false);
    
    return 0;
}


Measured memory_bytes: 19592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#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__)
#define all(x) (x).begin(),(x).end()





int main() {
    ll n, d;
    cin >> n >> d;
    ll e = d * d;
    int ans = 0;
    rep (i, n) {
        ll x, y;
        cin >> x >> y;
        if (x * x + y * y <= e) {
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <stack>
#include <functional>
#include <queue>
#include <cmath>
#include <set>
#include <map>

#define rep(i,j,k) for(int i=j;i<k;i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vi vector<int>
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define MP make_pair
typedef long long ll;
typedef std::pair<int,int> pii;
int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

using namespace std;

int main() {
    string s;
    string v="qwertasdfgzxcvb";
    //vector<char> v;
    //rep(i,0,s.length()) v.pb(vv[i]);
    while(cin>>s){
        if(s=="#")return 0;
        int ans=0;
        bool left;
        rep(i,0,s.length()){
            if(i==0){
                if(find(all(v),s[i])==v.end())left=false;
                else left=true;
            }else {
            if(find(all(v),s[i])!=v.end()){
                if(!left){
                    ans++;
                    left=true;
                }
            }else {
                if(left){
                    ans++;
                    left=false;
                }
            }}
        }
        cout<<ans<<endl;
    }
    return 0;
}



Measured memory_bytes: 3136
// atcoder/aising2020/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

const int N = 2 * 1e5 + 5;

int memo[N];
int rec(int x)
{
  if (x == 0) return 0;
  int& ret = memo[x];
  if (ret != -1) return ret;
  return ret = rec(x % __builtin_popcount(x)) + 1;
}

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int n;
  str s;
  while (cin >> n >> s) {
    fill(memo, memo + N, -1);

    const int _1 = count(s.begin(), s.end(), '1');
    const int a = _1 + 1;
    const int b = _1 - 1;

    static int w0[N];
    static int w1[N];
    w0[0] = 1;
    w1[0] = 1;
    for (int i = 1; i < N; ++i) {
      if (a) w0[i] = (w0[i - 1] * 2) % a;
      if (b) w1[i] = (w1[i - 1] * 2) % b;
    }

    int sum0 = 0;
    int sum1 = 0;
    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == '1') {
        sum0 += w0[n - i - 1];
        sum1 += w1[n - i - 1];
        if (a) sum0 %= a;
        if (b) sum1 %= b;
      }
    }

    for (int i = 0; i < s.size(); ++i) {
      if (s[i] == '0') {
        int x = (sum0 + w0[n - i - 1]) % a;
        cout << rec(x)+1 << endl;
      }
      if (s[i] == '1') {
        if (b) {
          int x = (sum1 - w1[s.size() - i - 1] + b) % b;
          cout << rec(x)+1 << endl;
        } else {
          cout << 0 << endl;
        }
      }
    }
  }

  return 0;
}


Measured memory_bytes: 6064
/*
C. Vication
填表法 数轴模型 
*/
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
#define MAXN 100005
int hp[MAXN][3];
int dp[MAXN][3];
int n, ans;
int main(){
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
        scanf("%d%d%d", &hp[i][0], &hp[i][1], &hp[i][2]);
    for(int i = 1; i <= n; i++)
        for(int j = 0; j < 3; j++)
            for(int k = 0; k < 3; k++)
                if(j != k)
                    dp[i][j] = max(dp[i][j], dp[i-1][k]+hp[i][j]);
    ans = max(dp[n][0], max(dp[n][1], dp[n][2]));
    printf("%d\n", ans);
}

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

int main()
{
  string N;
  
  cin >> N;
  
  int total = 0;
  
  for (int i = 0; i < size(N); i++) 
  {
    total += int(N[i] - 0x30);
  }
  
  //cout << total << endl;
  
  if (total % 9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
    
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll X, A, B;
  cin >> X >> A >> B;
  if (A >= B) {
    COUT("delicious");
    return 0;
  }

  if (A + X >= B) {
    COUT("safe");
    return 0;
  }

  COUT("dangerous");

  return 0;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

using namespace std;
typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = (1LL<<60);
const double eps = (1e-9);

typedef pair<int, int> P;  // 最短距離と頂点番号

// 隣接表現の圧縮版
// @param [in] n: ノード数
// @param [in] cost: 重みの隣接表現
// @param [in] s: スタートするノード
// @param [out] d: s からの距離
void dijkstra(const int& n, const vector<vector<pair<int, int>>>& cost, const int& s, vector<int>& d) {
  priority_queue<P, vector<P>, greater<P>> que;  // P#first が小さい順に取り出せる
  d[s] = 0;
  que.push(P(0, s));

  while (!que.empty()) {
    P p = que.top(); que.pop();
    int v = p.second;
    if (d[v] < p.first) continue;
    for (int j = 0; j < cost[v].size(); j++) {  // v から移動できる全ての node について
      int t = cost[v][j].first;
      int c = cost[v][j].second;
      if (d[t] > d[v] + c) {
        d[t] = d[v] + c;
        que.push(P(d[t], t));
      }
    }
  }
}

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

  int n , x, y;
  cin >> n >> x >> y; x--; y--;

  vector<vector<pair<int, int>>> cost(n, vector<pair<int, int>>());
  for (int i = 1; i < n; i++) {
    cost[i-1].emplace_back(i, 1);
    cost[i].emplace_back(i-1, 1);
  }
  cost[x].emplace_back(y, 1);
  cost[y].emplace_back(x, 1);

  vector<ll> ans(n, 0);

  for (int i = 0; i < n; i++) {
    vector<int> d(n, INF);
    dijkstra(n, cost, i, d);
    for (int j = i + 1; j < n; j++) {
      ans[d[j]]++;
    }
  }

  for (int i = 1; i < n; i++) {
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int maxn = 1005;
int X, Y, Z, K;
LL A[maxn], B[maxn], C[maxn];
priority_queue<LL>Q;

int main(){
	cin>>X>>Y>>Z>>K;
	for(int i = 0; i < X; i ++)cin>>A[i];
	for(int i = 0; i < Y; i ++)cin>>B[i];
	for(int i = 0; i < Z; i ++)cin>>C[i];
	sort(A, A+X, greater<LL>());
	sort(B, B+Y, greater<LL>());
	sort(C, C+Y, greater<LL>());
	
	for(int x = 0; x < X; x ++)
		for(int y = 0; y < Y; y ++){
			if((x+1)*(y+1) - 1 >= K)break;
			for(int z = 0; z < Z; z++){
				if((x+1)*(y+1)*(z+1) - 1 >= K)break;
				LL tmp = A[x] + B[y] + C[z];
				Q.push(tmp);
			}
		}		
	
	for(int i = 0; i < K; i ++){
		cout << Q.top() << endl;
		Q.pop();
	}
	
	return 0;
} 

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

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

 int d,r;
 double f;

 d = a/b;
 r = a%b;
 f = (double)a/b;

 cout << d << " " << r << " " << fixed << setprecision(5) << f << endl;

 return 0;
}


Measured memory_bytes: 3284
import sys
sys.setrecursionlimit(10**8)

def sort(a):
	a.sort()

def rev(a):
	a.reverse()

def sd():
	return int(input())

def _sd():
	return map(int,input().split())

def sa():
	return list(map(int,input().split()))

def ss():
	return input()

def sf():
	return float(input())
 
def main():
	n,m=_sd()
	X=sa()
	Y=sa()
	sum_x=int(0)
	sum_y=int(0)
	mod=int((1e+9)+7)
	for i in range(1,n+1):
		sum_x+=(i+i-n-1)*X[i-1]
		sum_x%=mod
	for i in range(1,m+1):
		sum_y+=(i+i-m-1)*Y[i-1]
		sum_y%=mod
	print((sum_x*sum_y)%mod)
main()

Measured memory_bytes: 18752
#include <stdio.h>
int a[10][10]={0};
void drop(int x,int y){
	if(0<=x&&x<=9&&0<=y&&y<=9)
	a[x][y]++;
}
int main(void){
	int x,y,s,i,j,c=0,m=0;
	while(scanf("%d,%d,%d",&x,&y,&s)!=EOF){
		drop(x,y);
		drop(x-1,y);
		drop(x+1,y);
		drop(x,y-1);
		drop(x,y+1);
		if(s>=2){
			drop(x-1,y-1);
			drop(x-1,y+1);
			drop(x+1,y-1);
			drop(x+1,y+1);
		}
		if(s==3){
			drop(x-2,y);
			drop(x+2,y);
			drop(x,y-2);
			drop(x,y+2);
		}
	}
	for(i=0;i<10;i++){
		for(j=0;j<10;j++){
			if(!a[i][j])
				c++;
			if(m<a[i][j])
				m=a[i][j];
		}
	}
	printf("%d\n%d\n",c,m);
	return 0;
}

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

#include <bits/stdc++.h>
using namespace std;

int main(){
    int N,K;
    cin >>N>>K;
    int sub=K;
    int count = 1;
    while(sub>=0){
        if(N-sub<0){
            break;
        }
        sub *= K;
        count ++;
    }
    cout <<count<<endl;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	if (X == 0) {
		*di++ = '0';
		*di++ = '\n';
		return;
	}
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int to[200001], ne[200001];
int H[100001], PM[100001], Pm[100001];
bool OK = true;
pair<int, int> sagasu(int A, int pre) {
	bool OE[2] = {};
	if (PM[A]) OE[PM[A] & 1] = 1;
	else {
		PM[A] = 5e6;
		Pm[A] = -5e6;
	}
	for (int i = H[A]; i; i = ne[i]) {
		if (to[i] != pre) {
			auto p = sagasu(to[i], A);
			if (p.first < 1e6) OE[p.first & 1] = 1;
			PM[A] = min(PM[A], p.first);
			Pm[A] = max(Pm[A], p.second);
		}
	}
	if (OE[0] && OE[1]) OK = false;
	if (PM[A] < Pm[A]) OK = false;
	return mp(PM[A] + 1, Pm[A] - 1);
}
void sagasu2(int A, int M, int prev) {
	if (M + 1 <= PM[A]) Pm[A] = M;
	else Pm[A] = M - 2;
	for (int i = H[A]; i; i = ne[i]) {
		if (to[i] != prev) sagasu2(to[i], Pm[A] + 1, A);
	}
}

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


	int N = getint();
	for (int i = 1; i < 2 * (N - 1); i += 2) {
		int a = getint(), b = getint();
		to[i] = a;
		ne[i] = H[b];
		H[b] = i;
		to[i + 1] = b;
		ne[i + 1] = H[a];
		H[a] = i + 1;
	}
	int K = getint();
	int v, p;
	rep(i, K) {
		v = getint();
		p = getint() + 1;
		PM[v] = p;
		Pm[v] = p;
	}

	sagasu(1, 0);

	if (OK) {
		sagasu2(1, PM[1] - 1, 0);
		*di++ = 'Y';
		*di++ = 'e';
		*di++ = 's';
		*di++ = '\n';
		rep1(i, N) putint(Pm[i]);
		fwrite_unlocked(dn, di - dn, 1, stdout);
	}
	else printf("No");

	Would you please return 0;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;
 
const int MAX = 1000005;
 
LL a[MAX];
LL b[MAX];
 
LL s[MAX];
int main()
{
 //  freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(false); cin.tie(0);
 
    int n;
    cin>>n;
    FOR(i,0,n)
    {
    //	a[i]=n-i;
    //	b[i]=1000000000;
    	cin>>a[i]>>b[i];
    }
 
    LL ans = 0;
 
    RFOR(i,n,0)
    {
    	a[i] += ans;
    	ans += (b[i]-a[i]%b[i])%b[i];
    }
 
    cout<<ans;
	return 0;
}

Measured memory_bytes: 1792
input() = parse(Int, readline())
inputs() = map(x -> parse(Int, x), readline() |> split)
let
  ans = 0
  A, B, C, D = inputs()
  while true
    C -= B
    C <= 0 && (println("Yes"); break)
    A -= D
    A <= 0 && (println("No"); break)
  end
end


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



int main() {
  string N; cin >> N;
  ll sum =0;
  rep(i,N.size()){

    int num = N[i] -'0';
    sum += num;
  }
  if(sum%9 == 0) cout << "Yes" << endl;
  else cout << "No" << endl;


	return 0;
}



Measured memory_bytes: 3752
import java.io.IOException;
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		while (true) {
			int M = scanner.nextInt();
			int W = scanner.nextInt();
			if ((M | W) == 0)
				break;
			int[] bm = new int[M];
			for (int i = 0; i < M; i++)
				bm[i] = scanner.nextInt();
			int[] bw = new int[W];
			for (int i = 0; i < W; i++)
				bw[i] = scanner.nextInt();
			int[] dp = new int[1 << W];

			Arrays.fill(dp, -1);
			dp[0] = 0;
			for (int i = 0; i < M; i++) {
				for (int j = (1 << W) - 1; j >= 0; j--) {
					if (dp[j] == -1)
						continue;
					for (int k = 0; k < W; k++) {
						if (((j >> k) & 1) == 1)
							continue;
						int a = j | 1 << k;
						int b = (int) (Math.abs(bm[i] - bw[k]) * Math.pow(
								Math.abs(bm[i] - bw[k]) - 30, 2));
						dp[a] = Math.max(dp[a], dp[j] + b);
					}
				}
			}
			int max = 0;
			for (int i = 0; i < 1 << W; i++) {
				max = Math.max(max, dp[i]);
			}
			System.out.println(max);
		}
	}
}

Measured memory_bytes: 22380
#include <bits/stdc++.h>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 1000000007
#define INF (ll)1e19
#define N 2000006

using namespace std;

string s;

int main() {
    //freopen("txt.in", "r", stdin);
    //freopen("txt.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    for (int i = 0; i < s.length() - 8; i++)
        cout << s[i];
    cout << endl;

	return 0;
}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
Arr.forEach(function(v){
   var arr=v.split(" ").map(Number);
   var m=Math.max(arr[0],arr[1]);
   var n=Math.min(arr[0],arr[1]);
   while(n!=0){
      var N=n;
      n=m%n;
      m=N;
   }
   console.log(m);
});

Measured memory_bytes: 7640
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

S = list(s())
ans = 700
print(ans+100*S.count('o'))

Measured memory_bytes: 9808
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int A,B,C,K,ans=0;
  	cin >> A >> B >> C >> K;
  
  	while(K > 0){
      	if(A != 0){
          A--;
          ans++;
        }
      	else if(B != 0){
          B--;
        }
      	else {
          C--;
          ans--;
        }
    	K--;
    }
  	cout << ans;
 
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define f first
#define s second
#define fore(i,a,b) for(int i = (a), ThxMK = (b); i < ThxMK; ++i)
#define pb push_back
#define all(s) begin(s), end(s)
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define _ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(s) int(s.size())
#define ENDL '\n'
#define vv(type, name, h, ...) vector<vector<type>> name(h, vector<type>(__VA_ARGS__))
#define vvv(type, name, h, w, ...) vector<vector<vector<type>>> name(h, vector<vector<type>>(w, vector<type>(__VA_ARGS__)))
using namespace std;
typedef long double ld;
typedef long long lli;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<lli> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<ii> vii;

#define deb(x) cout << #x": " << (x) << endl;


// ---- コーディングはここから！ ('-')7
const lli MOD = 998244353;
void solve(){
	int n,k; cin>>n>>k;
	vii v(k);
	fore(i,0,k)cin>>v[i].f>>v[i].s;
	sort(all(v));
	vl d(n+1,0);
	lli ac = 1,aux=0;
	d[2]=MOD-1;
	fore(i,1,n+1){
		d[i]=(d[i]+ac)%MOD;
		fore(j,0,k){
			if(i+v[j].f<=n)d[i+v[j].f]=(d[i+v[j].f]+d[i]+MOD)%MOD;
			if(i+v[j].s+1<=n)d[i+v[j].s+1]=(d[i+v[j].s+1]-d[i]+MOD)%MOD;
		}
		ac = d[i];
	}
	cout<<d[n]<<ENDL;
}
int main(){_
	//int t; cin>>t; while(t--)
	solve();
}


Measured memory_bytes: 4776
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

/*  Macros from Endagorion */
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;


int main(){
        
    ios_base::sync_with_stdio(0);
    
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    int a,b;
    cin>>a>>b;
    int cnt_neg=0, cnt_pos=0;
    for(int i=a;i<=b;i++){
        if(i<0) cnt_neg++;
        else    cnt_pos++;
    }

    if(cnt_neg>0 && cnt_pos>0)  cout<<"Zero\n";
    else if(cnt_neg==0)         cout<<"Positive\n";
    else{
        if(cnt_neg%2==0)    cout<<"Positive\n";
        else                cout<<"Negative\n";
    }
    return 0;
}



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

const int maxn = 55;
int a [maxn];
int negative = 1e9, positive = -1e9, pos1, pos2, n;
bool flag1, flag2;
int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
        if(a[i] > 0) {
            flag1 = true;
            if(a[i] > positive ) {
                positive = a[i];
                pos1 = i;
            }
        } else if(a[i] < 0) {
            flag2 = true;
            if(a[i] < negative) {
                negative = a[i];
                pos2 = i;
            }
        }
    }
    if(!flag1 && !flag2) {
        printf("0");
        return 0;
    }

    printf("%d\n", 2 * (n - 1));
    if(flag1 && (!flag2 || positive > -negative)) {
        for(int i = 1; i <= n; i++) {
            if(i != pos1)
                printf("%d %d\n", pos1, i);
        }
        for(int i = 1; i < n; i++) {
            printf("%d %d\n", i, i + 1);
        }
    }

    else {
        for(int i = 1; i <= n; i++) {
            if(i != pos2)
                printf("%d %d\n", pos2, i);
        }
        for(int i = n; i >= 2; i--) {
            printf("%d %d\n", i, i - 1);
        }
    }
    return 0;
}


Measured memory_bytes: 256
// 降順ソート解法

#include <bits/stdc++.h>

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

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }
	mint operator-()const{ return mint(-x); }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint operator+(long long x,const mint& m){ return mint(x)+m; }
mint operator-(long long x,const mint& m){ return mint(x)-m; }
mint operator*(long long x,const mint& m){ return mint(x)*m; }
mint operator/(long long x,const mint& m){ return mint(x)/m; }

int main(){
	int n,x0; scanf("%d%d",&n,&x0);
	vector<int> a(n);
	rep(i,n) scanf("%d",&a[i]);

	sort(a.rbegin(),a.rend());

	vector dp(n+1,vector(1e5+1,mint(0)));
	dp[0][x0]=1;
	rep(i,n){
		rep(x,1e5+1){
			dp[i+1][x%a[i]]+=dp[i][x];
			dp[i+1][x]+=(n-i-1)*dp[i][x];
		}
	}

	mint ans=0;
	rep(x,1e5+1) ans+=dp[n][x]*x;
	cout<<ans<<'\n';

	return 0;
}


Measured memory_bytes: 82464
#!/usr/bin/env python3
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import collections
from decimal import Decimal # 10進数で考慮できる

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

d = collections.deque()
def LI(): return list(map(int, sys.stdin.readline().split()))
N = int(input())

p = LI()

ans = 1
tmp = p[0]
for i in range(1, N):
    if tmp >= p[i]:
        ans += 1
        tmp = p[i]


print(ans)


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

const int maxn = 2e5 + 10;
typedef long long int ll;
void solved(){
	string s;cin>>s;
	int len = s.size() - 1;
	if(s[len] == '2' || s[len] == '4' || s[len] == '5' || s[len] == '7' || s[len] == '9')
	cout<<"hon"<<endl;
	else if(s[len] == '0' || s[len] == '1' || s[len] == '6' || s[len] == '8')
	cout<<"pon"<<endl;
	else cout<<"bon"<<endl;
}
int main(){
	solved();
	return 0;
}

Measured memory_bytes: 3612
from sys import stdin

n = int(stdin.readline().strip())
li = list(map(int, stdin.readline().split()))

ans = 0
p = 0
cnt = 1
for i in range(n):
    if li[i]!=p:
        ans += cnt // 2
        p = li[i]
        cnt = 1
    else:
        cnt += 1
ans += cnt // 2

print(ans)

Measured memory_bytes: 3064
N, K = map(int, input().split())
k = K
twofac = 2
boarder = []
enough = 0
while(k > twofac):
    if k % twofac == 0:
        boarder.append(k // twofac)
    else:
        boarder.append(k // twofac + 1)
    twofac *= 2
boarder.append(1)
boarder.insert(0, K)
each = 1 / N
ans = 0
lenb = len(boarder)
for i in range(lenb-1, 0, -1):
    if boarder[i-1] <= N:
        ans += (boarder[i-1]-boarder[i])*each/(2**i)
    else:
        ans += (N-boarder[i]+1)*each/(2**i)
        enough = 1
        break
if enough == 0:
    ans += (N-K+1)*each
print(str(ans))


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    int n,m;
    cin>>n>>m;
    //long long x[n],y[n],z[n];
    long long cake[n][3];
    //vector<long long>sum(n);
    rep(i,n){
        rep(l,3){
            cin>>cake[i][l];
        }
    }
    int second[3];
    second[0]=1;
    rep2(i,2)second[i]=second[i-1]*2;
    long long ans=-INF;

    for(int bits=0;bits<(1<<3);bits++){
        vector<long long> sum(n,0);
        long long tmp=0;
        rep(i,n){
            rep(l,3){
            if(bits&second[l]){
            sum[i]+=cake[i][l];
            }
            else{
            sum[i]+=cake[i][l]*-1;
            }
            }
        }
        sort(sum.begin(),sum.end());
        reverse(sum.begin(),sum.end());
        rep(i,m)tmp+=sum[i];
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 256
//B - Beautiful Strings: 
//Assunto: 
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define loop(i, a, b) for(int i = a; i < b; i++)
#define loopBack(i, a, b) for(int i = a; i >= b; i--)
#define INF INT_MAX
#define LINF LLONG_MAX
#define DINF DBL_MAX
#define MAX 100050
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    string w;
    map<char, int> ocur;
    bool beauty = true;

    cin >> w;
    for(auto x : w) ocur[x]++;
    for(auto x : ocur) if(x.se % 2 != 0) beauty = false;
    if(beauty) cout << "Yes\n";
    else cout << "No\n";
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdlib>

int main(void)
{
    int i,N,L;
    int azi[300],pi=0,taberu=101;

    scanf("%d %d",&N,&L);

    for(i=0; i<N; i++){
        azi[i] = i+L;
        pi+=azi[i];
    }

    for(i=0; i<N; i++){
        if(abs(taberu) > abs(azi[i])){
            taberu = azi[i];
        }
    }

    printf("%d\n",pi-taberu);

    return 0;
}

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

int main(){
  int N,K,X,Y;
  cin >>N>>K>>X>>Y;
  
  long long ans;
  
  if(N>K) ans = K*X + (N-K)*Y;
  else ans = N*X;
  
  cout <<ans<< endl;
}

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

namespace test
{
 static class test
 {
  static void Main()
   {
    string day = Console.ReadLine();
    string[] days = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    var list = new List<string>();
    list.AddRange(days);
    Console.WriteLine(7- list.IndexOf(day)); 
   }
 }
}

Measured memory_bytes: 13152
import numpy as np
people_num = int(input())

otoshidama_box = []

for i in range(people_num):
    value, v_type = [_ for _ in input().split()]
    value = float(value)
    if str(v_type) == "JPY":
        ans = value
    elif str(v_type) == "BTC":
        ans = value * 380000.0
    
    otoshidama_box.append(float(ans))
otoshidama_box = np.array(otoshidama_box)
total = np.sum(otoshidama_box)
print(total)

Measured memory_bytes: 12444
import java.util.Scanner;

public class Main {
	private static Scanner sc;

	public static void main(String[] args) {
		sc = new Scanner(System.in);
		String n = sc.next();
		String[] nArray = n.split("");
		long sum = 0;
		for (String nChar : nArray) {
			sum += Integer.parseInt(nChar);
		}
		
		if (0 == (sum%9)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
  		
		
	}



}


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

#define DEBUG(x) cerr << #x << " = " << x << endl

typedef long long ll;

const int MAX_M = 100000;

bool prime[MAX_M + 1];

int main() {
  fill(prime, prime + MAX_M + 1, true);
  prime[0] = prime[1] = false;
  for(int i = 2; i * i <= MAX_M; ++i) {
    if(prime[i]) {
      for(int j = i * i; j <= MAX_M; j += i) {
        prime[j] = false;
      }
    }
  }
  while(true) {
    int M, A, B; cin >> M >> A >> B;
    if(M == 0 && A == 0 && B == 0) break;
    int maxP = 0, maxQ = 0;
    for(ll i = 2; i <= M; ++i) {
      if(prime[i]) {
        for(ll j = 2; j <= min(i, M / i); ++j) {
          if(prime[j] && maxP*maxQ < i * j && A*i <= B*j) {
            maxP = j;
            maxQ = i;
          }
        }
      }
    }
    cout << maxP << ' ' << maxQ << endl;
  }
}

Measured memory_bytes: 1256
import java.util.Scanner;

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

        Scanner scanner = new Scanner(System.in);
        int A = scanner.nextInt();
        if (A % 10 == 3) {
            System.out.println("bon");
        } else if (check(new int[]{0, 1, 6, 8}, A % 10)) {
            System.out.println("pon");
        } else {
            System.out.println("hon");
        }
    }

    private static boolean check(int[] ints, int i) {
        for (int anInt : ints) {
            if (anInt == i) {
                return true;
            }
        }
        return false;
    }
}

Measured memory_bytes: 26932
import sys,itertools as it
input=sys.stdin.readline
n=int(input())
ll=[]
for i in range(n):
  a=int(input())
  for _ in range(a):
    x,y=map(int,input().split())
    ll+=[(i,x-1,y)]
c=0
for p in it.product([0,1],repeat=n):
  b=1
  for i,x,y in ll:
    if p[i] and p[x]!=y:
      b=0
      break
  if b: c=max(c,sum(p))
print(c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int N;
string S;
long long cnt;
struct Node
{
	int R, G, B;
}F[4005], B[4005];
int main()
{
	cin >> N >> S;
	F[0].R = 0;
	F[0].G = 0;
	F[0].B = 0;
	B[N - 1].R = 0;
	B[N - 1].G = 0;
	B[N - 1].B = 0;
	for (int i = 1; i < N; i++)
	{
		F[i] = F[i - 1];
		if (S[i - 1] == 'R')
		{
			F[i].R++;
		}
		else if (S[i - 1] == 'G')
		{
			F[i].G++;
		}
		else
		{
			F[i].B++;
		}
	}
	for (int i = N - 2; i >= 0; i--)
	{
		B[i] = B[i + 1];
		if (S[i + 1] == 'R')
		{
			B[i].R++;
		}
		else if (S[i + 1] == 'G')
		{
			B[i].G++;
		}
		else
		{
			B[i].B++;
		}
	}
	for (int i = 1; i < N; i++)
	{
		if (S[i] == 'R')
		{
			cnt += F[i].G * B[i].B + F[i].B * B[i].G;
		}
		else if (S[i] == 'G')
		{
			cnt += F[i].R * B[i].B + F[i].B * B[i].R;
		}
		else
		{
			cnt += F[i].G * B[i].R + F[i].R * B[i].G;
		}
	}
	for (int i = 0; i < N; i++)
	{
		for (int j = 1; i + 2 * j < N; j++)
		{
			if (S[i] != S[i + j] && S[i] != S[i + 2 * j] && S[i + j] != S[i + 2 * j])
			{
				cnt--;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 3668
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };

    let a: char = sc.read();

    if a.is_ascii_lowercase() {
        println!("{}", "a");
    } else {
        println!("{}", "A");
    }

}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2172
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
//#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
// cerr<<1.0/CLOCKS_PER_SEC<<endl;
using namespace std;
#define N  1000000007 
#define MAXN   200005
//ll int dp[1001][100005];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cout.precision(15);
ll int n,k;
cin>>n>>k;
vi a(n);
rep(i,0,n)
cin>>a[i];
ll int dp[n+1][k+1];
rep(i,0,n+1)
{
rep(j,0,k+1)
{
if(i==0 && j==0)
{dp[i][j]=1;}
else if(j==0)
{dp[i][j]=1;}
else if(i==0)
{dp[i][j]=0;}
else
{
dp[i][j]=dp[i][j-1]+dp[i-1][j];
if(j>a[i-1])
dp[i][j]-=dp[i-1][j-a[i-1]-1];
dp[i][j]=(dp[i][j]+N)%N;
}}}
cout<<dp[n][k];
 
}

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

int main() {
  int N, M, X;
  cin >> N >> M >> X;
  int to_0 = 0, to_N = 0;
  for (int i = 0; i < M; i++) {
    int tmp;
    cin >> tmp;
    if (tmp < X) to_0++;
    else to_N++;
  }
  cout << min(to_0, to_N) << endl;
}


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

int main() {
  string stra, strb, strc;
  cin >> stra >> strb >> strc;
  
  vector<vector<char>> vec(3);
  
  for (int j=0; j<stra.size(); j++){
    vec.at(0).push_back(stra.at(j));
  }
  for (int k=0; k<strb.size(); k++){
    vec.at(1).push_back(strb.at(k));
  }
  for (int l=0; l<strc.size(); l++){
    vec.at(2).push_back(strc.at(l));
  }
  
  reverse(vec.at(0).begin(), vec.at(0).end());
  reverse(vec.at(1).begin(), vec.at(1).end());
  reverse(vec.at(2).begin(), vec.at(2).end());
  
  char hensu = 'a';
  
  while(true){
    if (hensu=='a' && vec.at(0).size()==0){
      cout << "A" << endl;
      break;
    }
    else if (hensu=='b' && vec.at(1).size()==0){
      cout << "B" << endl;
      break;
    }
    else if (hensu=='c' && vec.at(2).size()==0){
      cout << "C" << endl;
      break;
    }
    
    if(hensu=='a'){
      hensu = vec.at(0).at(vec.at(0).size()-1);
      vec.at(0).pop_back();
      continue;
    }
    if(hensu=='b'){
      hensu = vec.at(1).at(vec.at(1).size()-1);
      vec.at(1).pop_back();
      continue;
    }
    if(hensu=='c'){
      hensu = vec.at(2).at(vec.at(2).size()-1);
      vec.at(2).pop_back();
      continue;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
	int t;
	cin >> t;
	while(t--)
	{
		int n;
		cin >> n;
		ll a[n];
		for(int i=0;i<n;i++) cin >> a[i];
		
		string s;
		cin >> s;
		
		vector<ll> base;
		bool flag=0;
		for(int i=n-1;i>=0;i--)
		{
			ll x = a[i];
			for(ll b:base) x = min(x,x^b);
			
			if(x)
			{
				if( s[i] == '1' ) 
				{     flag = 1;
					//cout<<'1';
					break;
				}
				else base.push_back(x);
			}
		}
		if(flag) cout<<1;
		else cout<<0;
		cout<<'\n';
		
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 3520
#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--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

P f(int x) {
   P p;
   p.second = x % 10;
   while (x) {
      p.first = x % 10;
      x /= 10;
   }
   return p;
}
int main() {
   int n;
   cin >> n;
   map<P, int> cnt;
   for (int i = 1; i <= n; i++) {
      P p = f(i);
      cnt[p]++;
   }
   llong ans = 0;
   for (int i = 1; i <= n; i++) {
      P p = f(i);
      ans += cnt[P(p.second, p.first)];
   }
   cout << ans << endl;
   return 0;
}

Measured memory_bytes: 256