akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define st first
#define nd second
#define pb push_back

typedef long long   ll;
typedef double      db;
typedef long double ldb;

typedef pair <int, int> pii;
typedef pair <ll,  ll>  pll;
typedef pair <ll,  db>  pdb;
typedef pair <ldb, ldb> pldb;

template <typename T>
void   Debug (T begin, T end);
int    si    ();
ll     sl    ();
string ss    (int); 
db     sf    ();
ldb    slf   ();
void   pi    (int, char = '\n');
void   pl    (ll, char = '\n');
void   pf    (db, char = '\n');
void   plf   (ldb, char = '\n');
void   ps    (string, char = '\n');

ll russian(ll, ll, ll);
ll fast_power(ll, ll, ll);
ll slow_power(ll, ll, ll);
ll gcd(ll, ll);
ll lcm(ll, ll);

const int INF  = 1e9;
const ll  LINF = 1e18;

const int N = 2e5 + 7;
int val[N];

int main()
{
    int n = si(), k = si();

    if (k == 1)
        return pi(0), 0;
    
    int sum = 0;
    ll result = 0;

    unordered_map<int, int> M;
    M[0] = 1;

    for (int i = 1; i <= n; ++i) {
        int a = si();
        sum = (sum + a) % k;
        
        int value = ((sum - i) % k + k) % k;
        val[i] = value;
        result += M[value]++;

        if (i - k + 1 >= 0) 
            --M[val[i - k + 1]];    
    }

    pl(result);

    return 0;
}

template <typename T>
void Debug(T begin, T end)
{
    printf("\nDEBUG:\n");
    while (begin != end)
        printf("%d ", *begin),
        begin++;
    printf("\n\n");
}

template <typename T>
T scanf_t(string s)
{
    T a;
    scanf(s.c_str(), &a);
    return a;
}

template <typename T>
void printf_t(T a, string s, char end_l)
{
    s.push_back(end_l);
    printf(s.c_str(), a);
}

int si() { return scanf_t<int>("%d"); }
ll sl() { return scanf_t<ll>("%lld"); }
db sf() { return scanf_t<db>("%f"); }
ldb slf() { return scanf_t<ldb>("%Lf"); }

void pi(int a, char end_l) { printf_t<int>(a, "%d", end_l); }
void pl(ll a, char end_l) { printf_t<ll>(a, "%lld", end_l); }
void pf(db a, char end_l) { printf_t<db>(a, "%lf", end_l); }
void plf(ldb a, char end_l) { printf_t<ldb>(a, "%Lf", end_l); }

void ps(string a, char end_l)
{
    string s = "%s";
    s.push_back(end_l);
    printf(s.c_str(), a.c_str());
}

string ss(int NN)
{
    char T[NN];
    scanf("%s", T);
    return (string)T;
}

ll fast_power(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = (r * a) % m;
        a = (a * a) % m;
        k >>= 1LL;
    }
    return r;
}

ll slow_power(ll a, ll k, ll m)
{
    ll r = 1LL;
    while (k)
    {
        if (k & 1LL)
            r = russian(r, a, m);
        a = russian(a, a, m);
        k >>= 1LL;
    }
    return r;
}

ll russian(ll a, ll k, ll m)
{
    ll r = 0LL;
    while (k)
    {
        if (k & 1LL)
            r = (r + a) % m;
        a = (a + a) % m;
        k >>= 1LL;
    }
    return r;
}

ll gcd(ll a, ll b)
{
    while (b)
        swap(a %= b, b);
    return a;
}

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


Measured memory_bytes: 9288
yes = 0
num = int(input())

for i in range(1, 10, 1):
  if(num%i == 0):
    tmp = int(num/i)
  else:
    continue
      
  if(0 < tmp & tmp < 10):
    yes = 1
    break

if(yes == 1):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 2940
/*
String[]の初期化、整数の型がlongになっているか
関数（splitとかcontainsとか）内では"+"とかは正規表現となされるので"\\+"とする
配列のコピーはarr1=arr.clone()
HashSet<>[]はおのおの初期化した？？？？？
負の数の割り算は絶対値が小さいほうに切り捨てられるex.-1/2=0ので、ある値>kみたいな式だとバグらせやすいので注意
ある値>=kとして、切り上げた値をとるべき
toLowerCase()はアルファベット以外に対して行ってもエラーにはならない
ArrayDequeではpopとpushはStackと同じ操作になる
//import static java.lang.System.*; はしばらく使わなそう(使うとしてもexit(0)のためだけ)←return;でよさそう
最後にout.flush()またはout.close()をするのを忘れずに！
Point2D p2d=new Point2D.Double(d1,d2);
//import static java.lang.System.*;
*/
//入力終了→Ctrl+D
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.geom.Point2D;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        int n=sc.nextInt();
        int m=sc.nextInt();
        long mod=1000000007;
        int[] a=new int[100010];
        for (int i = 0; i < m; i++) {
            a[i]=sc.nextInt();
        }
        long[] dp=new long[100010];
        int index=0;
        dp[1]=1;
        dp[2]=2;
        for (int i = 1; i < n + 1; i++) {
            if(index<m&&a[index]==i){
                dp[i]=0;
                if(i==1){
                    dp[2]=1;
                }
                index++;
            }else if(i>2){
                dp[i]=dp[i-1]%mod+dp[i-2]%mod;
            }
        }
        //out.println(Arrays.toString(dp));
        out.println(dp[n]%mod);
        //out.println(index);
        out.close();
    }

    static PrintWriter out = new PrintWriter(System.out);

    static class sc {
        static Scanner s = new Scanner(System.in);

        static String next() {
            return s.next();
        }

        static String nextLine() {
            return s.nextLine();
        }

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

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

        static double nextDouble() {
            return Double.parseDouble(s.next());
        }

        static boolean hasNext() {
            return s.hasNext();
        }
    }
}

