akhauriyash/Code-Regression huggingface dataset:
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
// using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

typedef double D;
typedef complex<D> P;
using pdi = pair<double,int>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int sx,sy,gx,gy;
    cin >> sx >> sy >> gx >> gy;
    int N;
    cin >> N;
    N += 2;
    vector<P> p(N);
    vector<D> r(N);
    p[0] = P(sx,sy);
    r[0] = 0;
    p[N-1] = P(gx,gy);
    r[N-1] = 0;
    for(int i=1; i<N-1; i++){
        double x,y;
        cin >> x >> y >> r[i];
        p[i] = P(x,y);
    }
    vector<vector<D>> G(N,vector<D>(N));
    for(int i=0; i<N; i++){
        for(int j=i; j<N; j++){
            double now = abs(p[i]-p[j]) - (r[i]+r[j]);
            G[i][j] = max(0.0,now);
            G[j][i] = max(0.0,now);
        }
    }
    priority_queue<pdi,vector<pdi>,greater<pdi>> que;
    que.emplace(0,0);
    vector<double> dist(N,INF);
    dist[0] = 0;
    while(que.size()){
        double cost;
        int v;
        tie(cost,v) = que.top();
        que.pop();
        if(dist[v] < cost) continue;
        for(int i=0; i<N; i++){
            double ncost = G[v][i];
            int nv = i;
            if(ncost+cost < dist[nv]){
                dist[nv] = ncost  + cost;
                que.emplace(dist[nv],nv);
            }
        }
    }
    cout << fixed << setprecision(15) << dist[N-1] << "\n";
    return 0;
}

Measured memory_bytes: 14328
using System;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var A = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            var result = 0;
            for (int i = 0; i < N; i += 2)
            {
                if ((A[i] % 2) == 1) result++;
            }
            Console.WriteLine(result);
        }
    }
}


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

typedef long long int LL;
typedef long long int LLint;

//Faster Program
#define endl "\n"

//Faster Coding
#define ED return
#define GET(a) int a;cin >> a
#define DGET(a) double a;cin >> a
#define SGET(a) string a;cin >> a
#define CGET(a) char a;cin >> a
#define PRINT(a) cout << a << "\n"
#define ANS(a,b) int a;cin >> a;cout << b << "\n"
#define FOR(n) for(int i = 0;i < n;i++)
#define SORT(vec) sort(vec.begin(),vec.end())
#define REV(vec) reverse(vec.begin(),vec.end())

//As Function
#define UP(a,b) ((a+(b-1))/b)
#define ipow(x,y) LL(pow(x,y))

//Debug
#define TEST cout << "OK\n"

const double PI = M_PI;
const long long INF = int(999999999);
const long long MOD = int(1000000007);

//Settings
const bool DO_BENCHMARK = false;
const int DOUBLE_ACCURACY = 15;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(DOUBLE_ACCURACY);
    void solve();
    if(DO_BENCHMARK){
        clock_t clock_start = clock();
        solve();
        clock_t clock_end = clock();
        const double time = static_cast<double>(clock_end-clock_start)/CLOCKS_PER_SEC*1000.0;
        cout << "\n" << time << "[ms]\n";
    }
    else solve();
}

int kaijyou(int N){
    int ans = 1;
    for(int i = 1;i <= N;i++){
        ans *= i;
    }
    return ans;
}

void solve(){
    int N;
    cin >> N;
    vector<int> P (N);
    for(int i = 0;i < N;i++){
        cin >> P[i];
    }
    int ansP = 1;
    vector<bool> checkP (N,false);
    for(int i = 0;i < N-1;i++){
        int num = 0;
        for(int j = 1;j <= N;j++){
            if(P[i] == j){
                checkP[j-1] = true;
                break;
            }
            if(checkP[j-1] == false){
                num++;
            }
        }
        ansP += num*kaijyou(N-i-1);
    }
    vector<int> Q (N);
    for(int i = 0;i < N;i++){
        cin >> Q[i];
    }
    int ansQ = kaijyou(N);
    vector<bool> checkQ (N,false);
    for(int i = 0;i < N-1;i++){
        int num = 0;
        for(int j = N;j >= 0;j--){
            if(Q[i] == j){
                checkQ[j-1] = true;
                break;
            }
            if(checkQ[j-1] == false){
                num++;
            }
        }
        ansQ -= num*kaijyou(N-i-1);
    }
    cout << abs(ansP-ansQ) << endl;
}


Measured memory_bytes: 256
A = [tuple(map(int, input().split())) for i in range(3)]
N = int(input())
b = [int(input()) for i in range(N)]
B = [[False]*3 for i in range(3)]

