akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)
#define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__)

#ifdef DEBUG
#define dump(...) dump_(#__VA_ARGS__, __VA_ARGS__);
#else
#define dump(...)
#endif

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// input
void input() {}
template <class Head, class... Tail>
void input(Head&& head, Tail&&... tail) {
  cin >> head;
  input(forward<Tail>(tail)...);
}

// outs
void outs() {}
template <class Head, class... Tail>
void outs(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  outs(forward<Tail>(tail)...);
}

template <class T>
void outs(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void outs(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// outl
void outl() {}
template <class Head, class... Tail>
void outl(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  outl(forward<Tail>(tail)...);
}

template <class T>
void outl(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// outn
void outn() {}
template <class Head, class... Tail>
void outn(Head&& head, Tail&&... tail) {
  cout << head;
  outn(forward<Tail>(tail)...);
}

template <class T>
void outn(vector<T> &vec) { for (auto &e : vec) cout << e; }

// dump
template <class T>
void dump_(const char *s, T&& x) {
  clog << '{';
  while(*s != '\0') clog << *(s++);
  clog << ": " << x << '}' << "\n";
}

template <class Head, class... Tail>
void dump_(const char *s, Head&& head, Tail&&... tail) {
  clog << '{';
  while(*s != ',') clog << *(s++);
  clog << ": " << head << "}, ";
  for (++s; !isgraph(*s); ++s);
  dump_(s, forward<Tail>(tail)...);
}
// }}} End

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  var(string, s);

  int year = stoi(s.substr(0, 4));
  int month = stoi(s.substr(5, 2));
  int day = stoi(s.substr(8, 2));

  if (year <= 2019 && month <= 4 && day <= 30) outl("Heisei");
  else outl("TBD");

  return 0;
}


Measured memory_bytes: 256
use std::io::stdin;

fn main() {
    let mut x = String::new();
    stdin().read_line(&mut x).unwrap();
    let n: usize = x.trim().parse().unwrap();

    let mut tasks: Vec<(_, _)> = (0..n).map(|_| {
        let mut x = String::new();
        stdin().read_line(&mut x).unwrap();
        let x: Vec<isize> = x.trim().split_whitespace().flat_map(str::parse).collect();
        (x[1], x[0])
    }).collect();
    tasks.sort();

    let mut current_time = 0;
    for (l, d) in tasks.into_iter() {
        current_time += d;
        if current_time > l {
            println!("No");
            return;
        }
    }
    println!("Yes");
}


Measured memory_bytes: 10492
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#include <array>
#include <vector>
#include <queue>
#include <stack>
#include <numeric>
#include <list>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int, int>PII;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), rend()
#define PB pushback
#define SORT(c) sort((c).begin(),(c).end())

const LL INF = 1LL << 60;

//priority_queue<int> p;

int i, j, k, tmp, ans, cnt, N, m;
string s;

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

//printf("%d", ans);

//cout <<  << endl;

/*------------------------------------------
	関数名：chmin
	機　能：aとbの小さいほうをaに代入する
	引　数：a b
	戻り値：true = bが小さい false aが小さい
-------------------------------------------*/
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}


int main(void) {
	cin >> s;
	REP(i, s.size()) {//←黒パターン
		if ((i & 1) == 0) {
			if (s.at(i) == '1') {
				cnt++;
			}
		}
		else {
			if (s.at(i) == '0') {
				cnt++;
			}
		}
	}
	ans = cnt;
	cnt = 0;
	REP(i, s.size()) {//←白パターン
		if ((i & 1) == 1) {
			if (s.at(i) == '1') {
				cnt++;
			}
		}
		else {
			if (s.at(i) == '0') {
				cnt++;
			}
		}
	}

	chmin(ans, cnt);

	printf("%d", ans);
	
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
//最大公約数　最小公倍数はa*b/GCD(a,b)
int64_t GCD(int64_t a,int64_t b){
    return b == 0 ? a : GCD(b, a % b);
   
}
int64_t LCM(int64_t a,int64_t b)
{
    return a / GCD(a, b) * b;
}
int64_t pow2(int64_t t){
    if(t==0){
        return 1;
    }
    else{
        return 2*pow2(t-1);
    }
} 
int main(){
    int64_t n,m;
    cin >> n >> m;
    vector<int64_t> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
        a[i] = a[i]/2;
    }
    sort(a.begin(), a.end());
    int64_t lcmm = a[0];
    for(int i=1; i<n; i++){
        lcmm = LCM(lcmm, a[i]);
    }
    int count=0;
    int t = a[0];
    while(t%2==0){
        t = t/2;
        count++;
    }
    //cout << count <<endl;
    for(int i=1;i<n;i++){
        if(a[i]% pow2(count+1)==0){
            cout << 0 << endl;
            return 0;
        }
    }
    //最小公倍数15⇒15,45がそう
    int64_t ans;
    ans = (m/lcmm+1)/2;
    cout << ans << endl;
    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e15;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    for(int n = 1; n <= 3500; n++){
        for(int w = 1; w <= 3500; w++){
            int a = n * w * N;
            int b = 4 * n * w - N * (w + n);
            if(b != 0 && a % b == 0){
                int h = a / b;
                if(0 < h && h <= 3500){
                    cout << h << ' ' << n << ' ' << w << endl;
                    return 0;
                }
            }
        }
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>
#include <set>

using namespace std;
using ll = long long;
const int MOD = 1000000007;
const ll INF = 1LL << 60;

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

vector<vector<int> > vvi;
vector<vector<vector<int> > > vvvi;

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; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }


int main(int argc, char**argv){
    string s, t;
    cin >> s >> t;
    int ns = s.size(), nt = t.size();
    int dp[ns+1][nt+1];

    for (int i = 0; i <= ns; i++){
        for (int j = 0; j <= nt; j++){
            dp[i][j] = 0;
        }
    }

    for (int i = 0; i < ns; i++){
        for (int j = 0; j < nt; j++){
            if (s[i] == t[j]) chmax(dp[i+1][j+1], dp[i][j] + 1);
            chmax(dp[i+1][j+1], dp[i+1][j]);
            chmax(dp[i+1][j+1], dp[i][j+1]);
        }
    }

    // for (int i = 0; i <= ns; i++){
    //     for (int j = 0; j <= nt; j++){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }

    string res = "";
    int i = ns, j = nt;
    while (i > 0 && j > 0){
        if (dp[i][j] == dp[i-1][j]){
            i--;
        }else if(dp[i][j] == dp[i][j-1]){
            j--;
        }else{
            i--;
            j--;
            res = s[i] + res;
        }
    }
    cout << res << endl;

    return 0;
}


Measured memory_bytes: 35456
n,m=io.read("*n","*n")
c,d={},{}
for i=1,m do
	local a,b=io.read("*n","*n")
	if a==1 then c[b]=true end
	if b==n then d[a]=true end
end
for i,_ in pairs(c)do
	if d[i]~=nil then
		print("POSSIBLE")
		os.exit()
	end
end
print("IMPOSSIBLE")

Measured memory_bytes: 6116
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
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; }
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    int a,b,c; cin>>a>>b>>c;
    cout<<(a*b)/2<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int x, y;
    int min, max;
    for(int i=1;i<10001;i++) {
        cin >> x >> y;
        if (x == 0 && y == 0) {
            break;
        }
        if (x >= y) {
            min = y;
            max = x;
        } else {
            min = x;
            max = y;
        }
        printf("%d %d\n", min, max);
    }
    return 0;
}


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

