akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define REP(X, Y, Z) for (ll(X) = (Y); (X) < (Z); (X)++)
#define REV(X, Y, Z) for (ll(X) = (Y); (X) > (Z); (X)--)

using namespace std;
using ld = long double;
using ll = long long;
using dll = deque<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using usll = unordered_set<ll>;
using umll = unordered_map<ll, ll>;
using sll = stack<int>;
using vll = vector<ll>;
using vvll = vector<vll>;

constexpr ll kMax = 1e12 + 1;
constexpr ll kMod = 1e9 + 7;
constexpr long double kPI = 3.14159265358979323846;

ll gcd(ll a, ll b) {
  if (a < b) {
    return gcd(b, a);
  }
  ll c = a % b;
  while (c != 0) {
    a = b;
    b = c;
    c = a % b;
  }
  return b;
}

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

void init() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

int main() {
  init();

  ll N;
  cin >> N;
  vll A(N);
  REP(i, 0, N) {
    cin >> A[i];
  }

  ll ans = 0;
  REP(i, 1, N) {
    if (A[i] >= A[i - 1]) {
      continue;
    }

    ll diff = A[i-1] - A[i];
    ans += diff;
    A[i] += diff;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4780
n = int(input())
m = int(input())

roads = [[float('inf') for _ in range(n)] for _ in range(n)]

for _ in range(m):
    a,b,c,d = map(int, input().split(','))
    roads[a-1][b-1] = c
    roads[b-1][a-1] = d

s,g,V,P = map(int, input().split(','))

for k in range(n):
    for i in range(n):
        for j in range(n):
            if roads[i][j] > roads[i][k] + roads[k][j]:
                roads[i][j] = roads[i][k] + roads[k][j]

print(V-P-roads[s-1][g-1]-roads[g-1][s-1])


Measured memory_bytes: 5616
#include <iostream>
#include <limits.h>

using namespace std;

int main(int argc, char const *argv[])
{
  int n,tmp;
  int min = INT_MAX;
  int max = INT_MIN;
  cin >> n;

  for(int i = 0; i < n; i++){
    cin >> tmp;

    if(max <tmp-min) max = tmp - min;
    if(min> tmp) min = tmp; 

  }

  cout << max << endl;

  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	int a,b;cin>>a>>b;
	cout<<max(a+b,max(a,b)*2-1)<<endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int k = sc.NextInt();
        var f = new bool[n];
        for (int i = 0; i < k; i++)
        {
            int d = sc.NextInt();
            for (int j = 0; j < d; j++)
            {
                int a = sc.NextInt() - 1;
                f[a] = true;
            }
        }
        Console.WriteLine(f.Count( b => !b));
    }

    public static void Main(string[] args) => new Program().Solve();
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28168
#include <stdio.h>
#include <map>
using namespace std;

const int N = 1e5 + 5;

int a[N];
int b[N];

map<int,int> mmp;

int mabs(int x)
{
	return x >= 0 ? x : -x;
}

int main()
{
	int n;
	
	scanf("%d",&n);
	
	for (int i = 1;i <= n;i++)
	{
		scanf("%d",&a[i]);
		
		mmp[a[i]]++;
	}
	
	int ans = 0;
	
	for (int i = 1;i <= n+1;i++)
	{
		ans += mabs(a[i] - a[i-1]);
	}
	
	for (int i = 1;i <= n;i++)
	{
		int tmp = ans - mabs(a[i-1] - a[i]) - mabs(a[i] - a[i+1]) + mabs(a[i+1] - a[i-1]);
		
		printf("%d\n",tmp);
	}
	
	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main () {
    unsigned short *A, *B;

    int C[VMAX+1];
    int n, i, j;
    scanf("%d",&n);

    A = malloc(sizeof(short) * n+1);
    B = malloc(sizeof(short) * n+1);
    
    for (i = 0; i <= VMAX; i++) C[i] = 0;
    for (i = 0; i< n; i++) {
        scanf("%hu",&A[i+1]);
        C[A[i+1]]++;
    }

    for ( i = 1; i <= VMAX; i++) C[i] = C [i] + C[i-1];

    for (j = 1; j <= n; j++) {
        B[C[A[j]]] = A[j];
        C[A[j]]--;
    }

    for ( i = 1; i <= n; i++) {
        if (i > 1) printf(" ");
        printf("%d",B[i]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 9708
#include <bits/stdc++.h>
#define ll long long
#define SZ(vvv) ((int)vvv.size())
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
using namespace std;

const int N = 1e5 + 5, M = 1e4 + 9, INF = 1e9, MOD = 1e9 + 7;

int freq[N];

void runtestcase() {
	int n, p;
	string str;
	cin >> n >> p >> str;
	if(p == 2 || p == 5) {
		ll ans = 0;
		if(p == 2) {
			for (int j = n - 1; j >= 0; --j) {
				if((str[j] - '0') % 2 == 0) ans += j + 1;
			}
		} else {
			for (int j = n - 1; j >= 0; --j) {
				if((str[j] - '0') == 0 || (str[j] - '0') == 5) ans += j + 1;
			}
		}
		cout << ans;
		return;
	}
	ll cur = 0, B = 1;
	freq[0]++;
	for (int i = n - 1; i >= 0; --i) {
		cur += (str[i] - '0') * B;
		cur %= p;
		freq[cur]++;
		B *= 10;
		B %= p;
	}
	ll ans = 0;
	for (int i = 0; i < p; ++i)
		ans += 1ll * freq[i] * (freq[i] - 1) / 2;
	cout << ans;
}


int main() {
    fastIO;
#ifdef LOCAL
    freopen("input.in", "rt", stdin);
//    freopen("cache.out", "wt", stdout);
#endif
  int t = 1, tt = 1;
//	cin >> t;
  while(t) {
//		cout << "Case #" << tt << ':' << ' ';
    runtestcase();
		cout << '\n';
    --t, ++tt;
  }
}


Measured memory_bytes: 3696
n=gets.to_i
total = 1
aNs =gets.split.map(&:to_i)
if aNs.include?(0)
  puts 0
  exit
end
n.times do |index|
 total *= aNs[index]
 if total > 10**18
   total = -1
   break
 end
end
puts total

Measured memory_bytes: 21740
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

//-----------------------ここから-----------


int main(void){
	int n, x;

	cin >> n >> x;

	vector<int> m(n);

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

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

	int ans = 0;
	int cost = 0;
	for(int i = 0; i < n; i++){
		ans++;
		cost += m[i];
	}

	while(cost + m[0] <= x){
		cost += m[0];
		ans++;
	}

	cout << ans << endl;

}



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

#define pi 2*acos(0.0)

int main()
{
    float a , b , u=0 , x=0 , y=0 ;
    char ch ;
    while(scanf("%f%c%f",&a,&ch,&b)!=EOF)
    {
        if(a==0 && b==0) break ;
        x+=a*sin(u*pi/180.0) ;
        y+=a*cos(u*pi/180.0) ;
        u+=b ;
    }
    x=(int)x ; y=(int)y ;
    printf("%.0lf\n%.0lf\n",x,y) ;
    return 0 ;
}

Measured memory_bytes: 1076
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll N;
    cin >> N;

    cout << N * (N + 1) / 2 << endl;

    return 0;
}

Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,w[10000]={};
  int q[10000]={};
  string c[1000];
  cin>>a>>b;
  for(int i=0;i<a;i++){
    cin>>c[i];
  }
  for(int i=0;i<a;i++){
     q[10000];
    for(int j=0;j<b;j++){
      if(c[i][j]=='#') q[i]=1,w[j]=1;
    }
  }
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
      if(w[j]==1&&q[i]==1) cout<<c[i][j];
    }
    cout<<"\n";
  }
}


Measured memory_bytes: 384
/*  -*- coding: utf-8 -*-
 *
 * q.cc: Q - Flowers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 200000;
const int MAX_E2 = 1 << 19; // = 524288

/* typedef */

typedef long long ll;

template <typename T, const int MAX_E2>
struct SegTreeMax {
  int n, e2;
  T nodes[MAX_E2];
  SegTreeMax() {}

  void init(int _n) {
    n = _n;
    for (e2 = 1; e2 < n; e2 <<= 1);
  }

  T &get(int i) { return nodes[e2 - 1 + i]; }

  void set(int i, T v) {
    int j = e2 - 1 + i;
    nodes[j] = v;

    while (j > 0) {
      j = (j - 1) / 2;
      nodes[j] = max(nodes[j * 2 + 1], nodes[j * 2 + 2]);
    }
  }

  T max_range(int r0, int r1, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return 0;
    if (r0 <= i0 && i1 <= r1) return nodes[k];

    int im = (i0 + i1) / 2;
    T v0 = max_range(r0, r1, k * 2 + 1, i0, im);
    T v1 = max_range(r0, r1, k * 2 + 2, im, i1);
    return max(v0, v1);
  }
  T max_range(int r0, int r1) { return max_range(r0, r1, 0, 0, e2); }
};

/* global variables */

int hs[MAX_N], as[MAX_N];
SegTreeMax<ll,MAX_E2> st;

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) scanf("%d", hs + i), hs[i]--;
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  st.init(n);
  ll maxsum = 0;

  for (int i = 0; i < n; i++) {
    ll sum = st.max_range(0, hs[i]) + as[i];
    st.set(hs[i], sum);
    if (maxsum < sum) maxsum = sum;
  }

  printf("%lld\n", maxsum);
  return 0;
}


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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cout << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

