akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.util.Map.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<Integer, Integer>();
        
        for (int i = 0; i < n; i++) {
            int num = sc.nextInt();
            if (map.containsKey(num)) {
                int val = map.get(num);
                map.put(num, val + 1);
            } else {
                map.put(num, 1);
            }
        }
        
        int counter = 0;
        for (Entry<Integer, Integer> entry : map.entrySet()) {
            counter++;
        }
        
        if (n % 3 != 0) {
            if (counter != 1) {
                System.out.println("No");
                return;
            }
        }
        
        if (counter == 1) {
            if (!map.containsKey(0)) {
                System.out.println("No");
            } else {
                System.out.println("Yes");
            }
            return;
        } else if (counter == 2) {
            for (Entry<Integer, Integer> entry : map.entrySet()) {
                if (entry.getKey() == 0) {
                    if (entry.getValue() != n / 3) {
                        System.out.println("No");
                        return;
                    }
                } else {
                    if (entry.getValue() != n / 3 * 2) {
                        System.out.println("No");
                        return;
                    }
                }
            }
            
            System.out.println("Yes");
            return;
        } else if (counter == 3) {
            int nu = n / 3;
            int[] array = new int[3];
            int number = 0;
            for (Entry<Integer, Integer> entry : map.entrySet()) {
                if (entry.getValue() != nu) {
                    System.out.println("No");
                    return;
                }
            }
            
            for (Entry<Integer, Integer> entry : map.entrySet()) {
                array[number] = entry.getKey();
                number++;
            }
            
            int ra = array[0] ^ array[1];
            int rb = array[1] ^ array[2];
            int rc = array[0] ^ array[2];
            
            if (ra != array[2]) {
                System.out.println("No");
                return;
            }
            if (rb != array[0]) {
                System.out.println("No");
                return;
            }
            if (rc != array[1]) {
                System.out.println("No");
                return;
            }
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 57876
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll int l,r;
    cin>>l>>r;

    if(l/2019 != r/2019)
        return cout<<"0", 0;

    ll int ans = INT_MAX;
    for(ll int i=l; i<r; i++)
    {
        for(ll int j=l+1; j<=r; j++)
            ans = min(ans, (i*j)%2019);
    }
    cout<<ans;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    //ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,a;
    cin>>n;
    string s;
    cin>>s;

    for(int i=0;i<s.size();i++)
    {
        a=s[i];
        a+=n;
        if(a>90){a=a-90;a+=64;}
        char c=char(a);
        cout<<c;
    }
}











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

int main()
{
	int a, b, c, d;
	int count = 0;
	int input_number;

	while ( scanf( "%d", &input_number ) != EOF )
	{

		count = 0;
		for ( a = 0 ; a < 10 ; a ++ )
		{
			for ( b = 0 ; b < 10 ; b++ )
			{
				for ( c = 0 ; c < 10 ; c ++ )
				{
					d = input_number - ( a + b + c );
					if (( d < 10 ) && ( d > -1 ))
					{
						count = count + 1;
					}
				}
			}
		}
		
		fprintf( stdout, "%d\n", count );
	}

	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b){
  if(a%b==0) return b;
  return gcd(b, a%b);
}

int main(){
  int n, m;  cin >> n >> m;
  vector<ll> box(n, 1);
  set<int> place = {0};

  for(int i=0; i<m; i++){
    int x, y;  cin >> x >> y;
    x--; y--;
    box[x] -= 1;
    box[y] += 1;
    if(place.find(x)!=place.end()){
      place.insert(y);
      if(box[x]==0) place.erase(x);
    }
  }
  cout << place.size() << endl;
  
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; //
typedef pair<db,db> pd; //
//
typedef vector<int> vi; 
typedef vector<ll> vl; //
typedef vector<db> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi;
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
 
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back()
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
 
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; //
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); //
//
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; } //
constexpr int pct(int x) { return __builtin_popcount(x); } //
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) //
constexpr int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 //
// IGNORE
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}
template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// IGNORE
//
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	cout << (1000 - N % 1000) % 1000 << endl;
}

Measured memory_bytes: 3644
import sys

def main():
    n, *p = map(int, sys.stdin.read().split())
    p = [None] + p + [None]
    cnt = 0
    i = 1
    while i <= n:
        if p[i] == i:
            cnt += 1
            if p[i+1] == i + 1:
                i += 1
        i += 1
        
    print(cnt)