Measured memory_bytes: 45180
d={}
for _ in [0]*int(input()):
    s=input()
    d[s]=d.get(s,0)+1
for _ in [0]*int(input()):
    s=input()
    d[s]=d.get(s,0)-1
print(max(sorted(d.items(), key=lambda x: x[1])[-1][1],0))

Measured memory_bytes: 3060
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
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")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let m = read::<usize>();
    let mut ab = (0..m)
        .map(|_| (read::<usize>(), read::<usize>()))
        .collect::<Vec<_>>();
    ab.reverse();

    let mut parent = vec![0; n + 1];
    for i in 1..n + 1 {
        parent[i] = i
    }
    let mut rank = vec![0; n + 1];

    let mut elems = vec![0; n + 1];
    for i in 0..n + 1 {
        elems[i] = 1;
    }
    let mut ans = n * (n - 1) / 2;
    let mut v = vec![];

    for (a, b) in ab {
        v.push(ans);
        let p1 = find(&parent, a);
        let p2 = find(&parent, b);
        if p1 == p2 {
            // pass
        } else {
            ans -= elems[p1] * elems[p2];

            let root = unite(&mut parent, &mut rank, a, b);
            elems[root] = elems[p1] + elems[p2];
        }
    }

    v.reverse();
    for x in v {
        println!("{}", x)
    }

    fn find(parent: &Vec<usize>, x: usize) -> usize {
        let p = parent[x];
        if p == x {
            x
        } else {
            find(parent, parent[x])
        }
    }

    fn unite(parent: &mut Vec<usize>, rank: &mut Vec<usize>, a: usize, b: usize) -> usize {
        let root_a = find(parent, a);
        let root_b = find(parent, b);
        if rank[root_a] < rank[root_b] {
            parent[root_a] = root_b;
            root_b
        } else if rank[root_a] > rank[root_b] {
            parent[root_b] = root_a;
            root_a
        } else {
            parent[root_b] = root_a;
            rank[root_a] += 1;
            root_a
        }
    }
}


Measured memory_bytes: 10864
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    int a;
    cin>>a;
    cout<<(a+a*a+a*a*a)<<endl;

}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	int n, m, a, b;
	vector<int> v[51];

	cin >> n >> m;
	for (int i = 0; i < m; ++i) {
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for (int i = 1; i <= n; ++i) {
		cout << v[i].size() << endl;
	}

	return 0;
}

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

