akhauriyash/Code-Regression huggingface dataset:
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    ll x[510];
    rep(i,0,N) cin >> x[i];
    bool ok = true;
    vector<lpair> lp;
    rep(i,0,N){
        lp.push_back({x[i], i+1});
    }
    sort(lp.begin(), lp.end());
    ll res[500*500+10] = {};
    rep(i,0,N){
        ll num = lp[i].second;
        ll ps = lp[i].first;
        ll cnt = 0;
        rep(j,0,ps-1){
            if(res[j] == 0) cnt++;
        }
        if(cnt < num-1){
            ok = false;
            break;
        }
        ll n = num-1;
        ll idx = 0;
        while(n > 0){
            if(res[idx] == 0){
                res[idx] = num;
                idx++;
                n--;
            }else{
                idx++;
            }
        }
        res[ps-1] = num;
    }
    rrep(i,N-1,0){
        ll num = lp[i].second;
        ll ps = lp[i].first;
        ll cnt = 0;
        rrep(j,N*N-1,ps){
            if(res[j] == 0) cnt++;
        }
        if(cnt < N - num){
            ok = false;
            break;
        }
        ll n = N - num;
        ll idx = N*N-1;
        while(n > 0){
            if(res[idx] == 0){
                res[idx] = num;
                idx--;
                n--;
            }else{
                idx--;
            }
        }
    }
    if(ok){
        print("Yes");
        printa(res, N*N);
    }else{
        print("No");
    }

    

}


Measured memory_bytes: 3200
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>

using namespace std;
typedef long long ll;


int main(){
    int D,G; cin >> D >> G;
    int p[10],c[10];
    for(int i=0;i<D;i++){
        cin >> p[i] >> c[i];
    }
    int ans=1e9;
    for(int i=0;i<1<<(D);i++){
        int s=0,num=0,rmax=-1;
        for(int j=0;j<D;j++){
            if(i&(1<<j)){ //j番目をすべて解く
                s+=(j+1)*100*p[j]+c[j];
                num += p[j]; //問題数
            }else{
                rmax = j;
            }
        }
        if(s<G){ //目標に達していない
            int s1 = 100*(rmax+1); //すべて解かなかったうちで最も大きい点数の問題
            int need = (G-s+s1-1)/s1; //何問とけばよいか
            if(need>=p[rmax]){ //点数が足りない
                continue;
            }
            num += need;
        }
        ans = min(ans,num);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cassert>
using namespace std;

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

	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for (string& x : s) cin >> x;
	
	sort(s.begin(), s.end());
	for (int i = 0; i < n; i++) cout << s[i];
	cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

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

	char a[n][m];
	for(ll i=0;i<n;i++)
		for(ll j=0;j<m;j++)
			cin>>a[i][j];

		ll dp[n][m];
		memset(dp,0,sizeof(dp));

		for(ll i=0;i<n;i++)
		{
			for(ll j=0;j<m;j++)
			{
				if(i==0 and j==0)
					dp[i][j]=1;

				else if(a[i][j]=='.')
				{
					if(i>0) dp[i][j]=(dp[i-1][j]+dp[i][j])%mod;
					if(j>0) dp[i][j]=(dp[i][j-1]+dp[i][j])%mod;
				}
			}
		}
		cout<<dp[n-1][m-1]<<endl;
}


Measured memory_bytes: 9088
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
typedef vector<llong> V;

#define _ cin.tie(0);ios::sync_with_stdio(false);

string s;
int main(){ _;
  cin>>s;
  if(s[0]!='A'){
    cout<<"WA"<<endl;
    return 0;
  }
  int  fpos = s.find("C");
  int  rpos = s.rfind("C");
  if(fpos != rpos || (fpos<2 || fpos > s.size()-2)){
    cout<<"WA"<<endl;
    return 0;
  }

  int down=0;
  REP(i,s.size()){
    if(s[i]>='a' && s[i]<='z')
      ++down;
  }
  if(down!=s.size()-2){
    cout<<"WA"<<endl;
    return 0;
  }
  cout<<"AC"<<endl;
    
    

  return 0;
}


Measured memory_bytes: 256
def char_match(s,t,m):
    match = 0
    for i in range(m):
        if s[i] == t[i]:
            match += 1
    return match
def substring(S,T):
    m = len(T)
    char_mismatch = m
    for i in range(0,(len(S)-m) +1):
        char_mismatch = min(char_mismatch, m - char_match(S[i:i+m],T, m))
    return char_mismatch

def start():
    S = input()
    T = input()
    print(substring(S,T))
start()



Measured memory_bytes: 9132
#![allow(unused_imports)]
#![allow(dead_code)]
use std::io::prelude::*;
use std::cmp::{max, min};
use std::collections::BinaryHeap;

const MOD: i64 = 1e9 as i64 + 7; 

fn main(){
    let s: Vec<char> = read::<String>().chars().collect();
    let mut a: usize = 0;
    let mut b: usize = 0;
    let mut c: usize = 0;
    for i in s{
        match i{
            'a' => a += 1,
            'b' => b += 1,
            'c' => c += 1,
            _ => {},
        }
    }
    let ans = if max(max(a, b), c) - min(min(a, b), c) <= 1 {"YES"} else {"NO"}; 
    println!("{}", ans);
}

fn read<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
  
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()

const int N = 2e5 + 5, L = 20;
int a[N], last[L];

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

    int n;
    cin >> n;

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

    ll ans = 0;
    int gl_mx = 0;

    for (int i = 1; i <= n; i++) {
        int mx = 0;
        for (int j = 0; j < L; j++) {
            if ((a[i] >> j) & 1) {
                mx = max(mx, last[j]);
                last[j] = i;
            }
        }
        gl_mx = max(mx, gl_mx);

        ans += i - gl_mx;
    }

    cout << ans;

    return 0;   
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A = sc.nextInt();
        int B = sc.nextInt();
        int [] h = new int [N];
        for(int i=0; i<N; i++){
            h[i] = sc.nextInt();
        }
        Arrays.sort(h);
        long min = 0;
        long max = 1000000000;
        long mid = 0;
        while(max-min>1){
            mid = max-(max-min)/2;
            if(judge(mid,h,N,B,A-B)){
                max = mid;
            }else{
                min = mid;
            }
        }
        if(!judge(mid,h,N,B,A-B))mid++;
        System.out.println(mid);
    }
    static boolean judge(long mid, int[]h, int N, int B, double C){
        long Z=0;
        for(int i=N-1; i>=0; i--){
            long tmp = h[i]-mid*B;
            if(tmp>0){
                Z+=((long)(Math.ceil(tmp/C)));
            }else{
                break;
            }
        }
        if(Z>mid)return false;
        return true;
    }
}


