akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;

int main(){
	ll n; cin >> n;
	vl a(n); rep(i,n) cin >> a[i];
	vl b(n,0); b[0] = 1;
	if(n==2){
		cout << -1 << endl;
		return 0;
	}
	else if(n==3){
		map<ll,ll> mp;
		rep(i,3) mp[a[i]]++;
		bool flag = true;
		ll t;
		for(auto i : mp){
			if(i.second>=2){
				flag = false;
				t = i.first;
			}
		}
		if(!flag){
			b[0] = t;
			b[1] = a[t-1]^t;
			b[2] = b[0]^b[1];
		}else{
			b[0] = 1;
			b[1] = a[0]^1;
			b[2] = b[0]^b[1];
		}
	}
	else{
		set<ll> se;
		REP(i,2,n+1) se.insert(i);
		rep(i,n-4){
			auto itr = se.begin();
			if(*itr==a[b[i]-1]) itr++;
			b[i+1] = *itr;
			se.erase(itr);
		}
		vl nxt;
		for(auto i : se){
			nxt.push_back(i);
		}
		do{
			bool flag = true;
			REP(i,n-4,n-1){
				if(nxt[i-n+4]==a[b[i]-1]){
					flag = false;
					break;
				}else{
					b[i+1] = nxt[i-n+4];
				}
			}
			if(flag) break;
			else REP(i,n-3,n) b[i] = 0;
		}while(next_permutation(all(nxt)));
		if(b[n-1]==0){
			ll t = a[b[n-4]-1];
			ll mx = 0;
			for(ll i=n-4; i>=0; i--){
				if(a[b[i]-1]!=t){
					mx = i+1;
					break;
				}
				se.insert(b[i]);
				b[i] = 0;
			}
			b[mx] = t;
			se.erase(t);
			REP(i,mx,n-4){
				auto itr = se.begin();
				if(*itr==a[b[i]-1]) itr++;
				b[i+1] = *itr;
				se.erase(itr);
			}
			vl nxt;
			for(auto i : se){
				nxt.push_back(i);
			}
			do{
				bool flag = true;
				REP(i,n-4,n-1){
					if(nxt[i-n+4]==a[b[i]-1]){
						flag = false;
						break;
					}else{
						b[i+1] = nxt[i-n+4];
					}
				}
				if(flag) break;
				else REP(i,n-3,n) b[i] = 0;
			}while(next_permutation(all(nxt)));
		}
	}
	for(auto i : b) cout << i << " ";
	cout << endl;
}

Measured memory_bytes: 7040
//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
 
//#include <x86intrin.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <string>
#include <bitset> 
#include <vector>
#include <cmath>
#include <deque>     
#include <queue>
#include <iomanip>
#include <stack>
#include <map>
#include <set>
//#include <ordered_set>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
//using namespace __gnu_pbds;
using namespace std;
 
//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)1e7 + 123;
const ll inf = (ll)1e18 + 1;
 
const double pi = acos (-1.0);
const double eps = 1e-9;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, cnt[N];
ll ans;

inline void boost () {
   ios_base :: sync_with_stdio (0);
   cin.tie (0), cout.tie (0);
}
 
inline void Solve () {
   cin >> n;
   for (int i = 1; i <= n; i ++) {
      for (int j = i; j <= n; j += i)
         cnt[j] ++;
      ans += 1ll * i * cnt[i];
   }
   cout << ans;
}               
 
signed main () {                                       
   #ifdef QWERTY
      freopen("input", "r", stdin);
   #endif
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}                   

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

ans = ['?' for _ in range(n)]
f = True
for i in range(m):
    s, c = map(int, input().split())
    if ans[s-1] != '?':
        if ans[s-1] != c:
            f = False
        else:
            ans[s-1] = c
    else:
        ans[s-1] = c
if n >= 2 and ans[0] == 0:
    f = False
output = ""

if f:
    if n >= 2 and ans[0] == '?':
        ans[0] = 1
    for i in range(n):
        if ans[i] == '?':
            ans[i] = 0
        output += str(ans[i])
    print(output)
else:
    print(-1)


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

using namespace std;
const long long INF = 1LL <<60;

int main(void){
  long long n,m,k;
  long long i,j;
  long long tmp,count=-1;
  long long b=0,c;
  long long res=0;
  
  cin>>n>>m>>k;
  long long a[n]={};

  
  cin>>a[0];
  if(a[0]>k){
    count=0;
    for(i=1;i<n;i++){
      cin>>tmp;
    }
  }
  else{
    for(i=1;i<n;i++){
      cin>>tmp;
      a[i]=a[i-1]+tmp;
      if(a[i]>k){
        count=i;
        break;
      }
    }
  }
  if(i<n-1){
    for(i=i+1;i<n;i++){
      cin>>tmp;
    }
  }
  if(count==-1){
    count=n;
  }
  if(count>0){
    c=a[count-1];
  }
  else{
    c=0;
  }
  //cout<<count<<endl;
  for(i=0;i<m;i++){
    cin>>tmp;
    b=b+tmp;
    //cout<<b<<endl;
    if(b+c>k){
      if(count>1){
        //cout<<b<<" "<<c<<" "<<count<<" "<<i<<endl;
        res=max(count+i,res);
        count--;
        c=a[count-1];
      }
      else if(count==1){
        res=max(count+i,res);
        c=0;
        count=0;
      }
      else{
        //cout<<b<<" "<<count+i<<endl;
        res=max(count+i,res);
        break;
      }
    }
  }    
  if(i==m){
    res=max(count+i,res);
  }
  
  cout<<res<<endl;
  return 0;
  
}