int main() {
	int x; cin >> x;
	cout << 180 * (x-2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include "stdio.h"
#include "math.h"

int main()
{
 int n;
 char s, t, b;

 scanf("%d", &n);
 while(n>0){
  scanf(" %c %c %c", &s, &t, &b);
  s-='A'; t-='A'; b-='A';

  int footprint1[9]={0,0,0,0,0,0,0,0,0};
  int footprint2[9];
  footprint1[s] = 1;
  for(int i=0; i<n; i++){
   for(int j=0; j<9; j++) footprint2[j]=0;
   for(int j=0; j<9; j++){
    if(footprint1[j]>0){
     if(j>2 && j-3!=b) footprint2[j-3]+=footprint1[j];
     else footprint2[j]+=footprint1[j];
     if(j%3>0 && j-1!=b) footprint2[j-1]+=footprint1[j];
     else footprint2[j]+=footprint1[j];
     if((j+1)%3>0 && j+1!=b) footprint2[j+1]+=footprint1[j];
     else footprint2[j]+=footprint1[j];
     if(j<6 && j+3!=b) footprint2[j+3]+=footprint1[j];
     else footprint2[j]+=footprint1[j];
    }
   }
   for(int j=0; j<9; j++) footprint1[j]=footprint2[j];
  }

  printf("%f\n", footprint1[t] / pow(4.0, n));

  scanf("%d", &n);
 }

 return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;

int C[2222][2222];

int dp[2222][2222];

inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

signed main(){
    for(int i=0;i<2222;i++){
        C[i][i]=C[i][0]=1;
        for(int j=1;j<i;j++)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
    }

    int N,K;
    cin>>N>>K;

    for(int i=2;i<=N;i++)dp[1][i]=1;
    for(int i=1;i+1<K;i++){
        int sum=0;
        for(int j=N;j>=2;j--){
            if(N-j+1-i>0)add(dp[i+1][j],dp[i][j]);
            add(dp[i+1][j],sum);
            add(sum,dp[i][j]);
        }
    }

    int ans=0;
    if(K==1){
        ans=1;
    }
    else{
        for(int i=2;i<=N;i++)add(ans,dp[K-1][i]);
    }

    for(int i=0;i<N-K-1;i++)ans=ans*2%mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 62080
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let a = n % 10;
    if a == 2 || a == 4 || a == 5 || a == 7 || a == 9 {
        println!("hon");
        return;
    }

    if a == 0 || a == 1 || a == 6 || a == 8 {
        println!("pon");
        return;
    }
    if a == 3 {
        println!("bon")
    }
}


Measured memory_bytes: 2148
import numpy as np
import collections

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

a=np.array(A, dtype=np.float64)
asign=np.sign(A)
c = collections.Counter(asign)
ar = np.array(c[-1], dtype=np.float64)
ac = a * asign

if c[-1] % 2 == 0:
    print(int(sum(ac)))
else:
    print(int(sum(ac)-min(ac)*2))




Measured memory_bytes: 23272
#include <stdio.h>
int main (void){
    int a,past=3000,jus=3000,i,ans;
    for(i=0;i<5;i++){
        scanf("%d",&a);
        if(i<3){
            if(past>a){
                past=a;
            }
        }
        else if(i>2){
            if(jus>a){
                jus=a;
            }
        }
    }
    ans=past+jus-50;
    printf("%d\n",ans);
return 0;
}

Measured memory_bytes: 592
# coding: utf-8

import itertools

n = int(input())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
a = b  = count= 0

org = sorted(p)

for v in itertools.permutations(org,n):
    count += 1
    
    if list(v)==p:
        a = count
    
    if list(v)==q:
        b = count

print(abs(a - b))

Measured memory_bytes: 3060
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto hw = readln.split.to!(int[]);
    auto H = hw[0];
    auto W = hw[1];

    wchar[][] map;
    map.length = H;
    foreach (i; 0..H) {
        map[i] = readln.chomp.to!(wchar[]);
    }

    bool[][] memo;
    memo.length = H;
    foreach (ref line; memo) {
        line.length = W;
    }

    long[wchar][] css;
    foreach (x; 0..W) {
        foreach (y; 0..H) {
            if (memo[y][x]) continue;
            alias S = Tuple!(int, "x", int, "y", wchar, "colour");
            long[wchar] cs = ['#': 0, '.': 0];
            S[] ss = [S(x, y, map[y][x])];
            while (!ss.empty) {
                auto h = ss[0];
                ss = ss[1..$];
                if (memo[h.y][h.x]) continue;
                ++cs[h.colour];
                memo[h.y][h.x] = true;
                foreach (d; [[0, 1], [0, -1], [1, 0], [-1, 0]]) {
                    auto yy = h.y + d[0];
                    auto xx = h.x + d[1];
                    if (yy < 0 || yy >= H || xx < 0 || xx >= W) continue;
                    auto c = map[yy][xx];
                    if (h.colour == c) continue;
                    ss ~= S(xx, yy, c);
                }
            }
            css ~= cs;
        }
    }

    long sum;
    foreach (cs; css) {
        sum += cs['#'] * cs['.'];
    }
    writeln(sum);
}

Measured memory_bytes: 30076
import sys
input = sys.stdin.readline

def main():
	n = int(input().strip())
	v = list(map(int, input().strip().split()))
	ans = 1000000000000000
	for i in range(1, n):
		s1 = sum(v[:i+1])
		s2 = sum(v[i+1:])
		ans = min(abs(s1-s2), ans)
	print(ans)
if __name__ == '__main__':
	main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

//重みある時
using Edge = pair<int,int>;
using Graph = vector<vector<Edge> >;

const int MAX = 1000010;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

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

int main() {
    int n,flg = 1;
    cin >> n;
    vector<string> w(n);
    set<string> se;
    for (int i = 0; i < n; ++i) {
        cin >> w[i];
        if(se.count(w[i])) flg = 0;
        se.insert(w[i]);
        if(i != 0)if(w[i][0] != w[i-1][w[i-1].size()-1]) flg = 0;
    }
    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			int[] p = new int[n];

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

			int count = 0;
//			while (!check(p)) {
//				for (int i = 0; i < p.length; i++) {
//					if (i == p[i]) {
//						if (i < p.length - 1) {
//							int tmp = p[i];
//							p[i] = p[i + 1];
//							p[i + 1] = tmp;
//							break;
//						} else {
//							int tmp = p[i];
//							p[i] = p[0];
//							p[0] = tmp;
//							break;
//						}
//					}
//				}
//				count++;
//			}

			boolean renzoku = false;
			for (int i = 0; i < p.length; i++) {
				if (i == p[i]) {
					if (!renzoku) {
						count++;
						renzoku = true;
					} else {
						renzoku = false;
					}
				} else {
					renzoku = false;
				}
			}

			System.out.println(count);
		}
	}

	private static boolean check(int[] arr) {
		for (int i = 0; i < arr.length; i++) {
			if (i == arr[i]) {
				return false;
			}
		}

		return true;
	}
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

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

const ll SIZE = 1e5+10;

ll a,b;
string s,t, u;

int main(){
    cin >> s >> t >> a >> b >> u;
    if(u == s) --a;
    else
    {
        --b;
    }
    cout << a << ' ' << b << endl;
    
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const long MOD = 1000000007;
        
        static void Solve()
        {
            var o = ReadAndParseIntArr();
            int n = o[0];
            long k = o[1];

            long ans = k;
            for(int i=0;i<n-1;++i)
            {
                ans *= (k - 1);
            }
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
#include<algorithm>
#include<functional>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<sstream>
#include<iostream>
#include<iomanip>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<climits>

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(itr,data) for(__typeof((data).begin()) itr=(data).begin();itr!=(data).end();++itr)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long UInt64;
typedef long long Int64;

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

using namespace std;

typedef pair<int ,int > P;

int n;
int solve() {
    int max;
    int min;
    int s;
    cin>>s;
    int sum=s;
    max=min=s;
    rep(i,n-1) {
        cin>>s;
        sum+=s;
        max=std::max(max,s);
        min=std::min(min,s);
    }

    sum-=max;
    sum-=min;

    return sum/(n-2);

}

int main() {
    while(cin>>n) {

        if(!n) return 0;

        cout<<solve()<<endl;

    }
    return 0;
}

Measured memory_bytes: 1156
#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

int calc_mul(long a, long b)
{
    return (a * b) % (1000000000 + 7);
}

int calc_fact(long n)
{
    int ret = 1;

    for (int i = 1; i <= n; i++) {
        ret = calc_mul(ret, i);
    }

    return ret;
}

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

    int F = calc_mul(calc_fact(N), calc_fact(M));

    int ret;

    if (abs(N - M) >= 2) {
        ret = 0;
    } else if (abs(N - M) >= 1) {
        ret = F;
    } else {
        ret = calc_mul(2, F);
    }

    printf("%d\n", ret);
}

Measured memory_bytes: 256
n = int(input())
b = list(map(int, input().split()))
amt = b[0] + b[n-2]
for i in range(n-1):
    if i != n-2 and b[i] <= b[i+1]:
        amt += b[i]
    elif i != n-2 and b[i] > b[i+1]:
        amt += b[i+1]
print(amt)

Measured memory_bytes: 3064
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_A main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
#endif

#ifdef _DEBUG
void init_global_A() {}
#else

#endif

int main_A() {
    cin.tie(0);
    ios::sync_with_stdio(false);
     
    int N, A; cin >> N >> A;

    int ans = N * N - A;
    cout << ans << endl;

    return 0;
}

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


typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

#define pb push_back
#define mp make_pair
#define snd second
#define fst first
#define debug printf("--%d--\n",__LINE__)
#define ll long long int

int N, M;
int main(void){
	cin >> N >> M;
	vvi l(N);
	vvi mem(M);
	for(int i=0;i<M;i++){
		vi a;
		mem[i] = a;
	}
	int K[N];
	for(int i=0;i<N;i++){
		cin >> K[i];
		vector<int> a;
		for(int j=0;j<K[i];j++){
			int tmp;
			cin >> tmp;
			a.pb(tmp-1);
			mem[tmp-1].pb(i);
		}
		l.pb(a);
	}
	
	//set<pair<int,int> > s;
	vvi e(N);
	for(int i=0;i<N;i++){vi a; e[i]=a;}
	for(int i=0;i<M;i++){
		for(int j=1;j<mem[i].size();j++){
			//s.insert(mp(mem[i][0], mem[i][j]));
			//s.insert(mp(mem[i][j], mem[i][0]));
			e[mem[i][0]].pb(mem[i][j]);
			e[mem[i][j]].pb(mem[i][0]);
			//cout << mem[i][0] << " " << mem[i][j] << endl;
		}
	}
	
	
	int flg[N] = {0};int cnt = 1;
	queue<int> q;
	q.push(0);flg[0] = 1;
	while(!q.empty()){
		int now = q.front(); q.pop();
		for(int i=0;i<e[now].size();i++){
			if (flg[e[now][i]]==0){
				flg[e[now][i]] = 1;cnt++;
				q.push(e[now][i]);
			}
		}
	}
	if (cnt==N) cout << "YES" << endl; else cout << "NO" << endl;
	
	
	
	return 0;
}


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

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

  if (!(a * b % 2 == 0)) {
    cout << "Odd" << endl;
  }
  else if (a * b % 2 == 0) {
    cout << "Even" << endl;
  }
}


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

using namespace std;

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll A[105];

int main() {
    ll N;
    cin >> N;
    REP(i, N) {
        cin >> A[i];
    }

    ll num = 0;
    while (true) {
        bool exist = false;
        for (ll i = N - 1; i > 0; --i) {
            if (A[i] < A[i - 1]) {
                swap(A[i], A[i - 1]);
                num++;
                exist = true;
            }
        }
        if (!exist)
            break;
    }

    REP(i, N - 1) {
        cout << A[i] << " ";
    }
    cout << A[N - 1] << endl;
    cout << num << endl;
    return 0;
}


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

int main() {
    int n;
    std::cin >> n;

    std::string s;
    std::cin >> s;

    int x = 0;
    std::vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        if(s[i] == 'I') {
            x++;
        } else {
            x--;
        }

        a[i] = x;
    }

    a.push_back(0);

    std::cout << *std::max_element(a.begin(), a.end()) << "\n";
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
/*
int count(int n, int m, int a[], int b[], int f){
    if (f == 1){
        return 0;
    }
    for (int i=0; i<m; i++){
        if (a[i] == n){
            count(b[i],m,a[i],b[i]);
        }else if (b[i] == n){
            count(a[i],m,a[i],b[i]);
        }
    }

}*/

int main(){
    int n,m;
    cin >> n >> m;
    int a[m],b[m];
    for (int i=0;i<m;i++){
        cin >> a[i] >> b[i];
    }
    int array[n-1];
    for (int i=0; i<n-1; i++){
        array[i] = i+2;
    }
    int root[n];
    root[0] = 1;
    int count = 0;
    do{
        for(int i=0; i<n-1; i++){
            root[i+1] = array[i];
        }
        for (int i=0; i<n-1; i++){
            int f = 0;
            for (int j=0; j<m; j++){
                /*cout << root[i];
                cout << a[j];
                cout << root[i+1];
                cout << b[j] << endl;*/
                if (root[i] == a[j]){
                    if (root[i+1] == b[j]){
                        f = 1;
                    }
                }else if (root[i] == b[j]){
                    if (root[i+1] == a[j]){
                        f = 1;
                    }
                }
                //cout << f << endl;
            }
            if (f == 0){
                break;
            }
            if (f == 1 && i == n-2){
                count++;
            }
        }
    }while(next_permutation(array,array+n-1));
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ini(a,i) memset(a,i,sizeof(a))
#define pb push_back
#define ll long long

int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//ll tt;	cin>>tt;	while(tt--)
	{
		ll n,i,j,k;
		cin>>n>>k;
		ll arr[n+1];
		ll dp[n+1];
		ini(dp,1000000);

		for(i=0;i<n;i++)	cin>>arr[i];
		dp[0]=0;
		for(i=1;i<n;i++)
		{
			for(j=i-1;j>=i-k and j>=0;j--)
			{
				dp[i]=min(dp[i],(dp[j]+abs(arr[i]-arr[j])));
			}
		}

		cout<<dp[n-1];
 	
 	}
	cerr<<" Execution : "<<(1.0*clock())/CLOCKS_PER_SEC<<"s \n";
		
		
return 0;
}

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

#define rep(i,n)  for(int i = 0; i < (int)(n); i++)
#define sz(x)     ((int)(x).size())
#define all(x)    (x).begin(),(x).end()

using ll = long long;

ll gcd ( ll a, ll b ) { if ( b == 0 ) return a; else return gcd ( b, a%b ); }
ll lcm ( ll a, ll b ) { return a * b / gcd(a, b); }

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1e9+7;
struct mint {
  typedef long long ll;
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  bool operator>(const mint a) const {
    mint res(*this);
    return res.x > a.x;
  }
  bool operator<(const mint a) const {
    mint res(*this);
    return res.x < a.x;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

constexpr int premax = 200020; 
std::array<mint, premax> f, rf; 
bool mymodflag = false;
mint nCk (int n, int k) {
  if ( n == k ) return mint(1);
  if ( n < k  ) return mint(0);
  if ( !mymodflag ) {
    f[0] = 1; for(int i=1; i<premax; i++) f[i] = f[i-1]*i;
    rf[premax-1] = f[premax-1].pow(mod-2); for(int i=premax-2; i>=0; i--) rf[i] = rf[i+1]*(i+1);
    mymodflag = true;
  }
  return f[n]*rf[n-k]*rf[k];
}

mint nPk (int n, int k) {
  if ( n < k  ) return mint(0);
  if ( !mymodflag ) {
    f[0] = 1; for(int i=1; i<premax; i++) f[i] = f[i-1]*i;
    rf[premax-1] = f[premax-1].pow(mod-2); for(int i=premax-2; i>=0; i--) rf[i] = rf[i+1]*(i+1);
    mymodflag = true;
  }
  return f[n]*rf[n-k];
}


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int n; std::cin >> n;
  std::vector<ll> A(n); rep(i,n) std::cin >> A[i];

  mint tot = 0; rep(i,n) tot += A[i];

  mint ans = 0;
  rep(i,n) {
    mint tmp = A[i];
    ans += tmp * tot;
    ans -= tmp * tmp;
  }
  ans /= 2;
  std::cout << ans.x << std::endl;
  return 0;
}



Measured memory_bytes: 7932
#include <iostream>

using namespace std;
int main(){
    int N;
    cin >>N ;
    double answer;
    int h[N];
    int max = 0;
    int sum = 0;
    for (int i = 0;i<N;i++)
    {
        cin >> h[i];
        if(max < h[i])
        {
            max = h[i];
        }
        sum += h[i];
    }
    if(sum - max > max)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" <<endl;
    }
    
return 0;
}
 

Measured memory_bytes: 256
n_k = list(map(int, input().split()))
n, k = n_k[0], n_k[1]
tree_list = []
for i in range(n):
    tree_list.append(int(input()))
tree_list.sort()
min = 1000000001
for i in range(n-k+1):
    if tree_list[i+k-1]-tree_list[i] <= min:

        min = tree_list[i+k-1]-tree_list[i]
print(int(min))


Measured memory_bytes: 7384
#include "bits/stdc++.h"
#include <string>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
// #define mod  1000000007
#define N 100005
// #define MAX 200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcount
#define PI acos(-1)
//#define endl "\n"
// const int inf = (int)1e18 + 10;
const int mod = 1e9 + 7;

const int inf = 1e15;

int patt[55] , layer[55];
int get(int x , int k ){
  // cout << x << " " << k << endl;
  if(k >= layer[x])
    return patt[x];
  if(k == 0) return 0;
  int y = layer[x-1];
  int p = patt[x-1];
  if(k >= (y + 2))
    return p + 1 + get(x-1 , k - y- 2);
  else if(k == y + 1)
    return p;
  else
    return get(x-1 , k-1 );
}
signed main(){
  fast;
  
  int n , k;
  cin >> n >> k;

  patt[0] = 1;
  layer[0] = 1;
  for(int i= 1 ; i<=n ; i++){
       layer[i] = 2*layer[i-1] + 3;
       patt[i] = 2*patt[i-1] + 1;
  }

  int ans = get(n , k);
  cout << ans << endl;
  


}


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

int main() {
    int cnt = 0;
    string w;
    string x;
    cin >> w;

    transform(w.begin(), w.end(), w.begin(), ::tolower);

    while(1){
        cin >> x;
        if(x == "END_OF_TEXT"){
            break;
        }

        transform(x.begin(), x.end(), x.begin(), ::tolower);

        if (x == w) {
            cnt++;
        }
    }
    cout << cnt << endl;
}



Measured memory_bytes: 3216
///Code Forces - DP Educational Contest


#include <iostream>
#include <string.h>
#include <algorithm>


const int NMAX = 100001;

int h[NMAX];
int DP[NMAX];

int main() 
{
	int N;
	std::cin >> N;

	for (int i = 1; i <= N; ++i) {
		std::cin >> h[i];
	}

	DP[N] = 0;
	DP[N - 1] = std::abs(h[N] - h[N - 1]);

	for (int i = N - 2; i >= 1; --i) {
		int dif1 = std::abs(h[i] - h[i + 1]);
		int dif2 = std::abs(h[i] - h[i + 2]);
		
		int sum1 = dif1 + DP[i + 1];
		int sum2 = dif2 + DP[i + 2];

		DP[i] = std::min(sum1, sum2);
	}

	std::cout << DP[1];

	return 0;
}

Measured memory_bytes: 1024
all_card = []
number = [str(x) for x in range(1,14)]
pattern = ['S','H','C','D']
for i in pattern:
    for j in number:
        card = i + ' ' + j
        all_card.append(card)
n = int(input())
exist = []
for i in range(n):
    exist.append(input())
for i in all_card:
    if i in exist:
        pass
    else:
        print(i)




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

using namespace std;

typedef long long ll;
typedef long double ld;
#define sp(x) fixed<<setprecision(x)
#define pb push_back
#define eb emplace_back
#define MP make_pair
#define die(x) return cout << x << endl, 0
#define fastio ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
const int MAXN = 100 * 1000 + 10;
int n, k, neg;
int a[MAXN][3], dp[MAXN][3];
int main(){
    fastio;
    cin >> n;
    for(int i = 0; i < n; i ++){
        cin >> a[i][0] >> a[i][1] >> a[i][2];
    }
    for(int i = 0; i < 3; i ++)dp[0][i] = a[0][i]/*, cout << 0 << ", " << i << ": " << a[0][i] << '\t'*/;
    //cout << endl;
    for(int i = 1; i < n; i ++){
    	for(int j = 0; j < 3; j ++){
    		dp[i][j] = INT_MIN;
    		//cout << i << ", " << j << ": ";
    		int mx = INT_MIN;
    		for(int k = 0; k < 3; k ++)if(k != j)mx = max(mx, dp[i - 1][k]);
    		//cout << mx << " + " << a[i][j] << '\t';
    		dp[i][j] = mx + a[i][j];
    	}
		//cout << endl;
    }
    die(max(max(dp[n - 1][1], dp[n - 1][2]), dp[n - 1][0]));
    return 0;
}

Measured memory_bytes: 5916
import sys
## io ##
def IS(): return sys.stdin.readline().rstrip()
def II(): return int(IS())
def MII(): return list(map(int, IS().split()))
def MIIZ(): return list(map(lambda x: x-1, MII()))
## dp ##
def DD2(d1,d2,init=0): return [[init]*d2 for _ in range(d1)]
def DD3(d1,d2,d3,init=0): return [DD2(d2,d3,init) for _ in range(d1)]
## math ##
def to_bin(x: int) -> str: return format(x, 'b') # rev => int(res, 2)
def to_oct(x: int) -> str: return format(x, 'o') # rev => int(res, 8)
def to_hex(x: int) -> str: return format(x, 'x') # rev => int(res, 16)
MOD=10**9+7
def divc(x,y) -> int: return -(-x//y)
def divf(x,y) -> int: return x//y
def gcd(x,y):
    while y: x,y = y,x%y
    return x
def lcm(x,y): return x*y//gcd(x,y)
def enumerate_divs(n):
    """Return a tuple list of divisor of n"""
    return [(i,n//i) for i in range(1,int(n**0.5)+1) if n%i==0]
def get_primes(MAX_NUM=10**3):
    """Return a list of prime numbers n or less"""
    is_prime = [True]*(MAX_NUM+1)
    is_prime[0] = is_prime[1] = False
    for i in range(2, int(MAX_NUM**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i*2, MAX_NUM+1, i):
            is_prime[j] = False
    return [i for i in range(MAX_NUM+1) if is_prime[i]]
## libs ##
from itertools import accumulate as acc
from collections import deque, Counter
from heapq import heapify, heappop, heappush
from bisect import bisect_left

#======================================================#

def main():
    a, b, m = MII()
    aa = MII()
    bb = MII()
    q = [MII() for _ in range(m)]
    minv = min(aa) + min(bb)
    for x,y,c in q:
        minv = min(minv, aa[x-1]+bb[y-1]-c)
    print(minv)

if __name__ == '__main__':
    main()

Measured memory_bytes: 38860
package main
import(
  "fmt"
)
func main(){
  var n, i int
  flag:=0
  fmt.Scan(&n)
  a:=make([]int, n)
  for i=0;i<n;i++{
    fmt.Scan(&a[i])
    if a[i]%2==0{
      if a[i]%3==0{
      }else if a[i]%5==0{
      }else{
        flag++
      }
    }
  }
  if flag==0{
    fmt.Println("APPROVED")
  }else{
    fmt.Println("DENIED")
  }
}

Measured memory_bytes: 512
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static final int MOD = (int) (1e9 + 7);

    long moves(long n) {
        if (n == 1) return 1;
        return moves(n / 2) * 2 + 1;
    }

    public void solve(InputReader in, PrintWriter out) {
        long n = in.nextLong();
        out.println(moves(n));
    }

    public static void main(String[] args) {
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        new Main().solve(in, out);
        out.flush();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }
    }
}


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

int main() {
    int N, K;
    cin >> N >> K;
    long ans = pow(N/K, 3);
    if (K%2 == 0) {
        ans += pow((2*N/K+1)/2, 3);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
using namespace std;
vector<int> mp[100001];
int vc[100001],cnt0;
bool dfs(int k,int clr)
{
	vc[k]=clr;
	if (clr==1)
		++cnt0;
	for (size_t i=0;i<mp[k].size();++i)
	{
		if (!vc[mp[k][i]])
		{
			if (!dfs(mp[k][i],3-clr))
				return false;
		}
		else if (vc[mp[k][i]]==clr)
			return false;
	}
	return true;
}
int main()
{
	int n,m;
	scanf("%d%d",&n,&m);
	for (int i=1;i<=m;++i)
	{
		int t1,t2;
		scanf("%d%d",&t1,&t2);
		mp[t1].push_back(t2);
		mp[t2].push_back(t1);
	}
	if (dfs(1,1))
		printf("%lld",(long long)cnt0*(n-cnt0)-m);
	else
		printf("%lld",(long long)n*(n-1)/2-m);
	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    string s,t;
    cin >> s >> t;
    int sn = s.length();
    int tn = t.length();

    map<char, vector<int>> ms;
    REP(i, sn){
        ms[s[i]].pb(i+1);
    }

    ll ans = 0;
    ll n = 0;
    ll id = 0;
    REP(i, tn){
        if(ms[t[i]].size() == 0){
            pr(-1);
            return 0;
        }

        auto it = upper_bound(ALL(ms[t[i]]), id);
        if(it != ms[t[i]].end()){
            id = *it;
        }else{
            n++;
            id = ms[t[i]].front();
        }
    }
    pr(sn*n+id);
}

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

namespace atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = Int32.Parse(Console.ReadLine());
            var tlist = new List < (int x, int y) > ();

            for (var i = 0; i < n; i++)
            {
                var l = Console.ReadLine();
                var list = l.Split(" ");
                var t = (Int32.Parse(list[0]), Int32.Parse(list[1]));
                tlist.Add(t);
            }

            var sums = new List < (int sum, int time) > ();

            tlist.Sort((t1, t2) => t1.y - t2.y);

            int sum = 0;
            for (var i = 0; i < n; i++)
            {
                sum += tlist[i].x;
                if (sum > tlist[i].y)
                {
                    Console.WriteLine("No");
                    return;
                }
            }

            Console.WriteLine("Yes");
        }
    }
}

Measured memory_bytes: 49788
#include <iostream>

int main()
{
  int64_t X, K, D;
  std::cin >> X >> K >> D;
  if (X < 0) X = -X;

  int64_t r;

  //KとDが非常に大きい場合、X-K*Dはint64_tでもオーバーフローするので、X/D-Kで判定する。
  if (X / D - K >= 0)
  {
    r = X - K * D;
  }
  else
  {
    r = X % D;

    if ((K - X / D) % 2 == 1)
    {
      r = D - r;
    }
  }

  std::cout << r << std::endl;

  return 0;
}

Measured memory_bytes: 3572
int_x, int_y = map(int, input().split())

g_a = [1, 3, 5, 7, 8, 10, 12]
g_b = [4, 6, 9, 11]

if int_x in g_a and int_y in g_a:
    print("Yes")
elif int_x in g_b and int_y in g_b:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
#include <algorithm>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

#ifdef __APPLE__
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...)
#endif

const int N = (int)1e6 + 123;
const int MOD = (int)1e9 + 7;
const int inf = (int)5e8;
const long long infll = (long long)1e17;

int a[N];

void solve() {
    int n, k;
    scanf("%d %d", &n, &k);
    map<int, int> cnt;
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        ++cnt[a[i]];
    }
    vector<pair<int, int>> res(cnt.begin(), cnt.end());
    sort(res.begin(), res.end(), [](const pair<int, int>& a, const pair<int, int>& b){ 
        return make_pair(a.second, a.first) > make_pair(b.second, b.first);
    });
    int ans = 0;
    for (size_t i = k; i < res.size(); ++i) {
        ans += res[i].second;
    }
    printf("%u", ans);
}

int main() {
#ifdef __APPLE__
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    int t = 1;
    while (t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 11904