akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;
 

int main(void){
    int n;
    cin>>n;
    vector<ll>x(n),y(n),a(n);
    for(int i=0;i<n;i++){
        a[i]=i;
        cin>>x[i]>>y[i];
    }
    double ans = 0;
    ll f = 0;
    do{
        ll  X = x[a[0]],Y=y[a[0]];
        for(ll i=1;i<n;i++){
            ll tmp1 = (x[a[i]]-X)*(x[a[i]]-X);
            ll tmp2 = (y[a[i]]-Y)*(y[a[i]]-Y);
            X = x[a[i]],Y = y[a[i]];
            ans += (double)sqrt(tmp1+tmp2);
        }
        f++;
    }while(next_permutation(a.begin(),a.end()));
    printf("%.10lf",(double)ans/f);
    cout<<endl;
    return 0;
}

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



int32_t main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int a;
	cin >> a;
	cout<<a + a * a + a*a*a<<endl;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)

typedef long long ll;
using namespace std;
int mod = 1000000007;

int main(void){
    string mes[] = {"first", "second"};
    int winner = 1;
    int N; cin >> N;
    rep(i, N){
        int a; cin >> a;
        if(a % 2 == 1) winner = 0;
    }
    cout << mes[winner] << endl;
    return 0;
}

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

int main(){
   int N, A, B;
   std::cin >> N >> A >> B;
   std::string S;
   std::cin >> S;
   int nai = 0;
   int gai = 0;
   for (int i=0; i<N; i++){
      if (S.at(i) == 'a'){
         if (nai+gai < A+B){
            nai++;
            std::cout << "Yes" << std::endl;
         } else{
            std::cout << "No" << std::endl;
         }
      } else if (S.at(i) == 'b'){
         if ((nai+gai < A+B) && (gai < B)){
            gai++;
            std::cout << "Yes" << std::endl;
         } else{
            std::cout << "No" << std::endl;
         }
      } else{
         std::cout << "No" << std::endl;
      }
   }
}



Measured memory_bytes: 896
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let N=read::<i32>();
    println!("{}",if N%100*21<=N{1}else{0})
}

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

#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define REACH cerr<<"reached line "<<__LINE__<<endl
#define DBG(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl

using uint=unsigned int;
using ll=long long;
using pii=pair<int,int>;
using vi=vector<int>;
using ld=long double;

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

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

int read(){
	int i;
	scanf("%d",&i);
	return i;
}

ll readLL(){
	ll i;
	scanf("%lld",&i);
	return i;
}

string readString(){
	static char buf[3341919];
	scanf("%s",buf);
	return string(buf);
}

char* readCharArray(){
	static char buf[3341919];
	static int bufUsed=0;
	char* ret=buf+bufUsed;
	scanf("%s",ret);
	bufUsed+=strlen(ret)+1;
	return ret;
}

template<class T,class U>
void chmax(T& a,U b){
	if(a<b)
		a=b;
}

template<class T,class U>
void chmin(T& a,U b){
	if(a>b)
		a=b;
}