int main(void){
    int n;
    scanf("%d", &n);
    int b[n+1];
    for(int i = 1;i <= n;i++){
        scanf("%d", &b[i]);
    }
    int j;
    int ans[n+1];
    for(int i = n;i > 0;i--){
        j = i;
        while(1){
            if(b[j]==j){
                ans[i]=j;
                break;
            }else j--;
            if(j==0)break;
        }
        if(j==0)break;
        for(int k = j;k < i;k++){
            b[k] = b[k+1];
        }
    }
    if(j == 0)printf("-1\n");
    else{
        for(int i = 1;i <= n;i++){
            printf("%d\n", ans[i]);
        }
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

int *numArray;

void createArray(int row, int column)
{
	int i;
	numArray = new int[row * column];
	for (i = 0; i < (row * column); i++)
		numArray[i] = 0;
}

void populateArray(int row, int column)
{
	int i, j;
	for (i = 0; i < row - 1; i++)
		for (j = 0; j < column - 1; j++)
			cin >> numArray[i * column + j];
}

void sumArray(int row, int column)
{
	int i, j, rsum = 0, csum = 0;
	for (i = 0; i < row - 1; i++)
	{
		for (j = 0; j < column - 1; j++)
			rsum += numArray[i * column + j];
		numArray[i * column + column - 1] = rsum;
		rsum = 0;
	}

	for (j = 0; j < column; j++)
	{
		for (i = 0; i < row - 1; i++)
			csum += numArray[i * column + j];
		numArray[(row - 1) * column + j] = csum;
		csum = 0;
	}
}

void drawArray(int row, int column)
{
	int i, j;
	for (i = 0; i < row; i++)
	{
		for (j = 0; j < column - 1; j++)
			cout << numArray[i * column + j] << " ";
		cout << numArray[i * column + column - 1] << endl;
	}
}

int main()
{
	int row, column;
	cin >> row >> column;
	createArray(row + 1, column + 1);
	populateArray(row + 1, column + 1);
	sumArray(row + 1, column + 1);
	drawArray(row + 1, column + 1);
	delete[] numArray;
	return 0;
}

Measured memory_bytes: 1232
#include <stdio.h>
#include <utility>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;
typedef long long int ll;
#define F first
#define S second
#define MP make_pair
const int N=5e5+10;
const ll INF=1LL<<60;
ll dis(pi a,pi b){
    ll x=a.F-b.F,y=a.S-b.S;
    return x*x+y*y;
}
int main(){
    int n,lim;
    ll ans=INF;
    pi a[N];
    scanf("%d",&n);
    for(int i=0;i<n;i++)scanf("%d%d",&a[i].F,&a[i].S);
    sort(a,a+n);
    lim=min(300,n);
    for(int i=0;i<lim;i++)for(int j=i+1;j<lim;j++)ans=min(ans,dis(a[i],a[j]));
    for(int i=lim;i<n;i++)for(int j=1;j<lim;j++)ans=min(ans,dis(a[i],a[i-j]));
    printf("%lld\n",ans);
}


Measured memory_bytes: 6592
N = int(input())
Syouhinlist = [input() for i in range(N)]

#sum = 0

Syouhinlist = set(Syouhinlist)
print(len(Syouhinlist))


#for i in range(len(Syouhinlist)):
#    if Syouhinlist.count(Syouhinlist[i]) >= 2 :
#        sum = sum + 1

    
#print(Syouhinlist[i])
#print(sum)


#print(Syouhinlist)

Measured memory_bytes: 35556
# include <iostream>
# include <set>
#include <algorithm>
#include <math.h>
# include<map>
typedef long long ll;
using namespace std;

ll rem(ll num, ll a) {
    while (num >= a) {
        num -= a;
    }
    return num;
}

int main() {
    int a;
    scanf("%d", &a);
    int one=0, three=0, five=0;
    if (a > 0) {
        one = min(9, a);
    }
    if (a > 99) {
        three = min(999, a)-100+1;
    }
    if (a > 9999) {
        five = min(99999, a)-10000+1;
    }
    cout << one+three+five << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define MOD 1000000007
#define INT long long
using namespace std;
int a, b, X, Y;
string s[30][30];
int main()
{
    cin>>a>>b;
    for(int i = 0 ; i < a ; i++ ) for(int j = 0 ; j < b ; j++ ) cin>>s[i][j];
    for(int i = 0 ; i < a ; i++ ) for(int j = 0 ; j < b ; j++ )
        if( s[i][j] == "snuke" ) X = i+1, Y = j;
    printf("%c%d\n", Y+'A', X);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
//#define int long long int
const int MOD = 1000000007;
const ll LINF = (ll)1e18 - 1;
const int INF = 1e9 - 1;
const double EPS = 0.000000001;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

void print(const vector<int> &v) {
  for(auto x : v) {
    cout << x << " ";
  }
  cout << endl;
}

template<typename T>
void warshall_floyd(std::vector<std::vector<T>> &distance, const T INF) {
  for(int k = 0; k < distance.size(); ++k) {
    for(int i = 0; i < distance.size(); ++i) {
      for(int j = 0; j < distance.size(); ++j) {
        if(distance[i][k] == INF || distance[k][j] == INF) continue;
        else distance[i][j] = std::min(distance[i][j], distance[i][k] + distance[k][j]);
      }
    }
  }
}

template<typename T>
bool isBipartiteGraph(const VVI &edges, std::vector<int> &color, const int v, const int c) {
  color[v] = c;
  for(auto u : edges[v]) {
    if(color[u] == c) return false;
    else if(color[u] == 0 && !isBipartiteGraph<T>(edges, color, u, -c)) return false;
  }
  return true;
}


signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  VVI s(n, VI(n));
  VVI edges(n);
  VI color(n, 0);
  rep(i, n) {
    string a;
    cin >> a;
    rep(j, n) {
      if(i == j) s[i][j] = 0;
      else if(a[j] == '0') s[i][j] = INF;
      else {
        s[i][j] = 1;
        edges[i].push_back(j);
      }
    }
  }

  if(isBipartiteGraph<int>(edges, color, 0, 1)) {
    warshall_floyd<int>(s, INF);
    int ans = 0;
    rep(i, n) rep(j, n) {
      if(s[i][j] != INF) ans = max(ans, s[i][j]);
    }
    out(ans + 1);
  }
  else out(-1);

  return 0;
}


Measured memory_bytes: 640
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(S):
    m = [[], [], []]
    for i, s in enumerate(S):
        if s == "R":
            m[0].append(i)
        elif s == "G":
            m[1].append(i)
        else:
            m[2].append(i)

    if len(m[0]) > len(m[1]):
        m[0], m[1] = m[1], m[0]
    if len(m[0]) > len(m[2]):
        m[0], m[2] = m[2], m[0]
    if len(m[1]) > len(m[2]):
        m[1], m[2] = m[2], m[1]

    C = set(m[2])
    ans = len(m[0]) * len(m[1]) * len(m[2])

    for a0 in m[1]:
        for b0 in m[0]:
            if a0 < b0:
                a, b = a0, b0
            else:
                a, b = b0, a0

            c1 = a - (b-a)
            c2 = b + (b-a)

            if c1 in C:
                ans -= 1
            if c2 in C:
                ans -= 1

            if (a+b) % 2 == 0:
                c3 = (a+b) // 2
                if c3 in C:
                    ans -= 1
    return ans


if __name__ == "__main__":

    _ = input()
    S = input()
    ans = solv(S)

    print(ans)


Measured memory_bytes: 9232
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int INF = (int)1e9 + 7;

int main() {
    int n, T; cin >> n >> T;
    int mi = INF;
    for (int i = 0; i < n; i++) {
        int c, t; cin >> c >> t;
        if (t <= T) mi = min(mi, c);
    }
    if (mi == INF) return !(cout << "TLE" << endl);
    cout << mi << endl;
    return 0;
}


Measured memory_bytes: 256
# 入力
S=input()

# a〜z
l=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

for x in l:
  if x not in S:
    print(x)
    exit()

print('None')

Measured memory_bytes: 3188
#include <iostream>
#include <cstdio>

int main()
{
        using namespace std;
        double a,b,c,d,e,f;

        while(cin >> a >> b >> c >> d >> e >> f){
                if((c*e-b*f) == 0 && (a*f-c*d) != 0)printf("%.3f %.3f\n",0.0,(a*f-d*c)/(a*e-b*d));
                else if((a*f-c*d) == 0 && (c*e-b*f) != 0)printf("%.3f %.3f\n",(c*e-b*f)/(a*e-b*d),0.0);
                else if((c*e-b*f) == 0 && (a*e-b*f) == 0) printf("%.3f %.3f\n",0.0,0.0);
                else printf("%.3f %.3f\n",(c*e-b*f)/(a*e-d*b),(a*f-c*d)/(a*e-b*d));
        }

        return 0;
}

Measured memory_bytes: 1236
#include <stdio.h>
int main ()
{
	int x,y,z;
	int count = 0;
	int counter;
	while(scanf("%d %d %d", &x, &y, &z)!=EOF)
	{
		count = 0;
		counter = x;
		while(x >= 1)
		{
			x = x - y - z;
			count++;
			if(x < 2 * z + y)break;
		}
		printf("%d\n",count);
	}
	return 0;
}


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

using namespace std;

typedef long long LL;

const int N = 1010;

int n, a, b;

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

    int res = 0;
    for(int i = 1; i <= n; i++)
    {
        int sum = 0, t = i;
        while(t)
        {
            sum += t % 10;
            t /= 10;
        }
        if(sum >= a && sum <= b) res += i;
    }

    cout << res << endl;
    return 0;
}


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

int main(){
    int N,Y;
    cin >> N >> Y;
    int resX=-1,resY=-1,resZ=-1;
    for (int i = 0; i <= N; i++)
    {
        if(resX!=-1) break;
        if((10*i+5*(N-i))*1000 < Y) continue;
        for (int j = 0; j <= (N-i); j++)
        {
            int k=N-(i+j);
            int sum = (10*i+5*j+k)*1000;
            if(sum>Y) break;
            if(sum!=Y) continue;
            resX=i;
            resY=j;
            resZ=k;
            break; 
        }
    }
    cout << resX << " " << resY << " " << resZ << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vl vector<LL>
#define vii vector<vi>
#define vll vector<vl>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	int n;
    LL ans=0;
    cin>>n;
    FOR(i,1,n+1){
        if(i%5==0||i%3==0){

        }else{
            ans+=i;
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3640
max_n = 1_000_000

is_prime = [false]*2 + [true]*(max_n - 1)

max_loop = Math.sqrt(max_n).floor + 1

2.upto(max_loop) do |i|
  next unless is_prime[i]
  (i*i).step(by:i, to: max_n) do |j|
    is_prime[j] = false
  end
end

count = 0
prime_count = []
0.upto(max_n) do |i|
  count += 1 if is_prime[i]
  prime_count[i] = count
end

while n = gets.to_i
  break if n == 0
  puts prime_count[n]
end

Measured memory_bytes: 32120
n = int(input())
a = list(map(int,input().split()))
ans = 1
a = sorted(a,reverse=True)
if(0 in a):
	print(0)
	exit()
for i in a:
	if(len(str(i)) + len(str(ans)) > 20):
		print(-1)
		exit()
	ans *=i

print(ans if(ans<=pow(10,18)) else -1)

Measured memory_bytes: 21468
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<map>
#include<queue>
#include<set>
#include<bitset>
#include<stdio.h>
#include<deque>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
 
int main()
{
    string s;
    cin >> s;
    set<int> t;
    rep(i, 4){
        t.insert(s[i]);
    }
    if(t.size() == 2){
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}

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

int main()
{
  vector<int> in(5);
  for (int i = 0; i < 5; ++i)
    cin >> in[i];

  sort(in.begin(), in.end(), greater<int>());

  cout << in[0];
  for (int i = 1; i < in.size(); ++i)
    cout << " " << in[i];
  cout << endl;

  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  while(cin>>n){
    if(n==0){return 0;}
    int s[n];
    for(int i=0;i<n;i++){
      cin>>s[i];
    }
    sort(s,s+n);
    int ans=0;
    for(int i=1;i<n-1;i++){
      ans+=s[i];
    }
    cout<<ans/(n-2)<<endl;
  }
  return 0;}

Measured memory_bytes: 3020
import collections 
import math

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

cnt=0
c =collections.Counter(a) #要素の数

#全体の式の導出
#今回は要素ごとの組み合わせの数

for i in c.values() :
    cnt += i*(i-1)//2

#各要素の影響を排除して出力
for i in a:
    print(cnt- c[i]*(c[i]-1)//2 + (c[i]-1)*(c[i]-2)//2)

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

int32_t main(){
	int n;
	cin >> n;
	int arr[n];
	for(int i=0;i<n;i++) cin>>arr[i];
	int answer=0;
	for(int i=1;i<n;i++){
		if(arr[i]<arr[i-1]){
			answer+=arr[i-1]-arr[i];
			arr[i]=arr[i-1];
		}
	}
	cout << answer << endl;
	return 0;
}

Measured memory_bytes: 5104
#include<bits/stdc++.h>
using namespace std;
int sq(int b,int p)
{
	int s=b;
	for(int i=1;i<=p-1;i++)
	{
		s*=b;
	}	
	return s;
}
int main()
{
	int x;
	cin>>x;
	int a[100];
	int l=1;
	memset(a,0,sizeof(a));
	for(int i=2;i<=31;i++)
	{
		for(int j=2;j<=9;j++)
		{
			if(sq(i,j)<=x)
			{
				a[l]=sq(i,j);
				l++;
			}
			else break;
		}
	}
	int max=1;
	for(int i=1;i<=l;i++) if(a[i]>max) max=a[i];
	cout<<max<<"\n";
	return 0; 
}

Measured memory_bytes: 256
int main(int argc, char *argv[])
{
	long S;
	long h;
	long m;
	long s;
	scanf("%ld\n", &S);
	h = S / (60*60);
	m = S % (60*60);
	s = m % 60;
	m = m / 60;
	printf("%d:%d:%d\n", h, m, s);
	return 0;
}

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

int main(){
  int h, w;
  cin >> h >> w;
  int a[h], b[h];
  rep(i,h) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
  }
  set<P> st;
  multiset<int> ms;
  rep(i,w) st.insert(P(i,i));
  rep(i,w) ms.insert(0);
  ms.insert(INF);
  rep(i,h) {
    vector<P> v;
    auto itr = st.lower_bound(P(a[i],0));
    while(itr != st.end() and (*itr).first <= b[i]) {
      v.push_back(*itr);
      itr = st.erase(itr);
    }
    for(auto p : v) ms.erase(ms.find(p.first-p.second));
    if((int)v.size()) {
      P p = v.back();
      if(b[i] < w-1) {
        st.insert(P(b[i]+1,p.second));
        ms.insert(b[i]+1-p.second);
      }
    }
    int ans = *ms.begin();
    cout << (ans == INF ? -1 : ans+i+1) << endl;
  }
  return 0;
}

Measured memory_bytes: 23904
#include <stdio.h>

int main(void){
    int n,x;
    int check_undone=1;
    scanf("%d",&n);
    int i=0;

    for(i=1;i<=n;i++){
        x=i;
        if(x%3==0){
            printf(" %d",i);
            check_undone=0;
        }

        while(check_undone){

            if(x/10==0){
                check_undone=0;
            }

            if(x%10==3){
                printf(" %d",i);
                check_undone=0;
            }else{
                x/=10;
            }
        }
        check_undone=1;
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2044
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

//#include "atcoder/all"
//using namespace atcoder;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int ans = 0, cnt = 0, b = 0;
	rep(i,n){
		int h;
		cin >> h;
		if(b >= h) ++cnt;
		else cnt = 1;
		chmax(ans, cnt);
		b = h;
	}
	--ans;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define ll long long int
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
signed main()
{
    string s;
    cin >> s;
    int best = 1e8;
    rep(i, s.size() - 2) {
        int x = atoi(s.substr(i, 3).c_str());
        if (best > abs(x - 753)) {
            best = abs(x - 753);
        }
    }
    put(best)
    return 0;
}

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

std::vector<std::string> ops;
int a[3];

void consider_next_op(int idx, int n, int *u, int *v) {
  if (idx + 1 >= n) return;
  if (ops[idx] == "AB" && ops[idx + 1] == "BC" || 
      ops[idx] == "AC" && ops[idx + 1] == "BC" ||
      ops[idx] == "BC" && ops[idx + 1] == "AC") {
    std::swap(*u, *v);
  }
}

void solve(int n) {
  std::vector<int> ans;
  bool ok = true;
  for (int i = 0; i < n; ++i) {
    std::string op = ops[i];
    int u, v;
    if (op == "AB") u = 0, v = 1;
    else if (op == "AC") u = 0, v = 2;
    else u = 1, v = 2;
    
    if (a[u] == 0 && a[v] == 0) {
      ok = false;
      break;
    } else if (a[u] == a[v]) {
      consider_next_op(i, n, &u, &v);
    } else if (a[u] > a[v]) {
      std::swap(u, v);
    }
    ++a[u];
    --a[v];
    ans.emplace_back(u);
  }
  if (!ok) {
    std::cout << "No" << std::endl;
  } else {
    std::cout << "Yes" << std::endl;
    for (const auto& val : ans) {
      std::cout << (char)(val + 'A') << std::endl;
    }
  }
}

int main() {
  int n;
  std::cin >> n >> a[0] >> a[1] >> a[2];
  std::string op;
  for (int i = 0; i < n; ++i) {
    std::cin >> op;
    ops.emplace_back(op);
  }
  solve(n);
  return 0;
}


Measured memory_bytes: 7472
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<string.h>
#include<stack>
#include<functional>
using namespace std;

int a[26];
signed main() {
	int b, c; cin >> b >> c;
	for (int d = 0; d < b; d++) {
		string e; cin >> e;
		a[e[0] - 'A']++;
	}
	int ans = 0;
	while (1) {
		sort(a, a + 26, greater<int>());
		for (int i = 0; i < c; i++) {
			if (!a[i]) { cout << ans << endl; return 0; }
			a[i]--;
		}
		ans++;
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;

const int MAX_N = 500005;

int P[MAX_N];

class Segment {
public:
  Segment *ls, *rs;
  int l, r, mx;
  inline Segment() {
    ls = rs = NULL;
  }
  inline int _max(int x, int y) {
    return P[x] > P[y] ? x : y;
  }
  void maintain() {
    mx = _max(ls->mx, rs->mx);
  }
  void build(int L, int R) {
    l = L, r = R;
    if (l == r) {
      mx = l;
      return;
    }
    int mid = (L + R) >> 1;
    if (!ls) ls = new Segment;
    if (!rs) rs = new Segment;

    ls->build(l, mid), rs->build(mid + 1, r);
    maintain();
  }
  int ask(int L, int R) {
    if (L <= l && r <= R)
      return mx;
    int mid = (l + r) >> 1;
    if (mid < L) return rs->ask(L, R);
    else if (mid >= R) return ls->ask(L, R);
    else return _max(ls->ask(L, R), rs->ask(L, R));
  }
  void modify(int pos, int val) {
    if (l == r) {
      P[pos] = val;
      return;
    }
    int mid = (l + r) >> 1;
    if (mid >= pos) ls->modify(pos, val);
    else rs->modify(pos, val);
    maintain();	   
  }
} *rt;

priority_queue<int> q;
int left[MAX_N], right[MAX_N], ans[MAX_N], id[MAX_N], N, K;
bool vis[MAX_N];

void insert(int x) {
  if (vis[x]) return;
  
  int l = max(1, x - K + 1), r = min(N, x + K - 1);
  int tmp2 = rt->ask(l, r);
  if (P[x] != -1 && P[tmp2] <= P[x])
    q.push(x), vis[x] = 1;
}

int main() {

  rt = new Segment;
  
  scanf("%d%d", &N, &K);
  
  for (int i = 1; i <= N; ++i)
    scanf("%d", &P[i]);
  
  rt->build(1, N);

  int tot = 0;
  
  for (int i = 1; i <= N; i += K) {
    ++tot;
    left[tot] = i, right[tot] = min(i + K - 1, N);
    
    for (int j = left[tot]; j <= right[tot]; ++j) id[j] = tot;
						    
    int tmp = rt->ask(left[tot], right[tot]);
    insert(tmp);
  }

  for (int i = N; i; --i) {
    int x = q.top();
    q.pop();
    ans[x] = i, rt->modify(x, -1);
    int le = id[x] - 1, ri = id[x] + 1;
    insert(rt->ask(left[id[x]], right[id[x]]));
    
    if (le >= 1) 
      insert(rt->ask(left[le], right[le]));
    
    if (ri <= tot) 
      insert(rt->ask(left[ri], right[ri]));
  }

  for (int i = 1; i <= N; ++i)
    printf("%d\n", ans[i]);
  return 0;
}

Measured memory_bytes: 62708
### subroutines

def calc_score(ns)
  th = 0

  frsc = Array.new(11){0}

  # 1-9th frame
  for fr in (1..9)
    # first throw
    t1 = ns[th]
    th += 1

    frsc[fr] = t1
    if t1 == 10 # strike
      frsc[fr] += ns[th] + ns[th + 1]
      next
    end

    # second throw
    t2 = ns[th]
    th += 1

    frsc[fr] += t2
    if frsc[fr] == 10   # spare
      frsc[fr] += ns[th]
      next
    end
  end

  # 10th frame
  third = false

  t1 = ns[th]
  th += 1
  frsc[10] = t1
  third = true if t1 == 10

  t2 = ns[th]
  th += 1
  frsc[10] += t2
  third = true if frsc[10] == 10

  if third
    frsc[10] += ns[th]
  end

  total = frsc[1..10].inject(0){|s, c| s + c}

  #p [frsc[1..10], total]
  total
end

### main

while true
  m = gets.strip.to_i
  break if m == 0

  scores = []

  m.times.each do
    ns = gets.strip.split(' ').map{|s| s.to_i}

    sid = ns.shift
    sc = calc_score(ns)

    scores << [sid, sc]
  end

  scores.sort do |a, b|
    cmp = b[1] <=> a[1]
    cmp != 0 ? cmp : a[0] <=> b[0]
  end.each do |scr|
    puts scr.join(' ')
  end
end

Measured memory_bytes: 6132
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
void solve()
{
	int n;
	cin>>n;
	string s1, s2;
	cin>>s1>>s2;
	int i=0, j=0;
	for(int i=0; i<n; i++)
	{
		cout<<s1[i]<<s2[i];	
	}	
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

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

using namespace std;

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

        int h, n;
        cin >> h >> n;
        for (int i = 1; i <= n; i++)
        {
                int x;
                cin >> x;
                h -= x;
                if (h <= 0)
                {
                        cout << "Yes\n";
                        return 0;
                }
        }
        cout << "No\n";
}


Measured memory_bytes: 384
N, K = map(int, input().split())
cnt = [int(x) * 0.5 + 0.5 for x in input().split()]

add = [0]
for i in cnt:
    add.append(add[-1]+i)

ans = [add[i+K]-add[i] for i in range(N-K+1)]

print(max(ans))

Measured memory_bytes: 23524
#include<bits/stdc++.h>
using namespace std ;
int main ()  {
  int N ;
  string S ;
  cin >> N >> S ;
  int ans = 0 ;
  for(int i = 0 ; i < N ; i++ ){
    int A[26] = {} , B[26] = {} ;
    for(int j = 0 ; j < i ; j++ ){
      A[S[j]-'a']=1 ;
    }
    for(int j = i ; j < N ; j++ ){
      B[S[j]-'a']=1 ;
    }
    int pre = 0 ;
    for(int j = 0 ; j < 26 ; j++ ){
      if(A[j]==1&&B[j]==1)pre++;
    }
    ans = max(ans,pre);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp>
    #include <ext/pb_ds/tree_policy.hpp>
    #include <ext/pb_ds/detail/standard_policies.hpp>
    using namespace std;
    using namespace __gnu_pbds;
    #define ll long long
    #define int long long
    #define pb push_back
    #define For(i,n) for(ll  i=0;i<n;i++)
    #define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) ;clock_t clk = clock();
    #define f(a,b,c) for(ll a=b;a<c;a++)
    #define mod 998244353
    #define ld long double
    #define read(t) ll t;cin>>t;
    #define all(x) x.begin(),x.end()
    #define fi first
    #define se second
    #define endl "\n"
    #define pii pair<ll,ll>
    #define what_is(x) cerr << #x << " is " << x << endl;
    #define time cerr << "Time (in ms): " << double(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';
    const double pi=3.14159265358979323846264;
    typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
    typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;

/**********************************************************************************************************************/

signed main()/*Check flow...question galat mat padhna */
{
    fast;   
    ll n;
    cin>>n;
    ll a[n];
    map<ll,ll>mp;
    For(i,n)
    {
        cin>>a[i];
        mp[a[i]]++;
    }
    ll ans=0;
    map<int, int>::iterator x;
    for(x=mp.begin();x!=mp.end();x++)
    {
        if(x->se>=2)
        {
            ans+=(x->se*(x->se-1))/2;
        }
    }
    For(i,n)
    {
        ll z=mp[a[i]];
        z--;
        cout<<ans-z<<endl;
    }
    cout<<endl;
}      

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

int main(void) {
    string s;
    string t;

    cin >> s;
    cin >> t;

    if (s == string(t.begin(), t.end() - 1) && t.size() == s.size() + 1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

Measured memory_bytes: 3632
x,n = map(int,input().split())
if n==0: exit(print(x))
p = list(map(int,input().split()))
p.sort()
if x not in p: exit(print(x))
h=101
l=0
for i in range(x,101):
    if i not in p:
        h = i
        break
for i in range(x,0,-1):
    if i not in p:
        l = i
        break
if abs(x-h)>=abs(x-l): print(l)
if abs(x-l)>abs(x-h): print(h)


Measured memory_bytes: 9212
import java.util.*;

public class Main{

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		String T = sc.next();
		String str ="";
		
		for(int i=0; i<N; i++){
			String strS = S.substring(i,i+1);
			String strT = T.substring(i,i+1);
			
			str += (strS + strT);
		
		}
			System.out.println(str);
	}
}

Measured memory_bytes: 21844
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {

	int N;
	int[] a;
	List<Integer> list;

	private class Node{
		Node prev,next;
		int value;
		public Node(int value){
			this.value = value;
			prev = null;
			next = null;
		}
	}

	public void solve() {
		N = nextInt();
		a = new int[N];
		for(int i = 0;i < N;i++){
			a[i] = nextInt();
		}

		Node first = new Node(-1);
		Node last = new Node(-1);
		first.next = last;
		last.prev = first;

		int count = N % 2;
		for(int i = 0;i < N;i++){
			Node node = new Node(a[i]);
			if(count % 2 == 0){
				Node prevNode = last.prev;
				node.next = last;
				node.prev = prevNode;
				last.prev = node;
				node.prev.next = node;
			}else{

				Node nextNode = first.next;
				first.next = node;
				node.next = nextNode;
				node.prev = first;
				node.next.prev = node;
			}
			count++;
		}


		Node node = first.next;
		for(int i = 0;i < N && node != null;i++,node = node.next){
			if(i != 0)out.print(" ");
			out.print(node.value);
		}
		out.println();
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 49208
#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int cnt = 0;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int sum = accumulate(begin(a), end(a), 0);
    for(int i = 0; i < n; i++){
        if((double)sum / (4 * m) <= a[i]){
            cnt++;
        }
    }
    cout << ((cnt >= m)? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
    int x[1000] ={0},y[1000] = {0};
    int n;
    int a = 0,b = 0;

    while(scanf("%d",&n)!=EOF){
        if(n == 0){
            x[a] = y[b-1];
            b--;
            ++a;
        }
        else {
            y[b] = n;
            b++;
        }
    }
    for(int i = 0;i < a; i++)printf("%d\n",x[i]);

    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>

#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vec vector<int>
#define vecll vector<ll>

using namespace std;
///////////////////////////////////////////////////////////



int main() {
    int n, l;
    cin >> n >> l;

    vector<string> v;
    string x;
    rep(i,n) {
        cin >> x;
        v.push_back(x);
    }

    sort(v.begin(), v.end());
    rep(i,n)
        cout << v[i];
    cout << endl;


    return 0;
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <tuple>
#include <algorithm>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

struct C1 {
    vector<ll> v_{};
    explicit C1(vector<ll> v) : v_(move(v)){
        std::sort(v_.begin(), v_.end());
    }
    double divBy2(double x, ll times) {
        double y = x;
        for (ll i=0; i < times; ++i) {
            y = y / 2.0;
        }
        return y;
    }
    double resolve() {
        double t = 0.0;
        ll N = v_.size();
        for(ll i = 0; i < N; ++i) {
            double x = v_[i];
            ll times = (i == 0 || i == 1) ? N-1 : N-i;
            t += divBy2(x, times);
        }
        return t;
    }
};

int main() {
    ll N;
    cin >> N ;
    vector<ll> v{};
    for (int i=0; i < N; ++i) {
        ll x;
        cin >> x;
        v.emplace_back(x);
    }
    C1 c{move(v)};
    cout.precision(12);
    cout << c.resolve() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

    if (a == b) {
        cout << c << endl;
    } else if (a == c) {
        cout << b << endl;
    } else {
        cout << a << endl;
    }
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

if N == 2:
  print(max(A[0], A[1]))
  exit()

DP = [[- 10 ** 10] * 3 for _ in range(N)]

DP[0][0] = A[0]
DP[1][0] = A[1]
DP[2][0] = A[0] + A[2]
DP[2][1] = A[2]

for i in range(3, N):
  DP[i][0] = DP[i - 2][0] + A[i]
  DP[i][1] = DP[i - 2][1] + A[i]
  DP[i][2] = DP[i - 2][2] + A[i]
  if i - 3 >= 0:
    DP[i][1] = max(DP[i][1], DP[i - 3][0] + A[i])
    DP[i][2] = max(DP[i][2], DP[i - 3][1] + A[i])
  if i - 4 >= 0:
    DP[i][2] = max(DP[i][2], DP[i - 4][0] + A[i])

ans = 0

if N % 2 == 0:
  ans = max(DP[-1][0], DP[-1][1])
  ans = max(ans, DP[-2][0])
else:
  ans = max(DP[-1][1], DP[-1][2])
  ans = max(ans, DP[-2][0])
  ans = max(ans, DP[-2][1])
  ans = max(ans, DP[-3][0])

print(ans)

Measured memory_bytes: 114108
// C.

#include <iostream>
#include <sstream>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	cout.precision(20);
	double a, b, h, m, r;
	cin >> a >> b >> h >> m;
	r = ((h+m/60) / 12.0) * 2.0 * M_PI;
	double hx = a * sin(r), hy = a * cos(r);
	r = (m / 60.0) * 2.0 * M_PI;
	double mx = b * sin(r), my = b * cos(r);
	double ans = sqrt((hx - mx) * (hx - mx) + (hy - my) * (hy - my));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4088
#include<bits/stdc++.h>
using namespace std; int d[11], n, m, i, a, b, sum, e;
int main() {
	while (true) {
		memset(d, 0, sizeof(d)); sum = 0;
		cin >> n >> m; if (!n) { break; }
		for (i = 0; i < n; i++) {
			cin >> a >> b;
			d[b] += a;
		}
		for (i = 10; i >= 0;i--){
			e = min(d[i], m);
			m -= e;
			sum += i*(d[i] - e);
		}
		cout << sum << endl;
	}
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){

  int n, m;
  cin >> n >> m;
  vii g(n);
  rep(i,m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vi ans(n,inf);
  ans[0] = 0;
  queue<int> q;
  q.push(0);
  while(sz(q)) {
    int v = q.front(); q.pop();
    for(int nv : g[v]) {
      if(ans[nv] != inf) continue;
      ans[nv] = v;
      q.push(nv);
    }
  }
  YesorNo(1);
  REP(i,n) cout << ans[i]+1 << endl;
}

Measured memory_bytes: 10208
#include<iostream>
#include<string>
#include<set>
using namespace std;
bool used[26] = {};
set<string> ans;
 
void dec(string &s, int d = 0){
  if(d == s.length()){
    ans.insert(s);
    return;
  }
  if(s[d] == 'z' or s[d] == 'a'){
    if(s[d] == 'z'){
      if(used[s[d] - 'a'])dec(s, d + 1);
      else return;
    }else {
      dec(s, d + 1);
      if(used[s[d] - 'a' + 1] == false){
        s[d]++;
        used[s[d] - 'a'] = true;
        dec(s, d + 1);
        used[s[d] - 'a'] = false;
        s[d]--;
      }
    }
  }else{
    if(used[s[d] - 'a' + 1] == false){    
      s[d]++;
      used[s[d] - 'a'] = true;
      dec(s, d + 1);
      used[s[d] - 'a'] = false;
      s[d]--;
    }
    if(used[s[d] - 'a'] == true){
      dec(s, d + 1);
    }
  }
}
 
int main(){
  string s;
  while(std::cin >> s, s != "#"){
    if(s == "z"){
      std::cout << 0 << std::endl;
      continue;
    }
    ans.clear();
    int n = s.length();
    dec(s);
    std::cout << ans.size() << std::endl;
    if(ans.size() <= 10){
      for (auto a: ans)std::cout << a << std::endl;
    }else{
      auto a = ans.begin();
      for (int i = 0; i < 5; i++, a++) std::cout << (*a) << std::endl;
      a = ans.end();
      for (int i = 0; i < 5; i++) a--;
      for (; a != ans.end(); a++) std::cout << (*a) << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 5076
#include <bits/stdc++.h>
using namespace std;
int main(){
    int m1, d1, m2, d2;
    cin >> m1 >> d1 >> m2 >> d2;
    
    if (m1 == m2) {
        cout << '0' << endl;
    } else {
        cout << '1' << endl;
    }
}

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

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main()
{
  int N;
  cin >> N;
  vector<int> C(N);
  REP(i, N)
  cin >> C[i];
  vector<ll> dp(200020, 0);
  vector<ll> last(200020, -1);
  dp[0] = 1;
  REP(i, N)
  {
    dp[i + 1] = dp[i];
    if (last[C[i]] != -1 && last[C[i]] != i - 1)
    {
      dp[i + 1] += dp[last[C[i]] + 1];
      dp[i + 1] = dp[i + 1] >= MOD ? dp[i + 1] - MOD : dp[i + 1];
    }
    last[C[i]] = i;
  }
  cout << dp[N] << endl;
  return 0;
}

Measured memory_bytes: 4096
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<utility>
#include<functional>
#include<stack>
#include<queue>
#include<cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef std::pair<int, int> int_pair;
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }


int main() {

	int n = 0;
	int t = 0, a = 0;
	int h[1000] = {};
	pair<double, int> p[1000];
	cin >> n >> t >> a;
	rep(i, n) {
		cin >> h[i];
	}
	rep(i, n) {

		p[i].second = i + 1;
		p[i].first = abs(a - (t - (h[i] * 0.006)));

	}

	sort(p, p + n);

	cout <<p[0].second << endl;
	
	return 0;
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

//gcdをユークリッド互除法で求める。O(log n)
int euclid(int x, int y){
    if(min(x, y) ==  0) return max(x, y);
    else return euclid(max(x, y)% min(x, y) , min(x, y));
}
//

int main() {
	int ans = 0;
	int tmp;
	int n; cin>> n;
	vector<int> a(n);
	REP(i, n) cin >> a[i];
	int l[n], r[n];
	REP(i, n){
		if(i == 0) l[i] = a[i];
		else l[i] = euclid(l[i-1], a[i]);
	}
	for(int i= n-1; i>=0; i--){
		if(i == n-1) r[i] = a[i];
		else r[i] = euclid(r[i+1], a[i]);
	}
	REP(i, n){
		if(i == 0) ans = max(ans, r[i+1]);
		else if(i == n-1) ans = max(ans, l[i - 1]);
		else ans = max(ans, euclid(l[i-1], r[i+1]));
	}

	cout << ans << endl;
}

Measured memory_bytes: 1408