int main(){
    int N, M;
    cin >> N >> M;
    priority_queue<int> pq;
    int sum = 0;
    rep(i,N){
        int A;
        cin >> A;
        sum += A;
        pq.push(A);
    }
    bool flg = true;
    rep(i,M){
        int thres;
        if (sum%(4*M)==0) thres=sum/(4*M);
        else thres=sum/(4*M)+1;
        if (pq.top()<thres){
            flg = false;
            break;
        }
        else{
            pq.pop();
        }
    }
    if (flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int x,a,b;cin >> x >> a >> b;
	x-=a;
	x%=b;
	cout << x << endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

//Taro's Obsession
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		int m = sc.nextInt(), n = sc.nextInt();
		boolean[][] e = new boolean[m+1][m+1];
		int[] deg = new int[m+1];
		while(n--!=0){
			int x = sc.nextInt(), y = sc.nextInt();
			e[y][x] = true;
			deg[y]++;
		}
		for(int i=0;i<m;i++){
			for(int j=1;j<=m;j++)if(deg[j]==0){
//				if(i!=m-1 && j==2)continue;
				System.out.println(j);
				deg[j] = -1;
				for(int k=1;k<=m;k++)if(e[k][j])deg[k]--;
			}
		}
	}
	
	void debug(Object...o){
		System.out.println(Arrays.deepToString(o));
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 18396
n = int(input())
s = input()

ans = 0
for i in range(len(s)):
    l = [s[j] for j in range(i + 1)]
    m = []
    for j in range(i + 1, len(s)):
        if s[j] in l and s[j] not in m:
            m.append(s[j])
    ans = max(ans, len(m))

print(ans)


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

using namespace std;

#define fore(i, s, e) for(int i = s; i < e; i++)
#define fore_(i, s, e) for(int i = s; i > e; i--)
#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

/*

What's the DP?

The DP in position i tells us: "The maximum path length starting from vertex i"


*/

vector<int> v[100001];
int dp[100001];
int n, m, r;
int a, b;

int solve(int pos) {
    
    if(!v[pos].size()) return 0;
    if(dp[pos] > -1) return dp[pos];

    int ret = 1;

    fore(i, 0, v[pos].size()) {
        ret = max(ret, 1 + solve(v[pos][i]));
    }

    dp[pos] = ret;
    return ret;
}

int main() {
    FIN;
    memset(dp, -1, sizeof(dp));

    cin >> n >> m;
    fore(i, 0, m) {
        cin >> a >> b;
        v[--a].pb(--b);
    }

    fore(i, 0, n) r = max(r, solve(i));
    cout << r << endl;

    return 0;
}

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

class Program {
    static void Main (string[] args) {
        int x = int.Parse (Console.ReadLine ());
        if (x >= 1800) {
            Console.WriteLine (1);
        } else if (x >= 1600) {
            Console.WriteLine (2);
        } else if (x >= 1400) {
            Console.WriteLine (3);
        } else if (x >= 1200) {
            Console.WriteLine (4);
        } else if (x >= 1000) {
            Console.WriteLine (5);
        } else if (x >= 800) {
            Console.WriteLine (6);
        } else if (x >= 600) {
            Console.WriteLine (7);
        } else {
            Console.WriteLine (8);
        }

    }

}

//dotnet run --project test

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

int w, n;
std::vector<int> ans;

int main() {
    int i = 0;

    std::cin >> w;
    std::cin >> n;

    ans.resize(w);
    for(i = 0; i < w; ++i) {
        ans[i] = i;
    }
    for(i = 0; i < n; ++i) {
        int a, b;
        char c;
        
        std::cin >> a >> c >> b;
        --a, --b;
        std::swap(ans[a], ans[b]);
    }
    for(int x: ans) {
        std::cout << x + 1 << std::endl;
    }
}


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

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int n,r;
  while(cin>>n>>r&&n&&r)
  {
    vi card(n);
    rep(i,n) card[i]=i;
    rep(i,r)
    {
      int p,c; cin>>p>>c;
      rep(k,c)
      {
        rep(j,p-1)
        {
          if(p==1) continue;
          swap(card[n-p-k],card[n-1-j-k]);
        }
      }
    }
    print(card[n-1]+1);
  } 

  return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define MAX(a,b) (a>b? a:b)
#define MIN(a,b) (a>b? b:a)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repr(i,n) for(lint i=(lint)(n);i>0;--i)
#define reps(i,a,b) for(lint i=a;i<=(lint)(b);i++)
typedef long long lint;
typedef long double ld;
using namespace std;

lint ext_gcd(lint a, lint b, lint &x, lint &y){
	if(b==0) {
		x=1;
		y=0;
		return a;
	}
	lint q=a/b;
	lint g=ext_gcd(b,a-q*b,x,y);
	lint z=x-q*y;
	x=y;
	y=z;
	return g;
}

int main(){
lint A, B, K, x, y;
cin >> A >> B >> K;
lint d = ext_gcd(A,B,x,y);
int cnt = 0;
int n=d;
while(1) {
if(d%n==0) cnt++;
if(cnt==K) break;
n--;
}
cout << n << endl;
return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int h,w,k;cin>>h>>w>>k;
    int si,sj,gi,gj;
    cin>>si>>sj>>gi>>gj;
    si--,sj--,gi--,gj--;
    string s[h];
    rep(i,h) cin>>s[i];

    int dis[h][w];
    rep(i,h)rep(j,w)dis[i][j]=INF;
    queue<pair<int,int>> que;
    dis[si][sj]=0;que.push({si,sj});
    
    auto check=[&](int i,int j){
        return 0<=i and i<h and 0<=j and j<w and s[i][j]!='@';
    };


    // 各頂点，各方向の一番近い場所からしか流入しないので間に合う
    while(!que.empty()){
        auto p=que.front();que.pop();
        int i=p.first,j=p.second;
        rep(t,4){
            for(int d=1;d<=k;d++){
                int ni=i+d*dx[t],nj=j+d*dy[t];
                if(!check(ni,nj)) break;
                if(dis[i][j]>=dis[ni][nj]) break;
                if(dis[ni][nj]==INF){
                    dis[ni][nj]=dis[i][j]+1;
                    que.push({ni,nj});
                }
            }
        }
    }
    cout<<(dis[gi][gj]==INF?-1:dis[gi][gj])<<endl;
    return 0;
}


Measured memory_bytes: 9552
#include <iostream>
using namespace std;
 
int main(void){
 
  /* 文字列 */
  string s1,s2,s3;
 
  /* 英数字を入力 */
  cin>>s1>>s2>>s3;
 
  /* アルファベットの頭文字を大文字に変換 */
  
      s1[0]=s1[0]-32;
      s2[0]=s2[0]-32;
      s3[0]=s3[0]-32;
      
  
  cout<<s1[0]<<s2[0]<<s3[0]<<endl;
  return 0;
}


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

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

  vector<int> a(n), cnt(n);
  for(int i=0;i<n;i++)cin >> a[i];

  for(int i=0;i<m;i++){
    int b;
    cin >> b;
    for(int j=0;j<n;j++){
      if(a[j]<=b){
	cnt[j]++; break;
      }
    }
  }

  int id = 0;
  for(int i=0;i<n;i++){
    if(cnt[i] > cnt[id])id = i;
  }
  cout << id+1 << endl;
}

Measured memory_bytes: 1200
/*
[agc031] B - Reversi
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 2e5;
const int MAX_C = 2e5;
const ll MOD = 1e9 + 7;

int N;
int C[MAX_N];
ll dp[MAX_N];

ll solve() {
    int last[MAX_C];
    memset(last, -1, sizeof(last));
    last[C[0]] = 0;
    dp[0] = 1;
    for (int i = 1; i < N; i++) {
        dp[i] = dp[i - 1];
        if (0 <= last[C[i]] && last[C[i]] < i - 1) {
            (dp[i] += dp[last[C[i]]]) %= MOD;
        }
        last[C[i]] = i;
    }

    return dp[N - 1];
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> C[i];
        C[i]--;
    }

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int n, h, w;
  cin >> n >> h >> w;
  int ans = (n - h + 1) * (n - w + 1);
  cout << ans << endl;
}

Measured memory_bytes: 256
// pck2016 パンケーキ
#include <iostream>
using namespace std;
int main(void){
    int N,p[5001],copy[5001],min=10000000;
    cin >> N;
    for(int i=1;i<=N;i++){
        cin >> p[i];
    }
    int count=0;
    for(int test=0;test<=p[1];test++){
        copy[1]=p[1]-test;
        count=test;
         for(int i=1;i<N;i++){
            copy[i+1]=p[i+1];
            if(copy[i]>0){
                count+=copy[i]*2;
                copy[i+1]-=copy[i];
            }
        }
        if(copy[N]>0)count+=copy[N];
        if(count<min)min=count;
    }
    cout << min << endl;
}



Measured memory_bytes: 3140
#include<cstdio>

#define R(i, n) for(int i = 0; i < n; i++)
#define RR(i, n) for(int i = n; i >= 0; i--)
#define F(i, m, n) for(int i = m; i < n; i++)
#define FR(i, m, n) for(int i = m; i >= n; i--)
#define S(a) scanf("%d", &a)
#define S2(a, b) scanf("%d%d", &a, &b)
#define S3(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define P(a) printf("%d\n", a)
using namespace std;

int K, X;

int main(){
	S2(K, X);
	int money = 500 * K;

	if(money >= X){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
};

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

int main()
{
    char pre;
    stack<char> st;
    char ch;
    while((ch = getchar()) != '\n')
        st.push(ch),pre = ch;
    char ttp;
    int cnt = 0;
    while(!st.empty())
    {
        ttp = st.top();
        st.pop();
        if(ttp != pre)
        {
            pre = ttp;
            ++cnt;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


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

int main(){
	int n, ans;
	double t, a, h, dif, min_dif;
	cin >> n >> t >> a;
	min_dif = 100000;
	for(int i=0; i<n; i++){
		cin >> h;
		dif = abs(a - (t - h*0.006));
		if(min_dif > dif){
			min_dif = dif;
			ans = i;
		}
	}
	cout << ans+1 << endl;
	return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
# include <cstdio>
# include <cstring>
# include <cmath>

using namespace std;

typedef long long LL;

int main ()
{
    LL n;
    cin >> n;
    if ((n-1)%2==0)
    cout<<(n-1)/2*n;
    else
    cout<<n/2*(n-1);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

ll man(ll x,ll y, ll s, ll t){
    return abs(x-s)+abs(y-t);
}

void solve() {
    ll N;
    cin >> N;
    vll A(N);
    map<ll,ll> counter;
    rep(i,N){
        cin >> A[i];
        counter[A[i]]++;
    }
    ll ans = 0;
    ll even = 0;
    for(auto co:counter){
        ans++;
        if(co.sc%2==0){
            even++;
        }
    }
    if(even%2){
        ans--;
    }
    print(ans);

}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 10140
n, m, X = map(int, input().split())

A = [[] for _ in range(n)]
c = [0] * n

for i in range(n):
    c_as = list(map(int, input().split()))
    c[i], A[i] = c_as[0], c_as[1:]

INF = 10**9
ans = INF
    
for s in range(0, 1 << n):
    smart = [0] * m
    cost_sum = 0
    for i in range(n):
        if (s >> i) % 2 == 0:continue
        cost_sum += c[i]
        for j in range(m):
            smart[j] += A[i][j]
    ok = True
    for j in range(m):
        if smart[j] < X:
            ok = False
    if ok:
        ans = min(ans, cost_sum)

if ans == INF:
    ans = -1

print(ans)
        
    

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
 
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
 
 
#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/
 
// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    for (T& x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}
#ifdef DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif


 
signed main() {
    int N;
    cin >> N;
    vector<int> H(N);
    rep(i,N) cin >> H[i];
    
    for(int i=N-1; i>=1; i--)
    {
        if(H[i-1]==H[i]+1) H[i-1]--;
        else if(H[i]<H[i-1]) { No; return 0;}
    }
    Yes;
    
    return 0;
}


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

int main()
{
    //箱の中に入っているボールの数と目的のボールの数
    int R, G, B, N;
    cin >> R >> G >> B >> N;
    //答え
    int ans = 0;

    //箱の数r(赤のボールが入った箱), g(緑のボールが入った箱)
    for (int r = 0; r <= N; r++)
    {
        for (int g = 0; g <= N; g++)
        {
            //赤と緑のボールの数の合計
            int sum = R * r + G * g;
            /*Nからsumを引いてそれが青のボールの数Bの倍数であれば
            ちょうどN個のボールが手に入る*/
            //sumがNより大きくなることはない
            if (sum <= N && (N - sum) % B == 0)
            {
                //cout << R * r << ' ' << G * g << endl;
                ans++;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;
const ll MOD = 1e9+7;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main() {
	int n;
	cin >> n;
    ll sums = 0, ans = 0;
    rep(i,n) {
        int a;
        cin >> a;
        sums += a;
        if (a==0) {
            ans += sums/2;
            sums = 0;
        }
    }
    ans += sums/2;
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

template<ll Modulus>
class ModInt {
  ll value;
public:
  inline ModInt(ll val = 0) noexcept :
    value((val >= Modulus) ? (val % Modulus) : (val < 0) ? ((val + Modulus) % Modulus) : val) {}

  template<class Int>
  explicit inline operator Int() const noexcept { return static_cast<Int>(value); }

  inline ModInt inv() const noexcept {
    return ModInt<Modulus>::pow(value, Modulus-2);
  }

  inline ModInt& operator+=(ModInt x) noexcept {
    if ((value += x.value) >= Modulus) value -= Modulus;
    return *this;
  }
  inline ModInt& operator-=(ModInt x) noexcept {
    if ((value -= x.value) < 0) value += Modulus;
    return *this;
  }
  inline ModInt& operator*=(ModInt x) noexcept {
    value = (value * x.value) % Modulus; return *this;
  }
  inline ModInt& operator/=(ModInt x) noexcept {
    value = (value * x.inv().value) % Modulus; return *this;
  }

  inline ModInt operator+(ModInt x) const noexcept { return ModInt(*this) += x; }
  inline ModInt operator-(ModInt x) const noexcept { return ModInt(*this) -= x; }
  inline ModInt operator*(ModInt x) const noexcept { return ModInt(*this) *= x; }
  inline ModInt operator/(ModInt x) const noexcept { return ModInt(*this) /= x; }
  inline bool operator==(ModInt x) const noexcept { return value == x.value; }
  inline bool operator!=(ModInt x) const noexcept { return !(this->operator==(x)); }

  friend ostream& operator<<(ostream &os, ModInt x) noexcept { os << x.value; return os; }
  friend istream& operator>>(istream &is, ModInt &x) noexcept { is >> x.value; return is; }

  static constexpr inline ModInt pow(ll n, ll p) noexcept {
    ll ret = 1;
    for(; p > 0; p >>= 1) {
      if (p & 1) ret = (ret * n) % Modulus;
      n = (n * n) % Modulus;
    }
    return ret;
  }

  ModInt p(ll p){
	ll n = value;
    ll ret = 1;
    for(; p > 0; p >>= 1) {
      if (p & 1) ret = (ret * n) % Modulus;
      n = (n * n) % Modulus;
    }
    return value = ret;
  }
};

#define MOD 1000000007
using mint = ModInt<MOD>;

//debug
#define debug(arr) cerr<<#arr<<"(l"<<__LINE__<<") : ";for(auto x:arr)cerr<<x<<" ";cerr<<endl;

vector<mint> fact((int)1e6);

mint P(ll n, ll k){
  return fact[n] / fact[n-k];
}
mint C(ll n, ll k){
  return P(n, k) / fact[k];
}

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

  mint ans = 0;
  fact[0] = 1;
  repi(i, 1, M+1) fact[i] = fact[i-1] * mint(i);

  rep(k, N+1){
    ans += mint(1-k%2*2) * P(M, k) * P(M-k, N-k) * P(M-k, N-k) * C(N, k);
  }

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



Measured memory_bytes: 11004
import heapq

n,m = map(int,input().split())
price = [-int(i) for i in input().split()]

heapq.heapify(price)
# print(price)
for i in range(m):
    # print(i+1)
    a = int(heapq.heappop(price)/2)
    heapq.heappush(price,a)
    # print(price)
print(-sum(price))
    

Measured memory_bytes: 14180
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    h, w = MII()
    ss = []
    for i in range(h):
        ss.append(IS())
    

    L = [[0]*w for _ in range(h)]
    R = [[0]*w for _ in range(h)]
    D = [[0]*w for _ in range(h)]
    U = [[0]*w for _ in range(h)]

    for i in range(h):
        for j in range(w):
            if ss[i][j] == '#': L[i][j] = 0; continue
            if j == 0: L[i][j] = 1; continue
            if j > 0: L[i][j] = L[i][j-1] + 1; continue

    for i in range(h):
        for j in reversed(range(w)):
            if ss[i][j] == '#': R[i][j] = 0; continue
            if j == w-1: R[i][j] = 1; continue
            if j < w-1: R[i][j] = R[i][j+1] + 1; continue

    for i in range(h):
        for j in range(w):
            if ss[i][j] == '#': D[i][j] = 0; continue
            if i == 0: D[i][j] = 1; continue
            if i > 0: D[i][j] = D[i-1][j] + 1; continue

    for i in reversed(range(h)):
        for j in range(w):
            if ss[i][j] == '#': U[i][j] = 0; continue
            if i == h-1: U[i][j] = 1; continue
            if i < h-1: U[i][j] = U[i+1][j] + 1; continue

    maxv = 0
    for i in range(h):
        for j in range(w):
            maxv = max(maxv, L[i][j]+R[i][j]+D[i][j]+U[i][j]-3)
    print(maxv)

if __name__ == '__main__':
    main()


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

int main() {
string t;
string s;
cin>>s;
cin>>t;

if(s.size()+1==t.size()){
    if(s==t.substr(0,s.size()))
    cout<<"Yes";
    else
    cout<<"No";
}
else
cout<<"No";

	
}


Measured memory_bytes: 3628
import java.util.Scanner;

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

        String status = "APPROVED";
        for (int i = 0; i < n; i++) {
            int a = in.nextInt();
            if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) {
                status = "DENIED";
            }
        }

        System.out.println(status);
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <stdio.h>
#include <string>
using namespace std;

int N = 0;
int A = 0;
int y = 0;



int main() {
	cin >> N;
	cin >> A;
	string name;
	int b = 0;
	b = N % 500;
	for (int i = 0; i <= A;	i++) {
		if (i == b) {
			y = 1;
		}

	}
	if (y == 1) {
		name = "Yes";
	}
	if (y == 0) {
		name = "No";
	}
	
	cout << name;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#include <vector>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  if(n % 2 == 0){
    for(int i = n - 1; i > 0; i -= 2) cout << a[i] << " ";
    for(int m = 0; m < n; m += 2){
      cout << a[m];
      if(m != n - 2) cout << " ";
    }
  }else{
    for(int i = n - 1; i > -1; i -= 2) cout << a[i] << " ";
    for(int i = 1; i < n; i += 2){
      cout << a[i];
      if(i != n - 2) cout << " ";
    }
    cout << "\n";
  }
  return 0;
}

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

namespace ConsoleApplication1
{

    class Program
    {

        static void Main(string[] args)
        {

            

            string input = Console.ReadLine();

            char[] str = input.ToCharArray();

            int s = str.Length - 1;
            long count = 0;
            int n = str.Length;

            if (str[n - 1] == 'B')
            {
                for (int i = n - 1; i >= 0; i--)
                {
                    if (str[i] == 'W')
                    {
                        s = i;
                        break;
                    }
                }
            }

            int k = 0;

            for (int i = s; i >= 0; i--)
            {
                if (str[i] == 'B')
                {
                    str[i] = 'W';
                    str[s] = 'B';
                    count += k;
                    s--;
                }
                else
                {
                    k++;
                }

            }

            Console.WriteLine(count);

        }
    }
}


Measured memory_bytes: 12128
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
long long GCD(long long a, long long b)
{
    if (b == 0)
        return a;
    return GCD(b, a % b);
}
long long LCM(long long a, long long b)
{
    return a * b / GCD(a, b);
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V vec(n);
    rep(i,n)cin>>vec[i];
    sort(all(vec),greater<ll>());
    ll res=0;
    ll res1=1;
    rep(i,n-1){
        res1*=4;
        res1%=MOD;
    }
    rep(i,n){
        ll k=res1*(i+2);
        k%=MOD;
        k*=vec[i];
        k%=MOD;
        res+=k;
        res%=MOD;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
struct Unionfind{
  vector<int> r;
  Unionfind(int n){
    r=vector<int> (n,-1);
  }
  int root(int x){
    if(r[x]<0) return x;
    return r[x]=root(r[x]);
  }
  bool unite(int x,int y){
    x=root(x);
    y=root(y);
    if(x==y) return false;
    if(r[x]>r[y]) swap(x,y);
    r[x]+=r[y];
    r[y]=x;
    return true;
  }
  int size(int x){
    return -r[root(x)];
  }
};

int main(){
  int n,m;
  cin>>n>>m;
  Unionfind UF(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a-=1;b-=1;
    UF.unite(a,b);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    ans=max(ans,UF.size(i));
  }
cout<<ans<<endl;
  return 0;
}


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

int main(){
    int ans=0;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<3;i++){
        ans += (s[i]==t[i]?1:0);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <algorithm>
using namespace std;
int main(){
        int n,W;
        int weight[110],value[110];
        int dp[110][10010];
        cin >> n >> W;
        for(int i=0;i<n;i++) cin >> value[i] >> weight[i];

        for(int w;w <= W;w++) dp[0][w]=0;

        for(int i=0;i<n;i++){
                for(int w=0;w <= W;w++){
                        if(w >= weight[i]) dp[i+1][w] = max(dp[i][w-weight[i]] + value[i],dp[i][w]);
                        else dp[i+1][w]=dp[i][w];
                }
        }

        cout << dp[n][W] << endl;
}


Measured memory_bytes: 7052
N,M = map(int,input().split())
H = list(map(int,input().split()))
l = [0]*N
ans = 0
for i in range(M):
    A,B = map(int,input().split())
    l[A-1] = max(l[A-1],H[B-1])
    l[B-1] = max(l[B-1],H[A-1])
for i in range(N):
    if H[i] > l[i]:
        ans += 1
    else:
        pass
print(ans)

Measured memory_bytes: 84840
N=int(input())
m=[]
for A in range(1,N):
  s=0
  B=N-A
  a="".join(str(A))
  b="".join(str(B))
  for x in range(0,len(a)):
    s+=int(a[x])
  for y in range(0,len(b)):
    s+=int(b[y])
  m.append(s)
print(min(m))

Measured memory_bytes: 3860
N = int(input())
dic = {}
for i in range(N):
  temp = str(input())
  temp = list(temp); N = len(temp)
  A = 0; dec = 0
  for j in range(N):
    if temp[j] != ".":
      A += int(temp[j])*pow(10,N-1-j)
    else:
      dec = N-1-j
      A //= 10
  t = -dec; f = -dec
  while A%2 == 0:
    t +=1 
    A = A//2
  while A%5 == 0:
    f += 1
    A = A//5
  #print(t,f)
  if (t,f) not in dic:
    dic[(t,f)] = 1
  else:
    dic[(t,f)] += 1
#print(dic)
V = list(dic.keys())
#print(V)
ans = 0
for i in range(len(V)):
  if V[i][0] >= 0 and V[i][1] >= 0:
    kosu = dic[V[i]]
    ans += kosu*(kosu-1)//2
for i in range(len(V)):
  for j in range(i+1,len(V)):
    keyi = V[i]
    keyj = V[j]
    if V[i][0]+V[j][0] >= 0 and V[i][1]+V[j][1] >= 0:
      ans += dic[keyi]*dic[keyj]
print(ans)

Measured memory_bytes: 80164
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;

ll g(ll X) { return X - X / 3 - X / 5 + X / 15; }

ll f(ll X) {
  ll ans = 0;
  ll d = 1, low = 1, high = 10;  // [low, high)
  while (high <= X) {
    ans += d * (g(high - 1) - g(low - 1));
    ++d;
    low = high;
    high *= 10;
  }
  ans += d * (g(X) - g(low - 1));
  ans += 4 * (X / 3) + 4 * (X / 5);
  return ans;
}

int main() {
  ll s;
  while (cin >> s) {
    ll fail = 0, pass = 1ll << 60;
    while (pass - fail > 1) {
      ll X = (fail + pass) / 2;
      if (f(X) >= s) {
        pass = X;
      } else {
        fail = X;
      }
    }
    if (pass > 1) {
      s -= f(pass - 1);
    }
    string ans = "";
    for (ll X = pass; ans.size() < s + 19; X++) {
      if (X % 15 == 0) {
        ans += "FizzBuzz";
      } else if (X % 3 == 0) {
        ans += "Fizz";
      } else if (X % 5 == 0) {
        ans += "Buzz";
      } else {
        ans += to_string(X);
      }
    }
    ans = ans.substr(s - 1, 20);
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3260
n, ww = map(int, input().split())

wv = [list(map(int, input().split())) for i in range(n)]
wv.sort(key=lambda x:x[1])
dp = {0:0}
for w, v in wv:
    dp_next = dp.copy()
    for key in dp:
        dp_next[key+v] = min(dp[key]+ w, dp.get(key+v, float("inf")))
    dp = dp_next
for key in sorted(dp.keys(), reverse=True):
    if dp[key] <= ww:
        print(key)
        exit()

Measured memory_bytes: 14216
#素因数分解（10**6まで）
def soinsu_bunkai(m):
    pf=set()
    mm =m
    pri_num =[2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541, 547, 557, 563, 569, 571, 577, 587, 593, 599, 601, 607, 613, 617, 619, 631, 641, 643, 647, 653, 659, 661, 673, 677, 683, 691, 701, 709, 719, 727, 733, 739, 743, 751, 757, 761, 769, 773, 787, 797, 809, 811, 821, 823, 827, 829, 839, 853, 857, 859, 863, 877, 881, 883, 887, 907, 911, 919, 929, 937, 941, 947, 953, 967, 971, 977, 983, 991, 997, 1009]
    for i in pri_num:
        if i > mm:
            break
        while mm %i==0:
            pf.add(i)
            mm //=i
    if mm !=1:
        pf.add(mm)
    return pf

# 初期入力
import math
import sys
from functools import reduce
input = sys.stdin.readline  #文字列では使わない
N = int(input())
A = list(map(int, input().split()))
used =set()
pair_w =set()

# 10**6までの素因数分解するために、「10**6のルート」までの素数を列挙
pri =10**6 +10

#not coprimeの判定
gcd_a =reduce(math.gcd,A)
if gcd_a !=1:
    ans ="not coprime"

#pairwise coprimeの判定
else:
    ans ="pairwise coprime"
    for a in A:
        aa =soinsu_bunkai(a)
        if used & aa:
            print("setwise coprime")
            sys.exit() #共通要素があったらpair_wではない→set_w
        used |=aa

        
print(ans)

Measured memory_bytes: 127696
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	fsc := NewFastScanner()
	N, K := fsc.NextInt(), fsc.NextInt()
	T := make([]int, 0)
	for i := 0; i < N; i++ {
		T = append(T, fsc.NextInt())
	}
	sort.Ints(T)
	result := 0
	for i := 0; i < K; i++ {
		result += T[N-1-i]
	}
	fmt.Println(result)
}

//template
type FastScanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewFastScanner() *FastScanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1024)
	return &FastScanner{r: rdr}
}
func (s *FastScanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *FastScanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *FastScanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *FastScanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *FastScanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *FastScanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}

//Max,Min
func IntMax(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func Int64Max(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func Float64Max(a, b float64) float64 {
	if a < b {
		return b
	}
	return a
}

func IntMin(a, b int) int {
	if a > b {
		return b
	}
	return a
}

func Int64Min(a, b int64) int64 {
	if a > b {
		return b
	}
	return a
}
func Float64Min(a, b float64) float64 {
	if a > b {
		return b
	}
	return a
}

//Gcd
func IntGcd(a, b int) int {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return IntGcd(b, a%b)
}
func Int64Gcd(a, b int64) int64 {
	if a < b {
		b, a = a, b
	}
	if b == 0 {
		return a
	}
	return Int64Gcd(b, a%b)
}

func IntAbs(a int) int {
	if a < 0 {
		a *= -1
	}
	return a
}

func Int64Abs(a int64) int64 {
	if a < 0 {
		a *= -1
	}
	return a
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = (1e9)+7;
void fastIO(){
  ios_base::sync_with_stdio(0); cin.tie(0);
}


int main(){
  fastIO();
  int n;
  cin>>n;
  vector<int>food(n);
  for(int i=0;i<n;i++){
  	cin>>food[i];
  }
  int sum = 0;
  for(int i=0;i<n;i++){
  	for(int j=i;j<n;j++){
  		if(j!=i){
  			sum+=(food[i]*food[j]);
  		}
  	}
  }
  cout<<sum<<endl;
} 





Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){

   int n;
   cin >> n;

   cout << n*n*n << endl;



   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <math.h>
using namespace std;
int main(){
    int n; cin >> n;
    int h[n]; for(int i=0; i<n; i++) cin >> h[i];
    int dp[n+2]; for(int i=0; i<n; i++) dp[i] = 1e9;
    dp[0] = 0;
    for(int i=1; i<n; i++){
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]),dp[i]);
        if(i>1) dp[i] = min(dp[i-2]+abs(h[i-2]-h[i]),dp[i]);
    }
    cout << dp[n-1] << endl; 
}

Measured memory_bytes: 1024
h, w, $d = gets.split.map(&:to_i)
f = Array.new(h).map{Array.new(w)}

def cx i, j
  i + j
end

def cy i, j
  i - j
end

def to_table_idx i
  (i % (2 * $d)) / $d
end

table = {[true, true]=>'R', [true, false]=>'G', [false, true]=>'B', [false, false]=>'Y'}

w.times { |i|
  h.times { |j|
    x = cx i, j
    y = cy i, j
    xx = to_table_idx x
    yy = to_table_idx y
    f[j][i] = table[[yy.odd?, xx.odd?]]
  }
}

puts *f.map{|f_| f_.join('')}

Measured memory_bytes: 4220