Measured memory_bytes: 5116
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
struct node
{
	ll r,c;
}u;
ll j,m,x,n,i,tr[100005],v,l,r,c;
vector<node>s[100005];
const ll inf=1e18;
ll lowbit(ll p){return p&-p;}
ll ask(ll p)
{
	ll ans=inf;
	while(p)
	{
		ans=min(ans,tr[p]);
		p-=lowbit(p);
	}
	return ans;
}
void modify(ll p)
{
	while(p<=n)
	{
		tr[p]=min(tr[p],v);
		p+=lowbit(p);
	}
}
int main()
{
	scanf("%lld%lld",&n,&m);
	for(i=1;i<=n;i++)tr[i]=inf;
	for(i=1;i<=m;i++)
	{
		scanf("%lld%lld%lld",&l,&r,&c);
		s[l].push_back((node){r,c});
	}
	v=0;
	modify(n);
	for(i=n-1;i>0;i--)
	{
		v=inf;
		for(j=0;j<s[i].size();j++)
		{
			u=s[i][j];
			v=min(v,ask(u.r)+u.c);
		}
		modify(i);
	}
	if(v>=inf)printf("-1\n");
	else printf("%lld\n",v);
	return 0;
} 

Measured memory_bytes: 6400
/**
 *      ABC 111 A
 *      author  : kyomukyomupurin
 *      created : 
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string n; cin >> n;
    for (auto i = 0; i < 3; ++i) {
        if (n[i] == '1'){
            cout << 9;
        }
        else {
            cout << 1;
        }
    }

    
    return 0;
}

Measured memory_bytes: 256
#define pb push_back
#define MX 1e18
#define mod 1000000009
#define ff first
#define ss second
#define for1(i,n) for(int i=1;i<=n;i++)
#define for0(i,n) for(int i=0;i<n;i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long unsigned  ll;
char c [10][105];
priority_queue<int>pq;
int main(int argc, char const *argv[]) {
  int x,k;

  ll ans = 0;
  for(int i=1;i<=3;i++){
    cin>>x;
    pq.push(x);
  }
  cin>>k;
  while(k--){
    x= pq.top();
    pq.pop();
    pq.push(x+x);
  }
  while(!pq.empty()){
    ans += pq.top();
    pq.pop();
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
//#define read io.read
int n,k,answer[100001],ans,p;
int main()
{
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	cin >> n >> k;
    double ans = 0;
    for(int i=1;i<=n;i++)
	{
        double p=(double)1/n;
        for(int j=i;j<k;j*=2) p*=0.5;
        ans+=p;
    }
    printf("%.12f\n",ans);
	return 0;
}


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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 200010 };
const ll MOD { 1000000007 }, oo { 1LL << 62 };

int solve(int N, const vector<int>& xs)
{
    return 0;
}

int main()
{
    ios::sync_with_stdio(false);

    int A, B, C;
    cin >> A >> B >> C;

    cout << max(0, C - (A - B)) << endl;

    return 0;
}


Measured memory_bytes: 256
main = do
  s <- getLine
  let n = [read (take 2 s),read (drop 2 s)]
  putStrLn $ f (map m n)
m x
  | x >= 1 && x <= 12 = 1
  | otherwise = 0
f y
  | head y == 1 && last y == 1 = "AMBIGUOUS"
  | head y == 1 && last y == 0 = "MMYY"
  | head y == 0 && last y == 1 = "YYMM"
  | otherwise = "NA"

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

#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 300;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 31;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-9;
const double pi = atan2(0, -1);

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    //ll TL = 0.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    ll a[n];
    rep(i, 0, n)
        cin >> a[i];
    ll sum, ans1 = 0, ans2 = 0;
    if (a[0] <= 0)
    {
        ans1 += (-a[0] + 1);
        sum = 1;
    }
    else
        sum = a[0];
    rep(i, 1, n)
    {
        ll sum1 = sum + a[i];
        if (sum > 0)
        {
            if (sum1 >= 0)
            {
                ans1 += (sum1 + 1);
                sum1 = -1;
            }
        }
        else
        {
            if (sum1 <= 0)
            {
                ans1 += (-sum1 + 1);
                sum1 = 1;
            }
        }
        sum = sum1;
    }
    if (a[0] >= 0)
    {
        ans2 += (a[0] + 1);
        sum = -1;
    }
    else
        sum = a[0];
    rep(i, 1, n)
    {
        ll sum1 = sum + a[i];
        if (sum > 0)
        {
            if (sum1 >= 0)
            {
                ans2 += (sum1 + 1);
                sum1 = -1;
            }
        }
        else
        {
            if (sum1 <= 0)
            {
                ans2 += (-sum1 + 1);
                sum1 = 1;
            }
        }
        sum = sum1;
    }
    cout << min(ans1, ans2);
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include <cmath>
#include <limits>
#include<set>
#include <iomanip>
#include <queue>
#include <string>
#pragma GCC optimize("Ofast")
using namespace std;
const long long INF=200000000;
//setprecision(2) <<

const int MOD = 1000000007;

long long gcd(long long a,long long b){
	if(a<b)swap(a,b);
	if(a%b==0)return b;
	return gcd(a%b,b);
}

long long lcm(long long a,long long b){
	return a/gcd(a,b)*b;
}
long myPow(long long x, long long n, long long m=MOD){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}
class Ans{
public:
	long long x;
	long long y;
	long long x_;
	long long y_;
};

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	long long T;
	cin>>T;
	//cout<<lcm(T,10)<<endl;
	long long ans=0;
	cin>>ans;
	for(int i=0;i<T-1;i++){
		long long t;
		cin>>t;
		ans=lcm(t,ans);
		//cout<<ans<<endl;
	}
	cout<<ans<<endl;
}


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

using namespace std;

int main()
{
   int n;
   cin>>n;
   string a ;
   cin>>a;
   int v[27]={0};
   int C=n;
   for(int i=0 ; i<n-1 ; i++)
   {
       if( a[i]==a[i+1] )
        C--;
   }
   cout<<C<<endl;
    return 0;
}


Measured memory_bytes: 512
N = int(input())

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))


result = sum(B)
for i in range(N - 1):
    if A[i + 1] == A[i] + 1:
        result += C[A[i] - 1]

print(result)

Measured memory_bytes: 3064
use proconio::input;
use proconio::marker::Usize1;

#[derive(Debug)]
struct Helper {
  pub map: Vec<Vec<(usize, usize)>>,
  pub result: Vec<usize>
}

impl Helper {
  pub fn traverse(
    &mut self,
    cur: usize,
    last_index: usize,
    last_id: usize
  ) {
    let mut id = 1;
    let targets = self.map.get(cur).unwrap().clone();
    for (to, index) in targets.iter() {
      let to = *to;
      let index = *index;
      if to == last_index { continue }
      if id == last_id { id += 1; }
      self.result[index] = id;
      id += 1;
      self.traverse(to, cur, self.result[index]);
    }
  }
} 

fn main() {
  let OVER = 1_000_000;
  input! {
    n: usize,
    edges: [(Usize1,Usize1);n-1]
  }

  let mut result: Vec<usize>  = vec![0;n-1];
  let mut map: Vec<Vec<(usize, usize)>> = vec![vec![];n];
  for (i, (from, to)) in edges.into_iter().enumerate() {
    map[from].push((to, i));
  }
  let mut helper = Helper { map, result };
  helper.traverse(0, OVER, OVER);
    
  let mut max = 0;
  for v in helper.result.iter() {
    max = std::cmp::max(max, *v);
  }
  println!("{}", max);

  for v in helper.result.iter() {
    println!("{}", v);
  }
}

Measured memory_bytes: 13592
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>

#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
//cout << fixed << setprecision(10) << ans << endl;
//int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ans[300000];
signed main(){
    int n,x,y;
    cin >> n >> x >> y;
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            int k1 = j-i;
            int k2 = abs(x-i) + abs(y-j) + 1;
            int k3 = min(k1,k2);
            ans[k3] ++;
        }
    }
    for(int i=1;i<=n-2;i++){
        cout << ans[i] << endl;
    }
    cout << ans[n-1] << endl;
    return 0;
}

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

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

    if (((int)(x / 100)) == 0)
    {
        cout << 0 << endl;
        return 0;
    }

    int y = (int)(x / 100), z = (int)(x % 100);

    if ((z <= 5 * y) & (y <= 1000000))
    {
        cout << 1 << endl;
    }
    else
    {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }



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

  string s, t;
  cin >> s >> t;
  string u = s, v = t;
  reverse(all(s));
  reverse(all(t));
  if(t == u && s == v) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}

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

int main() {
    double N,K; cin>>N>>K;

    vector<double> tsum(1001);
    tsum[0]=0;
    for(int i=1;i<=1000;i++){
        tsum[i] = tsum[i-1]+i;
    }

    vector<double> pi(N);
    for(int i=0;i<N;i++){
        cin>>pi[i];
        pi[i]=tsum[pi[i]]/pi[i];
    }

    double ans = 0, t=0;
    for(int i=0;i<K;i++){
        t += pi[i];
    }
    ans = t;
    for(int i=K;i<N;i++){
        t -= pi[i-K];
        t += pi[i];
        ans = max(ans,t);
    }
    cout<<fixed<<ans<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main() {
  int p, q, r, ar, br;
  cin >> p >> q >> r;
	if (p <= r) ar = p + q;
	else ar = q + r;
  	if (p <= q) br = p + r;
	else br = q + r;
    if (ar <= br) cout << ar << endl;
	else cout << br << endl;
}

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

typedef long long ll;
const int N = 1e5 + 100;

ll n, ans;

bool check(ll d) {
	if(d == 1)
		return false;
	return (n / (d - 1)) * d == n;
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for (ll i = 1; i * i <= n; i++)
		if(n % i == 0) {
			if(i * i == n)
				ans += check(i) * (i - 1);
			else
				ans += check(i) * (i - 1) + check(n / i) * ((n / i) - 1);
		}
	cout << ans;
	return 0;
}

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

vector<P>E[200000];
int x[200000];
struct st{int a,b,c;};

struct UnionFind{
	vector<int>par;
	vector<ll>sum;
	UnionFind(int n){
		par=vector<int>(n);
		sum=vector<ll>(n);
		rep(i,n){
			par[i]=i;
			sum[i]=x[i];
		}
	}
	int find(int x){
		if(par[x]==x)return x;
		return par[x]=find(par[x]);
	}
	void unite(int x,int y){
		x=find(x);y=find(y);
		if(x==y)return;
		par[x]=y;
		sum[y]+=sum[x];
	}
	ll calc(int x){
		return sum[find(x)];
	}
};

set<P>se;
bool used[200000];

void dfs(int v,int w){
	used[v]=true;
	for(auto p:E[v]){
		if(p.first<=w){
			se.insert(P(min(p.second,v),max(p.second,v)));
			if(!used[p.second]){
				dfs(p.second,w);
			}
		}
	}
}

bool b[200000];
int main(){
	int n,m;cin>>n>>m;
	rep(i,n)scanf("%d",&x[i]);
	vector<st>v;
	rep(i,m){
		int a,b,y;scanf("%d%d%d",&a,&b,&y);a--;b--;
		v.push_back({a,b,y});
		E[a].push_back(P(y,b));
		E[b].push_back(P(y,a));
	}
	sort(v.begin(),v.end(),[](st a,st b){return a.c<b.c;});
	UnionFind uf(n);
	rep(i,m){
		uf.unite(v[i].a,v[i].b);
		if(uf.calc(v[i].a)>=v[i].c){
			b[i]=true;
		}
	}
	for(int i=m-1;i>=0;i--){
		if(b[i]){
			dfs(v[i].a,v[i].c);
			dfs(v[i].b,v[i].c);
		}
	}
	cout<<m-se.size()<<endl;
}


Measured memory_bytes: 26548
#include<iostream>
#include<vector>
#define INF (1<<21)
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define neg -1
using namespace std;

int n;
int m[100][100];
vector<int> color;
vector<int> g;
vector<int> p;

int prim(){
  int mincost, u;
  
  for(int i = 0; i < n; i++){
    g[i] = INF;
    color[i] = WHITE;
    p[i] = neg;
  }

  g[0] = 0;

  while(1){
    mincost = INF;
    u = -1;

    for(int i = 0; i < n; i++){
      if(mincost > g[i] && color[i] != BLACK){
	u = i;
	mincost = g[i];
      }
    }

    if(u == -1) break;

    color[u] = BLACK;
    
    for(int i = 0; i < n; i++){
      if(color[i] != BLACK && m[u][i] != INF){
	if(g[i] > m[u][i]){
	  g[i] = m[u][i];
	  p[i] = u;
	  color[i] = GRAY;
	}
      }
    }
  }

  int sum = 0;

  for(int i = 0; i < n; i++){
    if(p[i] != neg) sum += m[i][p[i]];
  }

  return sum;
  
}

int main()
{
  cin >> n;
  color.resize(n);
  g.resize(n);
  p.resize(n);

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
    int x;
    cin >> x;

    m[i][j] = (x == -1) ? INF:x;
    
    }
  }

  cout << prim() << endl;

  return 0;

}



Measured memory_bytes: 3128
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    m = [(1,0),(-1,0),(0,1),(0,-1)]
    def bfs(sx,sy):
        d = [[float("inf")]*h for i in range(w)]
        d[sx][sy] = 0
        q = deque([(sx,sy)])
        res = 0
        while q:
            x,y = q.popleft()
            nd = d[x][y]+1
            for dx,dy in m:
                nx,ny = x+dx,y+dy
                if 0 <= nx < w and 0 <= ny < h:
                    if s[ny][nx] == "#":
                        continue
                    if nd < d[nx][ny]:
                        d[nx][ny] = nd
                        q.append((nx,ny))
                        res = nd
        return res
    h,w = LI()
    s = [input() for i in range(h)]
    ans = 0
    for y in range(h):
        for x in range(w):
            if  s[y][x] == ".":
                res = bfs(x,y)
                if ans < res:
                    ans = res
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 43376
from collections import Counter

from sys import stdin

input = stdin.readline

N, K = map(int, input().split())

An = Counter(input().split())


def main():
    # 要素数(v) 昇順
    # 先頭 から インデックス len(An) - K - 1 まで
    # 要素数(v) 合計
    print(sum(sorted(An.values())[:len(An) - K]))

    return


main()


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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

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

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

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

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

  int a, b, c, d;
  cin >> a >> b >> c >> d;

  int s = 0;
  for (int i = a; i <= b; ++i) {
    if (c <= i && i <= d) ++s;
  }

  cout << (s ? s-1 : 0) << "\n";

  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define dbl double
#define pi acos(-1)
#define sc1(a) scanf("%lld",&a)
#define sc2(a,b) scanf("%lld%lld",&a,&b)
#define sc3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define pb push_back

priority_queue<ll>pq;
ll ara[1000006];
ll p[100005];
ll vis[200005][50];

int main()
{
    ll a,b,t;;
    sc1(t);
    cout<<(t+1)/2<<endl;
    return 0;
}


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

int main() {
  double N;
  cin >> N;
  
  double x;
  double sum =0;
  for (int i = 0; i < N; i++) {
    cin >> x;
    sum += 1/x;
  }
  cout << 1/sum << endl;
}


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

int main() {
    int N, M;
    int sum = 0;
    cin >> N >> M;
    int a[M];
    for(int i = 0; i < M; i++)
    {
        cin >> a[i];
        sum += a[i];
    }
    if(N - sum >= 0)
        cout << N - sum << endl;
    else
        cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3624
N,K = (int(x) for x in input().split())
N1 = N + 1
K1 = K - 1
setN = (((N1*N1*(N1+1))//2) - (N1*(N1+1)*(2*N1+1)//6) + N1) % 1000000007
setK = (((N1*K1*(K1+1))//2) - (K1*(K1+1)*(2*K1+1)//6) + K1) % 1000000007
print((setN-setK)%1000000007)

Measured memory_bytes: 9204
#include <stdio.h>
 
int  main(void){
         int h,w,i,j;
          while(1){
          scanf("%d %d",&h,&w);
           if( h==0 && w==0)
              break;
           for(i=1; i<=h; i++){
            for(j=1; j<=w; j++){
              if((i+j)%2 == 0)
              printf("#");
             else
              printf(".");
             }printf("\n");
            }printf("\n");
           }
            return 0;
}



Measured memory_bytes: 2032
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

N,M = map(int, input().split())
R = []
for i in range(M):
    a = tuple(map(int, input().split()))
    R.append(a)
R = sorted(R, key=lambda x:(x[1]))

ans = 0
brid = -1
for a,b in R:
    if a >= brid:
        brid = b
        ans += 1

print(ans)

Measured memory_bytes: 28168
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int m = in.nextInt();
		List<int[]> list = new ArrayList<>();
		for(int i=0;i<n;i++) {
			int[] tmp = new int[2];
			tmp[0] = in.nextInt();
			tmp[1] = in.nextInt();
			list.add(tmp);
		}
		list.sort((s,t)->s[0]-t[0]);
		long ans = 0;
		int i = 0;
		while(m>0) {
			int[] tmp = list.get(i);
			ans += (long)tmp[0] * Math.min(m, tmp[1]);
			m -= tmp[1];
			i++;
		}
		System.out.println(ans);
		in.close();
	}

}


Measured memory_bytes: 64744
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define endl "\n"
#define ll long long 
#define int ll
#define mod 1000000007
#define mod1 1000000006
#define modi 998244353
#define ff first
#define ss second
#define pb push_back
vector<ll> vi[300005];
int color[100005];
ll pa[500005];
ll si[500005];
#define pb push_back
bool visi[1000005]={false};
bool is[100005];
ll fac[10000001];
ll prime[400005];
ll bit[100005];
const long double eps = 1.0e-14;      // allowable error
#define fio ios_base::sync_with_stdio(false); cin.tie(NULL);
 
 
void fact(){
    fac[0]=1;
    for(int i=1;i<=10000000;i++){
        fac[i]=(fac[i-1]*i)%mod;
    }
    return ;
}
void sieve(){
    prime[0]=0;
    prime[1]=0;
    for(int i=2;i<400005;i++){
        prime[i]=1;
    }
    for(int i=2;i*i<400005;i++){
        if(prime[i]==1){
            for(int j=i*i;j<400005;j+=i){
                prime[j]=0;
            }
        }
    }
    
}
 
ll power(ll n , ll p ){
    if(p==0)
        return 1;
    
    ll res = power((n*n)%mod,p/2);
    if(p%2==1)
        res = (n*res)%mod;
    
    return res;
}
 
 
void upd(ll i,ll val,ll n) {
    for(;i<=n;i+=i&(-i))
        bit[i]+=val;
}
 
ll qry(ll i) {
    ll sum=0;
    for(;i>0;i-=i&(-i))
        sum+=bit[i];
    return sum;
}
 
 
ll fin(ll u) {
    if(pa[u]==u)
        return u;
    return fin(pa[u]);
}
 
void uni(ll u,ll v) {
    ll p1=fin(u);
    ll p2=fin(v);
    if(p1==p2)
        return;
    if(si[p1]<si[p2])
        swap(p1,p2);
    si[p1]+=si[p2];
    pa[p2]=p1;
    return;
}
 
int32_t main() {
    fio
    
    int x,n;
    cin >> x >> n;
    int arr[n];
    for(int i=0;i<n;i++) {
        cin >> arr[i];
    }
    int ans = abs(x-arr[n-1]);
    ans += arr[0];
    
    for(int i=1;i<n;i++) {
        int a = abs(arr[i]-arr[i-1]);
        if(a>ans)
        ans=a;
    }
    //cout << ans << endl;
    cout << x-ans << endl;
    
    
	return 0;
    
}

Measured memory_bytes: 10496
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <random>

using namespace std;

#define x first
#define y second
#define prev _prev
typedef long long ll;
typedef unsigned long long ull;

mt19937 rnd(rand());
const int MOD = 1e9 + 7;
const ll BIG_MOD = 1e18 + 7;
const int MAXN = 2e5 + 7;

int dp[MAXN][26];
int last[MAXN][26];
int last1[26];

signed main(){
	cout.precision(20);
	//freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	for (int i = 0; i < 26; ++i){
		last1[i] = -1;
		last[n][i] = -1;
		dp[n][i] = 1;
	}

	for (int i = n - 1; i >= 0; --i){
		last1[s[i] - 'a'] = i;

		for (int j = 0; j < 26; ++j){
			last[i][j] = last1[j];
		}
	}

	for (int i = n - 1; i >= 0; --i){
		if (!i){
			int lul = 1;
		}

		for (int j = 0; j < 26; ++j){
			dp[i][j] = MOD;
			int next = last[i][j];
			if (next == -1){
				dp[i][j] = 1;
			}
			else{
				for (int k = 0; k < 26; ++k){
					dp[i][j] = min(dp[i][j], 1 + dp[next + 1][k]);
				}
			}
		}
	}

	int ans = MOD;
	for (int i = 0; i < 26; ++i){
		ans = min(ans, dp[0][i]);
	}

	int i = 0;
	while (ans){
		for (int j = 0; j < 26; ++j){
			if (dp[i][j] == ans){
				cout << (char)((int)'a' + j);
				i = last[i][j] + 1;
				--ans;
				break;
			}
		}
	}

	return 0;
}

Measured memory_bytes: 41236
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF (1<<29)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define CLR(a) memset(a,0,sizeof(a))
const int dx[] = {-1,0,0,1},dy[] = {0,1,-1,0};

typedef long long int ll;

using namespace std;

int main(){
    while(true){
	int ans = 0;
	int m;
	cin >> m;
	if(m == 0) break;
	m = 1000 - m;
	ans += m / 500;
	m %= 500;
	ans += m / 100;
	m %= 100;
	ans += m / 50;
	m %= 50;
	ans += m / 10;
	m %= 10;
	ans += m / 5;
	m %= 5;
	ans += m;
	cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include <stdio.h>

int main(void)
{
	int hp; //HP
	int n; //n種類の技
	int i;
	scanf("%d%d", &hp, &n);

	int at[n];
	i = 0;
	while (i < n)
		scanf("%d", &at[i++]);
	i = 0;
	while (i < n)
		hp -= at[i++];
	if (hp <= 0)
		printf("Yes", hp);
	else
		printf("No", hp);
	return (0);
}


Measured memory_bytes: 512
s = input()

if 1 <= int(s[0:2]) <= 12 and 1 <= int(s[2:4]) <= 12:
    print('AMBIGUOUS')
elif 1 <= int(s[0:2]) <= 12:
    print('MMYY')
elif 1 <= int(s[2:4]) <= 12:
    print('YYMM')
else:
    print('NA')


Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.Scanner;

public class Main {

	final static String END_SIGN = "-";

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

		ArrayList<String> resultList = new ArrayList<String>();

		String str;
		while (EndDecision(str = sc.nextLine())) {

			int shuffleCount = Integer.parseInt(sc.nextLine());

			for (int i = 0; i < shuffleCount; i++) {
				str = Shuffle(str, Integer.parseInt(sc.nextLine()));
			}
			resultList.add(str);
		}

		for (String s : resultList) {
			System.out.println(s);
		}

	}

	static String Shuffle(String str, int num) {
		String result = str.substring(num);
		result += str.substring(0, num);
		return result;
	}

	// 終了判定
	public static boolean EndDecision(String array) {
		if (array.equals(END_SIGN)) {
			return false;
		} else {
			return true;
		}

	}

}



Measured memory_bytes: 26336
#include <bits/stdc++.h>
using namespace std;
int N, M, x;
int main() {
	scanf("%d%d", &N, &M);
	int ret = N;
	for(int i = 0; i < M; i++) {
		scanf("%d", &x);
		ret = __gcd(ret, __gcd(x, N));
	}
	puts(ret == 1 ? "Yes" : "No");
	return 0;
}

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

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

	int data1[100],data2[100];

	for(int i = 0; i < N; i++){
		cin >> data1[i];
	}
	for(int i = 0; i < N; i++){
		cin >> data2[i];
	}

	int candy = 0;
	int candyMax = 0;

	for(int i = 0; i < N; i++){
		candy = 0;

		for(int j = 0; j < N; j++){
			if(j <= i){
				candy += data1[j];
			}
			if(j >= i){
				candy += data2[j];
			}
		}

		if(candy > candyMax) candyMax = candy;
	}

	cout << candyMax << endl;
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	map<ll,ll>a;
	cin>>n;
	for(ll i=0;i<n;i++){
		ll x;
		cin>>x;
		a[x]++;
		if(a[x]>1){
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";
	// your code goes here
	return 0;
}

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


int main() {
  int N;
  cin >> N;
  int cnt[3];
  cnt[0] = cnt[1] = cnt[2] = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a % 4 == 0) {
      cnt[0]++;
    } else if (a % 2 == 0) {
      cnt[1]++;
    } else {
      cnt[2]++;
    }
  }

  if ((cnt[0] + 1) >= (cnt[1] % 2 + cnt[2])) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

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

int main() {
	int t; cin>>t;
	int s= t%60;
	t/=60;
	int m= t%60;
	t/=60;
	int h=t%24;
	cout<<h<<":"<<m<<":"<<s<<endl;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3112
# coding: utf-8
# Here your code !

N  = int(input())
a = list(map(int,input().split()))
n_4 ,n_2 ,n_1 = 0,0,0
ans = ""

for i in range(N):
    if a[i] %4 ==0:
        n_4 += 1
    elif a[i] %4 == 2:
        n_2 += 1
    else :
        n_1 += 1
if n_1 < n_4 + 1:
    ans = "Yes"
elif (n_1 == n_4 + 1)and(n_2 == 0):
    ans = "Yes"
elif n_1 == 0:
    ans = "Yes"
else :
    ans ="No"

print(ans)

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

#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 INF (int)1e9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define endl "\n"

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef map<int, int> mii;

void solve(ll test_case)
{
  char s;
  cin>>s;
  if(s>='A' && s<='Z'){
    cout<<"A";
  }
  else{
    cout<<"a";
  }
}

int main()
{

//#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1, t1 = 0;
    //cin >> t;
    while (t1 < t)
    {
        solve(t1 + 1);
        t1++;
    }
 return 0;
}


Measured memory_bytes: 3564
N=int(input())
S=input()
#print(N,S)

count=0


for n1 in range(10):
 cond=0
 for i in range(N-2):
   if n1==int(S[i]):
      p1=i
      cond=1
      break
 if cond==1:
  for n2 in range(10):
    for j in range(p1+1,N-1):
      if n2==int(S[j]):
        p2=j
        cond=2
        break
    if cond==2:
     for n3 in range(10):
       #print(n3,S[p2+1:],str(n3) in S[p2+1:] )
       if str(n3) in S[p2+1:]:
        #print(n1,n2,n3)
        count+=1
        cond=0
      
              
print(count)


Measured memory_bytes: 3188
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7
A = [format(Ai, 'b') for Ai in A]
L = max(len(Ai) for Ai in A)
A = ['0'*(L-len(Ai))+Ai for Ai in A]
ans = 0

for i in range(L):
    one, zero = 0, 0
    
    for j in range(N):
        if A[j][i]=='1':
            one += 1
        else:
            zero += 1
    
    add = pow(2, L-i-1, MOD)*one*zero%MOD
    ans += add
    ans %= MOD

print(ans)

Measured memory_bytes: 200720
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> l(n);
    vector<int> r(n);
    rep(i, q) {
        int tmp_l, tmp_r;
        cin >> tmp_l >> tmp_r;
        --tmp_l, --tmp_r;
        l[i] = tmp_l;
        r[i] = tmp_r;
    }

    vector<ll> ac_accum_num(n);
    ac_accum_num[0] = 0;

    for ( int i = 1; i < n; ++i ) {
        if ( s[i-1] == 'A' && s[i] == 'C' ) {
            ac_accum_num[i] = ac_accum_num[i-1] + 1LL;
        }
        else {
            ac_accum_num[i] = ac_accum_num[i-1];
        }
    }

    rep(i, q) {
        ll ans;
        if ( l[i] == 0 ) {
            ans = ac_accum_num[r[i]];
        }
        else if ( ac_accum_num[l[i]] != ac_accum_num[l[i]-1] ) {
            ans = ac_accum_num[r[i]] - ac_accum_num[l[i]-1] - 1;
        }
        else {
            ans = ac_accum_num[r[i]] - ac_accum_num[l[i]-1];
        }

        cout << ans << endl;
    }

    return 0;
}

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

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

int n, m;
char polje[110][110];

int main() {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
        scanf("%s", polje+i);

    bool can = true;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (polje[i][j] == '#') {
                bool ac = false;
                for (int x = 0; x < 4; x++) {
                    int tx = i + dx[x];
                    int ty = j + dy[x];

                    if (tx < 0 || tx >= n || ty < 0 || ty >= m) continue;
                    if (polje[tx][ty] == '#') ac = true;
                }
                if (!ac) can = false;
            }
        }
    }

    if (can) printf("Yes");
    else printf("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

template<class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template<class T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

int main() {
    int x,y;
    cin>>x>>y;
    ll t[4] = {300000,200000,100000,0};
    ll ans = t[min(x-1,3)]+t[min(y-1,3)];
    if(x==1&&y==1){
        ans+=400000;
    }
    cout<<ans<<endl;

    return 0;
}


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

int main() {
    int n;
    std::cin >> n;

    std::vector<int> p(n);
    for (int i = 0; i < n; i++)
        std::cin >> p[i];

    int ans = 0;
    for (int i = 1; i < n - 1; i++) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1])
            ans++;
        else if (p[i + 1] < p[i] && p[i] < p[i - 1])
            ans++;
    }
    
    std::cout << ans << "\n";
}

Measured memory_bytes: 256
// エイシングプログラミングコンテスト2020-A
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define e_b emplace_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
void map_p(map<int,int>& d){cout<<"map: ";for(auto a : d){cout<<"{"<<a.first<<":"<<a.second<<"}";}cout<<endl;} //mapの中身を見る
void set_p(set<int>& d){cout<<"set: ";for(int a : d){cout<<a<<" ";}cout<<endl;} //setの中身を見る


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);

    int l,r,d;
    cin>>l>>r>>d;
    l=(l+d-1)-((l+d-1)%d),r=r-(r%d);
    cout<<(r-(l-d))/d<<endl;
    return 0;
}

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

using namespace std;

#define ll long long
#define rep(i,n) for(int i=1;i<=(n);i++)
#define rep0(i,n) for(int i=0;i<(n);i++)

const ll INF=1e9+7;
struct hhh{
	int num,pri;
}a[100001];
bool cmp(hhh a,hhh b){
	if(a.pri<b.pri){
		return 1;
	}
	else{
		return 0;
	}
}
ll n,m,g,k;
int main()
{
	/*freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
	cin>>n>>m;
	rep(i,n){
		cin>>a[i].pri>>a[i].num;
	}
	sort(a+1,a+n+1,cmp);
	while(g<m){
		k++;
		g+=a[k].num;
	}
	cout<<a[k].pri;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair

using namespace std;

int main()
{
	ios::sync_with_stdio(false); cin.tie(NULL);
	#ifdef PIYUSH_AASHIRWAAD
		I_O;
	#else
	#define print(...) 0
	#endif
	int n;
	cin >> n;
	int A[100001] = {0};
	for (int i = 1; i <= 100000; ++i)
	{
		int j = i;

		while(j){
			A[i] += (j%10);
			j /= 10;
		}
	}
	int sum = 0;
	int m = 1000000;
	for (int i = 1; i < n; ++i)
	{
		if((A[i] + A[n-i]) < m)
		{
			m = A[i] + A[n-i];
		}
	}
	cout<<m;
}

Measured memory_bytes: 640
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {

	public static void main(String argv[]) throws IOException {
		Scanner cin = new Scanner(System.in);
		int dp[][][] = new int[30][20][200];
		dp[0][0][0] = 1;
		for (int i = 1; i <= 20; ++ i) {
			for (int k = 0; k <= 10; ++ k) {
				for (int s = 0; s <= 155; ++ s) {
					dp[i][k][s] = dp[i - 1][k][s];
					if (k > 0 && s >= i) dp[i][k][s] += dp[i - 1][k - 1][s - i];
				}
			}
		}
		while (cin.hasNextInt()) {
			int n = cin.nextInt(), k = cin.nextInt(), s = cin.nextInt();
			if (n == 0) break;
			System.out.println(dp[n][k][s]);
		}
	}

}

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

int main() {
	int n;
	cin>>n;
	int A[n];
	int B[n];
  for(int i = 0; i< n ; i++){
  	cin>>A[i];
  	B[i] = A[i];}
  	sort(B,B+n);
 for(int i=0; i<n;i++){
 	if(A[i]<=B[n/2-1]){
 		cout<<B[n/2]<<endl;}
 		else{
 			cout<<B[n/2-1]<<endl;}
 }
  

}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];
string s;

int32_t main(){_

   cin>>n;
   cin>>s;

   int ans = 0;
   for (int i = 0; i < n; ++i)
   {
      if(s[i] != '.'){
         ans++;
      }
   }

   int fans = ans, pref = ans, suff = 0;
   for (int i = n-1; i >= 0; --i)
   {
      if(s[i] == '#')
         --pref;
      if(s[i] == '.'){
         suff++;
      }
      tr(i, s[i], fans, pref, suff);
      smin(fans, pref+suff);         
   }
   
   cout<<fans;
   return 0;
}



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

#define int long long
#define double long double
#define incin(n) int (n); cin >> (n)
#define uniq(v) sort((v).begin(),(v).end()); (v).erase(unique((v).begin(),(v).end()),(v).end());
#define steprap(i,n,s) for(int (i)=0;i<(s)*(n);(i)+=(s))
#define rap(i,n) steprap((i),(n),1)

using intV = std::vector<int>;

using namespace std;
namespace math
{
	double PI = 3.14159265359;
	int step(int n);
	int ncr(int n,int r);
	int npr(int n,int r);
	int gcm(int a,int b);
	int lcm(int a,int b);

	int step(int n){
		if(n<=1){
			return 1;
		}else{
			return n * step(n-1);
		}
	}
	int ncr(int n,int r){
		for(int i=1;i<r;i++){
			n *= n-i;
		}
		for(int i=1;i<r;i++){
			r *= r-1;
		}
		return n/r;
	}
	int npr(int n,int r){
		for (int i = 1; i < r; ++i)
		{
			n *= n-1;
		}
		return n;
	}
	int gcm(int a,int b){
		int p=max(a,b);
		int q=min(a,b);
		int r;
		while(true){
			if(p%q==0){
				return q;
			}
			r = p%q;
			p=q;
			q=r;
		}
	}
}

using namespace std;
// using StringMap = std::vector<std::vector<char>> map(h+2,vector<char>(w+2,'#'));
namespace tmp {
    template <typename T> bool inArry(T x,vector<T> v);
    template <typename T> void input(int n,vector<T> &v);

    template <typename T> bool inArry(T x,vector<T> v){
        int l = v.size();
        for(int i=0;i<l;i++){
            if(x==v[i]){
                return true;
            }
        }
        return false;
    }
    
    template <typename T> void input(int n,vector<T> &v){
        for(int i=0;i<n;i++){
            cin >> v.at(i);
        }
    }
}

using namespace std;

signed main (){
	int a,b,h;
	cin >> a >> b>>h;
	cout<<(a+b)*h/2<<endl;
	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		//入力表示

		int N = sc.nextInt();
		int a[]=new int[N];
		
		for(int i=0;i<N;i++) {
			a[i]=sc.nextInt();
		}
		
		Arrays.sort(a);
		
		System.out.println(a[N / 2]  - a[N / 2 - 1]);

	}
}

Measured memory_bytes: 50596