akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>
#include <string>

using namespace std;

vector<string> split(const string &s, char delim) {
  vector<string> elems;
  string item;
  for (char ch: s) {
    if (ch == delim) {
      if (!item.empty()) {
        elems.push_back(item);
      }
      item.clear();
    }
    else {
      item += ch;
    }
  }
  if (!item.empty()) {
    elems.push_back(item);
  }
  return elems;
}

string to_str_with_zero(int i, int w) {
  ostringstream sout;
  sout << std::setfill('0') << std::setw(w) << i;
  string s = sout.str();
  return s;
}

int letter_to_int(char c) {
  return tolower(c) - 'a';
}

bool array_equal(vector<int> a1, vector<int>a2) {
  if (a1.size() != a2.size()) {
    return false;
  }
  for (int i=0; i<a1.size(); i++) {
    if (a1.at(i) != a2.at(i)) {
      return false;
    }
  }
  return true;
}

int gcd(int a, int b) {
  if (a == b) {
    return a;
  }
  else if (a > b) {
    return gcd(a - b, b);
  }
  else {
    return gcd(a, b - a);
  }
}

char int_to_char(int a) {
  if (a == -1) {
    return 'z';
  }
  else {
    return 'a' + a;
  }
}

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

int main() {
  std::cout << std::setprecision(9);
  int a;
  cin >> a;

  cout << a + a * a + a * a * a << endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
#define debug(x) cerr << #x << ": " << x << '\n'
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
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;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 1e9;
const int MOD = 1e9 + 7;

using P = pair<int, int>;
int main() {
    int N, M;
    cin >> N >> M;
    vector<P> p(N);
    for (int i = 0; i < N; i++) {
        int a, b;
        cin >> a >> b;
        p[i] = P(a, b);
    }
    vector<P> q(M);
    for (int i = 0; i < M; i++) {
        int c, d;
        cin >> c >> d;
        q[i] = P(c, d);
    }

    vector<int> D(N, INF);
    vector<int> ans(N, 0);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < M; j++) {
            if (chmin(D[i], abs(p[i].first - q[j].first) + abs(p[i].second - q[j].second))) {
                ans[i] = j;
            }
        }
    }

    for (auto i : ans) {
        cout << i + 1 << "\n";
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int  ,int > pii;
typedef pair<ll  ,ll > pll;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll maxn  = 3e6;//AmShZ
const ll mod =1e9+7;
const ld PI = acos((ld)-1);

#define pb(x) push_back(x);
#define endl '\n'
#define dokme(x) cout << x ;  return(0);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ms(x , y) memset(x , y , sizeof x);
ll pw(ll a, ll b, ll md = mod) {
    ll res = 1;while(b){if(b&1){res=(a*res)%mod;}a=(a*a)%mod;b>>=1;}return(res);
}

ll n , cnt[maxn];
int a[maxn];

int main(){
    migmig
    cin >> n;
    for(int i = 0 ; i < n ; i ++){
        cin >> a[i];
        cnt[a[i]]++;
    }
    ll sum = 0;
    for(int i = 0 ; i < maxn ; i ++){
        sum += cnt[i]*(cnt[i]-1)/2;
    }
    for(int  i = 0; i < n ; i ++){
        sum -=cnt[a[i]]*(cnt[a[i]]-1)/2;
        cnt[a[i]]--;
        sum += cnt[a[i]]*(cnt[a[i]]-1)/2;
        cout << sum << endl;
        sum -=cnt[a[i]]*(cnt[a[i]]-1)/2;
        cnt[a[i]]++;
        sum += cnt[a[i]]*(cnt[a[i]]-1)/2;
    }


    return(0);
}

//When we hit our lowest point, we are open to the greatest change.
//If I try, I fail. If I don't try, I'm NEVER GOING TO GET IT.
//Sometimes, life is like this dark tunnel. You can't always see the light at the end of the tunnel. But if you just keep moving... you will come to a better place.
//It is important to draw wisdom from diffrent places. If you take it from only one place it becomes rigid and stale.
//kuxtal jach uts chuchul u u páajtal máak jach táaj meyajilo'ob le castigadas tumen ch'aik descansos.


Measured memory_bytes: 7552
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

int E,Y;

int main() {
	cin>>E>>Y;
	if(E==0){
		if(Y>=1868 && Y<=1911)cout<<"M"<<Y-1868+1<<endl;
		if(Y>=1912 && Y<=1925)cout<<"T"<<Y-1912+1<<endl;
		if(Y>=1926 && Y<=1988)cout<<"S"<<Y-1926+1<<endl;
		if(Y>=1989 && Y<=2016)cout<<"H"<<Y-1989+1<<endl;
	}
	if(E==1)cout<<1868+Y-1<<endl;
	if(E==2)cout<<1912+Y-1<<endl;
	if(E==3)cout<<1926+Y-1<<endl;
	if(E==4)cout<<1989+Y-1<<endl;


	return 0;
}

Measured memory_bytes: 3108
from collections import defaultdict
inf = input().split()
N = int(inf[0])
W = int(inf[1])
dic = defaultdict(int)

line = input().split()

for a in line:
    dic[int(a)] += 1

for w in range(W):
    inf = input().split()
    b = int(inf[0])
    c = int(inf[1])
    dic[c] += b
    
keys = list(dic.keys())

keys.sort(reverse=True)

count = 0
ans = 0
for k in keys:
    while dic[k]>0:
        if count == N:
            break
        ans += k
        dic[k] -= 1
        count += 1
    if count == N:
        break

print(ans)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int L[101010],R[101010];

multiset<ll> LS,RS;
ll ofl,ofr;
ll ret;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N) cin>>L[i]>>R[i];
	
	LS.insert(-1LL<<60);
	RS.insert(1LL<<60);
	
	FOR(i,N) {
		if(i) {
			ofl -= R[i]-L[i];
			ofr += R[i-1]-L[i-1];
		}
	
		if(L[i]<*LS.rbegin()+ofl) ret+=*LS.rbegin()+ofl-L[i];
		else if(*RS.begin()+ofr<L[i]) ret+=L[i]-(*RS.begin()+ofr);
		
		if(L[i]<*LS.rbegin()+ofl) {
			RS.insert(*LS.rbegin()+ofl-ofr);
			LS.insert(L[i]-ofl);
			LS.insert(L[i]-ofl);
			LS.erase(LS.find(*LS.rbegin()));
			
		}
		else if(*RS.begin()+ofr<L[i]) {
			LS.insert(*RS.begin()+ofr-ofl);
			RS.insert(L[i]-ofr);
			RS.insert(L[i]-ofr);
			RS.erase(RS.begin());
		}
		else {
			LS.insert(L[i]-ofl);
			RS.insert(L[i]-ofr);
		}
		
		/*
		FORR(r,LS) cout<<r+ofl<<" ";
		cout<<" : ";
		FORR(r,RS) cout<<r+ofr<<" ";
		cout<<" : "<<" "<<ofl<<" "<<ofr<<" "<<ret<<endl;
		*/
		
	}
	cout<<ret<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 10368