if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
	int n, i;
	string s;
	cin >> n;
	cin >> s;
	for(i=0;i<s.size();i++)
	{
		s[i] += n;
		while(s[i] > 'Z')
		{
			s[i] -= 'Z' - 'A' + 1;
		}
	}
	cout << s << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    unsigned long long N, cnt=0;
    scanf("%lld", &N);
    for(long long i=1; i<=N; i++){
        if(i%3 && i%5){
            cnt+=i;
        }
    }
    printf("%lld\n", cnt);
    return 0;
}

Measured memory_bytes: 1736
A,B,C,D = map(int,input().split())

def gcd(a,b):
  while b:
    a,b = b,a%b
  return a

def F(N,C,D):
  x = N
  x -= N//C
  x -= N//D
  lcm = C*D//gcd(C,D)
  x += N//lcm
  return x

answer = F(B,C,D) - F(A-1,C,D)
print(answer)


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

int main(){
    int64_t a,b,c;
    cin>>a>>b>>c;
    int64_t x = c-a-b;
    if(x<=0)cout<<"No"<<endl;
    else{
    if(x*x<=4*a*b)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    }
}

Measured memory_bytes: 256
import itertools
N,M=map(int,input().split())
L=[[] for _ in range(N)]
for _ in range(M):
    a,b=map(int,input().split())
    L[a-1].append(b-1)
    L[b-1].append(a-1)
cnt=0
for i in itertools.permutations(range(N),N):
    if i[0]==0:
        for j in range(N):
            if j==N-1:
                cnt+=1
                break
            if not (i[j+1] in L[i[j]]):
                break
print(cnt)

Measured memory_bytes: 40560
import java.util.*;

import static java.lang.Math.*;

import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.MathContext;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int n = sc.nextInt();
		int[]a = new int[n];
		for(int  i  = 0; i< n; i++) {
			a[i]=sc.nextInt();
		}
		int min =1000000000;
		for(int j=1;j<=100;j++) {
			int all=0;
			for(int x:a)
				all+=(x-j)*(x-j);
			min =Math.min(min, all);
		}
		pw.println(min);
		pw.close();

	}
	static class Scanner 
	{
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

		public String next() throws IOException 
		{
			while (st == null || !st.hasMoreTokens()) 
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {return Integer.parseInt(next());}
		
		public long nextLong() throws IOException {return Long.parseLong(next());}

		public String nextLine() throws IOException {return br.readLine();}
		
		public double nextDouble() throws IOException
		{
			String x = next();
			StringBuilder sb = new StringBuilder("0");
			double res = 0, f = 1;
			boolean dec = false, neg = false;
			int start = 0;
			if(x.charAt(0) == '-')
			{
				neg = true;
				start++;
			}
			for(int i = start; i < x.length(); i++)
				if(x.charAt(i) == '.')
				{
					res = Long.parseLong(sb.toString());
					sb = new StringBuilder("0");
					dec = true;
				}
				else
				{
					sb.append(x.charAt(i));
					if(dec)
						f *= 10;
				}
			res += Long.parseLong(sb.toString()) / f;
			return res * (neg?-1:1);
		}
		
		public boolean ready() throws IOException {return br.ready();}


	}
	static class pair implements Comparable<pair> {
		int x;
		int y;

		public pair(int d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair o) {
			// TODO Auto-generated method stub
			return y - o.y;
		}

	}

	static class pair2 implements Comparable<pair2> {
		long x;
		int y;

		@Override
		public String toString() {
			// TODO Auto-generated method stub
			return y + " ";
		}

		public pair2(long d, int u) {
			x = d;
			y = u;
		}

		@Override
		public int compareTo(pair2 o) {
			// TODO Auto-generated method stub
			if (x - o.x > 0)
				return 1;
			else if (x - o.x == 0)
				return 0;
			return -1;
		}

	}

}


Measured memory_bytes: 22868
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

using namespace std;

int main(){
	int a,b;

	while(cin>>a>>b){
		cout << (int)log10((double)a+b)+1 << endl;
	}
}

Measured memory_bytes: 1204
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

signed main(){
	string s;
	cin >> s;
	if(s[2] == s[3] && s[4] == s[5])out("Yes");
	else out("No");
}

Measured memory_bytes: 256
// Problem : B - Tax Rate
// Contest : AtCoder - Sumitomo Mitsui Trust Bank Programming Contest 2019
// URL : https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
        db cur = (db)(1.08*i);
        if((int)cur == n){
            cout<<i;
            return;
        }
    }
    cout<<":(";
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3660
import math

N = int(input())
A = list(map(int, input().split()))
ans = 0