for x in b:
    for i in range(3):
        for j in range(3):
            if A[i][j] == x:
                B[i][j] = True
                break


flag = False
for i in range(3):
    for j in range(3):
        if B[i][j] == False:
            break
        if j == 2:
            flag = True


for j in range(3):
    for i in range(3):
        if B[i][j] == False:
            break
        if i == 2:
            flag = True

for i in range(3):
    if B[i][i] == False:
        break
    if i == 2:
        flag = True
for i in range(3):
    if B[2 - i][i] == False:
        break
    if i == 2:
        flag = True

if flag:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto x = lread();
    if (x >= 30)
    {
        writeln("Yes");
    }
    else
    {
        writeln("No");
    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

int main() {
	int a, b, max;
	cin >> a >> b;
	max = a + b;
	if (max < a - b)
		max = a - b;
	if (max < a * b)
		max = a * b;
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a<b){
         if(b<c){
             cout<<"Yes"<<endl;
         }else{
             cout<<"No"<<endl;
         }
    }else{
        cout<<"No"<<endl;
    }
    return 0;
         
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  vector<string> board(H);
  rep(i,0,H-1) cin >> board[i];

  string ans = "Yes";
  rep(i,0,H-1) {
    rep(j,0,W-1) {
      if (board[i][j] == '.') continue;

      bool ok = false;
      if (0 <= i - 1) {
        if (board[i-1][j] == '#') ok = true;
      }

      if (i + 1 < H) {
        if (board[i+1][j] == '#') ok = true;
      }

      if (0 <= j - 1) {
        if (board[i][j-1] == '#') ok = true;
      }

      if (j + 1 < W) {
        if (board[i][j+1] == '#') ok = true;
      }

      if (!ok) ans = "No";
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
/* Author : Aaryan Srivastava ^__^ */ 
#include <bits/stdc++.h>
#include <random>
#include <chrono>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define pb push_back
#define mp make_pair
#define ff first
#define ss second   
#define rep(i,n) for(int i = 0 ; i < (n) ; i++)
#define repA(i,x,y) for(int i = (x) ; i <= (y) ; i++)
#define repD(i,x,y) for(int i = (x) ; i >= (y) ; i--)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define setval(a,val) memset(a,val,sizeof(a))
#define Randomize mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define trav(x , a) for(auto &x : a)
#define sz(a) ((int)a.size())
typedef long long ll ; 
#define int ll
using namespace std;

const int N = 3e5 + 5 ;
const int mod = 1e9 + 7 ;
const ll inf = 1e18 ;
const int SZ = 101 ;
const long double eps = 1e-9 ;

using namespace __gnu_pbds;
using ordered_set =  tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ;

typedef pair<int, int> pii; 
typedef pair<int , pii> ipii ;
typedef pair<pii , int> piii ; 
typedef unsigned long long ull ;
typedef long double ld;

ll po(ll x,ll y,ll p = mod) {ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}

void solve()
{
    int A , B , C , D , E , F ;
    cin >> A >> B >> C >> D >> E >> F ;
    pii ans = {1 , 0};
    repA(i , 0 , 50)
        repA(j , 0 , 50)
            repA(k , 0 , 50)
                repA(l , 0 , 50){
                    int tw = i * A * 100LL + j * B * 100LL ;
                    int ts = k * C + l * D ;
                    if( tw * E < ts * 100 ) continue ;
                    if(tw + ts > F) continue ;
                    if(ans.ss * (ts + tw) <= ts * ans.ff ){
                        ans = {tw + ts , ts} ;
                        // if(ans.ff == 190) cout << i << ' ' << j << ' ' << k << ' ' << l << '\n';
                    }
                }
    if(ans.ss == 0) ans.ff = 100 * A ;
    cout << ans.ff << ' ' << ans.ss ;
}
     
int32_t main(int32_t argc, char *argv[])
{
    ios::sync_with_stdio(0);    
    cin.tie(0); cout.tie(0);
    int TC = 1, t = 0;
    //cin >> TC ;
    while(t++ < TC)
    {
        //cout << "Case #" << t << ": " ;
        solve();
        cout << "\n" ;
    }
    return 0;
}


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

public class Main {

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

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		StringTokenizer st = new StringTokenizer(str, " ");
		int a = Integer.parseInt(st.nextToken());
		int b = Integer.parseInt(st.nextToken());
		int c = Integer.parseInt(st.nextToken());

		if (a <= b && b <= c) {
			System.out.println(a + " " + b + " " + c);

		} else if(a <= c && c <= b) {
			System.out.println(a + " " + c + " " + b);

		} else if(b <= a && a <= c) {
			System.out.println(b + " " + a + " " + c);

		} else if(b <= c && c <= a) {
			System.out.println(b + " " + c + " " + a);

		} else if(c <= a && a <= b) {
			System.out.println(c + " " + a + " " + b);

		} else if(c <= b && b <= a) {
			System.out.println(c + " " + b + " " + a);
		}
	}
}



Measured memory_bytes: 24172
// Problem : C - Stones
// Contest : AtCoder - Tenka1 Programmer Beginner Contest 2019
// URL : https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	// && has higher precedence than ||
	ios_base::sync_with_stdio(0); cin.tie(0);    
	int N;
	cin>>N;
	string str;
	cin>>str;
	vi vb(N),vw(N);
	if(str[0]=='.')
		vw[0]=1;
	else
		vb[0]=1;
	F0R(x,N-1)
	{
		vb[x+1]=vb[x];
		vw[x+1]=vw[x];
		if(str[x+1]=='.')
			vw[x+1]++;
		else
			vb[x+1]++;
	}
	int mn=min(vw.back(),vb.back());
	int val=0;
	F0R(x,N)
	{
		// if(str[x]=='#')
		// {
			// val++;
			ckmin(mn,vb[x]+vw.back()-vw[x]);
		// }	
	}
	cout<<mn<<nl;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 5236
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]
if N==1:
    print(D[0][0],D[0][1],D[0][2])
    exit()
H={}
for cx in range(101):
    for cy in range(101):
        H=set()
        d = []
        for x, y, h in D:
            if h >=1:
                H.add(abs(x-cx)+abs(y-cy)+h)
            else:
                d.append(abs(x-cx)+abs(y-cy))

        if len(H)==1:
            if len(d)==0 or list(H)[0] <= min(d):
                print(cx, cy, list(H)[0])
                exit()


Measured memory_bytes: 3064
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);

        int[] a = new int[2];
        a[0] = sc.nextInt();
        a[1] = sc.nextInt();
        int idx = a[0] - 1;
        Integer[] numbers = new Integer[a[0]];
        int i = 0;
        while (sc.hasNext()) {
          numbers[i] = sc.nextInt();
          i++;
        }
        for (int p=i; p<a[0]; p++) {
          numbers[p] = 9999;
        }
		Arrays.sort(numbers);
        int total = 0;
        for (int q=0; q<a[1]; q++) {
          total = total + numbers[q];
        }
        System.out.println(total);        
    }
}