n=int(input())
x=[-1]*(10**7+5)
x[0]=0
x[1]=1
i=2
while i<=10**7+1:
    j=2*i
    if x[i]==-1:
        x[i]=i
        while j<=10**7+1:
            if x[j]==-1:x[j]=i
            j+=i
    i+=1
def f(k):
    if k==1:
        return 1

    z=[]
    p=x[k]
    m=1
    ans=1
    while k>=2:
        k=k//p
        if p==x[k]:
            m+=1
        else:
            z.append(m)
            m=1
            p=x[k]

    for i in range(len(z)):
        ans*=z[i]+1
    return ans
s=0
for i in range(1,n+1):
    s+=i*f(i)
print(s)



Measured memory_bytes: 152608
/*

*/
#include<iostream>
#include<iomanip>
#include<ios>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)
#define MAX_N 10000

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;
const ll MOD = ll(1e9+7);

int main(){
  ll x;cin>>x;
  ll deposit = 100LL;
  int ans=0;
  while(x>deposit){
    ans++;
    // deposit = ll(deposit * 1.01);
    deposit += ll(deposit/100);
  }
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 3624
#include <stdio.h>
  int main() {
      int X, A, B, i;
      
    
      scanf("%d %d %d",&X ,&A ,&B);
      
     i = B-A;   
      if(i > X){
      printf("dangerous\n");
      }
       else if(i <= 0){
       printf("delicious\n");
      }
      else {
      printf("safe\n");
      }
      return 0;
  }
      
      

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

int main(){
  int n;  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++)  cin >> a[i];
  int maxi = -1e9, ans = -1e9;
  for(int i=n-1; i>=0; i--){
    ans = max(ans, maxi - a[i]);
    maxi = max(maxi, a[i]);
  }

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


Measured memory_bytes: 3532
use proconio::input;
use std::cmp::Reverse;

fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    }

    a.sort_by_key(|k| Reverse(*k));

    let ans: i64 = (0..n - 1).map(|i| a[(i + 1) / 2]).sum();

    println!("{}", ans);
}


Measured memory_bytes: 6208
import std.stdio, std.string, std.range, std.conv, std.array, std.algorithm, std.math, std.typecons;

void main() {
    auto N = readln.chomp.to!int;
    string[] list = ["7","5","3"];
    foreach (i; 0..8) {
        list ~= list.map!(x => ["7","5","3"].map!(y => x ~ y).array).join;
    }
    list
        .filter!(s => s.canFind("7") && s.canFind("5") && s.canFind("3"))
        .map!(to!int)
        .array
        .sort!"a<b"
        .uniq
        .filter!(x => x <= N)
        .count
        .writeln;
}