Measured memory_bytes: 49816
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var A = Console.ReadLine();
            var B = Console.ReadLine();
            var C = Console.ReadLine();
            var t = A.First();
            A = A.Substring(1);

            while (true)
            {
                switch (t)
                {
                    case 'a':
                        if (!A.Any())
                        {
                            Console.WriteLine("A");
                            return;
                        }
                        t = A.First();
                        A = A.Substring(1);
                        break;
                    case 'b':
                        if (!B.Any())
                        {
                            Console.WriteLine("B");
                            return;
                        }
                        t = B.First();
                        B = B.Substring(1);
                        break;
                    case 'c':
                        if (!C.Any())
                        {
                            Console.WriteLine("C");
                            return;
                        }
                        t = C.First();
                        C = C.Substring(1);
                        break;
                }
            }
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <vector>
#include <cmath>
 
using namespace std;
string S;
int main()
{
  int i;
  string w[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};

  cin >> S;
  for (i=0; i<7; i++) {
    if (S == w[i]) break;
  }
  printf("%d\n", 7-i);
  return 0;
}


Measured memory_bytes: 256
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    s=STR()
    if s[5]=='0'and int(s[6])<=4:
        print('Heisei')
    else:
        print('TBD')
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i, n) REP(i, 0, n)
#define lengthof(x) (sizeof(x) / sizeof(*(x)))
#define FILL(ptr, value) FILL_((ptr), sizeof(ptr)/sizeof(value), (value))
template <typename T>
void FILL_(void * ptr, size_t size, T value){
  std::fill((T*)ptr, (T*)ptr+size, value);
}
//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
int W,H;
//board[i][j]は(i,j)を右下とした領域の中の個数
int S,T;
int main()
{
  int N;
  while(scanf("%d",&N) !=EOF&& N!=0){
    int board[101][101]={{0}};
    cin>>W>>H;
    int x,y;
    for(int i = 0;i < N;i++){
      cin>>x>>y;
      board[y][x]+=1;
    }
    cin>>S>>T;
    for(int i = 1;i <=H;i++){
      for(int j = 1;j <=W;j++){
	board[i][j] =max(board[i][j],board[i][j-1]+board[i][j]);
      }
    }
    for(int j = 1;j <=W;j++){
      for(int i = 1;i <=H;i++){
	board[i][j] =max(board[i][j],board[i-1][j]+board[i][j]);
      }
    }
    int ans = 0;
    for(int i = T;i <=H;i++){
      for(int j = S;j <=W;j++){
	ans = max(ans,board[i][j]-board[i-T][j]-board[i][j-S]+board[i-T][j-S]);
      }
    }
    cout <<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1292
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a;i<(int)b;++i)
int main(){
    int n;cin>>n;
    bool flag=false;
    rep(i,n){
        char c;cin>>c;
        if(c=='Y')flag=true;
    }
    if(flag==true)cout<<"Four"<<endl;
    else cout<<"Three"<<endl;
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"

using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i, n)  FOR(i,0,(n))
typedef vector<int> vec;

class CLamps {
public:
    void solve(std::istream &in, std::ostream &out) {
      int n, k;
      in >> n >> k;
      vector<int> a(n);
      REP(i, n) in >> a[i];
      vector<pair<double, double>> b(n);
      REP(j, min(k, 100ll)) {
        REP(i, n) {
          b[i] = make_pair(max(i - a[i], 0ll), min(i + a[i] + 1, n));
        }
        vec c(n + 1, 0);
        REP(i, n) {
          c[b[i].first]++;
          c[b[i].second]--;
        }
        FOR(i, 1, c.size()) {
          c[i] += c[i - 1];
          a[i - 1] = c[i - 1];
        }
      }
      REP(i, n) {
        out << a[i] << " ";
      }
      out << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  CLamps solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 9572
//Link : https://atcoder.jp/contests/mujin-pc-2017/tasks/mujin_pc_2017_b

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 503
#define inf 200000000
char s[N][N];
void solve() {
  int n;scanf("%d ", &n);
  int row[N],column[N];
  memset(row,0,sizeof(row));
  memset(column,0,sizeof(column));

  for(int i=0;i<n;++i) {
    scanf(" %s ", s[i]);
    for(int j=0;j<n;++j) {
      if(s[i][j]=='#') {
        ++column[j];
        ++row[i];
      }
    }
  }
  int x = n;
  int ret = inf;
  for(int i=0;i<n;++i) {
    if(row[i]==n) {
      --x;
    }
  }
  for(int c=0;c<n;++c) {
    bool isGood = true;
    int tmp = 0;
    for(int j = 0;j<n;++j) {
      if(s[c][j]=='.') {
        if(c==j && column[j]==0) {
          if(row[c])
            tmp+=2;
          else
            isGood = false;
        } else {
          ++tmp;
        }
      }
    }
    if(!isGood) {
      continue;
    }
    for(int j=0;j<n;++j) if (s[c][j]=='.'||column[j]!=n) tmp++;
    ret = min(ret,tmp);
  }

  if(ret==inf) {
    ret = -1;
  }
  printf("%d\n", ret);
}

int main() {
    //freopen("input.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 512
/*input

*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

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

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  int n, a, b;
  cin >> n >> a >> b;
  int ans = min(n * a, b);
  cout << ans;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define pb push_back
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define inp(n) for(i=0;i<n;i++) cin>>A[i];
#define inz(A) memset(A,0,sizeof(A))
#define lb lower_bound
#define ub upper_bound
#define all(v) v.begin(),v.end()
#define T 1000000
#define F first
#define S second
#define pi pair<int,int>
#define vi vector<int>
#define mii map<int,int>
#define vp vector<pair< int,int> >
#define mpi map<pair<int,int> ,int>
#define mip map<int, pair<int,int> >
#define inf INT_MAX
#define inf1 LONGLONG_MAX
#define sz(v) v.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define deb(x) cout<<#x<<"is "<<x<<endl;
#define lower(s) transform(all(s),s.begin(),::tolower)
#define endl "\n"
vector<int>adj [T];
			/*brownsands IIITA*/
 
void solve()
{	string s,s1;
 	int n,i;
	cin>>n;
  	cin>>s>>s1;
  for(i=0;i<n;i++)
   cout<<s[i]<<s1[i];
}
signed main()
{
   boost
        int test=0,t;
		//cin>>t;
		t=1;
		while(test++ <t){
            //cout<<"Case "<<test<<": ";
            solve();
            //cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
               }		
}

Measured memory_bytes: 23680
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int main(){
    int x,y,z;
    cin >> x>> y>> z;
    cout<<z<<endl;
    cout<<x<<endl;
    cout<<y<<endl;

    return 0;
}



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

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repr(i,n) for (int i = 0; i < (f); --i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

const int MAX = 100;
const int INF = (1<<12);

int A[3][3], S[3][3],n;

void set(){
  rep(i,n){
    int b;
    cin >> b;
    rep(i,3){
      rep(j,3){
        if(A[i][j] == b) S[i][j] = true;
      }
    }
  }
}

void check(){
  rep(i,3) if(S[i][0] && S[i][1] && S[i][2]) {
    cout << "Yes" << endl; return;
  }
  rep(i,3) if(S[0][i] && S[1][i] && S[2][i]) {
    cout << "Yes" << endl; return;
  }
  if(S[0][0] && S[1][1] && S[2][2]) {
    cout << "Yes" << endl; return;
  }
  if(S[0][2] && S[1][1] && S[2][0]) {
    cout << "Yes" << endl; return;
  }
  cout << "No" << endl;
  return;
}

int main() {
  rep(i,3){
    rep(j,3){
      cin >> A[i][j];
      S[i][j] = false;
    }
  }
  cin >> n;
  set();
  check();
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstdio>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)2e18
#define jck 3.141592

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


ll dp[110][100010];

int main(){
	int N; cin >> N;
	ll W; cin >> W;
	vector<ll> w(N),v(N);
	rep(i,N) cin >> w[i] >> v[i];
	rep(i,110)rep(j,100010) dp[i][j] = LINF;
	dp[0][0] = 0;
	rep(i,N){
		rep(j,100010){
			if(j-v[i] >= 0) dp[i+1][j] = min(dp[i+1][j],dp[i][j-v[i]]+w[i]);
			dp[i+1][j] = min(dp[i+1][j],dp[i][j]);
		}
	}
	ll ans = 0;
	rep(i,100010){
		if(dp[N][i] <= W) ans = i;
	}
	cout << ans << endl;
}


Measured memory_bytes: 86144
#include <iostream>
#include <algorithm>

using namespace std;

class C {
	int a, b, c;
public:
	void solve()
	{
		int target{ max(a, max(b, c)) * 3 };
		int current{ a + b + c };
		target -= current;

		if (1 & target) target += 3;

		cout << target / 2 << endl;

	}
	C()
	{
		cin >> a >> b >> c;
	}
};


int main()
{
	C solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    bool bl1,bl2;
    string s;
    cin >> s;
    int l=s.length();
    bool a = true;
    bool b = true;
    for(int i=0;i<(l-1)/2;i++){
    string sh1=s.substr(i,1);
    string sf1=s.substr((l-1)/2-i-1,1);
    
    string sh2=s.substr(i+(l+3)/2-1,1);
    string sf2=s.substr(l-i-1,1);

    if(!(sh1 == sf1 && sh2 == sf2)) {
        a = false;
    }
    for(int i=0;i<l;i++){
        string sh3=s.substr(i,1);
        string sf3=s.substr(l-1-i,1);

        if(!(sh3 == sf3)){
            b=false;
        }
    }
    }
    if(a && b){
        cout << "Yes";
    }
    else{
        cout << "No";
    }


    }
   



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll N;
    cin >> N;
    vec a(N);
    loop(i, N) cin >> a[i];
    sort(all(a));
    ll ans = a[N - 1];
    ll count = 1;
    loop(i, N - 2)
    {
        ans += a[N - 1 - count];
        if (i % 2 == 1)
            count++;
    }
    putout(ans);
    return 0;
}


Measured memory_bytes: 4820
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_D = 105;
const int MAX_N = 10005;

string K;
int D;
int dp[MAX_N][MAX_D][2];

signed main()
{
  cin >> K;
  cin >> D;

  dp[0][0][0] = 1;
  REP(n,K.size()) {
    REP(d,D) {
      REP(f,2) {
        for(int dd = 0; dd < (f ? 10 : K[n]-'0'+1); dd++) {
          if(f) {
            dp[n+1][(d+dd)%D][f] += dp[n][d][f];
            dp[n+1][(d+dd)%D][f] %= MOD;
          } else {
            if(dd < K[n]-'0') {
              dp[n+1][(d+dd)%D][1] += dp[n][d][f];
              dp[n+1][(d+dd)%D][1] %= MOD;
            } else {
              dp[n+1][(d+dd)%D][0] += dp[n][d][f];
              dp[n+1][(d+dd)%D][0] %= MOD;
            }
          }
        }
      }
      
    }
  }

  cout << (dp[K.size()][0][0] + dp[K.size()][0][1] + MOD - 1) % MOD << endl;

  return 0;
}

Measured memory_bytes: 16640
{-# OPTIONS_GHC -O2 -funbox-strict-fields #-}
import qualified Data.ByteString.Char8 as BC
import           Data.Maybe            (fromJust)

main :: IO ()
main = do
  [a, b, c, d] <- map readInt . BC.words <$> BC.getLine
  putStrLn $ if solve a b c d then "Yes" else "No"

solve :: Int -> Int -> Int -> Int -> Bool
solve a b c d
  | abs (a - c) <= d = True
  | abs (a - b) <= d && abs (b - c) <= d = True
  | otherwise = False

readInt :: BC.ByteString -> Int
readInt = fst . fromJust . BC.readInt


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

int main() {
  int n;
  cin >> n;
  vector<int> b(n);
  rep(i,n-1){
   cin >> b[i]; 
  }
  
  int ans=b[0]+b[n-2];
  rep2(i,1,n-1){
    ans+=min(b[i],b[i-1]);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import heapq

N = int(input())
a = [int(i) for i in input().split()]

hq = a[0: N]
left_max = [sum(hq)]
heapq.heapify(hq)
for i in range(N):
    left_max.append(left_max[i] + a[N + i] - heapq.heappushpop(hq, a[N + i]))

hq = [-i for i in a[2 * N: 3 * N]]
right_min = [-sum(hq)]
heapq.heapify(hq)
for i in range(N):
    right_min.append(right_min[i] + a[2 * N - i - 1] + heapq.heappushpop(hq, -a[2 * N - i - 1]))

ans = -100000000000000
for i in range(N + 1):
    ans = max(ans, left_max[i] - right_min[N - i])

print(ans)

Measured memory_bytes: 38148
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=998244353 ;


int main(){
  ll n; cin >> n; ll k = n;
  int cnt = 0; ll t = 26;
  while(k>0){
    k-=t; t*=26; cnt++;
  }
  k+=t; k--; char ans[cnt]; int be = 0;
  while(k>0){
    ans[be]=(k%26)+'a'; k/=26; be++;
  }
  reverse(ans, ans+cnt);
  rep(i, cnt){
    cout << ans[i];
  }
  cout << endl;
}


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

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

  if(a == b){
    if(b == c){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return 0;
}


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

int main(){
    int A, B;

    scanf("%d %d", &A, &B);

    if((A-B)%2==0){
        if(A<B){
            printf("%d", abs(A-B)/2+A);
        }else{
            printf("%d", abs(A-B)/2+B);
        }
    }else{
        printf("IMPOSSIBLE");
    }

    return 0;
}

Measured memory_bytes: 128
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;
template<typename T> T abs(T val){return val>0?val:-val;}
int N;
LL A,B,C,D;
void solve()
{
    LL AB = abs(A-B);
    LL d = N-1;
    LL MIN = d*C, MAX = d*D;
    if( MIN <= AB && MAX >= AB ) puts("YES");
    else if( MAX < AB) puts("NO");
    else
    {
        bool flag = false;
        for(int i=1;i<d;i++)
        {
            LL tmp = 1LL*i*C + AB;
            MAX = (d-i)*D;
            MIN = (d-i)*C;
            if(tmp>MAX) break;
            else if(tmp>=MIN)
            {
                flag = true;
                break;
            }
        }
        for(int i=1;i<d;i++)
        {
            LL tmp = 1LL*i*D + AB;
            MAX = (d-i)*D;
            MIN = (d-i)*C;
            if(tmp>MAX) break;
            else if(tmp>=MIN)
            {
                flag = true;
                break;
            }
        }
        if(flag) puts("YES");
        else puts("NO");
    }
}
int main()
{
    //std::ios::sync_with_stdio(false);
    while(~scanf("%d%lld%lld%lld%lld", &N, &A, &B, &C, &D))
    {
        solve();
    }
    //system("pause");
    //printf("%lld\n", (x%mod+mod)%mod );
}


Measured memory_bytes: 256
a = [input().split() for _ in range(3)]
n = int(input())
b = [input() for _ in range(n)]

for i in b:
    for j in range(3):
        for k in range(3):
            if a[j][k] == i:
                a[j][k] = "o"

for i in range(3):
    tmp1 = ""
    tmp2 = ""
    for j in range(3):
        tmp1 += a[i][j]
        tmp2 += a[j][i]
    if tmp1 == "ooo" or tmp2 == "ooo":
        print("Yes")
        exit()

if a[0][0] + a[1][1] + a[2][2] == "ooo" or a[0][2] + a[1][1] + a[2][0] == "ooo":
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int from, to;
    int id;
};

struct vert {
    vector<edge> edges;
};

void rec(vector<vert>& verts, int v, int before, vector<bool>& visited, vector<int>& colors) {
    int color = 1;
    for ( auto& e : verts[v].edges ) {
        if (visited[e.to]) continue;
        visited[e.to] = true;
        if (color == before) color++;
        colors[e.id] = color;
        rec(verts, e.to, color, visited, colors);
        color++;
    }
}

int main() {
    int n;
    cin >> n;
    vector<int> vert_count(n);
    vector<vert> verts(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        verts[a].edges.push_back(edge{from: a, to: b, id: i});
        verts[b].edges.push_back(edge{from: b, to: a, id: i});
        vert_count[a]++;
        vert_count[b]++;
    }
    auto it = max_element(vert_count.begin(), vert_count.end());
    int k = *it;
    cout << k << endl;

    int idx = (int)distance(vert_count.begin(), it);
    vector<bool> visited(n, false);
    visited[idx] = true;
    vector<int> colors(n-1);
    rec(verts, idx, 0, visited, colors);

    for (const auto c : colors) {
        cout << c << endl;
    }
}


Measured memory_bytes: 11364
#include<bits/stdc++.h>
#define mo 1000000007
#define pi 3.1415926535898
#define eps 1e-9 
using namespace std;
long long read(){
    long long xx=0,flagg=1;
    char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-')
        ch=getchar();
    if(ch=='-'){
        flagg=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        xx=xx*10+ch-'0';
        ch=getchar();
    }
    return xx*flagg;
}
void pus(long long xx,long long flagg){
    if(xx<0){
        putchar('-');
        xx=-xx;
    }
    if(xx>=10)
        pus(xx/10,0);
    putchar(xx%10+'0');
    if(flagg==1)
        putchar(' ');
    if(flagg==2)
        putchar('\n');
    return;
}
int n,q,i,j,a[3005],f[3005][3005],g[3005][3005],x,y,flag,cm,ans;
int add(int u,int v){
	return u+v>=mo?u+v-mo:u+v;
}
int main(){
	n=read();q=read();
	for(i=1;i<=n;i++)
		a[i]=read();
	for(i=1;i<=n;i++)
		for(j=1;j<=n;j++)
			if(a[i]>a[j])
				f[i][j]=1;
	cm=1;
	while(q--){
		x=read();y=read();
		for(i=1;i<=n;i++){
			flag=add(f[i][x],f[i][y]);
			if(i!=y)
				g[i][y]=add(g[i][y],flag);
			if(i!=x)
				g[i][x]=add(g[i][x],flag);
			flag=add(f[x][i],f[y][i]);
			if(i!=y)
				g[y][i]=add(g[y][i],flag);
			if(i!=x)
				g[x][i]=add(g[x][i],flag);
		}
		cm=cm*2%mo;
		g[x][y]=add(f[x][y],f[y][x]);
		g[y][x]=g[x][y];
		for(i=1;i<=n;i++){
			f[i][y]=1LL*g[i][y]*500000004%mo;
			f[y][i]=1LL*g[y][i]*500000004%mo;
			f[i][x]=1LL*g[i][x]*500000004%mo;
			f[x][i]=1LL*g[x][i]*500000004%mo;
		}
		for(i=1;i<=n;i++){
			g[i][y]=0;
			g[y][i]=0;
			g[i][x]=0;
			g[x][i]=0;
		}
	}
	for(i=1;i<=n;i++)
		for(j=i+1;j<=n;j++)
			ans=add(ans,f[i][j]);
	ans=1LL*ans*cm%mo;
	pus(ans,2);
    return 0;
}

Measured memory_bytes: 70912
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdlib>
using namespace std;
typedef long long int lli;
lli mod = 1e9 +7;

lli modpow(lli a, lli p){
	lli ret = 1;
	for(int i=63; i>=0; i--){
		ret *= ret;
		ret %= mod;
		if((1LL<<i & p) != 0){
			ret *= a;
			ret %= mod;
		}
	}
	return ret;
}

int main(){
	int n;
	cin >> n;
	vector<lli> a(n);
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a.begin(), a.end(), greater<lli>());

	lli ans = 0;
	int num = modpow(2, n-1);
	for(int i=0; i<n; i++){
		ans += num *a[i];
		ans %= mod;
		num += modpow(2, n-2);
		num %= mod;
	}
	ans *= modpow(2, n);
	ans %= mod;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353                                                                          
#define vi vector<ll>
#define pll pair<ll, ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end() 
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll>,greater<ll>>
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce               \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                    \
    cout.tie(0);

using namespace __gnu_pbds;
using namespace std;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

const int maxN=8*1e6;
bool prime[maxN+1];
ll mpow(ll base,ll exp);
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);
ll modInverse(ll n);
ll nCr(ll n, ll r);
void sieve();
ll myxor(ll a,ll b);

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

void solve(){
    string s,t;
    cin >> s >> t;
    ll ans=s.size();
    for(int i=0;i<=s.size()-t.size();i++){
        string cur=s.substr(i,t.size());
        ll c=0;
        for(int j=0;j<t.size();j++){
            if(cur[j]!=t[j]) c++;
        }
        ans=min(ans,c);
    }

    cout << ans << endl;

}

int32_t main(){
    SpeedForce


    int t;
    t=1;
    //cin >> t;
    cerr << endl;
    while (t--){
        //cout << fixed << setprecision(10);
        solve();
    }
    cerr << "Time : " << 1000*((double)clock())/ (double)CLOCKS_PER_SEC << "ms" << endl;
}   

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

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

ll modInverse(ll n) { 
    return mpow(n, mod-2); 
}
 
ll nCr(ll n, ll r){ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    return ((fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod)%mod)%mod; 
}

ll myxor(ll a,ll b){
    return (a|b)&(~a|~b);
}

void sieve(){
    memset(prime,true,sizeof(prime));
    for(int p=2;p*p<maxN;p++){
        if(prime[p]){
            for(int i=2*p;i<maxN;i+=p){
                prime[i]=false;
            }
        }
    }
}

Measured memory_bytes: 3776
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define len(x) ((ll)(x).size())
#define debug(var) cout << "[" << #var << "]\n" << var << "\n\n"
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;
const double EPS = 1e-9;

template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1)
      s << ' ';
  }
  return s;
}

template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1)
      cout << '\n';
  }
  return s;
}

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