C = list(set(A))
M = len(C)
t = []
anst = 0
dic = {}
for i in A:
  if not i in dic:
    dic[i] = 0
  dic[i] += 1

jisyo = {}
for i in range(M):
  temp = dic[C[i]]
  jisyo[C[i]] = temp
  #t.append(A.count(C[i]))
  if temp >=2:
    anst += temp*(temp-1)/2

#jisyo = dict(zip(C, t))
#print(jisyo)   
for i in range(N):
  #print(t[C.index(A[i])])
  print(int(anst-jisyo[A[i]]+1))

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

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  
  int i,sum = 0;
  for( i = 1 ; i <= n ; i++ ){
    int digit_sum = 0;
    int tmp = i;
    while( tmp != 0 ){
      digit_sum += tmp % 10;
      tmp /= 10;
    }
    if( a <= digit_sum && digit_sum <= b )	sum += i;
  }
  
  cout << sum << endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}

int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	
	int hm = m /2;
	int amx = hm + m%2;
	rep(i, amx){
		printf("%d %d\n", i+1, i+ 2*(amx-i));
	}
	int zs = 2*amx +1;
	rep(i, hm){
		printf("%d %d\n",zs+i, zs+i+ 2*(hm-i));
	}
	return 0;
}


Measured memory_bytes: 3732
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int a, b;
	cin >> a >> b;\
	if(a < b)
		swap(a,b);
	for(int i = 0; i < a; i++)
		cout << b;
	
	return 0;
}



Measured memory_bytes: 256
[n,t] = [int(i) for i in input().split()]
ts = [int(i) for i in input().split()]
ans = 0
for i in range(n-1):
    if ts[i+1] - ts[i] > t:
        ans += t
    else:
        ans += ts[i+1] - ts[i]
print(ans+t)


Measured memory_bytes: 103908
#include <bits/stdc++.h>
using namespace std;
int main(){
  
  int N;
  cin >> N;
  
  vector<int> cont(N);
  
  for(int i = 0 ; i < N ; i++){
    cin >> cont.at(i); 
  }
  
  sort(cont.begin() , cont.end());
  
  cout << cont.at(N/2) - cont.at(N/2 - 1) << endl;
  
}

Measured memory_bytes: 640
N = int(input())
lis = []
d1 = []
d2 = []
for i in range(N):
    x,y = map(int,input().split())
    lis.append([x,y])
    d1.append(x-y)
    d2.append(x+y)
ans = max(d1) - min(d1)
ans = max(ans,max(d2) - min(d2))
print(ans)



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

using namespace std;

int main(){
  int n,k,sum = -1;
  cin >> n >> k;
  int s[n+1];s[0] = 0;
  for(int i = 0;i < n;i++){
    int x;cin >> x;
    s[i+1] = s[i] + x;
  }
  for(int i = 0;i <= n-k;i++){
    sum = max(sum,s[i+k]-s[i]);
  }
  cout << fixed << setprecision(18);
  cout << (double)(sum + k)/2;
  return 0;
}

Measured memory_bytes: 1024
#include<cstdio>

int main() {
   
   int a,b;
   char op;
    while(1){
    scanf("%d %c %d",&a,&op,&b);
    if (op == '?') {
        break;
    }
    else if (op == '+'){
        printf("%d\n",a + b);
    } 
    else if(op == '-'){
        printf("%d\n",a - b);
    }
    else if(op == '*'){
        printf("%d\n",a * b);
    }
    else if(op == '/'){
        printf("%d\n",a / b);
    }
    }
}


Measured memory_bytes: 2740
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef long long int LL;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//---------------------------------------------------------------------------
bool color[200001];
//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n,k;cin>>n>>k;
    int ans=0;
    for(int i=1;i<=n;i+=2)ans++;
    if(ans>=k)cout<<"YES"<<Endl;
    else cout<<"NO"<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------

/*
ll n;cin>>n;
vector<ll>a(n);
for(ll i=0;i<n;i++)
    cin>>a[i];
 
ll n;cin>>s;
string s;cin>>s;

ll n,m;cin>>n>>m;
vector<ll>a(n),b(m);
for(ll i=0;i<n;i++){
    cin>>a[i];
}
for(ll i=0;i<m;i++){
    cin>>b[i];
}

ll n;cin>>n;
vector<Pll>xy;
for(ll i=0;i<n;i++){
    ll x,y;cin>>x>>y;
    xy.pb({x,y});
}
*/


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        if (x >= 400 && x <= 599) {
            System.out.println(8);
            return;
        }
        if (x <= 799) {
            System.out.println(7);
            return;
        }
        if (x <= 999) {
            System.out.println(6);
            return;
        }
        if (x <= 1199) {
            System.out.println(5);
            return;
        }
        if (x <=1399) {
            System.out.println(4);
            return;
        }
        if (x <= 1599) {
            System.out.println(3);
            return;
        }
        if (x <= 1799) {
            System.out.println(2);
            return;
        }
        if (x <= 1999) {
            System.out.println(1);
            return;
        }


    }

}