Measured memory_bytes: 22908
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// string to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, k; cin >> n >> k;
    vector<long long> vec(n);
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
    }
    

    for(ll i = 0; i < k; i++){
        vector<ll> imos(n+1);

        for(ll j = 0; j < n; j++){
            imos[max(j - vec[j], (ll)0)]++;
            imos[min(j + vec[j] + 1, n)]--;
        }

        rep(j, n+1){
            if(j > 0){
                imos[j] += imos[j-1];
            }
        }
        
        imos.pop_back();
        if(vec == imos){
            break;
        }

        vec = imos;

    }

    
    rep(i, n){
        cout << vec[i] << " ";
    }
    br;
}

Measured memory_bytes: 6428
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
    	int s = Integer.parseInt(sc.next());

    	LinkedList<Integer> a = new LinkedList<Integer>();
    	a.add(s);

    	for (int i=0; i<=1000000; i++){
    		int a_next;
    		if (a.get(i)%2 == 0){
    			a_next = a.get(i)/2;
    		}else {
    			a_next = 3*a.get(i)+1;
    		}

    		if (a.contains(a_next)){
    			System.out.println(i+2);
    			return;
    		}else {
    			a.add(a_next);
    		}
    	}
	}
}

Measured memory_bytes: 20948
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int x, y, z, temp;
int ans = 0;