__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}

signed main() {
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) {
    cin >> P[i];
    P[i]--;
  }

  vector<int> pos(N);
  rep(i, N) {
    pos[P[i]] = i;
  }

  pos.pb(-1);
  int ans = 1;
  int temp = 1;
  rep(i, N) {
    if (pos[i] < pos[i + 1]) {
      temp++;
    } else {
      chmax(ans, temp);
      temp = 1;
    }
  }
  ans = N - ans;

  cout << ans << "\n";
}

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

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

  int ans = 0;
  rep(_, N) {
    int l, r;
    cin >> l >> r;
    ans += (r - l + 1);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

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

    pair<ll, ll> ans;
    ans.first = -1, ans.second = -1;
    rep(i, s.size()-1){
        if(i < s.size()-2){
            if(s[i] == s[i+1] || s[i] == s[i+2])ans.first = i+1, ans.second = i+3;
        }
        else if(s[i] ==  s[i+1])ans.first = i+1, ans.second = i+2;
    }
    cout << ans.first << " " << ans.second << endl;
}

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

int main(int argc, char* argv[])
{
	int N, M, NC, MC, answer;
	scanf("%d %d", &N, &M);

	if(N >= 2){
		NC = N*(N-1)/2;
	}else{
		NC = 0;
	}
	if(M >= 2){
		MC = M*(M-1)/2;
	}else{
		MC = 0;
	}

	answer = NC + MC;

	printf("%d\n", answer);
	return 0;
}

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