Measured memory_bytes: 35628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> Pair;
#define MM 1000000000
#define MOD MM+7
#define MAX 10000
#define MAP_SIZE 51
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int h, w;
char s[100][100];
int dist[100][100];
int shortest_load;

int bfs(){
    queue<Pair> que;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            dist[i][j] = MAX;
        }
    }
    que.push(Pair(0,0));
    dist[0][0] = 0;
    
    while(que.size()){
        Pair p = que.front();
        que.pop();
        if(p.first == w-1 && p.second == h-1) break;
        for(int i = 0; i < 4; i++){
            int nx = p.first + dx[i];
            int ny = p.second + dy[i];
            if(s[nx][ny] == '.' && dist[nx][ny] == MAX){
                que.push(Pair(nx,ny));
                dist[nx][ny] = dist[p.first][p.second]+1;
            }
        }
    }
    return dist[h-1][w-1];
}

int main(){
    scanf("%d %d", &h, &w);
    int sum_dot = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> s[i][j];
            if(s[i][j] == '.') sum_dot++;
        }
    }
    shortest_load = bfs();
    if(dist[h-1][w-1] == MAX){
        cout << -1 << endl;
        return 0;
    }
    ll ans;
    ans = sum_dot - (shortest_load + 1);
    cout << ans << endl;
}


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

int main(void){
    int n,d[256],baket[256]={0},result=0;
    cin >> n;
    
    for(int i=0;i<n;i++) cin >> d[i];
    
    for(int i=0;i<n;i++) baket[d[i]]++;

    for(int i=1;i<=100;i++){
        if(baket[i]){
            result++;
        } 
    }
    
    cout << result << endl;
    
    return 0;
}


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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

int main(){
//  ios::sync_with_stdio(false);
//  cin.tie(0);
  int n;
  cin >> n;
  int pre = -1;
  int ans = 0;
  REP(i,n) {
    int a;
    cin >> a;
    if (a >= pre) {
      pre = a;
      ans++;
    }
  }
cout << ans << endl;

  return 0;
}


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

long long int Min(long long int a, long long int b, long long int c) {
	if (a < b && a < c)return a;
	else if (b < a && b < c)return b;
	else return c;
}

int main(void)
{
	long long int q, h, s, d, n, lowest_s;
	long long int ans = 0;
	scanf("%lld %lld %lld %lld", &q, &h, &s, &d);
	scanf("%lld", &n);

	lowest_s = Min(4 * q, 2 * h, s);
	if (lowest_s * 2 > d) {
		ans += n / 2 * d;
		if (n % 2 == 1)ans += lowest_s;
	}
	else {
		ans += n * lowest_s;
	}
	printf("%lld\n", ans);
	return 0;
}


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

template<typename T>
class SegTree{
    const T identity_element = 0; // additive identity
    //const T identity_element = 1LL; // multiplicative identity
    //const T identity_element = numeric_limits<int>::max(); // identity element for min()
    //const T identity_element = -1e9; // identity element for max()
    //static const T mod = 1e9+7;
    static T combine(T L, T R){
        return (L + R);  // modify this code.
        //return (L * R) % mod;
        //return min(L, R);
        //return max(L, R);
    }
    size_t n;
    vector<T> data;
public:
    SegTree(size_t _n): n(_n), data(vector<T>(2 * _n, identity_element)) {}
    SegTree(const vector<T> &src): n(src.size()), data(2 * n, identity_element) {init(src);}
    void init(const vector<T> &src){
        for (size_t i = 0; i != n; ++i) data[n + i] = src[i];
        for (size_t i = n - 1; i != 0; --i) data[i] = combine(data[i<<1], data[i<<1|1]);
    }
    void modify(size_t i, T v){
        for (data[i += n] = v; i >>= 1; ) data[i] = combine(data[i<<1], data[i<<1|1]);
    }
    void add(size_t i, T v){
        modify(i, v + data[i + n]);
    }
    T query(size_t L, size_t R){
        T retL = identity_element;
        T retR = identity_element;
        for (L += n, R += n; L < R; L>>= 1, R >>= 1){
            if (L & 1) retL = combine(retL, data[L++]);
            if (R & 1) retR = combine(data[--R], retR);
        }
        return combine(retL, retR);
    }
};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, q;
    cin >> n >> q;
    SegTree<int> seg(n);
    while (q--){
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 0){
            seg.add(--x, y);
        }else{
            cout << seg.query(--x, y) << '\n';
        }
    }
    return 0;
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