Measured memory_bytes: 38780
N, M = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

from collections import defaultdict

ts = defaultdict(int)

ts[0] = 1

t = 0
for a in A:
    t = (t + a) % M
    ts[t] += 1

result = 0

for k, v in ts.items():
    result += v * (v - 1) // 2

print(result)


Measured memory_bytes: 14252
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static Scanner cin = new Scanner();

    struct p {
        public int x, y;
        public p(int X, int Y) {
            x = X;
            y = Y;
        }
    }

    static void Main(string[] args) {
        int H = cin.Int();
        int W = cin.Int();
        var S = new string[H+2];

        for (int i = 1; i <= H; i++) {
            S[i] = "." + Console.ReadLine() + ".";
        }

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

        long ans = 0;
        var isSearched = new bool[H + 2, W + 2];

        for (int i = 0; i < W+2; i++) {
            isSearched[0, i] = true;
            isSearched[H + 1, i] = true;
        }
        for (int i = 0; i < H+2; i++) {
            isSearched[i, 0] = true;
            isSearched[i, W + 1] = true;
        }

        for (int i = 1; i <= H; i++) {
            for (int j = 1; j <= W; j++) {
                if (!isSearched[i, j]) {
                    int black = 0, white = 0;
                    Queue<p> que = new Queue<p>();
                    que.Enqueue(new p(j, i));
                    isSearched[i, j] = true;
                    while (que.Count > 0) {
                        p point = que.Dequeue();
                        if (S[point.y][point.x] == '#') black++;
                        else if(S[point.y][point.x] == '.') white++;
                        for (int k = 0; k < 4; k++) {
                            int ni = point.y + dy[k];
                            int nj = point.x + dx[k];
                            if (1 <= ni && ni <= H && 1 <= nj && nj <= W && !isSearched[ni, nj] && S[point.y][point.x] != S[ni][nj]) {
                                    que.Enqueue(new p(nj, ni));
                                    isSearched[ni, nj] = true;
                            }
                        }
                    }
                    ans += (long)black * (long)white;
                }
            }
        }
        Console.WriteLine(ans);
        Console.ReadLine();
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 15668
#include<stdio.h>

int main(void){

  int array[128] = {0};
  int i;
  int count = 0;

  while(scanf("%d",&i) != EOF){
    array[i]++;

    if(array[i] > count)
      count = array[i];
  }

  for(i=0;i<101;i++){
    if(array[i] == count)
      printf("%d\n",i);
  }
  return 0;
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n:u64 = read();
    let v = read_vec::<u64>();
    let ans:u64 = v.iter().map(|x| x-1).sum();
    println!("{}",ans );
}

Measured memory_bytes: 4352
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 2000100;

bool isprime(int n){
   if(n==2)return true;
   if(n%2==0)return false;
    if(n<2)return false;

    for(int i = 3; i*i<=n; i+=2){
        if(n%i==0)return false;
    }
    return true;
}

int main(){
        _
        int n; cin >> n;
        if(isprime(n)){
            cout<<n<<endl;
            return 0;
        }
        for(int i = n+1; ; i++){
            if(isprime(i)){
                cout<<i<<endl;
                return 0;
            }
        }


return 0;
}




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

int main() {
	string s;
	int count = 0;
	cin>>s;
	int j = s.length()-1;
	if(s.length()==1){
	    count = 0;
	}else{
    	for(int i=0; i<s.length()/2; i++){
    	    if(s[i] != s[j]){
    	        count++;
    	    }
    	    j--;
    	}
	}
    cout<<count;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>


using namespace std;
int main() {
    int H,W,A,B;
    cin >> H >> W >> A >>B;
    for(int yi = 0; yi < H; yi++){
        for(int xi = 0; xi < W; xi++){
            if(xi < A){
                if(yi < B){
                    cout << "1";
                }else{
                    cout <<"0";
                }
            }else{
                if(yi < B){
                    cout << "0";
                }else{
                    cout << "1";
                }
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;
ll migi[20000], hida[100000];

int main() {
	ll n, k, a,y=0,y1=0,y2=0;
	cin >> n >> k;
	vector<ll> vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec[i];
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (i != j) {
				if (vec[i] < vec[j]) {
					if (i < j) {
						hida[i]++;
					}
					else {
						migi[i]++;
					}
				}
			}
		}
	}
	ll h = 0;
	for (int i = 0; i < n; i++) {
		y1 += migi[i];
		y1 %= mod;
		y2 += hida[i];
		y2 %= mod;
	}
	ll c = k * (k + 1) / 2,d=k*(k-1)/2;
	d %= mod;
	c %= mod;
	y1 = y1 * c;
	y1 %= mod;
	y2 = y2 * d;
	y2 %= mod;
	cout << (y1+y2) % mod << endl;
}

Measured memory_bytes: 256
l, r = map(int, input().split())
rest = l*(l+1) % 2019
ans = rest
 
if r - l > 1:
  for i in range(l, r):
    if ans == 0:
      break
    for j in range(i+1, r+1):
      rest_next = i*j % 2019
      if rest_next < ans:
        ans = rest_next
      if ans == 0:
        break
print(ans)

Measured memory_bytes: 3060
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"

using namespace std;

using u8 = uint8_t;
using u16 = uint16_t;
using u32 = uint32_t;
using u64 = uint64_t;
using i8 = int8_t;
using i16 = int16_t;
using i32 = int32_t;
using i64 = int64_t;

constexpr char newl = '\n';
constexpr double eps = 1e-10;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = ((b)-1); i >=(a); i--)
#define RF0(i,b) RFO(i,0,b)
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << '\n';
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()

template<typename T1, typename T2> inline void chmin(T1& a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
template<class T> void Print(vector<T> v) {
  F0R(i, v.size()) {
    cout << v[i] << ' ';
  }
  cout << newl;
}

#if 1


// INSERT ABOVE HERE
signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int a, b;
  cin >> a >> b;
  cout << (b % a == 0 ? a + b : b - a);
}
#endif


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

int main(){
    vector<string> u;
    int N; cin >> N;
    vector<string> s(N);
    for(int i=0; i<N; i++){
        cin >> s[i];
        u.push_back(s[i]);
    }
    int M; cin >> M;
    vector<string> t(M);
    for(int i=0; i<M; i++){
        cin >> t[i];
        u.push_back(t[i]);
    }
    sort(u.begin(),u.end());
    u.erase(unique(u.begin(),u.end()), u.end());
    u.push_back("0");
    
    int mny=0, m=-10000;
    for(int i=0; i<u.size(); i++){
        mny=0;
        for(int j=0; j<N; j++){
            if(u[i]==s[j]) mny++;
        }
        for(int j=0; j<M; j++){
            if(u[i]==t[j]) mny--;
        }
        if(mny>m) m=mny;
    }
    
    cout << m << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(a>=k)
    cout<<k<<endl;
  else if(a+b>=k)
    cout<<a<<endl;
  else cout<<a*2+b-k<<endl;
}

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

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        if(a%2 == 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3120
#include <algorithm>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
// const int INF = (1 << 30) - 1;
// const ll LL_INF = (1LL << 62) - 1;
// const ll MOD = 1e9 + 7;

int N;
vector<int> p;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N;
  p.resize(N);
  for (int i = 0; i < N; i++) {
    int pi;
    cin >> pi;
    p[i] = pi;
  }

  int ans = 0;
  for (int i = 0; i < N - 1; i++) {
    if (p[i] == i + 1) {
      swap(p[i], p[i + 1]);
      ans++;
    }
  }
  if (p[N - 1] == N) {
    ans++;
  }

  cout << ans << endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  int l[n];
  rep(i,n) cin >> l[i];
  sort(l,l+n);
  int ans = 0;
  rep(i,n){
    for(int j = i+1; j < n; j++){
      int c = lower_bound(l,l+n,l[i]+l[j]) - l;
      ans += c-j-1;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll k,n,i;
	cin>>k>>n;
	vector<ll> a(n),b(n);
	for(i=0;i<n;i++) cin>>a[i];
	for(i=1;i<n;i++) b.pb(a[i]-a[i-1]);
	b.pb(k-a.back()+a[0]);
	sort(all(b));
	cout<<accumulate(b.begin(), b.end()-1, 0);
}

Measured memory_bytes: 6400
N = int(input())

if N < 10:
	print(N)
elif N < 100:
	print(9)
elif N < 1000:
	print(N - 90)
elif N < 10000:
	print(909)
elif N < 100000:
	print(N - 9090)
else:
	print(90909)

Measured memory_bytes: 3060
main=do
    ctx<-getContents
    let p=tail [msg|msg<- lines ctx]
    let countA = sum $ map istailA p
    let countB = sum $ map isheadB p
    let countAB = sum $ map isthAB p
    let res = sum $ map inLineAB p
    let tailAB= countAB + (if countA>0 then 1 else 0) + (if countB>0 then 1 else 0)
    let tailA= if countA>0 then (countA-1) else countA
    let headB= if countB>0 then (countB-1) else countB
    print $ res+(max 0 (tailAB-1))+(max 0 (min tailA headB))

istailA::[Char]->Int
istailA s=if (last s)=='A' && head s/='B'then 1 else 0

isheadB::[Char]->Int
isheadB s= if (head s)=='B' && last s/='A' then 1 else 0

isthAB::[Char]->Int
isthAB s = if (head s)=='B' && (last s)=='A' then 1 else 0

inLineAB::[Char]->Int
inLineAB s = length [1 |x<-(zip s (drop 1 s)),(snd x)=='B',(fst x) =='A']


Measured memory_bytes: 3324
#042c slow
N,K = map(int, input().split())
D_set = set([int(e) for e in input().split()])

INF = 9999999999

OK_D = {0,1,2,3,4,5,6,7,8,9} - D_set

OK_D_list = list(OK_D)
OK_D_list.sort

ans = []
pay = 0

def dfs(pos,pay):
    #print("#####################")
    #print(pay)
    
    #停止条件
    #深さに限らず，任意の停止条件を書く
    if pos >= 5 or pay>=N:
        #print("%%%%%%%%%%%%%%%%")
        if pay>=N:
        #支払い出来る
            ans.append(pay)
            return pay
        else:
            return INF
        
    # pos (bamboo_number)を進めながら（末端に進みながら）分岐処理
    # 末端まで到達した時それぞれの分岐から値が返される
    for number in OK_D_list:
        #print(number)
        dfs(pos+1 ,pay*10 + number) 
        
    #それぞれの分岐からの戻り値の処理を行う関数

dfs(0,0)
#print("###############")
#print(ans)
print(min(ans))

Measured memory_bytes: 5400
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<ll,ll> p;
const int inf=(1<<30);
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
	int main(){
		ll a,b;
		cin>>a>>b;
		rep(i,0,a+1){
			if(2*i+4*(a-i)==b){
				cout<<"Yes"<<endl;
              return 0;
			}
		}
		cout<<"No"<<endl;
	}

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

using ll = long long;
using pii = pair<ll, ll>;

ll H, W, N;
ll A[111111], B[111111];
set<pii> coord, S; // 入力座標, 入力座標の周辺座標
ll ans[100];

// 黒マス周辺の9座標を列挙するための左上の座標をsetに格納する
void make(ll y, ll x) {
   for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
         int ny = y - i, nx = x - j;
         if (ny >= 1 && ny <= H-2 && nx >= 1 && nx <= W-2) {
            S.insert({ny, nx});
         }
      }
   }
}

int main() {
   cin >> H >> W >> N;
   for (int i = 0; i < N; i++) {
      cin >> A[i] >> B[i];
      coord.insert({A[i], B[i]});
      make(A[i], B[i]);
   }

   ll white = (H-2) * (W-2); // 9*9が白いマスの個数
   for (pii p : S) {
      ll y = p.first, x = p.second;
      int cnt = 0;
      for (ll i = y; i < y+3; i++) {
         for (ll j = x; j < x+3; j++) {
            if (coord.find({i, j}) != coord.end()) {
               cnt++;
            }
         }
      }
      if (cnt) white--;
      ans[cnt]++;
   }

   ans[0] = white;
   for (int i = 0; i <= 9; i++) {
      cout << ans[i] << endl;
   }


   return 0;
}

Measured memory_bytes: 64256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AOJ1042
{
    class Program
    {
        static void Main()
        {
            ReadInputs()
                .Select(s => s.Split(' ').Select(w => w.Length.ToString()))
                .Select(l => string.Join("", l.ToArray()))
                .ForEach(Console.WriteLine);
        }

        private static IEnumerable<string> ReadInputs()
        {
            string line;
            while ((line = Console.ReadLine()) != null && line != "END OF INPUT")
            {
                yield return line;
            }
        }
    }

    static class EnumerableExtensions
    {
        public static void ForEach<T>(this IEnumerable<T> source, Action<T> action)
        {
            foreach (var item in source)
            {
                action(item);
            }
        }
    }
}

Measured memory_bytes: 9452
#include <stdio.h>
#include <stdbool.h>

char grading(int x, int y, int z)
{    
    int sum2 = x + y;
    int sum3 = x + y + z;
    char rank;
    if(x == 100 || y == 100 || z == 100){
        rank = 'A';
    } else if (sum2 >= 180){
        rank = 'A';
    } else if (sum3 >= 240){
        rank = 'A';        
    } else if (sum3 >= 210){
        rank = 'B';        
    } else if (sum3 >= 150 && (x >= 80 || y >= 80)){
        rank = 'B';        
    } else {
        rank = 'C'; 
    }  
    return rank;     
}
    

int main(void)
{   
    int rep, ma, en, ja;
    char rank;
    while(true){
        scanf("%d", &rep);
        if(rep == 0){
            break;
        }
        for(int i = 0; i < rep; ++i){
            scanf ("%d%d%d", &ma, &en, &ja);
            rank = grading(ma, en, ja);
            printf("%c\n", rank);
        }
    }
    return 0;        
}

Measured memory_bytes: 1028
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABC097_B solver = new ABC097_B();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABC097_B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int x = in.nextInt();

            int ans = 1;
            for (int i = 2; i <= x; i++) {
                int p = 2;
                while (Math.pow(i, p) <= x) {
                    ans = (int) Math.max(ans, Math.pow(i, p));
                    p++;
                }
            }

            out.print(ans);
        }

    }
}