int main()
{
    char date[10];
    int c[10],year,month,day,i;

    for(i=0;i<10;i++){
        c[i] = getchar();
    }

    year = (c[0]-'0')*1000 + (c[1]-'0')*100 + (c[2]-'0')*10 + (c[3]-'0');
    month = (c[5]-'0')*10 + (c[6]-'0');
    day = (c[8]-'0')*10 + (c[9]-'0');

    int sum;
    sum = year*10000 + month*100 + day;

    if(sum <= 20190430){
        printf("Heisei\n");
    }else{
        printf("TBD\n");
    }

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define triple tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define N 100005  //check the limits, man
const ll INF = 1e12;
int main()
{
    int i,n,x;
    in(n);
    in(x);
    vi v(n);
    read(v,i,n);
    ll ans=0;
    rep(i,n-1)
    {
        if(v[i]+v[i+1]>x)
        {
            ans+=(v[i]+v[i+1]-x);
            if(v[i]>x)
                v[i]=x,v[i+1]=0;
            else
                v[i+1]=x-v[i];
        }
    }
    llout(ans);
}



Measured memory_bytes: 640
n=int(input())
s=map(int,input().split())
import collections
d=collections.Counter(s)
d=d.most_common()
count=0

for i in d:
    if i[1]%2==0:
        count+=1

if count%2==0:
    print(len(d))
else:
    print(len(d)-1)


Measured memory_bytes: 22448
import itertools
import math
n=int(input())
x=[]
for i in range(n):
    a=input().split()
    x.append([int(i) for i in a])

#全経路
all_way=[]
for i in itertools.permutations(x):
    all_way.append(list(i))

result=[]
for each_way in all_way:
    total=0
    for town in range(len(each_way)-1):
        total+=math.sqrt((each_way[town][0]-each_way[town+1][0])**2 + (each_way[town][1]-each_way[town+1][1])**2)
    result.append(total)

print(sum(result)/len(result))

Measured memory_bytes: 47600
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
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()
{
  ll n, p ;
  cin >> n >> p ; 
  ll a = 1 ;
  ll ans ;
  
  if(n==1){
    cout << p <<endl ;
    return 0 ;
  }
  if(n>=p){
    cout << 1 <<endl ;
    return 0 ;
  }
  if(n>=50){
    cout << 1 <<endl ;
    return 0 ;
  }
  
  ll P = sqrt(p) ;
  
  for(ll i=1; i<=P; i++){
    for(ll j=0; j<n; j++){
      a *= i ;
    }
    if(p%a==0){
      ans = i ;
    }
    else if(a>=p){
      break ;
    }
    a = 1 ;
  }
  
  cout << ans <<endl ;

  return 0 ;
}



Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <cmath>
#include <set>
#include <map>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstdio>
#include <cstdlib>
#define inf 0x3f3f3f3f
#define INF 0x7fffffffffffffff
typedef long long ll;
const double PI=3.1415926535897931;
const long long mod=1e9+7;
const int MA= 1e7+10;
const int ma= 2*1e5+10;
const int few=1e3+10;
const int maxn=1e8+10;
using namespace std;
//////////////////////////////////////////////
int a[ma];
int main()
{
    int n,x,y;
    cin>>n>>x>>y;
    for(int i=1;i<=n;i++)
        for(int j=i+1;j<=n;j++)
    {
        int tmp;
        tmp=min(j-i,abs(x-i)+abs(y-j)+1);
        a[tmp]++;
    }
    for(int i=1;i<n;i++)
        cout<<a[i]<<endl;
    return 0;
}


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

int main(){
    int n,ans = 1e9;
    cin >> n;
    map<int,int> mp;
    for(int i = 0;i < n;i ++){
        int a;
        cin >> a;
        mp[a] ++;
    }
    for(int i = -100;i < 101;i ++){
        int s=0;
        for(auto ite = mp.begin();ite != mp.end();++ite){
            s += (ite->first-i)*(ite->first-i)*ite->second;
        }
        ans = min(ans,s);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main() {
  string S;
  cin >> S;
  int len = S.size();

  char last = S[len - 1];
  if (last == 's') {
    S += "es";
  } else {
    S += "s";
  }

  cout << S << endl;

  return 0;
}

Measured memory_bytes: 3628