class G {
public:
  vector<vector<int>> p, inv, sp, sinv;
  int n, m;
  vector<int> b, c, depth;
  vector<bool> a;

  G(int nn, vector<vector<int>> &np, vector<vector<int>> &ninv) {
    n = nn;
    p = np;
    inv = ninv;
    a.resize(n);
    c.resize(n);
    for (int i = 0; i < n; i++) {
      c[i] = -1;
    }
  }

  void dfs(int i) {
    if (a[i])
      return;
    a[i] = true;
    for (int j = 0; j < p[i].size(); j++) {
      if (a[p[i][j]]) {
        continue;
      }
      dfs(p[i][j]);
    }
    b.push_back(i);
  }

  void dfs2(int i, int id) {
    if (c[i] > -1)
      return;
    c[i] = id;
    for (int j = 0; j < inv[i].size(); j++) {
      if (c[inv[i][j]] > -1)
        continue;
      dfs2(inv[i][j], id);
    }
  }

  void solve() {
    for (int i = 0; i < n; i++) {
      dfs(i);
    }
    int j = 0;
    for (int i = n - 1; i >= 0; i--) {
      if (c[b[i]] > -1)
        continue;
      dfs2(b[i], j++);
    }
    m = j;
    sp.resize(m);
    sinv.resize(m);
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < p[i].size(); j++) {
        if (c[i] == c[p[i][j]])
          continue;
        sp[c[i]].push_back(c[p[i][j]]);
        sinv[c[p[i][j]]].push_back(c[i]);
      }
    }
  }
};