Measured memory_bytes: 22996
N,M = list(map(int,input().split()))
l = -1
r = 1000000000
for _ in range(M):
    ll,rr = list(map(int,input().split()))
    if (ll > r) or (rr < l):
        print(0)
        exit(0)
    else:
        l = max(l,ll)
        r = min(r,rr)
print(r-l+1)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
#define INF (1<<30)
#define NUMMAX 10000
int main(){
    int N,W;
    cin>>N>>W;
    vector<int> line(NUMMAX+1,INF);
    line[0]=0;
    for(int i=0;i<N;++i){
        int v,w;
        cin>>v>>w;
        for(int j=NUMMAX-v;j>=0;--j){
            line[j+v]=min(line[j+v],line[j]+w);
        }
    }
    int ans=0;
    for(int j=NUMMAX;j>0;--j){
        if(line[j]<=W){
            ans=j;
            break;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define YEET ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define f first
#define s second
#define mod 1000000007

using namespace std;

ll lcm(ll a, ll b)
{
    ll temp = __gcd(a, b);

    return temp ? (a / temp * b) : 0;
}
int main ()
{
	YEET;
     ll a,b,c,d;
    cin>>a>>b>>c>>d;
     ll ans = -(a+(c-a%c))/c+(b-(b%c))/c+1;
     if(a%c==0)
        ans++;
    //cout<<ans<<" ";
    ans += -(a+(d-a%d))/d+(b-(b%d))/d+1;
    if(a%d==0)
        ans++;
    //cout<<ans<<" ";
    c = lcm(c,d);
    if(c<b)
        ans-=-((a+(c-a%c)))/c+(b-(b%c))/c+1;
    if(a%c==0)
        ans--;
    //cout<<ans<<" ";
    cout<<(b-a+1)-ans;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, H, W;
  cin >> N >> H >> W;
  int A[1000], B[1000];
  int ans = 0;
  for(int i = 0; i < N; i++){
    cin >> A[i] >> B[i];
    if(A[i] >= H && B[i] >= W)ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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;
}
const int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N, L;
	cin >> N >> L;
	vector<int>data(N);
	int af, be, check, ans;
	af = be = 0;
	check = INT_MAX;
	for (int i = 0; i < N; i++) {
		data[i] = L + i;
		be += data[i];
	}
	for (int i = 0; i < N; i++) {
		af = 0;
		for (int j = 0; j < N; j++) {
			if (i != j) {
				af += data[j];
			}
		}
		if (check > abs(be - af)) {
			chmin(check, abs(be - af));
			ans = af;
		}
	}
	cout << ans << endl;
}


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

int main(){
	int n; cin >> n; std::vector<int> a(n);
	for(int i = 0; i < n; i++) cin >> a[i];
	
	int ma = 0;
	for(int i = 0; i < n; i++) {
		while(!(a[i] % 2)) {
			ma++;
			a[i] /= 2;
		}
	}
	
	cout << ma << endl;
	return 0;
}


Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
const long double epsA=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	llint n,e,i;cin>>n>>e;
	vector<vector<int>>go(n);
	for(i=0;i<e;i++){
		
		int a,b;cin>>a>>b;a--;b--;
		go[a].pub(b);go[b].pub(a);
		
	}
	
	vector<int>pa(n,-1);
	queue<int>que;
	int base=0;
	static int kaz[100001]={0};
	for(i=0;i<n;i++){
		
		if(pa[i]!=-1){continue;}
		
		pa[i]=0;que.push(i);
		int g=0,k=0;
		while(que.size()){
			int t=que.front();que.pop();
			int z=pa[t];
			if(z){g++;}
			else{k++;}
			for(auto it:go[t]){
				//cerr<<it<<endl;
				if(pa[it]==-1){que.push(it);pa[it]=1-z;}
				if(pa[it]==z){cout<<-1<<endl;return 0;}
			}
		}
		//cerr<<"g="<<g<<"k="<<k<<endl;
		base+=min(g,k);
		kaz[abs(g-k)]++;//偏り
	}
	bitset<100001>bits;bits[base]=1;
	for(i=1;i<=n;i++){
		if(kaz[i]==0){continue;}
		if(kaz[i]>2){
			int t=(kaz[i]-2)/2;
			kaz[i]-=t*2;kaz[i+i]+=t;
		}
		if(kaz[i]>0){bits|=(bits<<i);}
		if(kaz[i]>1){bits|=(bits<<i);}
	}
	llint ans=0;
	for(i=0;i<=n;i++){
		if(bits[i]){maxeq(ans,i*(n-i));}
	}
	cout<<ans-e<<endl;
	//gの合計をできるだけn/2-baseに近づける
	
	return 0;
}



Measured memory_bytes: 9480
#include <cstdio>
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>

#define int long long
#define rr register

#define inf 1e9
#define MAXN 10000010

using namespace std;

inline int read() {
	int s = 0, f = 0;
	char ch = getchar();
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return f ? -s : s;
}

void print(int x) {
	if (x < 0) putchar('-'), x = -x;
	if (x > 9) print(x / 10);
	putchar(x % 10 + 48);
}

int n, ans, m, k, cnt;

int a[MAXN];

inline void pri(int x) {
	for (rr int i = 1; i <= x; i++) 
		for (rr int j = i; j <= x; j += i)
			a[j]++;
}

signed main() {
	n = read();
	pri(10000000);
	for (rr int i = 1; i <= n; i++) ans += i * a[i];
		cout << ans;
}
/*
5 4 731
80 150 80 150 1
60 90 120 149
*/

Measured memory_bytes: 81740
S = input()
y1, m1 = int(S[:2]), int(S[2:])
y2, m2 = int(S[2:]), int(S[:2])
if 1 <= m1 <= 12 and 1 <= m2 <= 12:
    print("AMBIGUOUS")
elif 1 <= m1 <= 12:
    print("YYMM")
elif 1 <= m2 <= 12:
    print("MMYY")
else:
    print("NA")


Measured memory_bytes: 3060
from math import ceil
N = int(input())
A = list(map(int, input().split()))
num2 = 0
num4 = 0
numO = 0
for num in A:
    if num % 4 == 0:
        num4 += 1
        continue
    elif num % 2 == 0:
        num2 += 1
        continue
    else:
        numO += 1
if num2 > 0:
    if numO > num4:
        print('No')
    else:
        print('Yes')
else:
    if numO > ceil((num4 + numO) / 2):
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 15020
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	if(n%2 == 0){
		vector<pii> ans;
		rep(i,1,n+1) rep(j,1,i) if(i+j != n+1){
			ans.emplace_back(i,j);
		}
		cout << sz(ans) << endl;
		trav(pa, ans) cout << pa.first << ' ' << pa.second << endl;
	} else {
		vector<pii> ans;
		rep(i,1,n+1) rep(j,1,i) if(i==n || i+j != n){
			ans.emplace_back(i,j);
		}
		cout << sz(ans) << endl;
		trav(pa, ans) cout << pa.first << ' ' << pa.second << endl;
	}
}


Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
 
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> pii;
using namespace std;
using ll = long long;
#define PI 3.14159265358979323846264338327950L
const int mod =  998244353;
 

void solve(){
    ll a;
    cin >> a;
    string b;
    cin >> b;
    int t = b[0] - '0';
    int t1 = b[2] - '0';
    int t2 = b[3] - '0';
    int tt = t1*10 + t2;
    ll at = a*t;
    ll att = a*tt;
    att /= 100;
    cout << at + att;
    
}


 
int main(){
    int T;
    T = 1;
    while(T--){
        solve(); 
    }
}
 


Measured memory_bytes: 3596
from collections import deque

H, W = [int(x) for x in input().split()]
c_h, c_w = [int(x) - 1 for x in input().split()]  # Convert to 0-origin
d_h, d_w = [int(x) - 1 for x in input().split()]  # Convert to 0-origin
s = [['.' for w in range(W)] for h in range(H)]
for h in range(H):
    s[h] = input()

def in_the_map(x):
    if x[0] < 0 or H <= x[0] or x[1] < 0 or W <= x[1]:
        return False
    return True

costs = [[-1 for w in range(W)] for h in range(H)]
queue = deque()
queue.append((c_h, c_w, 0))
while len(queue) > 0:
    q = queue.popleft()
    h = q[0]
    w = q[1]
    c = q[2]
    if costs[h][w] > -1:
        continue
    # print(f'{h}, {w}: {c}')
    costs[h][w] = c
    
    # Explore neighbours where can be visited with the same cost as this point
    neighbours = ((h, w - 1), (h, w + 1), (h - 1, w), (h + 1, w))
    for n in neighbours:
        if not in_the_map(n) or costs[n[0]][n[1]] > -1:  # 01-BFS assures that the cost we have recorded is the smallest
            continue
        if s[n[0]][n[1]] == '.':  # not wall
            queue.appendleft((n[0], n[1], c))  # This operation assures that the point with the lowest cost (+0) is popped earlier

    for dh in range(-2, 3):
        for dw in range(-2, 3):
            hh = h + dh 
            ww = w + dw
            if not in_the_map((hh, ww)) or costs[hh][ww] > -1:
                continue
            if s[hh][ww] == '.':
                queue.append((hh, ww, c+1))

print(costs[d_h][d_w])

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

const int INF = 0x0f0f0f0f;

int dp[50][4];

int main() {
    int n;
    while (cin >> n, n) {
        vector<int> p(n+1);
        vector<int> t(n+1);
        for (int i = 0; i < n; ++i)
            cin >> p[i] >> t[i];
        p[n] = 0; t[n] = INF;

        memset(dp, INF, sizeof(dp));

        dp[0][1] = (p[0] <= t[0]) ? p[0] : INF;

        for (int i = 1; i <= n; ++i) {
            // ??´??\?§????
            for (int k = 1; k <= 3; ++k) {
                int dist = abs(p[i] - p[i-1]);
                int time = k * dist;
                if (time <= t[i] - t[i-1])
                    dp[i][k] = dp[i-1][k-1] + dist;

            }

            // ??????????????±?§???? (????????? k ????????¨????????? k)
            for (int k = 1; k <= 3; ++k) {
                int dist = p[i-1] + p[i];
                int time = (k + 1) * p[i-1] + p[i];
                if (time <= t[i] - t[i-1])
                    dp[i][1] = min(dp[i][1], dp[i-1][k] + dist);
            }
        }

        for (int i = 0; ; ++i) {
            int m = INF;
            for (int k = 1; k <= 3; ++k)
                m = min(m, dp[i][k]);
            if (m == INF) {
                cout << "NG " << i+1 << endl;
                break;
            } else if (i == n) {
                cout << "OK " << m << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 1192
void main() {
    string s = readln.chomp;
    int n = s.to!int;
    int fx;
    foreach (x; s) {
        fx += x - '0';
    }
    writeln(n % fx == 0 ? "Yes" : "No");
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256