int main(){
	string s=readString();
	int k=((int)s.size()+1)/2;
	int p=0;
	REP(i,k)
		if(s[i]=='p')
			p--;
	FOR(i,k,(int)s.size())
		if(s[i]=='g')
			p++;
	cout<<p<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<map>
#include<string.h>
#include<queue>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<cstdlib>
#include<math.h>
#include<set>
#include<array>
using namespace std;

template<class T>inline bool chmax(T&a, T b) { if (a < b) { a = b; return 1; }return 0; }
template<class T>inline bool chmin(T&a, T b) { if (a > b) { a = b; return 1; }return 0; }



#define rep(n) for(int i=0;i<n;i++)
typedef pair<int, int> pii;

typedef long long ll;
typedef pair<ll, ll>pll;
const int MOD = 1000000007;
const int INF = 1 << 29;


int main() {
	int n;

	cin >> n;
	cout << n * n << endl;
	return 0;
}


Measured memory_bytes: 256
# include<bits/stdc++.h>
using namespace std;
int main(){
	string weather[4] = {"Sunny", "Cloudy", "Rainy", "Sunny"};
  	string inp;
  	cin >> inp;
  	for(int i = 0; i < 3; i++){
    	if(inp == weather[i])
          cout << weather[i+1]<<'\n';
    }
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

const int INF = INT_MAX / 2;

vector<vector<int>> dp;

int solve(const int len1, const int len2, const string &s1, const string &s2) {
    for (int pos1 = 0; pos1 <= len1; pos1++) {
        for (int pos2 = 0; pos2 <= len2; pos2++) {
            char c1 = s1[pos1];
            char c2 = s2[pos2];
            if (pos1 != 0 && pos2 != 0 && c1 == c2) {
                chmin(dp[pos1][pos2], dp[pos1 - 1][pos2 - 1]);
            }
            if (pos1 - 1 >= 0) {
                chmin(dp[pos1][pos2], dp[pos1 - 1][pos2] + 1);
            }
            if (pos1 - 1 >= 0 && pos2 - 1 >= 0) {
                chmin(dp[pos1][pos2], dp[pos1 - 1][pos2 - 1] + 1);
            }
            if (pos2 - 1 >= 0) {
                chmin(dp[pos1][pos2], dp[pos1][pos2 - 1] + 1);
            }
        }
    }

    return dp[len1][len2];
}

int main(void) {
    string s1, s2;
    cin >> s1 >> s2;
    int len1 = (int) s1.size(), len2 = (int) s2.size();
    s1 = " " + s1;
    s2 = " " + s2;

    dp.resize(len1 + 1, vector<int>(len2 + 1, INF));
    dp[0][0] = 0;
    // for (int i = 0; i <= len1; i++) {
    //     dp[i][0] = 0;
    // }
    // for (int i = 0; i <= len2; i++) {
    //     dp[0][i] = 0;
    // }

    cout << solve(len1, len2, s1, s2) << endl;

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

    return 0;
}



Measured memory_bytes: 6912
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;
vector<vector<int>> seqs;
int dfs(int index,int size,vector<int> seq){
    if(index==size){
        seqs.push_back(seq);
        return 0;
    }
    
    for(int i=index;i<size;i++){
        swap(seq[index],seq[i]);
        dfs(index+1,size,seq);
        swap(seq[index],seq[i]);
    }
    
}
int main(){
    int n;
    cin>>n;
    vector<double>x(n);
    vector<double>y(n);
    for(int i=0;i<n;i++){
        cin>>x[i]>>y[i];
    }
    vector<int> seq;
    for(int i=0;i<n;i++){
        seq.push_back(i);
    }
    dfs(0,n,seq);
    double sum=0;
    for(int i=0;i<seqs.size();i++){
        
        for(int j=0;j<seqs[i].size()-1;j++){
            double difx=x[seqs[i][j]]-x[seqs[i][j+1]];
            double dify=y[seqs[i][j]]-y[seqs[i][j+1]];
            sum+=pow(difx*difx+dify*dify,0.5);
        }
    }
    int mul=1;
    for(int i=1;i<=n;i++){
        mul*=i;
    }
    cout<<std::fixed<<std::setprecision(6)<<sum/mul<<endl;
    return 0;
}

Measured memory_bytes: 3256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,ans=0,cnt; cin>>n;
    vector<string> s(n,"");
    rep(i,n) cin>>s[i];
    rep(k,n){
        cnt=0;
        for(int i=0;i<=n-2;i++){
            for(int j=i+1;j<=n-1;j++){
                if(s[(i+k)%n][j]==s[(j+k)%n][i]) cnt++;
            }
        }
        if(cnt==n*(n-1)/2) ans+=n;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10000000)
import math
import bisect
from collections import deque
def input():
    return sys.stdin.readline()[:-1]

n = int(input())

f = [0 for i in range(n+1)]

ans = 0
lis = [0]
for i in range(1,n+1):
    lis.append(lis[-1]+i)

for i in range(1,n+1):
    tmp = n//i
    ans+=lis[tmp]*i

print(ans)


Measured memory_bytes: 353924
#include <bits/stdc++.h> 
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define sz(x) (int)(x).size()
typedef vector<int> vi;
// #define ll long long 
#define int long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define all(x) (x).begin(), (x).end()
const int MOD = 1e9+7;
int mpow(int a,int b,int p=MOD){a=a%p;int res=1;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b=b>>1;}return res%p;}
const int N=2*1e5+2;
int dp[64][2][2][2];
bool vis[64][2][2][2];
int get(int l,int r,int d,bool bot,bool top,bool first)
{
	if(d<0) return 1;
	if(vis[d][bot][top][first])
	{
		return dp[d][bot][top][first];
	}
	int ans=0;
	for(int y=0;y<2;y++)
	{
		for(int x=0;x<2;x++)
		{
			if(x>y) continue;
			if((!first)&&(x!=y)) continue;
			int bitr= !!(r&(1LL<<d));
			int bitl= !!(l&(1LL<<d));
			// cout<<bitl<<" "<<bitr<<"\n";
			if(top&&(y>bitr)) continue;
			if(bot&&(x<bitl)) continue;
			ans+=get(l,r,d-1,bot&&(x==bitl),top&&(y==bitr),first||(y>0));
			ans%=MOD;
			// cout<<"*";
		}
	}
	vis[d][bot][top][first]=true;
	// cout<<ans<<" ";
	return dp[d][bot][top][first]=ans;
}
int32_t main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int l,r;
	cin>>l>>r;
	cout<<get(l,r,62,true,true,false);
}
// I never lose. I either win or I learn

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

unsigned long round_up(long double f)
{
	if (f > (unsigned long)f) {
		return (unsigned long)f + 1;
	}
	return f;
}