struct N {
  int i, f, d;
};

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> p(n), inv(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[a].push_back(b);
    inv[b].push_back(a);
  }
  G g(n, p, inv);
  g.solve();
  if (n == g.m) {
    cout << -1 << endl;
    return 0;
  }
  vector<bool> used(n);
  vector<int> par(n, -1);

  auto bfs = [&](int i) {
    queue<N> q;
    q.push(N{i, -1, 1});
    while (q.size()) {
      auto now = q.front();
      q.pop();
      if (used[now.i]) {
        continue;
      }
      used[now.i] = true;
      par[now.i] = now.f;
      map<int, int> mp;
      vector<int> buf;
      int k = now.i;
      int c = 0;
      while (par[k] >= 0) {
        mp[k] = c;
        buf.push_back(k);
        c++;
        k = par[k];
      }
      mp[i] = c;
      buf.push_back(i);
      c++;

      vector<int> ans;
      int anssize = n * 2;
      for (auto &j : p[now.i]) {
        if (used[j]) {
          if (mp.find(j) != mp.end()) {
            vector<int> b;
            for (int k = mp[j]; k >= 0; k--) {
              b.push_back(buf[k] + 1);
            }
            if (anssize > b.size()) {
              anssize = b.size();
              ans = b;
            }
          } else {
            continue;
          }
        }
        q.push(N{j, now.i, now.d + 1});
      }
      if (anssize < 2 * n) {
        cout << anssize << endl;
        for (auto j : ans) cout << j << endl;
        return true;
      }
    }
    return false;
  };

  for (int i = 0; i < n; i++) {
    if (used[i]) continue;
    if (bfs(i)) {
      return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


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

using namespace std;

int main()
{
    long long n,m,i,j,k,x,y,z;
    cin>>n>>k>>x>>y;
    if(n>k){
    m=(x*k);
    j=(n-k)*y;
    z=m+j;
    cout<<z<<endl;}
    else
    {
        z=n*x;
        cout<<z<<endl;
    }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main () {

    int a, b, c, x;

    cin >> a >> b >> c;

    if (a > b) {

        x = a;
        a = b;
        b = x;

    }

    if (b > c) {

        x = b;
        b = c;
        c = x;

    }

    if (a > b) {

        x = a;
        a = b;
        b = x;

    }

    cout << a << " " << b << " " << c << endl;

    return 0;

}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}
template<typename T,typename U>
ll FindErase(T &v,U tar){
  ll cnt = 0;
  for(auto it = v.begin(); it != v.end();){
    if(*it == tar){
      it = v.erase(it);
      ++cnt;
    }
    else{
      ++it;
    }
  }
  return cnt;
}

template<typename T>
bool SuffixErase(T &v,size_t suf){
  if(suf > v.size()) return false;
  for(auto it = v.begin(); it != v.end();){
    if(distance(v.begin(),it) == suf){
      v.erase(it);
      return true;
    }
    else{
      ++it;
    }
  }
  return false;
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  int l = 0,w = s.size(),r = w;
  bool f = false;
  while(w <= s.size()){
    l = 0,r = w;
    map<char,int> m;
    rep(i,r){
      m[s[i]]++;
    }
    while(r <= s.size()){
      rep(i,26){
        if(m['a'+i] > w/2){
          f = true;
          cout << l+1 << ' ' << r << endl;
          break;
        }
      }
      m[s[l]]--;
      m[s[r]]++;
      l++;
      r++;
      if(f) break;
    }
    if(f) break;
    w = w/2;
    if(w == 1) break;
  }
  if(!f) cout << -1 << ' '  << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
from collections import Counter
N,C=map(int,input().split())
D=[list(map(int,input().split())) for _ in range(C)]
c=[list(map(int,input().split())) for _ in range(N)]

c0=Counter([c[i][j] for i in range(N) for j in range(N) if (i+j)%3==0])
c1=Counter([c[i][j] for i in range(N) for j in range(N) if (i+j)%3==1])
c2=Counter([c[i][j] for i in range(N) for j in range(N) if (i+j)%3==2])

d0,d1,d2=dict(),dict(),dict()
for i in range(C):
	d0[i]=sum([c0[j+1]*D[j][i] for j in range(C)])
	d1[i]=sum([c1[j+1]*D[j][i] for j in range(C)])
	d2[i]=sum([c2[j+1]*D[j][i] for j in range(C)])

min_=10**9
for i in range(C):
	for j in range(C):
		for k in range(C):
			if i!=j and j!=k and k!=i:
				if min_>d0[i]+d1[j]+d2[k]:
					min_=d0[i]+d1[j]+d2[k]
print(min_)

Measured memory_bytes: 6652
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int a, b; cin >> a >> b;
    if (a > 9 || b > 9)
        cout << -1 << endl;
    else
        cout << a * b << endl;
    return 0;
}


Measured memory_bytes: 3644
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  st S;
  ci(S);
  ll a = 0;
  rep(bit, 1 << sz(S) - 1){
    ll c = 0;
    rep(i, sz(S) - 1){
      ll b = 0;
      if(bit >> i & 1 == 1){
        repi(j, c, i + 1){
          b *= 10;
          b += S.at(j) - 48;
          c = i + 1;
        }
      }
      a += b;
    }
    ll b = 0;
    repi(j, c, sz(S)){
      b *= 10;
      b += S.at(j) - 48;
    }
    a += b;
  }
  co(a);
}


Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *A = map(int, read().split())

    ans = 0
    while True:
        ok = True
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] //= 2
            else:
                ok = False
        if ok:
            ans += 1
        else:
            break

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9112
import operator as op
from functools import reduce

MOD = (10 ** 9) + 7

factors = [1, 1]
finv = [1, 1]
inv = [0, 1]