int main(){
    ios::sync_with_stdio(0);
    cin >> x >> y >> z;
    forr(i,1,x){
        temp = (i*y)+2*z+(i-1)*z;
        if(temp <= x){
            ans = i;
        }else{
            break;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
N = int(input())
li = list(map(int,input().split()))	
Sum = 0
for i in range(len(li)):
    Sum += li[i]
ave = int((Sum / len(li)) + 0.5)

S = 0
for i in range(len(li)):
    S += (li[i] - ave) ** 2
print(S)

Measured memory_bytes: 38544
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    while(cin>>a>>b)
    {
        if(a==b)
        {
            cout<<"Draw"<<endl;
        }
        else
        {
            if(a==1)
                cout<<"Alice"<<endl;
            else if(b==1)
                cout<<"Bob"<<endl;
            else
            {
                if(a>b)
                    cout<<"Alice"<<endl;
                else
                     cout<<"Bob"<<endl;
            }
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool dfs(int x){
  if(x<0)return false;
  if(x==0)return true;
  return dfs(x-4)||dfs(x-7);
}
int N;
main(){
  cin>>N;
  cout<<(dfs(N)?"Yes":"No")<<endl;
}


Measured memory_bytes: 256
N = int(input())
s = [int(input()) for _ in range(N)]

memo = [x for x in s if x%10 != 0]
memo.sort()

if len(memo)==0:
    memo = 0
else:
    memo = min(memo)

if sum(s)%10==0:
    if memo != 0:
        print(sum(s) - memo)
    else:
        print(0)
else:
    print(sum(s))

Measured memory_bytes: 3064
//key2020_a.cpp
//Sat Feb 22 18:05:47 2020

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int h,w,n;
	cin >> h >> w >> n;


	cout << (n+max(h,w)-1)/max(h,w) << endl;
//	printf("%.4f\n",ans);
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif


using namespace std;

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

const int MOD = 1e9 + 7;
const int INF = INT_MAX;

signed main() {
    Fast();

    int n, a;
    cin >> n >> a;

    cout << (n % 500 <= a ? "Yes" : "No") << endl;

    return 0;
}



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

int main(){
    ll n;
    cin >> n;
    vector<ll> p(n);
    rep(i, n)   cin >> p[i];

    ll cnt = 0;
    rep(i, n){
        if(i+1 == p[i]){
            if(i+1 < n && i+2 == p[i+1]){
                p[i+1] = -1;
            }
            cnt++;
        }
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1024
/*
* Note: This template uses some c++11 functions , so you have to compile it with c++11 flag.
*       Example:-   $ g++ -std=c++11 c++Template.cpp
*
* Author : Akshay Pratap Singh
* Handle: code_crack_01
*
*/
 
/********   All Required Header Files ********/
#include <iostream>
#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <climits>

using namespace std;

/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for(int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for(int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define IN(A, B, C) assert( B <= A && A <= C)
#define MP make_pair
#define PB push_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define read(type) readInt<type>()
typedef long long int ll;
typedef unsigned long long int  ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<ll> vll;
typedef vector<vi> vvi;

int main() {

    int N;
    string s1, s2;
    cin >> N >> s1 >> s2;

    ll res = 0;
    int i = 0;
    if( s1[0] == s2[0] ){
        res = 3;
        i = 1;
    } else {
        res = 6;
        i = 2;
    }


    while (i < N) {
        if( s1[i] == s2[i] ){
            if (s1[i-1] == s2[i-1]) {
                res *= 2;
            }
            i += 1;
        } else {
            if( s1[i-1] == s2[i-1] ){
                res *= 2;
            } else {
                res *= 3;
            }
            i += 2;
        }
    }

    cout << res % (ll)1000000007 << endl;

    return 0;
}


Measured memory_bytes: 256
//ΔAGC 018 B
#include<iostream>
#include<cstdio>
#include<fstream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
typedef long long LL;
int a[333][333],f[333],s[333],p[333];
int main()
{
	int n,m,ans,k,i,j,x;
	cin>>n>>m;
	for(i=1;i<=n;i=i+1){
		for(j=1;j<=m;j=j+1)
			cin>>a[i][j];
		p[i]=1;
	}
	for(i=1;i<=m;i=i+1)
		f[i]=1;
	ans=n;
	for(k=1;k<=m;k=k+1){
		for(i=1;i<=n;i=i+1){
			while(p[i]<=m&&!f[a[i][p[i]]]){
				p[i]++;
			}
			if(p[i]>m)
				break;
			s[a[i][p[i]]]++;
			//cout<<a[i][p[i]]<<' ';
		}
		//cout<<endl;
		x=0;
		for(i=1;i<=m;i=i+1){
			if(s[i]>x){
				x=s[i];
				j=i;
			}
		}
		ans=min(ans,x);
		f[j]=0;
		for(i=1;i<=m;i=i+1)
			s[i]=0;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 640
x, y = map(int, input().split())

if x * 2 == y or x * 4 == y:
    print ('Yes')
elif (x / 2 * 2 + x / 2 * 4) == y and y % 2 == 0:
    print ('Yes')
else:

    c = x
    v = y

    while x > 0:
        if y - 4 != 0:
            y -= 2
            x-= 1
        else:
            y -= 4
            x -=1


    if x == y == 0:
        print ('Yes')


    else:
        while c > 0:
            if v - 2 != 0:
                v -= 4
                c-= 1
            else:
                v -= 2
                c -=1

        if c == v == 0:
            print('Yes')
        else:
            print ('No')

Measured memory_bytes: 61888
s=input()
ym=True if 0 < int(s[2:]) < 13 else False
my=True if 0 < int(s[:2]) < 13 else False
if my and ym:
  print('AMBIGUOUS')
elif my:
  print('MMYY')
elif ym:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 61784
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n;
    cin>>n;
    vector <long long> vect(n,0);
    for(int i=0;i<n;i++)
    {
        cin>>vect[i];
    }
    sort(vect.begin(),vect.end());
    double sum=0;
    long long int j=2;
    sum=vect[0]+vect[1];
    for(int i=2;i<n;i++)
    {
        sum+=j*vect[i];
        j*=2;
    }
    double k=pow(2,n-1);
    cout<<setprecision(10)<<sum/k<<endl;
    return 0;
}


Measured memory_bytes: 512
a, b, c, d, e, f = map(int, input().split())
directions = [x for x in input()]


class Dice():
    def __init__(self, a, b, c, d, e, f):
        self.a = a
        self.b = b
        self.c = c
        self.d = d
        self.e = e
        self.f = f

    def rotation(self, directions):
        for direction in directions:
            if direction == 'N':
                self.a, self.b, self.f, self.e = self.b, self.f, self.e, self.a
            if direction == 'S':
                self.a, self.b, self.f, self.e = self.e, self.a, self.b, self.f
            if direction == 'E':
                self.a, self.c, self.f, self.d = self.d, self.a, self.c, self.f
            if direction == 'W':
                self.a, self.c, self.f, self.d = self.c, self.f, self.d, self.a
        return self


dice = Dice(a, b, c, d, e, f)
print(dice.rotation(directions).a)



Measured memory_bytes: 5612
import sys
sys.setrecursionlimit(10**6)
MOD = 10**9 + 7

#上限指定がなければ0,0 or 0,1 or 1,0
pow_3 = [1]
for _ in range(2*10**5):
  pow_3.append((pow_3[-1]*3)%MOD)

def F(i):
  # i桁目以降をL[i:]以下で作る方法
  if i == L_size:
    return 1
  result = 0
  c = int(L[i])
  if c == 0:
    # 0,0ととるしかない
    result += F(i+1)
  else:
    # 0,1 あるいは 1,0 ととった場合
    result += 2*F(i+1)
    # 0,0ととった場合は、下の桁は自由
    result += pow_3[L_size - i - 1]
  result %= MOD
  return result



L = input()
L_size = len(L)

answer = F(0)
print(answer)

Measured memory_bytes: 96992
//C
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<pii> vii;
const int INF=(int)2e9;
const double PI=(double)acos(-1.0);
const double EPS=(double)1e-9;
const ll MOD=(ll)1e9+7;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define REPP(i,a,b,c) for(int i=a;i<=b;i+=c)
#define REP(i,a,b) REPP(i,a,b,1)
#define FOR(i,n) REP(i,0,n-1)
#define REVV(i,a,b,c) for(int i=a;i>=b;i-=c)
#define REV(i,a,b) REVV(i,a,b,1)
#define FORD(i,n) REV(i,n-1,0)

int n,a,dat[100005],res;

int main(){
	FOR(i,100003)dat[i]=0;
	scanf("%d",&n);
	REP(i,1,n)scanf("%d",&a),dat[a-1]++,dat[a]++,dat[a+1]++;
	res=0;
	FOR(i,100003)res=max(res,dat[i]);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 640
/********************************************************
  **░██████╗██╗░░░░░░█████╗░██╗░░░██╗██╗░█████╗░░██████╗░**
  **██╔════╝██║░░░░░██╔══██╗██║░░░██║██║██╔══██╗██╔════╝░**
  **╚█████╗░██║░░░░░███████║╚██╗░██╔╝██║██║░░╚═╝██║░░██╗░**
  **░╚═══██╗██║░░░░░██╔══██║░╚████╔╝░██║██║░░██╗██║░░╚██╗**
  **██████╔╝███████╗██║░░██║░░╚██╔╝░░██║╚█████╔╝╚██████╔╝**
  **╚═════╝░╚══════╝╚═╝░░╚═╝░░░╚═╝░░░╚═╝░╚════╝░░╚═════╝░**
  *********************************************************/
 
#include <bits/stdc++.h>
using namespace std;
 
 
#define ll                          long long
#define ld                          long double
 
#define forn(i,n)                   for(int i=0;i<n;++i)
#define all(v)                      v.begin(), v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define isSubstring(s1,s2)          s1.find(s2) != std::string::npos
	
#define pb                          push_back
#define pf                          push_front
#define mp                          make_pair
#define fr                          first
#define sc                          second
 
#define vpi                         vector<pair<int,int>>
#define vi                          vector<int>
#define sz(a)                       (int)a.size()
 
#define   endl                       "\n"
#define     nl                       cout<<"\n";
#define fastio                       ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define  MN                           INT_MIN
#define  MX                           INT_MAX
bool isPrime(ll n){if(n<2)return false;for(ll x = 2;x*x <=n;x++){if(n%x == 0)return false;}return true;}
bool isPerfectSquare(long double x){long double sr=sqrt(x);return((sr-floor(sr))==0);}
int gcd(int a, int b){if(a==0)return b;if(b==0) return a;if(a==b)return a;if(a>b)return gcd(a-b,b);return gcd(a,b-a);}

int main()
{
	fastio;
	ll x,k,d;
	cin >> x >> k >> d;
	ll toDel = 0;
	if(x < 0 ) x = -x;
	ll l = 0, r = k;
	while(l<=r)
	{
		ll mid = (l+r) / 2LL;
		if(x/d >= mid)
		{
			toDel = mid;
			l = mid + 1LL;
		}else{
			r = mid - 1LL;
		}
	}
	ll ans = x - toDel*d;
	k-= toDel;
	if(k&1){
		ans = x - toDel*d - d;
	}
	if(ans < 0 )
		ans = - ans;
	cout << ans << endl;
}

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

#define N 1000

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1) {
        int n, m, list[N];
        cin>>n>>m;
        
        if (n == 0 && m == 0) break;
        
        for (int i = 0; i < N; i++) {
            list[i] = 0;
        }
        
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                int p;
                cin>>p;
                list[j] += p;
            }
        }
        
        int max = 0;
        for (int i = 0; i < n; i++) {
            if (max < list[i]) max = list[i];
        }
        
        cout<<max<<endl;
    }
    return 0;
}



Measured memory_bytes: 3136
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }
void modpow(ref long x, long y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto K = RD;
	auto X = RD;

	writeln(K*500 >= X ? "Yes" : "No");
	stdout.flush;
	debug readln;
}


Measured memory_bytes: 256
from collections import OrderedDict
N,K,Q = map(int,input().split())
answer = []
dic = OrderedDict()
for i in range(N):
    b = "name" + str(i+1)
    dic[b] = K - Q
for i in range(Q):
    answer = int(input())
    ans = "name" + str(answer)
    dic[ans]= dic[ans] + 1
for key,value in dic.items():
    if value <= 0:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 41204
from operator import add
import sys
input=sys.stdin.readline


class SegTree():
    def __init__(self, N, e, operator_func=add):
        self.e = e # 単位元
        self.size = N
        self.node = [self.e] * (2*N)
        self.operator_func = operator_func # 処理(add or xor max minなど)

    def set_list(self, l):
        for i in range(self.size):
            self.node[i+self.size-1] = l[i]
        for i in range(self.size-1)[::-1]:
            self.node[i] = self.operator_func(self.node[2*i+1], self.node[2*i+2])
    
    def update(self, k, x):
        k += self.size-1
        self.node[k] = x
        while k >= 0:
            k = (k - 1) // 2
            self.node[k] = self.operator_func(self.node[2*k+1], self.node[2*k+2])

    def get(self, l, r):
        # [l, r) についてqueryを求める
        x = self.e
        l += self.size
        r += self.size

        while l<r:
            if l&1:
                x = self.operator_func(x, self.node[l-1])
                l += 1
            if r&1:
                r -= 1
                x = self.operator_func(x, self.node[r-1])
            l >>= 1
            r >>= 1
        return x


def solve():
    N, K = map(int, input().split())
    P = list(map(int, input().split()))
    tree = SegTree(N, 10**12, min)
    tree_min = SegTree(N, 10**12, min)
    tree_max = SegTree(N, -10**12, max)
    tree_min.set_list(P)
    tree_max.set_list(P)
    tree.set_list([P[i]-P[i-1] if i else P[i] for i in range(N)])

    f = lambda l,r:tree.get(l+1, r)>=0

    ans = N-K+1
    isOrig = 0
    for i in range(N-K):
        if f(i, i+K):
            ans -= 1
            isOrig = 1
        elif tree_min.get(i, i+1+K)==P[i] and tree_max.get(i, i+1+K)==P[i+K]:
            ans -= 1
    if f(N-K, N):
        ans -= 1
        isOrig = 1
    ans += isOrig
    print(ans)


solve()


Measured memory_bytes: 111060
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);

using namespace std;

int main()
{
    ll n;cin >> n;
    vector<ll> d;
    for(ll i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            d.pb(i);
            if(n / i != i)d.pb(n / i);
        }
    }
    sort(all(d));
    ll ans = 1e18;
    for(auto x: d)
    {
       // cout << x << endl;
        ans = min(ans, x - 1 + (n / x) - 1);
    }
    cout << ans;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <map>
#include <queue>
#include <deque>
#include <set>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define FOR(i,a,b) for (ll i = (a) ; i <= (b); ++i)
#define RFOR(i,a,b) for (ll i = (a) ; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
//#define repitr(itr, st) for(auto itr = st.begin(); itr != st.end(); ++itr)
#define P_B push_back
#define PO_B pop_back
#define E_B emplace_back
#define M_P make_pair
#define fi first
#define se second
#define debug(x) cout << #x << ": " << x << endl
//#define print(x) printf("%d\n", x)

using namespace std;
using ll = long long;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using VI = vector<int>;
using VL = vector<ll>;
using VVI = vector<vector<int> >;
using VVL = vector<vector<ll> >;
//int dx[4] = {1, 0, -1, 0};
//int dy[4] = {0, 1, 0, -1};
//const ll LINF = (ll)1e18 - 1;
//const int INF = 1e9 - 1;
//int:±2*10^9くらい　ll:±9*10^18くらい



void Main(){
	int n, a;
	cin >> n;

	if(n<=599) a = 8;
	else if(n<=799) a = 7;
	else if(n<=999) a = 6;
	else if(n<=1199) a = 5;
	else if(n<=1399) a = 4;
	else if(n<=1599) a = 3;
	else if(n<=1799) a = 2;
	else if(n<=1999) a = 1;


	cout << a << endl;
}

int main()
{
	cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();

  return 0;
}


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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

template <typename T>
auto factorization(T x) {
    vector<pair<T, T>> ans;
    for (ll i = 2; i * i <= x; ++i) {
        if (x % i != 0) continue;
        ll count = 0;
        while (x % i == 0) {
            ++count;
            x /= i;
        }
        ans.push_back(make_pair(i, count));    
    }
    if (x != 1) ans.push_back(make_pair(x, 1));
    return ans;
} 

int main() {
    cout << setprecision(15) << fixed;
    ll N;
    cin >> N;
    auto fac = factorization(N);
    ll res = 0;
    for (auto&& f : fac) {
        ll e = f.second;
        ll tmp = 0, cur = 1;
        while (e >= cur) e -= cur++, ++tmp;
        res += tmp;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <list>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <map>
#include <fstream>
#include <complex>
using namespace std;

const int inf = 2000000;
int main()
{
	int N,K;
	string S;
	cin>>N>>S>>K;

	char c = S[K-1];
	for(int i=0; i<S.size(); i++)
	{
		if(S[i] != c)
		{
			S[i] = '*';
		}
	}
	cout<<S<<endl;
	return 0;
}

Measured memory_bytes: 256
(let* ((n (read))
       (s (read-line))
       (l 0)
       (r (1- n))
       (ans 0))
  ;
  (loop :named main
        :do (cond ((<= r l)
                   (return-from main))
                  ((and (char= (aref s l) #\W) (char= (aref s r) #\R))
                   (progn (incf ans) (incf l) (decf r)))
                  ((char= (aref s l) #\W)
                   (decf r))
                  ((char= (aref s r) #\R)
                   (incf l))
                  (t 
                   (progn (incf l) (decf r)))))
  (format t "~A~%" ans))


Measured memory_bytes: 27028
#include<iostream>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<cmath>
#include<ctime>

using namespace std;
const int maxn = 1e5 + 7;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
const double pi = acos(-1.0);
typedef long long ll;
#define pb push_back

int n;
ll a[405];
ll dp[405][405];
ll sum[405][405];

int main(){
	scanf("%d", &n);
	memset(dp, inf, sizeof dp);
	memset(sum, 0, sizeof sum);
	for(int i = 1; i <= n; ++i){
		scanf("%lld", &a[i]);
		dp[i][i] = 0;
		sum[i][i] = a[i];
	}
	for(int len = 1; len < n; ++len){
		for(int i = 1; i <= n && i + len <= n; ++i){
			int j = i + len;
			for(int k = i; k <= j; ++k){
				sum[i][j] = sum[i][k] + sum[k+1][j];
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + sum[i][j]);
			}
		}
	}
	printf("%lld\n", dp[1][n]);
}

Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
int mod = 1e9 + 7;

signed main() {
    int N, u, v;
    cin >> N >> u >> v;
    --u, --v;
    vector<vector<int>> graph(N, vector<int>());
    for (int i = 0; i < N - 1; i++) {
        int x, y;
        cin >> x >> y;
        graph[x - 1].push_back(y - 1);
        graph[y - 1].push_back(x - 1);
    }
    vector<vector<int>> length(N, vector<int>(2, - 1));
    function<void(int, int, int)> dfs = [&](int base, int count, int address) {
        length[base][address] = count;
        for (auto i : graph[base]) {
            if (length[i][address] == -1) dfs(i, count + 1, address);
        }
    };
    dfs(u, 0, 1);
    dfs(v, 0, 0);
    int ans = 0;
    for (auto i : length) {
        cerr << i[0] << " " << i[1] << endl;
        if (i[1] < i[0]) {
            ans = max(ans, i[0]);
        }
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 19072
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    vector<int> b;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    a.push_back(1000000000);
    sort(a.begin(),a.end());
    int count = 0;
    int veri  =0;
    for(int i=0;i<n;i++){
        count ++;
        if(a[i] != a[i+1]){
            b.push_back(count);
            count =0;
            veri ++;
        }
    }
    sort(b.begin(),b.end());
    int ans=0;
    for(int i=0;i< (veri-k);i++){
        ans += b[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2800
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int n, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 1;
	scanf("%d %d", &n, &k);
	f(i, 100000){
		if (k % (i + 1) == 0){
			if ((i + 1) >= n){
				if (ans < (k / (i + 1)))ans = k / (i + 1);
			}
			if ((k/(i + 1)) >= n){
				if (ans < (i + 1))ans = i + 1;
			}
		}
	}

	printf("%d\n", ans);


	return 0;
}

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


i = 0

for i in range(len(A)):
    if (A[i] % 2 == 0):
        if A[i] % 3 != 0 and A[i] % 5 != 0:
            print('DENIED')
            exit()
        else:
            continue
    else:
        continue

print('APPROVED')

Measured memory_bytes: 62008
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;

const ll MOD = 1000000007;
const long double EPS = 1e-10;
const int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

ll cnt[26];

int main() {
    std::ios::sync_with_stdio(0); cin.tie(0);
    int n;
    string s;
    cin >> n >> s;

    for(int i=0;i<n;++i) {
        ++cnt[s[i] - 'a'];
    }

    ll ans = 1LL;
    for(int i=0;i<26;++i) {
        ans *= cnt[i]+1LL;
        ans %= MOD;
    }

    cout << ans-1 << endl;
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int[] data = new int[n];
    	for (int i = 0; i < n; i++) {
    		data[i] = sc.nextInt();
    	}
		
    	int q = sc.nextInt();
    	for (int i = 0; i < q; i++) {
    		if (solve(data, 0, sc.nextInt())) {
    			System.out.println("yes");
    		} else {
    			System.out.println("no");
    		}
    	}

    	sc.close();
	}

	private static boolean solve(int[] data, int p, int m) {
		if (m == 0) {
			return true;
		} else if (m < 0 || p >= data.length) {
			return false;
		} else {
			if (solve(data, p + 1, m - data[p])) {
				return true;
			}
			if (solve(data, p + 1, m)) {
				return true;
			}
			
			return false;
		}
	}
}

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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define INF 1000000007
// cin.eof() 入力個数の問題
int main(){
int a,b;
cin>>a>>b;
cout<<a*b<<endl;



  return 0;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    bool colors[4];
    for (int i = 0; i < 4; i++) {
        colors[i] = false;
    }

    int n;
    cin >> n;

    for (int i = 0; i < n; i++) {
        char arare;
        cin >> arare;
        switch (arare) {
            case 'G':
                colors[0] = true;
                break;
            case 'P':
                colors[1] = true;
                break;
            case 'W':
                colors[2] = true;
                break;
            case 'Y':
                colors[3] = true;
                break;
        }
    }

    int ans = 0;
    for (int i = 0; i < 4; i++) {
        if (colors[i]) {
            ans++;
        }
    }
    cout << ((ans == 3)? "Three": "Four") << endl;

    return 0;
}

Measured memory_bytes: 256
#define MAX 2000001
#define VMAX 10000

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

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

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

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

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

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

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

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

  return 0;
}

Measured memory_bytes: 8464
//第8回シンデレラガール総選挙は是非本田未央ちゃんに投票をお願いします！
//ファンのことも他のアイドルの子たちのことも本当に大事にしてて、今まで周りに色んなものを与えてくれました。
//今度は私たちが未央ちゃんにお返しをする番です。みんなでガラスの靴を履かせてあげましょう！
// #本田未央を一番星に #本田未央を令和のシンデレラガールに #第8回シンデレラガール総選挙
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int out[(1<<17)+10];
int n;
void sw(int a,int b){
	rep(i,(1<<n)){
		int x=0,y=0;
		if((out[i]&(1<<a))>0) x=1;
		if((out[i]&(1<<b))>0) y=1;
		out[i]-=(x<<a);out[i]+=(x<<b);
		out[i]-=(y<<b);out[i]+=(y<<a);
	}
}
int main()
{
	int a,b,c,d;
	cin>>n>>a>>b;c=(a^b);d=__builtin_popcount(c);
	if(d%2==0){
		//assert(false);
		cout<<"NO"<<endl;return 0;
	}
	rep(i,(1<<n)){
		out[i]=(i^(i/2));
	}
	for(int i=d-2;i>0;i-=2){
		rep(j,(1<<(i-1))) swap(out[(1<<n)-1-j],out[(1<<n)-1-j-(1<<i)]);
	}
	/*rep(i,(1<<n)-1){
		if(__builtin_popcount((out[i]^out[i+1]))!=1){
			cout<<i<<' '<<out[i]<<' '<<out[i+1]<<endl;
		}
	}*/
	vector<int> from,to;
	rep(i,n){
		if((out[(1<<n)-1]&(1<<i)) && (c&(1<<i))) continue;
		if((out[(1<<n)-1]&(1<<i))) from.pb(i);
		if((c&(1<<i))) to.pb(i);
	}
	rep(i,from.size()){
		sw(from[i],to[i]);
	}
	rep(i,(1<<n)) out[i]^=a;
	assert(out[0]==a);
	assert(out[(1<<n)-1]==b);
	rep(i,(1<<n)-1){
		if(__builtin_popcount((out[i]^out[i+1]))!=1){
			//cout<<i<<' '<<out[i]<<' '<<out[i+1]<<endl;
			assert(false);
		}
	}
	cout<<"YES"<<endl;
	rep(i,(1<<n)){
		cout<<out[i];
		if(i<(1<<n)-1) cout<<' ';else cout<<endl;
	}
}


Measured memory_bytes: 1536
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		int D = sc.nextInt();
		
		int[][] X = new int[N][D];
		for(int i=0;i<N;i++) {
			for(int p=0;p<D;p++) {
				X[i][p] = sc.nextInt();
			}
		}
		
		int count = 0;
		for(int i=0;i<N;i++) {
			for(int p=i+1;p<N;p++) {
				double total = 0;
				for(int d =0;d<D;d++) {
					double a =Math.pow(X[i][d] - X[p][d],2); 
					total += a;
				}
				total = Math.sqrt(total);
				if(total % 1 == 0) {
					count ++;
				}
			}
		}
		System.out.println(count);	
		sc.close();	
	}
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <set>
using namespace std;
int main(){
    int n,temp;
    set<int> s;
    scanf("%d",&n);
    while(n--){
        scanf("%d",&temp);
        s.insert(temp);
    }scanf("%d",&n);
    while(n--){
        scanf("%d",&temp);
        s.erase(temp);
    }
    for(int i:s)printf("%d\n",i);
}


Measured memory_bytes: 12044
#include<stdio.h>
main()
{
    char a,b,c,d,e,f;
    scanf("%c%c%c",&a,&b,&c);
    scanf(" %c%c%c",&d,&e,&f);
    if(a==f&&b==e&&c==d)
    	printf("YES");
    	else
    		printf("NO");
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define dump(x) cout << (x) << endl
typedef long long ll;
typedef pair<ll, ll> pl;
typedef pair<int, int> pi;
typedef vector<int> V;

int main() {
  ll d, n;
  cin >> d >> n;
  ll x = 1;
  if (d == 1) x = 100;
  else if (d == 2) x = 10000;
  if (n == 100) {
    dump((n+1)*x);
    return 0;
  }
  dump(n*x);
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

int n,m;
vector<vector<int>> to;

signed main(){
	int n;
	cin>>n;
	vector<int> a(n);
	int f=0,d=0,o=0;
	rep(i,n){
		cin>>a[i];
		if(a[i]%4==0) f++;
		else if(a[i]%2==0) d++;
		else o++;
	}
	if(f+1-o>=(d?1:0)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 1024