int main(void)
{
	int j;
	scanf("%d", &j);
	unsigned long curr_a, curr_b;
	for (int i = 0; i < j; ++i) {
		int a, b;
		scanf("%d %d", &a, &b);
		if (!i) {
			curr_a = a;
			curr_b = b;
			continue;
		}
		unsigned long mf;
		if ((long double)curr_a / a > (long double)curr_b / b) {
			mf = round_up((long double)curr_a / a);
		} else {
			mf = round_up((long double)curr_b / b);
		}
		curr_a = a * mf;
		curr_b = b * mf;
	}
	printf("%lu\n", curr_a + curr_b);
}


Measured memory_bytes: 128
#include "stdio.h"
#include "string.h"

int main(){
  char c[3];

  int idx = 0;
  
  scanf("%s", c);

  if(c[0] == '1'){
    idx++;
  }

  if(c[1] == '1'){
    idx++;
  }

  if(c[2] == '1'){
    idx++;
  }

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

  return 0;
}


Measured memory_bytes: 128
MOD=10**9+7

S=input()
S=S[::-1]
N=len(S)

def POWt(N):
    arr=[1]
    for i in range(1,N+1):
        arr.append(arr[-1]*10%13)
    return arr

dp=[[0]*13 for i in range(N+1)]
dp[0][0]=1
POW=POWt(N)
for i in range(N):
    for j in range(13):
        if(S[i]!='?'):
            dp[i+1][(j+(int(S[i])*POW[i]%13))%13]=(dp[i+1][(j+(int(S[i])*POW[i])%13)%13]+dp[i][j])%MOD
        else:
            for k in range(10):
                dp[i+1][(j+k*POW[i]%13)%13]=(dp[i+1][(j+k*POW[i]%13)%13]+dp[i][j])%MOD
print(dp[N][5])

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

using namespace std;

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

void solve() {
  int l[4];
  cin >> l[0] >> l[1] >> l[2] >> l[3];
  sort(l, l+4);
  bool good = true;
  good &= l[0] == 1;
  good &= l[1] == 4;
  good &= l[2] == 7;
  good &= l[3] == 9;
  if(good) cout << "YES\n";
  else cout << "NO\n";
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc088_b.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;
  
  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  sort(c.begin(), c.end(), greater<int>());
  int alice = 0;
  int bob = 0;

  rep(i, N) {
    if (i % 2 == 0) alice += c[i];
    else
      bob += c[i];
  }

  cout << alice - bob << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static int num1[],num2[];
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int K=sc.nextInt();
		int arr[]=new int[N];
		int count1=0,count2=0,zero=0;
		int min=0,result1=2147483647,result2=2147483647,result = 2147483647;
		for(int i=0;i<N;i++) {
			arr[i]=sc.nextInt();
			if(arr[i]<0) {
				count1++;
			}else if(arr[i]>0) {
				count2++;
			}else {
				zero=1;
			}
		}
		num1=new int[count1];
		for(int i=0;i<count1;i++) {
			num1[i]=arr[count1-1-i];
		}

		num2=new int[count2];
		for(int i=0;i<count2;i++) {
			num2[i]=arr[i+count1+zero];
		}
		int newk=K-zero;
		if(count1>0) {		
			if(newk<=count1) {
				result1=-num1[newk-1];
			}
		}
		if(count2>0) {			
			if(newk<=count2) {
				result2=num2[newk-1];
			}
		}
		if(count1>0||count2>0) {
		min=Math.min(result1, result2);
		}
		int x=Math.min(count1,newk)-1,y=Math.min(count2,newk)-1;
		if(count1>0&count2>0){
			for(int i=x;i>=-1&(newk-2-i)<=y;i--) {	
				if(newk-2-i<0) {
					result=-num1[i];
				}else if(i<0) {
					result=num2[newk-2-i];
				}else if(newk-2-i>=0&i>=0){
					result1=-num1[i]*2+num2[newk-2-i];
					result2=-num1[i]+num2[newk-2-i]*2;
					result=Math.min(result1, result2);
				}
				if(result<min) {
					min=result;
				}			
			}
		}		
		System.out.println(min);							
		sc.close();
	}
}

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

struct P {
	double x, y;
} p[111], cur, s, t, tt;

int n;

double len(P p) {
	return sqrt(1.*p.x*p.x + 1.*p.y*p.y);
}

double dot(P p1, P p2) {
	return 1.*p1.x*p2.x + 1.*p1.y*p2.y;
}

int cmp(const P &a, const P &b) {
	return atan2(a.y, a.x) < atan2(b.y, b.x);
}