for i in range(2, 200010):
    factors.append(factors[i - 1] * i % MOD)
    inv.append(MOD - inv[MOD % i] * (MOD // i) % MOD)
    finv.append(finv[i - 1] * inv[i] % MOD)

def nck(n, k):
    if n < k or n < 0 or k < 0:
        return 0
    return factors[n] * (finv[k]  * finv[n - k] % MOD) % MOD

def ncr(n, r):
    if n < r or n < 0 or r < 0:
        return 0
    r = min(r, n-r)
    numer = reduce(op.mul, range(n, n-r, -1), 1)
    denom = reduce(op.mul, range(1, r+1), 1)
    return numer / denom

assert ncr(3, 4) == 0

def g(h, w, a, b):
    prev = [1] * w
    cur = [0] * w

    for i in range(h - 1):
        cur[0] = 1
        start = 0
        if i >= h - 1 - a:
            cur[b] = prev[b]
            start = b
        for j in range(start + 1, w):
            cur[j] = cur[j - 1] + prev[j]
            cur[j] = cur[j] % (1e9 + 7)
        prev, cur = cur, prev
    return prev[-1]

def f(H, W, A, B):
    count = 0
    x, y, a = H - A - 1, W + A - 2, A - 1
    for i in range(B, W): # bottom-left to top-right
        c1 = nck(x + i, i)
        c2 = nck(y - i, a)
        c = c1 * c2
        count += c
        count = count % MOD
    return int(count)

## assert f(4, 4, 0, 0) == 20
# assert f(4, 4, 2, 2) == 10
#assert f(2, 3, 1, 1) == 2
#assert f(10, 7, 3, 4) == 3570
#assert f(100000, 100000, 99999, 99999) == 1
#assert f(100000, 100000, 44444, 55555) == 738162020

H, W, A, B = map(int, input().split())
ans = f(H, W, A, B)
print(ans)


Measured memory_bytes: 81776
#include <cstring>
#include <cstdio>
#include <algorithm>

using namespace std;
const int MAXN = 510;
const char *c = "RGBY";
int _wno;

int n, m, d, a[MAXN][MAXN];

bool inside( int x, int y ) {
	return x >= 1 && y >= 1 && x <= n && y <= m;
}

void assign( int x, int y, int c ) {
	if( inside(x, y) ) a[x][y] = c;
}

void paint( int x, int y, int c ) {
	int d2 = d>>1;
	for( int i = 1; i <= d2; ++i )
		for( int j = d2; j > d2-i; --j ) {
			int i2 = d-i, j2 = d-j+1;
			assign( x+i-1, y+j-1, c );
			assign( x+i-1, y+j2-1, c );
			assign( x+i2-1, y+j-1, c );
			assign( x+i2-1, y+j2-1, c );
		}
}

void solve_even() {
	int d2 = d>>1;
	for( int i = 1; i <= n; i += d+d )
		for( int j = 1; j <= m; j += d+d )
			paint(i, j, 0);
	for( int i = d+1; i <= n; i += d+d )
		for( int j = d+1; j <= m; j += d+d )
			paint(i, j, 0);
	for( int i = 1; i <= n; i += d+d )
		for( int j = d+1; j <= m; j += d+d )
			paint(i, j, 1);
	for( int i = d+1; i <= n; i += d+d )
		for( int j = 1; j <= m; j += d+d )
			paint(i, j, 1);
	for( int i = 1-d2; i <= n; i += d+d )
		for( int j = 1-d2; j <= m; j += d+d )
			paint(i, j, 2);
	for( int i = 1+d2; i <= n; i += d+d )
		for( int j = 1+d2; j <= m; j += d+d )
			paint(i, j, 2);
	for( int i = 1-d2; i <= n; i += d+d )
		for( int j = 1+d2; j <= m; j += d+d )
			paint(i, j, 3);
	for( int i = 1+d2; i <= n; i += d+d )
		for( int j = 1-d2; j <= m; j += d+d )
			paint(i, j, 3);
}

void solve_odd() {
	for( int i = 1; i <= n; ++i )
		for( int j = 1; j <= m; ++j )
			a[i][j] = (i+j)&1;
}

int main() {
	_wno = scanf( "%d%d%d", &n, &m, &d );
	memset( a, -1, sizeof(a) );
	if( d & 1 ) solve_odd();
	else solve_even();
	for( int i = 1; i <= n; ++i, puts("") )
		for( int j = 1; j <= m; ++j )
			putchar( c[a[i][j]] );
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int cnt[10];
int main()
{
	int a,b,c;cin>>a>>b>>c;
	cnt[a]++;
	cnt[b]++;
	cnt[c]++;
	for(int i=0;i<9;i++)
		if(cnt[i]==2){
			puts("Yes");
			return 0;
		}
	puts("No");
}


Measured memory_bytes: 256
def main():
    import sys
    input=sys.stdin.readline
    n,x,y=map(int,input().split())
    x-=1
    y-=1
    ans=[0]*(n-1)
    for i in range(n-1):
        for j in range(i+1,n):
            d=min(j-i,abs(x-i)+abs(y-j)+1,abs(y-i)+abs(x-j)+1)
            ans[d-1]+=1
    for i in range(n-1):
        print(ans[i])

if __name__ == '__main__':
    main()

Measured memory_bytes: 45532
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	string s; cin >> s;
	int n = (int)s.size();

	int a = 0, b = 0, c = 0, d = 0;
	
	for (int i = 0; i < s.size(); i++) {
		if (i % 2 == 0 && s[i] == '1')b++;
		if (i % 2 == 1 && s[i] == '0')c++;
	}

	int ans = min(b + c, n-(b+c));
	cout << ans << endl;
}

Measured memory_bytes: 512
// Shift-JIS（シフトジス）

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

int main()
{
    string S, str;
    cin >> S;
    int former = stoi(S.substr(0, 2));
    int latter = stoi(S.substr(2, 2));
    bool flag = false;
    if (0 <= former && former <= 99 && 1 <= latter && latter <= 12)
    {
        str = "YYMM";
        flag = true;
    }
    if (1 <= former && former <= 12 && 0 <= latter && latter <= 99)
    {
        str = "MMYY";
        flag = true;
    }
    if (1 <= former && former <= 12 && 1 <= latter && latter <= 12)
    {
        str = "AMBIGUOUS";
        flag = true;
    }
    if (!flag)
    {
        str = "NA";
    }

    cout << str << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> vv;

int abs(int a){
  if(a>0) return a;
  return -a;
}

int main(){
  int n;
  cin >> n;
  vec a(n+2);
  rep1(i,n) cin >> a[i];
  a.push_back(0);
  int s = 0;
  rep1(i,n+1) s += abs(a[i] - a[i-1]);
  rep1(i,n){
    cout << s + abs(a[i-1]-a[i+1]) - abs(a[i-1]-a[i]) - abs(a[i]-a[i+1]) << endl;
  }
}

Measured memory_bytes: 1656
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	s, t := ReadString(), ReadString()
	dp := make([][]string, len(s)+1)
	for i := 0; i < len(s)+1; i++ {
		dp[i] = make([]string, len(t)+1)
	}
	for i := 1; i <= len(s); i++ {
		for j := 1; j <= len(t); j++ {
			dp[i][j] = dp[i-1][j]
			if len(dp[i][j]) < len(dp[i][j-1]) {
				dp[i][j] = dp[i][j-1]
			}
			if s[i-1] == t[j-1] && len(dp[i][j]) < len(dp[i-1][j-1])+1 {
				dp[i][j] = dp[i-1][j-1] + string([]byte{s[i-1]})
			}
		}
	}
	fmt.Println(dp[len(s)][len(t)])
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadString() (s string) { Scan(&s); return }


Measured memory_bytes: 1006816
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    int n;
    cin >> n;
    vector<i64> a(n + 1);
    i64 max_a = -1e10;
    int max_i = 0;
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        if (a[i] > max_a) {
            max_a = a[i];
            max_i = i;
        }
    }
    vector<int> res;
    i64 ans = 0;
    if (max_a < 0) {
        ans = max_a;
        for (int i = n; i > max_i; --i) {
            res.push_back(i);
        }
        for (int i = 1; i < max_i; ++i) {
            res.push_back(1);
        }
    } else {
        i64 sum[2] = {};
        for (int i = 1; i <= n; ++i) {
            sum[i & 1] += max(i64(0), a[i]);
        }
        ans = max(sum[0], sum[1]);
        if (sum[0] > sum[1]) {
            a.erase(begin(a) + 1);
            res.push_back(1);
        }
        if ((a.size() - 1) % 2 == 0) {
            res.push_back(a.size() - 1);
            a.pop_back();
        }
        int cnt = 0;
        for (int i = a.size() - 1; i >= 1; i -= 2) {
            if (a[i] < 0) {
                res.push_back(i);
                if (i == 1) {
                    res.push_back(1);
                }
                if (cnt == 0) {
                    res.push_back(i - 1);
                }
            } else {
                ++cnt;
            }
        }
        for (int i = 0; i < cnt - 1; ++i) {
            res.push_back(2);
        }
    }

    cout << ans << '\n';
    cout << res.size() << '\n';
    for (int x : res) {
        cout << x << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
def main():

    N = int(input())
    x = []
    y = []
    for _ in range(N):
        a, b = map(int, input().split())
        x.append(a)
        y.append(b)

    ans = 0
    for mv in [[1, 1], [1, -1], [-1, 1], [-1, -1]]:
        min_v = mv[0] * x[0] + mv[1] * y[0]
        for i in range(N):
            v = mv[0] * x[i] + mv[1] * y[i]
            ans = max(ans, v - min_v)
            min_v = min(min_v, v)
            # print(ans)
    return ans


if __name__ == '__main__':
    print(main())


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

    void solve() {
	    ll a, b;
	    cin >> a >> b;
	    ll cnt = a/b + !!(a%b);
	    cout << cnt << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    }


Measured memory_bytes: 256