int main() {
	scanf("%d", &n);
	s.x = s.y = 0;
	for(int i=0;i<n;i++) {
		scanf("%lf%lf", &p[i].x, &p[i].y);
		s.x += p[i].x; s.y += p[i].y;
	}
	sort(p, p+n, cmp);
	
	double ans = 0;
	for(int i=0;i<n;i++) {
		t.x = t.y = 0;
		for(int j=i;j<n;j++) {
			t.x+=p[j].x;
			t.y+=p[j].y;
			ans = max(ans, len(t));
			tt.x = s.x - t.x;
			tt.y = s.y - t.y;
			ans = max(ans, len(tt));
		}
	}
	printf("%.12lf\n", ans);
	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll                          long long
#define in(a)                       ll a; cin>>a;
#define in2(a,b)                    ll a,b; cin>>a>>b;
#define in3(a,b,c)                  ll a,b,c; cin>>a>>b>>c;
#define in4(a,b,c,d)                ll a,b,c,d; cin>>a>>b>>c>>d;
#define in5(a,b,c,d,e)              ll a,b,c,d,e; cin>>a>>b>>c>>d>>e;
#define lelo(b)                     for(auto &i:b)cin>>i;
#define ff                          first
#define ss                          second
#define call(v)                     v.begin(),v.end()
#define rall(v)                     v.rbegin(),v.rend()
#define show(x)                     for(auto t:x)cout<<t<<" ";
#define pb                          push_back
#define bhar(s,v)                   memset(s,v,sizeof(s))
#define endl                        "\n"                       
#define ce(x)                       cout<<x<<"\n";
#define nl                          cout<<endl;
#define jaldi                       ios_base::sync_with_stdio(false);cin.tie(NULL);
#define dekh_lo                     ce("dekh_lo");
#define sz(x)                       (ll)x.size()
#define re                          return

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

typedef pair<ll,ll> pii;
typedef vector<pii> vii;
typedef vector<ll> vi;

const ll mod=1e9+7;
const ll N=4e5+5;
ll i,j;

/*


*/

void solve(){
    in(x);
    if(x==0){
        ce("1");
        re;
    }
    ce("0");
}

int32_t main(){
    // jaldi
    ll t; 
    // cin>>t;
    t=1;     
    while(t--){
        solve();
    }
}

/*


*/



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

int main() {
  int x, n;
  cin >> x >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  if (n == 0) {
    cout << x << endl;
    return 0;
  }
  sort(p.begin(), p.end());
  bool found = false;
  for (int i = 0; i < n; ++i) {
    if (p[i] == x) {
      found = true;
    }
  }
  if (!found) {
    cout << x << endl;
    return 0;
  }
  vector<int> v1;
  for (int i = 0; i <= 101; ++i) {
    v1.push_back(i);
  }
  vector<int> diff;
  set_difference(v1.begin(), v1.end(), p.begin(), p.end(),
                 inserter(diff, diff.begin()));
  // for (int foo : diff) {
  //   cout << foo << " ";
  // }
  // cout << endl;
  // if (diff.size() == 0) {
  //   cout << 0 << endl;
  //   return 0;
  // }
  int ab = 1000000;
  for (int i = (int)diff.size() - 1; i >= 0; --i) {
    ab = min(ab, abs(x - diff[i]));
  }
  for (int i = 0; i < (int)diff.size(); ++i) {
    if (abs(x - diff[i]) == ab) {
      cout << diff[i] << endl;
      return 0;
    }
  }
}


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

int main() {
  int N;
  cin >> N;
  
  vector <int> data(N), data_i(N);
  for (int i = 0; i < N; i++) {
  	cin >> data.at(i);
  }
  
  
  for (int i = 0; i < N; i++) {
  	if (data.at(i) % 2 == 0) {
    	data_i.at(i) = 1;
    }
  }
  
  int i = 0;
  bool x = true;
  while (true) {
    if (i == N) {
      break;
    }
  	if (data_i.at(i) == 1) {
    	if (!(data.at(i) % 3 == 0 || data.at(i) % 5 == 0)){
        	x = false;
        }
    }
    i++;
  }
  
  if (x == true) {
  	cout << "APPROVED" << endl;
  }
  else {
  	cout << "DENIED" << endl;
  }
}

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

int main(void){
        char s[101];
        int k,i;

        scanf("%d",&k);
        scanf("%s",s);

        if (strlen(s) > k){
                for ( i = 0;i < k;i++){
                        printf("%c",s[i]);
                }
                printf("...");
        }
        else {
                printf("%s",s);
        }
        return 0;
}

Measured memory_bytes: 1732
from bisect import bisect_left

n = int(input())
a = list(map(int, input().split()))
a.sort()
ma = a[-1]
mid = ma / 2 # ma/2に最も近いものをとってくればよい

idx = bisect_left(a, mid)

if abs(a[idx] - mid) < abs(a[idx-1] - mid):
	ans_idx = idx
else:
	ans_idx = idx - 1

print(ma, a[ans_idx])

Measured memory_bytes: 14052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>

#define F first
#define S second
#define pb push_back
#define ll long long
#define all(x) x.begin() , x.end()
#define mod(x,m) ((x%m + m )%m)
#define rep(i, start, end) for(int i = start; i < end; ++i)
using namespace std;
using namespace __gnu_pbds;
void OJ();

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
        tree_order_statistics_node_update>;

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

    vector<int> vec(5);
    for ( int& i : vec ) cin >> i;

    rep(i,0,5){
        if ( vec[i] == 0 ){
            return cout << i + 1 , 0;
        }
    }
    return 0;
}

void OJ(){
#ifndef ONLINE_JUDGE
    freopen( "C:\\Users\\ehab\\Desktop\\Code Forces\\CF\\in.txt" , "r" , stdin  );
    // freopen( "C:\\Users\\ehab\\Desktop\\Code Forces\\CF\\out.txt", "w" , stdout );
#endif // ONLINE_JUDGE
}
/*ll binEXP( ll x , ll pw , ll MOD )
{ ll res=1; while(pw>0){ pw%2 ? res *= x : 0; x *= x; x%=MOD; pw /= 2; res%= MOD; } return res%=MOD; }*/

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int h, w;
    //cin >> h >> w;
    while (cin >> h >> w,h != 0 && w != 0){
        for (int i = 0; i < h; i++) {
            if ( i % 2 == 0) {
                for ( int j = 0; j < w; j++) {
                    if ( j % 2 == 0) {
                        cout << '#';
                    } else {
                        cout << '.';
                    }
                }
            } else {
                for ( int j = 0; j < w; j++) {
                    if ( j % 2 == 0) {
                        cout << '.';
                    } else {
                        cout << '#';
                    }
                }
            }
            cout << "\n";
        }
        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 3192
#include<cstdio>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
struct node
{
    int cx,cy;
    ll h;
}pl[105];
ll map[105][105];
ll map2[105][105];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;++i)
    {
        scanf("%d%d%lld",&pl[i].cx,&pl[i].cy,&pl[i].h);
        map[pl[i].cx][pl[i].cy]=pl[i].h;
    }
    int k=0;
    while(pl[k].h==0)
        k++;
    for(int i=0;i<=100;++i)
        for(int j=0;j<=100;++j)
    {
        ll mh=pl[k].h+abs(i-pl[k].cx)+abs(j-pl[k].cy);
        int flag=0;
        for(int p=0;p<n;p++)
        {
            ll ch=mh-abs(i-pl[p].cx)-abs(j-pl[p].cy);
            if(ch<0)
                ch=0;
            if(ch!=pl[p].h)
            {
                flag=1;
                break;
            }
        }
        if(flag==0)
        {
            printf("%d %d %lld\n",i,j,mh);
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll N;
    string S;
    cin >> S;
    if(S == "ARC"){
        cout << "ABC" <<endl;
    }else{
        cout << "ARC" <<endl;
    }
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B;
  cin >> A >> B;
  if (A + B >= 10) {
    cout << "error" << endl;
  } else {
    cout << A + B << endl;
  }

  return 0;
}


Measured memory_bytes: 256
// Problem Code: abc170_b

#include <iostream>
#include <string>

using namespace std;

string crane_and_turtle(int x, int y) {
	for (int j, i = 0; i <= x; i++) {
		j = x - i;
		if (i * 2 + j * 4 == y)
			return "Yes";
	}
	return "No";
}

int main() {
	int x, y;
	cin >> x >> y;
	cout << crane_and_turtle(x, y);
	return 0;
}

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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int N;
    cin >> N;
    int c = 0;
    for(int i = 0; i < N; ++i) {
        int a, b;
        cin >> a >> b;
        if(a == b) ++c;
        else {
            if(c < 3) c = 0;
        }
        if(c >= 3) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if(c < 3) cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x " = " << x << endl)
#define PRINT(x) TRACE(printf(x))
#define WATCHR(a, b) \
    TRACE(for (auto c = a; c != b;) cout << *(c++) << " "; cout << endl)
#define WATCHC(V)                   \
    TRACE({                         \
        cout << #V " = ";           \
        WATCHR(V.begin(), V.end()); \
    })
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define mp make_pair
#define st first
#define nd second

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using ld = long double;
using pll = pair<ll, ll>;
using vll = vector<ll>;
using pll = pair<ll, ll>;

void buff() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
}

constexpr ll MOD = 1e9 + 7;

inline ll pow_mod(ll a, ll b, ll mod = MOD) {
    ll res = 1;
    a %= mod;
    assert(b >= 0);
    for (; b; b >>= 1) {
        if (b & 1) res = (res * a) % mod;
        a = (a * a) % mod;
    }
    return res;
}
// End of template code!
vector<pii> dirs = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
constexpr int inf = -1;
int main() {
    buff();
    int h, w, k;
    cin >> h >> w >> k;
    pii st, nd;
    cin >> st.first >> st.second;
    cin >> nd.first >> nd.second;
    st.first--; st.second--;
    nd.first--; nd.second--;
    vector<string> mat(h);
    vector<vector<int> > dist(h, vector<int>(w, inf));
    for (int i = 0; i < h; ++i) {
        cin >> mat[i];
    }

    queue<pair<int, int> > q;
    dist[st.first][st.second] = 0;
    q.push(st);
    
    auto inside = [&] (int x, int y) { return (x >= 0 && x < h && y >= 0 && y < w); };
    while (!q.empty()) {
        auto vamo = q.front();
        q.pop();
        for(const auto& d : dirs)
        {
            int nx = vamo.first;
            int ny = vamo.second;
            for(int i = 0; i < k; ++i)
            {
                nx += d.first;
                ny += d.second;
                if(!inside(nx, ny)) break;
                if(mat[nx][ny] == '@') break;
                if(dist[nx][ny] == dist[vamo.first][vamo.second]) break;
                if(dist[nx][ny] == -1) {
                    dist[nx][ny] = dist[vamo.first][vamo.second] + 1;
                    q.push(make_pair(nx, ny));
                } 
            } 
        }
    }
    cout << dist[nd.first][nd.second] << '\n';

    return 0;
}



Measured memory_bytes: 11120
(r, c) = [int(i) for i in input().split()]
last_row = [0 for _ in range(c+1)]
 
for _ in range(r):
    row = [int(i) for i in input().split()]
    for cc in range(c):
        last_row[cc] += int(row[cc])
        print(row[cc], end=' ')
 
    print(sum(row))
 
last_row[-1] = sum(last_row)
print(' '.join([str(a) for a in last_row]))

Measured memory_bytes: 7796
#include "bits/stdc++.h"
using namespace std;

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

#define int                                       long long
#define lop(i,s,e)                                for(int i=s;i<(int)e;i++)
#define rlop(i,e,s)                               for(int i=e;i>=s;i--)
#define prvec(v)                                  lop(R15,0,v.size())cout << v[R15] <<" "; cout << endl;
#define prarr(arr,s1,e1)                          lop(R15,s1,e1)cout << arr[R15] << " "; cout << endl;

#define endl                                      '\n'
#define ff                                        first
#define ss                                        second
#define pii                                       pair<int,int>

#define pb                                        push_back
#define all(v)                                    v.begin(),v.end()         

#define bug(...)                                  __f (#__VA_ARGS__, __VA_ARGS__)
#define rtn                                       if(0)return;
template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { rtn cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{     rtn 
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //

inline void INP();
const int N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;

int n, Q;
int arr[N+2];


void solve()
{
      int n, m;
      cin >> n >> m;
      int sum = 0;
      lop(i,0,n) cin >> arr[i], sum += arr[i];
      sort( arr, arr + n );
      int min = n/(4*m);

      int ans = 0;
      rlop(i,n-1,0)
      {
            if( arr[i]*4*m >= sum ) ans++;
      }

      if(ans >= m) cout << "Yes";
      else cout << "No";
      
}

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

      int test = 1;
      // cin >> test;

      // cout << setprecision(9) << fixed;
      // clock_t z = clock();
      while(test--)solve();
      // cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
}











inline void INP()
{
      #ifndef ONLINE_JUDGE
          freopen("input.txt",  "r",  stdin);
          freopen("output.txt", "w", stdout);
      #endif
}


// M A F I A - M A F I A - M A F I A - M A F I A - M A F I A - M A F I A //






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

const int maxn = 300;
int a[maxn + 1][maxn + 1];

int main() {
	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
		}
	}
	bool valid = true;
	long long ans = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			int dis = 2e9 + 5;
			for (int k = 1; k <= n; k++) {
				if (k == i || k == j)continue;
				dis = min(dis, a[i][k] + a[k][j]);
			}
			if (dis < a[i][j])valid = false;
			else if (dis > a[i][j])ans += a[i][j];
		}
	}
	cout << (valid ? ans : -1) << endl;

	return 0;
}

Measured memory_bytes: 640
#include <algorithm>  // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>     // bitset
#include <cctype>     // isupper, islower, isdigit, toupper, tolower
#include <cstdint>    // int64_t, int*_t
#include <cstdio>     // printf
#include <deque>      // deque
#include <iomanip>    // fixed, setprecision
#include <iostream>   // cout, endl, cin
#include <map>        // map
#include <numeric>    // accumulate
#include <queue>      // queue, priority_queue
#include <set>        // set
#include <stack>      // stack
#include <string>     // string, to_string, stoi
#include <tuple>      // tuple, make_tuple
#include <unordered_map>  // unordered_map
#include <unordered_set>  // unordered_set
#include <utility>        // pair, make_pair
#include <vector>         // vector
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll H, W;
  cin >> H >> W;
  if (H == 1 || W == 1) {
    cout << 1 << endl;
    return 0;
  }

  if (H % 2 == 0 || W % 2 == 0) {
    cout << H * W / 2 << endl;
    return 0;
  }

  cout << H * W / 2 + 1 << endl;
}


Measured memory_bytes: 3156
// Problem : C - Stones
// Contest : AtCoder - Tenka1 Programmer Beginner Contest 2019
// URL : https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)
/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>
 
 
using namespace std;
// using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a) for (int i=0; i<(a); i++)
#define rep1(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rep(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define uid(a, b) uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define imax INT_MAX
#define imin INT_MIN
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

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

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy

int main() {
	 
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int n;
	cin>>n;
	string s;
	cin>>s;
	vi pref1(n),pref2(n);
	int j=0;
	loop(i,n)
	{
		if(s[i]=='#')
		j++;
		pref1[i]=j;
	}
	j=0;
	rep(i,n)
	{
		if(s[i]=='.')
		j++;
		pref2[i]=j;
	}
	int mn=min(pref2[0],pref1.back());
	loop(i,n-1)
	{
		mn=min(mn,pref2[i+1]+pref1[i]);
	}
	cout<<mn;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343



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

int main (){
int l,n;
cin >> n >> l;
vector<string> s(n);
rep(i,n){
    cin >> s[i];
}
sort(s.begin(),s.end());
rep(i,n){
    cout<< s[i] ;
}
return 0;

}

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

#define FOR(a, b, c) for(int a=b;a<c;a++)

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

int main() {
	int n;
	cin >> n;
	int a[n];
	
	FOR(i, 0, n) {
		cin >> a[i];
	}
	int ans = 0;
	FOR(i, 0, n) {
		if (i == a[(a[i]-1)]-1) {
			 ans++;
		}
	}
	ans /= 2;
	cout << ans << endl;
}

Measured memory_bytes: 640
S = input()
N = len(S)
t = N // 2
ans = 0
for i in range(N):

    if len(S) % 2 == 0:
        if i == t:
            break
        if S[i] == S[N-1-i]:
            continue
        else:
            ans += 1
    else:
        if i == t:
            break
        if S[i] == S[N-1-i]:
            continue
        else:
            ans += 1
print(ans)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
int n;
const int MAXN=300100;
int a[MAXN];
int num[MAXN],use[MAXN],p[MAXN];
int po[MAXN],mo[MAXN];
long long ans[MAXN];
int tot;
int deal(int i,int x)
{
	int q=upper_bound(num+1,num+tot+1,x)-num;
	if(po[q-1]+(tot-q+1)*1LL*x>=1LL*x*i)  return 1;
	return 0;
}
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
		if(!use[a[i]])
		{
			p[++tot]=a[i];
			use[a[i]]=tot;
		}
		num[use[a[i]]]++;
	}
	sort(num+1,num+tot+1);
	for(int i=1;i<=tot;i++)  po[i]=po[i-1]+num[i];
	int now=0;
	for(int i=tot;i>=1;i--)
	{
		while(now<n && deal(i,now+1))  now++;
		ans[i]=now;
	}
	for(int i=1;i<=n;i++)
	{
		cout<<ans[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 11572
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

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


const long long int mod = 1000000007;
const long long int INF = 9999999999;




long long int aI,aO,aT,aJ,aL,aS,aZ,len=0;

int main()
{
    cout << fixed << setprecision(18);
    cin>>aI>>aO>>aT>>aJ>>aL>>aS>>aZ;
    len=aO;
    if(aI%2==aJ%2&&aJ%2==aL%2){
        len+=aI+aJ+aL;
    }else if(aI%2==0&&aJ%2==0||aL%2==0&&aJ%2==0||aI%2==0&&aL%2==0){
        len+=aI+aJ+aL-1;
    }else if(aI>=2&&aJ>=2&&aL>=2){
        len+=aI+aJ+aL-1;
    }else{
        len+=aI+aJ+aL-2;
    }
    cout<<len<<endl;
}


Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
	int n;
	cin >> n;
	string s;
	cin >> s;
	int a[10] = {};
	int b[100] = {};
	int c[1000] = {};
	for (int i = 0; i < n; ++i) {
		int d = s[i] - '0';
		for (int j = 0; j < 100; ++j) {
			if (b[j]) {
				c[j * 10 + d] = 1;
			}
		}
		for (int j = 0; j < 10; ++j) {
			if (a[j]) {
				b[j * 10 + d] = 1;
			}
		}
		a[d] = 1;
	}
	int ans = 0;
	for (int i = 0; i < 1000; ++i) {
		ans += c[i];
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import math
 
K = int(input())
 
ans = 0
for i in range(1, K+1):
  for j in range(i+1, K+1):
    for k in range(j+1, K+1):
        ans += math.gcd(i, math.gcd(j, k)) * 6

for i in range(1, K+1):
    for j in range(i+1, K+1):
        ans += math.gcd(i, j) * 6

for i in range(1, K+1):
    ans += i
print(ans)

Measured memory_bytes: 9208
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int h,w,a;cin>>h>>w>>a;
    int m=max(h,w);
    cout<<(a+m-1)/m<<endl;
}


Measured memory_bytes: 3568
#include<iostream>
#include<cstdio>
using namespace std;
const int N = 200005;
int a[N];
int Cnt[1000005];
bool Check(int x) {
    if(Cnt[1] && x != 1) return false;
    if(x == 1) {
        if(Cnt[1] > 1)return false;
        else return true;
    }
    for(int i = 2; i*i <= x; ++i) {
        if(!(x%i)) {
            if(Cnt[i] || Cnt[x/i]) return false;     
        }
    }
    if(Cnt[x] > 1) return false;
    return true;
}
int main() {
    int n;
    cin >> n;
    for(int i = 1; i <= n; ++i) {
        scanf("%d",&a[i]);
        ++Cnt[a[i]];
    }
    int cnt = 0;
    for(int i = 1; i <= n; ++i) {
        if(Check(a[i])) ++cnt;
    }
    cout << cnt << '\n';
return 0;
}

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

int main() {
    int a=0, b=0;
    char c;

    cin >> c; a = (c-'0')*10; cin >> c; a += c-'0';
    cin >> c; b = (c-'0')*10; cin >> c; b += c-'0';

    if (1 <= a && a <= 12 && 1 <= b && b <= 12) {
        cout << "AMBIGUOUS";
    } else if (1 <= a && a <= 12) {
        cout << "MMYY";
    } else if (1 <= b && b <= 12) {
        cout << "YYMM";
    } else {
        cout << "NA";
    }

    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a);i<(b);++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
#define INF 1000000000000000
#define MOD 1000000007
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} 



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

int N; cin >> N;
VI p(N); invec(p);
int M = 40000;
VI a, b;
rep(i, 0, N){
    a.push_back(M * (i+1));
    b.push_back(M*(N-i-1) + 1);
}
rep(i, 0, N){
    a[p[i] - 1] += i;
}
for(i64 i: a) cout << i << " ";
cout << "\n";
for(i64 i: b) cout << i << " ";
cout << "\n";

return 0;
}
// 書いて考える．場合分け．情報整理．
// 単純に分かる量から．愚直解を実装して研究．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP(小さい問題から大きな問題)
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性→二分探索
// 存在判定：構成方法，入力の特徴
// 構築問題。極端解を試す。
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// コーナーケース。境界値。
// 実行エラー：vector添え字超え．0割り．



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

lli n, k;

int main(void){
    cin >> n >> k;
    vector<lli> m(k);
    rep(i, n) m[(i+1)%k]++;
    lli ans = 0;
    for(lli i = 0; i < k; i++){
        lli a = m[i];
        lli b = m[(2*k-i)%k];
        lli c = b;
        if((-2*i+2*k)%k == 0) ans += a*b*c;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4836
#include<bits/stdc++.h>
#define int long long int
#define db double
#define ull unsigned long long
#define vii vector <int>
#define pii pair <int, int>
#define fi first
#define se second
#define rep(i,a,n)		for(int i=a;i<n;i++)
#define endl '\n'
#define mem(a,b) memset(a, b, sizeof a)
#define mkp make_pair
#define pb push_back
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
using namespace std;
double pi=3.1415926535;
double eps=0.000001;
int mod=1000000007; 
void print(vector <int> &arr){
	for(int i=0;i<arr.size();i++)
		cout<<arr[i]<<" ";
	
	cout<<endl;
}
int ncr(int n, int r)
{
    r=min(r,n-r);
    int A[r],i,j,B[r];
    iota(A,A+r,n-r+1);  //initializing A starting from n-r+1 to n
    iota(B,B+r,1);      //initializing B starting from 1 to r

    int g;
    for(i=0;i<r;i++)
    for(j=0;j<r;j++)
    {
        if(B[i]==1)
            break;
        g=__gcd(B[i], A[j] );
        A[j]/=g;
        B[i]/=g;
    }
    long long ans=1;
    for(i=0;i<r;i++)
        ans=(ans*A[i]%mod);
    return ans;
}
int32_t main(){
/////////////////////////////////////////////////////////////////////
//	ios_base::sync_with_stdio(false);
//	cin.tie(NULL);
//	cout.tie(NULL);
//	cerr.tie(NULL);
//For fast IO
///////////////////////////////////////////////////////////////////// 
//	std::cout.unsetf ( std::ios::floatfield );  // floatfield not set
//    std::cout.precision(10);
	int n;
	cin>>n;
	int a=n/500;
	n-=(a*500);
	int b=n/5;
	
	cout<<a*1000+(b*5)<<endl;
	return 0;
	}

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

int main() {
  int X;
  cin >> X;
  for (long i = -500; i < 500; i++) {
    for (long j = -500; j < 500; j++) {
      if (i * i * i * i * i - j * j * j * j * j == X) return cout << i << " " << j << "\n", 0;
    }
  }
}

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

int main() {
	int N, T;
	cin >> N >> T;
	int c[N];
	int t[N];
	int ans = 100000;
	for(int i = 0; i < N; i++){
		cin >> c[i] >> t[i];
		if (t[i] <= T){
			ans = min(ans, c[i]);
		}
	}
	if (ans == 100000){
		cout << "TLE" << endl;
	} else{
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
# from numba import njit
# input = stdin.readline


# k回以下の試行でにすべての長さをl以下にできるか
def isDividable(l,k,a):
  cnt = 0
  for Log in a:
    cnt += (Log - 1) // l
  return cnt <= k


#bottom = ng,top = ok
def binary_search(ng,ok,k,a):
  while abs(ng-ok) > 1:
    mid = (ng + ok) // 2
    if isDividable(mid,k,a):
      ok = mid
    else:
      ng = mid
  return ok


# @njit
def solve(k,a):
  return binary_search(0,max(a),k,a)



def main():
  N,K = map(int,input().split())
  a = list(map(int,input().split()))
  print(solve(K,a))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 30764